Magento 2 – How to Get Default Quantity of Child Product in Bundle Product

bundled-productmagento-2.1.3

Today I am working on Bundle Products, Here I am trying to get the Default Quantity of child product of Bundle Product. But I am unable to get the details. Even though I debugged in product page, I am not getting results.

See My debugging child product of Bundle Product.
enter image description here

I want to get the Default Quantity of Bundle Child Product as shown below pic.

enter image description here

Any help on this?

Best Answer

Finally, I achieved this by fallowing method.

public function getBundleOptions($product){

       /* $bundleOptions = $this->_options->getProduct();
        return $bundleOptions;*/
        $_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $store_id = 1;
        $options = $_objectManager->create('Magento\Bundle\Model\Option')
            ->getResourceCollection()
            ->setProductIdFilter($product->getId())
            ->setPositionOrder();
        $options->joinValues($store_id);
        $typeInstance = $_objectManager->get('Magento\Bundle\Model\Product\Type');
        $selections = $typeInstance->getSelectionsCollection($typeInstance->getOptionsIds($product), $product);
        foreach($selections as $selection){
            if($product->getSku() == $selection->getSku()){
                return $selection->getSelectionQty();
            }
        }
        return $selections;
    }
Related Topic