Damz already coded the migrate handler for entityreference. It really should be implemented in the module. (tested and approved locally, it works)
Patch by Damien attached for reference.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | handle_default_values-1261086-16.patch | 1.05 KB | mikeryan |
| #8 | entityreference_1261086.patch | 1.94 KB | drewish |
| #7 | entityreference_1261086.patch | 1.89 KB | drewish |
| #3 | 1261086.3.patch | 3.08 KB | haza |
| #1 | entityreference_migrate.patch | 1.1 KB | haza |
Comments
Comment #1
hazaComment #2
damien tournoud commentedThanks for reminding me of this. Committed.
Comment #3
hazaIt seems that, even if migrate implement the hook_hook_info(), it doesn't trigger the class (during an import) unless I add the file in the .info of the module.
Attached here an other patch that implements the migrate plugin in an other way.
What do you think about that ?
Comment #4
damien tournoud commentedI simply added the missing reference to the file in the .info. Please reopen if this is not fixed.
Comment #6
drewish commentedShouldn't we be allowing the type to be passed in as an argument? I'm getting the following error trying to use this:
but the problem might be in the code we're using to make webform_submissions fieldable.
Comment #7
drewish commentedHere's what I had to use to get this going… did some cleanup along the way.
Comment #8
drewish commentedfixed one other issue with empty values.
Comment #9
mikeryanWell, I was all set to submit my own patch adding a target_type argument, you beat me to it! Your patch works for me...
Comment #10
damien tournoud commentedThere is only one type per field, so this argument should not be required at all. Can anyone explain the rationale here?
Comment #11
mikeryanIf the target_type is not specified, you get the error in comment #6. But, if the target_type is common to all instances of a given field, then we should be able to just pull it from the field info, right?
Comment #12
damien tournoud commented'target_type'is added byentityreference_field_presave(). Why doesn't that work in the context of Migrate?Comment #13
mikeryanHmm, a good question, migrate calls node_save() so the presave hooks should be getting called... Guess some more debugging is in order.
Comment #14
mikeryanOK, my problem is that the field is defined via features, with a default value of:
Features does not save a target_type. Because default values aren't fetched until after hook_field_presave(), it doesn't get fixed up. I'm not sure what the workflow is when creating features - whether there's something entityreference can declare differently to get it picked up, for example - but a quick and easy fix is to just rename entityreference_field_presave() to entityreference_field_insert().
That solves my problem, anyway, I can't speak for drewish...
Comment #15
drewish commentedI'm also using fields exported as features. I didn't have time to circle back and sort this out, I just left my patch applied.
Comment #16
mikeryanHere's a patch to replace the presave hook with insert and update hooks, to make sure target_type gets set in all scenarios.
Comment #17
amitaibu@mikeryan, I think it's related -- #1319040: Remove "target_type" column from db, I think we should remove the target_type completely, as in the end ER references only a single target_type.
Comment #18
mikeryanSo much the better, but there's no patch there yet. This will tide us over unless/until the target_type is removed.
Comment #19
amitaibu> but there's no patch there yet.
Now there is ;)
Comment #21
damien tournoud commentedTarget type is now gone for good.