- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
$collections = Yii::app()->db->createCommand()
->selectDistinct('prod.product_id,cc.category_id AS id, cc.code AS code,cc.img AS '
. 'pic,cc.category_name AS name, pl.category_name AS ln_name, '
. 'fvs.value AS country,c2.category_name AS parent_category,'
. 'c2.category_id AS p_id, c2.code AS p_code')
// ->select()
->from('Products prod')
->join('Products_Categoryes pc', 'prod.product_id = pc.product_id')
->join('Categories c', 'c.category_id = pc.category_id')
->join('Products_Categoryes ppp', 'ppp.category_id = c.category_id')
->join('Products p', 'p.product_id = ppp.product_id')
->join('Products_Categoryes pppccc', 'pppccc.product_id = ppp.product_id ')
->join('Categories cc', 'cc.category_id = pppccc.category_id
AND cc.category_left > :cat_left
AND cc.category_right < :cat_right
AND cc.category_level = 3', array(':cat_left' => $brends['category_left'], ':cat_right' => $brends['category_right']))
->join('Categories c2', 'cc.category_left > c2.category_left
AND cc.category_right < c2.category_right
AND c2.category_level = cc.category_level - 1')
->leftJoin('kk_categories_ln pl', ' pl.ln_id = :ln '
. 'AND pl.category_id = cc.category_id', array(':ln' => $ln_id))
->leftJoin('Feature_Product_Values fpv', 'p.product_id = fpv.product_id '
. 'AND feature_id = :country_id ', array(':country_id' => $counrty_id))
->leftJoin('Feature_Values_string fvs', 'fvs.feature_id = fpv.feature_id')
->group('cc.category_id')
->where($where, $params)
->queryAll();