Adds product translations to the search index
@param array $product
@return boolean
170583
protected function indexProductTranslations(array $product)
    {
        if (empty($product['translation'])) {
            return false;
        }

        $indexed = 0;

        foreach ($product['translation'] as $language => $translation) {
            $translation += $product;
            $snippet = $this->search->getSnippet($translation, $language);
            $indexed += (int) $this->search->setIndex($snippet, 'product', $product['product_id'], $language);
        }

        return $indexed > 0;
    }
912209
protected function setIds(array $product)
    {

        // pass the product to the parent method
        parent::setIds($product);

        // temporarily persist the row ID
        $this->setLastRowId($product[MemberNames::ROW_ID]);
    }
1284402
private function removeDefaultPrices(Product $product)
    {
        $defaultPrices = [];

        // get default prices
        foreach ($product->getPrices() as $price) {
            if ($price->getId() === null) {
                $defaultPrices[] = $price;
            }
        }

        foreach ($defaultPrices as $price) {
            $product->removePrice($price->getEntity());
        }
    }
546039
protected function reindexProductsCompare(array $products)
    {
        $prepared = array();

        foreach ($products as $product_id => $product) {
            $prepared[$product['product_class_id']][$product_id] = $product;
        }

        return $prepared;
    }
660424
public function addTranslatableField(array $field)
	{
		$currFields = $this->getTranslatableFields();

		$this->setTranslatableFields(array_merge($currFields, $field));
	
		return $this;
	}
888294
public function index($product)
    {
        if (is_numeric($product)) {
            $product = $this->product->get($product);
        }

        if (empty($product)) {
            return false;
        }

        $indexed = 0;
        $indexed += (int) $this->indexProduct($product);
        $indexed += (int) $this->indexProductTranslations($product);

        return $indexed > 0;
    }
25915
protected function attachFields(array &$product)
    {
        if (empty($product)) {
            return $product;
        }

        $product['field'] = $this->product_field->getList($product['product_id']);

        if (empty($product['field']['option'])) {
            return $product;
        }

        foreach ($product['field']['option'] as &$field_values) {
            $field_values = array_unique($field_values);
        }

        return $product;
    }
867028
public function can_load( $product ) {
		if ( $this->is_from_partner( $product ) ) {
			return false;
		}
		if ( ! $product->is_wordpress_available() ) {
			return false;
		}

		$lang = $this->get_user_locale();

		if ( 'en_US' === $lang ) {
			return false;
		}

		$languages = $this->get_translations( $product );

		if ( ! is_array( $languages ) ) {
			return false;
		}

		if ( ! isset( $languages['translations'] ) ) {
			return false;
		}

		$languages = $languages['translations'];

		$available = wp_list_pluck( $languages, 'language' );

		if ( in_array( $lang, $available ) ) {
			return false;
		}

		if ( ! isset( self::$locales[ $lang ] ) ) {
			return false;
		}

		return apply_filters( $product->get_slug() . '_sdk_enable_translate', true );
	}
340277
public function updateTranslations(array $values)
    {
        $array = [];

        foreach ($values as $lang => $data) {
            $array['locale'] = $lang;

            foreach ($this->translatedAttributes as $key => $attribute) {
                $array[$attribute] = isset($values[$lang][$attribute]) ? $values[$lang][$attribute] : '';
            }

            $translation = $this->translations()->where('locale', $lang)->first();

            // Make sure we can translate Stapler files as well
            $staplerConfig = (array)object_get(new $this->translationModel(), 'staplerConfig', []);
            $staplerFields = array_keys($staplerConfig);
            foreach ($staplerFields as $staplerField) {
                $array = collect($array)->filter(function ($value, $key) use ($staplerField) {

                    $removable = [
                        $staplerField . '_file_name',
                        $staplerField . '_file_size',
                        $staplerField . '_content_type',
                        $staplerField . '_updated_at'
                    ];

                    if (in_array($key, $removable)) {
                        return false;
                    }

                    return true;
                })->toArray();
            }

            if (! $translation) {
                $this->translations()->create($array);
            } else {
                $translation->update($array);
            }
        }
    }
