Create Collection
Create Collection Mutation
This mutation creates a new product collection in the store, allowing you to group related products together for better organization and marketing.
Use Cases
- Product Organization: Group related products by category, brand, or theme
- Marketing Campaigns: Create seasonal or promotional collections
- Store Navigation: Organize products for easier customer browsing
- SEO Strategy: Create targeted landing pages for product groups
- Multilingual Stores: Support collections in multiple languages
Key Features
Collection Information
- Basic Details: Title, description, and URL handle
- Visibility Controls: Control collection visibility in storefront
- Status Management: Archive or delete collections as needed
- Rich Content: HTML descriptions with formatting support
Product Management
- Initial Products: Add products during collection creation
- Product Relationships: Automatically establish product-collection links
- Dynamic Updates: Collections update automatically when products change
SEO and Marketing
- SEO Metadata: Custom title and description for search engines
- URL Handle: SEO-friendly collection URLs
- Collection Images: Featured images for collection pages
- Social Sharing: Optimized metadata for social media
Internationalization
- Multi-language Support: Create collections in multiple languages
- Localized Content: Translate titles, descriptions, and SEO metadata
- Regional Customization: Adapt collections for different markets
Input Parameters
$input: CollectionInput!- Complete collection information including:storeId: Store identifier where the collection will be createdtitle: Collection name/titlehandle: URL-friendly collection slugdescriptionHtml: Full HTML collection descriptionshortDescription: Brief collection summaryisVisible: Whether collection appears in storefrontisArchived: Archive status for internal organizationisDeleted: Soft delete statusimage: Featured collection imageseo: SEO metadata objectproductsToAdd: Array of product IDs to include initiallytranslations: Array of translations for different locales
$locale: String- Primary language locale for the collection (optional)
Response Structure
The mutation returns a CreateCollectionPayload containing:
collection: Complete collection object with all created data- Associated products with basic information
- Generated IDs and timestamps
- All translations and metadata
Collection Fields Detail
Basic Information
id- Unique collection identifiertitle- Collection namehandle- URL-friendly slugdescriptionHtml- Full HTML descriptionshortDescription- Brief summaryisVisible/isArchived/isDeleted- Status flagslocale- Primary languagecreatedAt/updatedAt- Timestamps
Associated Data
image- Featured collection image with dimensionsseo- SEO metadata for search enginesproducts- Paginated list of collection productstranslations- Array of localized versions
Example Response
{
"data": {
"createCollection": {
"collection": {
"id": "Collection_electronics_001",
"title": "Electronics & Gadgets",
"handle": "electronics-gadgets",
"descriptionHtml": "<p>Discover our curated collection...</p>",
"shortDescription": "Cutting-edge electronics and innovative gadgets",
"isVisible": true,
"isArchived": false,
"isDeleted": false,
"locale": "en",
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z",
"image": {
"id": "Image_collection_banner_001",
"src": "https://example.com/collections/electronics-banner.jpg",
"altText": "Electronics and Gadgets Collection Banner",
"width": 1200,
"height": 600
},
"seo": {
"title": "Electronics & Gadgets - Latest Technology Products",
"description": "Shop the latest electronics and gadgets..."
},
"products": {
"totalCount": 3,
"nodes": [
{
"id": "Product_smartphone_001",
"title": "iPhone 15 Pro",
"handle": "iphone-15-pro",
"status": "ACTIVE"
}
]
},
"translations": [
{
"title": "الإلكترونيات والأجهزة",
"locale": "ar",
"seo": {
"title": "الإلكترونيات والأجهزة - أحدث منتجات التكنولوجيا"
}
}
]
}
}
}
}
Implementation Notes
Validation Requirements
- Collection title must be unique within the store
- Handle must be URL-friendly and unique
- At least one translation is recommended for multilingual stores
- Product IDs in
productsToAddmust exist and be accessible
Best Practices
- Use descriptive, keyword-rich titles for SEO
- Create meaningful handles that reflect collection content
- Include comprehensive descriptions with relevant keywords
- Set up proper image alt text for accessibility
- Plan collection hierarchy for logical site navigation
Error Handling
- Handle duplicate handle errors with unique alternatives
- Validate product IDs before adding to collection
- Check store permissions and collection limits
- Ensure translation locales are supported
Performance Considerations
- Limit initial product additions to essential items
- Use pagination when querying collection products
- Consider collection size impact on page load times
- Optimize collection images for web performance
Related Operations
addProductsToCollection- Add more products to existing collectionsremoveProductsFromCollection- Remove products from collectionsupdateCollection- Update collection informationarchiveCollection- Archive collectionsListStoreProducts- Query products to add to collections
GraphQL Endpoint
https://graphql.wuilt.com
Operation: CreateCollection
Try It Out
Query
Query Variables
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Note: Make sure to change the storeId with your store ID. For guidance on how to get your store ID, reference the Store ID guide.
Authentication
To use this query, you will need an API key. Click the "API Key" button in the navigation bar to enter your credentials.