1

I want to add product updated date as sort order but I don't want to add Updated date field in product setting page which means if admin updates a product, it's edited date should be detected automatically.

Ref: enter image description here

I want to achieve this using custom module.

I am using magento 1.9.0.1.

  • Magento provide in built field "updated_at" in table "catalog_product_entity", you can used that field. You need to overide list.php file to in custom extension to override sorting functionlity work with this field. – Dhiren Vasoya Sep 26 '16 at 7:12
  • Which function I should override in list.php ? – Hiranya Sarma Sep 26 '16 at 7:19
  • I added answer please check and if it used full please mark as solution, so other also get help. – Dhiren Vasoya Sep 26 '16 at 7:21
0

Magento provide in built field "updated_at" in table "catalog_product_entity", you can used that field. You need to overide list.php file to in custom extension to override sorting functionlity work with this field.

For List.php override, you need to do following code :

In your extension config.xml file write following :

<blocks>
      <myextension>
        <class>Mymodule_Myextension_Block</class>
      </myextension>
            <catalog>
                <rewrite>
                    <product_list_toolbar>Mymodule_Myextension_Block_Catalog_Product_List_Toolbar</product_list_toolbar>
                </rewrite>
            </catalog>
    </blocks>

And create Block file Mymodule/Myextension/Block/Catalog/Product/List/Toolbar.php code:

<?php
class Mymodule_Myextension_Block_Catalog_Product_List_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar
{
}
?>

And there is function _getProductCollection() which create collection, you need to customized this collection.

| improve this answer | |
  • You asked to override Mage_Catalog_Block_Product_List_Toolbar but _getProductCollection() is not located inside this class,how is it possible? also I want Updated date should be visible in drop-down like price. – Hiranya Sarma Sep 26 '16 at 7:28
  • If possible, provide full answer otherwise it will take much time to understand. – Hiranya Sarma Sep 26 '16 at 7:29
  • Here is the complete path of file : app\code\core\Mage\Catalog\Block\Product\List.php And check line no. 56 there is a function protected function _getProductCollection(). – Dhiren Vasoya Sep 26 '16 at 9:28

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.