Народ кто знает как сделать если, товара нету в наличии, то он бы автоматом в конец списка спускался?
так вроде норм встало, а еще тогда такой вопрос, как сделать чтобы сортировка была от меньшей цены к большей, в 1.5.3?
Я не автор модуля, откуда мне знать Угомонитесь - хватит набивать сообщения ето = бан А если так? Код: <!-- OpenCart Ukrainian Community LICENSE This source file is subject to the GNU General Public License, Version 3 It is also available through the world-wide-web at this URL: http://www.gnu.org/copyleft/gpl.html If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately. @category OpenCart @package OCU Product Sorting by Stock Status @copyright Copyright (c) 2011 Eugene Kuligin by OpenCart Ukrainian Community (http://opencart.ua) @license http://www.gnu.org/copyleft/gpl.html GNU General Public License, Version 3 @category OpenCart @package OCU Product Sorting by Stock Status @copyright Copyright (c) 2011 Eugene Kuligin by OpenCart Ukrainian Community (http://opencart.ua) @license http://www.gnu.org/copyleft/gpl.html GNU General Public License, Version 3 --> <modification> <id>OCU Product Sorting by Stock Status</id> <version>1.0</version> <vqmver>2.1.5</vqmver> <author>Eugene Kuligin</author> <website>http://www.opencart.ua</website> <email>[email protected]</email> <!-- catalog:start --> <!-- controller:start --> <!-- bug fix --> <file name="catalog/controller/product/special.php"> <operation> <search position="replace"> <![CDATA[ 'href' => $this->url->link('product/special', 'sort=special&order=ASC' . $url) ]]> </search> <add> <![CDATA[ 'href' => $this->url->link('product/special', 'sort=ps.price&order=ASC' . $url) ]]> </add> </operation> </file> <!-- latest module support --> <file name="catalog/controller/module/latest.php"> <operation> <search position="before"> <![CDATA[ 'sort' => 'p.date_added', ]]> </search> <add> <![CDATA[ 'is_module' => true, ]]> </add> </operation> </file> <!-- controller:end --> <!-- model:start --> <!-- get product list --> <file name="catalog/model/catalog/product.php"> <operation> <search position="replace"> <![CDATA[ $sql = "SELECT p.product_id, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id)"; ]]> </search> <add> <![CDATA[ $sql = "SELECT if(max(p.quantity) > 0, 1, 0) availability, if(exists(SELECT NULL FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id LIMIT 1), (SELECT ps.price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id ORDER BY ps.priority DESC LIMIT 1), price) current_price, p.product_id, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id)"; ]]> </add> </operation> <operation> <search position="replace"> <![CDATA[ $sql .= " ORDER BY LCASE(" . $data['sort'] . ")"; ]]> </search> <add> <![CDATA[ $sql .= " ORDER BY availability DESC, LCASE(" . $data['sort'] . ")"; } else if ($data['sort'] == 'p.price' || $data['sort'] == 'ps.price') { $sql .= " ORDER BY availability DESC, current_price"; } else if ($data['sort'] == 'p.date_added' && isset($data['is_module'])) { $sql .= " ORDER BY date_added DESC, availability DESC, current_price ASC, " . $data['sort']; ]]> </add> </operation> <operation> <search position="replace"> <![CDATA[ $sql .= " ORDER BY " . $data['sort']; ]]> </search> <add> <![CDATA[ $sql .= " ORDER BY availability DESC, current_price ASC, " . $data['sort']; ]]> </add> </operation> <operation> <search position="replace"> <![CDATA[ $sql .= " ORDER BY p.sort_order"; ]]> </search> <add> <![CDATA[ $sql .= " ORDER BY availability DESC, current_price ASC, p.sort_order"; ]]> </add> </operation> <!-- get special product list --> <operation> <search position="replace"> <![CDATA[ $sql = "SELECT DISTINCT ps.product_id, (SELECT AVG(rating) FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = ps.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating FROM " . DB_PREFIX . "product_special ps LEFT JOIN " . DB_PREFIX . "product p ON (ps.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ps.customer_group_id = '" . (int)$customer_group_id . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) GROUP BY ps.product_id"; ]]> </search> <add> <![CDATA[ $sql = "SELECT DISTINCT if(max(p.quantity) > 0, 1, 0) availability, ps.price AS current_price, ps.product_id, (SELECT AVG(rating) FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = ps.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating FROM " . DB_PREFIX . "product_special ps LEFT JOIN " . DB_PREFIX . "product p ON (ps.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND ps.customer_group_id = '" . (int)$customer_group_id . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) GROUP BY ps.product_id"; ]]> </add> </operation> </file> <!-- optional: if using spotonsolutions filter module --> <file name="catalog/model/catalog/browse.php"> <operation> <search position="replace"> <![CDATA[ $sql = "SELECT p.product_id, pd.name, pd.description, pd.meta_description, pd.meta_keyword, p.model, p.sku, p.location, p.quantity, ss.name as stock_status, p.image, p.manufacturer_id, m.name AS manufacturer, p.price, ps.price AS special, pr.points AS reward, p.points, p.tax_class_id, p.date_available, p.weight, wcd.unit AS weight_class, p.length, p.width, p.height, lcd.unit AS length_class, p.subtract, (SELECT AVG(r.rating) FROM " . DB_PREFIX . "review r WHERE p.product_id = r.product_id GROUP BY r.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews, p.minimum, p.sort_order, p.status, p.date_added, p.date_modified, p.viewed FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "') LEFT JOIN " . DB_PREFIX . "manufacturer m ON m.manufacturer_id = p.manufacturer_id LEFT JOIN " . DB_PREFIX . "stock_status ss ON ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "' LEFT JOIN " . DB_PREFIX . "product_reward pr ON pr.product_id = p.product_id AND pr.customer_group_id = '" . (int)$customer_group_id . "' LEFT JOIN " . DB_PREFIX . "weight_class_description wcd ON wcd.weight_class_id = p.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "' LEFT JOIN " . DB_PREFIX . "length_class_description lcd ON lcd.length_class_id = p.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "' LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id)"; ]]> </search> <add> <![CDATA[ $sql = "SELECT if(max(p.quantity) > 0, 1, 0) availability, if(exists(SELECT NULL FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id LIMIT 1), (SELECT ps.price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id ORDER BY ps.priority DESC LIMIT 1), p.price) current_price, p.product_id, pd.name, pd.description, pd.meta_description, pd.meta_keyword, p.model, p.sku, p.location, p.quantity, ss.name as stock_status, p.image, p.manufacturer_id, m.name AS manufacturer, p.price, ps.price AS special, pr.points AS reward, p.points, p.tax_class_id, p.date_available, p.weight, wcd.unit AS weight_class, p.length, p.width, p.height, lcd.unit AS length_class, p.subtract, (SELECT AVG(r.rating) FROM " . DB_PREFIX . "review r WHERE p.product_id = r.product_id GROUP BY r.product_id) AS rating, (SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews, p.minimum, p.sort_order, p.status, p.date_added, p.date_modified, p.viewed FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "') LEFT JOIN " . DB_PREFIX . "manufacturer m ON m.manufacturer_id = p.manufacturer_id LEFT JOIN " . DB_PREFIX . "stock_status ss ON ss.stock_status_id = p.stock_status_id AND ss.language_id = '" . (int)$this->config->get('config_language_id') . "' LEFT JOIN " . DB_PREFIX . "product_reward pr ON pr.product_id = p.product_id AND pr.customer_group_id = '" . (int)$customer_group_id . "' LEFT JOIN " . DB_PREFIX . "weight_class_description wcd ON wcd.weight_class_id = p.weight_class_id AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "' LEFT JOIN " . DB_PREFIX . "length_class_description lcd ON lcd.length_class_id = p.length_class_id AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "' LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id)"; ]]> </add> </operation> <operation> <search position="replace"> <![CDATA[ $sql .= " ORDER BY LEAST(IF(p.price, p.price, 99999), IF(pdis.price, pdis.price, 99999), IF(ps.price, ps.price, 99999))"; ]]> </search> <add> <![CDATA[ $sql .= " ORDER BY availability DESC, LEAST(IF(p.price, p.price, 99999), IF(pdis.price, pdis.price, 99999), IF(ps.price, ps.price, 99999))"; ]]> </add> </operation> <operation> <search position="replace"> <![CDATA[ $sql .= " ORDER BY " . $sort; ]]> </search> <add> <![CDATA[ $sql .= " ORDER BY availability DESC, current_price ASC, " . $sort; ]]> </add> </operation> <operation> <search position="replace"> <![CDATA[ $sql .= " ORDER BY p.sort_order, pd.name"; ]]> </search> <add> <![CDATA[ $sql .= " ORDER BY availability DESC, current_price ASC, p.sort_order, pd.name"; ]]> </add> </operation> </file> <!-- model:end --> <!-- catalog:end --> </modification> --- добавлено: 19 фев 2013 в 22:26 ---