How to Edit Magento 2 Customer Attributes Programmatically

Table of Content

Magento-2-Add-Customer-Attributes-Programmatically
Posted in: Magento 2 Guides

Good day to you, Amasty reader!

As everyone knows, to maintain fruitful business cooperation with your customers and promote the necessary products to them, you, as a business owner, should know more about your current clients.

The perfect way to gain these goals in your Magento 2 is to add Customer Attributes.

Today, I’m going to show you how to edit customer attributes programmatically and via our product – Customer Attributes for Magento 2 extension.

 Also, to improve your customer service try out this Magento 2 Order Number extension and reduce the risk of messing order numbering in a multi-language store.

This extension allows you to create Magento 2 customer address attribute programmatically without limitations in their quantity and get to know your customers better. To create a new attribute, go to Customers>Customer Attributes>Manage Attributes and click on the Add New Attribute button. Here is a list of 11 input types you may use for the purpose:

Each attribute, except the Single file Upload, can be added to the Registration and Checkout pages.
Moreover, every newly created characteristic can be shown on the Order View Page and Customer Information page, as well as in Customers and Orders grids in the backend:

Also, all the attributes are shown on a separate grid where you can find information on the type, sort order, as well as about the page where each of the labels is displayed. Moreover, you can edit attributes right from this grid:

customer-attributes-magento-2-separate-grid-amasty

The big advantage of the extension is a possibility to hide attribute fields that were filled in before. Say, a user is registered on your website and has filled out the extra info forms. Then this client won’t have to fill these fields again during the checkout process. This helps you make the shopping process more convenient and improve customer experience.

At the same time, we highly recommend using the Attributes extension together with Customer Group Catalog for Magento 2. Since there is a Customer group selector attribute type, this allows you separating clients during the registration automatically.

Another key feature of the module is a possibility to create attribute relations. It is a simple way to avoid overloading a website page, and at the same time, to collect useful information about buyers for future beneficial cooperation.

 Note: See the user guide to learn how to manage attribute relations correctly.

Get to know your clients better to meet their individual needs and increase revenue! Explore Customer Attributes

How to modify a created customer attribute programmatically in Magento 2?

As you know, Magento 2 supports REST (Representational State Transfer) and SOAP (Simple Object Access Protocol) like it was in previous Magento versions. Therefore, you can easily manage customer attributes programmatically via API to collect valuable buyer information.

Follow the 5 steps to manage a created customer attribute programmatically:

Step 1: Extend current permissions to administrative

  • Open Magento 2 frontend and put ‘swagger’ at the end of the URL line:

  • To widen permissions, please, find IntegrationAdminToken:

Step 2: Enter the backend credentials

  • Open an example on the right side of the window:

  • and fill in your username and password for the backend panel:

Step 3: Get and use the API key

  • When everything’s ready, you will get the API key:

  • Enter the key here:

Step 4: Edit a customer attribute

  • As you have already received the admin permissions, you are able to edit customer attributes. To do this, please, find customerCustomerRepositoryV1:

  • To find a client, please, open Get tab and enter the Customer ID:

  • and click on the Try it out button. For me, the ID is ‘1’:

  • As a result, you will receive a customer ‘Response body’. Just copy it and go to the next step:

Step 5: Fill in the customer ID and body

  • Open the /V1/customers/{customerId} tab and paste customer body here:

  • Please, do not forget to enter “customer” in this area (it’s marked in green).

Bonus: Get your free instruction on how to edit a customer attribute in Magento 2

Wrap-up

By following the simple steps, you can edit your customer attributes in Magento 2 programmatically. I, in turn, hope this article will help you spend less time on updating Magento customer attribute programmatically and allow you to get more benefits from using our Magento 2 Customer Attributes.

Best of luck and stay tuned!

August 10, 2018
September 12, 2018
July 26, 2018
Comments
Arjun
September 6, 2019
Can I see with this plugin statistic of my customers?
Reply
Polina Litreyeva
September 6, 2019
Hello, Arjun Yes, you can see the report for every attribute. You need to go to<strong> Customers>Customer Attributes>Manage Attributes</strong> open the needed attribute and click on <strong>Reports</strong>.
Bernadette
September 13, 2019
Thanks for your extension! It saves a lot of time!
Reply
Polina Litreyeva
September 13, 2019
Hi Bernadette, thanks for sharing your opinion! We're glad to know the module is helpful.
Leave your comment

Your email address will not be published

This blog was created with Amasty Blog Pro

This blog was created with Amasty Blog Pro

© 2009-2024 Amasty. All Rights Reserved.