2013-04-26 111 views
0

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

这就是我现在所拥有的可配置的产品:

价格:$ [最廉价的相关产品价格]

这是我想说明什么:

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

如果你可以推荐如何修改这个扩展而不是核心文件,它会更好,但任何解决方案将不胜感激。

P.S .:我已经阅读了堆栈溢出和Magento论坛上的大量线程,但似乎没有人为此提供可靠的解决方案。

回答

2

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

我把它通过修改文件的工作:
应用程序/代码/社区/ OrganicInternet/SimpleConfigurableProducts /目录/产品/ Price.php
(它复制到代码/本地/ ...目录树理智的缘故; d)

既然你不想实际“价格从:”文,你可以注释掉这些行:

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。您可能可以使用内置的货币格式方法,但我并不熟悉它,因为我没有在多货币商店工作过。

给它一个跑步,让我知道你是否有任何问题。

+0

不得不改变我的上面的代码使用round()到number_format()。 round()会导致产品价格整体出现问题($ 5.00 vs $ 5.98)。 – Jason 2013-05-29 18:44:01