1
<ol class="product-grid">
            <?php foreach ($products as $product): ?>
                <li class="product-grid_item product-tile">
                    <a class="product-image" href="<?php echo $product->getProductUrl(); ?>">
                                            <div class="quickview"><button class="button button--s button--inverted">Quick View</button></div>
                        <picture class="pimg1">
                            <source srcset="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(290, 290); ?>" media="(min-width: 400px)">
                            <img srcset="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(130, 130); ?>" alt="<?php echo $this->escapeHtml($this->getImageLabel($product, 'small_image')); ?>">
                        </picture>
                                                <picture class="pimg2">
                            <source srcset="<?php echo $this->helper('catalog/image')->init($product, 'thumbnail')->resize(290, 290); ?>" media="(min-width: 400px)">
                            <img srcset="<?php echo $this->helper('catalog/image')->init($product, 'thumbnail')->resize(130, 130); ?>" alt="<?php echo $this->escapeHtml($this->getImageLabel($product, 'thumbnail')); ?>">
                        </picture>
                        <?php

                        // GravDept:
                        // Check if product is new.
                        $isNewProduct = Mage::helper('magefrontend')->isNewProduct($product);
                        ?>
                        <?php if ($isNewProduct): ?>
                            <ul class="badge-list">
                                <li class="badge-list_item badge-list_item--new">
                                    <?php echo $this->__('New'); ?>
                                </li>
                            </ul>
                        <?php endif; ?>
                    </a>
                                        <div class="product-banner-box">
                                                    <span class="plussize-banner">now in plus sizes</span>
                                        </div>
3
  • I want to display last div only if size of the product is also XXL – onlyfordigitalworld Jun 23 '17 at 11:00
  • are you using custom options or configurable products? – Jaimin Sutariya Jun 23 '17 at 11:12
  • Yes, My size attribute is custom ,and itis for all type of products – onlyfordigitalworld Jun 23 '17 at 11:14
2

Try replacing below code

<div class="product-banner-box">
    <span class="plussize-banner">now in plus sizes</span>
</div>

With

<?php
$showMessage = false;
$tmpProduct = Mage::getModel("catalog/product")->load($product->getId());
    foreach ($tmpProduct->getOptions() as $o) {
        if($o->getTitle() == 'Size'){ // Use Your Size Option Title
            $values = $o->getValues();
            foreach ($values as $v){
                if($v->getTitle() == 'XXL'){ // Use your option text to match
                    $showMessage = true;
                    break;
                }
            }
        }
    }
?>
<?php if($showMessage): ?>
    <div class="product-banner-box">
        <span class="plussize-banner">now in plus sizes</span>
    </div>
<?php endif; ?>
8
  • Parse error: syntax error, unexpected '}' :( – onlyfordigitalworld Jun 23 '17 at 11:51
  • Please check updated code. There was a type extension – Jaimin Sutariya Jun 23 '17 at 12:02
  • Uncaught Error: Call to undefined method Mage_Catalog_Model_Resource_Product_Collection::getId() in – onlyfordigitalworld Jun 23 '17 at 12:10
  • 1
    This solution should work, but it's better not to use $product = Mage::getModel("catalog/product")->load($_product->getId()); in a product grid, because then the entire product info will be loaded, for each product in the grid. Better make sure the value is present in the collection. – Niels Jun 23 '17 at 12:10
  • @shushant, please check updated answer – Jaimin Sutariya Jun 23 '17 at 12:12

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.