/** * Get default tags for current layer state * * @param array $additionalTags * @return array */ public function getStateTags(array $additionalTags = array()) { if (Mage::helper('conversionpro')->getIsEngineAvailableForNavigation()) { $additionalTags = array_merge($additionalTags, array(Mage_Catalog_Model_Category::CACHE_TAG . $this->getCurrentCategory()->getId() . '_SEARCH')); } return parent::getStateTags($additionalTags); }
public function prepareProductCollection($collection) { parent::prepareProductCollection($collection); $query = Mage::helper('catalogsearch')->getQuery(); $queryText = trim($query->getQueryText()); do { $temp = $queryText; $queryText = str_replace(' ', ' ', $queryText); } while ($temp != $queryText); // $words = addslashes(str_replace(' ', ',', $queryText)); $words = explode(' ', $queryText); $joinCondition = array(); foreach (Vikont_Pulliver_Helper_Sku::getDistributorFieldNames() as $dFieldName) { foreach ($words as $word) { $joinCondition[] = "pn.d_{$dFieldName}='" . addslashes($word) . "'"; } } /* $collection->getSelect() ->joinLeft( array('pn' => Mage::getSingleton('core/resource')->getTableName('oemdb/sku')), 'e.sku = pn.sku AND (' . implode(' OR ', $joinCondition) . ')', null, (string) Mage::getConfig()->getNode('global/resources/oemdb_database/connection/dbname') ); /**/ //sql($collection); //die; return $this; }
/** * 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')->getVisibleInSearchIds(); $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('product_search_layer'); return parent::prepareProductCollection($collection); }
/** * Get current layer product collection * * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection */ public function getProductCollection() { if (!Mage::helper('factfinder')->isEnabled()) { return parent::getProductCollection(); } if (isset($this->_productCollections[$this->getCurrentCategory()->getId()])) { $collection = $this->_productCollections[$this->getCurrentCategory()->getId()]; } else { $collection = Mage::getResourceModel('factfinder/search_collection'); $this->prepareProductCollection($collection); $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection; } return $collection; }
/** * 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()->setStore(Mage::app()->getStore())->addMinimalPrice()->addFinalPrice()->addTaxPercents()->addStoreFilter()->addUrlRewrite(); Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection); return $this; }
/** * Get default tags for current layer state * * @param array $additionalTags * @return array */ public function getStateTags(array $additionalTags = array()) { $additionalTags = array_merge($additionalTags, array(Mage_Catalog_Model_Category::CACHE_TAG . $this->getCurrentCategory()->getId() . '_SEARCH')); return parent::getStateTags($additionalTags); }