php - prestashop -How to find out if a product is available for sale or not
Get the solution ↓↓↓I need to know is my product is available for sale or not . I searched alot in product table but I don't know which cell is showing that how many of this product is available and is it for sale or not at all .
How can I find it out from mysql database of prestashop ?
Answer
Solution:
You can check product availability by calling{-code-1}
in the Product Class
$prod = new Product($idProduct);
$available = $prod->{-code-1};
If you want to do that via SQL, you have to check two things :
In
prefix_stock_available
, make surequantity
is not at zero (quantity = sum of all combination's qty)In
prefix_stock_available
, ifout_of_stock
- equals
0
, it means the product will NOT allow new orders if not enough quantity - equals
1
, it means the product will allow new orders if not enough quantity - equals
2
, it means that the product behaviour is defined by the global setting you can find inprefix_configuration
at the keyPS_ORDER_OUT_OF_STOCK
so you have to check that one too.
- equals
Answer
Solution:
This is the easiest way to get only the active products through MySql query. Remember replacing the PS_PREFIX for the real prefix. The default prefix is - ps - , but for security reasons, it is recomendable change it:
SELECT * FROM `PS_PREFIX_product` WHERE `active` = 1 AND `available_for_order` = 1
Now, you can change the query to apply some filter to get the result that you need. For example, checking if some product is available. In this case, you would have to replace the PRODUCT_ID for a real number:
SELECT * FROM `PS_PREFIX_product` WHERE `active` = 1 AND `available_for_order` = 1 AND `id_product` = PRODUCT_ID
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: gd library extension not available with this php installation.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.