4

I want to add my custom arguments on categroy url. For example I have 3 custom filters (links) on the category page (red, green, yellow) and the category page url is like:

localhost/test/sale/accessories.html

Now when a customer clicks on "red" the url should be like:

localhost/test/sale/accessories.html?color=1

Please help me on this.

I have modified two files already: toolbar.phtml and list.phtml

3

This feature does exist in Magento and hence you don't want to do any extra code for do this.

Just make your category a layered category instead of a default category. That is the quick and easy solution for this. If you are confused with the terms default and layered, then

  • Default - A category which is not possible to filter down with any product attributes. For this, isAnchor property set to NO.

  • Layered - A category which can be filtered by product attributes. For this isAnchor property set to YES.

By default, if you set your category as layered, and then make your color attribute as visible in layered navigation (which you can easily do through backend), then the feature that you are looking will be automatically available for you.

Or other wise, just make your color attribute links look like this.

www.domain.com/men/shirts.html?color=27

If you place such links for your color attribute options, then magento will automatically do a filter for you. ie links should somewhat look like this.

<ul>
    <li>
         <a href="www.domain.com/your-category-reference.html?color=27">Blue</a>
    </li>
     <li>
         <a href="www.domain.com/your-category-reference.html?color=29">Red</a>
    </li>
    <li>
         <a href="www.domain.com/your-category-reference.html?color=34">Green</a>
    </li>
</ul>

Where color attribute values are assumed for demonstration

  • Please check my edited question. – Krupali Mehta Jun 29 '15 at 6:09
  • That simple edit changed the full meaning of your initial question. You should do that as a new question I think – Rajeev K Tomy Jun 29 '15 at 6:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.