Class: Spree::SampleData::Loader

Inherits:
Object
  • Object
show all
Includes:
Helper, Spree::ServiceModule::Base
Defined in:
app/services/spree/sample_data/loader.rb

Instance Method Summary collapse

Methods included from Spree::ServiceModule::Base

prepended

Instance Method Details

#call(store: nil) ⇒ Spree::ServiceModule::Result

Loads the demo data into one store. The sample files and the imports they run read Spree::Current.store, so it is set for the whole run and restored afterwards.

Parameters:

  • store (Spree::Store, nil) (defaults to: nil) —

    the store to load into; defaults to the default store, resolved after the seeds so a bare install works

Returns:



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/services/spree/sample_data/loader.rb', line 14

def call(store: nil)
  Spree::Events.disable do
    without_geocoding do
      ActiveRecord::Base.no_touching do
        puts 'Running seeds first...' unless seeds_loaded?
        ensure_seeds_loaded

        @store = store || Spree::Store.default
        Spree::Current.set(store: @store) { load_sample_data }
      end
    end
  end
end