diff --git a/oscar_odin/mappings/catalogue.py b/oscar_odin/mappings/catalogue.py index 2e0b66f..af7a419 100644 --- a/oscar_odin/mappings/catalogue.py +++ b/oscar_odin/mappings/catalogue.py @@ -22,7 +22,7 @@ save_attributes, save_many_to_many, save_one_to_many, - save_products, + save_objects, save_foreign_keys, ) from .context import ModelMapperContext @@ -405,7 +405,7 @@ def products_to_db( save_foreign_keys(context, errors) # Save all the products in one go - save_products(instances, context, errors) + save_objects(ProductModel, instances, context, errors) # Save all product attributes save_attributes(instances) diff --git a/oscar_odin/mappings/utils.py b/oscar_odin/mappings/utils.py index 90d3dd7..8daa903 100644 --- a/oscar_odin/mappings/utils.py +++ b/oscar_odin/mappings/utils.py @@ -39,18 +39,18 @@ def save_foreign_keys(context, errors): Model.objects.bulk_update(instances, fields=fields) -def save_products(instances, context, errors): +def save_objects(Model, instances, context, errors): instances_to_create, instances_to_update = get_instances_to_create_or_update( - Product, instances, context.identifier_mapping + Model, instances, context.identifier_mapping ) validated_create_instances, errors = validate_instances(instances_to_create, errors) - Product.objects.bulk_create(validated_create_instances) + Model.objects.bulk_create(validated_create_instances) fields = context.get_fields_to_update(Product) if fields is not None: - Product.objects.bulk_update(instances_to_update, fields=fields) + Model.objects.bulk_update(instances_to_update, fields=fields) def save_one_to_many(context, errors):