0

I have the following code in view.phtml that checks if a product is in a specific category (2495), and if it is, outputs some text.

EXISTING CODE

<?php if (Mage::registry('current_category') && Mage::registry('current_category')->getId() == 2495) { ?>
CONTENT GOES HERE...
<?php } ?>

How do I go about checking if the product exists in more than one category (e.g. 2495, 2496 & 2497)?

1
$categoryIds = array(2495, 2496, ...);
if (Mage::registry('current_category') && in_array (Mage::registry('current_category')->getId(), $categoryIds)) {
     //code here
}
  • Final code I ended with is as follows... <?php $categoryIds = array(2495, 1163); if (Mage::registry('current_category') && in_array (Mage::registry('current_category')->getId(), $categoryIds)) { ?>code here <?php } ?> – YorkieMagento Dec 29 '16 at 10:43

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.