Context
For example if you have a store that sells various electronic products, you will probably have categories like “Phones”, “Computers”, “Cameras” etc. Each of these categories may have several products that can be listed. And to try to group the products in an even more detailed way you can create for example a collection called “Gaming Collection” and specify in this collection that any product with certain conditions can be included. And that Gaming Collection can have products that even come from various categories in your site (desktop, laptop, monitor, and many others of the same type) or that don’t even have categories (very rare case in e-commerce sites). Let’s use Netflix as an example. Categories are essentially genres: adventure, action, horror, romance, etc., while collections are similar to a TV series or movie sequels that are ultimately meant to be viewed together.Collections vs Categories
The question is essential, it is difficult to find this type of configuration on e-commerce tools because most of the time categories, collections or taxonomies are used to perform the same action group products. The advantage of having collections in addition to categories in Shopper is to differentiate or optimize the search for products by customers in your store.Depth
A collection can’t have a child or a parent like a category. So all the collections are at the same hierachical level.Condition
Where products can be added to any category, collections cannot. Depending on the type of collection you want to create (Manual or Automatic) you will find yourself creating conditions or rules for the products that should be in that collection.Overview
As mentioned above, the collections in Shopper are inspired by Shopify collections. So there are also 2 types of collections: “Manual” and “Automatic” and the configuration for each is different.
Collections
Fields
As the collections can be automatic, they are managed by 2 Models, the Collection model and the model for rules associated with automatic collections. Manual collections do not need to have rules.- Collection model is
Shopper\Framework\Models\Shop\Product\Collection. - Rule model is
Shopper\Framework\Models\Shop\Product\CollectionRule
CollectionRule Model
Let’s keep in mind the modification that was made in the previous section regarding Categories.
-
Create your own model that you have to use
Once the
app/Models/Collection.phpmodel is created in our app folder, we will make it extend from theShopper\Framework\Models\Shop\Product\Collectionmodel available in Shopper. -
Extend our Collection model from the Collection Shopper Model
-
Update
Collectionkey for the model on thesystem.phpconfig file to use our new model
Components
Livewire components for managing collections are available in the component configuration fileconfig/shopper/components.php.
Manage Collections
Form your Shopper admin on the sidebar go to Collections. The display page is rendered by the Livewire componentShopper\Framework\Http\Livewire\Collections\Browse and for the display of the collections table is the component Shopper\Framework\Http\Livewire\Tables\CollectionsTable.
By default you will see this page without data which is rendered by a blade component of Shopper called empty state.

Collections empty data
Create collection
Click on the “Create” button on the collections page, and a creation form appears.
Create collection

Automatic collection rules
Shopper\Framework\Http\Livewire\Collections\Create. Here is the function to save a collection
Retrieve Data
After extending the Shopper Collection model you can use your own model to retrieve data from the database. Here an example code.
Example display for collections