Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/category test #289

Merged
merged 3 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions packages/admin/docs/content/brands.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Unless you make your own products, you'll be registering your product's brands i
If you sell your own products, you must at least create your company as a brand: this helps your customer find what they are looking for, and this can bring some valuable search engine points.

## Overview

The management of brands is exactly the same as the one done in most of the e-commerce website creation tools: only the name can change.
It is mainly used to facilitate the navigation of customers in your catalog, as it is increasingly common to search for a specific brand.

Expand All @@ -17,7 +18,8 @@ It is mainly used to facilitate the navigation of customers in your catalog, as
New brands are automatically activated and available for your online store, even if they do not contain any products yet. You must deactivate them so that they do not appear online.

### Fields
The model used is `Shopper\Framework\Models\Shop\Product\Brand`.

The model used is `Shopper\Models\Brand`.

| Name | Type | Required | Notes |
|-------------------|----------|----------|----------------------------------------------------------|
Expand Down Expand Up @@ -93,6 +95,7 @@ return [
```

## Manage Brands

The brands are accessible via the Brands Menu on the left sidebar.
You can update the livewire page component in the configuration file to use your own.

Expand All @@ -105,16 +108,18 @@ php artisan make:shopper-page Brand
This page will extend shopper's default layout, and you can render the view you want.

### Create brand
Click on the "Create" button on the brands page, which will display and slideover.

Click on the "Create" button on the brands page, which will display the form.

<div class="screenshot">
<img src="/img/screenshots/{{version}}/brand-form.png" alt="Create brand">
<img src="/img/screenshots/{{version}}/create-brand.png" alt="Create brand">
<div class="caption">Create brand</div>
</div>

Save your changes in order to be taken back to the brand's list. Required fields are marked with an **asterisk (*)**

## Retrieve Data

Once you have your brands you want to display them in your store, you can retrieve them this way in your controller

```php
Expand Down Expand Up @@ -191,7 +196,7 @@ class AppServiceProvider extends ServiceProvider
And in your front-end you can browse your brands to have a display like this

<div class="screenshot">
<img src="/img/screenshots/{{version}}/brand-lists.png" alt="Brands preview list">
<img src="/img/screenshots/{{version}}/brand-lists.png" alt="Brands list">
<div class="caption">Brands example list</div>
</div>

Expand All @@ -200,7 +205,7 @@ And in your front-end you can browse your brands to have a display like this
Sometimes in your store, you won't have a brand name for your products (it's rare but possible), especially if you make them yourself.
In this case, you can hide brands on the sidebar and disabled all brand-related functionalities in your store.

To disable brand-related functionalities, open the `features.php` configuration file in the `config/shopper` folder and set the brand key to disable.
To disable brands-related functionalities, open the `features.php` configuration file in the `config/shopper` folder and set the brand key to disable.

```php
use Shopper\Enum\FeatureState;
Expand Down
95 changes: 42 additions & 53 deletions packages/admin/docs/content/categories.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Categories

Categories are the primary way to group products with similar features. You can also add subcategories if desired.

For example, if you sell clothing, you might have “t-shirts”, “hoodies” and “pants” as categories.

## 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](https://github.com/staudenmeir/laravel-adjacency-list) package to create categories trees like this

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](https://github.com/staudenmeir/laravel-adjacency-list) package to create categories trees like this

```plain theme:github-light
Category
Expand Down Expand Up @@ -32,19 +35,20 @@ Category
</div>

### Fields

The model used is `Shopper\Core\Models\Category`.

| Name | Type | Required | Notes |
|-------------|-----------|------------|------------|
| `id` | autoinc | | auto |
| `name` | string | yes | |
| `slug` | string | yes | Unique, default value is generated using category name |
| `description` | longText | no | Nullable |
| `position` | string | no | Default `0` |
| `is_enabled` | boolean | no | Default `false` |
| `seo_title` | string | no | Nullable, for seo title max length is 60 |
| `seo_description` | string | no | Nullable, for seo description max length is 160 |
| `parent_id` | bigint | no | |
| Name | Type | Required | Notes |
|-------------------|----------|----------|--------------------------------------------------------|
| `id` | autoinc | | auto |
| `name` | string | yes | |
| `slug` | string | yes | Unique, default value is generated using category name |
| `description` | longText | no | Nullable |
| `position` | string | no | Default `0` |
| `is_enabled` | boolean | no | Default `false` |
| `seo_title` | string | no | Nullable, for seo title max length is 60 |
| `seo_description` | string | no | Nullable, for seo description max length is 160 |
| `parent_id` | bigint | no | |

