bundle - How to check programmatically if Magento getSelectionsCollection don't have any product -


what output of $selectioncollection given if no selection product found in code magento bundle product list

$bundled_product_custom = new mage_catalog_model_product(); $bundled_product_custom->load($bundleparentproductid); $selectioncollection = $bundled_product_custom->gettypeinstance(true)->getselectionscollection(           $bundled_product_custom->gettypeinstance(true)->getoptionsids($bundled_product_custom), $bundled_product_custom          ); 

actually need check if bundle product has selection products or not.

first of should avoid instantiating object new operator. suggest use magento's factory method shown below:

$bundled_product_custom = mage::getmodel('catalog/product'); 

this way if third party extension overrides mage_catalog_model_product class factory method instantiates right object according override rules.

to answer question, try count elements in collection way:

$selectioncollection->count(); // or count($selectioncollection); 

Comments