@param string $productSku

@throws \Spryker\Zed\DataImport\Business\Exception\EntityNotFoundException

@return void
17805
protected function addProductToProductHeapBySku(string $productSku): void
    {
        if (isset(static::$productHeap[$productSku])) {
            return;
        }

        $productEntity = $this->getProductQuery()
            ->filterBySku($productSku)
            ->findOne();

        if ($productEntity === null) {
            throw new EntityNotFoundException(sprintf("Product concrete with SKU '%s' was not found", $productSku));
        }

        $this->addProductToProductHeap($productEntity);
    }
705217
public function execute(DataSetInterface $dataSet): void
    {
        $sku = $dataSet[ShoppingListItemDataSetInterface::COLUMN_PRODUCT_SKU];
        if (!isset($this->productConcreteSkuCache[$sku])) {
            $productQuery = SpyProductQuery::create();
            $idProduct = $productQuery
                ->select([SpyProductTableMap::COL_ID_PRODUCT])
                ->findOneBySku($sku);

            if (!$idProduct) {
                throw new EntityNotFoundException(sprintf('Could not find product concrete by SKU "%s"', $sku));
            }

            $this->productConcreteSkuCache[$sku] = $idProduct;
        }
    }
302941
protected function indexActionInternal($entities): void {
        $objects = [];
        foreach($entities as $entity) {
            $objects[] = $this->generateEntityAction($entity);
        }
        $outputObject = $this->getOutputObject();
        $blankEntity = $this->generateEntity();
        $outputObject->{$blankEntity->getEntityName() . 's'} = $objects;

        $this->setOutputObject($outputObject);
    }
829914
public function setModel($itemModel, $relations = [])
    {
        if (!class_exists($itemModel)) {
            throw new ModelNotFound('Could not find relation model');
        }

        $this->itemModel = $itemModel;
        $this->itemModelRelations = $relations;
    }
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;
    }
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(),
        );
    }
225547
protected function doAddProductCategory($productCategory)
    {
        parent::doAddProductCategory($productCategory);

        $productCategoryPosition = ProductCategoryQuery::create()
            ->filterByCategoryId($productCategory->getCategoryId())
            ->orderByPosition(Criteria::DESC)
            ->findOne();

        $productCategory->setPosition($productCategoryPosition !== null ? $productCategoryPosition->getPosition() + 1 : 1);
    }
854847
public function setDeliveryStatusForProduct($product, $statusId)
    {
        $status = $this->deliveryStatusRepository->find($statusId);
        if (!$status) {
            throw new ProductDependencyNotFoundException(self::$productStatusEntityName, $statusId);
        }
        $product->setDeliveryStatus($status);
    }
626885
public function mapSkuToEntityId($sku)
    {

        // query weather or not the SKU has been mapped
        if (isset($this->skuEntityIdMapping[$sku])) {
            return $this->skuEntityIdMapping[$sku];
        }

        // throw an exception if the SKU has not been mapped yet
        throw new MapSkuToEntityIdException(
            $this->appendExceptionSuffix(
                sprintf('Found not mapped entity ID for SKU %s', $sku)
            )
        );
    }
848979
public function execute(DataSetInterface $dataSet): void
    {
        $shoppingListKey = $dataSet[ShoppingListItemDataSetInterface::COLUMN_SHOPPING_LIST_KEY];

        if (!isset($this->idShoppingListCache[$shoppingListKey])) {
            $shoppingListQuery = new SpyShoppingListQuery();
            $idShoppingList = $shoppingListQuery
                ->select([SpyShoppingListTableMap::COL_ID_SHOPPING_LIST])
                ->findOneByKey($shoppingListKey);

            if (!$idShoppingList) {
                throw new EntityNotFoundException(sprintf('Could not find shopping list by key "%s"', $shoppingListKey));
            }

            $this->idShoppingListCache[$shoppingListKey] = $idShoppingList;
        }

        $dataSet[ShoppingListItemDataSetInterface::ID_SHOPPING_LIST] = $this->idShoppingListCache[$shoppingListKey];
    }
1299662
public function addProduct(\Sulu\Bundle\ProductBundle\Entity\ProductInterface $products)
    {
        $this->products[] = $products;

        return $this;
    }
