Sha256: 7290d0892d37f5d59dd2920cd73f7912e59348ff960009dcadbc82e346bd9970

Contents?: true

Size: 1.59 KB

Versions: 78

Compression:

Stored size: 1.59 KB

Contents

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

78 entries across 78 versions & 1 rubygems

Version Path
spree_core-4.0.0 db/migrate/20140309033438_create_store_from_preferences.rb
spree_core-4.0.0.rc3 db/migrate/20140309033438_create_store_from_preferences.rb
spree_core-3.7.6 db/migrate/20140309033438_create_store_from_preferences.rb
spree_core-3.7.5 db/migrate/20140309033438_create_store_from_preferences.rb
spree_core-4.0.0.rc2 db/migrate/20140309033438_create_store_from_preferences.rb
spree_core-4.0.0.rc1 db/migrate/20140309033438_create_store_from_preferences.rb
spree_core-4.0.0.beta db/migrate/20140309033438_create_store_from_preferences.rb
spree_core-3.7.4 db/migrate/20140309033438_create_store_from_preferences.rb
spree_core-3.7.3 db/migrate/20140309033438_create_store_from_preferences.rb
spree_core-3.7.2 db/migrate/20140309033438_create_store_from_preferences.rb
spree_core-3.7.1 db/migrate/20140309033438_create_store_from_preferences.rb
spree_core-3.7.0 db/migrate/20140309033438_create_store_from_preferences.rb
spree_core-3.7.0.rc3 db/migrate/20140309033438_create_store_from_preferences.rb
spree_core-3.2.9 db/migrate/20140309033438_create_store_from_preferences.rb
spree_core-3.7.0.rc2 db/migrate/20140309033438_create_store_from_preferences.rb
spree_core-3.7.0.rc1 db/migrate/20140309033438_create_store_from_preferences.rb
spree_core-3.6.6 db/migrate/20140309033438_create_store_from_preferences.rb
spree_core-3.6.5 db/migrate/20140309033438_create_store_from_preferences.rb
spree_core-3.6.4 db/migrate/20140309033438_create_store_from_preferences.rb
spree_core-3.6.3 db/migrate/20140309033438_create_store_from_preferences.rb