Good day to you, Amasty reader!

Today, I’m going to introduce one of our leading products to you – Customer Attributes for Magento 2 extension.

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

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

 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 a limitless number of custom attributes and get to know your customers better. Here is a list of 11 attribute input types you may use for the purpose:

customer-attributes-magento-2-input-types-amasty

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

customer-attributes-magento-2-customers-infromation-amasty

customer-attributes-magento-2-orders-information-amasty

Also, all the customer 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 attribute is displayed:

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

The big advantage of the Customer Attribute extension for Magento 2 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 customer 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 Customer Attributes extension together with Customer Group Catalog for Magento 2. Since there is a Customer group selector attribute type, this allows you separating customers 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 customers for future beneficial cooperation.

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

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 customer information.

How to edit a created customer attribute programmatically?

Follow the 5 steps to edit 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:

customer-attributes-magento-2-swagger-amasty

  • To widen permissions, please, find IntegrationAdminToken:

customer-attributes-magento-2-wide-permissions-amasty

Step 2: Enter the backend credentials

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

customer-attributes-magento-2-example-blog

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

customer-attributes-magento-2-credentials-blog

Step 3: Get and use the API key

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

customer-attributes-magento-2-api-key-amasty

  • Enter the key here:

customer-attributes-magento-2-use-api-key-amasty

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:

customer-attributes-magento-2-customer-id-amasty

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

customer-attributes-magento-2-customer-idjpg-amasty

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

customer-attributes-magento-2-1-amasty

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

customer-attributes-magento-2-response-body-amasty

Step 5: Fill in the customer ID and body

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

customer-attributes-magento-2-customer-body-amasty

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

Bonus: Magento 2 ‘Test’ customer attribute as an example

In my Magento 2, I have created the attribute ‘test’ with the self-titled attribute code:

customer-attributes-magento-2-test-case-amasty

  • and the value of this attribute for my customer is the next one:

customer-attributes-magento-2-value-amasty

  • So, I just found this line to edit the value the way I needed it (of course, in accordance with the attribute type):

customer-attributes-magento-2-result-backend-amasty

  • Then I clicked on the Try it out button and got the following result on the Customer page:

customer-attributes-magento-2-customerpage-amasty

And that’s it!

So, by using this simple method in Magento 2, you can edit created customer attributes and specify as many attributes as you want. All you need for this is to separate them using the commas, like in the example below:

customer-attributes-magento-2-comma-amasty

As we specified two attributes for the customer, on the Customer page, we see two custom attributes:

customer-attributes-magento-2-comma-results-amasty

Wrap-up

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

Best of luck and stay tuned!

Get to know your customers better with our Customer Attributes extension for Magento 2: