Layered Navigation Category link Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Show layered subcategories on the left of the subcategories pageHow will the selected layered navigation apply to all categories?layered navigation category => auto set filterLayered navigation filter by product nameFilter Layered Navigation: Specify Filter for SubcategoryMagento : Layered Navigation on CMS Page is Only Filtering by 'Default Category'How to show all categories and their subcategories on Layered Navigation?Magento2 layered navigation on category pagesMagento 2 : I Want to Display All Catagory and Sub Category in Layerd NavigationMagento 2.2 Layered Navigation Category Page issue

Generate an RGB colour grid

Do I really need to have a message in a novel to appeal to readers?

What was the first language to use conditional keywords?

Chinese Seal on silk painting - what does it mean?

Time to Settle Down!

Selecting user stories during sprint planning

As a beginner, should I get a Squier Strat with a SSS config or a HSS?

What is the font for "b" letter?

How do living politicians protect their readily obtainable signatures from misuse?

How often does castling occur in grandmaster games?

Should I follow up with an employee I believe overracted to a mistake I made?

Amount of permutations on an NxNxN Rubik's Cube

Why is Nikon 1.4g better when Nikon 1.8g is sharper?

Why does the remaining Rebel fleet at the end of Rogue One seem dramatically larger than the one in A New Hope?

Can a new player join a group only when a new campaign starts?

Disembodied hand growing fangs

Crossing US/Canada Border for less than 24 hours

How fail-safe is nr as stop bytes?

What is this clumpy 20-30cm high yellow-flowered plant?

Why do we need to use the builder design pattern when we can do the same thing with setters?

Sum letters are not two different

Maximum summed subsequences with non-adjacent items

How to write this math term? with cases it isn't working

How can I reduce the gap between left and right of cdot with a macro?



Layered Navigation Category link



Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Show layered subcategories on the left of the subcategories pageHow will the selected layered navigation apply to all categories?layered navigation category => auto set filterLayered navigation filter by product nameFilter Layered Navigation: Specify Filter for SubcategoryMagento : Layered Navigation on CMS Page is Only Filtering by 'Default Category'How to show all categories and their subcategories on Layered Navigation?Magento2 layered navigation on category pagesMagento 2 : I Want to Display All Catagory and Sub Category in Layerd NavigationMagento 2.2 Layered Navigation Category Page issue



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I have my layered navigation set up so that the user can filter by category, and this will filter the results on the page and stay on the category the filter was placed on e.g.



I have categories like so:



  • Balls

    • Rugby Balls

      • large

      • small


    • Football balls


If i am on rugby balls, in my layered navigation i have the option to filter for small or large rugby balls and the results are shown on the rugby balls page.



What i would like to do is instead of getting the results filtered, i would like, when the user wants to see whats in a sub category (large balls, small balls) they click on the link under the categories filter, but then actually get taken to the subcategory page instead of receiving filtered results.



Is there any way to do this?










