Browse Source

fix:修改商品分类错误字段

antshop
linyaostalker 5 years ago
parent
commit
4c18a48247
  1. 41
      backend/modules/goods/migrations/m191217_091658_update_column_is_manual_in_table_atg_goods_sku.php
  2. 10
      backend/modules/goods/models/ars/Category.php

41
backend/modules/goods/migrations/m191217_091658_update_column_is_manual_in_table_atg_goods_sku.php

@ -0,0 +1,41 @@
<?php
use yii\db\Migration;
/**
* Class m191217_091658_update_column_is_manual_in_table_atg_goods_sku
*/
class m191217_091658_update_column_is_manual_in_table_atg_goods_sku extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->dropColumn('atg_goods_sku', 'is_manaul');
$this->addColumn('atg_goods_sku', 'is_manual', $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('是否手动'));
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
return true;
}
/*
// Use up()/down() to run migration code without a transaction.
public function up()
{
}
public function down()
{
echo "m191217_091658_update_column_is_manual_in_table_atg_goods_sku cannot be reverted.\n";
return false;
}
*/
}

10
backend/modules/goods/models/ars/Category.php

@ -5,6 +5,7 @@ namespace backend\modules\goods\models\ars;
use Yii;
use yii\behaviors\TimestampBehavior;
use backend\modules\file\models\ars\File;
use backend\modules\goods\logic\goods\GoodsManager;
/**
* This is the model class for table "atg_category".
@ -105,7 +106,14 @@ class Category extends \yii\db\ActiveRecord
*/
public static function modelColumn($ownId = 0)
{
return $column = self::find()->select(['name'])->where(['is_delete' => self::IS_DELETE_NO])->andWhere(['!=', 'id', $ownId])->indexBy('id')->column();
$query = self::find()->where(['is_delete' => self::IS_DELETE_NO]);
if ($ownId) {
$query->andWhere(['not in', 'id', GoodsManager::subCategoryId($ownId)]);
}
$data = $query->asArray()->all();
$data = GoodsManager::btree($data);
$data = GoodsManager::constructDropList($data);
return $data;
}
public function getIconFile()

Loading…
Cancel
Save