0

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];

etc.

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?

1
  • 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]; Commented Aug 12, 2014 at 6:40

1 Answer 1

1

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

1
  • Glad to hear it :) Commented Aug 12, 2014 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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