Attributes
Attributes are groups of properties that can be assigned to products. They can also be used as category filters showing a filtered list of products containing specific attributes.
Entity Object
To create a new attribute group with 3 values:
$attribute_group = new ent_attribute_group();
$attribute_group->data['name']['en'] = 'Color';
$attribute_group->data['values'][] = ['name' => ['en' => 'Red']];
$attribute_group->data['values'][] = ['name' => ['en' => 'Green']];
$attribute_group->data['values'][] = ['name' => ['en' => 'Blue']];
$attribute_group->save();
Reference Model
Attributes doesn't have a reference object. Instead, values from the entity will be returned.
echo reference::attribute_group($group_id)->name[$language_code];
Adding Attributes to a Product
$product = new ent_product(1122);
$product->data['attributes'][] = [
'group_id' => 11,
'value_id' => 22,
'custom_value' => null,
];
$product->data['attributes'][] = [
'group_id' => 11,
'value_id' => 0,
'custom_value' => 'Lorem ipsum',
];