请帮我解决我的麻烦。我需要从 magento 的购物车中获取捆绑产品,然后我需要获取每个捆绑产品的选定项目。我怎样才能做到这一点?谢谢!
问问题
5588 次
3 回答
6
在 magento 1.8.1 中
$cart = Mage::getModel('checkout/cart')->getQuote();
foreach ($cart->getAllItems() as $_item) :
$_product = Mage::getModel('catalog/product')->load($_item->getProduct()->getId());
if($_product->getTypeId()==='bundle') :
$options = $_item->getProduct()->getTypeInstance(true)->getOrderOptions($_item->getProduct());
?>
<dl class="item-options">
<?php foreach ($options['bundle_options'] as $option):?>
<dt><?php echo $option['label'] ?></dt>
<?php foreach ($option['value'] as $sub) :?>
<dd><?php echo $sub['qty'] . " x " . $sub['title'] . " " . Mage::helper('core')->currency($sub['price']) ?></dd>
<?php endforeach;
endforeach;
?>
</dl>
<?php endif;
endforeach
于 2014-06-25T15:08:24.657 回答
1
$optionCollection = $product->getTypeInstance()->getOptionsCollection();
$selectionCollection =$product->getTypeInstance()->getSelectionsCollection($product->getTypeInstance()->getOptionsIds());
$options = $optionCollection->appendSelections($selectionCollection);
foreach( $options as $option )
{
$_selections = $option->getSelections();
foreach( $_selections as $selection )
{
$product_simple = Mage::getModel('catalog/product')->load($selection->getId());
}
}
希望这对你有用。:)
祝你好运。
于 2014-02-11T09:30:31.437 回答
0
$_product = Mage::getModel('catalog/product')->load($_item->getProduct()->getId());
if($_product->getTypeId()==='bundle') {
$options = $_item->getProduct()->getTypeInstance(true)->getOrderOptions($_item->getProduct());
?>
<dl class="item-options">
<?php
foreach ($options['bundle_options'] as $option) {?>
<dt><?php echo $option['label'] ?></dt>
<dd><?php echo $option['value'][0]['title'] ?></dd>
<?php
}
?>
</dl>
<?php }
这项工作适用于捆绑项目的输入类型“下拉”
于 2014-03-10T17:23:44.360 回答