Interface
Implementation: \Magento\Eav\Model\AttributeSetManagement
072a1ae/app/code/Magento/Eav/Model/AttributeSetManagement.php#L39-L65
/**
* {@inheritdoc}
*/
public function create($entityTypeCode, AttributeSetInterface $attributeSet, $skeletonId)
{
/** @var \Magento\Eav\Model\Entity\Attribute\Set $attributeSet */
if ($attributeSet->getId() !== null) {
throw InputException::invalidFieldValue('id', $attributeSet->getId());
}
if ($skeletonId == 0) {
throw InputException::invalidFieldValue('skeletonId', $skeletonId);
}
// Make sure that skeleton attribute set is valid (try to load it)
$this->repository->get($skeletonId);
try {
$attributeSet->setEntityTypeId($this->eavConfig->getEntityType($entityTypeCode)->getId());
$attributeSet->validate();
} catch (\Exception $exception) {
throw new InputException(__($exception->getMessage()));
}
$this->repository->save($attributeSet);
$attributeSet->initFromSkeleton($skeletonId);
return $this->repository->save($attributeSet);
}
Usage
It is intended to be used from the /V1/eav/attribute-sets
Web API:
Details: How to create an attribute set programmatically with the /V1/eav/attribute-sets
Web API?