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: use "price" in ecommerce data loader #4450

Conversation

tecoholic
Copy link

@tecoholic tecoholic commented Sep 24, 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-unsupported/ecommerce#4050

Additional information

The same as #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.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Sep 24, 2024
@openedx-webhooks
Copy link

Thanks for the pull request, @tecoholic!

What's next?

Please work through the following steps to get your changes ready for engineering review:

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.

🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads

🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Let us know that your PR is ready for review:

Who will review my changes?

This repository is currently maintained by @openedx/course-discovery-admins. Tag them in a comment and let them know that your changes are ready for review.

Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@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-unsupported/ecommerce#4050
@tecoholic tecoholic force-pushed the tecoholic/BB-9209-fix-ecommerce-loader branch from ed70947 to c472007 Compare September 24, 2024 05:16
@tecoholic
Copy link
Author

@AfaqShuaib09 Thanks for the suggestion. I have applied it to the PR.

Copy link
Contributor

@AfaqShuaib09 AfaqShuaib09 left a comment

Choose a reason for hiding this comment

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

Hey,

Don’t we need to update other places, like in this closed PR?
https://github.com/openedx/course-discovery/pull/4291/files

i.e;, in update_entitlement and validate_stockrecord methods?

@tecoholic
Copy link
Author

@AfaqShuaib09 I raised the with the fix for just the one place where I encountered an error. If other functions also need to be updated, I can do that. But I am not sure what those functions do. So, anyone can confirm those functions need to be updated, I can recreate update the PR accordingly.

@Ali-D-Akbar
Copy link
Contributor

@AfaqShuaib09 I raised the with the fix for just the one place where I encountered an error. If other functions also need to be updated, I can do that. But I am not sure what those functions do. So, anyone can confirm those functions need to be updated, I can recreate update the PR accordingly.

Hi there! I do agree with Afaq since this field was previously added in the aforementioned closed PR. Also, I believe adding it in update_entitlement and validate_stockrecord is also the right way since both of these functions are used in EcommerceApi Data Loader and having the correct price value should be the right thing else it will result in failure again.

@tecoholic
Copy link
Author

tecoholic commented Sep 26, 2024

@AfaqShuaib09 @Ali-D-Akbar Hi, thanks for confirming. I have updated the references in the mentioned functions and the mock data as well. Can you kindly review?

Note: All the CI checks for Python 3.8 seems to be failing due to a setuptools error. I want to highlight that course-discovery tutor template for redwood uses Python 3.12. So we can safely disregard the 3.8 failures.

@tecoholic
Copy link
Author

@Ali-D-Akbar Hi, can you kindly review this change and merge it?

cc: @AfaqShuaib09

@Ali-D-Akbar Ali-D-Akbar merged commit 8ea38d5 into openedx:open-release/redwood.master Oct 2, 2024
20 of 26 checks passed
@tecoholic
Copy link
Author

@Ali-D-Akbar Thank you.

@Agrendalath Agrendalath deleted the tecoholic/BB-9209-fix-ecommerce-loader branch October 3, 2024 15:17
tecoholic added a commit to open-craft/course-discovery that referenced this pull request Oct 4, 2024
* chore: bump upload-artifact GH task to v4

* 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 checks for the `price_excl_tax` key and
falls back to the 'price' value.

Ref: openedx-unsupported/ecommerce#4050

* refactor: apply review suggestion on fix

* fix: update all references of `price_excl_tax` to price

* fix: remove extra item added accidentally
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants