/** * Execute the console command. * * @return mixed */ public function handle() { if ($clientId = $this->input->getOption('partner')) { $this->downloadService->downloadClientFeed($clientId); } elseif ($feedId = $this->input->getOption('feed')) { logger()->debug($feedId); $this->downloadService->downloadOnlyFeed($feedId); } else { logger()->error('Nothing to download.'); } $message = sprintf("Downloading feeds for partner"); $this->notificationService->success($message); }
private function downloadFeed($feed) { $this->generateDownladUniqueId(); $url = $feed->feed_url; $path = $this->config["amanda_download_dir"]; $filename = $path . '/amanda-' . $this->downloadUniqueKey; try { file_put_contents($filename, fopen($url, 'r')); $this->sendMessageToRabbit($feed->partner->id, $feed->id, $filename); $message = sprintf("Feed %s for client %s downloaded from url %s.", $feed->name, $feed->partner->name, $url); logger()->debug($message); $this->notificationService->success($message); } catch (\ErrorException $e) { $message = sprintf("Feed %s for client %s could not be downloaded.", $feed->name, $feed->partner->name); logger()->error($message); $this->notificationService->error($message); } }
/** * Execute the console command. * * @return mixed */ public function handle() { logger()->debug("Starting listening"); $callback = function ($message) { logger()->debug('consume message - reindex started'); $data = json_decode($message->body, true); logger()->debug($data); if (isset($data["data"]["type"]) && $data["data"]["type"] == 'product') { if (!isset($data["data"]["id"])) { logger()->error("Product id not found."); } else { $productId = $data["data"]["id"]; $this->productIndexer->indexProduct($productId); $this->notificationService->success(sprintf("Indexing product %s", $productId)); } } else { logger()->error("Bad data for reindex."); } }; $this->connectToRabbit($callback); }