diff --git a/config/default.json b/config/default.json index 511971d445..29d03ba54a 100644 --- a/config/default.json +++ b/config/default.json @@ -140,6 +140,7 @@ "product": { "excludeFields": [ "*.msrp_display_actual_price_type", "required_options", "updated_at", "created_at", "attribute_set_id", "options_container", "msrp_display_actual_price_type", "has_options", "stock.manage_stock", "stock.use_config_min_qty", "stock.use_config_notify_stock_qty", "stock.stock_id", "stock.use_config_backorders", "stock.use_config_enable_qty_inc", "stock.enable_qty_increments", "stock.use_config_manage_stock", "stock.use_config_min_sale_qty", "stock.notify_stock_qty", "stock.use_config_max_sale_qty", "stock.use_config_max_sale_qty", "stock.qty_increments", "small_image", "sgn", "*.sgn"], "includeFields": null, + "useDynamicAttributeLoader": true, "standardSystemFields": [ "description", "configurable_options", diff --git a/core/modules/catalog/store/attribute/actions.ts b/core/modules/catalog/store/attribute/actions.ts index 67f5318fa4..a392116720 100644 --- a/core/modules/catalog/store/attribute/actions.ts +++ b/core/modules/catalog/store/attribute/actions.ts @@ -18,19 +18,21 @@ const actions: ActionTree = { let searchQuery = new SearchQuery() - const orgFilterValues = Object.assign({}, filterValues) - filterValues = filterValues.filter(fv => { // check the already loaded - if (filterField === 'attribute_id') return (typeof context.state.list_by_id[fv] === 'undefined' || context.state.list_by_id[fv] === null) - if (filterField === 'attribute_code') return (typeof context.state.list_by_code[fv] === 'undefined' || context.state.list_by_code[fv] === null) - return true - }) - if (!filterValues || filterValues.length === 0) { - Logger.info('Skipping attribute load - attributes already loaded', 'attr', { orgFilterValues, filterField})() - return Promise.resolve({ - items: Object.values(context.state.list_by_code) + if (filterValues) { + const orgFilterValues = Object.assign({}, filterValues) + filterValues = filterValues.filter(fv => { // check the already loaded + if (filterField === 'attribute_id') return (typeof context.state.list_by_id[fv] === 'undefined' || context.state.list_by_id[fv] === null) + if (filterField === 'attribute_code') return (typeof context.state.list_by_code[fv] === 'undefined' || context.state.list_by_code[fv] === null) + return true }) + if (!filterValues || filterValues.length === 0) { + Logger.info('Skipping attribute load - attributes already loaded', 'attr', { orgFilterValues, filterField})() + return Promise.resolve({ + items: Object.values(context.state.list_by_code) + }) + } + searchQuery = searchQuery.applyFilter({key: filterField, value: {'in': filterValues}}) } - searchQuery = searchQuery.applyFilter({key: filterField, value: {'in': filterValues}}) if (only_user_defined) { searchQuery = searchQuery.applyFilter({key: 'is_user_defined', value: {'in': [true]}}) } diff --git a/core/modules/catalog/store/product/actions.ts b/core/modules/catalog/store/product/actions.ts index f908412464..af24f7f88c 100644 --- a/core/modules/catalog/store/product/actions.ts +++ b/core/modules/catalog/store/product/actions.ts @@ -612,8 +612,8 @@ const actions: ActionTree = { return rootStore.state.config.entities.product.standardSystemFields.indexOf(fieldName) < 0 // don't load metadata info for standard fields }) subloaders.push(context.dispatch('attribute/list', { // load attributes to be shown on the product details - the request is now async - filterValues: productFields, - only_visible: true, + filterValues: rootStore.state.config.entities.product.useDynamicAttributeLoader ? productFields : null, + only_visible: rootStore.state.config.entities.product.useDynamicAttributeLoader ? true : false, only_user_defined: true, includeFields: rootStore.state.config.entities.optimize ? rootStore.state.config.entities.attribute.includeFields : null }, { root: true }))