0

How do you sort the products in the catalog to sort in descending, of the order they were imported. The latest products imported be the first listed on the page / catalog? I guess the product id is best method to sort by!

Note:
I just need to place the newest products first. MORE IMPORTANT is that they are placed along side each other! As most of the products are one style, but different color blends. So we import them in that order.

My preferred way of doing this would to place it in local.xml.

enter image description here

enter image description here

  • In admin area or in front end? – Adarsh Khatri Apr 5 '16 at 2:10
  • Thank you for the reply. I know that already. When I sort by "Position", It does not sort the products, by the id! They are are not in order and scattered? – user2774042 Apr 5 '16 at 4:06
  • do you want to show product based on id on category page ? – Arunendra Apr 5 '16 at 4:56
  • this might be help you – Akhilesh Patel Apr 5 '16 at 6:08
  • No, there is no need to show the product id on the catalog page. I just need to place the newest products first. MORE IMPORTANT is that they are placed along side each other! As most the products are one style, but different color blends. So we import them in that order. – user2774042 Apr 5 '16 at 13:52
1

Don't use the product id, use the created_at timestamp instead. Unfortunately neither are EAV attributes, so you cannot configure them in the admin panel to be used for sorting.

But it is possible to add sort options via layout XML. The best answer from this StackOverflow thread contains the code:

<reference name="product_list">
    <action method="setAvailableOrders" json="value">
        <value><![CDATA[
                       {"created_at" : "Latest","price":"Price"}
               ]]>
        </value>
    </action>
</reference>
<reference name="product_list_toolbar">
    <action method="setDefaultDirection">
        <dir>desc</dir>
    </action>
</reference>

To add the sort option to all categories, add the code in your theme's layout/local.xml inside the catalog_category_default and catalog_category_layered handles:

<layout>
    ...
    <catalog_category_default>

        HERE

    </catalog_category_default>
    <catalog_category_layered>

        AND HERE

    </catalog_category_layered>
</layout>

But you can also add the option only to specific categories, using the "Custom Layout Update" text field in the "Custom Design" tab. Just paste the code from above there.

| improve this answer | |
  • Thank you for reply @fschmengler . When I place the code in "Custom Layout Update" text field in the "Custom Design" tab, it works perfectly. But when I want to add the sort option to all categories; by placing it in app/design/frontend/MyTheme/layout/local.xml, it does NOT. Why is that? – user2774042 Apr 5 '16 at 14:30
  • I'd say, either a mistake in the local.xml or you did not flush the cache afterwards. Can you update the question with the full local.xml file? – Fabian Schmengler Apr 5 '16 at 14:32
  • I placed it in between <layout version="0.1.0"> and </layout> of local.xml. This I flushed all cache as well. No luck! – user2774042 Apr 5 '16 at 14:52
  • two times, once with <catalog_category_default> for non-anchor categories and once with <catalog_category_layered> for anchor categories? – Fabian Schmengler Apr 5 '16 at 14:55
  • Yes sir in both <catalog_category_default> and <catalog_category_layered>. – user2774042 Apr 5 '16 at 14:57

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