i have the following code :

 $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
        $attributeSet = $this->attributeSetFactory->create();
        $entityTypeId = $categorySetup->getEntityTypeId(\Magento\Catalog\Model\Product::ENTITY);
        $attributeSetId = $categorySetup->getDefaultAttributeSetId($entityTypeId, 'medicamento_expira_curta2');
        $autosettingsTabName = 'medicamento_expira_curta2_group';
        $categorySetup->addAttributeGroup($entityTypeId, $attributeSetId, $autosettingsTabName, 60);
        $data = [
            'attribute_set_name' => 'medicamento_expira_curta2', 
            'entity_type_id' => $entityTypeId,
            'sort_order' => 200,

        $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);   

            $attributeSet = $attributeSetId , 

            \Magento\Catalog\Model\Product::ENTITY,  'medicamento_expira_curta2',   /* Custom Attribute Code */
                'group' => 'medicamento_expira_curta_group2',/* Group name in which you want 
                                              to display your custom attribute */
                'type' => 'int',/* Data type in which formate your value save in database*/
                'backend' => '',
                'frontend' => '',
                'label' => 'DATATESTESCOPED2', /* lablel of your attribute*/
                'input' => 'date',
                'class' => '',
                // 'source' => 'ModuleNameSpace\YourModuleName\Model\Config\Source\Options',
                                /* Source of your select type custom attribute options*/
                'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
                                    /*Scope of your attribute */
                'visible' => true,
                'required' => true,
                'user_defined' => true,
                'default' => '',
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => true,
                'unique' => false,
                'attribute_set_id' => 'medicamento_expira_curta2'

The attribute is allowed to the correct attribute set, but the group, is persisted in all attributesets, i miss any configuration ?


Please check the following:

  • All the attribute sets you have created are dependent on the Default attribute sets.
  • You are adding the new attribute group to the Default attribute set.

If yes, all the attribute sets will have the new attribute group as part.

If you want to assign the attribute group to a particular attribute set only, then either assign the attribute group to a non-default attribute set.

Or, create the custom attribute sets as non-dependent on the default attribute set.

  • You can show me an example for adding the attribute group not assing to the default ? – FlávioD Jan 17 '19 at 13:02
  • Sorry, I have updated my answer. There is no way from the admin panel to do so. – Mohit Kumar Arora Jan 17 '19 at 13:30
  • programatically ? – FlávioD Jan 17 '19 at 13:48
  • I just checked whether a new attribute set can be independent or not. I found that apart from the default attribute set, all other attribute sets must have a value for Based On. So, I think there is no way to create an attribute set which is independent of the default attribute set. – Mohit Kumar Arora Jan 17 '19 at 14:03

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.