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

Incorrect mpath Calculation for Product Categories When Parent Remains Unchanged #9769

Open
prateekkaramchandani opened this issue Oct 24, 2024 · 0 comments

Comments

@prateekkaramchandani
Copy link

Bug report

Describe the bug:

There is a bug in the calculation of the mpath for the product categories when the parent_category_id remains unchanged. This affects scenarios where the grandparent category changes but the immediate parent category does not, leading to incorrect mpath values for the affected categories' descendants.

This issue causes problems with querying category data, particularly when using the include_ancestors_tree or include_descendants_tree query parameters, as the mpath does not reflect the correct hierarchical relationship after changes to the grandparent category.

System information:

Medusa version (including plugins): v2.0
Node.js version: v20.15.1
Database: Postgres v16
Operating system: Linux

Steps to reproduce the behavior:

  1. Create a category tree with at least three levels: Grandparent → Parent → Child.
  2. Using the edit ranking feature in Medusa Admin move the Parent (along with Child) under another category.
  3. Observe that while the mpath of the parent is updated correctly as its immediate parent was changed, but the child category’s mpath remains unchanged, the mpath still starts with previous grandparent's id.

Expected behavior:

When the grandparent category is updated, the mpath of all descendant categories (including children and grandchildren) should be updated to reflect the new hierarchical structure.

Impact:

  1. Queries using the include_ancestors_tree parameter return incorrect results due to incorrect mpath calculation.
  2. Data inconsistency in category hierarchy can lead to broken functionality in areas relying on accurate category trees.
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

No branches or pull requests

1 participant