share|improve this question






























    3















    I have my layered navigation set up so that the user can filter by category, and this will filter the results on the page and stay on the category the filter was placed on e.g.



    I have categories like so:



    • Balls

      • Rugby Balls

        • large

        • small


      • Football balls


    If i am on rugby balls, in my layered navigation i have the option to filter for small or large rugby balls and the results are shown on the rugby balls page.



    What i would like to do is instead of getting the results filtered, i would like, when the user wants to see whats in a sub category (large balls, small balls) they click on the link under the categories filter, but then actually get taken to the subcategory page instead of receiving filtered results.



    Is there any way to do this?










    share|improve this question


























      3












      3








      3








      I have my layered navigation set up so that the user can filter by category, and this will filter the results on the page and stay on the category the filter was placed on e.g.



      I have categories like so:



      • Balls

        • Rugby Balls

          • large

          • small


        • Football balls


      If i am on rugby balls, in my layered navigation i have the option to filter for small or large rugby balls and the results are shown on the rugby balls page.



      What i would like to do is instead of getting the results filtered, i would like, when the user wants to see whats in a sub category (large balls, small balls) they click on the link under the categories filter, but then actually get taken to the subcategory page instead of receiving filtered results.



      Is there any way to do this?










      share|improve this question
















      I have my layered navigation set up so that the user can filter by category, and this will filter the results on the page and stay on the category the filter was placed on e.g.



      I have categories like so:



      • Balls

        • Rugby Balls

          • large

          • small


        • Football balls


      If i am on rugby balls, in my layered navigation i have the option to filter for small or large rugby balls and the results are shown on the rugby balls page.



      What i would like to do is instead of getting the results filtered, i would like, when the user wants to see whats in a sub category (large balls, small balls) they click on the link under the categories filter, but then actually get taken to the subcategory page instead of receiving filtered results.



      Is there any way to do this?







      category layered-navigation filter






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 1 '16 at 5:02









      Community

      1




      1










      asked Oct 16 '13 at 10:48









      Tom BurmanTom Burman

      3931432




      3931432




















          2 Answers
          2






          active

          oldest

          votes


















          5














          Yes, very possible, and I do exactly the same for a client site.



          First I created a new attribute for categories, to allow me to set that a category needs to use the normal link. This is done via a module.



          The module structure:



          app/code/local/ProxiBlue/AttributeUseNormalFilterLink/
          app/code/local/ProxiBlue/AttributeUseNormalFilterLink/Model/Mysql4/
          app/code/local/ProxiBlue/AttributeUseNormalFilterLink/etc
          app/code/local/ProxiBlue/AttributeUseNormalFilterLink/sql/proxiblue_filterlink_setup


          In Model/Mysql4 I have file Setup.php
          Contents:



          class ProxiBlue_AttributeUseNormalFilterLink_Model_Mysql4_Setup extends Mage_Catalog_Model_Resource_Setup 

          private $_category_attributes = array(
          'use_normal_filter_link' => array(
          'label' => 'Use normal filter link in left navigation',
          'type' => 'int',
          'input' => 'select',
          'source' => 'eav/entity_attribute_source_boolean',
          'default' => '0',
          'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
          'visible' => true,
          'required' => false,
          'user_defined' => false,
          'visible_on_front' => true,
          'is_visible_on_front' =>true,
          'used_in_product_listing' => true,
          )
          );

          public function getDefaultEntities()
          $entities = array();

          $default_attribute_options = array(
          'group' => 'General Information',
          'required' => false,
          );

          /* Build Catalog Attributes */
          $entities['catalog_category'] = array(
          'entity_model' => 'catalog/category',
          'attribute_model' => 'catalog/resource_eav_attribute',
          'table' => 'catalog/category',
          'additional_attribute_table' => 'catalog/eav_attribute',
          'entity_attribute_collection' => 'catalog/category_attribute_collection',
          'attributes' => array(),
          );
          foreach ($this->_category_attributes as $name => $options)
          /* Override values provided by the defaults */
          $attribute_options = $default_attribute_options;
          foreach ($options as $k => $v)
          $attribute_options[$k] = $v;

          $entities['catalog_category']['attributes'][$name] = $attribute_options;


          return $entities;





          in etc folder I have the config.xml
          contents:





          <modules>
          <ProxiBlue_AttributeUseNormalFilterLink>
          <version>0.0.1</version>
          </ProxiBlue_AttributeUseNormalFilterLink>
          </modules>

          <global>
          <models>
          <proxiblue_attributeusenormalfilterlink>
          <class>ProxiBlue_AttributeUseNormalFilterLink_Model</class>
          </proxiblue_attributeusenormalfilterlink>
          </models>
          <resources>
          <proxiblue_filterlink_setup>
          <setup>
          <module>ProxiBlue_AttributeUseNormalFilterLink</module>
          <class>ProxiBlue_AttributeUseNormalFilterLink_Model_Mysql4_Setup</class>
          </setup>
          </proxiblue_filterlink_setup>
          </resources>
          </global>




          and in the sql fiolder I have the install script : mysql4-install-0.0.1.php
          contents:



          $installer = $this;
          $installer->startSetup();
          $installer->installEntities();
          $installer->endSetup();


          Now you can adjust the filter template to use this attribute, and any category can be set to display the actual category link, and not work as a filter.



          Copy the template catalog/layer/filter.phtml to your custtom theme folder, then adjust as follows: (note this has some other customization, so pull the bits you need)



          <?php $category = false; ?>
          <?php if ($this instanceof Mage_Catalog_Block_Layer_Filter_Category): ?>
          <?php $category = Mage::registry('current_category'); ?>
          <?php if ($category): ?>
          <h2>
          <a class='level-top' href="<?php $category->getUrl(); ?>"><?php echo $category->getName(); ?></a>
          </h2>
          <?php endif; ?>
          <?php endif; ?>
          <ol>
          <?php foreach ($this->getItems() as $_item): ?>
          <li>
          <?php if ($_item->getCount() > 0): ?>
          <?php
          $link = $_item->getUrl();
          if(is_object($category) && !$category->getUseNormalFilterLink())
          $filter = $_item->getFilter();
          if($filter instanceof Mage_Catalog_Model_Layer_Filter_Category)
          $linkCategory = mage::getModel('catalog/category')->load($_item->getValue());
          if($linkCategory->getId())
          $link = $linkCategory->getUrl();



          ?>
          <a href="<?php echo $this->urlEscape($link) ?>"><?php echo $_item->getLabel() ?></a>
          <?php else: echo $_item->getLabel() ?>
          <?php endif; ?>
          <?php //echo $_item->getCount() ?>
          </li>
          <?php endforeach ?>
          </ol>





          share|improve this answer




















          • 1





            Nice solution. one comment though. Instead of this if(get_class($this) == "Mage_Catalog_Block_Layer_Filter_Category") I think it's better to use if ($this instanceof Mage_Catalog_Block_Layer_Filter_Category), in case the block class Mage_Catalog_Block_Layer_Filter_Category is rewritten by an other module

            – Marius
            Oct 17 '13 at 10:14











          • Good point, not sure why I did it like that. Will adjust my code, and answer

            – ProxiBlue
            Oct 17 '13 at 12:27


















          0














          It's possible you can use this code for magento 2.



          For magento 2, we have the same function in vendormagentomodule-catalogModelLayerFilterItem.php we have getUrl() function.



          the orignal code:



          public function getUrl()

          $query = [
          $this->getFilter()->getRequestVar() => $this->getValue(),
          // exclude current page from urls
          $this->_htmlPagerBlock->getPageVarName() => null,
          ];
          return $this->_url->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]);



          and then the custom code to solve the issue:



          public function getUrl()

          if($this->getFilter()->getRequestVar() == "cat")
          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $category_url = $objectManager->create('MagentoCatalogModelCategory')->load($this->getValue())->getUrl();
          $return = $category_url;
          $request = $this->_url->getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true));
          if(strpos($request,'?') !== false )
          $query_string = substr($request,strpos($request,'?'));

          else
          $query_string = '';

          if(!empty($query_string))
          $return .= $query_string;

          return $return;

          else
          $query = array(
          $this->getFilter()->getRequestVar()=>$this->getValue(),
          $this->_htmlPagerBlock->getPageVarName() => null // exclude current page from urls
          );

          return $this->_url->getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true, '_query'=>$query));




          It's working only category section. It's working fine in my case.






          share|improve this answer










          New contributor




          Sohel Khan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f9513%2flayered-navigation-category-link%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            5














            Yes, very possible, and I do exactly the same for a client site.



            First I created a new attribute for categories, to allow me to set that a category needs to use the normal link. This is done via a module.



            The module structure:



            app/code/local/ProxiBlue/AttributeUseNormalFilterLink/
            app/code/local/ProxiBlue/AttributeUseNormalFilterLink/Model/Mysql4/
            app/code/local/ProxiBlue/AttributeUseNormalFilterLink/etc
            app/code/local/ProxiBlue/AttributeUseNormalFilterLink/sql/proxiblue_filterlink_setup


            In Model/Mysql4 I have file Setup.php
            Contents:



            class ProxiBlue_AttributeUseNormalFilterLink_Model_Mysql4_Setup extends Mage_Catalog_Model_Resource_Setup 

            private $_category_attributes = array(
            'use_normal_filter_link' => array(
            'label' => 'Use normal filter link in left navigation',
            'type' => 'int',
            'input' => 'select',
            'source' => 'eav/entity_attribute_source_boolean',
            'default' => '0',
            'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
            'visible' => true,
            'required' => false,
            'user_defined' => false,
            'visible_on_front' => true,
            'is_visible_on_front' =>true,
            'used_in_product_listing' => true,
            )
            );

            public function getDefaultEntities()
            $entities = array();

            $default_attribute_options = array(
            'group' => 'General Information',
            'required' => false,
            );

            /* Build Catalog Attributes */
            $entities['catalog_category'] = array(
            'entity_model' => 'catalog/category',
            'attribute_model' => 'catalog/resource_eav_attribute',
            'table' => 'catalog/category',
            'additional_attribute_table' => 'catalog/eav_attribute',
            'entity_attribute_collection' => 'catalog/category_attribute_collection',
            'attributes' => array(),
            );
            foreach ($this->_category_attributes as $name => $options)
            /* Override values provided by the defaults */
            $attribute_options = $default_attribute_options;
            foreach ($options as $k => $v)
            $attribute_options[$k] = $v;

            $entities['catalog_category']['attributes'][$name] = $attribute_options;


            return $entities;





            in etc folder I have the config.xml
            contents:





            <modules>
            <ProxiBlue_AttributeUseNormalFilterLink>
            <version>0.0.1</version>
            </ProxiBlue_AttributeUseNormalFilterLink>
            </modules>

            <global>
            <models>
            <proxiblue_attributeusenormalfilterlink>
            <class>ProxiBlue_AttributeUseNormalFilterLink_Model</class>
            </proxiblue_attributeusenormalfilterlink>
            </models>
            <resources>
            <proxiblue_filterlink_setup>
            <setup>
            <module>ProxiBlue_AttributeUseNormalFilterLink</module>
            <class>ProxiBlue_AttributeUseNormalFilterLink_Model_Mysql4_Setup</class>
            </setup>
            </proxiblue_filterlink_setup>
            </resources>
            </global>




            and in the sql fiolder I have the install script : mysql4-install-0.0.1.php
            contents:



            $installer = $this;
            $installer->startSetup();
            $installer->installEntities();
            $installer->endSetup();


            Now you can adjust the filter template to use this attribute, and any category can be set to display the actual category link, and not work as a filter.



            Copy the template catalog/layer/filter.phtml to your custtom theme folder, then adjust as follows: (note this has some other customization, so pull the bits you need)



            <?php $category = false; ?>
            <?php if ($this instanceof Mage_Catalog_Block_Layer_Filter_Category): ?>
            <?php $category = Mage::registry('current_category'); ?>
            <?php if ($category): ?>
            <h2>
            <a class='level-top' href="<?php $category->getUrl(); ?>"><?php echo $category->getName(); ?></a>
            </h2>
            <?php endif; ?>
            <?php endif; ?>
            <ol>
            <?php foreach ($this->getItems() as $_item): ?>
            <li>
            <?php if ($_item->getCount() > 0): ?>
            <?php
            $link = $_item->getUrl();
            if(is_object($category) && !$category->getUseNormalFilterLink())
            $filter = $_item->getFilter();
            if($filter instanceof Mage_Catalog_Model_Layer_Filter_Category)
            $linkCategory = mage::getModel('catalog/category')->load($_item->getValue());
            if($linkCategory->getId())
            $link = $linkCategory->getUrl();



            ?>
            <a href="<?php echo $this->urlEscape($link) ?>"><?php echo $_item->getLabel() ?></a>
            <?php else: echo $_item->getLabel() ?>
            <?php endif; ?>
            <?php //echo $_item->getCount() ?>
            </li>
            <?php endforeach ?>
            </ol>





            share|improve this answer




















            • 1





              Nice solution. one comment though. Instead of this if(get_class($this) == "Mage_Catalog_Block_Layer_Filter_Category") I think it's better to use if ($this instanceof Mage_Catalog_Block_Layer_Filter_Category), in case the block class Mage_Catalog_Block_Layer_Filter_Category is rewritten by an other module

              – Marius
              Oct 17 '13 at 10:14











            • Good point, not sure why I did it like that. Will adjust my code, and answer

              – ProxiBlue
              Oct 17 '13 at 12:27















            5














            Yes, very possible, and I do exactly the same for a client site.



            First I created a new attribute for categories, to allow me to set that a category needs to use the normal link. This is done via a module.



            The module structure:



            app/code/local/ProxiBlue/AttributeUseNormalFilterLink/
            app/code/local/ProxiBlue/AttributeUseNormalFilterLink/Model/Mysql4/
            app/code/local/ProxiBlue/AttributeUseNormalFilterLink/etc
            app/code/local/ProxiBlue/AttributeUseNormalFilterLink/sql/proxiblue_filterlink_setup


            In Model/Mysql4 I have file Setup.php
            Contents:



            class ProxiBlue_AttributeUseNormalFilterLink_Model_Mysql4_Setup extends Mage_Catalog_Model_Resource_Setup 

            private $_category_attributes = array(
            'use_normal_filter_link' => array(
            'label' => 'Use normal filter link in left navigation',
            'type' => 'int',
            'input' => 'select',
            'source' => 'eav/entity_attribute_source_boolean',
            'default' => '0',
            'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
            'visible' => true,
            'required' => false,
            'user_defined' => false,
            'visible_on_front' => true,
            'is_visible_on_front' =>true,
            'used_in_product_listing' => true,
            )
            );

            public function getDefaultEntities()
            $entities = array();

            $default_attribute_options = array(
            'group' => 'General Information',
            'required' => false,
            );

            /* Build Catalog Attributes */
            $entities['catalog_category'] = array(
            'entity_model' => 'catalog/category',
            'attribute_model' => 'catalog/resource_eav_attribute',
            'table' => 'catalog/category',
            'additional_attribute_table' => 'catalog/eav_attribute',
            'entity_attribute_collection' => 'catalog/category_attribute_collection',
            'attributes' => array(),
            );
            foreach ($this->_category_attributes as $name => $options)
            /* Override values provided by the defaults */
            $attribute_options = $default_attribute_options;
            foreach ($options as $k => $v)
            $attribute_options[$k] = $v;

            $entities['catalog_category']['attributes'][$name] = $attribute_options;


            return $entities;





            in etc folder I have the config.xml
            contents:





            <modules>
            <ProxiBlue_AttributeUseNormalFilterLink>
            <version>0.0.1</version>
            </ProxiBlue_AttributeUseNormalFilterLink>
            </modules>

            <global>
            <models>
            <proxiblue_attributeusenormalfilterlink>
            <class>ProxiBlue_AttributeUseNormalFilterLink_Model</class>
            </proxiblue_attributeusenormalfilterlink>
            </models>
            <resources>
            <proxiblue_filterlink_setup>
            <setup>
            <module>ProxiBlue_AttributeUseNormalFilterLink</module>
            <class>ProxiBlue_AttributeUseNormalFilterLink_Model_Mysql4_Setup</class>
            </setup>
            </proxiblue_filterlink_setup>
            </resources>
            </global>




            and in the sql fiolder I have the install script : mysql4-install-0.0.1.php
            contents:



            $installer = $this;
            $installer->startSetup();
            $installer->installEntities();
            $installer->endSetup();


            Now you can adjust the filter template to use this attribute, and any category can be set to display the actual category link, and not work as a filter.



            Copy the template catalog/layer/filter.phtml to your custtom theme folder, then adjust as follows: (note this has some other customization, so pull the bits you need)



            <?php $category = false; ?>
            <?php if ($this instanceof Mage_Catalog_Block_Layer_Filter_Category): ?>
            <?php $category = Mage::registry('current_category'); ?>
            <?php if ($category): ?>
            <h2>
            <a class='level-top' href="<?php $category->getUrl(); ?>"><?php echo $category->getName(); ?></a>
            </h2>
            <?php endif; ?>
            <?php endif; ?>
            <ol>
            <?php foreach ($this->getItems() as $_item): ?>
            <li>
            <?php if ($_item->getCount() > 0): ?>
            <?php
            $link = $_item->getUrl();
            if(is_object($category) && !$category->getUseNormalFilterLink())
            $filter = $_item->getFilter();
            if($filter instanceof Mage_Catalog_Model_Layer_Filter_Category)
            $linkCategory = mage::getModel('catalog/category')->load($_item->getValue());
            if($linkCategory->getId())
            $link = $linkCategory->getUrl();



            ?>
            <a href="<?php echo $this->urlEscape($link) ?>"><?php echo $_item->getLabel() ?></a>
            <?php else: echo $_item->getLabel() ?>
            <?php endif; ?>
            <?php //echo $_item->getCount() ?>
            </li>
            <?php endforeach ?>
            </ol>





            share|improve this answer




















            • 1





              Nice solution. one comment though. Instead of this if(get_class($this) == "Mage_Catalog_Block_Layer_Filter_Category") I think it's better to use if ($this instanceof Mage_Catalog_Block_Layer_Filter_Category), in case the block class Mage_Catalog_Block_Layer_Filter_Category is rewritten by an other module

              – Marius
              Oct 17 '13 at 10:14











            • Good point, not sure why I did it like that. Will adjust my code, and answer

              – ProxiBlue
              Oct 17 '13 at 12:27













            5












            5








            5







            Yes, very possible, and I do exactly the same for a client site.



            First I created a new attribute for categories, to allow me to set that a category needs to use the normal link. This is done via a module.



            The module structure:



            app/code/local/ProxiBlue/AttributeUseNormalFilterLink/
            app/code/local/ProxiBlue/AttributeUseNormalFilterLink/Model/Mysql4/
            app/code/local/ProxiBlue/AttributeUseNormalFilterLink/etc
            app/code/local/ProxiBlue/AttributeUseNormalFilterLink/sql/proxiblue_filterlink_setup


            In Model/Mysql4 I have file Setup.php
            Contents:



            class ProxiBlue_AttributeUseNormalFilterLink_Model_Mysql4_Setup extends Mage_Catalog_Model_Resource_Setup 

            private $_category_attributes = array(
            'use_normal_filter_link' => array(
            'label' => 'Use normal filter link in left navigation',
            'type' => 'int',
            'input' => 'select',
            'source' => 'eav/entity_attribute_source_boolean',
            'default' => '0',
            'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
            'visible' => true,
            'required' => false,
            'user_defined' => false,
            'visible_on_front' => true,
            'is_visible_on_front' =>true,
            'used_in_product_listing' => true,
            )
            );

            public function getDefaultEntities()
            $entities = array();

            $default_attribute_options = array(
            'group' => 'General Information',
            'required' => false,
            );

            /* Build Catalog Attributes */
            $entities['catalog_category'] = array(
            'entity_model' => 'catalog/category',
            'attribute_model' => 'catalog/resource_eav_attribute',
            'table' => 'catalog/category',
            'additional_attribute_table' => 'catalog/eav_attribute',
            'entity_attribute_collection' => 'catalog/category_attribute_collection',
            'attributes' => array(),
            );
            foreach ($this->_category_attributes as $name => $options)
            /* Override values provided by the defaults */
            $attribute_options = $default_attribute_options;
            foreach ($options as $k => $v)
            $attribute_options[$k] = $v;

            $entities['catalog_category']['attributes'][$name] = $attribute_options;


            return $entities;





            in etc folder I have the config.xml
            contents:





            <modules>
            <ProxiBlue_AttributeUseNormalFilterLink>
            <version>0.0.1</version>
            </ProxiBlue_AttributeUseNormalFilterLink>
            </modules>

            <global>
            <models>
            <proxiblue_attributeusenormalfilterlink>
            <class>ProxiBlue_AttributeUseNormalFilterLink_Model</class>
            </proxiblue_attributeusenormalfilterlink>
            </models>
            <resources>
            <proxiblue_filterlink_setup>
            <setup>
            <module>ProxiBlue_AttributeUseNormalFilterLink</module>
            <class>ProxiBlue_AttributeUseNormalFilterLink_Model_Mysql4_Setup</class>
            </setup>
            </proxiblue_filterlink_setup>
            </resources>
            </global>




            and in the sql fiolder I have the install script : mysql4-install-0.0.1.php
            contents:



            $installer = $this;
            $installer->startSetup();
            $installer->installEntities();
            $installer->endSetup();


            Now you can adjust the filter template to use this attribute, and any category can be set to display the actual category link, and not work as a filter.



            Copy the template catalog/layer/filter.phtml to your custtom theme folder, then adjust as follows: (note this has some other customization, so pull the bits you need)



            <?php $category = false; ?>
            <?php if ($this instanceof Mage_Catalog_Block_Layer_Filter_Category): ?>
            <?php $category = Mage::registry('current_category'); ?>
            <?php if ($category): ?>
            <h2>
            <a class='level-top' href="<?php $category->getUrl(); ?>"><?php echo $category->getName(); ?></a>
            </h2>
            <?php endif; ?>
            <?php endif; ?>
            <ol>
            <?php foreach ($this->getItems() as $_item): ?>
            <li>
            <?php if ($_item->getCount() > 0): ?>
            <?php
            $link = $_item->getUrl();
            if(is_object($category) && !$category->getUseNormalFilterLink())
            $filter = $_item->getFilter();
            if($filter instanceof Mage_Catalog_Model_Layer_Filter_Category)
            $linkCategory = mage::getModel('catalog/category')->load($_item->getValue());
            if($linkCategory->getId())
            $link = $linkCategory->getUrl();



            ?>
            <a href="<?php echo $this->urlEscape($link) ?>"><?php echo $_item->getLabel() ?></a>
            <?php else: echo $_item->getLabel() ?>
            <?php endif; ?>
            <?php //echo $_item->getCount() ?>
            </li>
            <?php endforeach ?>
            </ol>





            share|improve this answer















            Yes, very possible, and I do exactly the same for a client site.



            First I created a new attribute for categories, to allow me to set that a category needs to use the normal link. This is done via a module.



            The module structure:



            app/code/local/ProxiBlue/AttributeUseNormalFilterLink/
            app/code/local/ProxiBlue/AttributeUseNormalFilterLink/Model/Mysql4/
            app/code/local/ProxiBlue/AttributeUseNormalFilterLink/etc
            app/code/local/ProxiBlue/AttributeUseNormalFilterLink/sql/proxiblue_filterlink_setup


            In Model/Mysql4 I have file Setup.php
            Contents:



            class ProxiBlue_AttributeUseNormalFilterLink_Model_Mysql4_Setup extends Mage_Catalog_Model_Resource_Setup 

            private $_category_attributes = array(
            'use_normal_filter_link' => array(
            'label' => 'Use normal filter link in left navigation',
            'type' => 'int',
            'input' => 'select',
            'source' => 'eav/entity_attribute_source_boolean',
            'default' => '0',
            'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
            'visible' => true,
            'required' => false,
            'user_defined' => false,
            'visible_on_front' => true,
            'is_visible_on_front' =>true,
            'used_in_product_listing' => true,
            )
            );

            public function getDefaultEntities()
            $entities = array();

            $default_attribute_options = array(
            'group' => 'General Information',
            'required' => false,
            );

            /* Build Catalog Attributes */
            $entities['catalog_category'] = array(
            'entity_model' => 'catalog/category',
            'attribute_model' => 'catalog/resource_eav_attribute',
            'table' => 'catalog/category',
            'additional_attribute_table' => 'catalog/eav_attribute',
            'entity_attribute_collection' => 'catalog/category_attribute_collection',
            'attributes' => array(),
            );
            foreach ($this->_category_attributes as $name => $options)
            /* Override values provided by the defaults */
            $attribute_options = $default_attribute_options;
            foreach ($options as $k => $v)
            $attribute_options[$k] = $v;

            $entities['catalog_category']['attributes'][$name] = $attribute_options;


            return $entities;





            in etc folder I have the config.xml
            contents:





            <modules>
            <ProxiBlue_AttributeUseNormalFilterLink>
            <version>0.0.1</version>
            </ProxiBlue_AttributeUseNormalFilterLink>
            </modules>

            <global>
            <models>
            <proxiblue_attributeusenormalfilterlink>
            <class>ProxiBlue_AttributeUseNormalFilterLink_Model</class>
            </proxiblue_attributeusenormalfilterlink>
            </models>
            <resources>
            <proxiblue_filterlink_setup>
            <setup>
            <module>ProxiBlue_AttributeUseNormalFilterLink</module>
            <class>ProxiBlue_AttributeUseNormalFilterLink_Model_Mysql4_Setup</class>
            </setup>
            </proxiblue_filterlink_setup>
            </resources>
            </global>




            and in the sql fiolder I have the install script : mysql4-install-0.0.1.php
            contents:



            $installer = $this;
            $installer->startSetup();
            $installer->installEntities();
            $installer->endSetup();


            Now you can adjust the filter template to use this attribute, and any category can be set to display the actual category link, and not work as a filter.



            Copy the template catalog/layer/filter.phtml to your custtom theme folder, then adjust as follows: (note this has some other customization, so pull the bits you need)



            <?php $category = false; ?>
            <?php if ($this instanceof Mage_Catalog_Block_Layer_Filter_Category): ?>
            <?php $category = Mage::registry('current_category'); ?>
            <?php if ($category): ?>
            <h2>
            <a class='level-top' href="<?php $category->getUrl(); ?>"><?php echo $category->getName(); ?></a>
            </h2>
            <?php endif; ?>
            <?php endif; ?>
            <ol>
            <?php foreach ($this->getItems() as $_item): ?>
            <li>
            <?php if ($_item->getCount() > 0): ?>
            <?php
            $link = $_item->getUrl();
            if(is_object($category) && !$category->getUseNormalFilterLink())
            $filter = $_item->getFilter();
            if($filter instanceof Mage_Catalog_Model_Layer_Filter_Category)
            $linkCategory = mage::getModel('catalog/category')->load($_item->getValue());
            if($linkCategory->getId())
            $link = $linkCategory->getUrl();



            ?>
            <a href="<?php echo $this->urlEscape($link) ?>"><?php echo $_item->getLabel() ?></a>
            <?php else: echo $_item->getLabel() ?>
            <?php endif; ?>
            <?php //echo $_item->getCount() ?>
            </li>
            <?php endforeach ?>
            </ol>






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Oct 17 '13 at 12:29

























            answered Oct 17 '13 at 9:26









            ProxiBlueProxiBlue

            8,87832653




            8,87832653







            • 1





              Nice solution. one comment though. Instead of this if(get_class($this) == "Mage_Catalog_Block_Layer_Filter_Category") I think it's better to use if ($this instanceof Mage_Catalog_Block_Layer_Filter_Category), in case the block class Mage_Catalog_Block_Layer_Filter_Category is rewritten by an other module

              – Marius
              Oct 17 '13 at 10:14











            • Good point, not sure why I did it like that. Will adjust my code, and answer

              – ProxiBlue
              Oct 17 '13 at 12:27












            • 1





              Nice solution. one comment though. Instead of this if(get_class($this) == "Mage_Catalog_Block_Layer_Filter_Category") I think it's better to use if ($this instanceof Mage_Catalog_Block_Layer_Filter_Category), in case the block class Mage_Catalog_Block_Layer_Filter_Category is rewritten by an other module

              – Marius
              Oct 17 '13 at 10:14











            • Good point, not sure why I did it like that. Will adjust my code, and answer

              – ProxiBlue
              Oct 17 '13 at 12:27







            1




            1





            Nice solution. one comment though. Instead of this if(get_class($this) == "Mage_Catalog_Block_Layer_Filter_Category") I think it's better to use if ($this instanceof Mage_Catalog_Block_Layer_Filter_Category), in case the block class Mage_Catalog_Block_Layer_Filter_Category is rewritten by an other module

            – Marius
            Oct 17 '13 at 10:14





            Nice solution. one comment though. Instead of this if(get_class($this) == "Mage_Catalog_Block_Layer_Filter_Category") I think it's better to use if ($this instanceof Mage_Catalog_Block_Layer_Filter_Category), in case the block class Mage_Catalog_Block_Layer_Filter_Category is rewritten by an other module

            – Marius
            Oct 17 '13 at 10:14













            Good point, not sure why I did it like that. Will adjust my code, and answer

            – ProxiBlue
            Oct 17 '13 at 12:27





            Good point, not sure why I did it like that. Will adjust my code, and answer

            – ProxiBlue
            Oct 17 '13 at 12:27













            0














            It's possible you can use this code for magento 2.



            For magento 2, we have the same function in vendormagentomodule-catalogModelLayerFilterItem.php we have getUrl() function.



            the orignal code:



            public function getUrl()

            $query = [
            $this->getFilter()->getRequestVar() => $this->getValue(),
            // exclude current page from urls
            $this->_htmlPagerBlock->getPageVarName() => null,
            ];
            return $this->_url->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]);



            and then the custom code to solve the issue:



            public function getUrl()

            if($this->getFilter()->getRequestVar() == "cat")
            $objectManager = MagentoFrameworkAppObjectManager::getInstance();
            $category_url = $objectManager->create('MagentoCatalogModelCategory')->load($this->getValue())->getUrl();
            $return = $category_url;
            $request = $this->_url->getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true));
            if(strpos($request,'?') !== false )
            $query_string = substr($request,strpos($request,'?'));

            else
            $query_string = '';

            if(!empty($query_string))
            $return .= $query_string;

            return $return;

            else
            $query = array(
            $this->getFilter()->getRequestVar()=>$this->getValue(),
            $this->_htmlPagerBlock->getPageVarName() => null // exclude current page from urls
            );

            return $this->_url->getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true, '_query'=>$query));




            It's working only category section. It's working fine in my case.






            share|improve this answer










            New contributor




            Sohel Khan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.
























              0














              It's possible you can use this code for magento 2.



              For magento 2, we have the same function in vendormagentomodule-catalogModelLayerFilterItem.php we have getUrl() function.



              the orignal code:



              public function getUrl()

              $query = [
              $this->getFilter()->getRequestVar() => $this->getValue(),
              // exclude current page from urls
              $this->_htmlPagerBlock->getPageVarName() => null,
              ];
              return $this->_url->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]);



              and then the custom code to solve the issue:



              public function getUrl()

              if($this->getFilter()->getRequestVar() == "cat")
              $objectManager = MagentoFrameworkAppObjectManager::getInstance();
              $category_url = $objectManager->create('MagentoCatalogModelCategory')->load($this->getValue())->getUrl();
              $return = $category_url;
              $request = $this->_url->getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true));
              if(strpos($request,'?') !== false )
              $query_string = substr($request,strpos($request,'?'));

              else
              $query_string = '';

              if(!empty($query_string))
              $return .= $query_string;

              return $return;

              else
              $query = array(
              $this->getFilter()->getRequestVar()=>$this->getValue(),
              $this->_htmlPagerBlock->getPageVarName() => null // exclude current page from urls
              );

              return $this->_url->getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true, '_query'=>$query));




              It's working only category section. It's working fine in my case.






              share|improve this answer










              New contributor




              Sohel Khan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.






















                0












                0








                0







                It's possible you can use this code for magento 2.



                For magento 2, we have the same function in vendormagentomodule-catalogModelLayerFilterItem.php we have getUrl() function.



                the orignal code:



                public function getUrl()

                $query = [
                $this->getFilter()->getRequestVar() => $this->getValue(),
                // exclude current page from urls
                $this->_htmlPagerBlock->getPageVarName() => null,
                ];
                return $this->_url->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]);



                and then the custom code to solve the issue:



                public function getUrl()

                if($this->getFilter()->getRequestVar() == "cat")
                $objectManager = MagentoFrameworkAppObjectManager::getInstance();
                $category_url = $objectManager->create('MagentoCatalogModelCategory')->load($this->getValue())->getUrl();
                $return = $category_url;
                $request = $this->_url->getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true));
                if(strpos($request,'?') !== false )
                $query_string = substr($request,strpos($request,'?'));

                else
                $query_string = '';

                if(!empty($query_string))
                $return .= $query_string;

                return $return;

                else
                $query = array(
                $this->getFilter()->getRequestVar()=>$this->getValue(),
                $this->_htmlPagerBlock->getPageVarName() => null // exclude current page from urls
                );

                return $this->_url->getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true, '_query'=>$query));




                It's working only category section. It's working fine in my case.






                share|improve this answer










                New contributor




                Sohel Khan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.










                It's possible you can use this code for magento 2.



                For magento 2, we have the same function in vendormagentomodule-catalogModelLayerFilterItem.php we have getUrl() function.



                the orignal code:



                public function getUrl()

                $query = [
                $this->getFilter()->getRequestVar() => $this->getValue(),
                // exclude current page from urls
                $this->_htmlPagerBlock->getPageVarName() => null,
                ];
                return $this->_url->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]);



                and then the custom code to solve the issue:



                public function getUrl()

                if($this->getFilter()->getRequestVar() == "cat")
                $objectManager = MagentoFrameworkAppObjectManager::getInstance();
                $category_url = $objectManager->create('MagentoCatalogModelCategory')->load($this->getValue())->getUrl();
                $return = $category_url;
                $request = $this->_url->getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true));
                if(strpos($request,'?') !== false )
                $query_string = substr($request,strpos($request,'?'));

                else
                $query_string = '';

                if(!empty($query_string))
                $return .= $query_string;

                return $return;

                else
                $query = array(
                $this->getFilter()->getRequestVar()=>$this->getValue(),
                $this->_htmlPagerBlock->getPageVarName() => null // exclude current page from urls
                );

                return $this->_url->getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true, '_query'=>$query));




                It's working only category section. It's working fine in my case.







                share|improve this answer










                New contributor




                Sohel Khan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                share|improve this answer



                share|improve this answer








                edited yesterday





















                New contributor




                Sohel Khan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                answered 2 days ago









                Sohel KhanSohel Khan

                11




                11




                New contributor




                Sohel Khan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.





                New contributor





                Sohel Khan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                Sohel Khan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f9513%2flayered-navigation-category-link%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

                    Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

                    Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림