一键导入
variant-matrix
Generate and manage all size/color/material combinations for a product using your platform's variant tools with bulk price and inventory management
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate and manage all size/color/material combinations for a product using your platform's variant tools with bulk price and inventory management
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Manage supplier invoices and vendor payments with automated receipt matching, payment scheduling, early discount optimization, and reconciliation workflows
Enable wholesale and B2B sales with company accounts, custom catalogs, quote workflows, purchase orders, and net payment terms
Predict future inventory needs using historical sales data, seasonal trends, and reorder points to prevent stockouts and overstock
Launch a multi-vendor marketplace with seller onboarding, commission rules, automated payouts via Stripe Connect, and vendor dashboards
Control which products appear first in collections using automated ranking rules, manual overrides, and performance-based sorting algorithms
Sync your catalog and inventory across your own site, Amazon, eBay, and wholesale channels to sell everywhere from one system
| name | variant-matrix |
| description | Generate and manage all size/color/material combinations for a product using your platform's variant tools with bulk price and inventory management |
| category | catalog-inventory |
| risk | safe |
| source | curated |
| date_added | 2026-03-12 |
| tags | ["variants","sku","matrix","combinations","options","catalog","product-data"] |
| triggers | ["product variants","size color variants","variant combinations","SKU generation","option matrix","variant matrix"] |
| tools | ["claude-code","cursor","gemini-cli","copilot","codex-cli","kiro","opencode"] |
| platforms | ["shopify","woocommerce","bigcommerce","custom"] |
| difficulty | intermediate |
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 |