0

The Excel file I'm trying to import is comprised of two part, the first three columns describe a node that might or might not exist currently, and the three last columns are my entity informations. To date I've created a Feeds plugin to provide a custom processor for my entity and I've explored Rules.

What I'd like is to import the three last column into a entity and before saving it, check if a node with the existing account number exists. If it doesn't, create one with the three first columns. After that, I'd store the nid into the entity as a foreign key (my entity has a n-to-1 relationship with the node).

I've tried to use Rules "Before saving an entity" event, but I can't access unmapped columns this way. I've tried adding mapping to non-existing properties of the entity thinking they would be set and simply forgotten once the entity goes out of scope, but I instead get an unknown property error at importation. I've even tried to override the setTargetElement function in my processor, but the error still occurs. It seems to me I've got little choice but to store the unwanted data in the table and duplicate it in the node afterward (exactly what I'm trying to avoid).

Does someone have either a way to create these non-persisted property, have a better way to create and store a node relationship in an entity (Entity reference maybe) or even another solution6

Thanks

0

I have done something similar with importing images. If the image exists in the files table I just add the fid, and if it does not yet exist I create it.

I created a custom module and implemented hook_feeds_processor_targets_alter, and hook_feeds_dimension_set_target

Aside from that I don't know of an answer that does not require a bit of coding.

0

Quite bad to answer my own question but here how I've did it. First I created a Feeds importer to import my Node dependencies from the file. Afterward, using a custom rule action, I trigger another feeds importer that pull the 4 others columns into an entity. Using the Feeds Tamper module and the EFQ plugin, I'm joining the two using the account number. I'll submit the Rules action to either Feeds or Feeds Rules module for common good.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.