:::tip
Models are customizable, and we recommend changing the **Category** model when you configure your store.
Expand Down Expand Up @@ -84,60 +88,53 @@ return [

3. Update `category` key for the model on the `shopper/models.php` config file to use our new model
```php
return [
'models' => [
// ...
'brand' => \App\Models\Brand::class,

// ...
'category' => \App\Models\Category::class, // [tl! focus]
]
];
'category' => Models\Category::class, // [tl! --]
'category' => \App\Models\Category::class, // [tl! ++]
```

### Components
Livewire components for managing categories are available in the component configuration file `config/shopper/components.php`.

```php
use Shopper\Http\Livewire;
By default, categories Livewire components are not published. To customize components, you must publish them.

return [
'livewire' => [
```bash
php artisan shopper:component:publish category
```

'categories.browse' => Livewire\Categories\Browse::class,
'categories.create' => Livewire\Categories\Create::class,
'categories.edit' => Livewire\Categories\Edit::class,
```php
use Shopper\Livewire;

'tables.categories-table' => Livewire\Tables\CategoriesTable::class,
return [

];
'pages' => [
'category-index' => Livewire\Pages\Category\Index::class,
];

'components' => [
'slide-overs.category-form' => Livewire\SlideOvers\CategoryForm::class,
'slide-overs.re-order-categories' => Livewire\SlideOvers\ReOrderCategories::class,
],
];
```

## 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 component `Shopper\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.

<div class="screenshot">
<img src="/img/screenshots/{{version}}/create-category.png" alt="Create category form">
<img src="/img/screenshots/{{version}}/category-create.png" alt="Create category form">
<div class="caption">Create category</div>
</div>

Save your changes in order to be taken back to the categories list. Required fields are marked with an **asterisk (*)**

The SEO section allows you to define how your category information should be displayed in search engines. To modify the content you click on the button "Edit SEO preview". It uses the same blade component as the brands.

<div class="screenshot">
<img src="/img/screenshots/{{version}}/seo-preview.gif" alt="Seo form">
<div class="caption">Seo form preview</div>
</div>

The SEO section allows you to define how your category information should be displayed in search engines.
Once you have finished configuring your category, save it, and you are ready to fill it with products.

