/** * Execute the console command. * * @return mixed */ public function handle() { //$res = \Merlion::call('getShipmentMethods'); //$res = \Merlion::call('getShipmentDates'); //print_r($res); //return; $cat_id = $this->argument('cat_id'); //$products = \Merlion::getItems($cat_id, null, null, 1, 10); //$products = $products->getItemsResult->item; $products_ids_arr = []; /*if (!is_array($products)) { $products_ids_arr[] = $products->No; } else { foreach ($products as $product_mix) { $products_ids_arr[] = $product_mix->No; } } if (empty($products_ids_arr)) { return; }*/ $products_avails = \Merlion::getItemsAvail('', $products_ids_arr); $products_avails = $products_avails->getItemsAvailResult->item; print_r($products_ids_arr); print_r($products_avails); return; $job = new \App\Jobs\MerlionFillProducts($cat_id); $job->onQueue('merlion_products'); $this->dispatch($job); }
/** * Execute the console command. * * @return mixed */ public function handle() { $cat_id = $this->argument('cat_id'); $time_start = time(); $this->info('Запрос getCatalog(' . $cat_id . ') к серверу Merlion...'); $catalog = \Merlion::getCatalog($cat_id); $catalog_items = $catalog->getCatalogResult->item; $this->info('- получено записей ' . count($catalog_items) . ', прошло секунд ' . (time() - $time_start)); if (!is_array($catalog_items)) { $this->error('Ответ пуст'); return; } $time_start = time(); $this->info('Обновление базы данных...'); foreach ($catalog_items as $catalog_item) { \App\Models\Merlion\CatalogItem::firstOrCreate(['id' => $catalog_item->ID, 'parent_id' => $catalog_item->ID_PARENT, 'description' => $catalog_item->Description]); echo '.'; } echo "\n"; $this->info('-прошло секунд ' . (time() - $time_start)); $this->info('Готово!'); }
/** * Execute the job. * * @return void */ public function handle($cat_id) { $products = \Merlion::getItems($cat_id, null, null, 1, 100); }