  |
132 | 132 | | } |
| |
133 | 133 | | |
| |
134 | 134 | | function &execute() { |
  |
135 | | - | global $osC_Database, $osC_Customer, $osC_Currencies, $osC_Language, $osC_Image; |
| |
| 135 | + | global $osC_Database, $osC_Customer, $osC_Currencies, $osC_Language, $osC_Image, $osC_CategoryTree; |
|
136 | 136 | | |
| |
137 | 137 | | $Qlisting = $osC_Database->query('select SQL_CALC_FOUND_ROWS distinct p.*, pd.*, m.*, i.image, if(s.status, s.specials_new_products_price, null) as specials_new_products_price, if(s.status, s.specials_new_products_price, p.products_price) as final_price'); |
| |
138 | 138 | | |
| |
|
|
 |
… |
|
173 | 173 | | |
| |
174 | 174 | | if ($this->hasCategory()) { |
| |
175 | 175 | | if ($this->isRecursive()) { |
  |
176 | | - | $subcategories_array = array(); |
| |
177 | | - | tep_get_subcategories($subcategories_array, $this->_category); |
| |
| 176 | + | $subcategories_array = array($this->_category); |
|
178 | 177 | | |
  |
179 | | - | $Qlisting->appendQuery('and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and (p2c.categories_id = :categories_id'); |
| |
180 | | - | $Qlisting->bindInt(':categories_id', $this->_category); |
| |
181 | | - | |
| |
182 | | - | foreach ($subcategories_array as $sc) { |
| |
183 | | - | $Qlisting->appendQuery('or p2c.categories_id = :categories_id'); |
| |
184 | | - | $Qlisting->bindInt(':categories_id', $sc); |
| |
185 | | - | } |
| |
186 | | - | |
| |
187 | | - | $Qlisting->appendQuery(')'); |
| |
| 178 | + | $Qlisting->appendQuery('and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and p2c.categories_id in (:categories_id)'); |
| |
| 179 | + | $Qlisting->bindRaw(':categories_id', implode(',', $osC_CategoryTree->getChildren($this->_category, $subcategories_array))); |
  |
188 | 180 | | } else { |
| |
189 | 181 | | $Qlisting->appendQuery('and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and pd.language_id = :language_id and p2c.categories_id = :categories_id'); |
| |
190 | 182 | | $Qlisting->bindInt(':language_id', $osC_Language->getID()); |