I have a problem with update quantity in ps_stock_availabe table
I am trying to run query:
$query = "UPDATE `"._DB_PREFIX_."stock_available` SET quantity='".$quantity."' WHERE (id_product_attribute = '".$ID_product_attribute."' AND id_product = '".$ID_product."' )";
Db::getInstance()->Execute($query);
and nothing happen. Values are correct and not null. I can update 'manually' via PHPMyAdmin - but can not with script.
No errors in server log.
I am running update in my module in Hook:
public function hookActionProductAttributeUpdate($params) {}
other stuff in this Hook is updating without any problem.
What am I missing??
Your SQL query is not enough.
Instead, you should use PrestaShop's core function designed for this: StockAvailable::setQuantity($id_product, $id_product_attribute, $quantity)
Alternatively, if you wand to add or remove quantity from stock instead of setting a new one, you can also use the following function: StockAvailable::updateQuantity($id_product, $id_product_attribute, $delta_quantity)
where $delta_quantity
can be positive or negative depending on if you want to add or remove quantity.