
Attributes
Models
- Attribute(
Shopper\Core\Models\Attribute) represents characteristics of a product, such as Size, Color, Material, or any other feature that helps differentiate products - AttributeValue(
Shopper\Core\Models\AttributeValue) Model stores the specific values associated with an attribute. For example, if the attribute is “Color,” the values might include “Red,” “Blue,” and “Green.” - AttributeProduct(
Shopper\Core\Models\AttributeProduct) Model acts as a pivot table that connects attributes and their values to specific products. This model is essential for creating variable products and managing product variations.
Attribute
| Name | Type | Required | Notes |
|---|---|---|---|
id | autoinc | auto | |
name | string | yes | |
slug | string | no | Unique, default value is generated using attribute name |
icon | string | no | |
description | string | no | |
type | string | yes | [FieldType](#attribute-types) |
is_enabled | bool | no | Default false |
is_searchable | bool | no | Default false |
is_filterable | bool | no | Default false |
AttributeValue
| Name | Type | Required | Notes |
|---|---|---|---|
id | autoinc | auto | |
value | string | yes | |
key | string | yes | Unique |
position | int | no | Default 1 |
attribute_id | int | yes | int (Attribute object via the attribute relation) |
AttributeProduct
| Name | Type | Required | Notes |
|---|---|---|---|
id | autoinc | auto | |
attribute_id | int | yes | int (Attribute object via the attribute relation) |
product_id | int | yes | int (Product object via the product relation) |
attribute_value_id | int | no | int (AttributeValue object via the value relation) |
attribute_custome_value | string | no | Custom value for attribute with no value id |
Attribute Types
Attributes can be of several types. And this allows you to define how they will be displayed when assigned to a product. The types are available via theShopper\Core\Enum\FieldType Enum className and the available values are:
FieldType::Checkbox()It represents multiple values that can be assigned to a product.FieldType::ColorPicker()Multiple values as checkbox but for the color.FieldType::DatePicker()Displays a date value in the preferred format.FieldType::RichText()Rich Text Editor.FieldType::Select()Displays an option to select a value.FieldType::Text()A single-line input field for text.FieldType::Number()Integer or Decimal value.
Create Attribute
On the sidebar, navigate to Products > Attributes and Click on the “Create” button on the attributes page to display the form.
Create Attribute