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.

Fixed: legacy multi store method mapping should return an AR relation so (#14248)

Damian Legawiec73126e404608
diff --git a/spree/core/app/models/concerns/spree/legacy_multi_store_support.rb b/spree/core/app/models/concerns/spree/legacy_multi_store_support.rb
index f98ff8cf25..07767f51a1 100644
--- a/spree/core/app/models/concerns/spree/legacy_multi_store_support.rb
+++ b/spree/core/app/models/concerns/spree/legacy_multi_store_support.rb
@@ -9,12 +9,15 @@ module Spree
extend ActiveSupport::Concern
included do
+ # Legacy accessors for the many-to-many store relationship. These are deprecated
+ # and will be removed in Spree 6.0 once the models finish migrating to single-store ownership.
+ # @return [ActiveRecord::Relation<Spree::Store>] the single store wrapped in a relation, or an empty relation if no store is set
def stores
Spree::Deprecation.warn(
"#{self.class.base_class}#stores is deprecated. Please use #{self.class.base_class}#store instead. " \
'If you want to continue using multiple stores please install spree_multi_store gem'
)
- store ? [store] : []
+ store ? Spree::Store.where(id: store.id) : Spree::Store.none
end
def store_ids