Hi all ...
I have a contenttype: "outlet".
This contenttype has a "field_address"
I imported a csv file with the feeds module. Everything fine.
I created a view (display: table) with node titles and the addressfield.
The view shows everything correct, so for every node it shows the title and the address.
I have a geofield. Geo data gets created on import based on the address field.

However, and here we go:
When I edit a node of type "outlet", the addressfield is empty.
When I save the node again, the address is removed and doesn't show at node display anymore.

So I have my view showing everything correct.
When I click the title and view the node, everything correct.
When I edit that node, the address field is empty.
I do not modify anything, save the node, address field is empty.
When I manually enter the address it shows.

Whats happening here? Anyone any ideas?

I have included my feeds import as a reference.

Thanks in advance for any help on this!

-------------

$feeds_importer = new stdClass();
$feeds_importer->disabled = FALSE; /* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'outlet';
$feeds_importer->config = array(
'name' => 'Outlet',
'description' => '',
'fetcher' => array(
'plugin_key' => 'FeedsFileFetcher',
'config' => array(
'allowed_extensions' => 'txt csv tsv xml opml',
'direct' => FALSE,
),
),
'parser' => array(
'plugin_key' => 'FeedsCSVParser',
'config' => array(
'delimiter' => ',',
'no_headers' => 0,
),
),
'processor' => array(
'plugin_key' => 'FeedsNodeProcessor',
'config' => array(
'content_type' => 'outlet',
'expire' => '-1',
'author' => '1',
'authorize' => 1,
'mappings' => array(
0 => array(
'source' => 'Name',
'target' => 'title',
'unique' => FALSE,
),
1 => array(
'source' => 'Zipcode',
'target' => 'field_adres:postal_code',
'unique' => FALSE,
),
2 => array(
'source' => 'City',
'target' => 'field_adres:locality',
'unique' => FALSE,
),
3 => array(
'source' => 'street',
'target' => 'field_adres:thoroughfare',
'unique' => FALSE,
),
),
'update_existing' => '0',
'input_format' => 'plain_text',
'skip_hash_check' => 0,
),
),
'content_type' => '',
'update' => 0,
'import_period' => '-1',
'expire_period' => 3600,
'import_on_create' => 1,
'process_in_background' => 0,
);

Comments

steven.wichers’s picture

We just started having this issue as well.

What modules do you have enabled?

steven.wichers’s picture

I don't know if you are having the same problem, but I found the issue to be with this logic in the addressfield module:



  if (!empty($form_state['addressfield'][$element_key])) {
    // Use the value from the form_state if available.
    $address = $form_state['addressfield'][$element_key];
  }
  elseif (!empty($items[$delta]['country'])) {
    // Else use the saved value for the field.
    $address = $items[$delta];
  }
  else {
    // Otherwise use the instance default.
    $address = (array) $instance['default_value'][0];
  }

Our imported addresses do not have a country set, so the third statement (the default value) was being used. After adding a country everything worked as expected.

johnv’s picture

Title: data shows on node display, not on node edit » data shows on node display, not on node edit, after import via Feeds

More precise title.

johnv’s picture

Status: Active » Closed (duplicate)

It seems your case is an example of #1094138: Create a watchdog error message when an address field value is saved without a country
I added comment #2 over there as an important hint.

merilainen’s picture

For me setting a default value with Feeds Tamper didn't help, had to do this instead:

<?php
/**
* Implements hook_node_presave().
*/
function hsl_dev_entity_presave($entity, $type) {
  if ($type == 'node' && $entity->type == 'ticket_sales_point') {
    $ticket_sale_point = entity_metadata_wrapper('node', $entity);
    $ticket_sale_point->field_address->country->set('FI');
  }
}
?>
steveixa’s picture

Adding the two letter country code for each record in the imported file worked for me too.
thanks

jprstoney’s picture

I'm getting the same issue when using Salesforce Suite to import an address. Apart form the above, were there any other solutions found?

I look forward to any thoughts.

Kind regards
James