Importing a catalogue¶
Handling imports works in Oscar, but the code quality of the importer is low as it is only used to populate the sandbox site, and not meant for general usage. So proceed at your own risk!
Importing a catalogue is pretty straightforward, and can be done in two easy steps:
Reading the catalogue CSV file, line by line, using
Using the info of each line, start by creating a
Productobject using the standard Django ORM, set the product attributes, save it, and finally set its
An example of that is the
CatalogueImporter used to import catalogues for
the sandbox site. The class is available under
Let’s take a closer look at
class CatalogueImporter(object): def __init__(self, logger): self.logger = logger @atomic def _import(self, file_path=None): .... def _import_row(self, row_number, row, stats): ....
The two steps procedure we talked about are obvious in this example, and are
_import_row functions, respectively.
You can find an example of the CSV data that the
expects in the repository.