lqmac 3 months ago
parent ceaa3e6cd5
commit 521788d1a9
  1. 27
      app/command/SyncCategoryAdmin.php
  2. 1
      config/console.php

@ -11,47 +11,28 @@ use app\store\model\Category as CategoryModel;
use app\common\model\Store;
use think\facade\Db;
class SyncCategory extends Command
class SyncCategoryAdmin extends Command
{
const DEFAULT_STORE_ID = 0;
protected function configure()
{
// 指令配置
$this->setName('SyncCategory')->setDescription('同步商品数据到ES');
$this->addArgument("store_id");
$this->setName('SyncCategoryAdmin')->setDescription('同步商品数据到ES');
$this->addArgument("is_update_image");
}
protected function execute(Input $input, Output $output)
{
// $store_id = $input->getArgument("store_id");
$is_update_image = $input->getArgument("is_update_image");
// $where[] = ['is_sync_cate','=', 1];
// $where[] = ['is_delete','=', 0];
// $where[] = ['is_recycle','=', 0];
// $where[] = ['status','=', 1];
// if ($store_id) {
// $where[] = ['store_id','=', $store_id];
// } else {
// $where[] = ['store_id', '<>', self::DEFAULT_STORE_ID];
// }
// $stores = Store::where($where)->field('store_id,is_sync,is_recycle,status,is_delete')->select()->toArray();
// if (!$stores) {
// echo "没有要同步的商城了";
// return;
// }
// foreach ($stores as $store) {
$this->copyCategory(0, $is_update_image);
//}
$this->copyCategory(0, $is_update_image);
}
public function copyCategory(int $new_store_id, $is_update_image = 0){
$store_id = 0;
$model = new CategoryModel;
$list = Db::connect("shopMysql")->name('yoshop_category')->where('store_id', 0)->order(['sort', 'create_time'])->select();
$list = Db::connect("shopMysql")->name('yoshop_category')->where('status',1)->where('store_id', 0)->order(['sort', 'create_time'])->select();
$list = $this->getTreeData($list);
//$list = $model->getList(['store_id' => self::DEFAULT_STORE_ID]);
// var_dump($list);

@ -16,6 +16,7 @@ return [
'ProfitSharing' => 'app\command\ProfitSharing',
'ProfitSharingResult' => 'app\command\ProfitSharingResult',
'SyncCategory' => 'app\command\SyncCategory',
'SyncCategoryAdmin' => 'app\command\SyncCategoryAdmin',
'HomeLocation' => 'app\command\HomeLocation',
],
];

Loading…
Cancel
Save