Plsが私の手伝いを助けます。私はmagentoのカートからバンドル製品を入手する必要があり、すべてのバンドル製品の選択されたアイテムを取得する必要があります。これどうやってするの?ありがとう!Magentoのカートにバンドル商品を入れる
4
A
答えて
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());
}
}
これはうまくいきます。 :)
幸運のベスト。バンドルの項目の入力タイプ「ドロップダウン」の
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 }
この作品
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
と、あなたがこれを達成するために行うことを試みてきた?で –
私はバンドル商品を手に入れることができ、バンドル商品のすべての商品を手に入れることができますが、カートから選択した商品を手に入れることはできません。 –
@AlexSkiLLerこれはあなたがこれを理解しましたか? – Chris