I'm currently showing a sale tag on products that are discounted in list.phtml:

$now = date("Y-m-d H:m:s");
$specialprice = Mage::getModel('catalog/product')->load($_product->getId())->getSpecialPrice(); 
$special_from_date = $_product->getSpecialFromDate();
$special_to_date = $_product->getSpecialToDate();

<?php if (($specialprice && ($special_from_date <= $now) && ($special_to_date >= $now || $special_to_date =="" ))) { ?>
    <div class='sale-item'>
        <span class="text">
            <?php echo $this->__('Sale') ?>
<?php } endif; ?>

This works well, however if a product is a grouped product type and one of it's associated products is discounted, the sale tag does not show so I somehow need to include associated products when checking if the product is discounted.

The list template is just using the default loaded collection currently:


foreach ($_productCollection as $_product)

I believe I can get any associated products with the following?

$associatedProducts = $_product->getTypeInstance(true)->getAssociatedProducts($_product);

Not quite sure how the best way of working this into the checking of whether the product is discounted or not though...

  • Check answers & give feedback Commented Jan 15, 2019 at 12:53

1 Answer 1


You could have something like this in a helper

public function isSale($product)
    if ($product->isGrouped()){
        foreach ($product->getTypeInstance(true)->getAssociatedProducts($product) as $childProduct){
            if ($childProduct->getFinalPrice() < $childProduct->getPrice()){
                // if at least one child is "on sale", then parent is flagged
                return true;
    } else {
        if ($product->getFinalPrice() < $product->getPrice()){
            return true;
    return false;

This will check catalogrule discounts too, not only special_price. If you want to check just special_price, then you'd include that date from & to validations

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.