cancel
Showing results for 
Search instead for 
Did you mean: 

Bundel products, get product Id by their value

SOLVED
   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Bundel products, get product Id by their value

Hi,

 

I created one bundle product, in bundle items I created one checkbox option with three products, ids 5,6 and 7.

 

In the frontend It have some values assigned to them, 13, 14, 15.

 

I want to get by ajax the product id selected, but I don't know how to do that with the value.

any idea?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Bundel products, get product Id by their value

ok, I have the answer:

 

        $product = Mage::getModel('catalog/product')->load($mainProductId);
        
        $selections = $product->getTypeInstance(true)
                                ->getSelectionsCollection($product->getTypeInstance(true)
                                ->getOptionsIds($product), $product);

        foreach ($selections as $selection) {

            $bundleIds[$selection->getData('selection_id')] = array(
                'product_id' => $selection->getId(),
                'selection_qty' => $selection->getData('selection_qty')
            );
        }

I put the value of the option in the key of the array to get it easely

View solution in original post

1 REPLY 1

Re: Bundel products, get product Id by their value

ok, I have the answer:

 

        $product = Mage::getModel('catalog/product')->load($mainProductId);
        
        $selections = $product->getTypeInstance(true)
                                ->getSelectionsCollection($product->getTypeInstance(true)
                                ->getOptionsIds($product), $product);

        foreach ($selections as $selection) {

            $bundleIds[$selection->getData('selection_id')] = array(
                'product_id' => $selection->getId(),
                'selection_qty' => $selection->getData('selection_qty')
            );
        }

I put the value of the option in the key of the array to get it easely