/**
  * Prepares layout if engine is active.
  * Difference between parent method is addFacetCondition() call on each created block.
  *
  * @return JR_Search_Block_Catalogsearch_Layer
  */
 protected function _prepareLayout()
 {
     /** @var $helper JR_Search_Helper_Data */
     $helper = Mage::helper('jr_search');
     if (!$helper->isActiveEngine()) {
         parent::_prepareLayout();
     } else {
         $stateBlock = $this->getLayout()->createBlock($this->_stateBlockName)->setLayer($this->getLayer());
         $categoryBlock = $this->getLayout()->createBlock($this->_categoryBlockName)->setLayer($this->getLayer())->init();
         $this->setChild('layer_state', $stateBlock);
         $this->setChild('category_filter', $categoryBlock->addFacetCondition());
         $filterableAttributes = $this->_getFilterableAttributes();
         $filters = array();
         foreach ($filterableAttributes as $attribute) {
             if ($attribute->getAttributeCode() == 'price') {
                 $filterBlockName = $this->_priceFilterBlockName;
             } elseif ($attribute->getSourceModel() == 'eav/entity_attribute_source_boolean') {
                 $filterBlockName = $this->_booleanFilterBlockName;
             } elseif ($attribute->getBackendType() == 'decimal') {
                 $filterBlockName = $this->_decimalFilterBlockName;
             } else {
                 $filterBlockName = $this->_attributeFilterBlockName;
             }
             $filters[$attribute->getAttributeCode() . '_filter'] = $this->getLayout()->createBlock($filterBlockName)->setLayer($this->getLayer())->setAttributeModel($attribute)->init();
         }
         foreach ($filters as $filterName => $block) {
             $this->setChild($filterName, $block->addFacetCondition());
         }
         $this->getLayer()->apply();
     }
     return $this;
 }
Esempio n. 2
0
 /**
  * Prepare child blocks
  *
  * @return Enterprise_Search_Block_Catalog_Layer_View
  */
 protected function _prepareLayout()
 {
     $helper = Mage::helper('enterprise_search');
     if ($helper->isThirdPartSearchEngine() && $helper->getIsEngineAvailableForNavigation(false)) {
         $stateBlock = $this->getLayout()->createBlock($this->_stateBlockName)->setLayer($this->getLayer());
         $categoryBlock = $this->getLayout()->createBlock($this->_categoryBlockName)->setLayer($this->getLayer())->init();
         $filterableAttributes = $this->_getFilterableAttributes();
         $filters = array();
         foreach ($filterableAttributes as $attribute) {
             if ($attribute->getAttributeCode() == 'price') {
                 $filterBlockName = $this->_priceFilterBlockName;
             } elseif ($attribute->getBackendType() == 'decimal') {
                 $filterBlockName = $this->_decimalFilterBlockName;
             } else {
                 $filterBlockName = $this->_attributeFilterBlockName;
             }
             $filters[$attribute->getAttributeCode() . '_filter'] = $this->getLayout()->createBlock($filterBlockName)->setLayer($this->getLayer())->setAttributeModel($attribute)->init();
         }
         $this->setChild('layer_state', $stateBlock);
         $this->setChild('category_filter', $categoryBlock->addFacetCondition());
         foreach ($filters as $filterName => $block) {
             $this->setChild($filterName, $block->addFacetCondition());
         }
         $this->getLayer()->apply();
     } else {
         parent::_prepareLayout();
     }
     return $this;
 }
Esempio n. 3
0
 /**
  * Prepare child blocks
  *
  * @return Mage_Catalog_Block_Layer_View
  */
 protected function _prepareLayout()
 {
     $options = $this->_getCustomOptions();
     foreach ($options as $option) {
         $block = $this->getLayout()->createBlock('magetools_optionfilter/layer_option')->setOptionCode($option->getOptionCode())->setLayer($this->getLayer())->init();
         $this->setChild('option_' . $option->getOptionCode() . '_filter', $block);
     }
     return parent::_prepareLayout();
 }
 /**
  * Prepare child blocks
  *
  * @return Mage_Catalog_Block_Layer_View
  */
 protected function _prepareLayout()
 {
     if (!$this->helper('elasticsearch')->isActiveEngine()) {
         return parent::_prepareLayout();
     }
     $stateBlock = $this->getLayout()->createBlock($this->_stateBlockName)->setLayer($this->getLayer());
     $categoryBlock = $this->getLayout()->createBlock($this->_categoryBlockName)->setLayer($this->getLayer())->init();
     $filterableAttributes = $this->_getFilterableAttributes();
     $filters = $this->_getFiltersArray($filterableAttributes);
     $this->setChild('layer_state', $stateBlock);
     $this->setChild('category_filter', $categoryBlock->addFacetCondition());
     $this->_addFacetConditionToFilters($filters);
     $this->getLayer()->apply();
     return $this;
 }
