Skip to main content
Attributes are crucial for creating variable products. Attributes can also be used to enhance the product filtering and selection process, allowing customers to find and select products that meet their specific preferences or needs. An Attribute is a specification or characteristic of a product, for example, Color, Size, and Pattern are attributes of a T-Shirt. You can also create many attributes for a single product. In Shopper, attributes go beyond basic product descriptions—they highlight the unique value and features of each item, helping customers understand what makes a product special. By leveraging attributes, you can create variable products, enhance search and filtering options, and provide a more personalized shopping experience.
Attributes

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

NameTypeRequiredNotes
idautoincauto
namestringyes
slugstringnoUnique, default value is generated using attribute name
iconstringno
descriptionstringno
typestringyes[FieldType](#attribute-types)
is_enabledboolnoDefault false
is_searchableboolnoDefault false
is_filterableboolnoDefault false

AttributeValue

NameTypeRequiredNotes
idautoincauto
valuestringyes
keystringyesUnique
positionintnoDefault 1
attribute_idintyesint (Attribute object via the attribute relation)

AttributeProduct

NameTypeRequiredNotes
idautoincauto
attribute_idintyesint (Attribute object via the attribute relation)
product_idintyesint (Product object via the product relation)
attribute_value_idintnoint (AttributeValue object via the value relation)
attribute_custome_valuestringnoCustom 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 the Shopper\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

Create Attribute

Fill in your information and save the form to return to the list of attributes. Required fields are marked with an asterisk (*). If you use another interface (e.g. API) to save your Attribute, you can save directly using the Attribute Model
use Shopper\Core\Models\Attribute;
use Shopper\Core\Enum\FieldType;

$attribute = Attribute::create([
    'name' => 'Color',
    'slug' => 'color',
    'type' => FieldType::Checkbox(),
    'is_enabled'=> true,
]);