i want to get bundled product id made using product ids.

suppose there is bundled product A made using product B and product c

i want to get product A , given ids of Product B and C.

How can i proceed


You can use the Mage_Bundle_Model_Product_Type::getParentIdsByChild method for each of the products B and C and then check the intersection.

Let's say that B id is $idB and C id is $idC.

$typeInstance = Mage::getSingleton('bundle/product_type');
$bParents = $typeInstance->getParentIdsByChild($idB);
$cParents = $typeInstance->getParentIdsByChild($idC);
$intersection = array_intersect($bParents, $cParents);

All the ids in the $intersection array represent bundle products that have as child products both B and C.

  • it works but , i am bit confused if it will works in all cases and give right product ?
    – mcoder
    Oct 13 '14 at 11:27
  • There could be cases when products B and C are part of 2 main products A and A1. Then you will get 2 ids in the $intersection array.
    – Marius
    Oct 13 '14 at 11:28
  • what if i restrict 1: make a bundled product with not more than two products 2: what have i to do to make above filter apply to crtain category id :$typeInstance = Mage::getSingleton('bundle/product_type'); use this for for specific category not for all ?.
    – mcoder
    Oct 13 '14 at 11:53
  • @saurav. This seams like a totally different question. and honestly I don't really understand it. Feel free to ask an other question and explain what you need.
    – Marius
    Oct 13 '14 at 11:57
  • i want to say if i make bundled products with only two product then we will always get right product ??
    – mcoder
    Oct 13 '14 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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