0
votes

I'm using Simple Configurable Products extension(http://www.magentocommerce.com/magento-connect/simple-configurable-products.html) on my 1.7 Magento and everything seems to be working fine. The only thing I'd like to change is to show price range on category pages instead of "Price From". In other words:

This is what I have right now for configurable products:

Price from: $[price of cheapest associated product]

This is what I want to show:

$[price of cheapest associated product] - $[price of most expensive associated product]

If you can recommend how to modify this extension instead of core files, it would be even better, but any solution would be greatly appreciated.

P.S.: I've read tons of threads about this on Stack Overflow and on Magento forum, but it does not seems like anyone came to a solid solution for this.

1

1 Answers

2
votes

This sounded interesting to me, so I decided to try it out.

I got it to work by modifying the file:
app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Product/Price.php
(Copy it to the code/local/... directory tree for sanity's sake ;D)

Since you don't want the actual "Price From:" text, you can comment out these lines:

if ($product->getMaxPossibleFinalPrice() != $product->getFinalPrice()) {
    $extraHtml .= $this->__('Price From:');
}


Now here is where it gets interesting. I basically copied their own method of insertion by changing this line:

return substr_replace($priceHtml, $extraHtml, strpos($priceHtml, $htmlToInsertAfter)+strlen($htmlToInsertAfter),0);

Into these lines:

$finalHtml = substr_replace($priceHtml, $extraHtml, strpos($priceHtml, $htmlToInsertAfter)+strlen($htmlToInsertAfter),0);

if ($product->getMaxPossibleFinalPrice() != $product->getFinalPrice()) {

    $finalPriceHtml = ' - $' . strval(number_format($product->getMaxPossibleFinalPrice(),2,'.',','));
    $finalPriceInsertAfter = strval(number_format($product->getFinalPrice(),2,'.',','));

    $finalHtml = substr_replace($finalHtml, $finalPriceHtml, strpos($finalHtml, $finalPriceInsertAfter)+strlen($finalPriceInsertAfter),0);
}
return $finalHtml;

Basically copying their original method of inserting the config price label, but this time inserting the max price after the default price. It won't really work for multi-currency stores though, you'll have to grab the store currency operator and change the number_format depending on the currency used. You'll probably be able to use the built in currency format methods, but I'm not familiar with it as I haven't worked on a multi-currency store.

Give it a run and let me know if you have any issues.