Serving options to customize the product the way customers love is a key success for any business and Magento 2 allows you to do the same by creating multiple custom options from the backend. Generally, these custom options are displayed on the store front-end and allow your customer to customize the product as per the need of a set of different Custom options.

From the backend, you can manually create custom options for the product by navigating the backend product edit page. But every time creating the same custom options for the product may become a cumbersome task for the store owner. That’s the reason we are back with another blog that will help you to automatically create and assign custom options to the newly created product once you are done with setting up and save the product from the backend.

Here is the code to do the same by creating custom extension.
Firstly, we need to create an “events.xml” file at this path and add below code.
app\code\Vendor\Extension\etc

Now, create one more file “Productoptions.php” at this location
app\code\Vendor\Extension\Observer

That’s it! You are free to add one or more custom options to this extension code.

Now onwards, whenever admin will try to save any product from the backend the extension will trigger “catalog_product_save_after” and automatically creates and assign custom options to that particular product.

The extension will work for all Magento 2 product types.

If you found this blog helpful, don’t forget to share it with your colleagues and Magento Friends.

And, Let us know if you are facing an issue while implementing this code.

Happy Coding!

Click to rate this post!
[Total: 14 Average: 4.7]