This page documents the endpoints and document events that keep ERPNext Item Groups in sync with Medusa collections and expose the group hierarchy to the storefront’s navigation menus.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/aerele/medusa_integration/llms.txt
Use this file to discover all available pages before exploring further.
GET get menu
GET /api/method/medusa_integration.api.get_menu
Returns a hierarchical Item Group tree for use in storefront navigation menus. The response depth varies depending on the mobile_view flag.
Parameters
Name of the ERPNext Item Group to use as the root of the returned tree.
Pass
1 to return the full group hierarchy with thumbnails. Pass 0 (default) to return only one level of children and no thumbnails.Response
Display name of the Item Group.
URL-safe slug generated from the group name (lowercase, hyphens replacing non-alphanumeric characters).
Value of the
custom_medusa_route field on the Item Group document. Only populated when mobile_view=1.Absolute URL of the group image. Only populated when
mobile_view=1. null if no image is attached.Number of direct child Item Groups.
Recursive array of child group objects. In
mobile_view=0, only one level deep. In mobile_view=1, full depth.Children are sorted by
childCount descending so that groups with the most sub-categories appear first.Example
Response (mobile_view=1)
GET update all item groups
GET /api/method/medusa_integration.api.update_all_item_groups
Recalculates the custom_medusa_route field on every Item Group in ERPNext using the full group hierarchy. This endpoint requires authentication.
No request parameters.
Route format
Routes are built by walking up the parent chain to theProducts root group and joining slugified names with /:
Dental Equipment inside Dental inside Products gets the route:
Response
"success" on completion, "error" if an exception occurred.Human-readable result message.
Response
Automatic collection export on Website Item save
When a Website Item is saved and its Item Group does not yet have amedusa_id, export_item_group() is called automatically to push the Item Group to Medusa as a collection.
This is triggered by the validate document event on Website Item:
hooks.py
What happens
- The Website Item’s
item_groupis checked for amedusa_id. - If none exists, a
POST /admin/collectionsrequest is sent to Medusa. - The returned collection ID is stored in
medusa_idon the Item Group doctype. update_all_item_groups()is called to refreshcustom_medusa_routeon all groups.