Adds the main product data to the search index
@param array $product
@return boolean
962863
protected function indexProduct(array $product)
    {
        $snippet = $this->search->getSnippet($product, 'und');
        return $this->search->setIndex($snippet, 'product', $product['product_id'], 'und');
    }
983391
public function post(array $products) {
    $storeId = '';
    $requestHeaders = $this->currentRequest->headers;
    if ($requestHeaders->has('X-ACM-UUID')) {
      $storeId = $requestHeaders->get('X-ACM-UUID');
    }

    \Drupal::logger('acm_sku')->info("Updating products for acm_uuid " . $storeId . ".");

    // To avoid even E_RECOVERABLE_ERROR, we set our custom error handler.
    set_error_handler([$this, 'errorHandler']);

    $response = $this->productManager->synchronizeProducts($products, $storeId);
    return (new ModifiedResourceResponse($response));
  }
228332
public function stockIncreaseAction(Product $product)
    {
        $em = $this->getDoctrine()->getManager();
        $warehouses = $em->getRepository(Warehouse::class)->findAll();
        return array(
            'warehouses' => $warehouses,
            'product' => $product,
        );
    }
667753
public function can_load( $product ) {
		if ( $this->is_from_partner( $product ) ) {
			return false;
		}
		if ( $product->is_theme() && ( false !== get_transient( 'ti_sdk_pause_' . $product->get_key(), false ) ) ) {
			return false;
		}

		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
			return true;
		}
		global $pagenow;

		if ( ! isset( $pagenow ) || empty( $pagenow ) ) {
			return false;
		}

		if ( $product->is_plugin() && 'plugins.php' !== $pagenow ) {
			return false;

		}
		if ( $product->is_theme() && 'theme-install.php' !== $pagenow ) {
			return false;
		}

		return true;
	}
924198
public function product(array $condition, array $data)
    {
        $is_product = (int) isset($data['product_id']);
        $value = (int) filter_var(reset($condition['value']), FILTER_VALIDATE_BOOLEAN);
        return $this->compare($is_product, $value, $condition['operator']);
    }
201703
protected function getTotalReviewsProduct(array $product)
    {
        $options = array(
            'status' => 1,
            'count' => true,
            'user_status' => 1,
            'product_id' => $product['product_id']
        );

        return (int) $this->review->getList($options);
    }
1110025
public function addProduct(\Gpupo\CommonSchema\ORM\Entity\Trading\Order\Shipping\Product\Product $product)
    {
        $this->products[] = $product;

        return $this;
    }
636348
public function addProductsInfo(array $productsInfo): self
    {
        foreach ($productsInfo as $title => $value) {
            $this->productInfo[] = [
                'title' => $title,
                'value' => $value,
            ];
        }

        return $this;
    }
909668
public function copyAction(Product $product)
    {


        $productCopy = new Product();
        $copyName = $this->get('translator')->trans('Copy of') . " " . $product->getName();
        $productCopy->setName($copyName);

        $productCopy->setCostPrice($product->getCostPrice());
        $productCopy->setDescription($product->getDescription()??$copyName);
        $productCopy->setCode($product->getCode());
        $productCopy->setImage($product->getImage());
        $productCopy->setPlace($product->getPlace());
        $productCopy->setSalePrice($product->getSalePrice());
        $productCopy->setSupplier($product->getSupplier());
        $productCopy->setWarehouse($product->getWarehouse());

        // boleans
        $productCopy->setEnabled($product->getEnabled());
        $productCopy->setForSale($product->getForSale());
        $productCopy->setCompositionOnDemand($product->isCompositionOnDemand());
        $productCopy->setPack($product->isPack());
        $productCopy->setManualPackPricing($product->isManualPackPricing());
        $productCopy->setRawMaterial($product->getRawMaterial());

        $em = $this->getDoctrine()->getManager();
        $em->persist($productCopy);

        // relations

        /* @var ProductRawMaterial $rawMaterial */
        foreach ($product->getRawMaterials() as $rawMaterial) {
            $rawMaterialCopy = new ProductRawMaterial();
            $rawMaterialCopy->setRawMaterial($rawMaterial->getRawMaterial());
            $rawMaterialCopy->setProduct($productCopy);
            $rawMaterialCopy->setMeasureUnit($rawMaterial->getMeasureUnit());
            $rawMaterialCopy->setQuantity($rawMaterial->getQuantity());

            $em->persist($rawMaterialCopy);

            $productCopy->addRawMaterial($rawMaterialCopy);

        }

        /* @var ProductCategory $category */
        foreach ($product->getCategories() as $category) {
            $productCopy->addCategory($category);
        }

        /* @var ProductCustomField $customField */
        foreach ($product->getCustomFields() as $customField) {
            $customFieldCopy = new ProductCustomField();
            $customFieldCopy->setProduct($productCopy);
            $customFieldCopy->setSettingField($customField->getSettingField());
            $customFieldCopy->setValue($customField->getValue());

            $em->persist($customFieldCopy);

            $productCopy->addCustomField($customFieldCopy);
        }

        $em->flush();


        return $this->redirect($this->generateUrl('product_show', array("id" => $productCopy->getId())));
    }
