window.addEventListener('error', function(e) { var msg = e.message || ''; if (msg.indexOf('Failed to fetch dynamically imported module') > -1 || msg.indexOf('Importing a module script failed') > -1) { console.warn('New deployment detected, reloading page...'); window.location.reload(); } }, true);    -          /* Montserrat Variable Font (Weights 100-900) */ @font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('/fonts/Montserrat/Montserrat-VariableFont_wght.ttf') format('truetype'); } @font-face { font-family: 'Montserrat'; font-style: italic; font-weight: 100 900; font-display: swap; src: url('/fonts/Montserrat/Montserrat-Italic-VariableFont_wght.ttf') format('truetype'); } /* Open Sans Variable Font (Weights 300-800) */ @font-face { font-family: 'Open Sans'; font-style: normal; font-weight: 300 800; font-display: swap; src: url('/fonts/Open_Sans/OpenSans-VariableFont_wdth,wght.ttf') format('truetype'); } @font-face { font-family: 'Open Sans'; font-style: italic; font-weight: 300 800; font-display: swap; src: url('/fonts/Open_Sans/OpenSans-Italic-VariableFont_wdth,wght.ttf') format('truetype'); }  Adobe Commerce: How To Make Customer Attribute ?                                /* If Javascript is enabled but the js_disabled cookie or ?js=0 query parameter is active, restore SPA mode */ var hasJsCookie = document.cookie.indexOf('js_disabled=1') !== -1; var hasJsParam = window.location.search.indexOf('js=0') !== -1; if (hasJsCookie || hasJsParam) { if (hasJsCookie) { const host = window.location.hostname; const wildDomain = '.' + host.replace(/^www\./, ''); document.cookie = 'js_disabled=; expires=Thu, 01 Jan 1970 00:00:00 UTC; Max-Age=0; path=/;'; document.cookie = 'js_disabled=; expires=Thu, 01 Jan 1970 00:00:00 UTC; Max-Age=0; path=/; domain=' + host + ';'; document.cookie = 'js_disabled=; expires=Thu, 01 Jan 1970 00:00:00 UTC; Max-Age=0; path=/; domain=' + wildDomain + ';'; } if (hasJsParam) { var cleanUrl = window.location.protocol + '//' + window.location.host + window.location.pathname + window.location.search.replace(/[?&]js=0&?/g, '').replace(/\?$/, ''); window.location.replace(cleanUrl); } else { window.location.reload(); } }   /* Prevent FOUC for navigation submenus before CSS is loaded */ .navigation ul.submenu { display: none; } /* Prevent FOUC for header and footer before main CSS is loaded */ .page-header, .page-footer { opacity: 0; } /* Prevent FOUC for hidden elements before CSS is loaded */ .is-hidden { display: none !important; } /* Noscript notice banner */ .noscript-warning-banner { background: linear-gradient(135deg, #1e1e24 0%, #121216 100%); color: #ffffff; padding: 16px 24px; border-bottom: 3px solid #ff9800; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif; font-size: 14px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4); position: relative; z-index: 99999; display: flex; justify-content: center; align-items: center; } .noscript-content { display: flex; align-items: center; gap: 16px; max-width: 1200px; width: 100%; } .noscript-icon { font-size: 24px; line-height: 1; } .noscript-text { flex: 1; } .noscript-text strong { display: block; font-size: 16px; margin-bottom: 4px; color: #ff9800; font-weight: 600; letter-spacing: 0.5px; } .noscript-text p { margin: 0; color: #d1d1e0; line-height: 1.4; }

{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "Organization",
      "@id": "https://www.sashas.org/#organization",
      "name": "Extensions Website",
      "url": "https://www.sashas.org/",
      "logo": {
        "@type": "ImageObject",
        "url": "https://www.sashas.org/logo.png",
        "width": 600,
        "height": 60
      },
      "address": {
        "@type": "PostalAddress",
        "addressLocality": "New York",
        "addressRegion": "NY",
        "addressCountry": "US"
      }
    },
    {
      "@type": "WebSite",
      "@id": "https://www.sashas.org/#website",
      "url": "https://www.sashas.org/",
      "name": "Extensions Website",
      "publisher": {
        "@id": "https://www.sashas.org/#organization"
      },
      "potentialAction": {
        "@type": "SearchAction",
        "target": "https://www.sashas.org/search?q={search_term_string}",
        "query-input": "required name=search_term_string"
      }
    },
    {
      "@type": "WebPage",
      "@id": "https://www.sashas.org/blog/magento-2-make-customer-attribute.html/#webpage",
      "url": "https://www.sashas.org/blog/magento-2-make-customer-attribute.html",
      "name": "Adobe Commerce: How To Make Customer Attribute ?",
      "isPartOf": {
        "@id": "https://www.sashas.org/#website"
      },
      "about": {
        "@id": "https://www.sashas.org/#organization"
      }
    },
    {
      "@type": "BreadcrumbList",
      "@id": "https://www.sashas.org/blog/magento-2-make-customer-attribute.html/#breadcrumb",
      "itemListElement": [
        {
          "@type": "ListItem",
          "position": 1,
          "name": "Home",
          "item": "https://www.sashas.org/"
        }
      ]
    },
    {
      "@type": [
        "BlogPosting",
        "FAQPage"
      ],
      "@id": "https://www.sashas.org/blog/magento-2-make-customer-attribute.html/#article",
      "headline": "Adobe Commerce: How To Make Customer Attribute ?",
      "description": "Learn how to resolve issues and optimize your Adobe Commerce: How To Make Customer Attribute ? setup with our step-by-step technical guide.",
      "datePublished": "2015-07-25T06:53:35.000Z",
      "dateModified": "2015-07-25T06:53:35.000Z",
      "author": {
        "@type": "Person",
        "name": "Sasha Shkolnik",
        "url": "https://www.sashas.org/about-us"
      },
      "publisher": {
        "@id": "https://www.sashas.org/#organization"
      },
      "mainEntity": [
        {
          "@type": "Question",
          "name": "What is the key takeaway of Adobe Commerce: How To Make Customer Attribute ??",
          "acceptedAnswer": {
            "@type": "Answer",
            "text": "This article explains the best practices, optimizations, and technical details regarding Adobe Commerce: How To Make Customer Attribute ?."
          }
        }
      ]
    }
  ]
}

     ⚠️  JavaScript Required To view this page correctly and access all features of S Group, please enable JavaScript in your browser settings.

         Toggle Nav  [![The S Group Ecommerce Development](https://www.sashas.org/images/logo-gray.svg)](https://www.sashas.org/)     [Experience](https://www.sashas.org/customer-experience.html)   [Catalog Enhancements](https://www.sashas.org/customer-experience/catalog-enhancements.html)
 -  [Cart / Checkout](https://www.sashas.org/customer-experience/cart-checkout.html)
 -  [Customers](https://www.sashas.org/customer-experience/customers.html)
 -  [Shipping](https://www.sashas.org/customer-experience/shipping.html)
 -  [Payments](https://www.sashas.org/customer-experience/payments.html)

  -  [Management](https://www.sashas.org/site-management.html)   [Sales / Fulfillment](https://www.sashas.org/site-management/sales-fulfillment.html)
 -  [Catalog](https://www.sashas.org/site-management/catalog.html)
 -  [Customer Support](https://www.sashas.org/site-management/customer-support.html)
 -  [Marketing / Promotions](https://www.sashas.org/site-management/marketing-promotions.html)
 -  [Content](https://www.sashas.org/site-management/content-management.html)
 -  [Reporting & Analytics](https://www.sashas.org/site-management/reporting-analytics.html)

  -  [Optimization](https://www.sashas.org/optimization.html)   [Performance](https://www.sashas.org/optimization/performance.html)
 -  [Monitoring](https://www.sashas.org/optimization/monitoring.html)
 -  [Troubleshooting / Debugging](https://www.sashas.org/optimization/troubleshooting-debugging.html)

  -  [Blog](https://www.sashas.org/blog)
 -  [About Us](https://www.sashas.org/about-us.html)
              - [My Account](https://www.sashas.org/customer/account/)
 - [Sign Out](https://www.sashas.org/#)
 - [Sign In](https://www.sashas.org/customer/login/)

           0    You have no items in your shopping cart.

      -                      [Home](https://www.sashas.org/)
 - /
 - [Blog](https://www.sashas.org/blog/)
 - /
 - [Adobe Commerce](https://www.sashas.org/blog/?category=adobe%20commerce)
 - /
 - Adobe Commerce: How To Make Customer Attribute ?

   # Adobe Commerce: How To Make Customer Attribute ?

 ![Adobe Commerce: How To Make Customer Attribute ? - Adobe Commerce Technical Guide Guide](https://www.sashas.org/images/blog/img-magento-2-make-customer-attribute.html-i.0.png)

 Since Adobe Commerce is pretty close to release we can review how the adding of custom attribute process has been changed. Today we will make Adobe Commerce extension which adds customer attribute into customer edit page at admin. To start with it we will have to have Adobe Commerce installed with Demo data. You can find Adobe Commerce Installation Guide at [Adobe Commerce Developer Documentation](https://devdocs.magento.com/guides/v2.0/install-gde/continue.html).

 # [UPD. For Adobe Commerce.1 & newest editions please read updated article](http://docs.google.com/blog/magento-2-1-3-how-to-make-customer-attribute-update.html).

 ## 1. Making Adobe Commerce extension skeleton

 The extension files now will be at the app/code/{Company_Name}/{Extension_Name} location. Where {Company_Name} and {Extension_Name} our values. Exactly same way was in Adobe Commerce 1.x . For our extension we will use Company name Sashas and Extension name CustomerAttribute . Once we will create folders the path to our extension will be app/code/Sashas/CustomerAttribute/ Folder structure inside extension folder is very similar from Adobe Commerce.x to Adobe Commerce 1.x. There are same Block, Controller, etc, Helper and Model folders. In our case we will need to make etc and Setup folder. The final folder tree for our Adobe Commerce extension will look this way: ![Adobe Commerce: How To Make Customer Attribute ? - Adobe Commerce Technical Guide Guide](https://www.sashas.org/images/blog/img-magento-2-make-customer-attribute.html-i.1.png) Now we need to create module.xml file for our extension to declare version and make it visible for Adobe Commerce. The module.xml file in Adobe Commerce replacement for previous module file at app/etc/modules folder. This way now all files related to our extension will be in the one folder.

 ## 2. Adobe Commerce Customer Attribute Module Files

 The first file we will need to make it is app/code/Sashas/CustomerAttribute/etc/module.xml This file will make our extension visible for Adobe Commerce and there we can declare dependency our customer attribute extension  from the Adobe Commerce_Customer module.

   <?xml version="1.0" encoding="UTF-8"?>
<config  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
   <module name="Sashas_CustomerAttribute"  setup_version="1.0.0">
        <sequence>
            <module name="Magento_Customer"/>
        </sequence>
   </module>
</config>

 Also you can notice there that at section we have definition of extension name and version. The second and the list file we will add its is Installation script. It will have path app/code/Sashas/CustomerAttribute/Setup/InstallData.php This file i had issues when I tried it the first time, but thanks to Adobe Commerce team they helped to figure it out. All action there happens at the install function where we add attribute for entity type "customer" and after it we set this attribute to be used in form "adminhtml_customer". Customer attributes can be used in different forms, this example will show customer attribute at the admin customer edit page.  You can also use also other forms. For example:  "used_in_forms" =>  ['adminhtml_customer_address', 'customer_address_edit', 'customer_register_address'] The final code of the InstallData.php file will look like this:

   <?php
namespace Sashas\CustomerAttribute\Setup;
use Magento\Customer\Setup\CustomerSetupFactory;
use Magento\Customer\Model\Customer;
use Magento\Eav\Model\Entity\Attribute\Set as AttributeSet;
use Magento\Eav\Model\Entity\Attribute\SetFactory as AttributeSetFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;

/**
 * @codeCoverageIgnore
 */
class InstallData implements InstallDataInterface
{

    /**
     * @var CustomerSetupFactory
     */
    protected $customerSetupFactory;

    /**
     * @var AttributeSetFactory
     */
    private $attributeSetFactory;

    /**
     * @param CustomerSetupFactory $customerSetupFactory
     * @param AttributeSetFactory $attributeSetFactory
     */
    public function __construct(
        CustomerSetupFactory $customerSetupFactory,
        AttributeSetFactory $attributeSetFactory
    ) {
        $this->customerSetupFactory = $customerSetupFactory;
        $this->attributeSetFactory = $attributeSetFactory;
    }

    /**
     * {@inheritdoc}
     */
    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {

        /** @var CustomerSetup $customerSetup */
        $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

        $customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
        $attributeSetId = $customerEntity->getDefaultAttributeSetId();

        /** @var $attributeSet AttributeSet */
        $attributeSet = $this->attributeSetFactory->create();
        $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

        $customerSetup->addAttribute(Customer::ENTITY, 'magento_username', [
            'type' => 'varchar',
            'label' => 'Magento Username',
            'input' => 'text',
            'required' => false,
            'visible' => true,
            'user_defined' => true,
            'sort_order' => 1000,
            'position' => 1000,
            'system' => 0,
        ]);

        $attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'magento_username')
        ->addData([
            'attribute_set_id' => $attributeSetId,
            'attribute_group_id' => $attributeGroupId,
            'used_in_forms' => ['adminhtml_customer'],
        ]);

        $attribute->save();

    }
}   In the example we use attribute code "magento_username" and you can see at Lines 68-76 we set properties of the attribute. The properties identical to the Adobe Commerce 1.x values. After we done with code we need to launch magento upgrade and clean cache.  Launch Adobe Commerce upgrade we can from the shell by using command:

   php bin/magento  setup:upgrade   This will go thru installed extension and perform upgrade or extension installation with data and database tables. Clean cache we can also with shell command:

   php bin/magento  cache:flush --all

 ## 3. The result

 In the result we can see our field at the admin of Adobe Commerce customer edit page, it is in General Tab: ![Adobe Commerce: How To Make Customer Attribute ? - Adobe Commerce Technical Guide Guide](https://www.sashas.org/images/blog/img-magento-2-make-customer-attribute.html-i.2.png) I hope this article would help you with exploring new Adobe Commerce platform. You can also access extension code at the [GitHub](https://github.com/sashas777/magento2-customer-attribute-extension)

 ## 4. Still having difficulties? Watch how it was done on Video:

   ID mTMCJqOrxOs

       - [Contac Us](https://www.sashas.org/contact/)
 - [Privacy Policy](https://www.sashas.org/privacy-and-refund-policy.html)
 - [Refund Policy](https://www.sashas.org/refund-policy.html)

  © The S Group. All Rights Reserved.