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

feat: updates with relations, feat: updating products in collections, fix: corrections in relations #22

Merged
merged 2 commits into from
May 8, 2023

Conversation

uro
Copy link
Collaborator

@uro uro commented May 6, 2023

Updated services to handle product collections and products in Strapi; also fixed some other major bugs.

Major changes:

In the update-strapi.ts file:

  • Reverted "relation" comments from product updates.
  • Added a new method, updateProductsWithinCollectionInStrapi, to update products within a collection in Strapi when they're added or removed from collections.
  • Added a private method adjustProductAndUpdateInStrapi to decouple product adjusting as it's now shared by two methods - there is an edge case in naming created by the Medusa team.
  • Updated the translateDataToStrapiFormat method to translate underscores in relation names to dashes for consistency globally.

In the strapi.ts file:

  • Added event subscribers for the PRODUCTS_ADDED and PRODUCTS_REMOVED events of the ProductCollectionService.
  • Implemented logic to update products within a collection in Strapi when products are added or removed.

In the schema.json files:

  • There was a bug in the relation between product and product collections. This prevented it from populating the data.
  • Updated the product and product-collection schema to change the relationship type from manyToMany to oneToMany and similarly in the product schema.

In the utils.js file:

  • Used attachOrCreateStrapiIdFromMedusaId function in the Update controller to handle nested relations

These changes enhance the functionality of the Medusa Plugin for Strapi by better handling product collections, products in the Strapi backend and to bring back the "nested update" functionality.

@uro uro force-pushed the feat/updates-with-relations branch from d1142e9 to 768fcae Compare May 6, 2023 11:10
@SGFGOV SGFGOV merged commit a290e18 into SGFGOV:master May 8, 2023
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