Browse Source

feat(AlibabaAgent): 添加主图参数传递到SKU插入方法

- 在insertStoreSkus方法中新增$mainImage参数
- 将商品主图传递给SKU数据插入流程
- 为默认SKU设置主图为默认图片字段值
shichen 3 months ago
parent
commit
6bfe28ba59
1 changed files with 3 additions and 3 deletions
  1. 3 3
      app/services/ThirdParty/AlibabaAgent/ProductService.php

+ 3 - 3
app/services/ThirdParty/AlibabaAgent/ProductService.php

@@ -487,7 +487,7 @@ class ProductService extends AlibabaAgentBaseService
487 487
             ]);
488 488
 
489 489
             // 9. 写入 store_product_attr 和 store_product_attr_value
490
-            $this->insertStoreSkus($productId, $skuList, $merId, $costPrice);
490
+            $this->insertStoreSkus($productId, $skuList, $merId, $costPrice,$mainImage);
491 491
 
492 492
             Log::channel('alibaba')->info("[1688正式入库1] 商品{$importGoods['product_id']}入库成功,product_id={$productId},mer_id={$merId}");
493 493
 
@@ -509,7 +509,7 @@ class ProductService extends AlibabaAgentBaseService
509 509
      * @param array $skuList    formatDetailResult 返回的 skuList
510 510
      * @param int   $merId
511 511
      */
512
-    protected function insertStoreSkus(int $productId, array $skuList, int $merId, $costPrice): void
512
+    protected function insertStoreSkus(int $productId, array $skuList, int $merId, $costPrice, $mainImage): void
513 513
     {
514 514
         if (empty($skuList)) {
515 515
             // 单规格:写入默认规格
@@ -525,7 +525,7 @@ class ProductService extends AlibabaAgentBaseService
525 525
                 'product_id'  => $productId,
526 526
                 'detail'      => json_encode(['规格' => '默认'], JSON_UNESCAPED_UNICODE),
527 527
                 'sku'         => '默认',
528
-                'image'       => '',
528
+                'image'       => $mainImage,
529 529
                 'cost'        => $costPrice,
530 530
                 'ot_price'    => $costPrice,
531 531
                 'price'       => $costPrice,