\app\models\Product::find()->innerJoin(‘category’)->where(‘description_1 like \’%red%\’’)->groupBy(‘category_path’)->all();
I have this statement. Category is a 1 to many join with product in that each product can have multiple categories.
When I run the above statement I get back an object each product and all the categories it is in. Which is right, but wrong for my needs.
$product (1 product)
$product->category (All categories the product is in)
I need all the categories the product is in grouped and then sorted in order. The current methodology just gives the product + all the categories the product is in but does not group the categories.
How do I achieve
$product (1)
$product->category in a 1 to 1 like a sql statement would do.
Or is it possible to extract our the categories and then ->groupby on the return?
I could take what I have now and program around it. Just did not know if someone had a better solution.