首页 文章

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

提问于
浏览
0

我在我的1.7 Magento上使用简单可配置产品扩展(http://www.magentocommerce.com/magento-connect/simple-configurable-products.html),一切似乎都运行正常 . 我唯一想改变的是在类别页面上显示价格范围而不是"Price From" . 换一种说法:

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

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

这就是我想要展示的内容:

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

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

P.S . :我已经在Stack Overflow和Magento论坛上阅读了大量关于此问题的帖子,但似乎并没有人为此找到一个可靠的解决方案 .

1 回答

  • 2

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

    我通过修改文件让它工作:
    应用程序/代码/社区/ OrganicInternet / SimpleConfigurableProducts /目录/产品/ Price.php
    (为了理智,将它复制到代码/ local / ...目录树; 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;
    

    基本上复制他们插入配置价格标签的原始方法,但这次插入默认价格后的最高价格 . 它不会真正适用于多货币商店,但您必须 grab 商店货币运营商并根据使用的货币更改number_format . 您可能可以使用内置的货币格式方法,但我不熟悉它,因为我没有在多货币商店工作 .

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

相关问题