|
|
@@ -8,6 +8,7 @@ use biz\product\models\Product;
|
|
|
use biz\shop\classes\ShopClass;
|
|
|
use bizGhs\item\classes\ItemClass;
|
|
|
use bizGhs\item\models\Item;
|
|
|
+use common\components\stringUtil;
|
|
|
use yii\console\Controller;
|
|
|
use Yii;
|
|
|
|
|
|
@@ -197,4 +198,31 @@ class ProductController extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public function actionRecover()
|
|
|
+ {
|
|
|
+ ini_set('memory_limit', '5045M');
|
|
|
+ set_time_limit(0);
|
|
|
+ if (getenv('YII_ENV') == 'production') {
|
|
|
+ $mainId = 8164;
|
|
|
+ } else {
|
|
|
+ $mainId = 644;
|
|
|
+ }
|
|
|
+ $list = ProductClass::getAllByCondition(['mainId' => $mainId], null, '*', null);
|
|
|
+ if (!empty($list)) {
|
|
|
+ $ids = array_column($list, 'itemId');
|
|
|
+ $ptInfo = PtItemClass::getByIds($ids, null, 'id');
|
|
|
+ foreach ($list as $item) {
|
|
|
+ $id = $item['id'] ?? 0;
|
|
|
+ $name = $item['name'] ?? '';
|
|
|
+ $ptItemId = $item['itemId'] ?? 0;
|
|
|
+ $pt = $ptInfo[$ptItemId];
|
|
|
+ $ptName = $pt['name'] ?? '';
|
|
|
+ if (!empty($ptName)) {
|
|
|
+ $ptPy = stringUtil::py($ptName);
|
|
|
+ ProductClass::updateById($id, ['name' => $ptName, 'py' => $ptPy]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|