How to fix issue of saving custom customer attribute value programmatically in Magento 2

Save custom customer attribute value programmatically M2

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!
Previous Article

Save the date, Most awaited MageComp Anniversary Sale is coming soon

Next Article

How to Fix programmatically mini cart not updated issue in Magento 2

Write a Comment
  1. 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.

Leave a Comment

Your email address will not be published. Required fields are marked *

Get Connect With Us

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