Create feed importer with custom module
Drupal family members would be well aware about the power of Feeds module. More than many times, thereof has served us in creating new contents with less work and time. Recently I looked the feeds module from a unseen angle, "How to create feeds importer from my custom module?". To make my requirement clear please visit Quiz Questions Import module's page and if possible use this to get a clear picture about what this blog can do for you.
The Quiz Questions Import module on enabling creates a list of feeds importer, and these importers can be used to import content in CSV format. I don't want to get too deep into the concept of creating such a module, but will limit to the exact API needed to make this work.
- Create a new custom feed importer in Structure -> Feeds importer
- Select the Fetcher, Parser and Preprocessor as per your requirement
- Once done, export this feeds configuration (Can be found in the export tab)
- Paste this code in your custom module
Many who have gone though the above steps would have failed to attain success, In simple terms on enabling this custom module you would not find any importer being created. To accomplish all we need is hook_ctools_plugin_api().
The above piece of code has been taken from Quiz Question Import module, replace qq_import with your module's name. Apart from that no other real change is needed. Now disable and if needed uninstall your custom module and enable it again. Voila feed importer in /import page.