I’m trying to achieve the following in Magento (1.9.2) in a phtml file:
I would like to display certain html on the product page only if the product is (also) in category id 350.
The product is in many categories. I don’t want to show the html when the product is viewed necessarily from a specific category path.
So someone can visit the product page on domain.com/productURL without getting there from a specific category.
What’s important is that if that product is ALSO (not only) in category id 350, among other categories it’s in, than show a certain div. If not, show a different div.
I’m tying to put an if statement in a phtml file that is already set up, but I don’t seem to get the if statement right.
2
Answers
To check either product is in category id 350 or not, you can use the following condition in product
view.phtml
fileYou can use the following code to get category id when the product has viewed from a specific category path
You can add your logic by play with these conditions.
Please use below code on your theme
view.phtml
file