-
-
Notifications
You must be signed in to change notification settings - Fork 313
Smart Collections
Joshua Harms edited this page Dec 20, 2023
·
1 revision
A smart collection is a grouping of products defined by simple rules set by shop owners. A shop owner creates a smart collection and then sets the rules that determine which products go in them. Shopify automatically changes the contents of smart collections based on their rules.
var service = new SmartCollectionService(myShopifyUrl, shopAccessToken);
var smartCollection = await service.CreateAsync(new SmartCollection()
{
Title = "My Smart Collection",
Handle = "my-url-slug",
BodyHtml = "\<h1\>Hello world!\</h1\>",
Image = new SmartCollectionImage()
{
// Base-64 image attachment
Attachment = "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n"
}
});
var service = new SmartCollectionService(myShopifyUrl, shopAccessToken);
var smartCollection = await service.UpdateAsync(smartCollectionId, new SmartCollection()
{
Title = "My updated title"
});
var service = new SmartCollectionService(myShopifyUrl, shopAccessToken);
var smartCollection = await service.GetAsync(smartCollectionId);
var service = new SmartCollectionService(myShopifyUrl, shopAccessToken);
var count = await service.CountAsync();
var service = new SmartCollectionService(myShopifyUrl, shopAccessToken);
var smartCollections = await service.ListAsync();
var service = new SmartCollectionService(myShopifyUrl, shopAccessToken);
await service.DeleteAsync(smartCollectionId);