0

We are migrating away from magento 1.9 and as one of the last steps we need to extract bundles data. As an easy approach I found this solution:

$product_id = "TestBundle";
$product = Mage::getModel('catalog/product')->load($product_id);
$selctionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
    $product->getTypeInstance(true)->getOptionsIds($product), $product
);
foreach($selctionCollection as $option) {
    print_r($option);
}

But strangely I get a fatal error Uncaught Error: Call to undefined method Mage_Catalog_Model_Product_Type_Simple::getSelectionsCollection(), which assumes the loaded product is a simple product. But it isn't, definitely! I created it newly as a bundle product and get the same behavior with other existing bundle products, too. As far as I know it should be Mage_Bundle.

Did anybody overcome this error or have any idea how to work around it?

1 Answer 1

1

This error came from a wrong value in $product_id. Don't know why, but I put the SKU in there, while the product ID was needed.

Without getting any error I did not suspect this to be a problem. When using a product ID, it works as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.