Products
Creating a product
Section titled “Creating a product”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:product = await service.CreateAsync(product, new ProductCreateOptions() { Published = false });Retrieving a product
Section titled “Retrieving a product”var service = new ProductService(myShopifyUrl, shopAccessToken);var product = await service.GetAsync(productId);Updating a product
Section titled “Updating a product”var service = new ProductService(myShopifyUrl, shopAccessToken);var product = await service.UpdateAsync(productId, new Product(){ Title = "New product title"});Deleting a product
Section titled “Deleting a product”var service = new ProductService(myShopifyUrl, shopAccessToken);
await service.DeleteAsync(productId);Counting products
Section titled “Counting products”var service = new ProductService(myShopifyUrl, shopAccessToken);int productCount = await service.CountAsync();Listing products
Section titled “Listing products”var service = new ProductService(myShopifyUrl, shopAccessToken);IEnumerable<Product> products = await service.ListAsync();
//Optionally filter the resultsvar filter = new ProductFilterOptions(){ Ids = new[] { productId1, productId2, productId3 }};products = await service.ListAsync(filter);Publishing a product
Section titled “Publishing a product”var service = new ProductService(myShopifyUrl, shopAccessToken);var product = await service.PublishAsync(productId);Unpublishing a product
Section titled “Unpublishing a product”var service = new ProductService(myShopifyUrl, shopAccessToken);var product = await service.UnpublishAsync(productId);