Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Removed multi_search aliases scheduled for removal in 6.0 (#14795)

Damian Legawiec3dcc8e9b66b8
diff --git a/.changeset/dashboard-search-param.md b/.changeset/dashboard-search-param.md
new file mode 100644
index 0000000000..1a582ed07f
--- /dev/null
+++ b/.changeset/dashboard-search-param.md
@@ -0,0 +1,5 @@
+---
+"@spree/dashboard": patch
+---
+
+The orders and products tables now search with the `search` filter, since the old `multi_search` alias was removed from the Admin API.
diff --git a/docs/api-reference/admin-api/querying.mdx b/docs/api-reference/admin-api/querying.mdx
index 55ffb323f3..dee135c3fe 100644
--- a/docs/api-reference/admin-api/querying.mdx
+++ b/docs/api-reference/admin-api/querying.mdx
@@ -131,7 +131,7 @@ Some resources expose convenience search scopes:
|---|---|---|
| Customers | `search` | Full-text over email + first/last name |
| Customers | `with_min_total_spent` | Filter by lifetime spend |
-| Orders | `multi_search` | Number + email full-text |
+| Orders | `search` | Number, purchase order and customer name (partial match); email (exact match) |
<CodeGroup>
diff --git a/docs/developer/upgrades/5.6-to-6.0.mdx b/docs/developer/upgrades/5.6-to-6.0.mdx
index 32d58addb7..48d41dcd05 100644
--- a/docs/developer/upgrades/5.6-to-6.0.mdx
+++ b/docs/developer/upgrades/5.6-to-6.0.mdx
@@ -494,6 +494,7 @@ These were deprecated in 5.x and are **gone now** — there is no bridge, so cal
| `Spree::Image::Configuration::ActiveStorage` | deleted — an empty no-op module; all logic lives in `Spree::Asset` |
| `Spree::OrderRouting::Strategy::Legacy` | `Spree::OrderRouting::Strategy::Rules` (see below) |
| `private_metafields` association | read `custom_fields` and filter, or query `Spree::CustomField.admin_only` |
+| `multi_search` (`Product`, `Variant`, `Order`, customers; also `q[multi_search]` in the Admin API) and `Searchable.sanitize_query_for_multi_search` / `.multi_search_condition` | `search` / `q[search]`, `sanitize_query_for_search` / `search_condition`. Saved exports or links still using `multi_search` lose their filter |
### Custom fields replace metafields
diff --git a/docs/plans/6.0-admin-spa.md b/docs/plans/6.0-admin-spa.md
index 9434c23036..1613874340 100644
--- a/docs/plans/6.0-admin-spa.md
+++ b/docs/plans/6.0-admin-spa.md
@@ -236,7 +236,7 @@ import { formatRelativeTime } from '@/lib/formatters'
defineTable('orders', {
title: 'Orders',
- searchParam: 'multi_search',
+ searchParam: 'search',
searchPlaceholder: 'Search orders...',
defaultSort: { field: 'completed_at', direction: 'desc' },
emptyMessage: 'No orders found',
diff --git a/packages/dashboard/src/tables/orders.tsx b/packages/dashboard/src/tables/orders.tsx
index 8df9bcc0fe..13688d1a88 100644
--- a/packages/dashboard/src/tables/orders.tsx
+++ b/packages/dashboard/src/tables/orders.tsx
@@ -22,7 +22,7 @@ defineTable('orders', {
title: i18n.t('admin.nav.orders'),
docsPath: 'orders/processing-orders',
description: i18n.t('admin.table_descriptions.orders'),
- searchParam: 'multi_search',
+ searchParam: 'search',
searchPlaceholder: i18n.t('admin.orders.table.search_placeholder'),
defaultSort: { field: 'completed_at', direction: 'desc' },
emptyIcon: <ShoppingCartIcon className="size-8 text-muted-foreground" />,
diff --git a/packages/dashboard/src/tables/products.tsx b/packages/dashboard/src/tables/products.tsx
index 4233ab369e..71260ca5e9 100644
--- a/packages/dashboard/src/tables/products.tsx
+++ b/packages/dashboard/src/tables/products.tsx
@@ -13,7 +13,7 @@ defineTable('products', {
docsPath: 'products/creating-products',
description: i18n.t('admin.table_descriptions.products'),
title: i18n.t('admin.nav.products'),
- searchParam: 'multi_search',
+ searchParam: 'search',
searchPlaceholder: i18n.t('admin.common.search_placeholder'),
defaultSort: { field: 'updated_at', direction: 'desc' },
emptyIcon: <PackageIcon className="size-8 text-muted-foreground" />,
diff --git a/spree/core/app/models/concerns/spree/customer_methods.rb b/spree/core/app/models/concerns/spree/customer_methods.rb
index 7a41f0a4f7..1addd60536 100644
--- a/spree/core/app/models/concerns/spree/customer_methods.rb
+++ b/spree/core/app/models/concerns/spree/customer_methods.rb
@@ -184,13 +184,10 @@ module Spree
where(conditions.reduce(:or))
end
- # Backward compatibility alias — remove in Spree 6.0
- def self.multi_search(query) = search(query)
-
self.whitelisted_ransackable_associations = %w[bill_address ship_address addresses tags spree_roles orders customer_groups]
self.whitelisted_ransackable_attributes = %w[id email first_name last_name phone accepts_email_marketing
created_at updated_at last_sign_in_at]
- self.whitelisted_ransackable_scopes = %w[search multi_search with_min_total_spent with_standing_for_company
+ self.whitelisted_ransackable_scopes = %w[search with_min_total_spent with_standing_for_company
anonymized]
# Two-state scope: see Spree::Base.ransack_flag? for why the cast is
diff --git a/spree/core/app/models/concerns/spree/searchable.rb b/spree/core/app/models/concerns/spree/searchable.rb
index d34c0d7781..53e10f91c0 100644
--- a/spree/core/app/models/concerns/spree/searchable.rb
+++ b/spree/core/app/models/concerns/spree/searchable.rb
@@ -25,10 +25,6 @@ module Spree
model_class.arel_table[attribute.to_sym].lower.matches("%#{escaped}%", '\\')
end
end
-
- # Backward compatibility aliases — remove in Spree 6.0
- def self.sanitize_query_for_multi_search(query) = sanitize_query_for_search(query)
- def self.multi_search_condition(model_class, attribute, query) = search_condition(model_class, attribute, query)
end
end
end
diff --git a/spree/core/app/models/spree/order.rb b/spree/core/app/models/spree/order.rb
index d11cd787f5..6f91e6c45a 100644
--- a/spree/core/app/models/spree/order.rb
+++ b/spree/core/app/models/spree/order.rb
@@ -150,7 +150,7 @@ module Spree
total item_total total_quantity considered_risky channel_id currency coupon_code customer_id seller_id
order_group_id po_number
]
- self.whitelisted_ransackable_scopes = %w[complete incomplete refunded partially_refunded search multi_search]
+ self.whitelisted_ransackable_scopes = %w[complete incomplete refunded partially_refunded search]
# A seller never sees the buyer's email, and a company member filtering the
# company's orders must not learn a colleague's; the risk flag and coupon
# are back-office data. `search` matches on the email too.
@@ -159,8 +159,8 @@ module Spree
seller: %w[email considered_risky coupon_code]
}
self.private_ransackable_scopes = {
- store: %w[search multi_search],
- seller: %w[search multi_search]
+ store: %w[search],
+ seller: %w[search]
}
# Set to false on admin-initiated flows to suppress customer-facing emails.
@@ -353,9 +353,6 @@ module Spree
left_joins(:bill_address).where(arel_table[:email].lower.eq(query.downcase)).or(where(conditions.reduce(:or)))
end
- # Backward compatibility alias — remove in Spree 6.0
- def self.multi_search(query) = search(query)
-
# Find an order by prefixed ID first, falling back to number, then integer id for backwards compatibility
# @param param [String] the prefixed ID, number, or integer id to search for
# @return [Spree::Order, nil] the found order or nil
diff --git a/spree/core/app/models/spree/product.rb b/spree/core/app/models/spree/product.rb
index dd2a1a6f9a..938c8fe3d7 100644
--- a/spree/core/app/models/spree/product.rb
+++ b/spree/core/app/models/spree/product.rb
@@ -302,9 +302,6 @@ module Spree
where(id: (product_ids + custom_field_ids).uniq.compact)
}
- # Backward compatibility alias — remove in Spree 6.0
- scope :multi_search, ->(*args) { search(*args) }
-
scope :archivable, -> { where(status: %w[active draft]) }
scope :by_source, ->(source) { send(source) }
scope :published, -> { where(status: 'active') }
@@ -375,7 +372,7 @@ module Spree
self.storefront_ransackable_associations = %w[tags categories collections]
self.whitelisted_ransackable_scopes = %w[not_discontinued search_by_name in_taxon in_category in_categories in_collection price_between
price_lte price_gte
- search multi_search in_stock out_of_stock with_option_value_ids
+ search in_stock out_of_stock with_option_value_ids
ascend_by_price descend_by_price]
diff --git a/spree/core/app/models/spree/variant.rb b/spree/core/app/models/spree/variant.rb
index 07db524c82..bb127f7d47 100644
--- a/spree/core/app/models/spree/variant.rb
+++ b/spree/core/app/models/spree/variant.rb
@@ -289,9 +289,6 @@ module Spree
relation.where(conditions.reduce(:or)).distinct
end
- # Backward compatibility alias — remove in Spree 6.0
- scope :multi_search, ->(*args) { search(*args) }
-
# FIXME: cost price should be represented with DisplayMoney class
LOCALIZED_NUMBERS = %w(cost_price weight depth width height)
diff --git a/spree/core/spec/models/concerns/spree/ransackable_attributes_spec.rb b/spree/core/spec/models/concerns/spree/ransackable_attributes_spec.rb
index d6d0e72adf..6d3c64571d 100644
--- a/spree/core/spec/models/concerns/spree/ransackable_attributes_spec.rb
+++ b/spree/core/spec/models/concerns/spree/ransackable_attributes_spec.rb
@@ -31,7 +31,7 @@ RSpec.describe Spree::RansackableAttributes do
it "drops the buyer's email and the searches that match on it" do
expect(Spree::Order.ransackable_attributes(:seller)).not_to include('email')
- expect(Spree::Order.ransackable_scopes(:seller)).not_to include('search', 'multi_search')
+ expect(Spree::Order.ransackable_scopes(:seller)).not_to include('search')
end
end
end
diff --git a/spree/core/spec/models/spree/export_spec.rb b/spree/core/spec/models/spree/export_spec.rb
index fa622000d5..3eb99c6a26 100644
--- a/spree/core/spec/models/spree/export_spec.rb
+++ b/spree/core/spec/models/spree/export_spec.rb
@@ -307,7 +307,7 @@ RSpec.describe Spree::Export, :job, type: :model do
it 'exports a searched product list' do
create(:product, name: 'Findable Widget')
product_export = Spree::Exports::Products.create!(
- store: store, user: user, format: 'csv', search_params: { multi_search: 'Findable' }.to_json
+ store: store, user: user, format: 'csv', search_params: { search: 'Findable' }.to_json
)
expect { product_export.generate }.to change(product_export.attachment, :attached?).from(false).to(true)