<?php namespace app\command; use app\common\service\GoodsCateEs; use app\common\service\GoodsEs; use think\console\Command; use think\console\Output; use think\console\Input; class SyncGoodsToEs extends Command { protected function configure() { // 指令配置 $this->setName('syncGoodsToEs') ->setDescription('同步商品数据到ES'); } protected function execute(Input $input, Output $output) { $goodsService = new GoodsCateEs(); try { $goodsService->batchCreateData(); }catch (\Exception $e) { $output->writeln($e->getMessage()); } } }