Disable creation for default stock item on product save.

@param \Magento\CatalogInventory\Model\StockRegistry $subject
@param \Closure $proceed
@param string $productSku
@param \Magento\CatalogInventory\Api\Data\StockItemInterface $stockItem
@return int
508491
public function aroundUpdateStockItemBySku(
        \Magento\CatalogInventory\Model\StockRegistry $subject,
        \Closure $proceed,
        $productSku,
        \Magento\CatalogInventory\Api\Data\StockItemInterface $stockItem
    ) {
        $result = null;
        $stockId = $stockItem->getStockId();
        if ($stockId) {
            $result = $proceed($productSku, $stockItem);
        }
        return $result;
    }
568213
public function beforeDeleteById(
        \Magento\Customer\Api\CustomerRepositoryInterface $subject,
        $customerId
    ) {
        $this->deleteSnaps($customerId);
        $this->deleteChange($customerId);
        $result = [$customerId];
        return $result;
    }
1230835
public function aroundSendMessage(
        TransportInterface $subject,
        \Closure $proceed
    ) {
        $storeId = $this->registry->registry('transportBuilderPluginStoreId');
        if ($this->helper->isEnabled($storeId)) {
            try {
                $this->smtpTransportAdapter->send($subject, $storeId);

            } catch (\Exception $e) {
                $this->dataHelper->log("TransportPlugin send exception: " . $e->getMessage());
                return $proceed();
            }
        } else {
            return $proceed();
        }
    }
104705
protected function assertHaveProductMeasurementSalesUnit(string $productSku): void
    {
        $this->addProductMeasurementSalesUnitCheckToHeap($productSku);

        if (static::$productMeasurementSalesUnitHeap[$productSku]) {
            return;
        }

        throw new EntityNotFoundException(sprintf("Product measurement sales unit was not found for SKU '%s'", $productSku));
    }
751593
protected function setItemByProductData($productData, ApiItemInterface $item, $locale)
    {
        $productId = $this->getProductId($productData);

        /** @var Product $product */
        $product = $this->productRepository->find($productId);
        if (!$product) {
            throw new ProductNotFoundException(self::$productEntityName, $productId);
        }
        $item->setProduct($product);
        $translation = $product->getTranslation($locale);

        // when the product is not available in the current language choose the first translation you find
        // FIXME: should be changed when products have a language fallback
        // https://github.com/massiveart/POOL-ALPIN/issues/611
        if (is_null($translation)) {
            if (count($product->getTranslations()) > 0) {
                $translation = $product->getTranslations()[0];
            } else {
                throw new ProductException('Product ' . $product->getId() . ' has no translations!');
            }
        }

        $this->setItemSupplier($item, $product);

        $item->setName($translation->getName());
        $item->setDescription($translation->getLongDescription());
        $item->setNumber($product->getNumber());

        // set order unit
        if ($product->getOrderUnit()) {
            $item->setQuantityUnit($product->getOrderUnit()->getTranslation($locale)->getName());
        }

        // TODO: get tax from product https://github.com/massiveart/POOL-ALPIN/issues/1224
        $item->setTax(0);

        return $product;
    }
88937
public function getStockCount(string $productNumber) : int
    {
        Assert::that($productNumber)->minLength(1, 'The length of $productNumber has to be > 0');
        $product = $this->getDataProduct($productNumber);

        return (int)$product['stockCount'];
    }
76003
public function unstickSubjectAction(Subject $subject)
    {
        $forum = $subject->getCategory()->getForum();
        $this->checkAccess($forum);
        $this->manager->unstickSubject($subject);

        return new RedirectResponse(
            $this->generateUrl('claro_forum_subjects', array('category' => $subject->getCategory()->getId()))
        );
    }
374033
protected function addProductToProductHeap(SpyProduct $productEntity): void
    {
        if (static::$productHeapSize >= static::HEAP_LIMIT) {
            $this->clearProductHeap();
        }

        static::$productHeapSize++;
        static::$productHeap[$productEntity->getSku()] = [
            static::PRODUCT_CONCRETE_ID => $productEntity->getIdProduct(),
            static::PRODUCT_ABSTRACT_ID => $productEntity->getFkProductAbstract(),
        ];
    }
490913
public function aroundGetConfigurationDesignTheme(Design $subject, callable $proceed, ...$args)
    {
        $forceLuma = $this->scopeConfig->getValue(self::CONFIG_PATH_FORCE_LUMA_CHECKOUT, ScopeInterface::SCOPE_STORE);
        if ($forceLuma &&
            $this->httpRequest->getModuleName() === 'checkout' &&
            $this->httpRequest->getControllerName() === 'index') {
            return $this->getLumaThemeId();
        }
        return $proceed(...$args);
    }
939241
public function updateSimplePurchasableStock(
        PurchasableInterface $purchasable,
        $stockToDecrease
    ) {
        $stock = $purchasable->getStock();
        if (
            $stock === ElcodiProductStock::INFINITE_STOCK ||
            $stockToDecrease <= 0 ||
            $stock <= 0
        ) {
            return false;
        }

        $realStockToDecrease = min($stock, $stockToDecrease);
        $resultingStock = $stock - $realStockToDecrease;
        $purchasable->setStock($resultingStock);

        return $realStockToDecrease;
    }
