As I couldn't understand how to use this, I'm writing up a walkthrough of how I'd *hoped* this would work... so maybe we can identify where the weak points are.
If I misunderstand the purpose of this module, please clarify, but the description on the project page matched what I was looking for pretty well.
A SIMPLIFIED use-case follows
(actual one is a non-RSS datasource of events where I want to map 'venue' identified by string to a local node)
- We want to consume a feed, eg RSS from http://www.stuff.co.nz/rss/
- We want the 'author' from the feed item to refer to a local node that describes the author.
- This is an 'about' page for a number of known authors, Not using user accounts or actual authorship, and not auto-created.
- The desired result is just that the imported story items link to the author bio using entityreference.
I'd expect that a feeds+entityreference mapper helper would be able to take the given string
<author>Hamish Rutherford</author>
and convert that to a link to our content.
The sample rss link above has genuinely messy real-world data in that field ['Hamish Rutherford', NULL, 'MICHAEL FIELD', 'Kate Chapman and Vernon Small'], so it's a good test.
What I try:
From a new site, using
# Feeds, Feed UI and requirements
# Entity Reference and requirements
# Feeds entity reference
also, just because I was getting desperate...
# Feeds Node Helper
# Feeds Tamper
# Feeds Tamper PHP
- I set up a placeholder content type, called 'person', just so I can link to it. I add some dummies to it, based on the current stories.
- I modify the normal 'Article' content type and add an entityreferenceto represent the attributed_author person. Make it an autocomplete field, single, although I don't plan to be entering data manually.
- I set up a Feeds importer,
* Unattached
* Unscheduled
* HTTP Fetcher
* Common Syndication defaults
* Node Processor
* Content type : Article - Add normal mappings
* Title:Title
* Description:Body
* Item URL:GUID:unique - Try to add my custom mapping:
* Author name:Attributed AuthorI'D HOPE THAT WOULD WORK.
- visit /import and enter the rss URL...
- 20 item imported. - inspected the stories that should have had valid authors linked in, and they hadn't.
.. Now to find out what's not working and why...
Comments
Comment #1
dman commentedAs I dig into the code, I find very little explanation of what is intended to happen in the source itself. It doesn't seem to be doing any actual lookups for targets, and seems to assume that I'm using 'feed nodes'.
I'm unclear about what the code is doing as there are no documentation hints to be found just by reading it.
... though I do find that entityreference module itself advertises fsome feeds support in entityreference/entityreference.feeds.inc.
It's possible that I should be directing my attention there to begin with...
Comment #2
dman commentedStill doing notes-to-self...
It appears that the entityreference.module version of feeds support will only allow entityreferences to be established between OTHER items that were ALSO imported via feeds, and have a GUID in the feeds_item table.
So, that doesn't fit my requirements. THough it does sound a lot more similar to what this module seems to be doing also.
It also seems that the feeds_entityreference.module version uses a mapping target labelled "Value of field: @field", not just fieldname. That was extremely unclear, and probably is one step towards finding why this module didn't seem to do anything at all when enabled. How were we to know this?
Comment #3
dman commentedI have found by adding a hunk pf php code via feeds_tamper_php I was able to coerce the source value (a title) into a target_id (nid) and then, if using feeds_entityreference to save the data for me at feeds_entityreference_set_entityreference_target, it's finally working.
I'll tidy up my php snippet and see if I can roll it into something re-usable.
Comment #4
dman commentedHere it is.
I couldn't find a way to leverage feeds_entityreference into doing what I wanted, so here's a stand-alone alternative.
I abstracted the actual task, added some smarts and produced
feeds_tamper_string2id today.
Huge description over there.
* get a label from a feeds data source
* tamper it (eg explode or convert case)
* tamper it to convert the string(s) into entity IDs by making lookups on our own data (existing node titles, views field values + mucho magic)
* store entity IDs as entityreference (using your method from here)
= auto-linked imported data.
Just FYI.
Comment #5
lotyrin commentedWow. Thanks dman for the documentation here. I found myself headed down this same rabbit hole and you saved me having to retrace your steps in their entirety.
I'll take a look at feeds_tamper_string2id.
Comment #6
marcus7777 commentedyes Thanks Dman me too
Comment #7
paul_ylz commenteddman, just used feeds_tamper_string2id to import 50 nodes with entity references to other nodes. The dropdown target menu items are spot on.
Thank you very much!
Comment #8
colanIt looks like Feeds + Entity Reference now does this (3 years later). Currently available options for mapping to an Entity Reference field are:
What I was hoping this module would do is create the referenced entity if it didn't exist yet.
Comment #9
dman commentedYes, I think you are right, and Feeds will now do those matches, which are the common cases.
This module now is only useful if you have the rare need to match by another field, (eg lookup product by SKU, lookup user by phone email)
or need views to adjust your search criteria (restrict to one entity type, order by date, if there are potential duplicates)
If you want autocreate (I did also, and that's why this helper module was created)
Use
entityreference_autocreate.
Comment #10
colanGood to know; thanks. A working link is Entityreference Autocreate.
Comment #11
imclean commentedEntityreference Feeds seems to be a more featured solution and allows mapping to fields of the referenced entities.
Although I'm having trouble getting it to work with profile2.