How to create a product with Category linked metafield attributes

How to create a product with Category linked metafield attributes

RickUp
Shopify Partner
5 0 0

Hello guys,

 

Our team is currently developing a product management software, and while creating products, we want to add category-related attributes. However, we encountered an issue when associating these attributes. We obtained the category list from product-taxonomy/tree, along with the corresponding attribute and attribute value lists and their IDs. The format of the attribute ID is gid://shopify/TaxonomyValue/2878.

However, in the ProductCreate API, the linkedMetafield field requires the ID to be in the format: "gid://shopify/Metaobject/971662527".

Could you please advise on how I can obtain the correct category attribute ID?

Replies 4 (4)

Eric-HAN
Shopify Partner
184 25 20

Hi, there

Recommend using this link.

- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee
RickUp
Shopify Partner
5 0 0

Hi Eric,

Thanks for replying. I have already obtained the category values and keys, as well as the corresponding attribute values and keys from this link. However, the format of the key is different from what is required by the ProductCreate API. Do you know how to convert the "id: gid://shopify/TaxonomyValue/2878" to the format "gid://shopify/Metaobject"?

Regards,
Rick

Eric-HAN
Shopify Partner
184 25 20

HI, Rickup

Have you ever build up your Metaobject in advance?

This could be done using API or manually in dashboard?

EricHAN_0-1725005227698.png

BTW , i dont understand why you wanna make aconvertion.

- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee
RickUp
Shopify Partner
5 0 0

RickUp_0-1725009175368.png

RickUp_1-1725009589231.png

When I select a category, Shopify recommends some metafields. These metafields were not created by me; they are provided by Shopify. I want to post those Shopify-recommended metafields.