1

I know that overriding and rewriting is not the same thing, in some cases we should override instead of rewrite like the abstract classes for exemple, but i found several replies which propose to override a block magento like catalog block product list ! But for me it's better to rewrite them right ?

Now i would like to have a clarification about rewriting a block catalog block product list, i want to add some filter in collection product of catalog/product/list.phtml so i think that the only way is to rewrite the block who prepare this collection, someone can tell me where I can find it?

1

found several replies which propose to override a block magento like catalog block product list

Not everybody makes this distinction. Either they meant "rewrite" or it was questionable advice.

Now i would like to have a clarification about rewriting a block catalog block product list, i want to add some filter in collection product of catalog/product/list.phtml so i think that the only way is to rewrite the block who prepare this collection, someone can tell me where I can find it?

The class is Mage_Catalog_Block_Product_List. But you don't need to override or rewrite it at all.

There is an event catalog_block_product_list_collection that is triggered immediately before the collection is loaded. Write an observer for this event and add your filters there.

See: https://github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/core/Mage/Catalog/Block/Product/List.php#L159-L161

| improve this answer | |
  • Thank you@Fabian Schmengler's for you reply, and as the question date, I found the solution, I rewrited the block and I addee my custom collection and it works – PЯINCƏ Feb 7 '17 at 22:59
1

You should be follow below links to solve your issue :

How to override core catalog block product list?

How to extend a core Product List Block model?

| improve this answer | |

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.