I have a content type that contains a couple of required fields that do not have a mapping counterpart in the csv feed. When I import the csv feed, the process fails because of the required fields. What plugin can I use in a custom module to 'finish' the import by providing the values for the other fields? Is this even possible?
1 Answer
You can use the Feeds Tamper plugin "Set value or default value".
- Install the modules Tamper and Feeds Tamper.
- Go to the mapping page.
- Select a target that you want to set a default value for.
- On the source selector that appears, select "New CSV source". Type in a source name that does not appear in your CSV file.
- Repeat step 2 and 3 for every field you want to set a default value for and save the mappings.
- Go to the 'Tamper' page.
- For each target you want to set a default value for, click on "Add plugin". From the selector that appears, select "Set value or default value".
- A field called "Value" appears. Fill in the default value and click "Submit".
-
Thank you very much! I have done this and applied this to two fields. But I cannot figure out how to handle the date field: I have a field that is date added and that is not in the csv. How do I add the current date via Tamper? Or do I need to do this in a custom module? Jun 18, 2019 at 16:18
-
One way of doing this is first using the plugin "Set value or default value" and set the value to "now". Then, for the same target, add the Tamper "String to Unix timestamp". The second tamper converts "now" to a timestamp, which targets for date fields understand. If you import more than one time, then this value will represent the current time, each time. So on each import the value will be different. [Edit: value should be "now" instead of "today"] Jun 19, 2019 at 9:23
-
If you import more than one time and don't want the time to change on each import, you can also map "Feed: created" to the date target field. Then the value stays the same on each import. Jun 19, 2019 at 9:23
-