/** * Prepare child blocks * * @return Enterprise_Search_Block_Catalog_Layer_View */ protected function _prepareLayout() { $helper = Mage::helper('enterprise_search'); if ($helper->isThirdPartSearchEngine() && $helper->getIsEngineAvailableForNavigation()) { $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; }
/** * Sets parameters for tempalte * * @return Celebros_Conversionpro_Block_Analytics_View */ protected function _prepareLayout() { //running simulated search, to have the log handle down the page. //Mage::helper('conversionpro')->getCurrentLayer()->getProductCollection()->getFacetedData(''); $this->setCustomerId(Mage::getStoreConfig('conversionpro/anlx_settings/cid')); $this->setHost(Mage::getStoreConfig('conversionpro/anlx_settings/host')); $product = $this->getProduct(); //Set product click tracking params if (isset($product)) { $this->setProductSku($product->getSku()); $this->setProductName(str_replace("'", "\\'", $product->getName())); $this->setProductPrice($product->getFinalPrice()); $webSessionId = isset($_SESSION['core']['visitor_data']['session_id']) ? $_SESSION['core']['visitor_data']['session_id'] : session_id(); $this->setWebsessionId($webSessionId); } else { $pageReferrer = Mage::getModel('core/url')->getBaseUrl() . $_SERVER['PHP_SELF']; $this->setPageReferrer($pageReferrer); //$this->setQwiserSearchSessionId(Mage::getSingleton('conversionpro/session')->getSearchSessionId()); $this->setQwiserSearchSessionId($this->_generateGUID()); $webSessionId = isset($_SESSION['core']['visitor_data']['session_id']) ? $_SESSION['core']['visitor_data']['session_id'] : session_id(); $this->setWebsessionId($webSessionId); if (Mage::Helper('conversionpro')->hasSearchResults()) { $this->setQwiserSearchLogHandle(Mage::Helper('conversionpro')->getSearchResults()->GetLogHandle()); } } return parent::_prepareLayout(); }
/** * Creates the layout if engine is active. * Difference between parent method is newFacetCondition() call on each created block. * * @return NanoWebG_ElasticSearch_Block_Catalog_Layer_View */ protected function _prepareLayout() { // if(Mage::helper('nanowebg_elasticsearch')->isLog()) { // Mage::log('NanoWebG_ElasticSearch_Block_Catalog_Layer_View _prepareLayout', null, 'elasticsearch_debug.log'); // } $helper = Mage::helper('nanowebg_elasticsearch'); if (!$helper->useElasticSearch()) { 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 ($filter->getAttributeCode() == 'price') { $filterBlockName = $this->_priceFilterBlockName; } elseif ($filter->getBackendType() == 'decimal') { $filterBlockName = $this->_decimalFilterBlockName; } elseif ($filter->getSourceModel() == 'eav/entity_attribute_source_boolean') { $filterBlockName = $this->_booleanBlockName; } else { $filterBlockName = $this->_attributeFilterBlockName; } $filters[$filter->getAttributeCode() . '_filter'] = $this->getLayout()->createBlock($filterBlockName)->setLayer($this->getLayer())->setAttributeModel($filter)->init(); } foreach ($filters as $filterName => $block) { $this->setChild($filterName, $block->newFacetCondition()); } $this->getLayer()->apply(); } return $this; }
protected function _prepareLayout() { if (!$this->_loadCache()) { return parent::_prepareLayout(); } return $this; }
/** * Prepares layout if engine is active. * Difference between parent method is addFacetCondition() call on each created block. * * @return Smile_ElasticSearch_Block_Catalog_Layer_View */ protected function _prepareLayout() { /** @var $helper Smile_ElasticSearch_Helper_Data */ $helper = Mage::helper('smile_elasticsearch'); if (!$helper->isActiveEngine()) { parent::_prepareLayout(); } else { $stateBlock = $this->getLayout()->createBlock($this->_stateBlockName)->setLayer($this->getLayer()); $categoryBlock = $this->getLayout()->createBlock($this->_categoryBlockName)->setUseUrlRewrites(true)->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->getAttributeCode() == 'rating_filter') { $filterBlockName = $this->_ratingFilterBlockName; } elseif ($attribute->getBackendType() == 'decimal') { $filterBlockName = $this->_decimalFilterBlockName; } elseif ($attribute->getSourceModel() == 'eav/entity_attribute_source_boolean') { $filterBlockName = $this->_booleanFilterBlockName; } else { $filterBlockName = $this->_attributeFilterBlockName; } $filters[$attribute->getAttributeCode() . '_filter'] = $this->getLayout()->createBlock($filterBlockName)->setLayer($this->getLayer())->setAttributeModel($attribute)->init(); } //die; foreach ($filters as $filterName => $block) { $this->setChild($filterName, $block->addFacetCondition()); } $this->getLayer()->apply(); } return $this; }
/** * 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(); }
/** * Change block type of catagory & price filter * */ protected function _prepareLayout() { if ($catId = $this->getRequest()->getParam('cat')) { $this->getLayer()->setCurrentCategory($catId); if ($categoryblock = $this->getLayout()->getBlock('category.products')) { $categoryblock->setCurrentCategory($this->getLayer()->getCurrentCategory()); } } parent::_prepareLayout(); $this->getLayout()->createBlock('layerednavigation/catalog_breadcrumbs'); return $this; }
/** * 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; }
/** * Prepare child blocks * * @return Mage_Catalog_Block_Layer_View */ protected function _prepareLayout() { /** @var Mage_Catalog_Model_Category $current_category */ $current_category = Mage::helper('catalog')->getCategory(); foreach ($this->_layeredCategories as $layeredCatConfig) { $categoryId = $layeredCatConfig['category']; // check if current category navigation is in path of categorylayered if ($current_category->getId() && in_array($categoryId, $current_category->getPathIds())) { continue; } // create categoryLayered filter block $blockAttributes = array('categoryId' => $layeredCatConfig['category'], 'requestParam' => $layeredCatConfig['filter']); $categoryBlock = $this->getLayout()->createBlock($this->_categoryLayeredBlockName, 'categorylayered_' . $categoryId, $blockAttributes)->setLayer($this->getLayer())->init(); $this->setChild('layeredcategory_' . $categoryId . '_filter', $categoryBlock); } return parent::_prepareLayout(); }
/** * Prepare child blocks * * @return Mage_Catalog_Block_Layer_View */ protected function _prepareLayout() { $filterableAttributes = $this->_getFilterableAttributes(); $collection = $this->getLayer()->getProductCollection(); $base_select = array(); if ($this->getRequest()->getParam('price') || $this->getRequest()->getParam('price_from') || $this->getRequest()->getParam('price_to')) { $base_select['price'] = clone $collection->getSelect(); } if ($this->getRequest()->getParam('cat')) { $base_select['cat'] = clone $collection->getSelect(); } if (!$this->getRequest()->getParam('order') || $this->getRequest()->getParam('order') == 'global_position') { $this->_addGlobalPosition(); } if (!$this->getRequest()->getParam('order') || $this->getRequest()->getParam('order') == 'price') { $this->_addPriceSort(); } foreach ($filterableAttributes as $attribute) { $code = $attribute->getAttributeCode(); if ($this->getRequest()->getParam($code, false)) { $base_select[$code] = clone $collection->getSelect(); } } //print_r($this->getLayer()->getProductCollection()->getSelect()->__toString()); $this->getLayer()->setBaseSelect($base_select); parent::_prepareLayout(); if (Mage::helper('gomage_navigation')->isGomageNavigation()) { if (!Mage::registry('subdomain')) { $styles_block = $this->getLayout()->createBlock('core/template', 'advancednavigation_styles')->setTemplate('gomage/navigation/header/styles.php'); $this->getLayout()->getBlock('head')->setChild('advancednavigation_styles', $styles_block); $this->getLayout()->getBlock('head')->addjs('gomage/advanced-navigation.js'); $this->getLayout()->getBlock('head')->addCss('css/gomage/advanced-navigation.css'); $this->unsetChild('layer_state'); } } }
protected function _prepareLayout() { if (Mage::registry('amshopby_layout_prepared')) { return parent::_prepareLayout(); } else { Mage::register('amshopby_layout_prepared', true); } if (!Mage::getStoreConfigFlag('customer/startup/redirect_dashboard')) { $url = Mage::helper('amshopby/url')->getFullUrl($_GET); Mage::getSingleton('customer/session')->setBeforeAuthUrl($url); } $head = $this->getLayout()->getBlock('head'); if ($head) { $head->addItem('skin_js', 'js/amshopby.js'); if (Mage::getStoreConfigFlag('amshopby/block/ajax') && !$this->getIsProductPage()) { $head->addItem('skin_js', 'js/amshopby-ajax.js'); } } return parent::_prepareLayout(); }
/** * Prepare child blocks * * @return Celebros_Conversionpro_Block_Catalog_Layer_View */ protected function _prepareLayout() { $helper = Mage::helper('conversionpro'); if ($helper->getIsEngineAvailableForNavigation()) { $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)); } } } //When nav2search is enabled, and someone clicks on a category from the navigation menu, // there won't be a 'cat' parameter in the url, but we still want to register the category he picked // for use when querying the Quiser API. // Take into consideration that usually this is done in the category block/model and this code probably has no influence. $currentCategory = Mage::registry('current_category'); if (!Mage::app()->getRequest()->getParams('cat') && isset($currentCategory)) { //Add the category filter differently for the different options under the nav2search config menu. if (Mage::helper('conversionpro')->getCelebrosConfigData('nav_to_search_settings/nav_to_search_search_by') == 'answer_id') { //This option adds a filter with the category\'s answer id. $helper->getCurrentLayer()->getProductCollection()->addFqFilter(array('category' => $currentCategory->getId())); } else { //This option adds a search query string with the name of the category. $query = $helper->getCategoryRewriteQuery($currentCategory); $helper->getCurrentLayer()->getProductCollection()->addSearchFilter($query); } } $this->setChild('layer_state', $stateBlock); $this->getLayer()->apply(); } else { parent::_prepareLayout(); } return $this; }
protected function _prepareLayout() { if (!Mage::getStoreConfigFlag('customer/startup/redirect_dashboard')) { $url = Mage::helper('amshopby/url')->getFullUrl($_GET); Mage::getSingleton('customer/session')->setBeforeAuthUrl($url); } $head = $this->getLayout()->getBlock('head'); if ($head) { $head->addItem('skin_js', 'js/amshopby.js'); } return parent::_prepareLayout(); }
protected function _prepareLayout() { return parent::_prepareLayout(); }
protected function _prepareLayout() { $pos = Mage::getStoreConfig('amshopby/block/categories_pos'); if ($this->_notInBlock($pos)) { $this->_categoryBlockName = 'amshopby/catalog_layer_filter_empty'; } if (Mage::registry('amshopby_layout_prepared')) { return parent::_prepareLayout(); } else { Mage::register('amshopby_layout_prepared', true); } if (!Mage::getStoreConfigFlag('customer/startup/redirect_dashboard')) { $url = Mage::helper('amshopby/url')->getFullUrl($_GET); Mage::getSingleton('customer/session')->setBeforeAuthUrl($url); } $head = $this->getLayout()->getBlock('head'); if ($head) { $head->addJs('amasty/amshopby/amshopby.js'); if (Mage::getStoreConfigFlag('amshopby/block/ajax') && !$this->getIsProductPage()) { $head->addJs('amasty/amshopby/amshopby-ajax.js'); } } return parent::_prepareLayout(); }
/** * Prepare child blocks * * @return Mage_Catalog_Block_Layer_View */ protected function _prepareLayout() { $saleBlock = $this->getLayout()->createBlock($this->_saleBlockName)->setLayer($this->getLayer())->init(); $this->setChild('sale_filter', $saleBlock); return parent::_prepareLayout(); }
/** * Prepare child blocks * * @return Mage_Catalog_Block_Layer_View */ protected function _prepareLayout() { $filterableAttributes = $this->_getFilterableAttributes(); $collection = $this->getLayer()->getProductCollection(); $base_select = array(); if ($this->getRequest()->getParam('price') || $this->getRequest()->getParam('price_from') || $this->getRequest()->getParam('price_to')) { $base_select['price'] = clone $collection->getSelect(); } if ($this->getRequest()->getParam('cat')) { $base_select['cat'] = clone $collection->getSelect(); } foreach ($filterableAttributes as $attribute) { $code = $attribute->getAttributeCode(); if ($this->getRequest()->getParam($code, false)) { $base_select[$code] = clone $collection->getSelect(); } } $this->getLayer()->setBaseSelect($base_select); $stockBlock = $this->getLayout()->createBlock("gomage_navigation/layer_filter_stock")->setLayer($this->getLayer())->init(); $this->setChild('stock_status_filter', $stockBlock); parent::_prepareLayout(); $currentCategory = Mage::registry('current_category'); if ($currentCategory && $currentCategory->getData('navigation_pw_gn_shopby') == GoMage_Navigation_Model_Adminhtml_System_Config_Source_Shopby::USE_GLOBAL || !$currentCategory) { $position = Mage::getStoreConfig('gomage_navigation/general/show_shopby'); } else { if ($currentCategory) { $position = $currentCategory->getData('navigation_pw_gn_shopby'); } } if (Mage::helper('gomage_navigation')->isGomageNavigation()) { $this->unsetChild('layer_state'); if ($position == GoMage_Navigation_Model_Adminhtml_System_Config_Source_Shopby::RIGHT_COLUMN || $position == GoMage_Navigation_Model_Adminhtml_System_Config_Source_Shopby::RIGHT_COLUMN_CONTENT) { $right = $this->getLayout()->getBlock('right'); if ($right) { $catalog_rightnav = clone $this; $catalog_rightnav->setParentBlock($right); $catalog_rightnav->setNameInLayout('gomage.catalog.rightnav'); if ($this->getLayout()->getBlock('gomage.navigation.right')) { $right->insert($catalog_rightnav, 'gomage.navigation.right', true, 'gomage.catalog.rightnav'); } else { $right->insert($catalog_rightnav, '', false, 'gomage.catalog.rightnav'); } } } } }
/** * Prepares layout if engine is active. * Difference between parent method is addFacetCondition() call on each created block. * * @return Smile_ElasticSearch_Block_Catalog_Layer_View */ protected function _prepareLayout() { /** @var $helper Smile_ElasticSearch_Helper_Data */ $helper = Mage::helper('smile_elasticsearch'); if (!$helper->isActiveEngine()) { parent::_prepareLayout(); } else { $stateBlock = $this->getLayout()->createBlock($this->_stateBlockName)->setLayer($this->getLayer()); $categoryBlock = $this->getLayout()->createBlock($this->_categoryBlockName, 'category_filter')->setUseUrlRewrites($this->_usesUrlRewrite)->setLayer($this->getLayer())->init(); $this->setChild('layer_state', $stateBlock); $this->setChild('category_filter', $categoryBlock->addFacetCondition()); $filters = $this->_addAppliedFilters(); $filterableAttributes = $this->_getFilterableAttributes(); foreach ($filterableAttributes as $attribute) { $blockName = $attribute->getAttributeCode() . '_filter'; if (!array_key_exists($blockName, $filters)) { $filters[$blockName] = $this->_addFilter($attribute); } $this->setChild($blockName, $filters[$blockName]->addFacetCondition()); } $this->getLayer()->apply(); } return $this; }