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?
Best Answer
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 inapp/etc/modules
and add this configuration directive to your module's config file.