You can get the bundle options details by bundle product SKU and option id using Magento 2 to explore option related information.
Magento 2 Native sample data comes with bundle product name, Sprite Yoga Companion Kit and SKU 24-WG080.
You can use interface, Magento\Bundle\Api\ProductOptionRepositoryInterface to fetch detail of options from the bundle.
<?php namespace Jesadiya\BundleOptions\Model; use Magento\Bundle\Api\Data\OptionInterface; use Magento\Bundle\Api\ProductOptionRepositoryInterface; class BundleOptionsBySkuOptionId { /** * @var ProductOptionRepositoryInterface */ private $productOptionRepo; public function __construct( ProductOptionRepositoryInterface $productOptionRepo ) { $this->productOptionRepo = $productOptionRepo; } /** * option type details of bundle products * * @return OptionInterface */ public function getBundleOptionDetailBySkuOptionId() { $sku = '24-WG080'; $optionId = 1; $items = $this->productOptionType->get($sku, $optionId); return $items; } }
Call Functions,
$items = $this->getBundleOptionDetailBySkuOptionId();
echo “<pre>”;print_r($items->debug());
Output:
Array ( [option_id] => 1 [required] => 1 [position] => 1 [type] => radio [title] => Sprite Stasis Ball [sku] => 24-WG080 [product_links] => Array ( [0 (Magento\Bundle\Model\Link)] => Array ( [entity_id] => 26 [sku] => 24-WG081-blue [option_id] => 1 [position] => 1 [is_default] => 1 [id] => 1 [qty] => 1.0000 [selection_can_change_quantity] => 1 ) [1 (Magento\Bundle\Model\Link)] => Array ( [entity_id] => 29 [sku] => 24-WG082-blue [option_id] => 1 [position] => 2 [is_default] => 0 [id] => 2 [qty] => 1.0000 [selection_can_change_quantity] => 1 ) [2 (Magento\Bundle\Model\Link)] => Array ( [entity_id] => 32 [sku] => 24-WG083-blue [option_id] => 1 [position] => 3 [is_default] => 0 [id] => 3 [qty] => 1.0000 [selection_can_change_quantity] => 1 ) ) )
You can get the details of Sprite Stasis Ball option from the sample data bundle product.