You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to get the variant metafields using below code and even though i know a product hass metafields all the products are returning metafields ass null. Please explain what i am doing wrong.
var filter = new ProductListFilter
{
Limit = pageSize,
SinceId = sinceId
};
// Get products from the Shopify store
var productList = await service.ListAsync(filter);
// Check if there are more products to retrieve
if (productList.Items.Count() < pageSize)
{
hasNextPage = false;
}
else
{
// Set the sinceId for the next page
sinceId = productList.Items.Last().Id;
}
System.Diagnostics.Debug.WriteLine($" Page Size:" + pageSize + " Has Page:" + hasNextPage);
foreach (var product in productList.Items)
{
if(product.Title.Contains("Finley Stripe See Through"))
{
Debug.WriteLine(product.Title);
}
var variantservice = new ProductVariantService(shopDomain, accessToken);
var variantfilter = new ProductVariantListFilter
{
Limit = 30
};
var variants = await variantservice.ListAsync(product.Id ?? 0, variantfilter);
foreach (var variant in variants.Items)
{
Debug.WriteLine(product.Title + "--" + variant.Title);
Debug.WriteLine(variant.Metafields);
}
}
The text was updated successfully, but these errors were encountered:
OK bit of an issue here with variant metafields if the metafield does not have some sort of existing value there is no way of you getting and id as far as i can see so i want to write size chart info into a metafield like so
var mpnmetafield = await metafieldservice.UpdateAsync(metafield.Id ?? 0, new MetaField()
{
Value = xxxxxxl
});
cant do it as metafield.Id does not exist until there is already an actual value. I had to update all the metafield manually via UI then ran same code and it worked. Found same issue on the community for shopify.
Just a heads up if anyone hass the same issue
I am trying to get the variant metafields using below code and even though i know a product hass metafields all the products are returning metafields ass null. Please explain what i am doing wrong.
var filter = new ProductListFilter
{
Limit = pageSize,
SinceId = sinceId
};
The text was updated successfully, but these errors were encountered: