3

I'm trying to display a message just on a certain category page in magento?

I know how to do this on a product page so like:

<?php
if (in_array(415, $_product->getCategoryIds())) {?>
    <span style="font-weight:bold;color:#69a740;padding:0 5px;font-size:14px;">Text</span>
<?php } ?>

But not sure how to do this on a category page?

4

You can try this:

<?php
$category = Mage::registry('current_category');
if ($category && $category->getId() == 415) { ?>
    <span style="font-weight: bold; color: #69a740; padding: 0 5px; font-size: 14px;">Text</span>
<?php }?>
  • From your above script, how to put a condition like, cart has only this category of products, if other categories of products available in cart should be an error. – Gem Sep 6 at 12:37
3

Try this.

<?php if (Mage::registry('current_category')->getId() == 415) {?> <span style="font-weight:bold;color:#69a740;padding:0 5px;font-size:14px;">Text</span> <?php } ?>

  • Using observer how to check current product category id & already cart products category id, if both category id is different trigger observer and show message like You are not allowed to mixed the product. magento.stackexchange.com/q/284557/57334 @Ketan – zus Aug 8 at 5:18

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.