Subject. Which classes I need to use to deal with it?
It seems that I don't understand much about how attributes work.
For example I use this code to add attribute to one attribute set and to one attribute group:
/** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
$attribute->setAttributeSetId($attributeSetId);
$attribute->setAttributeGroupId($groupId);
Thanks.
UPD:
My problem not in 'how to get attribute set ids', I already have a few. I'm more interesting in the part of code where // add your code here
.
I think if we set the value by method $attribute->setAttributeSetId()
, it override previous attribute set link in the attribute. I'm trying to find some solution like $attribute->addAttributeSetId()
or $attribute->setAttributeSetIds()
, but there are none
UPD2:
Found the way: Using \Magento\Eav\Api\AttributeManagementInterface->assign()
. Full code in answer below.