ShopifySharp
ShopifySharp copied to clipboard
Creating product metafields not working
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
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;
}