From 5ebf1a498b6b6a5934ed659a6a4067503259f0f6 Mon Sep 17 00:00:00 2001 From: Arunmozhi Date: Mon, 23 Sep 2024 14:01:22 +1000 Subject: [PATCH] fix: fallback to 'price' in ecommerce api loader The Django Oscar upgrade of ecommerce changed the item's price field from `price_excl_tax` to just `price` causing the EcommerceApi data loader to fail. This commit handled the exception and falls back to the 'price' value. Ref: https://github.com/openedx/ecommerce/pull/4050 --- course_discovery/apps/course_metadata/data_loaders/api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/course_discovery/apps/course_metadata/data_loaders/api.py b/course_discovery/apps/course_metadata/data_loaders/api.py index a63aca75e43..7dde0dee439 100644 --- a/course_discovery/apps/course_metadata/data_loaders/api.py +++ b/course_discovery/apps/course_metadata/data_loaders/api.py @@ -572,7 +572,10 @@ def update_seats(self, body): def update_seat(self, course_run, product_body): stock_record = product_body['stockrecords'][0] currency_code = stock_record['price_currency'] - price = Decimal(stock_record['price_excl_tax']) + try: + price = Decimal(stock_record['price_excl_tax']) + except KeyError: # uses newer ecommerce version without 'price_excl_tax' key + price = Decimal(stock_record['price']) sku = stock_record['partner_sku'] # For more context see ADR docs/decisions/0025-dont-sync-mobile-skus-on-discovery.rst