How do I display a message (ex. AVAILABLE IN 30 DAY) in product page only for a specific category id (98, 100 and 101)?

I've created

<?php if($_product->isSaleable()): ?>
<div class="sedia">
<?php echo $this->getChildHtml('chair') ?>
<?php endif;?>

in view.phtml, and

$_product= Mage::getModel('catalog/product');
$catIds = $_product->getCategoryIds();

<?php if ($catIds = $_product->getCategoryIds(); == '100')) ?>
        <div class="trentagg">
            <p>AVAILABLE IN 30 DAY</p>

<?php endif;

in chair.phtml but it's not working. Thanks

  • let me know whether your product has been assigned to multiple categories? – Nagaraju K May 30 '17 at 8:59
  • hi @fossati whether you got a solution? – Nagaraju K Jun 3 '17 at 8:50

Please try the below code as shown in view.phtml

    $_product = $this->getProduct(); 
    $categoryIds = $_product->getCategoryIds();
    foreach($categoryIds as $id) {
      $cat = Mage::getModel('catalog/category')->load($id);
      echo  $cat->getId()."<br>";
      echo  $cat->getName()."<br>";
      if($cat->getId() == '98')
         echo "AVAILABLE IN 30 DAY";

Screenshot: enter image description here

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.