Every Business is different that’s why the information that is stored & proceed by business is different too. Being featured pack CMS, Magento allows the store owner to create, store and proceed their own custom attribute in the database. Basically, an attribute is the property of a product which can be used for fulfilling business needs.
Recently, developers are facing an issue while saving customer attribute programmatically in Magento 2. It doesn’t show any error while running the script from the root, but when you check the saved attribute it reruns blank. Meanwhile working on extension development and customization we faced this issue multiple times that’s why we decided to fix this issue & we found that even this issue request in pulled by one of Magento developer on Official Magento Github. After spending some time in coding we found a code that did work for us that I am going to share on today’s blog.
Here in this example, we have tried to save custom attribute value using Controller file in custom extension. To fix this issue, firstly we need to create ‘controller.php’ file at below location.
app\code\Vendor\Extension\Controller\Index
Lastly, Comment down below if you face any issue while using this code. Happy Coding!
All these tutorials show you how to create the field but none mention that you’ll need a controller to save it! This worked!! Thank you.
Thank you. Glad we could help you 🙂