I have a csv file from a different cms(custom) and i need to import customer profiles. The commerce feeds imports additional fields but not address field like first and last name.
if i dsm the profile which is going to be insertes in this function in commerce customer profile commerce_customer_profile_save($profile) the last and first name values are there. but when i goes to edit the inserted profile these fields are empty

Any ideas why this is happening?

Comments

dianikol’s picture

The problem was with the addressfield module. If one of the required field is missing then it doesn't fill in the others. My workaround is this code in
addressfield_set_target($source, $entity, $target, $value) function in addressfield module

function addressfield_set_target($source, $entity, $target, $value) {

  if ($target == 'commerce_customer_address:country') {
	  $value = 'your counties initials';
  } 
  if ($value == '' && $target != 'commerce_customer_address:country' ) {
	  $value = ' ';
  }

  list($field_name, $sub_field) = explode(':', $target, 2);

  // Handle non-multiple value fields.
  if (!is_array($value)) {
    $value = array($value);
  }

  $field = isset($entity->$field_name) ? $entity->$field_name : array();

  foreach ($value as $i => $v) {
    $field['und'][$i][$sub_field] = $v;
  }

  $entity->$field_name = $field;
}
pcambra’s picture

Addressfield feeds integration lives in addressfield, you probably need to patch it there.

pcambra’s picture

Project: Commerce Feeds » Address Field
Version: 7.x-1.3 » 7.x-1.x-dev
Component: User interface » Code
johnv’s picture

Title: Unable to save customer address fields » Unable to save customer address fields upon import with Commerce Feeds.

better title.
You are using Commerce Feeds ?
Perhaps this issue belongs in that project, then.

johnv’s picture

Status: Active » Closed (duplicate)
dianikol’s picture

Must be done by accident. Sorry :)