1

Product "A", Product "B", and Product "C" are all products in Product Bundle "ABC".

I'm trying to achieve the following scenario:

If a user is on the product page for any individual Product, a link will be displayed that sends them to the Product Bundle page.

If there is a way to do this programmatically so that this will apply to any and all bundled products, that'd be great (i.e. Products A,B,C link to Bundle ABC, Products D,E,F link to Bundle DEF, etc.)

Thanks!

1

Yes it's possible. Given current product ID $productId you can find the IDs of all bundles that contain this product with:

$bundleIds = Mage::getResourceSingleton('bundle/selection')
    ->getParentIdsByChild($childId);

Now you can load a collection based on these (a product can be part of multiple bundles):

$bundles = Mage::getResource('catalog/product_collection')->addIdFilter($bundleIds)
foreach ($bundles as $bundle) {
    $bundleUrl = $bundle->getUrlInStore();
    $bundleName = $bundle->getName();

    // now do what you need to display a link
}

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.