数据库中的 Prestashop 数量为 0 但实际数量显示在 BO

Prestashop quantity in database is 0 but actual quantities shows in BO

我对 Prestashop 1.7.7 有一个完全神秘的问题。

在数据库中,ps_product table,所有数量都设置为 0。但是,在 BO 中,我可以看到实际数量。

编辑:我找到了 table ps_stock_availabe。数量在这里。我在我的控制器中添加了这段代码:

$champion->loadStockData(); // This is a Product instance.
$chevalier->loadStockData(); // This is a Product instance.
$porter->loadStockData(); // This is a Product instance.
$potions->loadStockData(); // This is a Product instance.
$pepites->loadStockData(); // This is a Product instance.

运气不好。

请问如何在控制器中的产品实例中获取库存信息?

感谢您的宝贵时间。

我找到了解决问题的方法。

$champion = new Product(27);
$chevalier = new Product(28);
$porter = new Product(24);
$potions = new Product(25);
$pepites = new Product(26);
$champion->quantity = Product::getQuantity($champion->id); // Get the actual quantity
$chevalier->quantity = Product::getQuantity($chevalier->id);
$porter->quantity = Product::getQuantity($porter->id);
$potions->quantity = Product::getQuantity($potions->id);
$pepites->quantity = Product::getQuantity($pepites->id);
$champion->price = $champion->getPrice(true, null, 2); // Get the actual price with tax
$chevalier->price = $chevalier->getPrice(true, null, 2);
$porter->price = $porter->getPrice(true, null, 2);
$potions->price = $potions->getPrice(true, null, 2);
$pepites->price = $pepites->getPrice(true, null, 2);