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
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | addressfield_fixed-default-values-in-feeds-imports-3044223-04.patch | 1.14 KB | m.stenta |
Comments
Comment #2
jannis commentedHere'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
Comment #3
jannis commentedComment #4
m.stentaI 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()usesisset()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 ofisset(). This fixes the issue.Comment #5
m.stentaComment #6
jannis commentedpatch #4 applies cleanly and fixes the issue. RTBC +1