Add Shopify publish/sync per product variant
Deploy / deploy (push) Successful in 14s

Each size row in the product form now shows a Shopify status badge
(green ✓ Shopify / gray Lokal). For saved variants, an action button
appears: 'Zu Shopify' for local-only variants (creates via Shopify
API and stores the returned variant ID), 'Shopify sync' for linked
variants (pushes price/SKU/GTIN to Shopify).

Also fixes:
- gtin missing from ProductSize::$fillable (was silently not saved)
- shopify_product_id added to products table and stored on import
- sizes afterStateHydrated now loads ProductSize directly instead of
  via the belongsToMany pivot (gets product_size_id, shopify_variant_id)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Malek TellissiandClaude Sonnet 4.6 committed 2026-09-12 17:20:26 +02:00
1 parent e187465553
commit 3ebd9845b0
7 files changed
+189 -20

No files matched your search

+16 -4
View File
@@ -58,17 +58,29 @@ class ShopifyImport extends Command
$product = Product::firstOrCreate(
['title' => $variant['product_title']],
['recipes_id' => null, 'description' => $variant['product_description']],
[
'recipes_id' => null,
'description' => $variant['product_description'],
'shopify_product_id' => $variant['shopify_product_id'],
],
);
if ($product->wasRecentlyCreated) {
$stats['products']++;
// Collect for image download after transaction
$newProducts[$product->id] = [
'product' => $product,
'image_urls' => $variant['image_urls'],
];
} elseif (empty($product->description) && ! empty($variant['product_description'])) {
$product->update(['description' => $variant['product_description']]);
} else {
$updates = [];
if (empty($product->description) && ! empty($variant['product_description'])) {
$updates['description'] = $variant['product_description'];
}
if (empty($product->shopify_product_id)) {
$updates['shopify_product_id'] = $variant['shopify_product_id'];
}
if ($updates) {
$product->update($updates);
}
}
$size = ProductSize::firstOrCreate(