未使用对象mobel设置预处理数量


prestashop quantity not set using object mobel

我使用以下代码设置产品数量:

$stock = (int)$prod->stock;
$ObjProduct->quantity = $stock;
$ObjProduct->out_of_stock = 0;

当我去后台时,每个产品的数量都设置为0。在php脚本的执行过程中没有抛出任何错误,并且回显$stock的值表明值是按预期返回的。我还试着把数量作为字符串传递。

知道这里发生了什么吗?

您必须更新库存

StockAvailable::setQuantity($prod->id_product, 0, (int) $prod->stock);