@@ -130,7 +130,8 @@ public function getProducts($data = array())
130130 $ sql ->where ('pl.`id_lang` = ' . (int )$ this ->context ->language ->id );
131131
132132 if (!empty ($ data ['filter_category_id ' ]) && $ data ['filter_category_id ' ] > 0 ) {
133- $ sql ->where ('p.`id_category_default` = ' . (int )$ data ['filter_category_id ' ]);
133+ $ sql ->leftJoin ('category_product ' , 'c ' , 'c.`id_product` = p.`id_product` ' );
134+ $ sql ->where ('c.`id_category` = ' . (int )$ data ['filter_category_id ' ]);
134135 }
135136
136137 if (!empty ($ data ['filter_ids ' ])) {
@@ -155,6 +156,10 @@ public function getProducts($data = array())
155156
156157 $ result = Db::getInstance (_PS_USE_SQL_SLAVE_ )->executeS ($ sql );
157158
159+ if ($ data ['sort ' ] == 'price ' ) {
160+ Tools::orderbyPrice ($ result ,$ data ['order ' ]);
161+ }
162+
158163 return $ result ;
159164 }
160165
@@ -169,7 +174,8 @@ public function getTotalProducts($data = array())
169174 $ sql ->where ('pl.`id_lang` = ' . (int )$ this ->context ->language ->id );
170175
171176 if (!empty ($ data ['filter_category_id ' ]) && $ data ['filter_category_id ' ] > 0 ) {
172- $ sql ->where ('p.`id_category_default` = ' . (int )$ data ['filter_category_id ' ]);
177+ $ sql ->leftJoin ('category_product ' , 'c ' , 'c.`id_product` = p.`id_product` ' );
178+ $ sql ->where ('c.`id_category` = ' . (int )$ data ['filter_category_id ' ]);
173179 }
174180 if (!empty ($ data ['filter_product_ids ' ])) {
175181 $ sql ->where ('p.`id_product` IN ' . "(' " . implode ("',' " , $ data ['filter_product_ids ' ]) . "') " );
0 commit comments