/** * * Retrieve Product data objects * LOE: remove if status(=2) is disabled or visibility(=1) false * * @param int|array $productIds * @param int $storeId * @param int $entityId * @param int $lastEntityId ref * * @return array */ protected function _getProducts($productIds, $storeId, $entityId, &$lastEntityId) { $storeId = (int) $storeId; if (false === $this->_getHelper()->excludeDisabledProducts($storeId) && false === $this->_getHelper()->excludeNotVisibleProducts($storeId) && false === $this->_getHelper()->excludeDisabledCategories($storeId)) { return parent::_getProducts($productIds, $storeId, $entityId, $lastEntityId); } $products = array(); $websiteId = Mage::app()->getStore($storeId)->getWebsiteId(); /** @var SchumacherFM_FastIndexer_Model_Db_Adapter_Pdo_Mysql $adapter */ $adapter = $this->_getReadAdapter(); if ($productIds !== null) { if (!is_array($productIds)) { $productIds = array($productIds); } } $bind = array('website_id' => (int) $websiteId, 'entity_id' => (int) $entityId); /** @var Varien_Db_Select $select */ $select = $adapter->select()->from(array('e' => $this->getTable('catalog/product')), array('entity_id'))->join(array('w' => $this->getTable('catalog/product_website')), 'e.entity_id = w.product_id AND w.website_id = :website_id', array())->where('e.entity_id > :entity_id')->order('e.entity_id')->limit($this->_productLimit); // <fastindexer> $this->_addProductStatusToSelect($select, $storeId); $this->_addProductVisibilityToSelect($select, $storeId); $this->_addProductAttributeToSelect($select, 'name', $storeId); $this->_addProductAttributeToSelect($select, 'url_key', $storeId); $this->_addProductAttributeToSelect($select, 'url_path', $storeId); /*</fastindexer>*/ if (false === empty($productIds)) { $select->where('e.entity_id IN(?)', $productIds); } Mage::dispatchEvent('fastindexer_get_products_select', array('model' => $this, 'select' => $select, 'store_id' => $storeId)); $rowSet = $adapter->fetchAll($select, $bind); foreach ($rowSet as $row) { $product = new Varien_Object($row); $product->setIdFieldName('entity_id'); $product->setCategoryIds(array()); $product->setStoreId($storeId); $products[$product->getId()] = $product; $lastEntityId = $product->getId(); } unset($rowSet); if (count($products) > 0 && false === $this->_getHelper()->excludeCategoryPathInProductUrl($storeId)) { $select = $adapter->select()->from($this->getTable('catalog/category_product'), array('product_id', 'category_id'))->where('product_id IN(?)', array_keys($products)); $this->_excludeDisabledCategories($select, $storeId); // fastindexer $categories = $adapter->fetchAll($select); foreach ($categories as $category) { $productId = $category['product_id']; $categoryIds = $products[$productId]->getCategoryIds(); $categoryIds[] = $category['category_id']; $products[$productId]->setCategoryIds($categoryIds); } } return $products; }
/** * Retrieve Product data objects * LOE: remove if status(=2) is disabled or visibility(=1) false * * @param int|array $productIds * @param int $storeId * @param int $entityId * @param int $lastEntityId * @return array */ protected function _getProducts($productIds, $storeId, $entityId, &$lastEntityId) { if (!is_array($productIds) && !is_null($productIds)) { $productIds = array($productIds); } if (empty($productIds)) { return array(); } // Skip on empty $productIds if ($this->_helper()->HideDisabledProducts($storeId) || $this->_helper()->HideNotVisibileProducts($storeId)) { $products = parent::_getProducts($productIds, $storeId, $entityId, $lastEntityId); $_attributes = array(); if ($this->_helper()->HideDisabledProducts($storeId)) { $_attributes[] = 'status'; } if ($this->_helper()->HideNotVisibileProducts($storeId)) { $_attributes[] = 'visibility'; } foreach ($_attributes as $attributeCode) { $attributes = $this->_getProductAttribute($attributeCode, array_keys($products), $storeId); foreach ($attributes as $productId => $attributeValue) { if ($attributeCode == 'status' && $attributeValue == Mage_Catalog_Model_Product_Status::STATUS_DISABLED || $attributeCode == 'visibility' && $attributeValue == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE) { if (isset($productIds[$productId])) { unset($productIds[$productId]); } } } } return $products; } return parent::_getProducts($productIds, $storeId, $entityId, $lastEntityId); }