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(medusa): Add metadata to Product Category #5599

Merged

Conversation

bqst
Copy link
Contributor

@bqst bqst commented Nov 10, 2023

Resolves: #5598

What

This PR introduces the addition of metadata (JSONB) attributes in the Product Category feature. Previously, metadata attributes were available for Product Collections and Product Tags, but not for categories. This update adds consistent metadata functionality across various entities within the platform.

Why

It allows for the storage of additional, custom data associated with categories, aligning the capabilities of Product Categories with that of product collections and tags. This change is relevant for developers and users who require extended information tied to each category for custom implementations.

How

Adding the JSONB field, exactly the same as the other metadata implementations.

Testing

  • Tested by running the migrations
  • API insert / update / read

bqst added 9 commits November 9, 2023 22:23
…database to store additional information about each product category
…del to store additional details

📝 docs(product-category.ts): add documentation for new metadata field in ProductCategory model
…for additional information storage

📝 docs(product-categories): add documentation for new metadata field in product categories
…ed product category fields for enhanced data tracking
🔧 refactor(product-category.ts): import setMetadata from utils to handle metadata setting in a more efficient way
…oryReq and AdminPostProductCategoriesReq models to store additional information
…n both admin and store specs

🔧 fix(api-reference): make metadata field required in ProductCategory schema to ensure data consistency
Copy link

changeset-bot bot commented Nov 10, 2023

🦋 Changeset detected

Latest commit: 262cada

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@medusajs/medusa Patch
@medusajs/client-types Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Nov 10, 2023

@bqst is attempting to deploy a commit to the medusajs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

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

LGTM, @riqwan could you review this one please? 🙏

@luluhoc
Copy link
Contributor

luluhoc commented Nov 13, 2023

Please merge this!

Copy link
Contributor

@riqwan riqwan left a comment

Choose a reason for hiding this comment

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

lgtm, clean work @bqst! 🔥

@bqst bqst marked this pull request as ready for review November 13, 2023 11:34
@bqst bqst requested review from a team as code owners November 13, 2023 11:34
Copy link

vercel bot commented Nov 16, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Visit Preview Nov 16, 2023 7:36pm
docs-ui ⬜️ Ignored (Inspect) Visit Preview Nov 16, 2023 7:36pm
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Nov 16, 2023 7:36pm

@olivermrbl olivermrbl merged commit b3093c3 into medusajs:develop Nov 16, 2023
18 checks passed
@muke5hy
Copy link

muke5hy commented Feb 25, 2024

Hi, is this available in the version 1.20.2?

I am getting following error when I run after upgrading to 1.20.2

  query: 'SELECT "product"."id" AS "product_id", "product"."created_at" AS "product_created_at", "product"."updated_at" AS "product_updated_at", "product"."deleted_at" AS "product_deleted_at", "product"."title" AS "product_title", "product"."subtitle" AS "product_subtitle", "product"."description" AS "product_description", "product"."handle" AS "product_handle", "product"."is_giftcard" AS "product_is_giftcard", "product"."status" AS "product_status", "product"."thumbnail" AS "product_thumbnail", "product"."weight" AS "product_weight", "product"."length" AS "product_length", "product"."height" AS "product_height", "product"."width" AS "product_width", "product"."hs_code" AS "product_hs_code", "product"."origin_country" AS "product_origin_country", "product"."mid_code" AS "product_mid_code", "product"."material" AS "product_material", "product"."collection_id" AS "product_collection_id", "product"."type_id" AS "product_type_id", "product"."discountable" AS "product_discountable", "product"."external_id" AS "product_external_id", "product"."metadata" AS "product_metadata", "categories"."id" AS "categories_id", "categories"."created_at" AS "categories_created_at", "categories"."updated_at" AS "categories_updated_at", "categories"."name" AS "categories_name", "categories"."description" AS "categories_description", "categories"."handle" AS "categories_handle", "categories"."is_active" AS "categories_is_active", "categories"."is_internal" AS "categories_is_internal", "categories"."parent_category_id" AS "categories_parent_category_id", "categories"."rank" AS "categories_rank", "categories"."metadata" AS "categories_metadata", "categories"."mpath" AS "categories_mpath" FROM "public"."product" "product" LEFT JOIN "public"."product_category_product" "product_categories" ON "product_categories"."product_id"="product"."id" LEFT JOIN "public"."product_category" "categories" ON "categories"."id"="product_categories"."product_category_id" WHERE ( "product"."id" IN ($1) ) AND ( "product"."deleted_at" IS NULL )',
  parameters: [ 'prod_01HHYFBA21T124902F5FA6QKQX' ],
  driverError: error: column categories.metadata does not exist
  

@olivermrbl
Copy link
Contributor

@muke5hy, have you run migrations?

npx medusa migrations run

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.

Missing metadata Attributes in Product Category
5 participants