简体   繁体   English

prestashop-如何确定产品是否可供出售

[英]prestashop -How to find out if a product is available for sale or not

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 ? 如何从prestashop的mysql数据库中找到它?

You can check product availability by calling checkQty() in the Product Class 您可以通过在产品类中调用checkQty()来检查产品的可用性

$prod = new Product($idProduct);
$available = $prod->checkQty();

If you want to do that via SQL, you have to check two things : 如果要通过SQL进行此操作,则必须检查两件事:

  • In prefix_stock_available , make sure quantity is not at zero (quantity = sum of all combination's qty) prefix_stock_available ,确保quantity不为零(数量=所有组合数量的总和)

  • In prefix_stock_available , if out_of_stock prefix_stock_available ,如果out_of_stock

    • equals 0 , it means the product will NOT allow new orders if not enough quantity 等于0 ,表示如果数量不足,产品将不允许新订单
    • equals 1 , it means the product will allow new orders if not enough quantity 等于1 ,表示如果数量不足,产品将允许新订单
    • equals 2 , it means that the product behaviour is defined by the global setting you can find in prefix_configuration at the key PS_ORDER_OUT_OF_STOCK so you have to check that one too. 等于2 ,这意味着该产品的行为是由你可以找到全局设置中定义prefix_configuration在关键PS_ORDER_OUT_OF_STOCK所以你要检查一个了。

This is the easiest way to get only the active products through MySql query. 这是通过MySql查询仅获取活动产品的最简单方法。 Remember replacing the PS_PREFIX for the real prefix. 切记将PS_PREFIX替换为真实前缀。 The default prefix is - ps - , but for security reasons, it is recomendable change it: 默认前缀是-ps- ,但是出于安全原因,建议更改它:

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: 在这种情况下,您必须将PRODUCT_ID替换为实数:

SELECT * FROM `PS_PREFIX_product` WHERE `active` = 1 AND `available_for_order` = 1 AND `id_product` = PRODUCT_ID

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM