-
Notifications
You must be signed in to change notification settings - Fork 2
Product Attributes
Code Slicer edited this page May 18, 2023
·
13 revisions
Allows managing the eav attributes related to products. Import it as follows:
private Migration\Facade\ProductAttribute $productAttribute;
public function __construct(
Migration\Context $context,
Migration\Facade\ProductAttribute $productAttribute
) {
parent::__construct($context);
$this->productAttribute = $productAttribute;
}
💡 Tip: all eav attribute capabilities are available for this entity:
https://github.com/discorgento/module-migrations/wiki/Eav-Attributes
Create a new dropdown attribute. Eg.:
$this->productAttribute->createDropdown('sizes', "Clothes Size", ['P', 'M', 'G']);
Simulates the process of navigating to "Stores->Attribute Set" and assigning an attribute there. Eg.:
// Assign to "Marketplace" attribute set, into the "Shipping Quote" group, after the "fragile" attribute
$this->productAttribute->assignToAttributeSet(
'size', // attribute code to assign
'Clothes', // (optional) attribute set, fallback to "Default"
'Tech Specs', // (optional) group name, fallback to the default one, usually "General"
'gender' // (optional) put your attribute after this one
);
Pretty much what the name implies.
// Assign to "Marketplace" attribute set, into the "Shipping Quote" group, after the "fragile" attribute
$this->productAttribute->unassignFromAttributeSet(
'size', // attribute code to assign
'Clothes', // (optional) attribute set, fallback to "Default"
);
We want YOU for our community 🫵