Indicates if the product position have moved after optimization.

@param array $baseProductIds      The base product Ids
@param array $optimizedProductIds The optimized product Ids.
@param int   $productId           The current product.

@return int
422651
private function getEffectOnProduct($baseProductIds, $optimizedProductIds, $productId)
    {
        $result                   = 0;
        $baseProductPosition      = array_search($productId, $baseProductIds);
        $optimizedProductPosition = array_search($productId, $optimizedProductIds);

        if ($baseProductPosition === false && $optimizedProductPosition !== false) {
            $result = 1;
        } elseif ($baseProductPosition !== false && $optimizedProductPosition === false) {
            $result = -1;
        } elseif ($baseProductPosition !== false && $optimizedProductPosition !== false) {
            if ($baseProductPosition > $optimizedProductPosition) {
                $result = 1;
            }
            if ($baseProductPosition < $optimizedProductPosition) {
                $result = -1;
            }
        }

        return $result;
    }
766922
public function findProductsByProductNumbers(int $siteId, array $productNumbers, int $page = 1, int $pageSize = 100) : array
    {
        Assert::that($siteId)->greaterThan(0, 'The $siteId has to be positive');
        Assert::that($productNumbers)->notEmpty();
        Assert::thatAll($productNumbers)->minLength(1, 'All product numbers in $productNumbers must have a length > 0');
        Assert::that($page)->greaterThan(0, 'The $page has to be positive');
        Assert::that($pageSize)->greaterThan(0, 'The $pageSize has to be positive');

        $body = [
            'Identifiers' => $productNumbers,
            'PageIndex' => $page,
            'Pagesize' => $pageSize
        ];

        return (array)$this->master->doRequest(
            'GET',
            sprintf('/admin/WEBAPI/Endpoints/v1_0/ProductService/{KEY}/FindProductsByProductNumbers/%d', $siteId),
            $body
        );
    }
3499
private function initStoreProductData($productId, $storeId)
    {
        if (!array_key_exists($productId, $this->attributeData)) {
            $this->attributeData[$productId] = [];
        }

        if (!array_key_exists($storeId, $this->attributeData[$productId])) {
            $this->attributeData[$productId][$storeId] = [];
        }
    }
1022987
public function readProductFamily($productFamilyId, $componentId)
    {
        $service = $this->getService();

        $response      = $service->request('product_families/' . (int)$productFamilyId . '/components/' . (int)$componentId, 'GET');
        $responseArray = $this->getResponseArray($response);

        if (!$this->isError()) {
            $this->_data = $responseArray['component'];
        } else {
            $this->_data = array();
        }

        return $this;
    }
1374001
public function loadProductById($productId)
    {
        $collection = $this->catalogCollection->create()
            ->addFieldToFilter('product_id', $productId)
            ->setPageSize(1);

        return $collection->getFirstItem();
    }
484161
private function markProductsAsSynced($products, $syncDomainsCount)
    {

        $syncProducts = $this->SyncProduct->findAllSyncProducts($this->AppAuth->getManufacturerId());

        foreach ($products as $product) {
            $syncCount = 0;
            $preparedSyncProducts = [];

            foreach ($syncProducts as $syncProduct) {
                if ($syncProduct->dash_separated_local_product_id === $product->id_product) {
                    $syncCount++;
                    $preparedSyncProducts[] = [
                        'domain' => $syncProduct->sync_domain->domain,
                        'name' => 'Name wird nach Login angezeigt...',
                        'remoteProductId' => $syncProduct->dash_separated_remote_product_id
                    ];
                }
            }

            if ($syncCount > 0) {
                $product->prepared_sync_products = $preparedSyncProducts;
            }
        }

        return $products;
    }
323953
public function purchase(array $productsToBuy, array $productIds, DataBaseExporter $exporter, int $internalOrderId): int
    {
        $preOrdersCount = 0;
        $order = Order::createOrder($productsToBuy, $internalOrderId, true);

        foreach ($order->getProducts() as $product) {
            $numberOfPreOrders = 0;
            $links = [];

            foreach ($product->getCodes() as $code) {

                if ($code->isPreOrder()) {
                    $numberOfPreOrders++;
                    $preOrdersCount++;
                }

                $links[] = $code->getCodeId();
            }

            $orderedCodes = [
                'cwOrderId' => $order->getOrderId(),
                'links' => $links,
                'preOrders' => $numberOfPreOrders
            ];

            $exporter->export(null, $orderedCodes, $productIds[$product->getProductId()], $internalOrderId);
        }

        return $preOrdersCount;
    }
