所以我一直在努力让这个工作,但没有运气,我在网上找不到任何东西似乎解决了这个问题 . 现在我的代码改变了捆绑产品下拉选项中的定价,以显示差价而不是绝对价格,因此您可以看到默认选择和其他选项之间的价格差异:
File: app/code/local/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php
public function getSelectionTitlePrice($_selection, $includeContainer = true)
{
$defaultPrice = 0.00;
$_product = $this->getProduct();
$_mbmo = new Mage_Bundle_Model_Option();
$_mbmo->load($_selection->getProductId());
$_default = $_mbmo->getDefaultSelection();
if (gettype($this->getOption()->getDefaultSelection())==object){
$defaultPrice=$this->getOption()->getDefaultSelection()->getFinalPrice();
}
$price = $_product->getPriceModel()->getSelectionFinalPrice($_product, $_selection, 1);
if ($price == $defaultPrice)
{
return $_selection->getName();
}
else
{
$sign = ($price < $defaultPrice) ? '-' : '+';
$diff = ($price < $defaultPrice) ? $defaultPrice - $price : $price - $defaultPrice;
return $_selection->getName() . ' ' .
($includeContainer ? '<span class="price-notice">':'') . $sign .
$this->formatPriceString($diff, $includeContainer) . ($includeContainer ? '</span>':'');
}
}
代码通过getSelectionFinalPrice()为下拉菜单中的其他选项成功获取FinalPrice,但是对于默认选择,getFinalPrice()不起作用(它只是给我正常价格) . 在应用特价折扣后如何更改它以给我价格?我已经尝试了一些其他功能,如getSpecialPrice(),但似乎没有任何工作!
谢谢!
1 回答
经过大量的修修补补后,我能够自己解决这个问题 .
基本上我检查是否有特殊价格百分比,然后我是否将其应用于默认价格 . 这是一种解决方法,因为它看起来是因为如果有特殊百分比,产品模型中的所有价格信息(最终价格等)都不准确 .
希望这有助于有人在同样的问题上挣扎!