Models
Shopper uses three models to manage attributes:
The Attribute model implements
Shopper\Core\Models\Contracts\Attribute and uses the HasSlug trait for automatic slug generation. Unlike products or brands, the Attribute model is not configurable via config/shopper/models.php and has no admin model wrapper.
Database Schema
Attribute Table
AttributeValue Table
AttributeProduct Table (Pivot)
Field Types
Attributes use theFieldType enum to determine input behavior:
Type Checking Methods
Each attribute type has helper methods to determine its behavior:hasMultipleValues() returns true for Checkbox and ColorPicker. hasSingleValue() returns true for Select. hasTextValue() returns true for Text, Number, RichText, and DatePicker. fieldsWithValues() returns the types that require predefined values.
Relationships
Values
Products
Variants (AttributeValue)
AttributeValue can be linked to product variants:Slug & Lookup
TheHasSlug trait generates unique slugs automatically and provides a findBySlug() static method:
Query Scopes
Filter attributes by their visibility and behavior flags:Status Management
Display Helpers
type_formatted returns a translated label like “Checkbox”. typesFields() returns all available types with their labels.
Working with AttributeProduct
TheAttributeProduct model provides a computed real_value accessor:
Creating Attributes
Attribute with Predefined Values
Attribute with Free Text
Assigning Attributes to Products
Retrieving Attributes
Observer Behavior
TheAttributeObserver handles cleanup when deleting:
Disabling Attribute Feature
Permissions
The admin panel generates five permissions for attribute management:Components
Attribute components are part of the product configuration. To customize them:config/shopper/components/product.php: