Get list all bundle products in Magento


Get list all bundle products in Magento : In magento there can be many types of products such as simple, configurable and bundled etc. You can user magento model catalog product model and filters to get the bundle products. You can get other types of products in the same way. Here we are going to explain how to get bundle products in magento.


Get list all bundle products in Magento

Here is syntax for getting bundle products-

Get list all bundled products in Magento Syntax

$products = Mage::getModel('catalog/product')->getCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToSelect('type')
    ->addAttributeToFilter('type_id', 'bundle');

Which will give you the bundle products.

Get bundle product items from Bundle Product in Magento

You can get the bundle product items simple using the following syntax –

Get bundle product items from Bundle Product in Magento Syntax

//first load bundle product
$bundleProduct = Mage::getModel('catalog/product')->load($bundleProductId);
$collection = $product->getTypeInstance(true)
    ->getSelectionsCollection(
        $product->getTypeInstance(true)
                ->getOptionsIds($bundleProduct), $bundleProduct);

foreach($collection as $item) {
    $itemId = $item->product_id;
}

The above example will give you items of the bundle product.


Advertisements

Add Comment

📖 Read More