Class: Spree::SampleData::ImportRunner
- Inherits:
-
Object
- Object
- Spree::SampleData::ImportRunner
- Includes:
- Spree::ServiceModule::Base
- Defined in:
- app/services/spree/sample_data/import_runner.rb
Overview
Runs a sample CSV through the regular import pipeline: start_mapping
auto-assigns the column mappings from the CSV headers (the sample files
use the canonical schema names, so every column maps) and
complete_mapping kicks off row creation and processing.
Enqueues by default, so row creation, batching and the per-import
concurrency cap behave exactly as they do for a merchant-uploaded CSV.
Pass inline: true for rake tasks, seeds and the console — where the data
has to exist when the call returns and there may be no worker attached.
Never inline from a request: products.csv alone is 211 rows, each
downloading a remote image.
Instance Method Summary collapse
-
#call(csv_path:, import_class:, store: nil, user: nil, inline: false, skip_events: false) ⇒ Spree::ServiceModule::Result
Pass
skip_events: truewhen seeding demo data — subscribers would otherwise deliver webhooks and analytics for a catalog nobody created.
Methods included from Spree::ServiceModule::Base
Instance Method Details
#call(csv_path:, import_class:, store: nil, user: nil, inline: false, skip_events: false) ⇒ Spree::ServiceModule::Result
Pass skip_events: true when seeding demo data — subscribers would
otherwise deliver webhooks and analytics for a catalog nobody created.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/services/spree/sample_data/import_runner.rb', line 22 def call(csv_path:, import_class:, store: nil, user: nil, inline: false, skip_events: false) import = Spree::SampleData::ImportBuilder.call( csv_path: csv_path, import_class: import_class, store: store, user: user, inline: inline, skip_events: skip_events ) import.start_mapping import.complete_mapping success(import.reload) end |