mercredi 29 mars 2023

Laravel: Product sorting based on categories

We are facing some issues while displaying the list of products with categories.

If there are 3 categories and each page contains 10 products on each page.

When we have 100 products, we need to show the listing with pagination. But the requirement is as below:

The list of products should be sorted like this: The first product from category 1 (In the list it will be in 1st place) The first product from category 2 (In the list it will be in 2nd place) The first product from category 3 (In the list it will be in 3rd place) The second product from category 1 (In the list it will be in 4th place) The second product from category 2 (In the list it will be in 5th place) The second product from category 3 (In the list it will be in 6th place) and So on...

We have product and category relation one to one relationship



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire