【发布时间】:2011-08-24 12:08:47
【问题描述】:
产品 myBundle 具有带有以下项目的 myColorOption:
- 绿色 $50
- 蓝色 $100
- 红色 100 美元
- 黑色 $150
默认情况下,Magento 1.4.2.0 会为客户提供一个选择下拉菜单,其中包含如下选项:
- 绿色 +$50
- 蓝色 +$100
- 红色 +$100
- 黑色 +$150
我正在寻找的更改是管理员选择了默认项目。如果是,则每个显示的价格都应与默认选项的价格相关。如果管理员将蓝色(价格 100 美元)设置为选项的默认项目,下拉列表现在应显示为:
- 绿色 -$50
- 蓝色
- 红色
- 黑色+$50
澄清一下:我只想改变下拉菜单中显示的价格,添加到购物车并用于其他计算的实际价格保持不变。
更新:这是我到目前为止的代码,问题出在注释行中。我需要帮助获得正确的模型等。
<?php
// From file app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php
// copied to app/code/local/Mage/...
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();
$defaultPrice = $_product->getPriceModel()->getSelectionPreFinalPrice($_product, $_default, 1);
*/
$price = $_product->getPriceModel()->getSelectionPreFinalPrice($_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>':'');
}
}
【问题讨论】:
标签: php magento magento-1.4