O'Reilly logo

Drupal 8 Module Development by Daniel Sipos

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required