  |
79 | 79 | | } |
| |
80 | 80 | | |
| |
81 | 81 | | function &execute() { |
  |
82 | | - | global $osC_Database, $osC_Language, $osC_Image; |
| |
| 82 | + | global $osC_Database, $osC_Language, $osC_CategoryTree, $osC_Image; |
|
83 | 83 | | |
| |
84 | 84 | | $Qlisting = $osC_Database->query('select distinct p.*, pd.*, m.*, 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, i.image from :table_products p left join :table_manufacturers m using(manufacturers_id) left join :table_specials s on (p.products_id = s.products_id) left join :table_products_images i on (p.products_id = i.products_id and i.default_flag = :default_flag), :table_products_description pd, :table_categories c, :table_products_to_categories p2c where p.products_status = 1 and p.products_id = pd.products_id and pd.language_id = :language_id and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id'); |
| |
85 | 85 | | $Qlisting->bindTable(':table_products', TABLE_PRODUCTS); |
| |
|
|
 |
… |
|
94 | 94 | | |
| |
95 | 95 | | if ($this->hasCategory()) { |
| |
96 | 96 | | if ($this->isRecursive()) { |
  |
97 | | - | $subcategories_array = array(); |
| |
98 | | - | tep_get_subcategories($subcategories_array, $this->_category); |
| |
| 97 | + | $subcategories_array = array($this->_category); |
|
99 | 98 | | |
  |
100 | | - | $Qlisting->appendQuery('and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and (p2c.categories_id = :categories_id'); |
| |
101 | | - | $Qlisting->bindInt(':categories_id', $this->_category); |
| |
102 | | - | |
| |
103 | | - | foreach ($subcategories_array as $sc) { |
| |
104 | | - | $Qlisting->appendQuery('or p2c.categories_id = :categories_id'); |
| |
105 | | - | $Qlisting->bindInt(':categories_id', $sc); |
| |
106 | | - | } |
| |
107 | | - | |
| |
108 | | - | $Qlisting->appendQuery(')'); |
| |
| 99 | + | $Qlisting->appendQuery('and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and p2c.categories_id in (:categories_id)'); |
| |
| 100 | + | $Qlisting->bindRaw(':categories_id', implode(',', $osC_CategoryTree->getChildren($this->_category, $subcategories_array))); |
  |
109 | 101 | | } else { |
| |
110 | 102 | | $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'); |
| |
111 | 103 | | $Qlisting->bindInt(':language_id', $osC_Language->getID()); |