Unknown column 'sales' in 'order clause'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) AS quantity, pl.`description`, pl.`description_short`, pl.`available_now`,
pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, image_shop.`id_image` id_image,
il.`legend` as legend, m.`name` AS manufacturer_name, cl.`name` AS category_default,
DATEDIFF(product_shop.`date_add`, DATE_SUB("2024-03-29 00:00:00",
INTERVAL 60 DAY)) > 0 AS new, product_shop.price AS orderprice
FROM `psan_category_product` cp
LEFT JOIN `psan_product` p
ON p.`id_product` = cp.`id_product`
INNER JOIN psan_product_shop product_shop
ON (product_shop.id_product = p.id_product AND product_shop.id_shop = 1)
LEFT JOIN psan_stock_available stock
ON (stock.id_product = `p`.id_product AND stock.id_product_attribute = 0 AND stock.id_shop = 1 AND stock.id_shop_group = 0 )
LEFT JOIN `psan_category_lang` cl
ON (product_shop.`id_category_default` = cl.`id_category`
AND cl.`id_lang` = 2 AND cl.id_shop = 1 )
LEFT JOIN `psan_product_lang` pl
ON (p.`id_product` = pl.`id_product`
AND pl.`id_lang` = 2 AND pl.id_shop = 1 )
LEFT JOIN `psan_image_shop` image_shop
ON (image_shop.`id_product` = p.`id_product` AND image_shop.cover=1 AND image_shop.id_shop=1)
LEFT JOIN `psan_image_lang` il
ON (image_shop.`id_image` = il.`id_image`
AND il.`id_lang` = 2)
LEFT JOIN `psan_manufacturer` m
ON m.`id_manufacturer` = p.`id_manufacturer`
WHERE product_shop.`id_shop` = 1
AND cp.`id_category` = 32 AND product_shop.`active` = 1 AND product_shop.`visibility` IN ("both", "catalog") ORDER BY `sales` DESC
LIMIT 0,24
at line 746 in file classes/db/Db.php
741. if ($webservice_call && $errno) {
742. $dbg = debug_backtrace();
743. WebserviceRequest::getInstance()->setError(500, '[SQL Error] '.$this->getMsgError().'. From '.(isset($dbg[3]['class']) ? $dbg[3]['class'] : '').'->'.$dbg[3]['function'].'() Query was : '.$sql, 97);
744. } elseif (_PS_DEBUG_SQL_ && $errno && !defined('PS_INSTALLATION_IN_PROGRESS')) {
745. if ($sql) {
746. throw new PrestaShopDatabaseException($this->getMsgError().'<br /><br /><pre>'.$sql.'</pre>');
747. }
748.
749. throw new PrestaShopDatabaseException($this->getMsgError());
750. }
751. }
373. $this->result = $this->_query($sql);
374. }
375. }
376.
377. if (_PS_DEBUG_SQL_) {
378. $this->displayError($sql);
379. }
380.
381. return $this->result;
382. }
383.
Argument [0] SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) AS quantity, pl.`description`, pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, image_shop.`id_image` id_image, il.`legend` as legend, m.`name` AS manufacturer_name, cl.`name` AS category_default, DATEDIFF(product_shop.`date_add`, DATE_SUB("2024-03-29 00:00:00", INTERVAL 60 DAY)) > 0 AS new, product_shop.price AS orderprice FROM `psan_category_product` cp LEFT JOIN `psan_product` p ON p.`id_product` = cp.`id_product` INNER JOIN psan_product_shop product_shop ON (product_shop.id_product = p.id_product AND product_shop.id_shop = 1) LEFT JOIN psan_stock_available stock ON (stock.id_product = `p`.id_product AND stock.id_product_attribute = 0 AND stock.id_shop = 1 AND stock.id_shop_group = 0 ) LEFT JOIN `psan_category_lang` cl ON (product_shop.`id_category_default` = cl.`id_category` AND cl.`id_lang` = 2 AND cl.id_shop = 1 ) LEFT JOIN `psan_product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = 2 AND pl.id_shop = 1 ) LEFT JOIN `psan_image_shop` image_shop ON (image_shop.`id_product` = p.`id_product` AND image_shop.cover=1 AND image_shop.id_shop=1) LEFT JOIN `psan_image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = 2) LEFT JOIN `psan_manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer` WHERE product_shop.`id_shop` = 1 AND cp.`id_category` = 32 AND product_shop.`active` = 1 AND product_shop.`visibility` IN ("both", "catalog") ORDER BY `sales` DESC LIMIT 0,24
592. throw new PrestaShopDatabaseException('Db->executeS() must be used only with select, show, explain or describe queries');
593. }
594. return $this->execute($sql, $use_cache);
595. }
596.
597. $this->result = $this->query($sql);
598.
599. if (!$this->result) {
600. $result = false;
601. } else {
602. if (!$array) {
Argument [0] SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) AS quantity, pl.`description`, pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, image_shop.`id_image` id_image, il.`legend` as legend, m.`name` AS manufacturer_name, cl.`name` AS category_default, DATEDIFF(product_shop.`date_add`, DATE_SUB("2024-03-29 00:00:00", INTERVAL 60 DAY)) > 0 AS new, product_shop.price AS orderprice FROM `psan_category_product` cp LEFT JOIN `psan_product` p ON p.`id_product` = cp.`id_product` INNER JOIN psan_product_shop product_shop ON (product_shop.id_product = p.id_product AND product_shop.id_shop = 1) LEFT JOIN psan_stock_available stock ON (stock.id_product = `p`.id_product AND stock.id_product_attribute = 0 AND stock.id_shop = 1 AND stock.id_shop_group = 0 ) LEFT JOIN `psan_category_lang` cl ON (product_shop.`id_category_default` = cl.`id_category` AND cl.`id_lang` = 2 AND cl.id_shop = 1 ) LEFT JOIN `psan_product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = 2 AND pl.id_shop = 1 ) LEFT JOIN `psan_image_shop` image_shop ON (image_shop.`id_product` = p.`id_product` AND image_shop.cover=1 AND image_shop.id_shop=1) LEFT JOIN `psan_image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = 2) LEFT JOIN `psan_manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer` WHERE product_shop.`id_shop` = 1 AND cp.`id_category` = 32 AND product_shop.`active` = 1 AND product_shop.`visibility` IN ("both", "catalog") ORDER BY `sales` DESC LIMIT 0,24
953. } else {
954. $sql .= ' ORDER BY '.(!empty($orderByPrefix) ? $orderByPrefix.'.' : '').'`'.bqSQL($orderyBy).'` '.pSQL($orderWay).'
955. LIMIT '.(((int) $p - 1) * (int) $n).','.(int) $n;
956. }
957.
958. $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql, true, false);
959.
960. if (!$result) {
961. return array();
962. }
963.
Argument [0] SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) AS quantity, pl.`description`, pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, image_shop.`id_image` id_image, il.`legend` as legend, m.`name` AS manufacturer_name, cl.`name` AS category_default, DATEDIFF(product_shop.`date_add`, DATE_SUB("2024-03-29 00:00:00", INTERVAL 60 DAY)) > 0 AS new, product_shop.price AS orderprice FROM `psan_category_product` cp LEFT JOIN `psan_product` p ON p.`id_product` = cp.`id_product` INNER JOIN psan_product_shop product_shop ON (product_shop.id_product = p.id_product AND product_shop.id_shop = 1) LEFT JOIN psan_stock_available stock ON (stock.id_product = `p`.id_product AND stock.id_product_attribute = 0 AND stock.id_shop = 1 AND stock.id_shop_group = 0 ) LEFT JOIN `psan_category_lang` cl ON (product_shop.`id_category_default` = cl.`id_category` AND cl.`id_lang` = 2 AND cl.id_shop = 1 ) LEFT JOIN `psan_product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = 2 AND pl.id_shop = 1 ) LEFT JOIN `psan_image_shop` image_shop ON (image_shop.`id_product` = p.`id_product` AND image_shop.cover=1 AND image_shop.id_shop=1) LEFT JOIN `psan_image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = 2) LEFT JOIN `psan_manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer` WHERE product_shop.`id_shop` = 1 AND cp.`id_category` = 32 AND product_shop.`active` = 1 AND product_shop.`visibility` IN ("both", "catalog") ORDER BY `sales` DESC LIMIT 0,24 Argument [1] 1 Argument [2]
72. $context->getIdLang(),
73. $query->getPage(),
74. $query->getResultsPerPage(),
75. $query->getSortOrder()->toLegacyOrderBy(),
76. $query->getSortOrder()->toLegacyOrderWay(),
77. $type !== 'products'
78. );
79. }
80. }
81.
82. public function runQuery(
Argument [0] 2 Argument [1] 1 Argument [2] 24 Argument [3] sales Argument [4] DESC Argument [5]
81.
82. public function runQuery(
83. ProductSearchContext $context,
84. ProductSearchQuery $query
85. ) {
86. $products = $this->getProductsOrCount($context, $query, 'products');
87. $count = $this->getProductsOrCount($context, $query, 'count');
88.
89. $result = new ProductSearchResult();
90.
91. if (!empty($products)) {
Argument [0] PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext Object ( [id_shop:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext:private] => 1 [id_lang:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext:private] => 2 [id_currency:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext:private] => 2 [id_customer:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext:private] => ) Argument [1] PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery Object ( [query_type:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => [id_category:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => 32 [id_manufacturer:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => [id_supplier:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => [search_string:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => [search_tag:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => [encodedFacets:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => [resultsPerPage:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => 24 [page:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => 1 [sortOrder:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => PrestaShop\PrestaShop\Core\Product\Search\SortOrder Object ( [entity:PrestaShop\PrestaShop\Core\Product\Search\SortOrder:private] => product [field:PrestaShop\PrestaShop\Core\Product\Search\SortOrder:private] => sales [direction:PrestaShop\PrestaShop\Core\Product\Search\SortOrder:private] => desc [label:PrestaShop\PrestaShop\Core\Product\Search\SortOrder:private] => ) ) Argument [2] products
310.
311. // We're ready to run the actual query!
312.
313. $result = $provider->runQuery(
314. $context,
315. $query
316. );
317.
318. // sort order is useful for template,
319. // add it if undefined - it should be the same one
320. // as for the query anyway
Argument [0] PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext Object ( [id_shop:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext:private] => 1 [id_lang:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext:private] => 2 [id_currency:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext:private] => 2 [id_customer:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext:private] => ) Argument [1] PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery Object ( [query_type:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => [id_category:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => 32 [id_manufacturer:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => [id_supplier:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => [search_string:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => [search_tag:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => [encodedFacets:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => [resultsPerPage:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => 24 [page:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => 1 [sortOrder:PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery:private] => PrestaShop\PrestaShop\Core\Product\Search\SortOrder Object ( [entity:PrestaShop\PrestaShop\Core\Product\Search\SortOrder:private] => product [field:PrestaShop\PrestaShop\Core\Product\Search\SortOrder:private] => sales [direction:PrestaShop\PrestaShop\Core\Product\Search\SortOrder:private] => desc [label:PrestaShop\PrestaShop\Core\Product\Search\SortOrder:private] => ) )
525. if ($this->ajax) {
526. ob_end_clean();
527. header('Content-Type: application/json');
528. $this->ajaxDie(json_encode($this->getAjaxProductSearchVariables()));
529. } else {
530. $variables = $this->getProductSearchVariables();
531. $this->context->smarty->assign(array(
532. 'listing' => $variables,
533. ));
534. $this->setTemplate($template, $params, $locale);
535. }
116.
117. $this->doProductSearch(
118. 'catalog/listing/category',
119. array(
120. 'entity' => 'category',
121. 'id' => $this->category->id
122. )
123. );
124. }
125.
126. protected function getProductSearchQuery()
Argument [0] catalog/listing/category Argument [1] Array ( [entity] => category [id] => 32 )
248. if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className))) {
249. $this->initHeader();
250. }
251.
252. if ($this->viewAccess()) {
253. $this->initContent();
254. } else {
255. $this->errors[] = $this->trans('Access denied.', array(), 'Admin.Notifications.Error');
256. }
257.
258. if (!$this->content_only && ($this->display_footer || (isset($this->className) && $this->className))) {
423. if (isset($params_hook_action_dispatcher)) {
424. Hook::exec('actionDispatcher', $params_hook_action_dispatcher);
425. }
426.
427. // Running controller
428. $controller->run();
429.
430. // Execute hook dispatcher after
431. if (isset($params_hook_action_dispatcher)) {
432. Hook::exec('actionDispatcherAfter', $params_hook_action_dispatcher);
433. }
23. * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
24. * International Registered Trademark & Property of PrestaShop SA
25. */
26.
27. require(dirname(__FILE__).'/config/config.inc.php');
28. Dispatcher::getInstance()->dispatch();