Hi, I'm hoping someone can help me with this.
I've been provided with ecommerce Excel spreadsheets which contain thousands of products. I've got the import working using the Maatwebsite Excel package but have run into an issue with returning paginated results which I need to return only the first of each product but not the other variations.
So, in my database I have the sku of the product along with the product_group column. There may be 20 'variations' which are actually 20 products so when I want to list all products in the admin area, it shows 20 variations of product 1, then 20 variations of product 2 etc.
What I'd like to do is only return the first 'variation' so that my list has product 1, product 2, product 3 etc.
Accessing the variations would be handled by clicking on the first (or parent) product and then I'd pull all the other variations in on a tab in that screen so they can be edited.
So, to clarify, I currently have this:
product_group product
001M - Product 1 (Black)
001M - Product 1 (Red)
001M - Product 1 (Green)
001M - Product 1 (Orange)
002M - Product 2 (Black)
002M - Product 2 (Red)
002M - Product 2 (Green)
002M - Product 2 (Orange)
003M - Product 3 (Black)
003M - Product 3 (Red)
003M - Product 3 (Green)
003M - Product 3 (Orange)
ETC
-----------------
< [1][2][3][4]…[100] >
But I'd like this:
product_group product
001M - Product 1 (Black)
002M - Product 2 (Black)
003M - Product 3 (Black)
004M - Product 3 (Black)
005M - Product 3 (Black)
006M - Product 3 (Black)
ETC
-----------------
< [1][2][3][4]…[100] >
This is the simple $product query I'm using:
$products = Product::orderby('created_at', 'desc')
->paginate(20);
Can anyone tell me what I need to change so I can get the results I need?
Many thanks.