0

I have added a Customer custom attribute called about,

$eavSetup->addAttribute(
    \Magento\Customer\Model\Customer::ENTITY, 'about', [
        'type' => 'varchar',
        'label' => 'About',
        'input' => 'text',
        'sort_order' => 1000,
        'required' => false,
        'visible' => true,
        'system' => 0,
        'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
    ]
);

The attribute is shown in Customer's Account information tab, and is successfully saving and retrieving.

The only issue is with the sort_order, whatever number I gave there (10, 10000, 500), the attribute always shows at the top of the list (above Associate to Website).

I have tried cache clean and flush, also upgraded and compiled.

What should I do to bring it to the bottom of the list?

3

I have added a customer attribute "Business Name" through following installation script and it's showing at the bottom of Customer's Account information tab

        $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, 'business_name',
        [
            'type' => 'varchar',
            'label' => 'Bussiness Name',
            'input' => 'text',
            'required' => false,
            'default' => 'NULL',
            'visible' => true,
            'user_defined' => true,
            'sort_order' => 216,
            'position' => 216,
            'system' => false,
        ]);
        $business_name = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY,'business_name')
        ->addData([
            'attribute_set_id' => $attributeSetId,
            'attribute_group_id' => $attributeGroupId,
            'used_in_forms' => ['adminhtml_customer','customer_account_create','customer_account_edit'],
        ]);
        $business_name->save();

I think this is because of "position" property. Please try with above code and let me know if it's still not work.

0

The sort order will be save in ui_bookmark table in database. Find the record of listing file which you are using and delete it after you change the sort order. After that try clean cache by:

php bin/magento cache:flush
php bin/magento cache:clean 

Hope it help you! Here is my ui_bookmark table: enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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