When magento2 store has 3rd parties system integration then we might be need to store 3rd parties data in magento to make relationships.
We might be need additional attribute to save 3rd parties data in magento 2. Here is post for create new customer attribute in magento2.
https://www.magedad.com/magento-2-create-a-customer-attribute-programmatically-using-setup-data-patch/
1. Get Custom Customer Attribute Value Programatically
/* Magento\Customer\Api\CustomerRepositoryInterface */
$customer = $this->customerRepository->getById($customerId);
$externalIdAttribute = $customer->getCustomAttribute('external_id');
if ($externalIdAttribute) {
$externalId = $externalIdAttribute->getValue();
}
2. Save Custom Customer Attribute Value Programatically
/* Magento\Customer\Api\CustomerRepositoryInterface */
$customer = $this->customerRepository->getById($customerId);
$customer->setCustomAttribute('external_id', 'ABC123');
$this->customerRepository->save($customer);
That’s it. We also have other customer related post might be it’s help to you.
- How to create customer using REST API?
- Create a customer address attribute programmatically using setup data patch
You can follow this link for more help.
I hope this blog is useful to set/get customer attribute value in magento2 and save. In case, I missed anything or need to add some more information, Don’t heisted to leave a comment in this blog, I’ll get back with some positive approach.
Keep liking 👍 Keep sharing 📣 Keep loving ❤️ Keep inspiring 🤩
10 Comments
**breathe**
breathe is a plant-powered tincture crafted to promote lung performance and enhance your breathing quality.
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
Your article helped me a lot, is there any more related content? Thanks!
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
Your point of view caught my eye and was very interesting. Thanks. I have a question for you.
https://t.me/s/Top_BestCasino/127
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article. https://www.binance.info/sk/register?ref=WKAGBF7Y
Your article helped me a lot, is there any more related content? Thanks! https://accounts.binance.info/da-DK/register-person?ref=V3MG69RO
Alright folks, mcgamesbet.info…seems like a combo of gaming and betting? What’s the deal? Are the odds any good on this site or is it just another trap? Would love to hear if anyone’s actually won something here. mcgamesbet
Hey Beeph! Beeph is the name, and legit gaming is the game. Solid platform, easy to navigate. Worth a look if you’re hunting for some fun. beeph