getShowOutOfStock() public method

public getShowOutOfStock ( $storeId = null )
Exemplo n.º 1
0
 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));
 }
Exemplo n.º 2
0
 protected function _registerEvent(Mage_Index_Model_Event $event)
 {
     $event->addNewData(self::EVENT_MATCH_RESULT_KEY, true);
     switch ($event->getEntity()) {
         case Mage_Catalog_Model_Product::ENTITY:
             $this->_registerCatalogProductEvent($event);
             break;
         case Mage_Catalog_Model_Convert_Adapter_Product::ENTITY:
             $event->addNewData('algoliasearch_reindex_all', true);
             break;
         case Mage_Core_Model_Store_Group::ENTITY:
             $event->addNewData('algoliasearch_reindex_all', true);
             break;
         case Mage_CatalogInventory_Model_Stock_Item::ENTITY:
             if (false == $this->config->getShowOutOfStock()) {
                 $this->_registerCatalogInventoryStockItemEvent($event);
             }
             break;
     }
 }