Skip to main content

Custom Layered Navigation in Magento


for category page
 <?php 
$_filters = Mage::getSingleton('catalog/layer')->getState()->getFilters();

foreach ($_filters as $_filter):?>
<?php echo $this->stripTags($_filter->getLabel()) ?><a href=”<?php echo $_filter->getRemoveUrl() ?>” title=”<?php echo $this->__('Remove This Item') ?>”><?php echo $this->__('Remove This Item') ?></a>
<?php endforeach; ?>
for search page
    <?php 
 $_filters = Mage::getSingleton('catalogsearch/layer')->getState()->getFilters();

foreach ($_filters as $_filter):?>
<?php echo $this->stripTags($_filter->getLabel()) ?><a href=”<?php echo $_filter->getRemoveUrl() ?>” title=”<?php echo $this->__('Remove This Item') ?>”><?php echo $this->__('Remove This Item') ?></a>
<?php endforeach; ?>
or you want to show only the current filter state use this code
for category page
<?php echo $this->getLayout()->createBlock('catalog/layer_state')->setTemplate('catalog/layer/state.phtml')->toHtml(); ?>
for search result
<?php echo Mage::app()->getLayout()->createBlock('catalogsearch/layer')->setTemplate('catal‌​og/layer/state.phtml')->toHtml(); ?>

Comments

Popular posts from this blog

TO Execute Multiple Raw Query In Magento 2

<?php         /*          *          * TO Execute Multiple Raw Query In Magento 2          *          * */ $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); $conn = $resource->getConnection('write'); $sqlScript = file($sqlFile); $query = ''; foreach ($sqlScript as $line) { $startWith = substr(trim($line), 0 ,2); $endWith = substr(trim($line), -1 ,1); if (empty($line) || $startWith == '--' || $startWith == '/*' || $startWith == '//') continue; $query = $query . $line; if ($endWith == ';') { $conn->query($query); $query= ''; } } echo '<div class="success-response sql-import-response">SQL file imported successfully</div>';

Find Duplicate Url In Magento

Find Duplicate Product Url SELECT Count(*),value FROM catalog_product_entity_varchar v WHERE EXISTS (SELECT * FROM eav_attribute a WHERE attribute_code = "url_key" AND v.attribute_id = a.attribute_id AND EXISTS (SELECT * FROM eav_entity_type e WHERE entity_type_code = "catalog_product" AND a.entity_type_id = e.entity_type_id )) AND store_id = 0 GROUP BY v.value HAVING Count(*) > 1 Find Duplicate Category Url SELECT Count(*),value FROM catalog_category_entity_varchar v WHERE EXISTS (SELECT * FROM eav_attribute a WHERE attribute_code = "url_key" AND v.attribute_id = a.attribute_id AND EXISTS (SELECT * FROM eav_entity_type e WHERE entity_type_code = "catalog_cate...

Magento 2 Change Core Config Value Programmatically

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // Instance of object manager $cacheTypeList = $objectManager->get('\Magento\Framework\App\Cache\TypeListInterface'); $cacheFrontendPool = $objectManager->get('\Magento\Framework\App\Cache\Frontend\Pool'); $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); $connection = $resource->getConnection(); $table = $resource->getTableName('core_config_data'); $select = $connection->select()->from( $table, ['config_id', 'value'] )->where( 'path = ?', 'carriers/storepickup/active' ); $data = $connection->fetchAll($select); if ($data) { try { $connection->beginTransaction(); foreach ($data as $value) { if($storeId == 1){ $dvalue = !(bool)1; }else{ $dvalue = 1; } $bind = ['path' => 'carriers/storepickup/active', 'value' => $dvalue]; $whe...