diff --git a/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php b/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php index 8af40c268..f4e94954e 100755 --- a/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php +++ b/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php @@ -75,7 +75,11 @@ class AttributeController extends Controller 'type' => 'required' ]); - $attribute = $this->attribute->create(request()->all()); + $data = request()->all(); + + $data['is_user_defined'] = 1; + + $attribute = $this->attribute->create($data); Event::fire('after.attribute.created', $attribute); diff --git a/packages/Webkul/Product/src/Listeners/ProductsFlat.php b/packages/Webkul/Product/src/Listeners/ProductsFlat.php index c80a91fbe..8f6c53370 100644 --- a/packages/Webkul/Product/src/Listeners/ProductsFlat.php +++ b/packages/Webkul/Product/src/Listeners/ProductsFlat.php @@ -49,8 +49,12 @@ class ProductsFlat if (Schema::hasTable('product_flat')) { if (!Schema::hasColumn('product_flat', strtolower($attribute->code))) { - Schema::table('product_flat', function (Blueprint $table) use($columnType, $attributeCode) { + Schema::table('product_flat', function (Blueprint $table) use($columnType, $attributeCode, $attributeType) { $table->{$columnType}(strtolower($attributeCode))->nullable(); + + if($attributeType == 'select' || $attributeType == 'multiselect') { + $table->string(strtolower($attributeCode).'_label')->nullable(); + } }); return true; @@ -76,6 +80,10 @@ class ProductsFlat if (Schema::hasColumn('product_flat', strtolower($attribute->code))) { Schema::table('product_flat', function (Blueprint $table) use($attribute){ $table->dropColumn(strtolower($attribute->code)); + + if ($attribute->type == 'select' || $attribute->type == 'multiselect') { + $table->dropColumn(strtolower($attribute->code).'_label'); + } }); return true;