Jump to content
покупайте без комиссии
Search In
  • More options...
Find results that contain...
Find results in...
  • Sign Up

Показывать товар с определенным статусом


Recommended Posts

Сейчас я изменил в файле catalog/model/catalog/pruduct.php 
p.status = '1' AND p.quantity > 0 - товары у которых остаток 0, не показывается на сайте
У некоторых товаров сейчас стоит статус отсутствия на складе 7 (
p.stock_status_id = '7')
Нужно чтобы товара которого нет в наличии, не показывался на сайте, как сейчас и есть, но товар который со статусом "Есть в наличии" выводился на сайт


 

Link to post
Share on other sites

сделайте по аналогии, как с p.quantity только p.stock_status_id != 7

Link to post
Share on other sites

Сделал так:
Не работает 

. "' AND p.status = '1' AND p.quantity > 0 AND p.stock_status_id != 7 AND p.date_available <= NOW() AND p2s.store_id = '" . 

 

Link to post
Share on other sites

p.`status`=1 AND ((p.`stock_status_id` <> 7) OR (p.`quantity` > 0 AND p.`stock_status_id` = 7))

У себя вот так делал. Попробуйте.

 

 

Link to post
Share on other sites

В 23.05.2018 в 23:53, Kindzaza сказал:

p.`status`=1 AND ((p.`stock_status_id` <> 7) OR (p.`quantity` > 0 AND p.`stock_status_id` = 7))

У себя вот так делал. Попробуйте.

 

 

Не получается, вот такая ошибка

SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, u.symbol_rus AS unit, (SELECT price FROM oc_product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '1' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM oc_product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '1' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special, (SELECT points FROM oc_product_reward pr WHERE pr.product_id = p.product_id AND customer_group_id = '1') AS reward, (SELECT ss.name FROM oc_stock_status ss WHERE ss.stock_status_id = p.stock_status_id AND ss.language_id = '3') AS stock_status, (SELECT wcd.unit FROM oc_weight_class_description wcd WHERE p.weight_class_id = wcd.weight_class_id AND wcd.language_id = '3') AS weight_class, (SELECT lcd.unit FROM oc_length_class_description lcd WHERE p.length_class_id = lcd.length_class_id AND lcd.language_id = '3') AS length_class, (SELECT AVG(rating) AS total FROM oc_review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT COUNT(*) AS total FROM oc_review r2 WHERE r2.product_id = p.product_id AND r2.status = '1' GROUP BY r2.product_id) AS reviews, p.sort_order FROM oc_product p LEFT JOIN oc_product_description pd ON (p.product_id = pd.product_id) LEFT JOIN oc_product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN oc_manufacturer m ON (p.manufacturer_id = m.manufacturer_id) LEFT JOIN oc_unit2 u ON (p.unit_id = u.unit_id) WHERE p.product_id = '680' AND pd.language_id = '3' p.`status`=1 AND ((p.`stock_status_id` <> 7) OR (p.`quantity` > 0 AND p.`stock_status_id` = 7)) AND p.date_available <= NOW() AND p2s.store_id = '0' in путь сайта/system/library/db/mysqli.php on line 41Notice: Trying to get property of non-object in путь сайта/system/storage/modification/catalog/model/catalog/product.php on line 10

Версия opencart 2.1.0.1

Link to post
Share on other sites

p.`status` = '1' AND (p.`quantity` > '0' OR p.`stock_status_id` = '7')

а у вас товары вычитаются со склада и отключен ли заказ при 0?
если да, то в в случае stock_status_id = 7 и 0 остатка, товар нельзя будет купить

Link to post
Share on other sites

15 часов назад, thentru сказал:

p.`status` = '1' AND (p.`quantity` > '0' OR p.`stock_status_id` = '7')

 а у вас товары вычитаются со склада и отключен ли заказ при 0?
если да, то в в случае stock_status_id = 7 и 0 остатка, товар нельзя будет купить


С остатком 0 можно купить
Сделал как Вы сказали, не получилось

Notice: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND p.date_available <= NOW() AND p2s.store_id = '0' AND cp.path_id =' at line 1
Error No: 1064
SELECT COUNT(DISTINCT p.product_id) AS total FROM oc_category_path cp LEFT JOIN oc_product_to_category p2c ON (cp.category_id = p2c.category_id) LEFT JOIN oc_product p ON (p2c.product_id = p.product_id) LEFT JOIN oc_product_description pd ON (p.product_id = pd.product_id) LEFT JOIN oc_product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '3' AND p.`status` = '1' AND (p.`quantity` > '0' OR p.`stock_status_id` = '7') AND p.date_available <= NOW() AND p2s.store_id = '0' AND cp.path_id = '9' in /var/www/u0379037/data/www/site.ru/system/library/db/mysqli.php on line 41Notice: Trying to get property of non-object in /var/www/u0379037/data/www/site.ru/system/storage/modification/catalog/model/catalog/product.php on line 496Notice: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND p.date_available <= NOW() AND p2s.store_id = '0' AND cp.path_id =' at line 1
Error No: 1064
SELECT p.product_id, (SELECT AVG(rating) AS total FROM oc_review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT price FROM oc_product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '1' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM oc_product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '1' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special FROM oc_category_path cp LEFT JOIN oc_product_to_category p2c ON (cp.category_id = p2c.category_id) LEFT JOIN oc_product p ON (p2c.product_id = p.product_id) LEFT JOIN oc_product_description pd ON (p.product_id = pd.product_id) LEFT JOIN oc_product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '3' AND p.`status` = '1' AND (p.`quantity` > '0' OR p.`stock_status_id` = '7') AND p.date_available <= NOW() AND p2s.store_id = '0' AND cp.path_id = '9' GROUP BY p.product_id ORDER BY p.sort_order ASC, LCASE(pd.name) ASC LIMIT 0,15 in /var/www/u0379037/data/www/site.ru/system/library/db/mysqli.php on line 41Notice: Trying to get property of non-object in /var/www/u0379037/data/www/site.ru/system/storage/modification/catalog/model/catalog/product.php on line 197Warning: Invalid argument supplied for foreach() in /var/www/u0379037/data/www/site.ru/system/storage/modification/catalog/model/catalog/product.php on line 197

 

Link to post
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.