-
-
Notifications
You must be signed in to change notification settings - Fork 313
Products
Joshua Harms edited this page Dec 20, 2023
·
1 revision
var service = new ProductService(myShopifyUrl, shopAccessToken);
var product = new Product()
{
Title = "Burton Custom Freestlye 151",
Vendor = "Burton",
BodyHtml = "<strong>Good snowboard!</strong>",
ProductType = "Snowboard",
Images = new List<ProductImage>
{
new ProductImage
{
Attachment = "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
}
},
};
product = await service.CreateAsync(product);
//By default, creating a product will publish it. To create an unpublished product:+1:
product = await service.CreateAsync(product, new ProductCreateOptions() { Published = false });
var service = new ProductService(myShopifyUrl, shopAccessToken);
var product = await service.GetAsync(productId);
var service = new ProductService(myShopifyUrl, shopAccessToken);
var product = await service.UpdateAsync(productId, new Product()
{
Title = "New product title"
});
var service = new ProductService(myShopifyUrl, shopAccessToken);
await service.DeleteAsync(productId);
var service = new ProductService(myShopifyUrl, shopAccessToken);
int productCount = await service.CountAsync();
var service = new ProductService(myShopifyUrl, shopAccessToken);
IEnumerable<Product> products = await service.ListAsync();
//Optionally filter the results
var filter = new ProductFilterOptions()
{
Ids = new[]
{
productId1,
productId2,
productId3
}
};
products = await service.ListAsync(filter);
var service = new ProductService(myShopifyUrl, shopAccessToken);
var product = await service.PublishAsync(productId);
var service = new ProductService(myShopifyUrl, shopAccessToken);
var product = await service.UnpublishAsync(productId);