Jay
Jay

Reputation: 2129

prestashop quantity not set using object mobel

I'm setting the product quantity using the following code:

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

When I go to the back office, the quantity of every product is set to 0. No errors are thrown during execution of the php script, and echoing out the value of $stock shows that values are being returned as expected. I've also tried passing in the quantity as a string.

Any idea whats going on here?

Upvotes: 0

Views: 1189

Answers (1)

Shaik Rilwan
Shaik Rilwan

Reputation: 355

you have to update the stock

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

Upvotes: 4

Related Questions