1

I have a bundle product that have different options, and each options have different items. How can I get only a list of default items and it's Default Qty of those options, programmatically.

See the screen shot, I only want to get Sku 020524 and Sku 020592

enter image description here

2
  • Are you trying to get this data in a report format? Commented Jul 27, 2017 at 19:45
  • I got it fixed. But no, not in a report format. I just want to retrieve the information and output it to the browser. Commented Jul 28, 2017 at 7:42

1 Answer 1

4

You can do this:

$product = Mage::getModel('catalog/product')->load(bundle_pruduct_id);
$selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
    $product->getTypeInstance(true)->getOptionsIds($product), $product
);
$bundled_items = array();
foreach($selectionCollection as $option) {
    if ($option->is_default) {
       $bundled_items[] = array(
           'id' => $option->product_id,
           'name' => $option->name,
           'qty'=> $option->selection_qty,
       );
    }

}
print_r($bundled_items);

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.