Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I am trying to import data and my regular CCK fields (and regular taxonomy fields) import ok, but my content_taxonomy cck taxonomy fields do not get imported. I have them set to allow new values to be added to taxonomy. I'm assuming this is either a bug or a case that is not covered in the code?
Has anyone been successful doing this?
Thanks :)
Comments
Comment #1
pimousse98 CreditAttribution: pimousse98 commentedAfter a look at the code there would be a need (probably ) to add a case to content.inc that covers content taxonomy. Right now I believe the fields just get ignored.
Since in the database only the tid gets stored in a column named field_ would there be a way to use existing functions in taxonomy.inc such as _migrate_taxonomy_get_term (to get the tid for existing terms) and some of the code in taxonomy_migrate_prepare_node (for handling terms that are not in the taxonomy term list yet?). The thing I haven't found out how to do is to get the appropriate vocabulary since it's handled in a different way from taxonomy.
If anyone could give me a hand with the code, I would be very grateful.
Comment #2
pimousse98 CreditAttribution: pimousse98 commentedI made a partial fix... This will always add terms to taxonomy if they don't exist (regardless of settings), and does not add rows to the term_node table (however, it seems that if the option "also save to taxonomy table" is not checked then terms don't get imported).
in modules/contrib/content.inc
function content_migrate_prepare_node
in switch statement add the following:
Hope this might help someone.
Comment #3
mikeryanNote there was already an issue for content_taxonomy support: #600012: How to migrate multiple Taxonomy terms into CCK. I'm closing that as a duplicate, since this contains more info.
The preferable way to add support for another module is in its own file (i.e., modules/contrib/content_taxonomy.inc).
Comment #4
BenK CreditAttribution: BenK commented+1 for support for content_taxonomy module!
Comment #5
rsvelko CreditAttribution: rsvelko commented@2: Thanks a lot that worked awesome.
Please patch the module soon.
Comment #6
mikeryanComment #7
mikeryanComment #8
BenK CreditAttribution: BenK commentedHey everyone,
Now that this has been assigned to Migrate Extras, should we make a new migrate extras sub-module for content taxonomy?
--Ben
Comment #9
gunzip CreditAttribution: gunzip commentedsubscribe
Comment #10
frankcarey CreditAttribution: frankcarey commentedwell, not submodule, but integration, yes. We need a content_taxonomy.inc and a patch adding it to the integrations listed in migrate_extras_migrate_api().
Comment #11
bsnodgrass CreditAttribution: bsnodgrass commentedgreat! looking for this too.
Comment #12
gg4 CreditAttribution: gg4 commented+1 for support for content_taxonomy module
Comment #13
3dloco CreditAttribution: 3dloco commented+1 too ;D
Comment #14
3dloco CreditAttribution: 3dloco commentedThanks Pimousse98 for sharing the code on #2 to migrate CCK taxonomy. I modified ../migrate_extras/content.migrate.inc and it worked for me too.
Comment #15
Summit CreditAttribution: Summit commentedHi KH,
Could you share your code for content.migrate.inc please?
Thanks a lot in advance!
greetings, Martijn
Comment #16
3dloco CreditAttribution: 3dloco commentedHi Martijn,
Hope this is not too late for you...I was out on vacation and I am catching up :)
See attached file specifically where I've put in the code from #2 between the comments //616910 starts //616910 ends.
Regards,
KH
Comment #17
milos.kroulik CreditAttribution: milos.kroulik commented+1
Comment #18
kruser CreditAttribution: kruser commentedsubscribe
Comment #19
darora CreditAttribution: darora commentedHas any one tried it with Migrate V2 module? The workaround above is for the older version of MigrateExtra module that handled that CCK fields.
Comment #20
Summit CreditAttribution: Summit commentedHi,
On project page there is stated: Notably, that means while CCK and filefield support were in migrate_extras for V1, they are in Migrate itself for Migrate V2.
What is the status on this issue in this perspective please?
greetings, Martijn
Comment #21
mikeryanSince Drupal 7 natively handles term references, it makes sense that supporting Drupal 6 term references as provided by content_taxonomy should go into the Migrate module itself. Moving this issue over there.
Comment #22
darora CreditAttribution: darora commentedHas anyone got it working with Migrate 2.0 version? Please share tips or code.
Comment #23
darora CreditAttribution: darora commentedFinally...got it working with Migrate 2.0 version. It ended up a simple fix but took long time to figure out.
Need to register the "content_taxonomy" as field type inside the /plugins/destination/fields.inc file as below...and that's it.
Hope it helps...
Comment #24
mikeryanI misunderstood what Content Taxonomy does - it's not really analagous to D7 core functionality, so back over to Migrate Extras.
The suggestion in #23 only works when passing in tids, not names. Here's the equivalent implementation for migrate_extras, but it would be nice to support both tids and names as the D7 term reference handler does:
Comment #25
mikeryanComment #26
Anonymous (not verified) CreditAttribution: Anonymous commentedI patched my Migrate module as suggested in comment #23.
I experience this behaviour: terms are correctly migrated between Drupal installations, but the term with value "1" is added to each field of my content type, even if the term with tid 1 does not belong to the vocabulary associated with that field.
How can I submit here relevant debug information about this?
Thanks
Leo
Comment #27
trunks CreditAttribution: trunks commentedMy two cents from migrating content_taxonomy fields from tids or term_names.
Instructions for developers:
The example field mapping code below shows how to import terms in content taxonomy field.
Note that these code snippet must go into your Migration subclass's constructor - see the migrate_example module for an example of how and where to use field mappings.
Comment #28
trunks CreditAttribution: trunks commentedI'm sorry. Forgot changing the status.
Comment #29
ermannob CreditAttribution: ermannob commentedHi trunks,
thank you for your patch. I found it very useful.
I'd like to point out a requirement that I found in your approach: terms must exist in vocabularies before importing content_taxonomy fields. I'm writing this just to help others who's willing to test your patch.
I'd also fix a line in the code you wrote in the issue, I will post it here as a whole. (MigrateLinkFieldHandler should be MigrateContentTaxonomyFieldHandler)
Greetings,
-ermannob
Comment #30
trunks CreditAttribution: trunks commentedHi ermanobb,
You're right. Here you are a new bugfixed revision for this patch.
By the way, it's a requisite migrating terms and vocabularies (implementing MigrateDestinationTerm or your own class) in your migration module before migrating nodes.
Comment #31
ermannob CreditAttribution: ermannob commentedHi trunks,
I made some improvements to your patch. I found some problem when having terms with same name in different vocabularies. I'm working on a large project where some terms names are identical but belong to different vocabularies.
I made some modifications that let developers restrict searching for terms in a particular vocabulary instead of searching through the entire term_data table.
For example:
$arguments = MigrateContentTaxonomyFieldHandler::arguments('name', 3);
'3' is the vid of the vocabulary to search into. It's an optional parameter.
[sorry, i couldn't produce a patch like yours, so I will post a patch for your patch and the entire file]
Greetings,
-ermannob
Comment #32
ermannob CreditAttribution: ermannob commentedI'm trying again with a (supposed) proper patch. :)
Comment #33
mikeryanPlease review the Drupal coding standards for indentation, structure, etc.
I haven't used Content Taxonomy myself, so I will be dependent on someone (other than the patch author) who does to test this for functionality and set it to RTBC.
Thanks.
Comment #34
ermannob CreditAttribution: ermannob commentedThank you for pointing me to the right direction, mikeryan.
Not sure if there's more to do on my patch... any hints are welcome.
I'm trying again. :)
Comment #35
mikeryanComment #36
mikeryanCommitted, thanks.
Comment #38
myselfhimself CreditAttribution: myselfhimself commentedHello,
here is a patch (done with cvs diff...) of migrate_extras/content_taxonomy.inc to allow for merging source terms with destination terms for multi-valued taxonomy fields.
Maybe this won't be useful for general use cases, but it will help others finding the same need that I had.
Here's an example how to use the patch, within a Migration class's __construct():
: )
Comment #39
Summit CreditAttribution: Summit commentedHi,
Any news on this please? Is there now a correct working migration for content_taxonomy migration from D6 to D7 to correctly migrate terms and term-fields references?
Greetings, Martijn
Comment #40
rootwork#36 says it was committed way back in March 2012, but it doesn't appear to be in the most recent version (from November 2012). What's up? Was it rolled back?
Comment #41
mikeker CreditAttribution: mikeker commentedPerhaps a bit late for @Summit and @rootwook, but the commit in #36 is to the 6.x-2.x branch.
I'm pretty sure it doesn't belong there, but should be in the 7.x branch instead? (Unless entities and DB-TNG were backported while I wasn't looking? :)