When i execute follow code
$options = [
[
'title' => 'drop_down option',
'type' => 'drop_down',
'is_require' => true,
'sort_order' => 4,
'values' => [
[
'title' => 'drop_down option 1',
'price' => 10,
'price_type' => 'fixed',
'sku' => 'drop_down option 1 sku',
'sort_order' => 1,
],
[
'title' => 'drop_down option 2',
'price' => 20,
'price_type' => 'fixed',
'sku' => 'drop_down option 2 sku',
'sort_order' => 2,
],
],
]
];
foreach ($options as $arrayOption) {
$option = $this->objectManager->create(\Magento\Catalog\Model\Product\Option::class)
->setProductId($_product->getId())
->setStoreId($_product->getStoreId())
->addData($arrayOption);
$option->save();
$_product->addOption($option);
$_product->save();
}
- Custom Option not appear on product frontend page.
When goto to product page from admin page and click save without any changing.
Then goto frontend product page custom show up.
I want create option programmatically and should shown on front page without saving product from admin panel.