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',
];

Revisions

Recently Edited Articles
This website uses no cookies and no third party tracking technology. We think we can do better than others and really think about your privacy.