Algolia_Algoliasearch_Helper_Data::getProductsRecords PHP 메소드

getProductsRecords() 보호된 메소드

protected getProductsRecords ( $storeId, $collection, $potentiallyDeletedProductsIds = [] )
    protected function getProductsRecords($storeId, $collection, $potentiallyDeletedProductsIds = array())
    {
        $productsToIndex = array();
        $productsToRemove = array();
        // In $potentiallyDeletedProductsIds there might be IDs of deleted products which will not be in a collection
        if (is_array($potentiallyDeletedProductsIds)) {
            $potentiallyDeletedProductsIds = array_combine($potentiallyDeletedProductsIds, $potentiallyDeletedProductsIds);
        } else {
            $potentiallyDeletedProductsIds = array();
        }
        $this->logger->start('CREATE RECORDS ' . $this->logger->getStoreName($storeId));
        $this->logger->log(count($collection) . ' product records to create');
        /** @var $product Mage_Catalog_Model_Product */
        foreach ($collection as $product) {
            $product->setStoreId($storeId);
            $productId = $product->getId();
            // If $productId is in the collection, remove it from $potentiallyDeletedProductsIds so it's not removed without check
            if (isset($potentiallyDeletedProductsIds[$productId])) {
                unset($potentiallyDeletedProductsIds[$productId]);
            }
            if (isset($productsToIndex[$productId]) || isset($productsToRemove[$productId])) {
                continue;
            }
            if ($product->isDeleted() === true || $product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED || (int) $product->getVisibility() <= Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE || $product->getStockItem()->is_in_stock == 0 && !$this->config->getShowOutOfStock($storeId)) {
                $productsToRemove[$productId] = $productId;
                continue;
            }
            $json = $this->product_helper->getObject($product);
            $productsToIndex[$productId] = $json;
        }
        $productsToRemove = array_merge($productsToRemove, $potentiallyDeletedProductsIds);
        $this->logger->stop('CREATE RECORDS ' . $this->logger->getStoreName($storeId));
        return array('toIndex' => $productsToIndex, 'toRemove' => array_unique($productsToRemove));
    }