set field_stock drupal_commerce_stock

by Romest   Last Updated January 19, 2018 18:07 PM

I get back product data and I create a product with its data.

I have to create a field field_stock (Stock level) in variations.

I create variations like this :

$variation =  ProductVariation::create(['type' => 'default', 'sku' => 'sku1', 'status' => TRUE, 'price' => $price]);

But I do not know how to add the value in the field_stock.

How I can do that ?

Related Questions

Find number of downloads in drupal commerce

Updated July 14, 2015 14:03 PM

Add multiple cart in drupal 7

Updated August 15, 2015 17:03 PM