613502
public function getProductsCollectionBySku($productsSku, $limit = false)
    {
        $productCollection = [];

        if (! empty($productsSku)) {
            $productCollection = $this->productFactory->create()
                ->getCollection()
                ->addAttributeToSelect(
                    ['product_url', 'name', 'store_id', 'small_image', 'price', 'visibility']
                )->addFieldToFilter('sku', ['in' => $productsSku]);

            if ($limit) {
                $productCollection->getSelect()->limit($limit);
            }
        }

        return $productCollection;
    }
1149369
public function updateGalleryItemAction(Request $request, GalleryItem $entity, Product $product)
    {
        $em = $this->getDoctrine()->getManager();

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find GalleryItem entity.');
        }

        $deleteForm = $this->createDeleteGalleryItemForm($entity->getId());
        $editForm = $this->createEditGalleryItemForm($entity, $product);
        $editForm->handleRequest($request);

        if ($editForm->isValid()) {
            $em->flush();

            return $this->redirect($this->generateUrl('admin_product_show', array('id' => $product->getId())));
        }

        return array(
            'entity' => $entity,
            'product' => $product,
            'edit_form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }
990247
public function afterExecute(Action $subject, $result)
    {
        // Get the code id from the original request
        $codeId = $subject->getRequest()->getParam('code_id');

        // Access protected checkoutSession property with a Closure proxy
        $getQuoteProxy = function () use ($subject) {
            return $subject->checkoutSession->create()->getQuote();
        };
        $quote = $getQuoteProxy->call($subject);

        // Remove Amasty Gift Cart from the parent (session) quote
        $this->discountHelper->removeAmastyGiftCard($codeId, $quote);

        // Access protected updateTotalsInQuote method with a Closure proxy
        $updateTotalsInQuoteProxy = function () use ($subject, $quote) {
            $subject->updateTotalsInQuote($quote);
        };
        $updateTotalsInQuoteProxy->call($subject);

        return $result;
    }
42466
public function updateAction(StockLevel $stocklevel, Request $request)
    {
        $editForm = $this->createForm(new StockLevelType(), $stocklevel, array(
            'action' => $this->generateUrl('stock_stocklevel_update', array('id' => $stocklevel->getid())),
            'method' => 'PUT',
        ));
        if ($editForm->handleRequest($request)->isValid()) {
            $this->getDoctrine()->getManager()->flush();

            return $this->redirect($this->generateUrl('stock_stocklevel_show', array('id' => $stocklevel->getId())));
        }
        $deleteForm = $this->createDeleteForm($stocklevel->getId(), 'stock_stocklevel_delete');

        return array(
            'stocklevel' => $stocklevel,
            'edit_form'   => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }
845401
public function processStockMessage(array $stock, $store_id = 0) {
    // Sanity check.
    if (!isset($stock['sku']) || !strlen($stock['sku'])) {
      $this->logger->error('Invalid or empty product SKU. Stock message: @message', [
        '@message' => json_encode($stock),
      ]);

      return;
    }

    $langcode = NULL;

    if (empty($store_id) && isset($stock['store_id'])) {
      $store_id = $stock['store_id'];
    }

    // Check for stock is valid for current site.
    // If store id not available, we consider it as valid message.
    if ($store_id) {
      $langcode = $this->i18nHelper->getLangcodeFromStoreId($store_id);

      if (empty($langcode)) {
        // It could be for a different store/website, don't do anything.
        $this->logger->info('Ignored stock message for different store. Message: @message', [
          '@message' => json_encode($stock),
        ]);

        return;
      }
    }

    // We get qty in product data and quantity in stock push or from stock api.
    $quantity = array_key_exists('qty', $stock) ? $stock['qty'] : $stock['quantity'];
    $stock_status = isset($stock['is_in_stock']) ? (int) $stock['is_in_stock'] : 1;

    $changed = $this->updateStock($stock['sku'], $quantity, $stock_status);

    $this->logger->info('@operation stock for sku @sku. Message: @message', [
      '@operation' => $changed ? 'Updated' : 'Processed',
      '@sku' => $stock['sku'],
      '@message' => json_encode($stock),
    ]);
  }
808499
public function reduceProductStock($productId, $quantity, array $skuInfo = null)
    {
        $result = $this->httpRaw(self::WECHAT_SHOP_PRODUCT_STOCK_REDUCE_URL . 'access_token=' . $this->getAccessToken(), [
            'product_id' => $productId,
            'quantity' => $quantity,
            'sku_info' => $skuInfo === null ? $skuInfo : implode(':', $skuInfo)
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'success';
    }
170257
public function revert(PromotionSubjectInterface $subject, array $configuration, PromotionInterface $promotion): void
    {
        if (!$subject instanceof OrderInterface && !$subject instanceof OrderItemInterface) {
            throw new UnexpectedTypeException(
                $subject,
                'Sylius\Component\Core\Model\OrderInterface or Sylius\Component\Core\Model\OrderItemInterface'
            );
        }

        foreach ($subject->getAdjustments(AdjustmentInterface::ORDER_SHIPPING_PROMOTION_ADJUSTMENT) as $adjustment) {
            if ($promotion->getCode() === $adjustment->getOriginCode()) {
                $subject->removeAdjustment($adjustment);
            }
        }
    }