I have a simple filtering on my catalog. It allows me to choose the product based on its attributes and its values. For instance we have a set of beads:
Stone bead it has a size of 12mm, round shape and material of stone
Glass/Wooden/Plastic bead it has a size of 26mm, square shape and material of glass, wood and plastic
The problem I'm facing is duplicates when I choose glass, wood and plastic materials in the filter, since one product has it all.
One product shows three times.
Here is the code for getting products: http://laravel.io/bin/WzRym
Which generates the following query:
select * from `products` inner join `products_attributes_values` as `pav0` on `pav0`.`product_id` = `products`.`id` where `category_id` in ('6') and `availability` = 'in_stock' and `pav0`.`attribute_id` = '2' and `pav0`.`value_id` in ('39', '93', '96') order by `id` desc limit 48 offset 0
How could I omit the duplicates?
Try adding
group by `products`.`id`
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community