Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
viggo-devries committed Dec 28, 2023
1 parent 86ecce7 commit 231944b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions oscar_odin/mappings/catalogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -382,18 +382,19 @@ 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.
The method will first bulk update or create the foreign keys like parent products and productclasses
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

Expand Down

0 comments on commit 231944b

Please sign in to comment.