Ejemplo n.º 1
0
 public static function processFeedsSubmissionList($feeds, $account)
 {
     WPLA()->logger->info('processFeedsSubmissionList() - processing ' . sizeof($feeds) . ' feeds for account ' . $account->id);
     $feeds_in_progress = 0;
     foreach ($feeds as $feed) {
         // check if feed exists
         $existing_record = WPLA_AmazonFeed::getFeedBySubmissionId($feed->FeedSubmissionId);
         if ($existing_record) {
             // skip existing feed if it was submitted using another "account" (different marketplace using the same account)
             if ($existing_record->account_id != $account->id) {
                 WPLA()->logger->info('skipped existing feed ' . $existing_record->id . ' for account ' . $existing_record->account_id);
                 continue;
             }
             $new_feed = new WPLA_AmazonFeed($existing_record->id);
             $new_feed->FeedSubmissionId = $feed->FeedSubmissionId;
             $new_feed->FeedType = $feed->FeedType;
             $new_feed->FeedProcessingStatus = $feed->FeedProcessingStatus;
             $new_feed->SubmittedDate = $feed->SubmittedDate;
             $new_feed->CompletedProcessingDate = isset($feed->CompletedProcessingDate) ? $feed->CompletedProcessingDate : '';
             // $new_feed->results                 = maybe_serialize( $feed );
             // save new record
             $new_feed->update();
         } else {
             // add new record
             $new_feed = new WPLA_AmazonFeed();
             $new_feed->FeedSubmissionId = $feed->FeedSubmissionId;
             $new_feed->FeedType = $feed->FeedType;
             $new_feed->FeedProcessingStatus = $feed->FeedProcessingStatus;
             $new_feed->SubmittedDate = $feed->SubmittedDate;
             $new_feed->CompletedProcessingDate = isset($feed->CompletedProcessingDate) ? $feed->CompletedProcessingDate : '';
             $new_feed->date_created = $feed->SubmittedDate;
             $new_feed->account_id = $account->id;
             // $new_feed->results                 = maybe_serialize( $feed );
             // save new record
             $new_feed->add();
         }
         if (!$new_feed->results) {
             $new_feed->loadSubmissionResult();
             $new_feed->processSubmissionResult();
         }
         // check if feed is in progress
         if (in_array($feed->FeedProcessingStatus, array('_SUBMITTED_', '_IN_PROGRESS_'))) {
             $feeds_in_progress++;
         }
     }
     // // update feed progress status
     // update_option( 'wpla_feeds_in_progress', $feeds_in_progress );
     return $feeds_in_progress;
 }
Ejemplo n.º 2
0
 public function processFeedResult($id)
 {
     $feed = new WPLA_AmazonFeed($id);
     $feed->processSubmissionResult();
     $msg = __('Feed result was processed.', 'wpla') . '<br><br>';
     $msg .= 'Errors: ' . sizeof($feed->errors) . '<br>';
     $msg .= 'Warnings: ' . sizeof($feed->warnings) . '<br>';
     $this->showMessage($msg);
 }