727882
public function editProduct($product_id = null)
    {
        $this->setProduct($product_id);
        $this->setTitleEditProduct();
        $this->setBreadcrumbEditProduct();

        $this->setData('product', $this->data_product);
        $this->setData('size_units', $this->convertor->getUnitNames('size'));
        $this->setData('weight_units', $this->convertor->getUnitNames('weight'));
        $this->setData('default_currency', $this->currency->getDefault());
        $this->setData('subtract_default', $this->config->get('product_subtract', 0));
        $this->setData('classes', $this->product_class->getList(array('status' => 1)));
        $this->setData('languages', $this->language->getList(array('enabled' => true)));

        $this->submitEditProduct();

        $this->setDataFieldsEditProduct();
        $this->setDataAuthorEditProduct();
        $this->setDataRelatedEditProduct();
        $this->setDataCategoriesEditProduct();
        $this->setDataImagesEditProduct();

        $this->setJsEditProduct();
        $this->outputEditProduct();
    }
759027
protected function resolveIdProductByConcreteSku(string $sku): int
    {
        if (!isset($this->idProductCache[$sku])) {
            $productEntity = SpyProductQuery::create()
                ->findOneBySku($sku);

            if (!$productEntity) {
                throw new EntityNotFoundException(sprintf('Concrete product by sku "%s" not found.', $sku));
            }

            $this->idProductCache[$sku] = $productEntity->getIdProduct();
        }

        return $this->idProductCache[$sku];
    }
569637
public function execute(DataSetInterface $dataSet): void
    {
        $companyBusinessUnitKey = $dataSet[ShoppingListCompanyBusinessUnitDataSetInterface::COLUMN_COMPANY_BUSINESS_UNIT_KEY];
        if (!isset($this->idCompanyBusinessUnitCache[$companyBusinessUnitKey])) {
            $companyBusinessUnitQuery = new SpyCompanyBusinessUnitQuery();
            $idCompanyUser = $companyBusinessUnitQuery
                ->select([SpyCompanyBusinessUnitTableMap::COL_ID_COMPANY_BUSINESS_UNIT])
                ->findOneByKey($companyBusinessUnitKey);

            if (!$idCompanyUser) {
                throw new EntityNotFoundException(sprintf('Could not find company business unit by key "%s"', $companyBusinessUnitKey));
            }

            $this->idCompanyBusinessUnitCache[$companyBusinessUnitKey] = $idCompanyUser;
        }

        $dataSet[ShoppingListCompanyBusinessUnitDataSetInterface::ID_COMPANY_BUSINESS_UNIT] = $this->idCompanyBusinessUnitCache[$companyBusinessUnitKey];
    }
954477
protected function addAlternativeProductAbstractId(DataSetInterface $dataSet): void
    {
        $productAlternativeSku = $dataSet[ProductAlternativeDataSetInterface::KEY_COLUMN_ALTERNATIVE_PRODUCT_ABSTRACT_SKU];

        if (!isset($this->idProductAbstractCache[$productAlternativeSku])) {
            /** @var \Orm\Zed\Product\Persistence\SpyProductAbstract|null $productAbstractEntity */
            $productAbstractEntity = SpyProductAbstractQuery::create()->findOneBySku($productAlternativeSku);
            if (!$productAbstractEntity) {
                throw new EntityNotFoundException(
                    sprintf(
                        'Could not find product by sku "%s"',
                        $productAlternativeSku
                    )
                );
            }

            $this->idProductAbstractCache[$productAlternativeSku] = $productAbstractEntity->getIdProductAbstract();
        }
        $dataSet[ProductAlternativeDataSetInterface::FK_PRODUCT_ABSTRACT_ALTERNATIVE] = $this->idProductAbstractCache[$productAlternativeSku];
    }
1153477
public function newAction($featureId)
    {
        $em = $this->getDoctrine()->getManager();

        /** @var Feature $feature */
        $feature = $em->getRepository('EcommerceBundle:Feature')->find($featureId);

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

        $entity = new FeatureValue();
        $form   = $this->createForm(new FeatureValueType(), $entity);

        return array(
            'entity'      => $entity,
            'feature'   => $feature,
            'form'        => $form->createView(),
        );
    }
1252533
protected function process()
    {

        // prepare the product link entity
        if ($attr = $this->prepareAttributes()) {
            // initialize the product link entity
            $productLink = $this->initializeProductLink($attr);

            // persist the product link entity and store the link ID
            $this->setLastLinkId($this->persistProductLink($productLink));
        }
    }