I've created a CSV feed via Views Export that exports out data for a content type. I'm then using Feeds to import that onto another Drupal site.
Everything except the images are working, when I run import it's stating
Failed importing 2 RSS Item items.
The content failed to validate with the following errors:
Image (field_image): Image: this field cannot hold more than 1 values.
Please check your mappings.
The field in question on Site A has a single limited value of 1, and checking the CSV export it's only showing one value, the absolute url of the image on Site A.
I've attempted to use Feeds Tamper and use all the plugins I can think of to fix this, but due to my freshness to Feeds and Feeds Tamper I'm not sure if this is a bug or misconfig on my part. Everything else is importing as expected onto Site B.
Comments
Comment #2
megachrizIt sounds like a misconfiguration, but it can also be that your source provides two (or more) values for the image field. It could be an empty value + an actual image url.
Can you share how your source looks like?
Comment #3
megachrizOh wait, I see something that could be an important detail in your description:
Are you importing from a RSS feed or from a CSV file? On the feed type, did you select the right parser?
Comment #4
Robhern135 commentedRe #3:
When I view the exported CSV its showing just the one value, the absolute url, without and white space or any other characters that I can find.
Also the RSS Item is the name of the content type, when I first started attempting this process I was working with an RSS feed but realised I needed more control over the data than RSS feed could provide. The content type name RSS Item is arbitrary.
Re #4:
I'm exporting a Data Export View from Site A as a CSV and using Feeds to import as CSV.
Here's my parser section of the feed config:
Comment #5
Robhern135 commentedRe #3:
When I view the exported CSV its showing just the one value, the absolute url, without and white space or any other characters that I can find.
Also the RSS Item is the name of the content type, when I first started attempting this process I was working with an RSS feed but realised I needed more control over the data than RSS feed could provide. The content type name RSS Item is arbitrary.
Re #4:
I'm exporting a Data Export View from Site A as a CSV and using Feeds to import as CSV.
Here's my parser section of the feed config:
Comment #6
Robhern135 commentedRE: #2
When I view the exported CSV file it's jsut showing the absolute path of the image in question, with no other characters or spaces to get a second items from.
RSS Item is just the name of the content type that I made to house the content, when I started I intended to use RSS but I realised I needed more control over the data and fields.
RE: #3
I'm exporting a CSV data export from Site A using Views Data Export and importing using Feeds to Site B.
I've selected CSV parser to match.
Comment #7
megachrizIn order to help you further, I will need to see an export of your configuration + a sample source file. It could be there's something strange in the CSV file that is causing this or that there's a misconfiguration.
Can you provide the following:
If you want to be sure that I can install your configuration, try to enable the created feature module on a clean install.
Comment #8
djdevinReproduced this on D8 and knew we saw something like this in D7 too #2920690: Field validation errors in Number field.
The issue is that Feeds is appending the value to the new entity instead of replacing it in setTarget()
The property has to have a default set like this:
That causes "Attended (attended): Attended: this field cannot hold more than 1 values."
Removing the default value worked:
It appears that on Entity creation, Feeds appended the value to the default.
Comment #9
djdevinFixes it specifically for single valued fields.
Comment #11
yassersammanThis issue also appears in boolean fields.
The patch #9 fixes the issue for me, but I can't confirm if this is a complete solution yet.
Comment #12
megachrizSo this issue occurs on at least base fields that set a default value? Interesting.
@djdevin
Do you want to write a kernel test for this bug?
Comment #13
djdevinYes, I'd like to get into it a bit more though. This is the first time I have looked at D8 feeds (bringing functionality over from D7).
Comment #14
megachrizI also ran into this error for a custom entity type.
EntityProcessorBase::clearTarget()currently checks if an entity implementsTranslatableInterface, whichContentEntityBasealready does, so that check almost has no value (because practically all supported content entity types extend that class). So this makes me think that this issue happens for non-translatable entities.In my case, the issue is fixed when I add the following check to the
clearTarget()method:Attached a patch that adds this + a kernel test.
I'm not sure if this fixes the issue as well for when a base field provides a default value. It would be interesting to have a test for that case as well.
Comment #15
mindaugasd commentedI had this error importing 'feeds_feed' entities:
Import was working initially, but then it stopped working one day.
This patch fixed the problem.
Comment #16
kristi wachter commentedJust another confirmation:
I, too, was getting
Title (title): Title: this field cannot hold more than 1 values.
when importing CSV from one site to another. The patch in #14 fixed it for me and my import worked correctly.
Thank you!
Comment #17
megachrizIn some of the multilingual tests
$entity->isTranslatable()returned FALSE because the entity bundle was not set as translatable. This can be set as translatable with the service "content_translation.manager".Let's see if that fixes the tests.
There are no functional changes in this patch, only changes in the tests.
Comment #18
glynster commented+1 RTBC this patch helped us progress forward with a useable feed import. This must have been something introduced recently as our imports have not changed.
Comment #19
megachrizRe #8
I tested the case of using a base field with a default value. I found out that this only caused an issue if the entity type was not translatable. For translatable entities, base fields with a default value did not cause any issue during my testing.
The fix I provided earlier also fixed the issue for the base field case.
In the patch I added a test for the base field case.
@glynster
Correct, this bug was introduced in Feeds 8.x-3.0-alpha7. In that release multilingual support was added.
Comment #22
megachrizI think we're good to go. I did note some other issues related to translations, but that seem to be out of scope for this issue: I noticed imports could fail when configuring a field as non-translatable (on content translation settings page), but do select a language for it on the mapping screen.
Committed #19.
Comment #24
mshdevx commentedHi @MegaChriz
I think this is not fixed or I experienced new very similar issue, see my debugging:
Because FileFieldItemList returns also extra properties, which doesn't exist in $values it appends existing values (the same goes for single image field).
Comment #25
kopfduenger commentedHi @MegaChriz,
unfortunately, this issue for single value fields is still not resolved, at least for date fields. My content type is translatable, even the date field (although this does not make sense for a date field in my opinion).
While importing the tag
<pubDate>...</pubDate>into a date field, the import fails due to:Comment #26
kopfduenger commentedHi @MegaChriz,
sorry, my fault: I could solve my issue above with:
- install module feed_ex
- changing the XPath statement for this field in feeds_tamper
and
- installing the patch in this comment: https://www.drupal.org/project/feeds/issues/3172709#comment-14999631
In order to make it work, I had to use these settings:
context: /rss/channel/item
XPath value: pubDate
both option fields checked for this 'custom source':
- raw value
- inner xml.