/** * Retrieve resource instance wrapper * * @return Mage_CatalogSearch_Model_Resource_Advanced */ protected function _getResource() { $resourceName = $this->_engine->getResourceName(); if ($resourceName) { $this->_resourceName = $resourceName; } return parent::_getResource(); }
public function _construct() { parent::_construct(); $this->queue = Mage::getSingleton('algoliasearch/queue'); $this->config = Mage::helper('algoliasearch/config'); $this->product_helper = Mage::helper('algoliasearch/entity_producthelper'); $this->category_helper = Mage::helper('algoliasearch/entity_categoryhelper'); $this->suggestion_helper = Mage::helper('algoliasearch/entity_suggestionhelper'); }
/** * Add entity data to fulltext search table * * @param int $entityId * @param int $storeId * @param array $index * @param string $entity 'product'|'cms' * @return Mage_CatalogSearch_Model_Resource_Fulltext_Engine */ public function saveEntityIndex($entityId, $storeId, $index, $entity = 'product') { if ($entity == 'product' && Vikont_ARIOEM_Helper_Data::isEnabled()) { $partNumbers = $this->getPartNumbers($entityId); if (isset($partNumbers[$entityId])) { $index .= self::_getFulltextFieldSeparator() . implode(self::_getFulltextFieldSeparator(), $partNumbers[$entityId]); } } return parent::saveEntityIndex($entityId, $storeId, $index, $entity); }
/** * Retrieve advanced search product collection * * @return Mage_CatalogSearch_Model_Resource_Advanced_Collection */ public function getProductCollection() { if (is_null($this->_productCollection)) { $collection = $this->_engine->getAdvancedResultCollection(); $this->prepareProductCollection($collection); if (!$collection) { return $collection; } $this->_productCollection = $collection; } return $this->_productCollection; }
public function getTopProductCollection() { $collection = $this->_engine->getAdvancedResultCollection(); $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); if (isset($_GET['cat']) && is_numeric($_GET['cat'])) { $collection->addCategoryFilter(Mage::getModel('catalog/category')->load($_GET['cat']), true); } if (isset($_GET['make']) || isset($_GET['number_plate'])) { if ($_GET['cat'] == '4') { $sess_str = Mage::getSingleton("core/session")->getSearchRimSize(); $sess_arr = array(); if ($sess_str != '') { $sess_arr = explode(',', $sess_str); for ($k = 0; $k < count($sess_arr); $k++) { $filters[] = array('attribute' => 'article_code', 'eq' => $sess_arr[$k]); } $collection->addAttributeToFilter($filters); } } else { if (isset($_GET['size'])) { $collection->addAttributeToFilter('short_size', array('eq' => $_GET['size'])); } } } if (isset($_GET['width'])) { $collection->addAttributeToFilter('width', array('eq' => $_GET['width'])); } if (isset($_GET['diameter'])) { $collection->addAttributeToFilter('diameter', array('eq' => $_GET['diameter'])); } if (isset($_GET['profile'])) { $collection->addAttributeToFilter('profile', array('eq' => $_GET['profile'])); } if (isset($_GET['product_group'])) { $collection->addAttributeToFilter('product_group', array('eq' => $_GET['product_group'])); } if (isset($_GET['rim_product_group'])) { $collection->addAttributeToFilter('rim_product_group', array('eq' => $_GET['rim_product_group'])); } return $collection; //echo $this->_productCollection->getSelect(); }
/** * Retrieve search result data collection * * @return Celebros_Conversionpro_Model_Resource_Collection */ public function getResultCollection() { //Solr's layer model might use catalogsearch's data helper to get the current engine, resulting in it // using our engine class instead of mage's. In that case, we should take care to return mage's results // collection instead of our own. if (Mage::helper('conversionpro')->getIsEngineAvailable()) { $collection = Mage::getResourceModel('conversionpro/product_collection')->setEngine($this); } else { $collection = parent::getResultCollection(); } return $collection; }
public function prepareEntityIndex($index, $separator = ' ') { if ($this->config->isEnabledBackEnd(Mage::app()->getStore()->getId()) === false) { return parent::rebuildIndex($index, $separator); } foreach ($index as $key => $value) { if (is_array($value) && !empty($value)) { $index[$key] = join($separator, array_unique(array_filter($value))); } else { if (empty($index[$key])) { unset($index[$key]); } } } return $index; }
/** * Define if engine is available * * @return bool */ public function test() { if (!$this->_helper->isEnabled()) { return parent::test(); } return $this->_helper->getApplicationID() && $this->_helper->getAPIKey() && $this->_helper->getSearchOnlyAPIKey(); }