Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fallback to 'price' in ecommerce api loader #5

Merged

Conversation

tecoholic
Copy link
Member

@tecoholic tecoholic commented Sep 23, 2024

Description

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: openedx/ecommerce#4050

Additional information

The same as openedx#4291.

Testing instructions

Reproduce Issue

  1. Setup Tutor 18 (Redwood) dev env with the plugins ecommerce and discovery enabled
  2. Clone course-discovery.
  3. Add a tutor mount for the course-discovery.
  4. Create a course or import the demo course.
  5. Setup admin user for ecommerce and discovery
  6. Add a course seat in http://ecommerce.local.edly.io:8130/courses/ for the test course
  7. Run the following from Discovery Shell to set the ecommerce API url. NOTE: trying the same in Discovery admin fails due to URL validation.
    from course_discovery.apps.core.models import Partner
    p = Partner.objects.get(short_code="dev")
    p.ecommerce_api_url = "http://ecommerce:8130/api/v2/"
    p.save()
    
  8. Run ./manage.py refresh_course_metadata --partner dev. It should fail with the KeyError price_excl_tax.

Testing the fix from PR

  1. Checkout the PR branch
  2. Run ./manage.py refresh_course_metadata --partner dev again. This time, it should run successfully.

@tecoholic tecoholic force-pushed the tecoholic/BB-9209-fix-ecommerce-loader branch from 2545af7 to b6ed4f9 Compare September 24, 2024 04:47
@tecoholic tecoholic force-pushed the tecoholic/BB-9209-fix-ecommerce-loader branch from b6ed4f9 to ed70947 Compare September 24, 2024 05:15
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 checks for the `price_excl_tax` key and
falls back to the 'price' value.

Ref: openedx/ecommerce#4050
@tecoholic tecoholic force-pushed the tecoholic/BB-9209-fix-ecommerce-loader branch from ed70947 to c472007 Compare September 24, 2024 05:16
Copy link
Member

@Agrendalath Agrendalath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tecoholic, you can apply the suggestion from the upstream PR if you'd like.

👍

@tecoholic
Copy link
Member Author

@Agrendalath Thanks for the review. I applied the suggestion from upstream reviewer.

@tecoholic tecoholic merged commit f39b839 into opencraft-release/redwood.1 Sep 25, 2024
2 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants