From e1e3ee9568e50cfebedb4088d9fed81e825ac0b3 Mon Sep 17 00:00:00 2001 From: mengwb Date: Fri, 7 Apr 2023 08:42:56 +0000 Subject: [PATCH] =?UTF-8?q?!75=20=E7=BC=96=E8=BE=91=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=97=B6=E9=87=8D=E9=87=8F=E4=B8=BA=E7=A9=BA=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E6=8A=A5=E9=94=99=20*=20=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83?= =?UTF-8?q?=E5=8C=96=20*=20Fix=20the=20issue=20of=20saving=20error=20when?= =?UTF-8?q?=20editing=20product=20weight=20is=20empty.=20*=20=E9=AB=98?= =?UTF-8?q?=E7=BA=A7=E7=AD=9B=E9=80=89=E5=93=AA=E4=BA=9B=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=9C=A8=E7=AD=9B=E9=80=89=E6=A0=8F=E5=8F=AF?= =?UTF-8?q?=E5=9C=A8=E5=90=8E=E5=8F=B0=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=87=8C=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Http/Controllers/SettingController.php | 9 +++-- beike/Admin/Services/ProductService.php | 1 + beike/Repositories/ProductRepo.php | 5 +++ .../beike/admin/views/pages/setting.blade.php | 36 +++++++++++++++++++ resources/lang/en/admin/setting.php | 3 ++ resources/lang/zh_cn/admin/setting.php | 3 ++ 6 files changed, 55 insertions(+), 2 deletions(-) diff --git a/beike/Admin/Http/Controllers/SettingController.php b/beike/Admin/Http/Controllers/SettingController.php index 1c2a5ce9..04d16eae 100644 --- a/beike/Admin/Http/Controllers/SettingController.php +++ b/beike/Admin/Http/Controllers/SettingController.php @@ -30,15 +30,20 @@ class SettingController extends Controller { $themes = ThemeRepo::getAllThemes(); - $tax_address = [ + $taxAddress = [ ['value' => 'shipping', 'label' => trans('admin/setting.shipping_address')], ['value' => 'payment', 'label' => trans('admin/setting.payment_address')], ]; + $multiFilter = system_setting('base.multi_filter'); + if ($attributeIds = $multiFilter['attribute'] ?? []) { + $multiFilter['attribute'] = AttributeRepo::getByIds($attributeIds); + } $data = [ 'countries' => CountryRepo::listEnabled(), 'currencies' => CurrencyRepo::listEnabled(), - 'tax_address' => $tax_address, + 'multi_filter' => $multiFilter, + 'tax_address' => $taxAddress, 'customer_groups' => CustomerGroupDetail::collection(CustomerGroupRepo::list())->jsonSerialize(), 'themes' => $themes, ]; diff --git a/beike/Admin/Services/ProductService.php b/beike/Admin/Services/ProductService.php index 93c5592c..912facdb 100644 --- a/beike/Admin/Services/ProductService.php +++ b/beike/Admin/Services/ProductService.php @@ -27,6 +27,7 @@ class ProductService DB::beginTransaction(); $data['brand_id'] = (int) $data['brand_id']; + $data['weight'] = (float) $data['weight']; $data['variables'] = json_decode($data['variables']); $product->fill($data); $product->updated_at = now(); diff --git a/beike/Repositories/ProductRepo.php b/beike/Repositories/ProductRepo.php index c1fe771c..b42f18e2 100644 --- a/beike/Repositories/ProductRepo.php +++ b/beike/Repositories/ProductRepo.php @@ -206,6 +206,11 @@ class ProductRepo ->whereNotNull('pa.attribute_id') ->distinct() ->reorder('pa.attribute_id'); + + if ($attributesIds = system_setting('base.multi_filter', [])['attribute'] ?? []) { + $builder->whereIn('pa.attribute_id', $attributesIds); + } + $productAttributes = $builder->get()->toArray(); $attributeMap = array_column(Attribute::query()->with('description')->orderBy('sort_order')->get()->toArray(), null, 'id'); diff --git a/resources/beike/admin/views/pages/setting.blade.php b/resources/beike/admin/views/pages/setting.blade.php index 66a4082a..d6fd18a4 100644 --- a/resources/beike/admin/views/pages/setting.blade.php +++ b/resources/beike/admin/views/pages/setting.blade.php @@ -113,6 +113,42 @@ +
+ +
+
+ + +
+ + +
+
+
+
{{ __('admin/builder.multi_filter_helper') }}
+
+
+
@hook('admin.setting.express.before') diff --git a/resources/lang/en/admin/setting.php b/resources/lang/en/admin/setting.php index 10fca776..6e3e9fd2 100644 --- a/resources/lang/en/admin/setting.php +++ b/resources/lang/en/admin/setting.php @@ -71,4 +71,7 @@ return [ 'head_code' => 'Insert code', 'head_code_info' => 'The code in the input box will be inserted into the head of the front-end page, which can be used to count the code or add special plug-ins, etc', 'rate_api_key' => 'Exchange rate API KEY', + 'multi_filter' => 'Multi Filter', + 'please_select' => 'Please select', + 'multi_filter_helper' => 'Please select the attributes to be displayed in the Multi Filter module.', ]; diff --git a/resources/lang/zh_cn/admin/setting.php b/resources/lang/zh_cn/admin/setting.php index 613a5700..a94232b8 100644 --- a/resources/lang/zh_cn/admin/setting.php +++ b/resources/lang/zh_cn/admin/setting.php @@ -69,4 +69,7 @@ return [ 'head_code' => '插入代码', 'head_code_info' => '会将输入框中的代码插入到前端页面 head 中,可用于统计代码或者添加特殊插件等', 'rate_api_key' => '汇率 API KEY', + 'multi_filter' => '高级筛选', + 'please_select' => '请添加', + 'multi_filter_helper' => '请选择需要在筛选模块显示的属性', ];