Sha256: b7d2b3fa2fd379b41b9d686be1601b28390c7217be761d5fdaf3ea54e55beacb

Contents?: true

Size: 1.66 KB

Versions: 9

Compression:

Stored size: 1.66 KB

Contents

# This migration comes from spree (originally 20140309033438)
class CreateStoreFromPreferences < ActiveRecord::Migration[4.2]
  def change
    # workaround for spree_i18n and Store translations
    Spree::Store.class_eval do
      def self.translated?(name)
        false
      end
    end
    
    preference_store = Spree::Preferences::Store.instance
    if store = Spree::Store.where(default: true).first
      store.meta_description = preference_store.get('spree/app_configuration/default_meta_description') {}
      store.meta_keywords    = preference_store.get('spree/app_configuration/default_meta_keywords') {}
      store.seo_title        = preference_store.get('spree/app_configuration/default_seo_title') {}
      store.save!
    else
      # we set defaults for the things we now require
      Spree::Store.new do |s|
        s.name              = preference_store.get 'spree/app_configuration/site_name' do
          'Spree Demo Site'
        end
        s.url               = preference_store.get 'spree/app_configuration/site_url' do
          'demo.spreecommerce.org'
        end
        s.mail_from_address = preference_store.get 'spree/app_configuration/mails_from' do
          'spree@example.com'
        end

        s.meta_description = preference_store.get('spree/app_configuration/default_meta_description') {}
        s.meta_keywords    = preference_store.get('spree/app_configuration/default_meta_keywords') {}
        s.seo_title        = preference_store.get('spree/app_configuration/default_seo_title') {}
        s.default_currency = preference_store.get('spree/app_configuration/currency') {}
        s.code             = 'spree'
      end.save!
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
spree_purchase_order-3.7.0 spec/dummy/db/migrate/20191113195843_create_store_from_preferences.spree.rb
spree_billing_sisow-0.9.2 spec/dummy/db/migrate/20190729091784_create_store_from_preferences.spree.rb
spree_billing_sisow-0.9.1 spec/dummy/db/migrate/20190729091784_create_store_from_preferences.spree.rb
spree_purchase_order-3.6.0 spec/dummy/db/migrate/20180516181972_create_store_from_preferences.spree.rb
spree_purchase_order-3.5.0 spec/dummy/db/migrate/20180516181972_create_store_from_preferences.spree.rb
spree_purchase_order-3.5.0.rc1 spec/dummy/db/migrate/20180516181972_create_store_from_preferences.spree.rb
spree_purchase_order-3.4.0 spec/dummy/db/migrate/20180516181972_create_store_from_preferences.spree.rb
spree_purchase_order-3.3.0 spec/dummy/db/migrate/20180516181972_create_store_from_preferences.spree.rb
spree_purchase_order-3.2.0 spec/dummy/db/migrate/20180516181972_create_store_from_preferences.spree.rb