1
Answers
commerce_product_save($product) problem with commerce_price
I am creating a product using the below code. Everything is fine, bar not saving the price information. When I load the product using commerce_product_load(); I get all the correct product information without the price information. Any ideas what I am doing wrong?
$existing_product = commerce_product_load_by_sku($sku);
$product = !empty($existing_product) ? $existing_product : commerce_product_new('date_reserve_product');
// add price and currency information
$product_wrapper = entity_metadata_wrapper('commerce_product', $product);
$product_wrapper->sku = $sku;
$product_wrapper->title = $value['promotion_label'];
$product_wrapper->language = LANGUAGE_NONE;
$product_wrapper->commerce_price->amount = $value['promotion_cost'];
$product_wrapper->commerce_price->currency_code = commerce_default_currency();
$product_wrapper->save();
$product_id = $product->product_id;