Advanced layout updates for categories and products in Magento

Advanced layout updates for categories and products in Magento

Recently I had a task to modify sorting in only one category of Magento shop.
What I had to do is “only” to change which attribute will be used for default sorting and I needed to reverse ordering from ascending to descending.
Task seems simple, right?

All you need to do is add/edit your category and in admin panel set your new configuration:

Default Product Listing Sort By:

Custom Layout Update:

For custom layout update I needed to add this 3 lines:

<reference name="product_list_toolbar">
   <action method="setDefaultDirection"><dir>desc</dir></action>

That works on Magento CE and
Issue was that client has Professional Edition and that 3 lines just don’t work via custom layout update when you use it in admin panel, everything else works but:

   <action method="setDefaultDirection"><dir>desc</dir></action>


I have described how to update layout of your custom controller in post
so can update anything trough your “local.xml” file.

Problem is that then you update category controller “catalog_category_default”, you will update all categories:

<catalog_category_default translate="label">
<reference name="product_list_toolbar">
   <action method="setDefaultDirection"><dir>desc</dir></action>

and I needed only one to update with this particularly action method, so I opened Category and Products controllers and started to tracing…

I wanted to add my own handle, but that was requiring rewriting existing CategoryController class in my new module which I needed to create and configure, and I said it seemed very simple task.

Then I found out in CategoryController viewAction():

            $update->addHandle('CATEGORY_' . $category->getId());

what was pretty interesting to me and my problem was solved with:

		<reference name="product_list_toolbar">
					<action method="setDefaultDirection"><dir>desc</dir></action>

Keyword is CATEGORY_20, 20 is id of category.

Same thing you can do with single products, you can found it at ProductController viewAction():


Enjoy coding!

You made it all the way down here so you must have enjoyed this post! You may also like:

Solr and Magento – search by department Domagoj Potkoc
Domagoj Potkoc, | 1

Solr and Magento – search by department

Magento 2 Custom CMS page layout Matej Djakovic
Matej Djakovic, | 7

Magento 2 Custom CMS page layout

Override Magento 2 Layout: Product page example Mladen Ristic
, | 6

Override Magento 2 Layout: Product page example


  1. This works great for me under 1.6.2:

    <reference name="product_list_toolbar">
       <action method="setDefaultDirection" before="product_list_toolbar_pager"><dir>desc</dir></action>
  2. Is it possible to add layout updates to individual pages within a category? For example to display 4 products on the first page, then 12 products per page for the rest of that category?

    I don’t know if viewAction() allows you to add in something like the follwing in catalog.xml:

        <reference name="something">
                    <action method="ssomething"><dir>desc</dir></action>
  3. @verdan…that will show me just 1 product but i want to have all the products of the category shown with its options.

  4. @raju

    copy/paste code from:


    hint: enable template path hints to see exactly which files you need to modify

  5. Hi, any idea how to change the category display mode for selected categories using xml layout updates?

    Default setting is ‘grid’, but I need to change it to ‘table’ for selected categories.
    Any suggestions are welcome.

  6. <catalog_product_view translate="label">
             <label>Catalog Product View (Any)</label>
                    <reference name="content">
                        <block type="catalog/product_view" name="" template="catalog/product/view-posters.phtml">
  7. Hi, really dig your blog, great stuff. In regards to this post topic, I have a few categories that need be presented differently on the product details page, basically i need to use an altered view.phtml for some categories. How can i apply this in the custom layout update or catalog.xml template? Can I do something like this

    Catalog Product View (Any)


  8. Hi,

    I use your Slide categories extension with EM Computer Store template. The template comes with magento version. I am new in magento but I update my magento And I reinstall the extension. It is working in frontpage. The menu catalog -> Featured Products also work but in settings panel the site says 404 the site not found error. Are there any solution for this. Thank you for this wonderful extension.

    Greetings from Turkey 🙂

  9. Yeah, have you guys looked into why those layout updates don’t work, I don’t get it and didn’t have a lot of time to figure it out, so I did the same thing as you.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.

Tell us about your project

Drop us a line. We'd love to know more about your project.