Hello,
I am trying to import 1500 taxonomy terms using a CSV file. Its four first lines follows:
GUID ITEM PGUID
100001 Filtre à particules
100002 Citroen 100001
100003 C5 100002
I have been unable to import any terms. I always get an error message "Missing bundle property on entity of type taxonomy_term.". What do I do wrong? Thank you.
$feeds_importer = new stdClass();
$feeds_importer->disabled = FALSE; /* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'menu';
$feeds_importer->config = array(
'name' => 'Menu',
'description' => '',
'fetcher' => array(
'plugin_key' => 'FeedsFileFetcher',
'config' => array(
'allowed_extensions' => 'txt csv tsv xml opml',
'direct' => FALSE,
'directory' => 'public://feeds',
'allowed_schemes' => array(
0 => 'public',
),
),
),
'parser' => array(
'plugin_key' => 'FeedsCSVParser',
'config' => array(
'delimiter' => 'TAB',
'no_headers' => 0,
),
),
'processor' => array(
'plugin_key' => 'FeedsTermProcessor',
'config' => array(
'vocabulary' => 0,
'mappings' => array(
0 => array(
'source' => 'GUID',
'target' => 'guid',
'unique' => 1,
),
1 => array(
'source' => 'ITEM',
'target' => 'name',
'unique' => FALSE,
),
2 => array(
'source' => 'PGUID',
'target' => 'parentguid',
'unique' => FALSE,
),
),
'update_existing' => '1',
'input_format' => 'plain_text',
'skip_hash_check' => 1,
'bundle' => 'menu',
),
),
'content_type' => '',
'update' => 0,
'import_period' => '-1',
'expire_period' => 3600,
'import_on_create' => 1,
'process_in_background' => 0,
);
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | feeds-2147341-21-term-missing-bundle.patch | 1.93 KB | milesw |
| #18 | feeds-2147341-18-term-missing-bundle.patch | 1.69 KB | milesw |
Comments
Comment #1
donSchoe commentedI have the same issue after upgrading fees to 7.x-2.0-alpha8.
I tried to debug this using feeds tamper module with execute php plugin.
And surpise: after just adding
dpm($field);it simply works!?!Therefore its impossible to debug but just passing this field to feeds tamper seems to work out. Just add some dummy comment:
But then again, no idea where this issue comes from.
Comment #2
twistor commented@MPeli, it looks like you need to set a vocabulary.
@donSchoe, could you provide an export of your importer before the upgrade?
Comment #3
donSchoe commentedI cannot reproduce it anymore. It's gone where it came from: unknown.
Comment #4
docans commentedI Also go the same error when i try to import my taxonomy terms into a vocabulary from a views data export in csv format. the error i got was :"Missing bundle property on entity of type taxonomy_term."
I am using drupal commerce kickstart
Comment #5
dobie_gillis commentedI get this error as well with a CSV created with Views Data Export, even when there's only one row in the CSV.
Comment #6
Offlein commentedThis may be an issue with old rows in the feeds_item table. I'm not sure. I think this was the case for me.
I believe I had imported some, then deleted them through a different interface -- not through the Feeds "Delete Items" tab. Then I tried to import things with the same GUID (maybe?!) and had this.
I just manually deleted all the rows for this Feeds importer and started over .. it looks like they came in right finally...
I'd consider it dangerous to manually delete those rows in your database, so be careful!
Comment #7
guypaddock commentedI'm seeing this as well with an import of commerce products that have a taxonomy reference field.
Comment #8
guypaddock commentedAll right, I know what causes this now. The field in question was a Taxonomy Term reference field that did not have a value for the "Field Settings" > "Vocabulary" setting. In addition, Feeds was configured to create new terms if they didn't exist.
Without a vocabulary, there is no bundle (the vocabulary ID is the bundle type for taxonomy terms), hence the error. This error can technically only happen if the vocabulary referenced by the reference field is deleted or renamed, or the field is created programmatically without the target vocabulary set properly (for example, by a bad Feature). Feeds should at least catch that it's trying to save an entity without a bundle
The attached patch addresses this issue by guarding the creation of the terms in case the bundle is missing.
Comment #9
megachrizCould use an automated test.
Comment #10
donquixote commentedProbably same issue here (with patch):
#2489006: Uninitialized array in taxonomy_feeds_set_target().
Or rather: Similar symptom.
I can re-post the patch here. But the other issue contains the explanation of the underlying problem that this particular patch is trying to fix.
Comment #11
twistor commentedTentatively marking this as a duplicate of #2489006: Uninitialized array in taxonomy_feeds_set_target().. The difference being that we bail earlier if invalid configuration is found.
If the problem still exists, feel free to re-open it.
Comment #12
ANDiTKO commentedThis issue still exists. It has to do with the "Term id (tid)". I removed this field from the mapping and it worked as expected. (tried with both dev and stable versions of feeds. Same result)
But it will be good if i could pass the "term ID" to my taxonomy terms imported from the feeds module.
Comment #13
ANDiTKO commentedComment #14
eabquina commentedI encountered the same thing and to be specific with my case:
1. Created a Feed with a Term Reference as a entry
2. Instead of choosing the right "Taxonomy Vocabulary", I left the term reference as "Forums" (which happend to be the first one on the list...)
3. Found out a bit later, changed the reference field from Forums to the right taxonomy term
Everything is fixed.
Comment #15
milesw commentedThe original issue here describes a problem with the Term Processor that still exists.
Steps to reproduce:
1. Create an importer that uses the Term Processor.
2. Configure the processor to "Replace existing terms".
3. Configure some mappings, at least a unique.
4. Import something.
5. Import same thing again.
Quick fix is to use "Update existing terms" instead of " "Replace existing terms"..
For "update", the processor loads the entire term object. For "replace", it loads the row from taxonomy_term_data, which does not include the vocabulary machine name (the missing bundle).
Here's a patch with a fix and another patch with a test.
Comment #16
milesw commentedUpdating status.
Comment #18
milesw commentedCombined patch to make the tests pass...
Comment #19
megachrizThanks for working on this, milesw! Could you add the test code to a new test method? You can call it
testReplaceTerms()for example.Note that there are more possible causes that can lead to this error message. For example: an other possible cause can be an "orphaned feeds item": a feeds item with a reference to a no longer existing entity. This cause is being handled in #1394320: Orphaned items in feeds_item table can cause an EntityMalformedException.
We can handle the "replace existing terms" cause here and handle other possible causes in other issues.
Comment #21
milesw commentedThanks for checking this @MegaChriz. Here's a new patch with a separate test method, as requested.
Comment #23
megachrizThanks, milesw. Patch is committed.
I've also checked where in the code the error is generated as
taxonomy_term_save()also setsvocabulary_machine_nameon the term if it is not set. The error appears to be generated in mappers/field.inc, in the functionfield_feeds_presave()whereentity_extract_ids()is called.field_feeds_presave()is only available since Feeds 7.x-2.0-beta1 and the original bug report is older than that release, but I can imagine thatentity_extract_ids()can be called by other modules in a hook before the save process, so I think the patch completely fixes the bug that was originally reported.Comment #24
milesw commentedAwesome, thanks. Yeah, now that I look at the export in the original description again, it's not the same issue. I think the original issue here was related to the vocabulary not being set. Either way, it's one more bug fixed. ;)
Comment #26
nofue commentedI'm terribly sorry, but this issue hit me today and after hours of trying all the hints I found a solution (in my case, of course -- ymmv):
I just went into the feeds_item table and deleted its content. After that, everything worked as advertised.
The whole issue in deeper detail:
I was importing a rather simple list of taxonomy items.
The taxonomy consists of an ID (which maps to GUID as unique), and a title, which maps to title and description.
Everything got checked, cross-checked and still nothing. I deleted that vocabulary(!), I deleted the importer, I deleted pretty much everything in question. Rebuilding the stuff, even using different names für field or taxonomy, always lead to the same odd error message (heck, it would be nice to see what bundle is missing …).
Finding all the outdated hints on this issue, scattered all across the web, and trying every single advice didn't yield anything. I finally sent my installation haywire by applying that dreaded patch. After reinstalling feeds module, and retrying for another couple of hours (ignoring that hash thing, updating vs. ignoring, vs. whatever is possible in the importing content), I simply emptied 'feeds_item' and voilá, everything's fine again.
After all of this I wouldn't consider this issue being fixed. There needs something to be implemented to allow average users to clean up that feeds_item table -- too bad I'm not a php coder but rather a shell scripter, I'd love to did into that code …
Comment #27
megachriz@nofue
See #1394320: Orphaned items in feeds_item table can cause an EntityMalformedException