I have created Term reference fields that I would like to change to Entity Reference fields. Can this module be used for that purpose?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bunthorne’s picture

No idea?

BTMash’s picture

@bunthorne, sorry for not responding sooner. I had not recieved notifications related to the issue queue for this project. I can take a look into this soon - I had forgotten that there was also a term reference field. Although...is there a reason not to use core taxonomy? Those are fieldable in D7 core.

BTMash’s picture

Assigned: Unassigned » BTMash

Setting as assigned.

bunthorne’s picture

It isn't a question of changing the referenced field type; it will still be a Term field. But the Entity Reference module has better support for widgets for selecting the referenced terms, such as the entity reference view. So I would prefer to use the Entity Reference field instead of Term reference field, but I cannot change field type once it is created.

The migration functionality looks like it is the same concept--moving from an older reference field type to the new-and-improved type! I hoped that I could expand your scope a bit with this request.

Thank you for getting back to me!

mossy2100’s picture

Subscribe :)
I need this feature. I've converted all my node refs to entity refs, but not term refs yet, so I have two similar modules running side by side.

Sinan Erdem’s picture

Following this issue. I need to convert term references to entity references, also for some performance reasons. Entity reference allows two way referencing with some extra modules' help. This type of reference is better in performance for listing the content having a specific term.

BTMash’s picture

Just so everyone knows, this is on my radar. With that said, the current iteration of the module is somewhat tied into references. Between this and #1908518: 1 step insert could cause memory issue, I am planning to tackle the latter as (a) it is a reasonably major bug and (b) will allow me a chance to rewrite the module so the pieces are broken apart and I can then go down different paths for field creation particularly for terms (this will be in a 7.x-2.x branch). So this is postponed until that particular portion in done. If someone else wants to tackle this in the meanwhile and is able to come up with something that works, then I'll gladly commit it to the 1.x branch.

BTMash’s picture

Now that #1908518: 1 step insert could cause memory issue is essentially solved, I can finally get around to this. But are there any takers to help out on this? This is a fairly complex feature request to code out.

johnv’s picture

Title: Migrate D7 Term reference field to Entity Reference? » Support Migration of Term reference field to Entity Reference field
Status: Active » Needs review
FileSize
10.25 KB

Please find attaeched patch, which does the trick.

It lacks 1 feature: afterwards, you must manually select the 'Taxonomy Term taxonomy bundle.'

BTMash’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
FileSize
5.2 KB

@johnv, I've revised your patch to be compatible with the 2.x-dev branch (one of the hunks already made its way in so we needed to reroll anyways :)). I removed the .php portion of the diff and made a few other changes (switch case blocks are replaced with 'if') and I I was able to get the taxonomy bundle in as well. Seems to be working well though it would be nice if one other person can also review.

BTMash’s picture

Status: Needs review » Fixed

I've now committed the patch to 2.x. Thanks for all the hard work, @johnv.

Please reopen the issue if something pops up.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

davidneedham’s picture

Issue summary: View changes

Wow, this works incredibly easily. Thanks for all of your work on this!

For people just using this for Term reference > Entity reference, does the references module still need to be required? I wasn't using it and only enabled it to use this module.

bunthorne’s picture

@davidneedham no, I don't think you will need References anymore. I also only used it long enough to convert my Term Reference fields.