0

I am trying to edit our grouped.phtml table so that when a product has a special price it displays different columns.
I have edited my grouped.phtml page to include these columns but can not work out the correct PHP statements to make them show only when a product has a 'special price'.

I have tried: <?php if($_product->getSpecialPrice() ): ?> and also <?php if($_product->getSpecialPrice()){ ?> but this does not seem to work.

I have also found another post showing how to display an icon for products with special price: https://stackoverflow.com/questions/17590849/dsplay-sale-icon-on-special-price-products-in-magento-only-at-homepage-it-is-sh

But again this doesn't not work for me.

migrated from stackoverflow.com Mar 25 '14 at 20:57

This question came from our site for professional and enthusiast programmers.

  • This belongs on the Magento stackexchange site. I've flagged it for migration – David Wilkins Feb 25 '14 at 16:19
  • @DavidWilkins Thanks, sorry didn't realise I posted it on the wrong site. Is it something I can do to migrate? – Chev Feb 25 '14 at 17:14
  • This should work: $currentProduct->getSpecialPrice() are you on the catalog category view or on the product detail page? – Fabian Blechschmidt May 20 '14 at 15:10
2

Given the stock template:

<?php foreach ($_associatedProducts as $_item): ?>
    <?php $_finalPriceInclTax = $this->helper('tax')->getPrice($_item, $_item->getFinalPrice(), true) ?>
    <tr>
        <td><?php echo $this->escapeHtml($_item->getName()) ?></td>
        <?php if ($this->getCanShowProductPrice($_product)): ?>
        <td class="a-right">
            <?php if ($this->getCanShowProductPrice($_item)): ?>
            <?php echo $this->getPriceHtml($_item, true) ?>
            <?php echo $this->getTierPriceHtml($_item) ?>
            <?php endif; ?>
        </td>
        <?php endif; ?>
        <?php if ($_product->isSaleable()): ?>
        <td class="a-center">
        <?php if ($_item->isSaleable()) : ?>
            <input type="text" name="super_group[<?php echo $_item->getId() ?>]" maxlength="12" value="<?php echo $_item->getQty()*1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
        <?php else: ?>
            <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
        <?php endif; ?>
        </td>
        <?php endif; ?>
    </tr>
<?php endforeach; ?>

You will need to use $_item->getSpecialPrice() and ensure that special_price is set to show in product listing in attribute management.

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.