显示价格范围的可配置产品Magento


Show Price Range for Configurable Products Magento

我在1.7 Magento上使用简单可配置产品扩展(http://www.magentocommerce.com/magento-connect/simple-configurable-products.html),一切似乎都很好。我唯一想改变的是在类别页面上显示价格范围,而不是"价格来自"。换句话说:

这是我现在对可配置产品的配置:

from: $[最便宜的相关产品价格]

这是我想显示的:

$[最便宜的关联产品价格]- $[最贵的关联产品价格]

如果你能建议如何修改这个扩展而不是核心文件,那就更好了,但任何解决方案都会非常感激。

注::我在Stack Overflow和Magento论坛上读了很多关于这个问题的帖子,但似乎没有人找到一个可靠的解决方案。

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

我通过修改文件让它工作:
应用程序/代码/社区/OrganicInternet/SimpleConfigurableProducts/目录/产品/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。您可能能够使用内置的货币格式方法,但我不熟悉它,因为我没有在多货币商店工作过。

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