How To

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

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!
Click to rate this post!
[Total: 31 Average: 3]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate 🎖️ Certified Magento Developer👨‍💻. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.🏏

View Comments

Recent Posts

How to Delete Product Variant in a Shopify Remix App using GraphQL Mutations?

Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…

2 hours ago

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

2 days ago

How Upcoming Cookie Changes Will Affect Your E-commerce Website?

The e-commerce world is constantly in flux. New tech and strategies emerge daily to help…

2 days ago

Magento 2: How to Add Header and Footer in Checkout

Hello Magento Friends, In today’s blog, we will discuss adding a header and footer to…

3 days ago

Understanding Flexbox Layout in React Native

Hello React Native Friends, Building a visually appealing and responsive mobile app is crucial in…

5 days ago

HYVÄ Themes Releases: 1.3.6 & 1.3.7 – What’s New

We have brought exciting news for Magento store owners. Hyvä Themes recently released 1.3.6 and…

5 days ago