I have been trying to create an order using a custom extension, I managed to do so, but whenever I try to add a bundle product I get a message error

Selected required options are not available.

here is the code I'm using


$product = Mage::getModel('catalog/product')->load($productDetails["product_id"]);

$optionCollection = $product->getTypeInstance()->getOptionsCollection();
$selectionCollection =$product->getTypeInstance()->getSelectionsCollection($product->getTypeInstance()->getOptionsIds());
$options = $optionCollection->appendSelections($selectionCollection);

foreach($options as $option) {

    $_selections = $option->getSelections();

    foreach($_selections as $selection) {
        $bundled_items[$option->getOptionId()] = $selection->getSelectionId();

$config = new Varien_Object(['product' =>$productDetails["product_id"],
                // X        'qty' => $productDetails["qty"],
                // 2        'bundle_options' => $bundled_items, 
                // array( 234 => 1070, 235=> 1646)
                            'bundle_option_qty' => $productDetails["bundle_option_qty"],
                // array( 234 => 2, 235=>2 )
$quote->addProduct($product, $config);


I found out that when loading the bundle items I'm not getting the options and that's why I get the exception

I also tried to use Magento's soap API but ones again when trying to add a bundle I get the error message " `

Please specify the product option(s).

I've been stuck on this for 4days now, any help is very much appreciated and thank you

2 Answers 2


try below code may be this code will help you

$cart = Mage::getModel('checkout/cart');

$params = $this->getRequest()->getParams();
$productId = 10; //product id

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

if($product->getTypeId() == "bundle"){

    $bundled_items = array();
    $optionCollection = $product->getTypeInstance()->getOptionsCollection();
    $selectionCollection = $product->getTypeInstance()->getSelectionsCollection($product->getTypeInstance()->getOptionsIds());
    $options = $optionCollection->appendSelections($selectionCollection);

    foreach($options as $option) {
        $_selections = $option->getSelections();

        foreach($_selections as $selection) {
            $bundled_items[$option->getOptionId()][] = $selection->getSelectionId();

    $params = array('bundle_option' => $bundled_items,'qty' => 1,'product'=>$productId);

if (isset($params['qty'])) {
    $filter = new Zend_Filter_LocalizedToNormalized(
        array('locale' => Mage::app()->getLocale()->getLocaleCode())
    $params['qty'] = $filter->filter($params['qty']);

$product = new Mage_Catalog_Model_Product();

$cart->addProduct($product, $params);

    array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse())
  • I tried the code and I did a slit change ( since my options are not multi, I removed the counter and kept one selection for each option ). but still getting the same error. my problem is not about the params, I manage to get them correctly, but when I load the product I get empty options, so when I pass it on addProduct, it reaches a point where Magento tries to getOptions but it's empty and returns the error message, to be specific it happens in Mage_Catalog_Model_Product_Type_Abstract._prepareOptions when fetching $this->getProduct($product)->getOptions()
    – Ayoub Moum
    Sep 1, 2020 at 9:15
  • i have add another answer you can check Sep 1, 2020 at 10:30

To get All Options For Bundle Products you can use

$store_id = $_storeManager->getStore()->getId();
                $options = $_objectManager->get('Magento\Bundle\Model\Option')
    $typeInstance = $_objectManager->get('Magento\Bundle\Model\Product\Type');
    $selections = $typeInstance->getSelectionsCollection($typeInstance->getOptionsIds($product), $product);
  • the thing is that I already get the options this way and I pass them as a parameter of addProduct but when loading the product itself the options are always an empty array and I don't wanna override Magento's functions. I get the error message Selected required options are not available. or I get Please specify product option(s).
    – Ayoub Moum
    Sep 1, 2020 at 10:47

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.