Model
The model used isShopper\Core\Models\ProductTag. Unlike products, categories, or brands, the tag model has no admin wrapper and is not configurable via config/shopper/models.php. It uses the HasSlug trait, which generates unique, URL-friendly slugs with collision handling.
Database Schema
Tags Table
| Column | Type | Nullable | Default | Description |
|---|---|---|---|---|
id | bigint | no | auto | Primary key |
name | string | no | - | Tag name |
slug | string | yes | auto | URL-friendly identifier (unique) |
created_at | timestamp | yes | null | Creation timestamp |
updated_at | timestamp | yes | null | Last update timestamp |
Pivot Table
Tags use the shared polymorphicproduct_has_relations pivot table. This is the same table used by categories, collections, channels, and related products. The polymorphic pattern lets all these models share a single pivot table instead of requiring a dedicated join table for each relationship type.
| Column | Type | Nullable | Description |
|---|---|---|---|
product_id | bigint | no | Foreign key to product |
productable_type | string | no | Morph type (e.g. product_tag) |
productable_id | bigint | no | Foreign key to the related model |
Slug Generation
TheHasSlug trait provides automatic slug generation with collision handling. When you set the slug attribute, the trait runs the value through Str::slug() and checks for uniqueness. If a slug already exists, it appends an incrementing suffix (-1, -2, etc.) until it finds a unique one.
findBySlug() static method that looks up a tag by its slug and throws a ModelNotFoundException if not found:
Relationships
Products
Tags connect to products through amorphToMany / morphedByMany polymorphic relationship via the product_has_relations table.
From the tag side:
Creating Tags
To create a tag, provide a name and a slug. TheHasSlug trait ensures slug uniqueness automatically:
Retrieving Tags
To get all tags ordered by name with their product count:Configuration
Disabling Tags
If you don’t need tags in your store, disable the feature inconfig/shopper/features.php:
Permissions
The admin panel generates four permissions for tag management:| Permission | Description |
|---|---|
browse_tags | View the tags list |
read_tags | View a single tag |
add_tags | Create new tags |
edit_tags | Edit existing tags |
delete_tags | Delete tags |
Components
Tags are managed under the product components configuration. To customize the admin UI:config/shopper/components/product.php: