Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Renames metafield search/sort key prefix from mf_ to cf_
Fizza Iqbal2d5a7a6b0149
diff --git a/docs/developer/core-concepts/metafields.mdx b/docs/developer/core-concepts/metafields.mdxindex 0f667c2563..061ace4786 100644--- a/docs/developer/core-concepts/metafields.mdx+++ b/docs/developer/core-concepts/metafields.mdx@@ -93,9 +93,9 @@ Product metafield definitions can opt into storefront SearchProvider participati| Flag | Effect | Allowed field types ||------|--------|---------------------|| `searchable` | Values are included in product text search | `short_text`, `long_text`, `number` |-| `sortable` | Listings can sort with `sort=mf_{namespace.length}_{namespace}_{key}` (prefix `-` for descending), e.g. `mf_6_custom_label` | `short_text`, `number` |+| `sortable` | Listings can sort with `sort=cf_{namespace.length}_{namespace}_{key}` (prefix `-` for descending), e.g. `cf_6_custom_label` | `short_text`, `number` |-Both default to `false`. Set them on the definition (Admin UI, Admin API, or seeds). For an existing catalog with Meilisearch, run `rake spree:search:reindex` after toggling flags so index settings and product documents pick up new `mf_*` fields.+Both default to `false`. Set them on the definition (Admin UI, Admin API, or seeds). For an existing catalog with Meilisearch, run `rake spree:search:reindex` after toggling flags so index settings and product documents pick up new `cf_*` fields.## Supported Resourcesdiff --git a/docs/developer/core-concepts/search-filtering.mdx b/docs/developer/core-concepts/search-filtering.mdxindex 3ed2499726..7d63b7a87f 100644--- a/docs/developer/core-concepts/search-filtering.mdx+++ b/docs/developer/core-concepts/search-filtering.mdx@@ -13,7 +13,7 @@ Spree provides powerful search, filtering, and sorting capabilities for products- Attribute-based filtering (price range, availability, stock status)- Category and taxon filtering- Faceted search with filter counts-- Flexible sorting options (including sortable product metafields via `sort=mf_{namespace.length}_{namespace}_{key}`)+- Flexible sorting options (including sortable product custom fields via `sort=cf_{namespace.length}_{namespace}_{key}`)## Product Search@@ -167,7 +167,7 @@ const sorted = await client.products.list({// Available sort options (prefix '-' for descending; use '-available_on' for newest):// price, -price, name, -name, available_on, -available_on, best_selling-// Plus any product metafield marked sortable, e.g. mf_6_custom_label / -mf_6_custom_label+// Plus any product custom field marked sortable, e.g. cf_6_custom_label / -cf_6_custom_label``````typescript Admin SDKdiff --git a/docs/developer/how-to/custom-search-provider.mdx b/docs/developer/how-to/custom-search-provider.mdxindex 92740abe3a..4fb8813d6e 100644--- a/docs/developer/how-to/custom-search-provider.mdx+++ b/docs/developer/how-to/custom-search-provider.mdx@@ -234,7 +234,7 @@ Always use prefixed IDs (`ctg_abc`, `prod_xyz`, `optval_abc`) when indexing. NevProduct metafields marked `searchable` / `sortable` on `MetafieldDefinition` are projected through `Spree::SearchProvider::MetafieldSchema` — shared by providers and `ProductPresenter`. Toggle participation with definition flags; run `rake spree:search:reindex` after changes when using Meilisearch.-Document shaping for `mf_*` fields stays on `search_product_presenter` — the only search-related dependency.+Document shaping for `cf_*` fields stays on `search_product_presenter` — the only search-related dependency.## Related Documentationdiff --git a/packages/admin-sdk/src/params.ts b/packages/admin-sdk/src/params.tsindex f788ecf8c1..38012d5f7b 100644--- a/packages/admin-sdk/src/params.ts+++ b/packages/admin-sdk/src/params.ts@@ -569,7 +569,7 @@ export interface CustomFieldDefinitionCreateParams {searchable?: boolean/*** Allow storefront product listings to sort by this field- * (`sort=mf_{n}_{namespace}_{key}`). Supported `field_type`s:+ * (`sort=cf_{n}_{namespace}_{key}`). Supported `field_type`s:* `short_text`, `number`. Other types are rejected by the API with 422.*/sortable?: boolean@@ -589,7 +589,7 @@ export interface CustomFieldDefinitionUpdateParams {searchable?: boolean/*** Allow storefront product listings to sort by this field- * (`sort=mf_{n}_{namespace}_{key}`). Supported `field_type`s:+ * (`sort=cf_{n}_{namespace}_{key}`). Supported `field_type`s:* `short_text`, `number`. Other types are rejected by the API with 422.*/sortable?: booleandiff --git a/packages/admin-sdk/tests/custom-fields.test.ts b/packages/admin-sdk/tests/custom-fields.test.tsindex 90b1b04156..04088fb4fa 100644--- a/packages/admin-sdk/tests/custom-fields.test.ts+++ b/packages/admin-sdk/tests/custom-fields.test.ts@@ -70,7 +70,7 @@ describe('custom fields', () => {it('gets a definition', async () => {const defn = await client.customFieldDefinitions.get('cfdef_1')expect(defn.key).toBe('fabric')- expect(defn.search_key).toBe('mf_5_specs_fabric')+ expect(defn.search_key).toBe('cf_5_specs_fabric')})it('creates a definition', async () => {diff --git a/packages/admin-sdk/tests/mocks/handlers.ts b/packages/admin-sdk/tests/mocks/handlers.tsindex 243c78d550..f4436af11c 100644--- a/packages/admin-sdk/tests/mocks/handlers.ts+++ b/packages/admin-sdk/tests/mocks/handlers.ts@@ -26,7 +26,7 @@ export const fixtures = {storefront_visible: true,searchable: false,sortable: false,- search_key: 'mf_5_specs_fabric',+ search_key: 'cf_5_specs_fabric',created_at: '2026-05-01T00:00:00.000Z',updated_at: '2026-05-01T00:00:00.000Z',},diff --git a/spree/api/spec/controllers/spree/api/v3/admin/custom_field_definitions_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/custom_field_definitions_controller_spec.rbindex 4bfff08b82..7c9defcb9d 100644--- a/spree/api/spec/controllers/spree/api/v3/admin/custom_field_definitions_controller_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/admin/custom_field_definitions_controller_spec.rb@@ -40,7 +40,7 @@ RSpec.describe Spree::Api::V3::Admin::CustomFieldDefinitionsController, type: :c'storefront_visible' => true,'searchable' => false,'sortable' => false,- 'search_key' => 'mf_5_specs_fabric'+ 'search_key' => 'cf_5_specs_fabric')endenddiff --git a/spree/api/spec/controllers/spree/api/v3/store/products/filters_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/store/products/filters_controller_spec.rbindex 5a3bb9f2c2..07aa705be3 100644--- a/spree/api/spec/controllers/spree/api/v3/store/products/filters_controller_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/store/products/filters_controller_spec.rb@@ -103,14 +103,14 @@ RSpec.describe Spree::Api::V3::Store::Products::FiltersController, type: :controit 'invalidates cached sort options when a metafield definition becomes sortable' doget :index- expect(json_response['sort_options'].map { |s| s['id'] }).not_to include('mf_6_custom_weight')+ expect(json_response['sort_options'].map { |s| s['id'] }).not_to include('cf_6_custom_weight')create(:metafield_definition, :number_field, :sortable,namespace: 'custom', key: 'weight', name: 'Weight')get :indexexpect(json_response['sort_options'].map { |s| s['id'] }).to include(- 'mf_6_custom_weight', '-mf_6_custom_weight'+ 'cf_6_custom_weight', '-cf_6_custom_weight')enddiff --git a/spree/api/spec/controllers/spree/api/v3/store/products/meilisearch_integration_spec.rb b/spree/api/spec/controllers/spree/api/v3/store/products/meilisearch_integration_spec.rbindex 0b1358b5fa..ed9cb6d30f 100644--- a/spree/api/spec/controllers/spree/api/v3/store/products/meilisearch_integration_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/store/products/meilisearch_integration_spec.rb@@ -265,8 +265,8 @@ RSpec.describe 'Meilisearch Integration', type: :controller, if: ENV['MEILISEARCit 'includes metafield keys in searchable and sortable settings' dosettings = ::Meilisearch::Client.new(ENV['MEILISEARCH_URL']).index(index_name).get_settings- expect(settings['searchableAttributes']).to include('mf_6_custom_label')- expect(settings['sortableAttributes']).to include('mf_6_custom_label', 'mf_6_custom_weight')+ expect(settings['searchableAttributes']).to include('cf_6_custom_label')+ expect(settings['sortableAttributes']).to include('cf_6_custom_label', 'cf_6_custom_weight')endit 'finds products by searchable metafield value' do@@ -279,13 +279,13 @@ RSpec.describe 'Meilisearch Integration', type: :controller, if: ENV['MEILISEARCendit 'sorts by short_text metafield ascending and descending with missing values last' do- get :index, params: { sort: 'mf_6_custom_label' }+ get :index, params: { sort: 'cf_6_custom_label' }expect(response).to have_http_status(:ok)asc_names = json_response['data'].map { |p| p['name'] }expect(asc_names.first(2)).to eq(['Red Cotton Shirt', 'Blue Silk Shirt'])expect(asc_names.last(2)).to match_array(['Green Linen Shirt', 'Blue Running Shoes'])- get :index, params: { sort: '-mf_6_custom_label' }+ get :index, params: { sort: '-cf_6_custom_label' }expect(response).to have_http_status(:ok)desc_names = json_response['data'].map { |p| p['name'] }expect(desc_names.first(2)).to eq(['Blue Silk Shirt', 'Red Cotton Shirt'])@@ -293,13 +293,13 @@ RSpec.describe 'Meilisearch Integration', type: :controller, if: ENV['MEILISEARCendit 'sorts by number metafield numerically' do- get :index, params: { sort: 'mf_6_custom_weight' }+ get :index, params: { sort: 'cf_6_custom_weight' }expect(response).to have_http_status(:ok)expect(json_response['data'].map { |p| p['name'] }.first(3)).to eq(['Blue Silk Shirt', 'Blue Running Shoes', 'Red Cotton Shirt'])- get :index, params: { sort: '-mf_6_custom_weight' }+ get :index, params: { sort: '-cf_6_custom_weight' }expect(response).to have_http_status(:ok)expect(json_response['data'].map { |p| p['name'] }.first(3)).to eq(['Red Cotton Shirt', 'Blue Running Shoes', 'Blue Silk Shirt']diff --git a/spree/api/spec/integration/spree/api/v3/admin/custom_field_definitions_spec.rb b/spree/api/spec/integration/spree/api/v3/admin/custom_field_definitions_spec.rbindex 640d9a7f5f..e5b2c6b36c 100644--- a/spree/api/spec/integration/spree/api/v3/admin/custom_field_definitions_spec.rb+++ b/spree/api/spec/integration/spree/api/v3/admin/custom_field_definitions_spec.rb@@ -42,7 +42,7 @@ RSpec.describe 'Admin Custom Field Definitions API', type: :request, swagger_docexpect(item['field_type']).to eq('short_text')expect(item['storefront_visible']).to eq(true)expect(item['resource_type']).to eq('Spree::Product')- expect(item['search_key']).to eq('mf_5_specs_fabric')+ expect(item['search_key']).to eq('cf_5_specs_fabric')endendenddiff --git a/spree/core/app/models/spree/metafield_definition/search_capabilities.rb b/spree/core/app/models/spree/metafield_definition/search_capabilities.rbindex d97c2634fc..ca16839f80 100644--- a/spree/core/app/models/spree/metafield_definition/search_capabilities.rb+++ b/spree/core/app/models/spree/metafield_definition/search_capabilities.rb@@ -40,10 +40,10 @@ module Spreeend# SearchProvider document key. Namespace is length-prefixed so- # (a_b, c) and (a, b_c) cannot collide as the same mf_* attribute.- # @return [String] e.g. +mf_6_custom_label++ # (a_b, c) and (a, b_c) cannot collide as the same cf_* attribute.+ # @return [String] e.g. +cf_6_custom_label+def search_key- "mf_#{namespace.to_s.length}_#{namespace}_#{key}"+ "cf_#{namespace.to_s.length}_#{namespace}_#{key}"endprivatediff --git a/spree/core/app/models/spree/search_provider/database.rb b/spree/core/app/models/spree/search_provider/database.rbindex b7f4b47791..11e30f3e7b 100644--- a/spree/core/app/models/spree/search_provider/database.rb+++ b/spree/core/app/models/spree/search_provider/database.rb@@ -123,11 +123,11 @@ module Spreereturn scope unless definitionp_table = Spree::Product.quoted_table_name- mf_table = Spree::Metafield.quoted_table_name+ cf_table = Spree::Metafield.quoted_table_nameconnection = scope.klass.connectionadapter = connection.adapter_name- mf_join_alias = 'sort_mf'+ cf_join_alias = 'sort_cf'sort_expr = Arel.sql(metafield_sort_expression(definition.field_type, adapter))null_rank = Arel.sql(metafield_sort_null_rank(definition.field_type, adapter))@@ -135,22 +135,22 @@ module Spreedirection = parsed[:direction] == 'desc' ? :desc : :ascdef_id = connection.quote(definition.id)- join_sql = "LEFT JOIN #{mf_table} AS #{mf_join_alias} " \- "ON #{mf_join_alias}.resource_type = 'Spree::Product' " \- "AND #{mf_join_alias}.resource_id = #{p_table}.id " \- "AND #{mf_join_alias}.metafield_definition_id = #{def_id}"+ join_sql = "LEFT JOIN #{cf_table} AS #{cf_join_alias} " \+ "ON #{cf_join_alias}.resource_type = 'Spree::Product' " \+ "AND #{cf_join_alias}.resource_id = #{p_table}.id " \+ "AND #{cf_join_alias}.metafield_definition_id = #{def_id}"scope.joins(join_sql).select("#{p_table}.*")- .select(Arel::Nodes::As.new(sort_expr, Arel.sql('mf_sort_value')))- .select(Arel::Nodes::As.new(null_rank, Arel.sql('mf_sort_missing')))- .reorder(Arel.sql('mf_sort_missing ASC'), sort_expr.send(direction))+ .select(Arel::Nodes::As.new(sort_expr, Arel.sql('cf_sort_value')))+ .select(Arel::Nodes::As.new(null_rank, Arel.sql('cf_sort_missing')))+ .reorder(Arel.sql('cf_sort_missing ASC'), sort_expr.send(direction))end- # Type-cast sort_mf.value for numeric metafields across PostgreSQL / MySQL / SQLite.+ # Type-cast sort_cf.value for numeric metafields across PostgreSQL / MySQL / SQLite.def metafield_sort_expression(field_type, adapter_name)- column = 'sort_mf.value'+ column = 'sort_cf.value'return column unless field_type == 'number'case adapter_name@@ -164,7 +164,7 @@ module Spreeend# NULL-rank so products missing the metafield sort last (Meilisearch parity).- # Projected as mf_sort_missing because PostgreSQL rejects (alias IS NULL) in ORDER BY.+ # Projected as cf_sort_missing because PostgreSQL rejects (alias IS NULL) in ORDER BY.def metafield_sort_null_rank(field_type, adapter_name)"(#{metafield_sort_expression(field_type, adapter_name)} IS NULL)"enddiff --git a/spree/core/app/presenters/spree/search_provider/product_presenter.rb b/spree/core/app/presenters/spree/search_provider/product_presenter.rbindex b02ad40f58..473f32e61c 100644--- a/spree/core/app/presenters/spree/search_provider/product_presenter.rb+++ b/spree/core/app/presenters/spree/search_provider/product_presenter.rb@@ -78,7 +78,7 @@ module Spree}.merge(metafield_document_attributes)end- # Flat mf_* hash for searchable ∪ sortable metafields (Meilisearch docs).+ # Flat cf_* hash for searchable ∪ sortable metafields (Meilisearch docs).def metafield_document_attributes@metafield_document_attributes ||= product.metafields.filter_map do |metafield|definition = metafield.metafield_definitiondiff --git a/spree/core/spec/models/spree/metafield_definition_spec.rb b/spree/core/spec/models/spree/metafield_definition_spec.rbindex 542a50b38f..488d7fb4f9 100644--- a/spree/core/spec/models/spree/metafield_definition_spec.rb+++ b/spree/core/spec/models/spree/metafield_definition_spec.rb@@ -119,15 +119,15 @@ RSpec.describe Spree::MetafieldDefinition, type: :model dodescribe '#search_key' doit 'returns the SearchProvider attribute key with a length-prefixed namespace' dometafield_definition = build(:metafield_definition, namespace: 'custom', key: 'material')- expect(metafield_definition.search_key).to eq('mf_6_custom_material')+ expect(metafield_definition.search_key).to eq('cf_6_custom_material')endit 'produces distinct keys when namespace/key underscore boundaries differ' doleft = build(:metafield_definition, namespace: 'a_b', key: 'c')right = build(:metafield_definition, namespace: 'a', key: 'b_c')- expect(left.search_key).to eq('mf_3_a_b_c')- expect(right.search_key).to eq('mf_1_a_b_c')+ expect(left.search_key).to eq('cf_3_a_b_c')+ expect(right.search_key).to eq('cf_1_a_b_c')expect(left.search_key).not_to eq(right.search_key)endenddiff --git a/spree/core/spec/models/spree/search_provider/database_spec.rb b/spree/core/spec/models/spree/search_provider/database_spec.rbindex 3d56d15cee..aa8a0a5505 100644--- a/spree/core/spec/models/spree/search_provider/database_spec.rb+++ b/spree/core/spec/models/spree/search_provider/database_spec.rb@@ -224,13 +224,13 @@ module Spreeproduct_3.set_metafield(definition, 'bravo')end- it 'sorts ascending by mf_* attribute' do- result = provider.search_and_filter(scope: scope, sort: 'mf_6_custom_label')+ it 'sorts ascending by cf_* attribute' do+ result = provider.search_and_filter(scope: scope, sort: 'cf_6_custom_label')expect(result.products.map(&:id)).to eq([product_2.id, product_3.id, product_1.id])end- it 'sorts descending by -mf_* attribute' do- result = provider.search_and_filter(scope: scope, sort: '-mf_6_custom_label')+ it 'sorts descending by -cf_* attribute' do+ result = provider.search_and_filter(scope: scope, sort: '-cf_6_custom_label')expect(result.products.map(&:id)).to eq([product_1.id, product_3.id, product_2.id])end@@ -238,7 +238,7 @@ module Spreeresult = provider.search_and_filter(scope: scope,filters: { 'name_cont' => 'Blue' },- sort: 'mf_6_custom_label'+ sort: 'cf_6_custom_label')expect(result.products.map(&:id)).to eq([product_3.id, product_1.id])end@@ -249,12 +249,12 @@ module Spreeendit 'keeps missing values last when sorting ascending' do- result = provider.search_and_filter(scope: scope, sort: 'mf_6_custom_label')+ result = provider.search_and_filter(scope: scope, sort: 'cf_6_custom_label')expect(result.products.map(&:id)).to eq([product_3.id, product_1.id, product_2.id])endit 'keeps missing values last when sorting descending' do- result = provider.search_and_filter(scope: scope, sort: '-mf_6_custom_label')+ result = provider.search_and_filter(scope: scope, sort: '-cf_6_custom_label')expect(result.products.map(&:id)).to eq([product_1.id, product_3.id, product_2.id])endend@@ -273,12 +273,12 @@ module Spreeendit 'sorts ascending numerically rather than lexicographically' do- result = provider.search_and_filter(scope: scope, sort: 'mf_6_custom_weight')+ result = provider.search_and_filter(scope: scope, sort: 'cf_6_custom_weight')expect(result.products.map(&:id)).to eq([product_2.id, product_3.id, product_1.id])endit 'sorts descending numerically' do- result = provider.search_and_filter(scope: scope, sort: '-mf_6_custom_weight')+ result = provider.search_and_filter(scope: scope, sort: '-cf_6_custom_weight')expect(result.products.map(&:id)).to eq([product_1.id, product_3.id, product_2.id])endend@@ -307,13 +307,13 @@ module Spreeit 'includes metafield sort options' doids = result.sort_options.map { |o| o[:id] }- expect(ids).to include('mf_6_custom_label', '-mf_6_custom_label')+ expect(ids).to include('cf_6_custom_label', '-cf_6_custom_label')endit 'includes human-readable labels for metafield sort options' doby_id = result.sort_options.index_by { |o| o[:id] }- expect(by_id['mf_6_custom_label'][:label]).to eq("Material (#{Spree.t(:sort_a_to_z)})")- expect(by_id['-mf_6_custom_label'][:label]).to eq("Material (#{Spree.t(:sort_z_to_a)})")+ expect(by_id['cf_6_custom_label'][:label]).to eq("Material (#{Spree.t(:sort_a_to_z)})")+ expect(by_id['-cf_6_custom_label'][:label]).to eq("Material (#{Spree.t(:sort_z_to_a)})")endend@@ -356,15 +356,15 @@ module Spreedescribe 'metafield sort SQL helpers' doit 'casts numeric metafields per adapter' do- expect(provider.send(:metafield_sort_expression, 'number', 'PostgreSQL')).to eq('sort_mf.value::numeric')- expect(provider.send(:metafield_sort_expression, 'number', 'Mysql2')).to eq('CAST(sort_mf.value AS DECIMAL(30, 10))')- expect(provider.send(:metafield_sort_expression, 'number', 'SQLite')).to eq('CAST(sort_mf.value AS REAL)')- expect(provider.send(:metafield_sort_expression, 'short_text', 'PostgreSQL')).to eq('sort_mf.value')+ expect(provider.send(:metafield_sort_expression, 'number', 'PostgreSQL')).to eq('sort_cf.value::numeric')+ expect(provider.send(:metafield_sort_expression, 'number', 'Mysql2')).to eq('CAST(sort_cf.value AS DECIMAL(30, 10))')+ expect(provider.send(:metafield_sort_expression, 'number', 'SQLite')).to eq('CAST(sort_cf.value AS REAL)')+ expect(provider.send(:metafield_sort_expression, 'short_text', 'PostgreSQL')).to eq('sort_cf.value')endit 'builds a null-rank expression from the sort expression' do- expect(provider.send(:metafield_sort_null_rank, 'number', 'PostgreSQL')).to eq('(sort_mf.value::numeric IS NULL)')- expect(provider.send(:metafield_sort_null_rank, 'short_text', 'PostgreSQL')).to eq('(sort_mf.value IS NULL)')+ expect(provider.send(:metafield_sort_null_rank, 'number', 'PostgreSQL')).to eq('(sort_cf.value::numeric IS NULL)')+ expect(provider.send(:metafield_sort_null_rank, 'short_text', 'PostgreSQL')).to eq('(sort_cf.value IS NULL)')endendenddiff --git a/spree/core/spec/models/spree/search_provider/meilisearch_spec.rb b/spree/core/spec/models/spree/search_provider/meilisearch_spec.rbindex 9c6a529a0f..a5d31195d2 100644--- a/spree/core/spec/models/spree/search_provider/meilisearch_spec.rb+++ b/spree/core/spec/models/spree/search_provider/meilisearch_spec.rb@@ -178,7 +178,7 @@ module Spreebefore doerror = ::Meilisearch::ApiError.new(400, 'Bad Request',- { 'code' => 'invalid_search_sort', 'message' => 'Attribute `mf_6_custom_label` is not sortable.' }+ { 'code' => 'invalid_search_sort', 'message' => 'Attribute `cf_6_custom_label` is not sortable.' })calls = 0allow(mock_index).to receive(:search) do@@ -192,7 +192,7 @@ module Spreeit 'pushes index settings and retries the search once' doexpect(mock_index).to receive(:update_sortable_attributes)- result = provider.search_and_filter(scope: store.products, query: 'shirt', sort: 'mf_6_custom_label')+ result = provider.search_and_filter(scope: store.products, query: 'shirt', sort: 'cf_6_custom_label')expect(result.products).to include(product_1, product_2)endend@@ -364,18 +364,18 @@ module Spreenamespace: 'custom', key: 'label')end- it 'includes mf_* in searchable and sortable attributes' do- expect(provider.send(:searchable_attributes)).to include('mf_6_custom_label')- expect(provider.send(:sortable_attributes)).to include('mf_6_custom_label')+ it 'includes cf_* in searchable and sortable attributes' do+ expect(provider.send(:searchable_attributes)).to include('cf_6_custom_label')+ expect(provider.send(:sortable_attributes)).to include('cf_6_custom_label')end- it 'does not put mf_* on filterable attributes' do- expect(provider.send(:filterable_attributes)).not_to include('mf_6_custom_label')+ it 'does not put cf_* on filterable attributes' do+ expect(provider.send(:filterable_attributes)).not_to include('cf_6_custom_label')end- it 'maps mf_* sort params without namespace resolution' do- expect(provider.send(:sort_mapping, 'mf_6_custom_label')).to eq(['mf_6_custom_label:asc'])- expect(provider.send(:sort_mapping, '-mf_6_custom_label')).to eq(['mf_6_custom_label:desc'])+ it 'maps cf_* sort params without namespace resolution' do+ expect(provider.send(:sort_mapping, 'cf_6_custom_label')).to eq(['cf_6_custom_label:asc'])+ expect(provider.send(:sort_mapping, '-cf_6_custom_label')).to eq(['cf_6_custom_label:desc'])endendenddiff --git a/spree/core/spec/presenters/spree/search_provider/product_presenter_spec.rb b/spree/core/spec/presenters/spree/search_provider/product_presenter_spec.rbindex ec2f55fdff..c33305c34b 100644--- a/spree/core/spec/presenters/spree/search_provider/product_presenter_spec.rb+++ b/spree/core/spec/presenters/spree/search_provider/product_presenter_spec.rb@@ -205,14 +205,14 @@ module Spreeproduct.set_metafield(ignored_def, 'secret')end- it 'indexes searchable and sortable metafield values as mf_* attributes' do+ it 'indexes searchable and sortable metafield values as cf_* attributes' dodoc = documents.first- expect(doc['mf_6_custom_pinyin_name']).to eq('mao-tai')- expect(doc['mf_6_custom_priority']).to eq(10.0)- expect(doc).not_to have_key('mf_6_custom_internal_note')+ expect(doc['cf_6_custom_pinyin_name']).to eq('mao-tai')+ expect(doc['cf_6_custom_priority']).to eq(10.0)+ expect(doc).not_to have_key('cf_6_custom_internal_note')end- it 'uses the same mf_* attributes on every market/locale document' do+ it 'uses the same cf_* attributes on every market/locale document' docreate(:market, store: store, name: 'US', currency: 'USD', default_locale: 'en')create(:market, store: store, name: 'EU', currency: 'EUR', default_locale: 'de')create(:price, variant: product.master, amount: 9.99, currency: 'EUR')@@ -220,9 +220,9 @@ module Spreedocs = described_class.new(product.reload, store.reload).callexpect(docs.size).to be > 1- mf_keys = docs.first.keys.grep(/\Amf_/)+ cf_keys = docs.first.keys.grep(/\Acf_/)docs.each do |doc|- expect(doc.slice(*mf_keys)).to eq(docs.first.slice(*mf_keys))+ expect(doc.slice(*cf_keys)).to eq(docs.first.slice(*cf_keys))endend@@ -232,7 +232,7 @@ module Spreeproduct.set_metafield(decimal_def, '42.5')doc = described_class.new(product.reload, store).call.first- expect(doc['mf_6_custom_rating']).to eq(42.5)+ expect(doc['cf_6_custom_rating']).to eq(42.5)endit 'omits registered keys when the product has no value' do@@ -240,14 +240,14 @@ module Spreenamespace: 'custom', key: 'origin', name: 'Origin')doc = described_class.new(product.reload, store).call.first- expect(doc).not_to have_key('mf_6_custom_origin')+ expect(doc).not_to have_key('cf_6_custom_origin')end- it 'includes no mf_* attributes when no definitions are searchable or sortable' do+ it 'includes no cf_* attributes when no definitions are searchable or sortable' doSpree::MetafieldDefinition.destroy_alldoc = described_class.new(product.reload, store).call.first- expect(doc.keys.grep(/\Amf_/)).to be_empty+ expect(doc.keys.grep(/\Acf_/)).to be_emptyendendenddiff --git a/spree/core/spec/services/spree/search_provider/metafield_schema_spec.rb b/spree/core/spec/services/spree/search_provider/metafield_schema_spec.rbindex 1322947989..ad97803bd8 100644--- a/spree/core/spec/services/spree/search_provider/metafield_schema_spec.rb+++ b/spree/core/spec/services/spree/search_provider/metafield_schema_spec.rb@@ -6,15 +6,15 @@ RSpec.describe Spree::SearchProvider::MetafieldSchema dosubject(:schema) { described_class.new }describe 'accessors' do- it 'exposes definitions by mf_* key' do+ it 'exposes definitions by cf_* key' dodefinition = create(:metafield_definition, :number_field, :sortable, :searchable,namespace: 'custom', key: 'weight', name: 'Weight')- entry = schema.entry_for('mf_6_custom_weight')+ entry = schema.entry_for('cf_6_custom_weight')expect(entry).to eq(definition)- expect(schema.searchable_attribute_keys).to include('mf_6_custom_weight')- expect(schema.sortable_attribute_keys).to include('mf_6_custom_weight')+ expect(schema.searchable_attribute_keys).to include('cf_6_custom_weight')+ expect(schema.sortable_attribute_keys).to include('cf_6_custom_weight')endend@@ -24,8 +24,8 @@ RSpec.describe Spree::SearchProvider::MetafieldSchema dopriority = create(:metafield_definition, :number_field, :sortable, namespace: 'custom', key: 'priority')expect(schema.entries).to include(- 'mf_6_custom_label' => label,- 'mf_6_custom_priority' => priority+ 'cf_6_custom_label' => label,+ 'cf_6_custom_priority' => priority)endend@@ -35,17 +35,17 @@ RSpec.describe Spree::SearchProvider::MetafieldSchema docreate(:metafield_definition, :short_text_field, :sortable, namespace: 'custom', key: 'name')end- it 'parses ascending and descending mf_* sorts' do- expect(schema.parse_sort('mf_6_custom_name')).to eq(attribute: 'mf_6_custom_name', direction: 'asc')- expect(schema.parse_sort('-mf_6_custom_name')).to eq(attribute: 'mf_6_custom_name', direction: 'desc')+ it 'parses ascending and descending cf_* sorts' do+ expect(schema.parse_sort('cf_6_custom_name')).to eq(attribute: 'cf_6_custom_name', direction: 'asc')+ expect(schema.parse_sort('-cf_6_custom_name')).to eq(attribute: 'cf_6_custom_name', direction: 'desc')endit 'returns nil for unknown or non-sortable keys' docreate(:metafield_definition, :short_text_field, :searchable, namespace: 'custom', key: 'notes')- expect(schema.parse_sort('mf_6_custom_unknown')).to be_nil+ expect(schema.parse_sort('cf_6_custom_unknown')).to be_nilexpect(schema.parse_sort('name')).to be_nil- expect(schema.parse_sort('mf_6_custom_notes')).to be_nil+ expect(schema.parse_sort('cf_6_custom_notes')).to be_nilendend@@ -57,8 +57,8 @@ RSpec.describe Spree::SearchProvider::MetafieldSchema doit 'returns both ascending and descending variants' doexpect(schema.sort_ids).to contain_exactly(- 'mf_6_custom_color', '-mf_6_custom_color',- 'mf_6_custom_weight', '-mf_6_custom_weight'+ 'cf_6_custom_color', '-cf_6_custom_color',+ 'cf_6_custom_weight', '-cf_6_custom_weight')endend@@ -69,8 +69,8 @@ RSpec.describe Spree::SearchProvider::MetafieldSchema donamespace: 'custom', key: 'label', name: 'Material')expect(schema.sort_options).to include(- { id: 'mf_6_custom_label', label: "Material (#{Spree.t(:sort_a_to_z)})" },- { id: '-mf_6_custom_label', label: "Material (#{Spree.t(:sort_z_to_a)})" }+ { id: 'cf_6_custom_label', label: "Material (#{Spree.t(:sort_a_to_z)})" },+ { id: '-cf_6_custom_label', label: "Material (#{Spree.t(:sort_z_to_a)})" })end@@ -79,8 +79,8 @@ RSpec.describe Spree::SearchProvider::MetafieldSchema donamespace: 'custom', key: 'weight', name: 'Weight')expect(schema.sort_options).to include(- { id: 'mf_6_custom_weight', label: "Weight (#{Spree.t(:sort_low_to_high)})" },- { id: '-mf_6_custom_weight', label: "Weight (#{Spree.t(:sort_high_to_low)})" }+ { id: 'cf_6_custom_weight', label: "Weight (#{Spree.t(:sort_low_to_high)})" },+ { id: '-cf_6_custom_weight', label: "Weight (#{Spree.t(:sort_high_to_low)})" })end@@ -97,8 +97,8 @@ RSpec.describe Spree::SearchProvider::MetafieldSchema doSpree::Current.locale = 'pl'labels = schema.sort_options.index_by { |o| o[:id] }- expect(labels['mf_6_custom_weight'][:label]).to eq('Weight (od najniższej)')- expect(labels['-mf_6_custom_weight'][:label]).to eq('Weight (od najwyższej)')+ expect(labels['cf_6_custom_weight'][:label]).to eq('Weight (od najniższej)')+ expect(labels['-cf_6_custom_weight'][:label]).to eq('Weight (od najwyższej)')ensureI18n.locale = I18n.default_localeSpree::Current.locale = nil