php - Determine if on product page programmatically in Magento -
I want to insert the tracking code on all pages of a Magento site, and if the page has to use a different syntax A CMS page, a category browsing page or product view page. I have a custom module that has been installed with a block that now puts a general tracking code on each page, from the inside of the block, I am using CMS pages, category pages And differences How do the product pages?
I started:
Dana :: app () - & gt; GetRequest ();
I can see that
Dana :: app () - & gt; GetRequest () - & gt; GetParam ('id');
Returns the product or category id on the product and category pages, but does not differentiate between those page types
Dana :: app () - & Gt; GetRequest () - & gt; GetRouteName ();
Return "CMS" for the CMS pages but the category "Returns the list" for both browsing and product view pages, so I use that category and product pages as separate Can not I
Can I use safely to have some indicators in this request? Or is there a better way to accomplish your goal of different tracking codes for different page types?
This is also a better way to use router, but a quick look at the registry The way we have a product that we are looking at is:
& lt ;? Php $ onCatalog = False; If (Dana :: Registry ('current_product')) {$ onCatalog = true; }
Hope that helps!
Thanks, Jo
Comments
Post a Comment