public function action_update_feeds() { WPLA()->logger->info("do_action: wpla_update_feeds"); $accounts = WPLA_AmazonAccount::getAll(); $feeds_in_progress = 0; foreach ($accounts as $account) { $api = new WPLA_AmazonAPI($account->id); // get feed submissions $feeds = $api->getFeedSubmissionList(); if (is_array($feeds)) { // run the import $feeds_in_progress += WPLA_AmazonFeed::processFeedsSubmissionList($feeds, $account); $msg = sprintf(__('%s feed submission(s) were found for account %s.', 'wpla'), sizeof($feeds), $account->title); WPLA()->logger->info($msg); $this->showMessage(nl2br($msg), 0, 1); } elseif ($feeds->Error->Message) { $msg = sprintf(__('There was a problem fetching feed submissions for account %s.', 'wpla'), $account->title) . ' - Error: ' . $feeds->Error->Message; WPLA()->logger->error($msg); $this->showMessage(nl2br($msg), 1, 1); } else { $msg = sprintf(__('There was a problem fetching feed submissions for account %s.', 'wpla'), $account->title); WPLA()->logger->error($msg); $this->showMessage(nl2br($msg), 1, 1); } } // update feed progress status update_option('wpla_feeds_in_progress', $feeds_in_progress); }
public function updateFeedStatus($feed_ids) { WPLA()->logger->info("updateFeedStatus() - " . join(', ', $feed_ids)); // echo "<pre>";print_r($feed_ids);echo"</pre>";die(); if (empty($feed_ids)) { return; } $accounts = WPLA_AmazonAccount::getAll(); foreach ($feed_ids as $feed_id) { $feed = new WPLA_AmazonFeed($feed_id); $account = new WPLA_AmazonAccount($feed->account_id); $api = new WPLA_AmazonAPI($feed->account_id); // get feed submissions $feeds = $api->getFeedSubmissionList($feed->FeedSubmissionId); if (is_array($feeds)) { // run the import WPLA_AmazonFeed::processFeedsSubmissionList($feeds, $account); $msg = sprintf(__('%s feed submission(s) were found for account %s.', 'wpla'), sizeof($feeds), $account->title); WPLA()->logger->info($msg); $this->showMessage(nl2br($msg), 0, 1); } elseif ($feeds->Error->Message) { $msg = sprintf(__('There was a problem fetching feed submissions for account %s.', 'wpla'), $account->title) . ' - Error: ' . $feeds->Error->Message; WPLA()->logger->error($msg); $this->showMessage(nl2br($msg), 1, 1); } else { $msg = sprintf(__('There was a problem fetching feed submissions for account %s.', 'wpla'), $account->title); WPLA()->logger->error($msg); $this->showMessage(nl2br($msg), 1, 1); } } }