0

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

You can use the Feeds Tamper plugin "Set value or default value".

  1. Install the modules Tamper and Feeds Tamper.
  2. Go to the mapping page.
  3. Select a target that you want to set a default value for.
  4. On the source selector that appears, select "New CSV source". Type in a source name that does not appear in your CSV file.
  5. Repeat step 2 and 3 for every field you want to set a default value for and save the mappings.
  6. Go to the 'Tamper' page.
  7. 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".
  8. 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? – Chris Howell Jun 18 '19 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"] – MegaChriz Jun 19 '19 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. – MegaChriz Jun 19 '19 at 9:23

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.