Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to get Bundel items from the bundel product in magento?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 376
    Comment on it

    In Magento, if we are required to check the items of Bundle product for some purpose, then we can do it by following way:


    For the same purpose lets check the below code:

    < ?php
    
     $product = new Mage_Catalog_Model_Product();  
     $product->load($BUNDLED_PRODUCT_ID);
    
    
     $selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
      $product->getTypeInstance(true)->getOptionsIds($product), $product
     );
    
     $items = array();
     foreach($selectionCollection as $option)
     {
      $items[] = $option->product_id;
     }
    
     print_r($items);
    
    ?>
    

     

    In the above code lets see what we have done, first of all we have loaded the product to the $product. the next step is to get the collection i.e., the array of the Bundle product.


    To do so we have used a Magento function getSelectionsCollection() method and passed the product Type Instance
    and option Ids. Now, as we have assigned the collection to the array $selectionCollection, the next step is to extract the bundle items ID.


    In the foreach loop the $selectionCollection is passed in array place and extracted the Bundle items Ids through $option->product_id and assigned to $items[] array.

     

    Finally we have the Bundle Product's Item Ids in the array $items[]. In the final step we have printed the $items[] array to display the ids.

     

    That's how we can get the item from the Bundle product to perform any operations on them.  
     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: