@@ -130,7 +130,8 @@ public function getProducts($data = array())
130
130
$ sql ->where ('pl.`id_lang` = ' . (int )$ this ->context ->language ->id );
131
131
132
132
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 ' ]);
134
135
}
135
136
136
137
if (!empty ($ data ['filter_ids ' ])) {
@@ -155,6 +156,10 @@ public function getProducts($data = array())
155
156
156
157
$ result = Db::getInstance (_PS_USE_SQL_SLAVE_ )->executeS ($ sql );
157
158
159
+ if ($ data ['sort ' ] == 'price ' ) {
160
+ Tools::orderbyPrice ($ result ,$ data ['order ' ]);
161
+ }
162
+
158
163
return $ result ;
159
164
}
160
165
@@ -169,7 +174,8 @@ public function getTotalProducts($data = array())
169
174
$ sql ->where ('pl.`id_lang` = ' . (int )$ this ->context ->language ->id );
170
175
171
176
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 ' ]);
173
179
}
174
180
if (!empty ($ data ['filter_product_ids ' ])) {
175
181
$ sql ->where ('p.`id_product` IN ' . "(' " . implode ("',' " , $ data ['filter_product_ids ' ]) . "') " );
0 commit comments