I'm tying into the event catalog_block_product_list_collection to add additional sort options onto the collection. However, the class Mage_Review_Model_Observer is also listening to this event. The observed function, catalogBlockProductCollectionBeforeToHtml, loads the product collection and prevents me from making additional changes. Because this observer is inside core, it always fires first.

I would like to make my observer fire before the core observer, and I believe this can be accomplished by making the core module depend on my custom module. Is this possible?

I'm open to other approaches to solving this as well; there are no other relevant events that I've seen to tie into.


I think you can use dependancy concept for this .

Suppose your module be Yoursite_Yourmodule. Then use the following code in the location app/etc/Yoursite_Yourmodule.xml

                <Yoursite_Yourmodule />

What this code does is, it will make the module Mage_Review depends on your module and hence your module will load bofore the core module does. This will make your observer listen first .

I think this may solve your problem.

  • My favorite example of how extensible Magento is. – philwinkle Mar 19 '14 at 18:21
  • Oh! I thought I had to declare the dependency for a module inside that module's XML. Being able to do it from my custom XML is a great solution! – Ryre Mar 20 '14 at 17:34

As noted by programmer_rkt, dependencies are one way to handle observer processing order by affecting the order in which the configuration files are merged.

Another strategy would be to take the loaded product collection, reset it, and unshift your sort order onto it:

$coll->clear()->unshiftOrder(/*your params*/);
  • 1
    Who actually reads the body of the question? I only answer based on the title. – philwinkle Mar 19 '14 at 20:15
  • how can we know order number of a modul then ? @benmarks – Rajeev K Tomy Mar 20 '14 at 0:48
  • 1
  • Thanks @benmarks. Your solutions always enlighten me. I was unaware you can "unload" collections with clear! – Ryre Mar 20 '14 at 17:38

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.