Jump to content
Sign in to follow this  
Chenom0r

getProductSpecials - выбрать товары с количеством > 0

Recommended Posts

Здравствуйте!

Помогите, пожалуйста. Как в методе getProductSpecials модуля specials выбрать товары в наличии?

А то, если продукт на складе закончился, он все-равно отображается в модуле на главной.

 

 

Share this post


Link to post
Share on other sites

написать свой метод

Или Допилить существующий

Share this post


Link to post
Share on other sites

 

Или Допилить существующий

 

Подскажите пожалуйста sql-запрос, который выберет товары с количеством >0

Share this post


Link to post
Share on other sites
SELECT *
  FROM product_special ps
  WHERE ps.product_id = '30'
    AND (SELECT quantity
                FROM product p
                WHERE p.product_id = ps.product_id
                  AND quantity >0
             ) >1
ORDER BY ps.priority, ps.price

Надеюсь, остальное сделаете

 

 

Но может понадобится и такое

SELECT *, (SELECT  	quantity FROM " .   DB_PREFIX . "product p WHERE p.product_id = '" . (int)$product_id ." AND quantity > 0) as quantity
	FROM " . DB_PREFIX . "product_special  ps
	WHERE ps.product_id = '" . (int)$product_id . "' ORDER BY ps.priority, ps.price");


Внимание! Если у вас мултимагазин - работать не будет.

Share this post


Link to post
Share on other sites

Можно и так, но на ночь запрос с подзапросом отработал быстрее. Хотя по идее должно быть наоборот

SELECT ps.*
    FROM product_special  ps
INNER JOIN product p ON p.product_id = ps.product_id
    WHERE ps.product_id = '30'
            AND p.quantity > 0
ORDER BY ps.priority, ps.price

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

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.