I need to calculate the total price of my bundle and if the required option of this bundle have promo I need to print the price before the promo and after on catalog/view.
For that I have : (helper)
public function bundleItemsPromo($product) {
$productId = $product->getId();
$bundled_product = Mage::getModel('catalog/product')->load($productId);
$selectionCollection = $bundled_product->getTypeInstance(true)->getSelectionsCollection(
$bundled_product->getTypeInstance(true)->getOptionsIds($bundled_product), $bundled_product
);
$bundled_items_reduct = 0;
$price = 0;
foreach($selectionCollection as $option)
{
if($price < $option->getPrice()) {
$price = $option->getPrice();
if ($option->getSpecialPrice()){
$bundled_items_reduct += $price - $option->getSpecialPrice();
}
}
}
return $bundled_items_reduct;
}
In my foreach I just need calculate the promo only if the product is required
I tried:
$bundled_product->getTypeInstance(true)->getSelectionsCollection(
$bundled_product->getTypeInstance(true)->getOptionsIds($bundled_product), $bundled_product
)->hasRequiredOptions()
but…
If you have an idea?
Best Answer
It works !
This helper returns the price of bundle product before the promo, 1st foreach to find if option is required and 2nd foreach to get option's price.