nebulab / solidus

Solidus, Rails eCommerce System
http://solidus.io/
Other
7 stars 3 forks source link

CSV importer Part I #35

Closed DanielePalombo closed 2 years ago

DanielePalombo commented 4 years ago

https://github.com/nebulab/solidus/issues/31

Rel https://github.com/nebulab/solidus/issues/31 First part

Make a CSV importer upload products, orders, and customers.

We think that the importer will be used only for the first import. So we can skip the check to update the entities.

Describe alternatives you've considered We can create a Converter from CSV to JSON to reuse the existing importers.

Additional context existing importers

DanielePalombo commented 4 years ago

Some details after meeting:

https://github.com/orgs/nebulab/projects/3#card-30533925

owners: @blocknotes @DanielePalombo @elia

blocknotes commented 4 years ago

After some analysis with @DanielePalombo:

# => correspond to a CSV file
class SolidusImporter::CSVFileBase
  # STI with: CSVFileCustomers, CSVFileOrders, CSVFileProducts

  def scan # in after_create
    # create CSVRow entities
  end

  def pre_process
    # example: parse each CSVRow
    #   extract all taxons
    #   create missing taxons, with a reference: CSVRow <-> Taxon
  end

  def process
    # process every row
  end

  def post_process
    # example: send a notification
  end

  def check_finished
    # check if all rows finished, if yes:
    #   - change state to complete
    #   - call post_process
  end
end
# => correspond to a CSV row
class SolidusImporter::CSVRowBase
  # STI with: CSVRowCustomer, CSVRowOrder, CSVRowProduct

  attr_accessor :procs

  # reference to parent

  def initialize
    @context = nil
    @procs = []
  end

  def process
    @procs.each do |fun|
      fun.call(@context)
    end
  end

  def post_process
    # ... log or n-to-n: references to generated entities ...
    # call parent.check_finished
  end
end
blocknotes commented 4 years ago

New Admin Import section with:

Other features:

blocknotes commented 4 years ago

Extension project ➡️https://github.com/nebulab/solidus_importer