delStatus; //已经下架的商品 if ($delStatus == 1) { $product->status = 2; $product->delStatus = 0; $product->save(); echo $product->name . " {$product->id} 已经下架 status 变成 2 delStatus 变成 0\n"; } } } //更新封面 ./yii product/update-cover public function actionUpdateCover() { $list = ProductClass::getAllByCondition([], null, '*', null, true); if (empty($list)) { return false; } foreach ($list as $product) { $itemId = $product->itemId ?? 0; $ptItem = PtItemClass::getById($itemId, true); $ptCover = $ptItem->cover ?? ''; if (!empty($ptCover)) { $product->cover = $ptCover; $product->save(); echo "{$product->id} 已更新为{$ptCover} \n"; } } } //更新价格 ./yii product/update-price public function actionUpdatePrice() { $list = ProductClass::getAllByCondition(['shopId' => 10], null, '*', null, true); if (empty($list)) { return false; } foreach ($list as $product) { $ptItemId = $product->itemId ?? 0; $weight = $product->weight ?? 0; $addPrice = $product->addPrice ?? 0; $ratio = $product->ratio ?? 20; $p = ProductClass::getByCondition(['shopId' => 214, 'itemId' => $ptItemId], true); if (!empty($p)) { //$p->addPrice = $addPrice; //$p->weight = $weight; $p->ratio = $ratio; $p->save(); echo "productId {$p->id} 加价改成了:{$addPrice} 重量改成了:{$weight} 比例修改为 {$ratio} \n"; } } } }