Recently updated to addressfield 7.x-1.3.

Existing feeds importer sets first name, last name, locality, country and organisation name

After updating to addressfield 7.x-1.3 - the first / last name fields are no longer importing.

Tracked it down to a line in addressfield_set_target() function in addressfield.feeds.inc where it sets the addressfield values from the 'default fields' -- all of which (besides country) will always be 'empty'

My thinking is a feeds importer should always respect what the feed has and only set default values for sub fields if the feed has an empty value for that field -- or change the addressfield_default_values() function to only include the 'default country' item.

I'm not sure what other trouble changing that function will cause, so I think I'm going to go with just updating the addressfield_set_target() function

Comments

jannis created an issue. See original summary.

jannis’s picture

Here's a patch for 7.x-1.3 that will make it so that feeds importing of a name & address field will only use default values for fields that are referenced in the feed and if those values are empty

jannis’s picture

Status: Active » Needs review
m.stenta’s picture

Title: Default Values Breaks Feeds Imports » Default Addressfield values break Feeds imports
Version: 7.x-1.3 » 7.x-1.x-dev
StatusFileSize
new1.14 KB

I ran into the same issue and also traced it to the change made in #3005418: Feeds integration: use default values from field settings on import.

I didn't find this issue at first, so dug in and discovered WHY the change was causing issues. It is because the logic in addressfield_field_presave() uses isset() instead of !empty() to check the first_name, last_name, and name_line address pieces. And with default values being added, all three of them are always set.

Attached is a patch that simply changes those conditions to use empty() instead of isset(). This fixes the issue.

m.stenta’s picture

jannis’s picture

Status: Needs review » Reviewed & tested by the community

patch #4 applies cleanly and fixes the issue. RTBC +1