0

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.

4

1 回答 1

2

这对我来说听起来很有趣,所以我决定尝试一下。

我通过修改文件让它工作:
app/code/community/OrganicInternet/SimpleConfigurableProducts/Catalog/Product/Price.php
(为了理智,将其复制到代码/本地/...目录树;D)

由于您不想要实际的“Price From:”文本,您可以注释掉这些行:

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


现在这里是有趣的地方。我基本上通过更改这一行来复制他们自己的插入方法:

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

进入这些行:

$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;

基本上复制了他们插入配置价格标签的原始方法,但这次在默认价格之后插入了最高价格。但是,它实际上不适用于多币种商店,您必须抓住商店货币运营商并根据使用的货币更改 number_format。您可能能够使用内置的货币格式方法,但我不熟悉它,因为我没有在多货币商店工作过。

试一试,如果您有任何问题,请告诉我。

于 2013-05-25T07:22:27.477 回答