Skip to content

Custom Collections

Joshua Harms edited this page Jan 21, 2025 · 2 revisions

Custom Collections

Warning

All public Shopify apps (i.e. those published on the Shopify App Store) are required to switch over to using the GraphQL product API by February 1st. All custom apps are required to switch by April 1st. Go here for a migration guide on using ShopifySharp's GraphService to query and mutate Shopify's GraphQL API.

A custom collection is a grouping of products that a shop owner can create to make their shops easier to browse. A shop owner creates a custom collection and then selects the products that will go into it.

Creating a custom collection

var service = new CustomCollectionService(myShopifyUrl, shopAccessToken);
var collection = await service.CreateAsync(new CustomCollection()
{
    Title = "My Custom Collection",
    Published = true,
    PublishedAt = DateTime.UtcNow,
    Image = new CustomCollectionImage()
    {
        Src = "https://placekitten.com/250/250"
    }
});

Getting a custom collection

var service = new CustomCollectionService(myShopifyUrl, shopAccessToken);
var collection = await service.GetAsync(collectionId);

Counting custom collections

var service = new CustomCollectionService(myShopifyUrl, shopAccessToken);
var count = await service.CountAsync();

Listing custom collections

var service = new CustomCollectionService(myShopifyUrl, shopAccessToken);
var collections = await service.ListAsync();

Updating a custom collection

var service = new CustomCollectionService(myShopifyUrl, shopAccessToken);
var collection = await service.UpdateAsync(collectionId, new Collection()
{
    Title = "My new collection title"
});

Deleting a custom collection

var service = new CustomCollectionService(myShopifyUrl, shopAccessToken);

await service.DeleteAsync(collectionId);