diff --git a/oscar_odin/mappings/catalogue.py b/oscar_odin/mappings/catalogue.py index f06937f..2e0b66f 100644 --- a/oscar_odin/mappings/catalogue.py +++ b/oscar_odin/mappings/catalogue.py @@ -369,11 +369,11 @@ def product_queryset_to_resources( def products_to_model( - products: List[resources.catalogue.Product], + products: List[resources.catalogue.Product], product_mapper=ProductToModel ) -> Tuple[List[ProductModel], Dict]: context = ModelMapperContext() - result = ProductToModel.apply(products, context=context) + result = product_mapper.apply(products, context=context) if hasattr(result, "__iter__"): return (list(result), context) @@ -382,10 +382,11 @@ def products_to_model( def products_to_db( - products: List[resources.catalogue.Product], + products, rollback=True, fields_to_update=ALL_CATALOGUE_FIELDS, identifier_mapping=MODEL_IDENTIFIERS_MAPPING, + product_mapper=ProductToModel, ) -> Tuple[List[ProductModel], Dict]: """Map mulitple products to a model and store them in the database. @@ -393,7 +394,7 @@ def products_to_db( After that all the products will be bulk saved. At last all related models like images, stockrecords, and related_products can will be saved and set on the product. """ - instances, context = products_to_model(products) + instances, context = products_to_model(products, product_mapper=product_mapper) context.fields_to_update = fields_to_update context.identifier_mapping = identifier_mapping