1

I have been trying to override the Random.php file and have looked at inchoo and another method here. When I do the change on the core file the change takes effect immediately, but when I created the override, the modification do not take effect.

I am trying to override /app/code/core/Mage/Catalog/Block/Product/List/Random.php. I have created /app/code/local/MyFolder/Catalog/Block/Product/List/Random.php (the modified file).

I have also changed the class name in my override file, to class MyFolder_Catalog_Block_Product_List_Random extends Mage_Catalog_Block_Product_List

I can't figure out how to properly modify app/etc/config.xml file? This is what I have so far.

<config>
 <global>
    ...
    <models>
    ...
    </models>
    <blocks>
        <catalog>
            <rewrite>
                <product_list>MyFolder_Catalog_Block_Product_List_Random</product_list>
            </rewrite>
        </catalog>
    </blocks>           
 </global>
</config>

OK it's now functioning.
Changed from:

<rewrite>
    <product_list>MyFolder_Catalog_Block_Product_List_Random</product_list>
</rewrite>  

To:

<rewrite>
    <product_list_random>MyFolder_Catalog_Block_Product_List_Random</product_list_random>
</rewrite>  

Now I am not sure if there are any other places that needs updating?

2

Your rewrite path should be global/blocks/catalog/rewrite/product_list_random.

Also, you should not be making this entry in app/etc/config.xml, because this change will be lost in an upgrade. Better to register a new module in app/etc/modules and add this configuration directive to your module's config file.

| improve this answer | |
  • Thanks for the reply. By registering you mean, create a file called MyFolder.xml in app/etc/module/? And adding this configuration means, adding the above: <config><blocks><catalog><rewrite><product_list_random>MyFolder_Catalog_Block_Product_List_Random</product_list_random</rewrite></catalog></blocks></config> to app/etc/module/MyFolder.xml? Kindly clarify. – user2774042 Jul 16 '15 at 22:58
  • I did exactly as explained above, but I am NOT getting the changes! But as soon as I place the directives back in app/etc/config.xml it starts working again. Please let me know if I'm missing anything. – user2774042 Jul 16 '15 at 23:05
  • 1
    Clear the configuration cache and see if it works. Also, the config directive should go in your module's config.xml file – benmarks Jul 16 '15 at 23:15
  • Cleared all cache. No it is not happening for me. Yes, I do have the <config><blocks><catalog><rewrite><product_list_random>MyFolder_Catalog_Block_P‌​roduct_List_Random</product_list_random</rewrite></catalog></blocks></config> saved as MyFolder.xml in this folder -> app/etc/module/MyFolder.xml. – user2774042 Jul 16 '15 at 23:51

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.