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.

3
  • 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. Commented Sep 26, 2016 at 7:12
  • Which function I should override in list.php ? Commented Sep 26, 2016 at 7:19
  • I added answer please check and if it used full please mark as solution, so other also get help. Commented Sep 26, 2016 at 7:21

1 Answer 1

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.

3
  • 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. Commented Sep 26, 2016 at 7:28
  • If possible, provide full answer otherwise it will take much time to understand. Commented Sep 26, 2016 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(). Commented Sep 26, 2016 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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