Price Field Type from the Commerce module package is not exportable for Feeds. So as a work-around, I saved my prices ('min price', 'hot price' and "deposit price') into normal Float fields and just move the values to the Price Field Types on-the-fly. And so here it is (set using Rules: After an item is saved of content type 'Property'):

$node->field_price_amount['und'][0]['value'] = [node:field-current-price-temp];
$node->field_hot_price_amount['und'][0]['value'] = [node-field-hot-price-temp];


and then applying the node_save($node) with $node->is_new set to FALSE.

All the other values are saving properly except for the field type defined by the Commerce module. No actual data saved to tables at all.

"$node->field_price" should be the right machine name I have defined for this field. But for some reason importing leads to error field_price_amount cannot be NULL. This is also weird. So I changed it to field_price_amount so it won't complain but still not saving despite no more errors in importing. (The db table is still named field_data_field_price but for some reason it is complaining as 'field_price_amount should not be null ).

Anyone have ideas?

  • Seems like there is a column amount not value for a price field $node->field_price_amount['und'][0]['amount'] = [node:field-current-price-temp]; – Pontus Nilsson Aug 12 '14 at 6:40

Commerce price fields have a different data structure from standard fields.

i.e not:

$product->commerce_price[LANGUAGE_NONE][0]['value'] = 500;

but instead

$product->commerce_price[LANGUAGE_NONE][0]['amount'] = 500;
$product->commerce_price[LANGUAGE_NONE][0]['currency_code'] = 'USD';

or just:

$product->commerce_price[LANGUAGE_NONE][0] = array('amount' => 500, 'currency_code' => 'USD');

They also have a 'data' property for additional price component information.

More info: commerce_price_field_data_property_info

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.