146679
public function add(array $data)
    {
        $result = null;
        $this->hook->attach('product.add.before', $data, $result, $this);

        if (isset($result)) {
            return (int) $result;
        }

        $data['created'] = $data['modified'] = GC_TIME;
        $data += array('currency' => $this->config->get('currency', 'USD'));

        $this->setPrice($data);

        $result = $data['product_id'] = $this->db->insert('product', $data);

        $this->setTranslations($data, $this->translation_entity, 'product', false);
        $this->setImages($data, $this->file, 'product');

        $this->setSku($data, false);
        $this->setSkuCombinations($data, false);
        $this->setOptions($data, false);
        $this->setAttributes($data, false);
        $this->setAlias($data, $this->alias, 'product', false);
        $this->setRelated($data, false);

        $this->search->index('product', $data);
        $this->hook->attach('product.add.after', $data, $result, $this);
        return (int) $result;
    }
1057519
public function addProduct($product = array())
    {
        if (!is_array($product)) {
            $this->errorMessage[] = 'PRODUCT: Not a valid product!';
        }
        foreach ($this->productFields as $field) {
            if (array_key_exists($field, $product)) {
                $add[$field] = $this->cleanString($product[$field]);
            } elseif (!array_key_exists($field, $product)) {
                $add[$field] = ' ';
                $this->debugMessage[] = 'Missing product field: ' . $field;
            }
        }
        $this->products[] = $add;
    }
1235902
protected function setSkuCombinationProduct(array &$product)
    {
        if (!empty($product['combination'])) {
            foreach ($product['combination'] as &$combination) {

                $combination['path'] = $combination['thumb'] = '';

                if (!empty($product['images'][$combination['file_id']])) {
                    $combination['path'] = $product['images'][$combination['file_id']]['path'];
                    $this->setItemThumb($combination, $this->image);
                }

                $combination['price'] = $this->price->decimal($combination['price'], $product['currency']);
            }
        }
    }
36930
public function setProduct($product)
    {
        $this->setSku($product->getSku());
        $this->setName($product->getName());

        return $this;
    }
478234
public function update(Product &$product)
    {
        $data = $product->exportData();
        $endpoint = '/admin/products/'.$product->id.'.json';
        $response = $this->request(
            $endpoint, 'PUT', array(
            'product' => $data
            )
        );
        $product->setData($response['product']);
    }
1105089
public function getAddToOrder(Models\Product $product)
    {
        return $this->getTrackPayload(ActionTypes::ADDED_TO_ORDER, [
            PayloadProperties::PROPERTIES =>
                [
                    [
                        PayloadProperties::PRODUCT => $product->toArray()
                    ]
                ]
        ]);
    }
971689
protected function _addItems($products)
    {
        $activeView = \OxidEsales\Eshop\Core\Registry::getConfig()->getActiveView();
        $errorDestination = $activeView->getErrorDestination();

        $basket = $this->getSession()->getBasket();
        $basketInfo = $basket->getBasketSummary();

        $basketItemAmounts = [];

        foreach ($products as $addProductId => $productInfo) {
            $data = $this->prepareProductInformation($addProductId, $productInfo);
            $productAmount = 0;
            if (isset($basketInfo->aArticles[$data['id']])) {
                $productAmount = $basketInfo->aArticles[$data['id']];
            }
            $products[$addProductId]['oldam'] = $productAmount;

            //If we already changed articles so they now exactly match existing ones,
            //we need to make sure we get the amounts correct
            if (isset($basketItemAmounts[$data['oldBasketItemId']])) {
                $data['amount'] = $data['amount'] + $basketItemAmounts[$data['oldBasketItemId']];
            }

            $basketItem = $this->addItemToBasket($basket, $data, $errorDestination);

            if (($basketItem instanceof \OxidEsales\Eshop\Application\Model\BasketItem)) {
                $basketItemKey = $basketItem->getBasketItemKey();
                if ($basketItemKey) {
                    if (! isset($basketItemAmounts[$basketItemKey])) {
                        $basketItemAmounts[$basketItemKey] = 0;
                    }
                    $basketItemAmounts[$basketItemKey] += $data['amount'];
                }
            }

            if (!$basketItem) {
                $info = $basket->getBasketSummary();
                $productAmount = $info->aArticles[$data['id']];
                $products[$addProductId]['am'] = isset($productAmount) ? $productAmount : 0;
            }
        }

        //if basket empty remove possible gift card
        if ($basket->getProductsCount() == 0) {
            $basket->setCardId(null);
        }

        // information that last call was tobasket
        $this->_setLastCall($this->_getLastCallFnc(), $products, $basketInfo);

        return $basketItem;
    }
798761
public function setProduct($product = null)
    {
        $productEntity = $product;
        // if api-product - temporarily save
        if ($product instanceof ApiProductInterface) {
            $this->tempProduct = $product;
            $productEntity = $product->getEntity();
        }
        $this->entity->setProduct($productEntity);

        return $this;
    }