Esempio n. 5
0
 /**
  * Creates layout if Elastic Search engine.
  * Difference between parent method is newFacetCondition() call on each created block.
  *
  * @return NanoWebG_ElasticSearch_Block_Catalogsearch_Layer
  */
 protected function _prepareLayout()
 {
     /** @var $helper NanoWebG_ElasticSearch_Helper_Data */
     if (Mage::helper('nanowebg_elasticsearch')->isLog()) {
         Mage::log('NanoWebG_ElasticSearch_Block_Catalogsearch_Layer _prepareLayout', null, 'elasticsearch_debug.log');
     }
     $helper = Mage::helper('nanowebg_elasticsearch');
     if (!$helper->useElasticSearch()) {
         if (Mage::helper('nanowebg_elasticsearch')->isLog()) {
             Mage::log('NanoWebG_ElasticSearch_Block_Catalogsearch_Layer _prepareLayout parent (do not use elastic)', null, 'elasticsearch_debug.log');
         }
         parent::_prepareLayout();
     } else {
         $stateBlock = $this->getLayout()->createBlock($this->_stateBlockName)->setLayer($this->getLayer());
         $categoryBlock = $this->getLayout()->createBlock($this->_categoryBlockName)->setLayer($this->getLayer())->init();
         $this->setChild('layer_state', $stateBlock);
         $this->setChild('category_filter', $categoryBlock->newFacetCondition());
         $filterables = $this->_getFilterableAttributes();
         $filters = array();
         foreach ($filterables as $filter) {
             if (Mage::helper('nanowebg_elasticsearch')->isLog()) {
                 Mage::log('NanoWebG_ElasticSearch_Block_Catalogsearch_Layer _prepareLayout next attribute:' . $filter->getAttributeCode(), null, 'elasticsearch_debug.log');
             }
             if ($filter->getAttributeCode() == 'price') {
                 $filterBlockName = $this->_priceFilterBlockName;
             } elseif ($filter->getSourceModel() == 'eav/entity_attribute_source_boolean') {
                 $filterBlockName = $this->_booleanBlockName;
             } elseif ($filter->getBackendType() == 'decimal') {
                 $filterBlockName = $this->_decimalFilterBlockName;
             } else {
                 $filterBlockName = $this->_attributeFilterBlockName;
             }
             $filters[$filter->getAttributeCode() . '_filter'] = $this->getLayout()->createBlock($filterBlockName)->setLayer($this->getLayer())->setAttributeModel($filter)->init();
         }
         $this->_catalogSearchFilters = $filters;
         foreach ($filters as $filterName => $block) {
             $this->setChild($filterName, $block->newFacetCondition());
         }
         $this->getLayer()->apply();
     }
     return $this;
 }
Esempio n. 6
0
 /**
  * Prepare child blocks
  *
  * @return Celebros_Conversionpro_Block_Catalog_Layer_View
  */
 protected function _prepareLayout()
 {
     $helper = Mage::helper('conversionpro');
     if ($helper->getIsEngineAvailableForNavigation(false)) {
         $stateBlock = $this->getLayout()->createBlock($this->_stateBlockName)->setLayer($this->getLayer());
         //Running over each param in the request URL, and using the $questionTexts array to verify whether each one is a
         // filter parameter or not.
         //For each parameter, we'll add a filter to the products collection, that will affect the search results.
         $params = Mage::app()->getRequest()->getParams();
         $questionTexts = $helper->getQuestionTexts();
         foreach ($params as $code => $values) {
             if ($code == 'cat') {
                 $helper->getCurrentLayer()->getProductCollection()->addFqFilter(array('category' => Mage::app()->getRequest()->getParam($code)));
             } elseif ($code == 'price') {
                 $arr = array();
                 $orig_filter = Mage::app()->getRequest()->getParam($code);
                 preg_match_all('/_P(\\d*)_(\\d*)/', $orig_filter, $arr, PREG_PATTERN_ORDER);
                 list($orig, $from, $to) = $arr;
                 $helper->getCurrentLayer()->getProductCollection()->addFqFilter(array('price' => $orig_filter));
             } elseif (array_key_exists($code, $questionTexts)) {
                 $values = explode(',', Mage::app()->getRequest()->getParam($code));
                 foreach ($values as $answerId) {
                     $helper->getCurrentLayer()->getProductCollection()->addFqFilter(array(strtolower($code) => $answerId));
                 }
             }
         }
         $this->setChild('layer_state', $stateBlock);
         $this->getLayer()->apply();
     } else {
         parent::_prepareLayout();
     }
     return $this;
 }