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

PHP
/* 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

PHP
/* 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.

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 🤩

29 Comments

  1. 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.

  2. 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?

  3. 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?

  4. 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?

  5. 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?

  6. Thank you, your article surprised me, there is such an excellent point of view. Thank you for sharing, I learned a lot.

  7. Searching for trusted roof installation in Lancaster? Roof Installation Pros provides expert services across all roofing styles. Their experienced team guarantees strong, lasting installations that enhance your home’s protection and market value. Excellent service, always on time and within budget.

  8. Get reliable roof installation services in Lancaster with Roof Installation Pros. Whether it’s a new roof or a replacement, their experienced crew delivers quality craftsmanship that lasts. Known for fair pricing and dependable results that boost home value—your roof is in safe hands.

  9. Searching for trusted roof installation in Lancaster? Roof Installation Pros provides expert services across all roofing styles. Their experienced team guarantees strong, lasting installations that enhance your home’s protection and market value. Excellent service, always on time and within budget.

  10. For dependable and expert roof installation services in Lancaster, Roof Installation Pros is your go-to choice. They specialize in all roofing types, delivering lasting solutions that safeguard your property and boost its value. Count on them for affordable, high-quality, and on-time service.

  11. 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.

Write A Comment