skills/catalog-inventory/variant-matrix/SKILL.md
Generate and manage all size/color/material combinations for a product using your platform's variant tools with bulk price and inventory management
npx skillsauth add finsilabs/awesome-ecommerce-skills variant-matrixInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Product variants let one product listing cover all size/color/material combinations — each with its own price, SKU, and inventory. Platforms generate the full matrix of combinations from your option values and handle the variant selector UI automatically. The main tasks are: entering options correctly, generating all SKUs, setting per-variant pricing and inventory, and managing large matrices efficiently.
| Platform | Options | Max Variants | Variant Fields | |----------|---------|-------------|----------------| | Shopify | Up to 3 options (e.g., Size, Color, Style) | 100 per product | Price, SKU, barcode, inventory, weight, image | | WooCommerce | Unlimited attributes used as variations | Practically unlimited (performance degrades at ~50+) | Price, sale price, SKU, stock, weight, dimensions, image | | BigCommerce | Unlimited options per product | 600 SKUs per product | Price adjustment, SKU, stock, weight, image | | Custom / Headless | Design your own | Unlimited | Design your own variant fields |
Creating variants from options:
Setting per-variant details:
Bulk variant management:
Disabling unavailable combinations:
Adding/removing option values after launch:
Creating variations from attributes:
Bulk variation updates:
SKU generation: WooCommerce doesn't auto-generate SKUs. Enter them manually or use a pattern:
[PRODUCT-CODE]-[SIZE]-[COLOR] → e.g., SHIRT-M-REDCreating options and variants:
Option Sets:
Bulk SKU management:
Build variant generation from Cartesian product of options, with diff logic to safely update existing catalogs:
// lib/variantMatrix.ts
// Generate all variant combinations from option value arrays
// Input: [['S','M','L'], ['Red','Blue']]
// Output: [['S','Red'], ['S','Blue'], ['M','Red'], ['M','Blue'], ['L','Red'], ['L','Blue']]
export function cartesianProduct(arrays: string[][]): string[][] {
return arrays.reduce(
(acc, values) => acc.flatMap(combo => values.map(v => [...combo, v])),
[[]] as string[][]
);
}
// Generate variant records with auto-generated SKUs
export function generateVariants(baseSku: string, optionNames: string[], optionValues: string[][]) {
const combinations = cartesianProduct(optionValues);
return combinations.map(combo => ({
sku: [baseSku, ...combo].join('-').toUpperCase().replace(/\s+/g, '-'),
options: Object.fromEntries(optionNames.map((name, i) => [name, combo[i]])),
price: null, // Set individually or via bulk rule
inventoryQuantity: 0,
published: true,
}));
}
// Compute what to create vs. archive when option values change
export function diffVariants(
existingVariants: { options: Record<string, string> }[],
newCombinations: string[][],
optionNames: string[]
) {
const existingKeys = new Set(existingVariants.map(v => optionNames.map(n => v.options[n]).join('|')));
const newKeys = new Set(newCombinations.map(c => c.join('|')));
const toCreate = newCombinations.filter(combo => !existingKeys.has(combo.join('|')));
const toArchive = existingVariants.filter(v => !newKeys.has(optionNames.map(n => v.options[n]).join('|')));
return { toCreate, toArchive };
}
// Variant selector logic — which values are available given current selections?
export function getAvailableOptionValues(
variants: { options: Record<string, string>; inventoryQuantity: number }[],
currentSelections: Record<string, string>,
targetOptionName: string
): string[] {
return variants
.filter(v =>
Object.entries(currentSelections)
.filter(([name]) => name !== targetOptionName)
.every(([name, value]) => v.options[name] === value)
&& v.inventoryQuantity > 0
)
.map(v => v.options[targetOptionName])
.filter(Boolean);
}
Consistent SKUs are critical for warehouse operations, reporting, and supplier communication. Establish a naming pattern before importing products.
Recommended format:
[PRODUCT-CODE]-[OPTION1]-[OPTION2]
Rules:
- Max 20 characters total
- All uppercase
- Hyphens between segments, no spaces
- Use standard size abbreviations: XS, S, M, L, XL, 2XL
- Use 3-letter color codes: RED, BLU, BLK, WHT, NVY, GRN
- Example: SHIRT-M-BLU → Blue shirt, Medium
SHOE-10-NVY → Navy shoe, Size 10
Use Matrixify (Shopify) or WP All Import (WooCommerce) to bulk-assign SKUs following this pattern for an existing catalog.
For products with many combinations (50+ variants):
Shopify: The 100-variant limit may be an issue for products with 3+ options. Strategies:
WooCommerce: Performance degrades with 50+ variations on one product. Use WooCommerce Performance Optimizations or YITH WooCommerce Variations Table to improve the admin and storefront experience.
Lazy variant creation: For extremely large matrices (e.g., custom paint colors × finish × size = 500+ SKUs), generate variants on demand when first ordered rather than pre-creating all combinations:
// For very large matrices: create variants on first request rather than upfront
export async function ensureVariantExists(productId: string, options: Record<string, string>) {
const key = Object.values(options).join('|');
const existing = await db.productVariants.findFirst({ where: { productId, variantKey: key } });
if (existing) return existing;
const product = await db.products.findUnique({ where: { id: productId } });
return db.productVariants.create({
data: {
productId,
sku: generateSku(product.baseSku, options),
variantKey: key,
options,
price: applyPricingRules(product, options),
inventoryQuantity: 0,
},
});
}
published: false when discontinued| Problem | Solution |
|---------|----------|
| Shopify 100-variant limit reached | Combine options or create separate products per color; use metafields to group related products in the storefront |
| Variant image not switching on option select | Assign variant-specific images explicitly per variant; the platform can only switch images if the variant has its own image set |
| Adding a new option value creates duplicate variants | Use diff logic to detect which combinations are genuinely new; Shopify handles this correctly in the admin, but custom imports need deduplication |
| Large matrix slows product page load | For 100+ variants, fetch variant availability via API on option change rather than embedding all variants in the initial page HTML |
| SKU collisions during bulk import | Normalize SKU segments before generating: toUpperCase().replace(/[^A-Z0-9]/g, '-'); check for duplicates before saving |
tools
Let shoppers save products to a wishlist, share it with friends, and get notified when saved items come back in stock or drop in price
development
Build a themeable storefront with design tokens and CSS custom properties that supports white-labeling, multi-brand variants, and dark mode
development
Speed up product discovery with instant search suggestions, fuzzy typo matching, and category-aware results powered by Algolia or Elasticsearch
development
Build a mobile-first storefront with thumb-friendly navigation, sticky add-to-cart buttons, and touch-optimized components for high mobile conversion