Advertisement
Guest User

Untitled

a guest
Apr 18th, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. function mymodule_importdata() {
  2. $csvs = array(
  3. 'http://www.example.com/1.csv',
  4. 'http://www.example.com/2.csv',
  5. 'http://www.example.com/3.csv',
  6. ....
  7. 'http://www.example.com/n.csv',
  8. );
  9. foreach ($csvs as $csv) {
  10. $feeds_source = feeds_source('my_feed_importer');
  11. $feeds_config = $feeds_source->getConfigFor($feeds_source->importer->fetcher);
  12. $feeds_config['source'] = $csv; //url of file | url of site
  13.  
  14.  
  15. $config = array(
  16. 'process_in_background' => TRUE,
  17. );
  18.  
  19.  
  20. $feeds_source->setConfigFor($feeds_source->importer->fetcher, $feeds_config);
  21. $feeds_source->importer->addConfig($config);
  22. $feeds_source->save();
  23.  
  24.  
  25. $feeds_source->startImport();
  26.  
  27.  
  28. while (FEEDS_BATCH_COMPLETE != $feeds_source->import());
  29. }
  30.  
  31.  
  32. return t('Import successfull');
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement