|
|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace console\controllers;
|
|
|
|
|
|
+use biz\item\models\PtItemClass;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
use yii\console\Controller;
|
|
|
|
|
|
@@ -27,4 +28,23 @@ class ProductController extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //更新封面 ./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";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|