瀏覽代碼

Include product_id in Excel product sync export.

Ops can match rows by ID while import still updates by SKU.

Co-authored-by: Cursor <cursoragent@cursor.com>
chengwl 6 天之前
父節點
當前提交
04f7715979

+ 1 - 0
packages/Longyi/Core/src/Exports/ProductBasicInfoExport.php

@@ -71,6 +71,7 @@ class ProductBasicInfoExport implements FromQuery, ShouldAutoSize, WithHeadings,
         $productId = (int) $row->product_id;
 
         return [
+            $productId,
             $row->sku,
             $row->locale,
             $row->name,

+ 1 - 0
packages/Longyi/Core/src/Resources/lang/en/app.php

@@ -107,6 +107,7 @@ return [
         'message'       => 'Message',
         'import-summary'=> 'Updated :updated product(s), :failed row(s) failed.',
         'columns'       => [
+            'product-id' => 'product_id: Bagisto product ID (export only; import still matches by SKU)',
             'sku'        => 'sku: existing product SKU (required, not used to rename SKU)',
             'locale'     => 'locale: store locale code; empty uses the default channel locale',
             'core'       => 'name, url_key, short_description, description, price, special_price, weight, status (1/0), SEO fields',

+ 1 - 0
packages/Longyi/Core/src/Resources/lang/zh_CN/app.php

@@ -105,6 +105,7 @@ return [
         'message'       => '原因',
         'import-summary'=> '已更新 :updated 个产品,失败 :failed 行。',
         'columns'       => [
+            'product-id' => 'product_id:产品 ID(导出对照用,导入仍按 SKU 匹配,不能用来改 ID)',
             'sku'        => 'sku:已有产品 SKU(必填,不能用来改 SKU)',
             'locale'     => 'locale:语言代码;留空则使用默认渠道语言',
             'core'       => 'name、url_key、short_description、description、price、special_price、weight、status(1/0)、SEO 字段',

+ 1 - 0
packages/Longyi/Core/src/Resources/views/admin/catalog/products/sync.blade.php

@@ -75,6 +75,7 @@
                     </p>
 
                     <ul class="list-inside list-disc space-y-1 text-sm text-gray-600 dark:text-gray-300">
+                        <li>@lang('longyi::app.product-sync.columns.product-id')</li>
                         <li>@lang('longyi::app.product-sync.columns.sku')</li>
                         <li>@lang('longyi::app.product-sync.columns.locale')</li>
                         <li>@lang('longyi::app.product-sync.columns.core')</li>

+ 1 - 0
packages/Longyi/Core/src/Services/ProductBasicInfoSyncService.php

@@ -521,6 +521,7 @@ class ProductBasicInfoSyncService
 
         return match ($normalized) {
             'category', '分类' => ProductBasicInfoColumns::CATEGORIES,
+            'id', 'productid', '产品id' => ProductBasicInfoColumns::PRODUCT_ID,
             default => $normalized,
         };
     }

+ 3 - 0
packages/Longyi/Core/src/Support/ProductBasicInfoColumns.php

@@ -6,6 +6,8 @@ class ProductBasicInfoColumns
 {
     public const SKU = 'sku';
 
+    public const PRODUCT_ID = 'product_id';
+
     public const LOCALE = 'locale';
 
     public const QTY = 'qty';
@@ -18,6 +20,7 @@ class ProductBasicInfoColumns
      * @var list<string>
      */
     public const HEADINGS = [
+        self::PRODUCT_ID,
         self::SKU,
         self::LOCALE,
         'name',

+ 1 - 0
packages/Longyi/Core/tests/Unit/ProductBasicInfoSyncServiceTest.php

@@ -210,6 +210,7 @@ class ProductBasicInfoSyncServiceTest extends TestCase
     public function test_headings_match_export_contract(): void
     {
         $this->assertSame([
+            'product_id',
             'sku',
             'locale',
             'name',