Note that there are some explanatory texts on larger screens.

plurals
  1. POOrder product list by creation date
    primarykey
    data
    text
    <p>I was adding date to sorting methods in catalog list. If I chose sort by date, list is sorting by date - this is working good. But, what should i do for set default sort by date (DESC) in catalog list? In my case, not working these solutions: catalog.xml<br /> </p> <pre><code>&lt;action method="setDefaultDirection"&gt;&lt;dir&gt;desc&lt;/dir&gt;&lt;/action&gt; &lt;action method="setDefaultOrder"&gt;&lt;field&gt;created_at&lt;/field&gt;&lt;/action&gt; </code></pre> <p>and:<br /> Catalog/Block/Product/List/Toolbar.php <br /></p> <pre><code>protected $_direction = 'desc'; </code></pre> <p>Magento Version: 1.7.0.2. </p> <p><strong>Edit: 1</strong> <br /> I made a new module in local folder /app/code/local/SortByDate/. I added two files. First /catalog/model/Config.php:</p> <pre><code>class SortByDate_Catalog_Model_Config extends Mage_Catalog_Model_Config { public function getAttributeUsedForSortByArray() { $options = parent::getAttributeUsedForSortByArray(); if (!isset($options['created_at'])) { $options['created_at'] = Mage::helper('catalog')-&gt;__('Date'); } return $options; } } </code></pre> <p><br />and second /etc/config.xml :</p> <pre><code> &lt;config&gt;&lt;global&gt;&lt;models&gt;&lt;catalog&gt;&lt;rewrite&gt;&lt;config&gt;SortByDate_Catalog_Model_Config&lt;/config&gt;&lt;/rewrite&gt;&lt;/catalog&gt;&lt;/models&gt;&lt;/global&gt;&lt;/config&gt; </code></pre> <p><strong>Edit 2 - Solved</strong> I modify this function, problem was gone :)</p> <pre><code> public function setDefaultOrder($field) { //set default order by date if (isset($this-&gt;_availableOrder[$field])) { $this-&gt;_availableOrder = array( 'created_at' =&gt; $this-&gt;__('Date'), 'name' =&gt; $this-&gt;__('Name'), 'price' =&gt; $this-&gt;__('Price'), ); $this-&gt;_orderField = $field; } return $this; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload