Hello,
I want to know if is possible to update the value of the stock of a product from a custom module. there is some public function or hook to do this task? if not, is safe to update the values directly to the field_data_commerce_stock database table?
thanks in advance.
Comments
Comment #1
guy_schneerson commentedHi you can update the commerce_stock field directly as long as you do it using Drupal you should not update the database directly (this is not only for stock and is generally a bad practice)
Comment #2
cigotete commentedHi, thanks for your reply and your guidance.
Comment #3
r_morgan commentedRecently I encountered the same issue, and wanted to share the solution I came up with.
The commerce_product_load_by_sku could be replaced with either commerce_product_load or commerce_product_load_multiple
Comment #4
guy_schneerson commentedA couple of notes:
closing due to lack of activity, re open if still relevant.