Answers.Body: <p>It's worth mentioning now that for more recent versions of FeedMe, the console command natively supports an all flag.</p>
  <p><a href="https://docs.craftcms.com/feed-me/v4/feature-tour/trigger-import-via-cron.html#console-command" rel="nofollow noreferrer">https://docs.craftcms.com/feed-me/v4/feature-tour/trigger-import-via-cron.html#console-command</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-03T20:32:48.537Z
Answers.LastActivityDate: 2022-05-03T20:32:48.537Z
Answers.UserDisplayName: James White
Answers.Body: <p>You should be able to use something similar to the following:</p>
  
  <pre><code>use Craft;
  use verbb\feedme\FeedMe;
  use verbb\feedme\queue\jobs\FeedImport;
  
  $feeds = FeedMe::$plugin-&gt;feeds-&gt;getFeeds();
  
  foreach ($feeds as $feed) {
      $limit = null;
      $offset = null;
      $processedElementIds = [];
  
      Craft::$app-&gt;getQueue()-&gt;delay(0)-&gt;push(new FeedImport([
          'feed' =&gt; $feed,
          'limit' =&gt; $limit,
          'offset' =&gt; $offset,
          'processedElementIds' =&gt; $processedElementIds,
      ]));
  }
  
  </code></pre>
  
  <p>The above will add all your feeds to Craft's queue system and start them.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-09-28T10:03:29.187Z
Answers.Text: Small update for newer versions of the Feedme plugin:
  `$feeds = \craft\feedme\Plugin::$plugin->getFeeds()->getFeeds();`
Answers.UserDisplayName: Mato
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-21T11:33:07.833Z
Answers.Text: can you pass a url to the feed using this method? I'm currently using a pretty hacky way to trigger a feed programatically -> https://craftcms.stackexchange.com/questions/32933/trigger-feedme-import-from-plugin/32955#32955
Answers.UserDisplayName: dmatthams
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-28T04:31:43.343Z
Answers.LastActivityDate: 2019-02-28T04:31:43.343Z
Answers.UserDisplayName: crawf
Body: <p>I currently use <code>Feed-Me</code> to pull data from an API-Endpoint. This API-Endpoint does change from time to time, providing new elements with each change.</p>
  
  <p>I don't want to manually trigger the Feed-Me-Reimport each time I notice a change.
  I do know that Feed-Me provides actions URLs for each <code>feed-entry</code> but as the amount of different import-feeds will grow rapidly soon, I don't think it's feasable to manually create those feeds, and after creation also manually put the URL into a custom cronjob.</p>
  
  <p>So in the end what I'd like to have is simply a script that is triggered by a single cronjob, then gets all Feed-Me feeds and for each feed run the reimport.</p>
  
  <p>Via <a href="https://pluginfactory.io/" rel="nofollow noreferrer">PluginFactory</a> I already generated a plugin that provides me an endpoint(/controller) to be called by <code>cron</code> </p>
  
  <pre><code>public function actionAutoImport()
      {
          $result = 'Autoimport engaged';
  
          return $result;
      }
  </code></pre>
  
  <p>But now I am wondering: How do I get information from the Feed-Me plugin i.e. get all existing feeds and trigger a run on each?</p>
  
Tags: <craft3><plugin-feedme>
Title: Craft 3 Feed-Me Auto run all feed
ThreadText: # Craft 3 Feed-Me Auto run all feed
  
  (Asked by: username_0 on 2019-02-21)
  
  I currently use `Feed-Me` to pull data from an API-Endpoint. This API-Endpoint does change from time to time, providing new elements with each change.
  
  I don't want to manually trigger the Feed-Me-Reimport each time I notice a change.
  I do know that Feed-Me provides actions URLs for each `feed-entry` but as the amount of different import-feeds will grow rapidly soon, I don't think it's feasable to manually create those feeds, and after creation also manually put the URL into a custom cronjob.
  
  So in the end what I'd like to have is simply a script that is triggered by a single cronjob, then gets all Feed-Me feeds and for each feed run the reimport.
  
  Via [PluginFactory](https://pluginfactory.io/) I already generated a plugin that provides me an endpoint(/controller) to be called by `cron`
  
  ```
  public function actionAutoImport()
      {
          $result = 'Autoimport engaged';
  
          return $result;
      }
  
  ```
  
  But now I am wondering: How do I get information from the Feed-Me plugin i.e. get all existing feeds and trigger a run on each?
  
  **Tags:** craft3, plugin-feedme
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2019-02-28. Score: 4 | Accepted answer
  
  You should be able to use something similar to the following:
  
  ```
  use Craft;
  use verbb\feedme\FeedMe;
  use verbb\feedme\queue\jobs\FeedImport;
  
  $feeds = FeedMe::$plugin->feeds->getFeeds();
  
  foreach ($feeds as $feed) {
      $limit = null;
      $offset = null;
      $processedElementIds = [];
  
      Craft::$app->getQueue()->delay(0)->push(new FeedImport([
          'feed' => $feed,
          'limit' => $limit,
          'offset' => $offset,
          'processedElementIds' => $processedElementIds,
      ]));
  }
  
  ```
  
  The above will add all your feeds to Craft's queue system and start them.
  
  > **Comments:**
  > **username_4**: can you pass a url to the feed using this method? I'm currently using a pretty hacky way to trigger a feed programatically -> https://craftcms.stackexchange.com/questions/32933/trigger-feedme-import-from-plugin/32955#32955  
  > **username_3**: Small update for newer versions of the Feedme plugin: `$feeds = \craft\feedme\Plugin::$plugin->getFeeds()->getFeeds();`  
  
  ---
  
  ### Answer by username_1 on 2022-05-03. Score: 1
  
  It's worth mentioning now that for more recent versions of FeedMe, the console command natively supports an all flag.
  
  <https://docs.craftcms.com/feed-me/v4/feature-tour/trigger-import-via-cron.html#console-command>
  
  
  ---
  
  