nozzlegear / ShopifySharp

ShopifySharp is a .NET library that helps developers easily authenticate with and manage Shopify stores.
https://nozzlegear.com/shopify-development-handbook
MIT License
742 stars 308 forks source link

Creating product metafields not working #1023

Open wesleylathan opened 6 months ago

wesleylathan commented 6 months ago

The store has a set of metafields that are surfaced in the Shopify UI. The code runs without error, but the meta fields aren't updated.

Here's a screen shot of the fields in shopify

image

Here's the code I'm using to do the update. If I manually enter values through the UI and can pull the metafileds using ShopifySharp, I'm just not able to update the values.

        public async Task<bool> UpdateMetaFields(TCGProduct tCGProduct) {
            long? productId = (long)tCGProduct.Id;
            var service = new MetaFieldService(ShopifyTokens.myShopifyUrl, ShopifyTokens.shopAccessToken);

            var metafield = new MetaField()
            {
                Namespace = "custom",
                Key = "tcgplayer_id",
                Value = tCGProduct.TCGplayerID,
                Type = "integer",
                Description = "TCGPlayer ID"
            };
            var bar = await service.CreateAsync(metafield, Convert.ToInt64(tCGProduct.Id), "products");
            Debug.WriteLine(bar.Id + " " + bar.Key);
            return true;

        }