Magento - get a list of bundled product ids from a product id

后端 未结 2 1725
一生所求
一生所求 2020-12-29 14:26

Lets say I load my product object:

$product = Mage::getModel(\'catalog/product\')->load($productId);

Is there a function or some way to

相关标签:
2条回答
  • 2020-12-29 14:31

    The following should work:

    $product->getTypeInstance(true)->getChildrenIds($product->getId(), false)
    

    The result is a multi-dimensional array with the top level being options and the children of options being products.

    Also, you can change the false to a true and it will only return required options of the bundle.

    0 讨论(0)
  • 2020-12-29 14:49

    Try this-

    $collection = $product->getTypeInstance(true)
        ->getSelectionsCollection(
            $product->getTypeInstance(true)
                    ->getOptionsIds($product), $product);
    
    foreach ($collection as $item) {
        # $item->product_id has the product id.
    }
    
    0 讨论(0)
提交回复
热议问题