Skip to main content
Tags are simple labels you attach to products for cross-cutting organization. Unlike categories (hierarchical) or collections (rule-based), tags are flat and flexible, ideal for seasonal labels (“Summer 2026”), marketing campaigns (“Flash Sale”), or storefront filtering (“New Arrival”, “Best Seller”).

Model

The model used is Shopper\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

Pivot Table

Tags use the shared polymorphic product_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.

Slug Generation

The HasSlug 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.
The trait also provides a 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 a morphToMany / morphedByMany polymorphic relationship via the product_has_relations table. From the tag side:
From the product side:

Creating Tags

To create a tag, provide a name and a slug. The HasSlug trait ensures slug uniqueness automatically:
Tags can also be created inline from the product edit form in the admin panel. The tag selection field includes a “Create” option that opens a modal form, so administrators can add new tags without leaving the product page.

Retrieving Tags

To get all tags ordered by name with their product count:
To find a tag by slug with its products:
To get all tags for a specific product:

Configuration

Disabling Tags

If you don’t need tags in your store, disable the feature in config/shopper/features.php:
When disabled, the tag menu item is hidden from the sidebar, tag-related routes are not registered, and the tag selection field is removed from product forms.

Permissions

The admin panel generates four permissions for tag management:

Components

Tags are managed under the product components configuration. To customize the admin UI:
The tag page is registered in config/shopper/components/product.php:

Storefront Example

This example shows a tag listing page and a tag detail page that displays all published products for a given tag.

Filtering Products by Tags

To get products that have a specific tag:
To get products that have any of the given tags: