/** * * @param Mage_CatalogSearch_Model_Mysql4_Advanced_Collection $collection * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute * @param string|array $value * * @return bool */ public function addIndexableAttributeModifiedFilter($collection, $attribute, $value) { if ($attribute->getIndexType() == 'decimal') { $table = $this->getTable('catalog/product_index_eav_decimal'); } else { $table = $this->getTable('catalog/product_index_eav'); } $tableAlias = 'ast_' . $attribute->getAttributeCode(); $storeId = Mage::app()->getStore()->getId(); $select = $collection->getSelect(); if (is_array($value)) { if (isset($value['from']) && isset($value['to'])) { if (empty($value['from']) && empty($value['to'])) { return false; } } } $select->distinct(true); $select->join(array($tableAlias => $table), "e.entity_id={$tableAlias}.entity_id AND {$tableAlias}.attribute_id={$attribute->getAttributeId()}" . " AND {$tableAlias}.store_id={$storeId}", array()); if (is_array($value) && (isset($value['from']) || isset($value['to']))) { if (isset($value['from']) && !empty($value['from'])) { $select->where("{$tableAlias}.`value` >= ?", $value['from']); } if (isset($value['to']) && !empty($value['to'])) { $select->where("{$tableAlias}.`value` <= ?", $value['to']); } return true; } $select->where("{$tableAlias}.`value` IN(?)", $value); return true; }
/** * Retrieve collection last page number * * @return int */ public function getLastPageNumberParent() { return parent::getLastPageNumber(); }
/** * Prepare product collection * * @param Mage_CatalogSearch_Model_Mysql4_Advanced_Collection $collection * @return Mage_Catalog_Model_Layer */ public function prepareProductCollection($collection) { $collection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->setStore(Mage::app()->getStore())->addMinimalPrice()->addTaxPercents()->addStoreFilter(); Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection); return $this; }
public function setOrder($attribute, $dir = 'desc') { $this->addAttributeToSort('on_top', 'desc'); parent::setOrder($attribute, $dir); return $this; }