spree_core 4.5.5 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/finders/spree/option_values/find_available.rb +1 -1
- data/app/finders/spree/product_properties/find_available.rb +1 -1
- data/app/finders/spree/products/find.rb +20 -12
- data/app/finders/spree/taxons/find.rb +10 -7
- data/app/helpers/spree/base_helper.rb +2 -2
- data/app/models/concerns/spree/product_scopes.rb +27 -23
- data/app/models/concerns/spree/translatable_resource.rb +25 -0
- data/app/models/concerns/spree/translatable_resource_scopes.rb +24 -0
- data/app/models/concerns/spree/translatable_resource_slug.rb +17 -0
- data/app/models/spree/address.rb +1 -1
- data/app/models/spree/asset.rb +1 -1
- data/app/models/spree/base.rb +1 -0
- data/app/models/spree/calculator/default_tax.rb +1 -1
- data/app/models/spree/cms_page.rb +1 -1
- data/app/models/spree/cms_section.rb +1 -1
- data/app/models/spree/credit_card.rb +1 -1
- data/app/models/spree/customer_return.rb +2 -2
- data/app/models/spree/data_feed/google.rb +15 -0
- data/app/models/spree/data_feed.rb +40 -0
- data/app/models/spree/line_item.rb +1 -1
- data/app/models/spree/option_type.rb +5 -1
- data/app/models/spree/option_value.rb +5 -1
- data/app/models/spree/order/store_credit.rb +0 -8
- data/app/models/spree/order.rb +3 -3
- data/app/models/spree/payment.rb +3 -3
- data/app/models/spree/payment_method.rb +1 -1
- data/app/models/spree/payment_source.rb +1 -1
- data/app/models/spree/price.rb +1 -1
- data/app/models/spree/product.rb +44 -13
- data/app/models/spree/product_property.rb +12 -3
- data/app/models/spree/promotion.rb +2 -2
- data/app/models/spree/property.rb +8 -2
- data/app/models/spree/prototype.rb +1 -1
- data/app/models/spree/refund.rb +1 -1
- data/app/models/spree/reimbursement.rb +1 -1
- data/app/models/spree/return_authorization.rb +1 -1
- data/app/models/spree/shipment.rb +5 -5
- data/app/models/spree/shipping_method.rb +1 -1
- data/app/models/spree/stock/estimator.rb +1 -1
- data/app/models/spree/stock_item.rb +1 -1
- data/app/models/spree/stock_transfer.rb +3 -3
- data/app/models/spree/store.rb +20 -1
- data/app/models/spree/store_credit.rb +1 -1
- data/app/models/spree/taxon.rb +23 -7
- data/app/models/spree/taxonomy.rb +5 -1
- data/app/models/spree/variant.rb +6 -9
- data/app/services/spree/data_feeds/google/optional_attributes.rb +23 -0
- data/app/services/spree/data_feeds/google/optional_sub_attributes.rb +21 -0
- data/app/services/spree/data_feeds/google/products_list.rb +14 -0
- data/app/services/spree/data_feeds/google/required_attributes.rb +67 -0
- data/app/services/spree/data_feeds/google/rss.rb +107 -0
- data/app/sorters/spree/products/sort.rb +23 -0
- data/brakeman.ignore +326 -18
- data/config/initializers/friendly_id.rb +2 -0
- data/config/initializers/mobility.rb +18 -0
- data/config/locales/en.yml +1 -0
- data/db/migrate/20220706112554_create_product_name_and_description_translations_for_mobility_table_backend.rb +27 -0
- data/db/migrate/20220715083542_create_spree_product_translations_for_mobility.rb +7 -0
- data/db/migrate/20220715120222_change_product_name_null_to_true.rb +5 -0
- data/db/migrate/20220718100743_create_spree_taxon_name_and_description_translations_for_mobility_table_backend.rb +27 -0
- data/db/migrate/20220718100948_change_taxon_name_null_to_true.rb +5 -0
- data/db/migrate/20220802070609_add_locale_to_friendly_id_slugs.rb +11 -0
- data/db/migrate/20220802073225_create_spree_product_slug_translations_for_mobility_table_backend.rb +5 -0
- data/db/migrate/20220804073928_transfer_data_to_translatable_tables.rb +66 -0
- data/db/migrate/20221215151408_add_selected_locale_to_spree_users.rb +8 -0
- data/db/migrate/20221219123957_add_deleted_at_to_product_translations.rb +6 -0
- data/db/migrate/20221220133432_add_uniqueness_constraint_to_product_translations.rb +5 -0
- data/db/migrate/20221229132350_create_spree_data_feed_settings.rb +14 -0
- data/db/migrate/20230103144439_create_option_type_translations.rb +26 -0
- data/db/migrate/20230103151034_create_option_value_translations.rb +26 -0
- data/db/migrate/20230109084253_create_product_property_translations.rb +25 -0
- data/db/migrate/20230109094907_transfer_options_data_to_translatable_tables.rb +58 -0
- data/db/migrate/20230109105943_create_property_translations.rb +26 -0
- data/db/migrate/20230109110840_transfer_property_data_to_translatable_tables.rb +59 -0
- data/db/migrate/20230110142344_backfill_friendly_id_slug_locale.rb +15 -0
- data/db/migrate/20230111121534_add_additional_taxon_translation_fields.rb +8 -0
- data/db/migrate/20230111122511_transfer_product_and_taxon_data_to_translatable_tables.rb +82 -0
- data/db/migrate/20230117115531_create_taxonomy_translations.rb +24 -0
- data/db/migrate/20230117120430_allow_null_taxonomy_name.rb +5 -0
- data/db/migrate/20230117121303_transfer_taxonomy_data_to_translatable_tables.rb +11 -0
- data/db/migrate/20230210142732_create_store_translations.rb +50 -0
- data/db/migrate/20230210142849_transfer_store_data_to_translatable_tables.rb +11 -0
- data/db/migrate/20230210230434_add_deleted_at_to_store_translations.rb +6 -0
- data/db/migrate/20230415155958_rename_data_feed_settings_table.rb +5 -0
- data/db/migrate/20230415160828_rename_data_feed_table_columns.rb +7 -0
- data/db/migrate/20230415161226_add_indexes_to_data_feeds_table.rb +5 -0
- data/db/migrate/20230512094803_rename_data_feeds_column_provider_to_type.rb +5 -0
- data/db/migrate/20230514162157_add_index_on_locale_and_permalink_to_spree_taxons.rb +5 -0
- data/lib/spree/core/configuration.rb +1 -0
- data/lib/spree/core/controller_helpers/locale.rb +26 -2
- data/lib/spree/core/dependencies.rb +70 -94
- data/lib/spree/core/dependencies_helper.rb +19 -0
- data/lib/spree/core/engine.rb +6 -1
- data/lib/spree/core/product_duplicator.rb +1 -1
- data/lib/spree/core/product_filters.rb +7 -4
- data/lib/spree/core/search/base.rb +1 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +2 -0
- data/lib/spree/permitted_attributes.rb +1 -1
- data/lib/spree/testing_support/factories/google_data_feed_factory.rb +8 -0
- data/lib/spree/testing_support/factories/product_factory.rb +6 -0
- data/lib/spree/testing_support/factories/product_translation_factory.rb +6 -0
- data/lib/spree/testing_support/factories/store_factory.rb +1 -0
- data/lib/spree/testing_support/factories/variant_factory.rb +4 -0
- data/lib/spree/translation_migrations.rb +40 -0
- data/spree_core.gemspec +3 -0
- metadata +93 -6
- data/app/models/spree/order_contents.rb +0 -31
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class CreateOptionValueTranslations < ActiveRecord::Migration[6.1]
|
|
2
|
+
def change
|
|
3
|
+
if ActiveRecord::Base.connection.table_exists? 'spree_option_value_translations'
|
|
4
|
+
# manually check for index since Rails if_exists does not always work correctly
|
|
5
|
+
if ActiveRecord::Migration.connection.index_exists?(:spree_option_value_translations, :spree_option_value_id)
|
|
6
|
+
remove_index :spree_option_value_translations, column: :spree_option_value_id, if_exists: true
|
|
7
|
+
end
|
|
8
|
+
else
|
|
9
|
+
create_table :spree_option_value_translations do |t|
|
|
10
|
+
|
|
11
|
+
# Translated attribute(s)
|
|
12
|
+
t.string :name
|
|
13
|
+
t.string :presentation
|
|
14
|
+
|
|
15
|
+
t.string :locale, null: false
|
|
16
|
+
t.references :spree_option_value, null: false, foreign_key: true, index: false
|
|
17
|
+
|
|
18
|
+
t.timestamps
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
add_index :spree_option_value_translations, :locale, name: :index_spree_option_value_translations_on_locale
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
add_index :spree_option_value_translations, [:spree_option_value_id, :locale], name: :unique_option_value_id_per_locale, unique: true
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
class CreateProductPropertyTranslations < ActiveRecord::Migration[6.1]
|
|
2
|
+
def change
|
|
3
|
+
if ActiveRecord::Base.connection.table_exists? 'spree_product_property_translations'
|
|
4
|
+
# manually check for index since Rails if_exists does not always work correctly
|
|
5
|
+
if ActiveRecord::Migration.connection.index_exists?(:spree_product_property_translations, :spree_product_property_id)
|
|
6
|
+
remove_index :spree_product_property_translations, column: :spree_product_property_id, if_exists: true
|
|
7
|
+
end
|
|
8
|
+
else
|
|
9
|
+
create_table :spree_product_property_translations do |t|
|
|
10
|
+
# Translated attribute(s)
|
|
11
|
+
t.string :value
|
|
12
|
+
t.string :filter_param
|
|
13
|
+
|
|
14
|
+
t.string :locale, null: false
|
|
15
|
+
t.references :spree_product_property, null: false, foreign_key: true, index: false
|
|
16
|
+
|
|
17
|
+
t.timestamps
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
add_index :spree_product_property_translations, :locale, name: :index_spree_product_property_translations_on_locale
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
add_index :spree_product_property_translations, [:spree_product_property_id, :locale], name: :unique_product_property_id_per_locale, unique: true
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
class TransferOptionsDataToTranslatableTables < ActiveRecord::Migration[6.1]
|
|
2
|
+
DEFAULT_LOCALE = 'en'
|
|
3
|
+
|
|
4
|
+
def up
|
|
5
|
+
# Only transfer data if translation tables are being newly created / no translations exist
|
|
6
|
+
# Otherwise, assume translation data is already in place from spree_globalize
|
|
7
|
+
|
|
8
|
+
# Option Types
|
|
9
|
+
if not Spree::OptionType::Translation.exists?
|
|
10
|
+
ActiveRecord::Base.connection.execute("
|
|
11
|
+
INSERT INTO spree_option_type_translations (name, presentation, locale, spree_option_type_id, created_at, updated_at)
|
|
12
|
+
SELECT name, presentation, '#{DEFAULT_LOCALE}', id, created_at, updated_at
|
|
13
|
+
FROM spree_option_types;
|
|
14
|
+
")
|
|
15
|
+
ActiveRecord::Base.connection.execute("
|
|
16
|
+
UPDATE spree_option_types
|
|
17
|
+
SET name=null, presentation=null;
|
|
18
|
+
")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Option Values
|
|
22
|
+
if not Spree::OptionValue::Translation.exists?
|
|
23
|
+
ActiveRecord::Base.connection.execute("
|
|
24
|
+
INSERT INTO spree_option_value_translations (name, presentation, locale, spree_option_value_id, created_at, updated_at)
|
|
25
|
+
SELECT name, presentation, '#{DEFAULT_LOCALE}', id, created_at, updated_at
|
|
26
|
+
FROM spree_option_values;
|
|
27
|
+
")
|
|
28
|
+
ActiveRecord::Base.connection.execute("
|
|
29
|
+
UPDATE spree_option_values
|
|
30
|
+
SET name=null, presentation=null;
|
|
31
|
+
")
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def down
|
|
36
|
+
# Option Types
|
|
37
|
+
ActiveRecord::Base.connection.execute("
|
|
38
|
+
UPDATE spree_option_types as option_types
|
|
39
|
+
SET (name, presentation) = (t_option_types.name, t_option_types.presentation)
|
|
40
|
+
FROM spree_option_type_translations AS t_option_types
|
|
41
|
+
WHERE t_option_types.spree_option_type_id = option_types.id;
|
|
42
|
+
")
|
|
43
|
+
ActiveRecord::Base.connection.execute("
|
|
44
|
+
TRUNCATE TABLE spree_option_type_translations;
|
|
45
|
+
")
|
|
46
|
+
|
|
47
|
+
# Option Values
|
|
48
|
+
ActiveRecord::Base.connection.execute("
|
|
49
|
+
UPDATE spree_option_values as option_values
|
|
50
|
+
SET (name, presentation) = (t_option_values.name, t_option_values.presentation)
|
|
51
|
+
FROM spree_option_value_translations AS t_option_values
|
|
52
|
+
WHERE t_option_values.spree_option_value_id = option_values.id;
|
|
53
|
+
")
|
|
54
|
+
ActiveRecord::Base.connection.execute("
|
|
55
|
+
TRUNCATE TABLE spree_option_value_translations;
|
|
56
|
+
")
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class CreatePropertyTranslations < ActiveRecord::Migration[6.1]
|
|
2
|
+
def change
|
|
3
|
+
if ActiveRecord::Base.connection.table_exists?('spree_property_translations')
|
|
4
|
+
# manually check for index since Rails if_exists does not always work correctly
|
|
5
|
+
if ActiveRecord::Migration.connection.index_exists?(:spree_property_translations, :spree_property_id)
|
|
6
|
+
remove_index :spree_property_translations, column: :spree_property_id, if_exists: true
|
|
7
|
+
end
|
|
8
|
+
else
|
|
9
|
+
create_table :spree_property_translations do |t|
|
|
10
|
+
# Translated attribute(s)
|
|
11
|
+
t.string :name
|
|
12
|
+
t.string :presentation
|
|
13
|
+
t.string :filter_param
|
|
14
|
+
|
|
15
|
+
t.string :locale, null: false
|
|
16
|
+
t.references :spree_property, null: false, foreign_key: true, index: false
|
|
17
|
+
|
|
18
|
+
t.timestamps
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
add_index :spree_property_translations, :locale, name: :index_spree_property_translations_on_locale
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
add_index :spree_property_translations, [:spree_property_id, :locale], name: :unique_property_id_per_locale, unique: true
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
class TransferPropertyDataToTranslatableTables < ActiveRecord::Migration[6.1]
|
|
2
|
+
DEFAULT_LOCALE = 'en'
|
|
3
|
+
|
|
4
|
+
def up
|
|
5
|
+
# Properties
|
|
6
|
+
change_column_null :spree_properties, :presentation, true
|
|
7
|
+
|
|
8
|
+
if not Spree::Property::Translation.exists?
|
|
9
|
+
ActiveRecord::Base.connection.execute("
|
|
10
|
+
INSERT INTO spree_property_translations (name, presentation, filter_param, locale, spree_property_id, created_at, updated_at)
|
|
11
|
+
SELECT name, presentation, filter_param, '#{DEFAULT_LOCALE}', id, created_at, updated_at
|
|
12
|
+
FROM spree_properties;
|
|
13
|
+
")
|
|
14
|
+
ActiveRecord::Base.connection.execute("
|
|
15
|
+
UPDATE spree_properties
|
|
16
|
+
SET name=null, presentation=null, filter_param=null;
|
|
17
|
+
")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Product Properties
|
|
21
|
+
if not Spree::ProductProperty::Translation.exists?
|
|
22
|
+
ActiveRecord::Base.connection.execute("
|
|
23
|
+
INSERT INTO spree_product_property_translations (value, filter_param, locale, spree_product_property_id, created_at, updated_at)
|
|
24
|
+
SELECT value, filter_param, '#{DEFAULT_LOCALE}', id, created_at, updated_at
|
|
25
|
+
FROM spree_product_properties;
|
|
26
|
+
")
|
|
27
|
+
ActiveRecord::Base.connection.execute("
|
|
28
|
+
UPDATE spree_product_properties
|
|
29
|
+
SET value=null, filter_param=null;
|
|
30
|
+
")
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def down
|
|
35
|
+
# Properties
|
|
36
|
+
change_column_null :spree_properties, :presentation, false
|
|
37
|
+
|
|
38
|
+
ActiveRecord::Base.connection.execute("
|
|
39
|
+
UPDATE spree_properties AS properties
|
|
40
|
+
SET (name, presentation, filter_param) = (t_properties.name, t_properties.presentation, t_properties.filter_param)
|
|
41
|
+
FROM spree_property_translations AS t_properties
|
|
42
|
+
WHERE t_properties.spree_property_id = properties.id;
|
|
43
|
+
")
|
|
44
|
+
ActiveRecord::Base.connection.execute("
|
|
45
|
+
TRUNCATE TABLE spree_property_translations;
|
|
46
|
+
")
|
|
47
|
+
|
|
48
|
+
# Product Properties
|
|
49
|
+
ActiveRecord::Base.connection.execute("
|
|
50
|
+
UPDATE spree_product_properties AS product_properties
|
|
51
|
+
SET (value, filter_param) = (t_product_properties.value, t_product_properties.filter_param)
|
|
52
|
+
FROM spree_product_property_translations AS t_product_properties
|
|
53
|
+
WHERE t_product_properties.spree_product_property_id = product_properties.id;
|
|
54
|
+
")
|
|
55
|
+
ActiveRecord::Base.connection.execute("
|
|
56
|
+
TRUNCATE TABLE spree_product_property_translations;
|
|
57
|
+
")
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class BackfillFriendlyIdSlugLocale < ActiveRecord::Migration[6.1]
|
|
2
|
+
DEFAULT_LOCALE = 'en'
|
|
3
|
+
|
|
4
|
+
def up
|
|
5
|
+
ActiveRecord::Base.connection.execute("
|
|
6
|
+
UPDATE friendly_id_slugs SET locale = '#{DEFAULT_LOCALE}'
|
|
7
|
+
")
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def down
|
|
11
|
+
ActiveRecord::Base.connection.execute("
|
|
12
|
+
UPDATE friendly_id_slugs SET locale = NULL
|
|
13
|
+
")
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
class AddAdditionalTaxonTranslationFields < ActiveRecord::Migration[6.1]
|
|
2
|
+
def change
|
|
3
|
+
add_column :spree_taxon_translations, :meta_title, :string, if_not_exists: true
|
|
4
|
+
add_column :spree_taxon_translations, :meta_description, :string, if_not_exists: true
|
|
5
|
+
add_column :spree_taxon_translations, :meta_keywords, :string, if_not_exists: true
|
|
6
|
+
add_column :spree_taxon_translations, :permalink, :string, if_not_exists: true
|
|
7
|
+
end
|
|
8
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
class TransferProductAndTaxonDataToTranslatableTables < ActiveRecord::Migration[6.1]
|
|
2
|
+
DEFAULT_LOCALE = 'en'
|
|
3
|
+
PRODUCTS_TABLE = 'spree_products'
|
|
4
|
+
PRODUCT_TRANSLATIONS_TABLE = 'spree_product_translations'
|
|
5
|
+
TAXONS_TABLE = 'spree_taxons'
|
|
6
|
+
TAXON_TRANSLATIONS_TABLE = 'spree_taxon_translations'
|
|
7
|
+
|
|
8
|
+
def up
|
|
9
|
+
# Only transfer data if translation tables are being newly created / no translations exist
|
|
10
|
+
# Otherwise, assume translation data is already in place from spree_globalize
|
|
11
|
+
|
|
12
|
+
# Products
|
|
13
|
+
if not Spree::Product::Translation.exists?
|
|
14
|
+
ActiveRecord::Base.connection.execute("
|
|
15
|
+
INSERT INTO #{PRODUCT_TRANSLATIONS_TABLE} (name, description, locale, spree_product_id, created_at, updated_at, meta_description, meta_keywords, meta_title, slug)
|
|
16
|
+
SELECT name, description, '#{DEFAULT_LOCALE}' as locale, id, created_at, updated_at, meta_description, meta_keywords, meta_title, slug FROM #{PRODUCTS_TABLE};
|
|
17
|
+
")
|
|
18
|
+
ActiveRecord::Base.connection.execute("
|
|
19
|
+
UPDATE #{PRODUCTS_TABLE}
|
|
20
|
+
SET name=null, description=null, meta_description=null, meta_keywords=null, meta_title=null, slug=null;
|
|
21
|
+
")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Taxons
|
|
25
|
+
if not Spree::Taxon::Translation.exists?
|
|
26
|
+
ActiveRecord::Base.connection.execute("
|
|
27
|
+
INSERT INTO #{TAXON_TRANSLATIONS_TABLE} (name, description, meta_title, meta_description, meta_keywords, permalink, locale, spree_taxon_id, created_at, updated_at)
|
|
28
|
+
SELECT name, description, meta_title, meta_description, meta_keywords, permalink, '#{DEFAULT_LOCALE}' as locale, id, created_at, updated_at FROM #{TAXONS_TABLE};
|
|
29
|
+
")
|
|
30
|
+
ActiveRecord::Base.connection.execute("
|
|
31
|
+
UPDATE #{TAXONS_TABLE}
|
|
32
|
+
SET name=null, description=null, meta_title=null, meta_description=null, meta_keywords=null, permalink=null;
|
|
33
|
+
")
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def down
|
|
38
|
+
ActiveRecord::Base.connection.execute("
|
|
39
|
+
UPDATE #{PRODUCTS_TABLE} as products
|
|
40
|
+
SET (name,
|
|
41
|
+
description,
|
|
42
|
+
meta_description,
|
|
43
|
+
meta_keywords,
|
|
44
|
+
meta_title,
|
|
45
|
+
slug) =
|
|
46
|
+
(t_products.name,
|
|
47
|
+
t_products.description,
|
|
48
|
+
t_products.meta_description,
|
|
49
|
+
t_products.meta_keywords,
|
|
50
|
+
t_products.meta_title,
|
|
51
|
+
t_products.slug)
|
|
52
|
+
FROM #{PRODUCT_TRANSLATIONS_TABLE} AS t_products
|
|
53
|
+
WHERE t_products.spree_product_id = products.id
|
|
54
|
+
")
|
|
55
|
+
|
|
56
|
+
ActiveRecord::Base.connection.execute("
|
|
57
|
+
TRUNCATE TABLE #{PRODUCT_TRANSLATIONS_TABLE}
|
|
58
|
+
")
|
|
59
|
+
|
|
60
|
+
ActiveRecord::Base.connection.execute("
|
|
61
|
+
UPDATE #{TAXONS_TABLE} as taxons
|
|
62
|
+
SET (name,
|
|
63
|
+
description,
|
|
64
|
+
meta_title,
|
|
65
|
+
meta_description,
|
|
66
|
+
meta_keywords,
|
|
67
|
+
permalink) =
|
|
68
|
+
(t_taxons.name,
|
|
69
|
+
t_taxons.description,
|
|
70
|
+
t_taxons.meta_title,
|
|
71
|
+
t_taxons.meta_description,
|
|
72
|
+
t_taxons.meta_keywords,
|
|
73
|
+
t_taxons.permalink)
|
|
74
|
+
FROM #{TAXON_TRANSLATIONS_TABLE} AS t_taxons
|
|
75
|
+
WHERE t_taxons.spree_taxon_id = taxons.id
|
|
76
|
+
")
|
|
77
|
+
|
|
78
|
+
ActiveRecord::Base.connection.execute("
|
|
79
|
+
TRUNCATE TABLE #{TAXON_TRANSLATIONS_TABLE}
|
|
80
|
+
")
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class CreateTaxonomyTranslations < ActiveRecord::Migration[6.1]
|
|
2
|
+
def change
|
|
3
|
+
if ActiveRecord::Base.connection.table_exists?('spree_taxonomy_translations')
|
|
4
|
+
# manually check for index since Rails if_exists does not always work correctly
|
|
5
|
+
if ActiveRecord::Migration.connection.index_exists?(:spree_taxonomy_translations, :spree_taxonomy_id)
|
|
6
|
+
remove_index :spree_taxonomy_translations, column: :spree_taxonomy_id, if_exists: true
|
|
7
|
+
end
|
|
8
|
+
else
|
|
9
|
+
create_table :spree_taxonomy_translations do |t|
|
|
10
|
+
# Translated attribute(s)
|
|
11
|
+
t.string :name
|
|
12
|
+
|
|
13
|
+
t.string :locale, null: false
|
|
14
|
+
t.references :spree_taxonomy, null: false, foreign_key: true, index: false
|
|
15
|
+
|
|
16
|
+
t.timestamps null: false
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
add_index :spree_taxonomy_translations, :locale, name: :index_spree_taxonomy_translations_on_locale
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
add_index :spree_taxonomy_translations, [:spree_taxonomy_id, :locale], name: :index_spree_taxonomy_translations_on_spree_taxonomy_id_locale, unique: true
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class TransferTaxonomyDataToTranslatableTables < ActiveRecord::Migration[6.1]
|
|
2
|
+
TRANSLATION_MIGRATION = Spree::TranslationMigrations.new(Spree::Taxonomy, 'en')
|
|
3
|
+
|
|
4
|
+
def up
|
|
5
|
+
TRANSLATION_MIGRATION.transfer_translation_data
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def down
|
|
9
|
+
TRANSLATION_MIGRATION.revert_translation_data_transfer
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
class CreateStoreTranslations < ActiveRecord::Migration[6.1]
|
|
2
|
+
def change
|
|
3
|
+
if ActiveRecord::Base.connection.table_exists?('spree_store_translations')
|
|
4
|
+
add_new_translation_columns_to_globalize_table
|
|
5
|
+
else
|
|
6
|
+
create_table :spree_store_translations do |t|
|
|
7
|
+
# Translated attribute(s)
|
|
8
|
+
t.string :name
|
|
9
|
+
t.text :meta_description
|
|
10
|
+
t.text :meta_keywords
|
|
11
|
+
t.string :seo_title
|
|
12
|
+
t.string :facebook
|
|
13
|
+
t.string :twitter
|
|
14
|
+
t.string :instagram
|
|
15
|
+
t.string :customer_support_email
|
|
16
|
+
t.text :description
|
|
17
|
+
t.text :address
|
|
18
|
+
t.string :contact_phone
|
|
19
|
+
t.string :new_order_notifications_email
|
|
20
|
+
|
|
21
|
+
t.string :locale, null: false
|
|
22
|
+
t.references :spree_store, null: false, foreign_key: true, index: false
|
|
23
|
+
|
|
24
|
+
t.timestamps null: false
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
add_index :spree_store_translations, :locale, name: :index_spree_store_translations_on_locale
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
add_index :spree_store_translations, [:spree_store_id, :locale], name: :index_spree_store_translations_on_spree_store_id_locale, unique: true
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def add_new_translation_columns_to_globalize_table
|
|
36
|
+
# manually check for index since Rails if_exists does not always work correctly
|
|
37
|
+
if ActiveRecord::Migration.connection.index_exists?(:spree_store_translations, :spree_store_id)
|
|
38
|
+
remove_index :spree_store_translations, column: :spree_store_id, if_exists: true
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
add_column :spree_store_translations, :facebook, :string
|
|
42
|
+
add_column :spree_store_translations, :twitter, :string
|
|
43
|
+
add_column :spree_store_translations, :instagram, :string
|
|
44
|
+
add_column :spree_store_translations, :customer_support_email, :string
|
|
45
|
+
add_column :spree_store_translations, :description, :text
|
|
46
|
+
add_column :spree_store_translations, :address, :text
|
|
47
|
+
add_column :spree_store_translations, :contact_phone, :string
|
|
48
|
+
add_column :spree_store_translations, :new_order_notifications_email, :string
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class TransferStoreDataToTranslatableTables < ActiveRecord::Migration[6.1]
|
|
2
|
+
TRANSLATION_MIGRATION = Spree::TranslationMigrations.new(Spree::Store, 'en')
|
|
3
|
+
|
|
4
|
+
def up
|
|
5
|
+
TRANSLATION_MIGRATION.transfer_translation_data
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def down
|
|
9
|
+
TRANSLATION_MIGRATION.revert_translation_data_transfer
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -65,6 +65,7 @@ module Spree
|
|
|
65
65
|
preference :show_raw_product_description, :boolean, deprecated: true
|
|
66
66
|
preference :tax_using_ship_address, :boolean, default: true
|
|
67
67
|
preference :track_inventory_levels, :boolean, default: true # Determines whether to track on_hand values for variants / products.
|
|
68
|
+
preference :use_user_locale, :boolean, default: true
|
|
68
69
|
|
|
69
70
|
# Store credits configurations
|
|
70
71
|
preference :non_expiring_credit_types, :array, default: []
|
|
@@ -22,15 +22,29 @@ module Spree
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def current_locale
|
|
25
|
-
@current_locale ||= if
|
|
25
|
+
@current_locale ||= if user_locale?
|
|
26
|
+
try_spree_current_user.selected_locale
|
|
27
|
+
elsif params_locale?
|
|
26
28
|
params[:locale]
|
|
27
|
-
elsif
|
|
29
|
+
elsif config_locale?
|
|
28
30
|
config_locale
|
|
29
31
|
else
|
|
30
32
|
current_store&.default_locale || Rails.application.config.i18n.default_locale || I18n.default_locale
|
|
31
33
|
end
|
|
32
34
|
end
|
|
33
35
|
|
|
36
|
+
def config_locale?
|
|
37
|
+
respond_to?(:config_locale, true) && config_locale.present?
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def params_locale?
|
|
41
|
+
params[:locale].present? && supported_locale?(params[:locale])
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def user_locale?
|
|
45
|
+
Spree::Config.use_user_locale && try_spree_current_user && supported_locale?(try_spree_current_user.selected_locale)
|
|
46
|
+
end
|
|
47
|
+
|
|
34
48
|
def supported_locales
|
|
35
49
|
@supported_locales ||= current_store&.supported_locales_list
|
|
36
50
|
end
|
|
@@ -54,6 +68,16 @@ module Spree
|
|
|
54
68
|
|
|
55
69
|
I18n.locale.to_s
|
|
56
70
|
end
|
|
71
|
+
|
|
72
|
+
def find_with_fallback_default_locale(&block)
|
|
73
|
+
result = begin
|
|
74
|
+
block.call
|
|
75
|
+
rescue ActiveRecord::RecordNotFound => _e
|
|
76
|
+
nil
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
result || Mobility.with_locale(current_store.default_locale) { block.call }
|
|
80
|
+
end
|
|
57
81
|
end
|
|
58
82
|
end
|
|
59
83
|
end
|