Overview
Shopper gives you a possibility to categorize your products in a very flexible way, which is one of the most vital functionalities of the modern e-commerce systems. The categories system in Shopper use the Laravel Adjacency List package to create categories trees like this
Categories
Fields
The model used isShopper\Framework\Models\Shop\Product\Category.
Let’s keep in mind the modification that was made in the previous section regarding Brands.
-
Create your own model that you have to use
Once the
app/Models/Category.phpmodel is created in our app folder, we will make it extend from theShopper\Framework\Models\Shop\Product\Categorymodel available in Shopper. -
Extend our Category model from the Category Shopper Model
-
Update
categorykey for the model on thesystem.phpconfig file to use our new model
Components
Livewire components for managing categories are available in the component configuration fileconfig/shopper/components.php.
Manage Categories
Categories are determinant of how people will navigate on your site and search for your products. You should focus on your category tree and how categories are organized even before you start creating product sheets. The categories are accessible via the Categories Menu on the left sidebar. The display page is rendered by the Livewire componentShopper\Framework\Http\Livewire\Categories\Browse and for the display of the categories table is the component Shopper\Framework\Http\Livewire\Tables\CategoriesTable.
You can modify them in the component configuration file to use your own.
Create category
Click on the “Create” button on the categories page, and a creation form appears.
Create category

Seo form preview
Create Category with parent

Category parent
Update category
The “Modify” button allows you to modify the category.It is important to know that if you update the category name, the slug will automatically be updated as well.

Update Category
Retrieve Data
With Shopper Framework you are the master of your front-end. After extending the model you can make all the necessary queries to retrieve your data. We just recommend that you always use theenabled scope to ensure that only active categories are visible
ancestors(): The model’s recursive parents.ancestorsAndSelf(): The model’s recursive parents and itself.bloodline(): The model’s ancestors, descendants and itself.children(): The model’s direct children.childrenAndSelf(): The model’s direct children and itself.descendants(): The model’s recursive children.descendantsAndSelf(): The model’s recursive children and itself.parent(): The model’s direct parent.parentAndSelf(): The model’s direct parent and itself.rootAncestor(): The model’s topmost parent.siblings(): The parent’s other children.siblingsAndSelf(): All the parent’s children.