4

For a configurable product with price differentials, Magento's catalog listing page (the page where Magento displays a list of products), prices can be displayed as a range

$35.23 - $64.00

(Update: Stock Magento can't display prices as a range.)

However, this range doesn't not incorporate (or does not appear to incorporate) price possibilities based on tiered pricing.

Is there a canonical/sane (ideally performant) way to get these price ranges to include the lowest/highest price including all tiered price options?

1 Answer 1

2

I'm a little confused - when you say "prices can be displayed as a range" do you mean Magento can be configured to display the range? I can't find any setting that would do that (in 1.9.1), so I am assuming you are doing the range generation yourself.

Maybe :

$tierPrices = array();
// returns an array when no qty is passed 
$tierInfo = $product->getTierPrice();

/* use afterLoad for load tier price to product object whenever 
            product collection does not contain tier price in collection-*/

if (is_null($tierInfo)) {
    $attribute = $product->getResource()->getAttribute('tier_price');
    if ($attribute) {
        $attribute->getBackend()->afterLoad($product);
        $tierInfo = $product->getData('tier_price');
    }
}


if (is_null($tierInfo)) {
    $attribute = $product->getResource()->getAttribute('tier_price');
    if ($attribute) {
        $attribute->getBackend()->afterLoad($product);
        $tierInfo = $product->getData('tier_price');
    }
}

foreach ($tierInfo as $tierPrice) {
    array_push($tierPrices, $tierPrice['price']);
}
$maxTier = max($tierPrices);
$minTier = min($tierPrices);

Then push the $maxTier and $minTier into the array of prices you are creating the range from, or compare them against the existing high / low values?

Of course, this could be totally off base depending on how the range is generated.

2
  • Thanks for the heads up -- I'd assumed the price range was a built-in feature. I hadn't realized it was hacked into the template by other people's code. Commented Aug 14, 2015 at 6:00
  • I'm used to seeing it as well, I assumed the same thing. Thought I was taking crazy pills when I couldn't find it.
    – AreDubya
    Commented Aug 14, 2015 at 6:14

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.