Untitled

mail@pastecode.io avatarunknown
plain_text
a month ago
1.2 kB
2
Indexable
Never
public function canProductBeReindexed(Mage_Catalog_Model_Product $product, $storeId)
    {
        if ($product->isDeleted() === true) {
            throw (new Algolia_Algoliasearch_Model_Exception_ProductDeletedException())
                ->withProduct($product)
                ->withStoreId($storeId);
        }

        if ($product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) {
            throw (new Algolia_Algoliasearch_Model_Exception_ProductDisabledException())
                ->withProduct($product)
                ->withStoreId($storeId);
        }

        if ($this->shouldIndexProductByItsVisibility($product, $storeId) === false) {
            throw (new Algolia_Algoliasearch_Model_Exception_ProductNotVisibleException())
                ->withProduct($product)
                ->withStoreId($storeId);
        }

        if (!$this->config->getShowOutOfStock($storeId)
            && !$product->getStockItem()->getIsInStock()) {
            throw (new Algolia_Algoliasearch_Model_Exception_ProductOutOfStockException())
                ->withProduct($product)
                ->withStoreId($storeId);
        }

        return true;
    }