You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/app/command/SyncGoodsToEs.php

49 lines
1.4 KiB

<?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');
$this->addArgument("type");
$this->addArgument("goods_id");
$this->addArgument("store_id");
}
protected function execute(Input $input, Output $output)
{
$type = $input->getArgument("type");
$goods_id = $input->getArgument("goods_id");
$store_id = $input->getArgument("store_id");
if ($type == "goods") {
$goodsCateService = new GoodsCateEs();
//$goodsService = new GoodsEs();
//$goodsService->createGoodsIndex();
$goodsCateService->batchCreateGoods($goods_id, $store_id);
} elseif ($type == "goods_cate"){
$goodsCateService = new GoodsCateEs();
//$goodsCateService->createGoodsCateIndex();
$goodsCateService->batchCreateGoodsCategory($goods_id, $store_id);
}
// try {
// $goodsService->batchCreateData();
// }catch (\Exception $e) {
// $output->writeln($e->getMessage());
// }
}
}