/** * Initialize product collection * * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection Product collection. * * @return Mage_Catalog_Model_Layer */ public function prepareProductCollection($collection) { $query = $collection->getSearchEngineQuery(); $allowedVisibilities = Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds(); $query->addFilter('terms', array('visibility' => $allowedVisibilities)); $allowedStatuses = Mage::getSingleton('catalog/product_status')->getVisibleStatusIds(); $query->addFilter('terms', array('status' => $allowedStatuses)); if (Mage::helper('cataloginventory')->isShowOutOfStock() == false) { $query->addFilter('terms', array('in_stock' => 1)); } $query->setQueryType('category_products_layer'); return parent::prepareProductCollection($collection); }
public function prepareProductCollection($collection) { parent::prepareProductCollection($collection); if (!Mage::helper('rayfox_catalog')->isSortOutOfStockProductsAtBottomEnabled()) { return $this; } $websiteId = Mage::app()->getStore()->getWebsiteId(); if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) { $collection->joinTable(array('cisi' => 'cataloginventory/stock_status'), 'product_id=entity_id', 'stock_status', array('website_id' => $websiteId), 'left'); } $collection->getSelect()->order('stock_status desc'); return $this; }
/** * Prepare product collection * * @param Mage_Catalog_Model_Resource_Eav_Resource_Product_Collection $collection * @return Mage_Catalog_Model_Layer */ public function prepareProductCollection($collection) { if (!Mage::helper('searchanise/ApiSe')->checkSearchaniseResult(true)) { return parent::prepareProductCollection($collection); } if (method_exists($collection, 'setSearchaniseRequest')) { $collection->setSearchaniseRequest(Mage::helper('searchanise')->getSearchaniseRequest()); } if (!method_exists($collection, 'checkSearchaniseResult') || !$collection->checkSearchaniseResult()) { return parent::prepareProductCollection($collection); } $collection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->addSearchaniseFilter()->addMinimalPrice()->addFinalPrice()->addTaxPercents()->addUrlRewrite($this->getCurrentCategory()->getId()); Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); return $this; }
public function prepareProductCollection($collection) { parent::prepareProductCollection($collection); $collection->getSelect()->group('e.entity_id'); return $this; }
public function prepareProductCollection($collection) { parent::prepareProductCollection($collection); Mage::helper('umicrosite')->addVendorFilterToProductCollection($collection); return $this; }
public function prepareProductCollection($collection) { parent::prepareProductCollection($collection); $collection->getSelect()->where('price_index.final_price < price_index.price'); return $this; }