开发者

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

Lets s开发者_C百科ay I load my product object:

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

Is there a function or some way to extract the bundled ids related to this product?

e.g.

$product->getBundledProductIDs()


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.


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