Processing the CSV file

Now that our plugin configuration works--and uploaded files are properly managed and marked as used--its time to implement the getData()method by which we process the CSV file of the importer entity. The result needs to be an array of product information as expected by the import() method we saw earlier. So we can have something like this:

/** * Loads the product data from the remote URL. * * @return array */ private function getData() { /** @var ImporterInterface $importer_config */ $importer_config = $this->configuration['config']; $config = $importer_config->getPluginConfiguration(); $fids = isset($config['file']) ? $config['file'] : []; if (!$fids) { return NULL; } $fid = reset($fids); /** @var \Drupal\file\FileInterface ...

Get Drupal 8 Module Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.