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' => '请选择需要在筛选模块显示的属性', ];