1254494
public function deleteProduct($product_id)
    {
        if (isset($this->_products[$product_id]["trial"]))
        {
            $this->deleteTrial($product_id);
        }
        if (isset($this->_products[$product_id]["subscription"]))
        {
            $this->deleteSubscription($product_id);
        }
        if (isset($this->_products[$product_id]["payment_plan"]))
        {
            $this->deletePaymentPlan($product_id);
        }
        unset($this->_products[$product_id]);

        return $this->_products;
    }
711050
public function addCustomerRelations(int $idProductList, array $customerIds): void
    {
        foreach ($customerIds as $idCustomer) {
            $productListCustomerEntity = new SpyProductListCustomer();
            $productListCustomerEntity->setFkProductList($idProductList)
                ->setFkCustomer($idCustomer)
                ->save();
        }
    }
1168240
public function removeCustomerRelations(int $idProductList, array $customerIds): void
    {
        if (count($customerIds) === 0) {
            return;
        }

        $productListCustomerEntities = $this->getFactory()
            ->createProductListCustomerQuery()
            ->filterByFkProductList($idProductList)
            ->filterByFkCustomer_In($customerIds)
            ->find();

        foreach ($productListCustomerEntities as $productListCustomer) {
            $productListCustomer->delete();
        }
    }
356101
protected function setProduct($product_id)
    {
        $this->data_product = array();

        if (is_numeric($product_id)) {

            $conditions = array(
                'language' => 'und',
                'product_id' => $product_id
            );

            $this->data_product = $this->product->get($conditions);

            if (empty($this->data_product)) {
                $this->outputHttpStatus(404);
            }

            $this->prepareProduct($this->data_product);
        }
    }
855450
protected function prepareProductInformation($addProductId, $productInfo)
    {
        $return = [];

        $return['id'] = isset($productInfo['aid']) ? $productInfo['aid'] : $addProductId;
        $return['amount'] = isset($productInfo['am']) ? $productInfo['am'] : 0;
        $return['selectList'] = isset($productInfo['sel']) ? $productInfo['sel'] : null;

        $return['persistentParameters'] = $this->getPersistedParameters($productInfo['persparam']);
        $return['override'] = isset($productInfo['override']) ? $productInfo['override'] : null;
        $return['bundle'] = isset($productInfo['bundle']) ? true : false;
        $return['oldBasketItemId'] = isset($productInfo['basketitemid']) ? $productInfo['basketitemid'] : null;

        return $return;
    }
471029
protected function updateProduct($product_id)
    {
        if (!$this->isError() && !$this->product->update($product_id, $this->getSubmitted())) {
            $this->errorAndExit($this->text('Unexpected result'));
        }
    }
136427
public function listProductFamily($productFamilyId)
    {
        $service = $this->getService();

        $response      = $service->request('product_families/' . (int)$productFamilyId . '/components', 'GET');
        $responseArray = $this->getResponseArray($response);

        if (!$this->isError()) {
            $this->_data = $this->_normalizeResponseArray($responseArray);
        } else {
            $this->_data = array();
        }

        return $this;
    }
192668
public function updateProductStatus($productId, $status)
    {
        $result = $this->httpRaw(self::WECHAT_SHOP_STATUS_PRODUCT_UPDATE_URL . 'access_token=' . $this->getAccessToken(), [
                'product_id' => $productId,
                'status' => $status
            ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'success';
    }
1333296
public function deleteProduct($productId)
    {
        $result = $this->httpRaw(self::WECHAT_SHOP_PRODUCT_DELETE_URL . 'access_token=' . $this->getAccessToken(), [
            'product_id' => $productId
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'success';
    }
1092944
public function addProducts($productIds)
    {
        $fullTextIndexer    = $this->indexerRegistry->get(\Magento\CatalogSearch\Model\Indexer\Fulltext::INDEXER_ID);
        $indexerChangeLog   = $fullTextIndexer->getView()->getChangelog();

        $changelogTableName = $indexerChangeLog->getName();
        $columnName         = $indexerChangeLog->getColumnName();

        try {
            $indexerChangeLog->create();

            $this->resource->getConnection()->insertArray(
                $changelogTableName,
                [$columnName],
                $productIds
            );
        } catch (\Exception $e) {
            throw new CouldNotSaveException(__(
                'Could not schedule products for reindexing : %1',
                $e->getMessage()
            ));
        }
    }