We are working on Magento 2.2 create custom attribute seller_id for customer,this attribute is created successfully.

But we can not display this attribute when loading the customer data.

namespace Kh\Hello\Setup;

use Magento\Customer\Model\Customer;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Customer\Setup\CustomerSetupFactory;
use Magento\Framework\Setup\InstallDataInterface;

class InstallData implements InstallDataInterface

    private $customerSetupFactory;

     * Constructor
     * @param \Magento\Customer\Setup\CustomerSetupFactory $customerSetupFactory
    public function __construct(
        CustomerSetupFactory $customerSetupFactory
    ) {
        $this->customerSetupFactory = $customerSetupFactory;

     * {@inheritdoc}
    public function install(
        ModuleDataSetupInterface $setup,
        ModuleContextInterface $context
    ) {
        $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

        $customerSetup->addAttribute(\Magento\Customer\Model\Customer::ENTITY, 'seller_id', [
            'type' => 'varchar',
            'label' => 'Seller Id',
            'input' => 'text',
            'source' => '',
            'required' => false,
            'visible' => true,
            'position' => 333,
            'system' => false,
            'backend' => ''

        $attribute = $customerSetup->getEavConfig()->getAttribute('customer', 'seller_id')
        ->addData(['used_in_forms' => [


when load customer collection this attribute is not display.

$collection = $this->_customerFactory->create()->getCollection()
                   ->addAttributeToFilter("email", array("eq" => "[email protected]"));

Also loading customer and accessing this attribute data not display.

2 Answers 2


Check to make sure that the attribute is in the customer_form_attribute table.

Additionally, check that the is_system attribute value is set to 0.

Also, you have assigned that attribute to "adminhtml_customer" form only. Might be it will not load attribute on the frontend.


Try also to add attribute to Default attribute set something like this:

$customerEntity = $customerSetup->getEavConfig()->getEntityType(Customer::ENTITY);
$attributeSetId = $customerEntity->getDefaultAttributeSetId();

$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

    'attribute_set_id' => $attributeSetId,
    'attribute_group_id' => $attributeGroupId,
    'used_in_forms' => ['customer_account_edit']

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.