Is there any reason why Attribute sets are hardcoded in magento 2 in interfaces?

Example in Magento\Customer\Api\CustomerMetadataInterface has const ATTRIBUTE_SET_ID_CUSTOMER=1

Magento\Rma\Api\RmaAttributesManagementInterface has it too as ATTRIBUTE_SET_ID=9

Because of that - when you have non standard attribute set Ids (i.e. after data migration from M1) - you cannot save any custom attributes as they belong somewhere else


Customer entity save in admin happens in \Magento\Customer\Controller\Adminhtml\Index\Save

and data from request is populated using data object helper


and that helper is trying to load all custom attributes using

Magento\Customer\Model\Metadata\CustomerMetadata method getAllAttributesMetadata()

public function getAllAttributesMetadata()
        /** @var AbstractAttribute[] $attribute */
        $attributeCodes = $this->attributeMetadataDataProvider->getAllAttributeCodes(

        $attributesMetadata = [];

        foreach ($attributeCodes as $attributeCode) {
            try {
                $attributesMetadata[] = $this->getAttributeMetadata($attributeCode);
            } catch (NoSuchEntityException $e) {
                //If no such entity, skip

        return $attributesMetadata;

As you can see if your attribute set Id is non default one, all custom attributes will not be included there, so no data will be populated.

eav_entity_table has column for default_attribute_set_id per entity and it is not hardcoded there

1 Answer 1


Well I reckon the problem here is that by default Magento (1 or 2) does not allow you to change the attribute set for the customer entity.

One attribute set is shipped by default with the software and its id is 1.

So in every install unless you have used a module or a corrupted/manually modified database this ID will always be 1.

Thus, when the data migration tool runs it will not work as your original database is not valid.

The solution would be to either temporary rewrite those classes or manually make changes in your database at your own risks. Maybe try to fix your M1 database first before migration.

  • During migration from M1 > M2 attribute_set_ids change (Even on a clean install) You'll end with some attribute sets like Migration_* and default Magento 2 attribute sets will remain as well Mar 8, 2018 at 13:46

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.