I have a CSV file that I import into my site using Feeds Tamper.
The CSV file has columns like
- URL path
- Favorite vegetable
- Favorite fruit
- Favorite pasta
In Drupal, my content type has a JSON Field, and I want to import "Favorite vegetable", "Favorite fruit", and "Favorite pasta" into the JSON field.
Is there a way to map all three favorites columns in the CSV file to the Drupal JSON field and combine their values in a Tamper plugin? I can't find any way to pull in data from multiple sources (the three CSV columns) in a Tamper plugin.
Here's the structure of a Tamper plugin.
<?php
namespace Drupal\tamper\Plugin\Tamper;
use Drupal\tamper\Annotation\Tamper;
use Drupal\tamper\TamperableItemInterface;
use Drupal\tamper\TamperBase;
/**
* Plugin implementation for CSV import. Copied from the encode plugin.
*
* @Tamper(
* id = "json_import",
* label = @Translation("JSON Import"),
* description = @Translation("Custom import for JSON."),
* category = "Text",
* handle_multiples = TRUE
* )
*/
class JsonImport extends TamperBase {
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
$config = parent::defaultConfiguration();
return $config;
}
/**
* {@inheritdoc}
*/
public function tamper($data, TamperableItemInterface $item = NULL) {
return $data;
}
}