On an observer file I need to detect if the loaded page corresponds to a product. I’ve been using a similar method to the one used on the checked answer on this question:
if (!(Mage::registry('current_product'))) return;
But until now we were testing on development. From today we are testing on pre-production servers, with lot of modules and plugins. Until now it worked seamesly but now it does not work, it does not detect when a product page is loaded. I think is related with the url rewrite to show a more “friendly” url’s but can not detect how to solve it. I took a look into Alan Storm tutorial In Depth Magento Dispatch but I still can get what is wrong or what do I need to change.
Any idea? Or some other solution on how to detect when a product page is loaded?
You’ve verified that the observer is being hit? Make sure that for the event you are triggering on has a unique name for that event. For example in the following code the name “catalog_product_set_price” must be unique in regards to “catalog_product_load_after” event. I’m assuming you’re getting into the observer, but just in case. This risk becomes possible if you add a bunch of new modules to an instance.
You could use the following array to check where you are:
it will output something like:
You could try a different observer.