开发者

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

开发者 https://www.devze.com 2023-04-02 00:01 出处:网络
Lets s开发者_C百科ay I load my product object: $product = Mage::getModel(\'catalog/product\')->load($productId);

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

精彩评论

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