How to fix it
The failure’s author should learn:
/** @var int $defaultProductsAttributeSetId */
$defaultProductsAttributeSetId =
$categorySetup->getDefaultAttributeSetId(ProductAttributeInterface::ENTITY_TYPE_CODE)
;
Then you should replace the 'Default'
string with the actual default attribute set id:
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
$defaultProductsAttributeSetId,
'Product Details',
'visibility',
80
);
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
$defaultProductsAttributeSetId,
'Product Details',
'news_from_date',
90
);
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
$defaultProductsAttributeSetId,
'Product Details',
'news_to_date',
100
);
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
$defaultProductsAttributeSetId,
'Product Details',
'country_of_manufacture',
110
);
//Content tab
$categorySetup->addAttributeGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
$defaultProductsAttributeSetId,
'Content',
15
);
$categorySetup->updateAttributeGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
$defaultProductsAttributeSetId,
'Content',
'tab_group_code',
'basic'
);
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
$defaultProductsAttributeSetId,
'Content',
'description'
);
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
$defaultProductsAttributeSetId,
'Content',
'short_description',
100
);
//Images tab
$groupId = (int)$categorySetup->getAttributeGroupByCode(
ProductAttributeInterface::ENTITY_TYPE_CODE,
$defaultProductsAttributeSetId,
'image-management',
'attribute_group_id'
);
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
$defaultProductsAttributeSetId,
$groupId,
'image',
1
);
$categorySetup->updateAttributeGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
$defaultProductsAttributeSetId,
$groupId,
'attribute_group_name',
'Images'
);
//Schedule Design Update tab
$categorySetup->addAttributeGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
$defaultProductsAttributeSetId,
'Schedule Design Update',
55
);
$categorySetup->updateAttributeGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
$defaultProductsAttributeSetId,
'Schedule Design Update',
'tab_group_code',
'advanced'
);
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
$defaultProductsAttributeSetId,
'Schedule Design Update',
'custom_design_from',
20
);
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
$defaultProductsAttributeSetId,
'Schedule Design Update',
'custom_design_to',
30
);
$categorySetup->updateAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
'custom_design',
'frontend_label',
'New Theme',
40
);
$categorySetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
$defaultProductsAttributeSetId,
'Schedule Design Update',
'custom_design'
);
if (!$categorySetup->getAttributeGroup(Product::ENTITY, 'Default', $groupName)) {
$categorySetup->addAttributeGroup(Product::ENTITY, 'Default', $groupName, 60);
}
$entityTypeId = $categorySetup->getEntityTypeId(Product::ENTITY);
$attributeSetId = $categorySetup->getAttributeSetId($entityTypeId, 'Default');
Replace it to:
/** @var int $defaultProductsAttributeSetId */
$defaultProductsAttributeSetId = $categorySetup->getDefaultAttributeSetId(Product::ENTITY);
if (!$categorySetup->getAttributeGroup(Product::ENTITY, $defaultProductsAttributeSetId, $groupName)) {
$categorySetup->addAttributeGroup(Product::ENTITY, $defaultProductsAttributeSetId, $groupName, 60);
}
$entityTypeId = $categorySetup->getEntityTypeId(Product::ENTITY);
$attributeSetId = $categorySetup->getAttributeSetId($entityTypeId, $defaultProductsAttributeSetId);
$groupId = (int)$eavSetup->getAttributeGroupByCode(
Product::ENTITY,
'Default',
'image-management',
'attribute_group_id'
);
$eavSetup->addAttributeToGroup(Product::ENTITY, 'Default', $groupId, 'swatch_image');
Replace it to:
/** @var int $defaultProductsAttributeSetId */
$defaultProductsAttributeSetId = $eavSetup->getDefaultAttributeSetId(Product::ENTITY);
$groupId = (int)$eavSetup->getAttributeGroupByCode(
Product::ENTITY,
$defaultProductsAttributeSetId,
'image-management',
'attribute_group_id'
);
$eavSetup->addAttributeToGroup(Product::ENTITY, $defaultProductsAttributeSetId, $groupId, 'swatch_image');