Closed DanielePalombo closed 2 years ago
Some details after meeting:
https://github.com/orgs/nebulab/projects/3#card-30533925
owners: @blocknotes @DanielePalombo @elia
After some analysis with @DanielePalombo:
SolidusImporter::CSVFileBase#scan
: create import rows entities (3 types STI)SolidusImporter::CSVFileBase#process
:SolidusImporter::CSVRowBase#process
SolidusImporter::CSVRowBase#post_process
# => 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
New Admin Import section with:
Other features:
Extension project ➡️https://github.com/nebulab/solidus_importer
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