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.

Use store.default_market for currency/locale instead of legacy store methods

Damian Legawiec1299fa0f5af2
diff --git a/spree/core/app/models/spree/search_provider/database.rb b/spree/core/app/models/spree/search_provider/database.rb
index 2b0ad6a652..0d5c364e33 100644
--- a/spree/core/app/models/spree/search_provider/database.rb
+++ b/spree/core/app/models/spree/search_provider/database.rb
@@ -55,7 +55,7 @@ module Spree
Spree::Api::V3::FiltersAggregator.new(
scope: scope,
- currency: Spree::Current.currency || store.default_currency,
+ currency: Spree::Current.currency || store.default_market&.currency,
category: category
).call
end
diff --git a/spree/core/app/models/spree/search_provider/meilisearch.rb b/spree/core/app/models/spree/search_provider/meilisearch.rb
index 6c89dbd327..ce52130dfd 100644
--- a/spree/core/app/models/spree/search_provider/meilisearch.rb
+++ b/spree/core/app/models/spree/search_provider/meilisearch.rb
@@ -298,11 +298,11 @@ module Spree
end
def locale
- Spree::Current.locale || store.default_locale || I18n.locale.to_s
+ Spree::Current.locale || store.default_market&.default_locale || I18n.locale.to_s
end
def currency
- Spree::Current.currency || store.default_currency
+ Spree::Current.currency || store.default_market&.currency
end
def valid_prefixed_id?(value)
diff --git a/spree/core/app/presenters/spree/search_provider/product_presenter.rb b/spree/core/app/presenters/spree/search_provider/product_presenter.rb
index 3cff8e6fc0..eb841a1124 100644
--- a/spree/core/app/presenters/spree/search_provider/product_presenter.rb
+++ b/spree/core/app/presenters/spree/search_provider/product_presenter.rb
@@ -22,9 +22,12 @@ module Spree
end
end
- # Fallback: if no markets, index with store defaults (only if product has a price)
- if documents.empty? && lowest_price(store.default_currency)
- documents << build_document(default_locale, store.default_currency, default_locale)
+ # Fallback for stores without markets (legacy/test)
+ if documents.empty?
+ fallback_currency = store.default_market&.currency || store.supported_currencies_list.first&.iso_code
+ if fallback_currency && lowest_price(fallback_currency)
+ documents << build_document(default_locale, fallback_currency, default_locale)
+ end
end
documents
@@ -77,7 +80,7 @@ module Spree
end
def default_locale
- @default_locale ||= store.default_locale || I18n.default_locale.to_s
+ @default_locale ||= store.default_market&.default_locale || I18n.default_locale.to_s
end
# Read a translated attribute with fallback to default locale.