1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
return ShopProduct::find() ->select( ShopProduct::tableName() . '.name pn, ' . ShopProduct::tableName() . '.path pp, lvl1.name l1n, lvl1.path l1p, lvl2.name l2n, lvl2.path l2p, lvl3.name l3n, lvl3.path l3p' ) ->leftJoin(ShopCategory::tableName() . ' lvl1', ShopProduct::tableName() . '.cat_id = lvl1.id') ->leftJoin(ShopCategory::tableName() . ' lvl2', 'lvl1.parent_id = lvl2.id') ->leftJoin(ShopCategory::tableName() . ' lvl3', 'lvl2.parent_id = lvl3.id') ->where([ShopProduct::tableName() . ".id" => $id]) ->asArray() ->one(); |