我尝试了几个想法,我可以在谷歌找到,但没有人为我工作了几天。最后,我找到了一种方法自定义扩展,以显示“最小可能的价格”和“最大可能的价格”捆绑产品在Magento:Magento:获得捆绑产品的最大和最小价格
$_product_id = YOUR_BUNDLE_PRODUCT_ID;
// highest possible price for this bundle product
$return_type = 'max'; // because I used this in a helper method
// lowest possible price for this bundle product
// $return_type = 'min';
$model_catalog_product = Mage::getModel('catalog/product'); // getting product model
$_product = $model_catalog_product->load($_product_id);
$TypeInstance = $_product->getTypeInstance(true);
$Selections = $TypeInstance->getSelectionsCollection($OptionIds, $_product);
$Options = $TypeInstance->getOptionsByIds($OptionIds, $_product);
$bundleOptions = $Options->appendSelections($Selections, true);
$minmax_pricevalue = 0; // to sum them up from 0
foreach ($bundleOptions as $bundleOption) {
if ($bundleOption->getSelections()) {
$bundleSelections = $bundleOption->getSelections();
$pricevalues_array = array();
foreach ($bundleSelections as $bundleSelection) {
$pricevalues_array[] = $bundleSelection->getPrice();
}
if ($return_type == 'max') {
rsort($pricevalues_array); // high to low
} else {
sort($pricevalues_array); // low to high
}
// sum up the highest possible or lowest possible price
$minmax_pricevalue += $pricevalues_array[0];
}
}
// echo $minmax_pricevalue;
echo ''.Mage::helper('core')->currency($minmax_pricevalue, true, false).'';
如果你有更好的和更短的方式随意张贴在这里。感谢所有参与!
背景所有的是,我已经做了一个自定义的扩展,并希望在那里显示这种配置的“最低可能的价格”和“最大可能的价格”。 Magento-Setup是:本地“捆绑产品”几个“捆绑项目选项”连接我的“捆绑产品”。每个“捆绑选项”都有多个不同价格的简单产品。我认为这是重点。
希望所有帮助别人 - 爱分享这种东西:-)
获取错误$ OptionIds未定义。任何线索? – aravind 2016-02-05 16:06:31