Active
Project:
Feeds Tamper
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
4 Dec 2011 at 01:03 UTC
Updated:
6 Jul 2016 at 20:46 UTC
Jump to comment: Most recent
I am pulling 2 cvs files from 'supplierA' and 'supplierB'. And I have setup 2 feeds imports for them.
On import-A, I want to set a static default value for a 'supplier' field, so that entities created by import-A will have the supplier field set to 'supplierA'. And the same for import-B and supplierB.
But the original cvs files do not have the 'supplier' field. How do I ADD a tamper plugin/rule for a field that does not exist in the source cvs file?
I tried to add a mapping rule source: {empty string} target: 'supplier'. But Tamper module uses the source name as the id for the import plugin/rule so obviously that didn't work.
Any idea?
Comments
Comment #1
jzornig commentedI also want to do this.
Comment #2
jzornig commentedI can use an existing field from the source that I was not needing and overwrite it's value with the default I want. But I can't make up a field name that doesn't appear in the source.
Comment #3
leex commentedI would also like to do this. I tried using the 'set default value' plugin but none of the plugins execute if the source field doesn't exist.
Comment #4
leex commentedI can see there is a 'blank source' option when you are importing an RSS feed, but not a CSV. This is all we would need to solve the problem:
http://drupal.org/node/1406210
Just look at the description here:
Blank source 1 A source provided by Feeds Tamper with no value of it's own.
Exactly what I want!
Comment #5
jzornig commentedleex, thanks for that tip. I was actually already using feeds tamper but had not seen the blank source feature.
Comment #6
leex commentedI guess you're not importing a CSV file then. Lucky you can use the feature.
Comment #7
dalearyous commentedi would also like to do this with a csv file!
Comment #8
jzornig commentedyes, I was importing from an ldap query.
Comment #9
mindaugasd commentedI am also looking for some solution here.
Comment #10
Anonymous (not verified) commentedI'm using for this "Find replace REGEX", with "REGEX to find" -> "/^\s*$/" and the replacement pattern you need.
Comment #11
mortona2k commentedI'm going to tamper an existing field to make it work, but I think this feature should exist since the workaround is not intuitive.
EDIT:
Hmmm, can't seem to get this to work. I just need the value "US", so I put that in the replacement pattern (with no quotes), but that doesn't work. Can you please explain a little further?
Comment #12
jonmcl commented@mortona2k (any anyone else):
I think that because the column doesn't actually exist, Tamper never gets a chance to run is plugins. I tried both "Rewrite" and "Default value" plugins and neither was able to populate the field.
I ended up using Feeds'
hook_feeds_presavefunction:(obviously this code is specific to the site I'm working on)
Comment #13
mortona2k commentedJonMcL, I ended up with that as well. Would be a great feature, so we could do everything within tamper.
Comment #14
agileadam#12 worked well for me also. Thanks JonMcL!
Comment #15
fureigh commentedAnother approach is to set up your own dummy field in the import mapping, if you have an unneeded source field to spare. You can do something like this:
0 -> Title (example)
1 -> Name (example)
17 -> Field For Which You Want To Set a Default Value
Then use the Feeds Tamper UI to add the 'Rewrite' plugin to the second '0', and specify the value you want.
However: if you try to use an existing field (like 0 or 1) again, Feeds Tamper will only let you rewrite all instances of the field at once.
Comment #16
blanca.esqueda commentedI had a similar situation where if a value was empty then another field value needed to be used.
I created a path for the rewrite plugin as it has the flexibility not only to use a replacement patterns but as well a custom strings, or a mix of both.
http://www.drupal.org/node/2632056
Comment #17
nwom commentedChanged the title to better match the issue. Setting a default value from a blank source is not possible, and instead as a work-around a dummy source must be used (and then overwritten). I would love the ability to no longer need to depend on a dummy source.
Thanks in advanced.
Comment #18
nwom commented#16 is not a workaround for this issue sadly, but instead fixes a different problem.
Comment #19
blanca.esqueda commented#15 works!!!
Map a dummy field, --- the content assigned initially doesn't matter, it can contain the value of any other field ---
And then use the rewrite tamper plugin to replace with the needed value.
But as @fureigh commented make sure that it is a separate source for this to work as expected.
I think that the ability to no longer need to depend on a dummy source for this cases has to be set up on the feeds module and not the tamper module. Feeds module is the one that manage the fields mapping.