Skip to main content
deleted 2 characters in body
Source Link
bh-
  • 41
  • 2

Here is how you would add it to the default attributset, with a group name you can define (or you use an existing group name, like Product DetailsProduct Details):

$attributeGroup = 'My Group Name'; // the group doesn't need to exist

$attributeCode = 'customer_product_points'; // or whatever attribute you want to add

$entityTypeId = $eavSetup->getEntityTypeId(
    \Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE
);

$attributeSetId = $eavSetup->getDefaultAttributeSetId($entityTypeId);

$eavSetup->addAttributeToSet($entityTypeId, $attributeSetId, $attributeGroup, $attributeCode);

Another option would be to add 'groups' => 'my group name' to your attribute array, it would then automatically be added to all attributsets.

Here is how you would add it to the default attributset, with a group name you can define (or you use an existing group name, like Product Details):

$attributeGroup = 'My Group Name'; // the group doesn't need to exist

$attributeCode = 'customer_product_points'; // or whatever attribute you want to add

$entityTypeId = $eavSetup->getEntityTypeId(
    \Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE
);

$attributeSetId = $eavSetup->getDefaultAttributeSetId($entityTypeId);

$eavSetup->addAttributeToSet($entityTypeId, $attributeSetId, $attributeGroup, $attributeCode);

Another option would be to add 'groups' => 'my group name' to your attribute array, it would then automatically be added to all attributsets.

Here is how you would add it to the default attributset, with a group name you can define (or you use an existing group name, like Product Details):

$attributeGroup = 'My Group Name'; // the group doesn't need to exist

$attributeCode = 'customer_product_points'; // or whatever attribute you want to add

$entityTypeId = $eavSetup->getEntityTypeId(
    \Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE
);

$attributeSetId = $eavSetup->getDefaultAttributeSetId($entityTypeId);

$eavSetup->addAttributeToSet($entityTypeId, $attributeSetId, $attributeGroup, $attributeCode);

Another option would be to add 'groups' => 'my group name' to your attribute array, it would then automatically be added to all attributsets.

Source Link
bh-
  • 41
  • 2

Here is how you would add it to the default attributset, with a group name you can define (or you use an existing group name, like Product Details):

$attributeGroup = 'My Group Name'; // the group doesn't need to exist

$attributeCode = 'customer_product_points'; // or whatever attribute you want to add

$entityTypeId = $eavSetup->getEntityTypeId(
    \Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE
);

$attributeSetId = $eavSetup->getDefaultAttributeSetId($entityTypeId);

$eavSetup->addAttributeToSet($entityTypeId, $attributeSetId, $attributeGroup, $attributeCode);

Another option would be to add 'groups' => 'my group name' to your attribute array, it would then automatically be added to all attributsets.