If you use another interface (e.g. API) to save your categories, you can save directly using your Model
Expand All @@ -153,7 +150,6 @@ $category = Category::create([
```

The slug cannot be null, you have to fill in the value of the category name and according to that the slug will be generated.

In case a slug already exists, the slug will be automatically extended to prevent duplicates:

```php
Expand All @@ -170,16 +166,15 @@ echo $category2->slug;
```

And if the category has a parent, the child's slug will be generated with the parent's directly

This generation is done when adding a category in Shopper. But you can change this behavior by extending the category create [Shopper\Framework\Http\Livewire\Categories\Create](https://github.com/shopperlabs/framework/blob/main/src/Http/Livewire/Categories/Create.php) Livewire component or by creating a new one.

```php
use App\Models\Category;

$category = Category::create(['name' => 'Photo', 'slug' => 'photo']);
$categoryChild = Category::create([
'name' => 'Camera',
'slug' => $this->parent ? $this->parent->slug . '-' . 'Camera' : 'Camera',
'name' => $name = 'Camera',
'slug' => $this->parent ? $this->parent->slug . '-' . $name : $name,
'parent_id' => $caregory->id
]);

Expand Down Expand Up @@ -209,22 +204,16 @@ $child = Category::create([
]);
```

On Shopper, to specify the parent category you just have to choose via the select field

<div class="screenshot">
<img src="/img/screenshots/{{version}}/category-parent.png" alt="category parent">
<div class="caption">Category parent</div>
</div>

### Update category
The "Modify" button allows you to modify the category.

The "Update" button allows you to modify the category.

:::info
It is important to know that if you update the category name, the slug will automatically be updated as well.
:::

<div class="screenshot">
<img src="/img/screenshots/{{version}}/update-category.png" alt="update category">
<img src="/img/screenshots/{{version}}/category-update.png" alt="update category">
<div class="caption">Update Category</div>
</div>

Expand Down
45 changes: 35 additions & 10 deletions packages/admin/docs/content/collections.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Collections

Collections, although not strictly the same, are akin to Categories. They serve to allow you to add products, either explicitly or via certain criteria, for use on your store.

In most e-commerce tools, collections are considered as categories. And especially on Shopify, collections are a great feature for grouping products.

And for the constitution of the collections we got closer to what Shopify offers in terms of configuration, and the management of collections in Shopper is inspired from Shopify.

## 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.
Expand All @@ -15,17 +17,21 @@ And that Gaming Collection can have products that even come from various categor
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](https://help.shopify.com/en/manual/products/collections). So there are also 2 types of collections: "Manual" and "Automatic" and the configuration for each is different.

<div class="screenshot">
Expand All @@ -34,6 +40,7 @@ As mentioned above, the collections in Shopper are inspired by [Shopify collecti
</div>

### 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.
Expand Down Expand Up @@ -66,7 +73,7 @@ Manual collections do not need to have rules.

:::tip
Models are customizable, and we recommend changing the **Collection** model when you configure your store.
To change the model you need to look at the configuration file `config/shopper/shopper.php`.
To change the model you need to look at the configuration file `config/shopper/models.php`.
:::

Let's keep in mind the modification that was made in the previous section regarding [Categories](/categories).
Expand Down Expand Up @@ -98,14 +105,15 @@ return [
}
```

3. Update `Collection` key for the model on the `models.php` config file to use our new model
3. Update `collection` key for the model on the `models.php` config file to use our new model
```php
'collection' => Models\Collection::class, // [tl! --]
'collection' => \App\Models\Collection::class, // [tl! ++]
```

### Components
By default, collection Livewire components are not published. To customize components, you must publish them.

By default, collections Livewire components are not published. To customize components, you must publish them.

```bash
php artisan shopper:component:publish collection
Expand Down Expand Up @@ -137,6 +145,7 @@ return [
```

## Manage Collections

Form your Shopper admin on the sidebar go to **Collections**. The display page is rendered by the Livewire component `Shopper\Livewire\Pages\Collection\Index::class`.

<div class="screenshot">
Expand All @@ -145,17 +154,11 @@ Form your Shopper admin on the sidebar go to **Collections**. The display page i
</div>

### Create collection
Click on the "Create" button on the collections page, which will display and slideover.

<div class="screenshot">
<img src="/img/screenshots/{{version}}/collection-create.png" alt="Create collection form">
<div class="caption">Create collection</div>
</div>

Click on the "Create" button on the collections page, which will display and slideover.
Save your changes in order to be taken back to the collection edit page. Required fields are marked with an **asterisk (*)**.

You can create two types of collections as we said: `Automatic` and `Manual` collection.

Only automatic collections have rules for automating them. When you choose to create an automatic collection the rules section will be available in the edit form.

<div class="screenshot">
Expand All @@ -166,6 +169,7 @@ Only automatic collections have rules for automating them. When you choose to cr
After you create a collection, you can't change its type.

## Retrieve Data

After extending (or not) the Shopper Collection Model you can use your own Model to retrieve data from the database. Here a code example.

```php
Expand All @@ -183,3 +187,24 @@ To view the image of a collection you can consult the [Media documentation](/med
<img src="/img/screenshots/{{version}}/collection-preview.png" alt="collections data">
<div class="caption">Example of collections</div>
</div>

## Disabled Collection

Sometimes in your store, you won't have a brand name for your products (it's rare but possible), especially if you make them yourself.
In this case, you can hide brands on the sidebar and disabled all brand-related functionalities in your store.

To disable collections-related functionalities, open the `features.php` configuration file in the `config/shopper` folder and set the brand key to disable.

```php
use Shopper\Enum\FeatureState;

return [
'attribute' => FeatureState::Enabled,
'brand' => FeatureState::Enabled,
'category' => FeatureState::Enabled,
'collection' => FeatureState::Enabled, // [tl! --]
'collection' => FeatureState::Disabled, // [tl! ++]
'discount' => FeatureState::Enabled,
'review' => FeatureState::Enabled,
];
```
2 changes: 1 addition & 1 deletion packages/core/database/factories/CategoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function definition(): array
'name' => $name = $this->faker->unique()->words(3, true),
'slug' => Str::slug($name),
'description' => $this->faker->realText(),
'is_visible' => $this->faker->boolean(),
'is_enabled' => $this->faker->boolean(),
'created_at' => $this->faker->dateTimeBetween('-1 year', '-6 month'),
'updated_at' => $this->faker->dateTimeBetween('-5 month'),
];
Expand Down
Loading
Loading