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
Added Store#supported_locales
Damian Legawiec63d3b09ae309
diff --git a/core/app/models/spree/store.rb b/core/app/models/spree/store.rbindex 7756a5cd37..3372f03728 100644--- a/core/app/models/spree/store.rb+++ b/core/app/models/spree/store.rb@@ -57,7 +57,7 @@ module Spreedef supported_locales_list# TODO: add support of multiple supported languages to a single Store- @supported_locales_list ||= [default_locale].compact.uniq+ @supported_locales_list ||= (read_attribute(:supported_locales).to_s.split(',') << default_locale).compact.uniqenddef unique_namediff --git a/core/db/migrate/20191017121054_add_supported_currencies_to_store.rb b/core/db/migrate/20191017121054_add_supported_currencies_to_store.rbindex 9b9a2c450f..6a64d5cf1d 100644--- a/core/db/migrate/20191017121054_add_supported_currencies_to_store.rb+++ b/core/db/migrate/20191017121054_add_supported_currencies_to_store.rb@@ -2,6 +2,7 @@ class AddSupportedCurrenciesToStore < ActiveRecord::Migration[6.0]def changeunless column_exists?(:spree_stores, :supported_currencies)add_column :spree_stores, :supported_currencies, :string+ Spree::Store.reset_column_informationSpree::Store.all.each do |store|store.update_attribute(:supported_currencies, store.default_currency)enddiff --git a/core/db/migrate/20210205211040_add_supported_locales_to_spree_stores.rb b/core/db/migrate/20210205211040_add_supported_locales_to_spree_stores.rbnew file mode 100644index 0000000000..3ebb672dbf--- /dev/null+++ b/core/db/migrate/20210205211040_add_supported_locales_to_spree_stores.rb@@ -0,0 +1,11 @@+class AddSupportedLocalesToSpreeStores < ActiveRecord::Migration[6.0]+ def change+ unless column_exists?(:spree_stores, :supported_locales)+ add_column :spree_stores, :supported_locales, :string+ Spree::Store.reset_column_information+ Spree::Store.all.each do |store|+ store.update_attribute(:supported_locales, store.default_locale)+ end+ end+ end+enddiff --git a/core/spec/models/spree/store_spec.rb b/core/spec/models/spree/store_spec.rbindex 9d92965775..e715960a9a 100644--- a/core/spec/models/spree/store_spec.rb+++ b/core/spec/models/spree/store_spec.rb@@ -262,11 +262,11 @@ describe Spree::Store, type: :model dodescribe '#supported_locales_list' docontext 'with supported locale set' do- let(:store) { create(:store, default_locale: 'fr') }+ let(:store) { create(:store, default_locale: 'fr', supported_locales: 'fr,de') }it 'returns supported currencies list' doexpect(store.supported_locales_list).to be_an_instance_of(Array)- expect(store.supported_locales_list).to contain_exactly('fr')+ expect(store.supported_locales_list).to contain_exactly('fr', 'de')endend