{"id":55251,"date":"2016-07-22T09:28:37","date_gmt":"2016-07-22T09:28:37","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=55251"},"modified":"2026-02-13T11:41:32","modified_gmt":"2026-02-13T11:41:32","slug":"bundle-product-items-magento-2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/","title":{"rendered":"How to Get Bundle Product Items in Magento 2"},"content":{"rendered":"\n<p>Here, we will explore how to retrieve and work with bundle product items in Magento 2, including their product IDs and associated selection data.<\/p>\n\n\n\n<p>Now here is the code to get all the selected products&nbsp;of bundle products:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\t\nnamespace Webkul\\Test\\Helper;\n\nuse Magento\\Catalog\\Model\\ProductFactory;\n\n\nclass Data extends \\Magento\\Framework\\App\\Helper\\AbstractHelper \n{\n\t\/**\n     * @var Magento\\Catalog\\Model\\ProductFactory\n     *\/\n    protected $_productFactory;\n\n\n    public function __construct(\n        \\Magento\\Framework\\App\\Helper\\Context $context,\n        ProductFactory $productFactory\n    ) {\n        parent::__construct($context);\n        $this-&gt;_productFactory = $productFactory;\n    }\n\n    public function getBundleProductOptionsData()\n    {\n\n\t\t$productId = 40;\/\/any product id\n\t\t$product = $this-&gt;_productFactory-&gt;create()-&gt;load($productId);\n\t\t\/\/get all the selection products used in bundle product.\n\t\t$selectionCollection = $product-&gt;getTypeInstance(true)\n\t        -&gt;getSelectionsCollection(\n\t            $product-&gt;getTypeInstance(true)-&gt;getOptionsIds($product),\n\t            $product\n\t        );\n\n\t    foreach ($selectionCollection as $proselection) {\n\t        $selectionArray = &#091;];\n\t        $selectionArray&#091;&#039;selection_product_name&#039;] = $proselection-&gt;getName();\n\t        $selectionArray&#091;&#039;selection_product_quantity&#039;] = $proselection-&gt;getPrice();\n\t        $selectionArray&#091;&#039;selection_product_price&#039;] = $proselection-&gt;getSelectionQty();\n\t        $selectionArray&#091;&#039;selection_product_id&#039;] = $proselection-&gt;getProductId();\n\t        $productsArray&#091;$proselection-&gt;getOptionId()]&#091;$proselection-&gt;getSelectionId()] = $selectionArray;\n\t    }\n\n\t    \/\/get all options of product\n\t    $optionsCollection = $product-&gt;getTypeInstance(true)\n\t        -&gt;getOptionsCollection($product);\n\n\t    foreach ($optionsCollection as $options) {\n\t        $optionArray&#091;$options-&gt;getOptionId()]&#091;&#039;option_title&#039;] = $options-&gt;getDefaultTitle();\n\t        $optionArray&#091;$options-&gt;getOptionId()]&#091;&#039;option_type&#039;] = $options-&gt;getType();\n\t    \t\n\t    }\n\t}\n}<\/pre>\n\n\n\n<p>It returns all the product&#8217;s items&nbsp;with item&nbsp;data and selection product data.<\/p>\n\n\n\n<p>Here, $productId is a product ID of bundle type product.<\/p>\n\n\n\n<p>$_productFactory is an instance of Magento\/Catalog\/Model\/ProductFactory<\/p>\n\n\n\n<p>$product is a type of Magento\/Catalog\/Model\/Product that holds the product data of the product with id $productId.<\/p>\n\n\n\n<p>$selectionCollection is a collection of products in bundle type products.<\/p>\n\n\n\n<p>$optionsCollection is a collection of items&nbsp;used in bundle products.<\/p>\n\n\n\n<p>After Printing $optionArray and $productArray you will get data of bundle product&#8217;s items.<\/p>\n\n\n\n<p>Thank you for reading this dev doc article, hope you liked it. If you have any queries, you may reach out to our team via a <a href=\"https:\/\/webkul.uvdesk.com\/en\/customer\/create-ticket\/\" target=\"_blank\" rel=\"noreferrer noopener\">support ticket<\/a>.<\/p>\n\n\n\n<p>For more functionalities and features, you can check various <a href=\"https:\/\/store.webkul.com\/Magento-2.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 extensions<\/a> and also check out <a href=\"https:\/\/store.webkul.com\/magento2-product-bundle-discount.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 Product Bundle<\/a> to provide custom offers on products.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here, we will explore how to retrieve and work with bundle product items in Magento 2, including their product IDs and associated selection data. Now here is the code to get all the selected products&nbsp;of bundle products: It returns all the product&#8217;s items&nbsp;with item&nbsp;data and selection product data. Here, $productId is a product ID of <a href=\"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":68,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302,1],"tags":[2070],"class_list":["post-55251","post","type-post","status-publish","format-standard","hentry","category-magento2","category-uncategorized","tag-magento2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Get Bundle Product Items in Magento 2<\/title>\n<meta name=\"description\" content=\"Learn how to get bundle product items in Magento 2\u00a0and their product IDs. With all the item\u00a0data and selection product data.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Get Bundle Product Items in Magento 2\" \/>\n<meta property=\"og:description\" content=\"Learn how to get bundle product items in Magento 2\u00a0and their product IDs. With all the item\u00a0data and selection product data.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-07-22T09:28:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-13T11:41:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Bulbul\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bulbul\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/\"},\"author\":{\"name\":\"Bulbul\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/c9c6288b3950490ffdb37cb2a526996e\"},\"headline\":\"How to Get Bundle Product Items in Magento 2\",\"datePublished\":\"2016-07-22T09:28:37+00:00\",\"dateModified\":\"2026-02-13T11:41:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/\"},\"wordCount\":186,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"keywords\":[\"Magento2\"],\"articleSection\":[\"Magento2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/\",\"url\":\"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/\",\"name\":\"How to Get Bundle Product Items in Magento 2\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2016-07-22T09:28:37+00:00\",\"dateModified\":\"2026-02-13T11:41:32+00:00\",\"description\":\"Learn how to get bundle product items in Magento 2\u00a0and their product IDs. With all the item\u00a0data and selection product data.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Get Bundle Product Items in Magento 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/c9c6288b3950490ffdb37cb2a526996e\",\"name\":\"Bulbul\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/37ea7175f5ae6557d01bb38e147f6a02a540714ecdb71770d8ec554d4d34c23f?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/37ea7175f5ae6557d01bb38e147f6a02a540714ecdb71770d8ec554d4d34c23f?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g\",\"caption\":\"Bulbul\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/bulbul896\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Get Bundle Product Items in Magento 2","description":"Learn how to get bundle product items in Magento 2\u00a0and their product IDs. With all the item\u00a0data and selection product data.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/","og_locale":"en_US","og_type":"article","og_title":"How to Get Bundle Product Items in Magento 2","og_description":"Learn how to get bundle product items in Magento 2\u00a0and their product IDs. With all the item\u00a0data and selection product data.","og_url":"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2016-07-22T09:28:37+00:00","article_modified_time":"2026-02-13T11:41:32+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Bulbul","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Bulbul","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/"},"author":{"name":"Bulbul","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/c9c6288b3950490ffdb37cb2a526996e"},"headline":"How to Get Bundle Product Items in Magento 2","datePublished":"2016-07-22T09:28:37+00:00","dateModified":"2026-02-13T11:41:32+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/"},"wordCount":186,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"keywords":["Magento2"],"articleSection":["Magento2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/","url":"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/","name":"How to Get Bundle Product Items in Magento 2","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2016-07-22T09:28:37+00:00","dateModified":"2026-02-13T11:41:32+00:00","description":"Learn how to get bundle product items in Magento 2\u00a0and their product IDs. With all the item\u00a0data and selection product data.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/bundle-product-items-magento-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Get Bundle Product Items in Magento 2"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/c9c6288b3950490ffdb37cb2a526996e","name":"Bulbul","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/37ea7175f5ae6557d01bb38e147f6a02a540714ecdb71770d8ec554d4d34c23f?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/37ea7175f5ae6557d01bb38e147f6a02a540714ecdb71770d8ec554d4d34c23f?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g","caption":"Bulbul"},"url":"https:\/\/webkul.com\/blog\/author\/bulbul896\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/55251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/68"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=55251"}],"version-history":[{"count":15,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/55251\/revisions"}],"predecessor-version":[{"id":526473,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/55251\/revisions\/526473"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=55251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=55251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=55251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}