954827
protected function setIds(array $product)
    {
        $this->setLastEntityId(isset($product[MemberNames::ENTITY_ID]) ? $product[MemberNames::ENTITY_ID] : null);
    }
268138
public static function addDefaultUserAgentProduct($product, $version = null, $comment = null)
    {
        self::$defaultUserAgentProducts[] = array($product, $version, $comment);
    }
459633
public function persistProduct($product, $name = null)
    {

        // persist the new entity and return the ID
        $id = $this->getProductAction()->persist($product, $name);

        // add the product to the cache, register the SKU reference as well
        $this->getProductRepository()->toCache($product[MemberNames::SKU], $product, array($product[MemberNames::SKU] => $id));

        // return the ID of the persisted product
        return $id;
    }
384656
private function addProductData($data)
    {
        $product = $data['product'];

        $productData = [
            'title' => $product->getName(),
            'image' => $this->getImageUrl($product),
            'url'   => $product->getProductUrl(),
            'price' => $this->renderProductPrice($product, \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE),
        ];

        foreach ($this->attributes as $attributeCode) {
            if ($product->hasData($attributeCode)) {
                $productData[$attributeCode] = $product->getData($attributeCode);
                if ($product->getResource()->getAttribute($attributeCode)->usesSource()) {
                    $productData[$attributeCode] = $product->getAttributeText($attributeCode);
                }
            }
        }

        $data = array_merge($data, $productData);

        return $data;
    }
211775
public function addimageAction(Product $product)
    {
        $gallery = $product->getMediaGallery();
        $entity = new GalleryItem();
        $entity->setGallery($gallery);
        $position = $gallery->getGalleryItems()->count();
        $entity->setPosition($position);

        $form = $this->createForm($this->get("amulen.shop.form.product.gallery"), $entity, array(
            'action' => $this->generateUrl('admin_product_gallery_item_create', array('id' => $product->getId())),
            'method' => 'POST',
        ));
        $form->add('submit', 'submit', array('label' => 'Create'));

        return array(
            'entity' => $entity,
            'product' => $product,
            'form' => $form->createView(),
        );
    }
706991
protected function addOptions(array $data)
    {
        if (empty($data['combination'])) {
            return false;
        }

        foreach ($data['combination'] as $combination) {

            if (empty($combination['fields'])) {
                continue;
            }

            foreach ($combination['fields'] as $field_id => $field_value_id) {

                $options = array(
                    'type' => 'option',
                    'field_id' => $field_id,
                    'product_id' => $data['product_id'],
                    'field_value_id' => $field_value_id
                );

                $this->product_field->add($options);
            }
        }

        return true;
    }
443389
public function create(Product &$product)
    {
        $data = $product->exportData();
        $endpoint = '/admin/products.json';
        $response = $this->request(
            $endpoint, 'POST', array(
            'product' => $data
            )
        );
        $product->setData($response['product']);
    }
1028177
private function setSeoData($product)
    {
        $view = $this->view;
        $titleTemplateSetting = 'seo-title-template-' . Yii::$app->language;
        $descriptionTemplateSetting = 'seo-description-template-' . Yii::$app->language;

        if(!empty($product->translation->seoTitle)) {
            $title = $product->translation->seoTitle;
        }
        else if (Yii::$app->has('settings')
            && Yii::$app->settings->has('shop-product', $titleTemplateSetting)
            && !empty(Yii::$app->settings->get('shop-product', $titleTemplateSetting))) {
            $titleTemplate = Yii::$app->settings->get('shop-product', $titleTemplateSetting);
            $title = strtr($titleTemplate, [
                '{title}' => $product->translation->title
            ]);
        }
        else {
            $title = $product->translation->title;
        }

        if(!empty($product->translation->seoDescription)) {
            $description = $product->translation->seoDescription;
        }
        else if (Yii::$app->has('settings')
            && Yii::$app->settings->has('shop-product', $descriptionTemplateSetting)
            && !empty(Yii::$app->settings->get('shop-product', $descriptionTemplateSetting))) {
            $descriptionTemplate = Yii::$app->settings->get('shop-product', $descriptionTemplateSetting);
            $description = strtr($descriptionTemplate, [
                '{title}' => $product->translation->title
            ]);
        }
        else {
            $description = '';
        }

        $view->title = strip_tags(html_entity_decode($title));
        $view->registerMetaTag([
            'name' => 'description',
            'content' => strip_tags(html_entity_decode($description)) ?? ''
        ]);
        $view->registerMetaTag([
            'name' => 'keywords',
            'content' => strip_tags(html_entity_decode($product->translation->seoKeywords)) ?? ''
        ]);
    }