Magento 2 supports the functionality for creating and assigning the custom options to the products. The process to add new custom product options is simple for any store owner.
Follow the steps given below for getting Product Options in Magento 2:
- Generate Object Manager1$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
- Generate the Product1$product = $_objectManager->get('\Magento\Catalog\Model\Product')->load($id);
- Custom Options1$customOptions = $_objectManager->get('Magento\Catalog\Model\Product\Option')->getProductOptionCollection($product);
- Configurable Options123$productTypeInstance = $_objectManager->get('Magento\ConfigurableProduct\Model\Product\Type\Configurable');$productAttributeOptions = $productTypeInstance->getConfigurableAttributesAsArray($product);
- Grouped Childs1$typeInstance = $_objectManager->get('Magento\GroupedProduct\Model\Product\Type\Grouped');$childs = $typeInstance->getAssociatedProducts($product);
- Bundle Selection12345678$store_id = $_storeManager->getStore()->getId();$options = $_objectManager->get('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);
Following these steps will enable Product Options in your Magento 2 Store.
If you have faced any issue while using this guide, do let us know by commenting below and we will help you out.
Hope to see you in the Next Tutorial. B’bye. ?
Get Weekly Updates
Never miss Magento tips, tricks, tutorials, and news.
Thank you for subscribing.
Something went wrong.
4.6
(based on 19 Reviews)