cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Simple Product Customizable Options

How to get Simple Product Customizable Options

Hi team,

 

I am trying to get Customizable Options for a simple product (Not for Config)

I have a custom option for a given simple product. I tried following code but none of returning that custom option.

 

Method 1

$simpleProductId = '5928';
$simpleProduct = $this->_productFactory->create();
$simpleProduct = $simpleProduct->load($simpleProductId);


foreach ($simpleProduct->getOptions() as $option) {
print_r("1");
print_r($option->getValue());
print_r($option->getCode());
}

 

Method 2
$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $_objectManager->get('\Magento\Catalog\Model\Product')->load($simpleProductId);
print_r($product->getId());

foreach ($product->getOptions() as $option) {
print_r("2");
print_r($option->getValue());
print_r($option->getCode());
}

 

Method 3
$customOptions = $_objectManager->get('Magento\Catalog\Model\Product\Option')->getProductOptionCollection($product);

foreach ($customOptions as $option) {
print_r("3");
print_r($option->getValue());
print_r($option->getCode());
}

 

Could someone look at this and tell me what I am missing here or if I have to use any other method?

 

Thanks in advance,

Deecee