2017-12-28 35 views
1

현재 Magento 2 REST API (Magento 2.2.1)를 통해 제품을 추가 할 수 있지만 주요 문제점이 1 개 있습니다.Magento 2 REST API 구성 가능한 제품에 축소판 이미지 지정

단일 제품으로 모든 것이 훌륭하게 작동하며 이미지로 이미지를 만들고 축소판으로 이미지를 지정할 수 있습니다. 그러나 구성 가능 제품에서는 이미지가 축소판으로 지정되지 않지만 여전히 성공적으로 업로드됩니다. 어떤 이유로 축소판, 이미지, small_image 및 견본 설정되지 않는 구성 제품

{ 
"product": { 
    "sku": "08130056-DARKNAVY", 
    "name": "Dakine Campus 25L Backpack - Dark Navy", 
    "price": "44.9900", 
    "status": "1", 
    "visibility": "4", 
    "type_id": "simple", 
    "weight": "1.0000", 
    "extension_attributes": { 
     "stock_item": { 
      "manage_stock": 1, 
      "qty": "1.0000", 
      "is_in_stock": true 
     } 
    }, 
    "options": [], 
    "tier_prices": [], 
    "media_gallery_entries": [{ 
     "media_type": "image", 
     "label": "Dakine Campus 25L Backpack - Dark Navy", 
     "position": "0", 
     "disabled": 0, 
     "types": [], 
     "file": "\/media\/catalog\/product\/i\/\/i\/m\/image_8735.jpg", 
     "content": { 
      "base64_encoded_data": "IMAGE BASE64 HERE", 
      "type": "image\/jpeg", 
      "name": "08130056 DARKNAVY" 
     } 
    }, { 
     "media_type": "image", 
     "label": "Dakine Campus 25L Backpack - Dark Navy", 
     "position": "0", 
     "disabled": 0, 
     "types": ["image", "small_image", "thumbnail", "swatch_image"], 
     "file": "\/media\/catalog\/product\/i\/\/i\/m\/image_8736.jpg", 
     "content": { 
      "base64_encoded_data": "IMAGE BASE64 HERE", 
      "type": "image\/jpeg", 
      "name": "08130056 DARKNAVY" 
     } 
    }], 
    "attribute_set_id": 62, 
    "custom_attributes": [{ 
     "attribute_code": "manufacturer", 
     "value": "503" 
    }, { 
     "attribute_code": "color", 
     "value": "452" 
    }, { 
     "attribute_code": "short_description", 
     "value": "<span>The Campus 25 litre follows the lead of our popular Campus 33 litre back-to-school backpack with a slightly smaller volume-great for smaller students or smaller workloads. Packed with all the same features including a large top compartment with a padded laptop sleeve and room for books and binders, a fleece lined pocket for sunglasses, a slim organiser pocket, and a handy insulated pocket to keep lunch and snacks cool. Padded shoulder straps and an adjustable sternum strap ensure a perfect fit. Dimensions =&nbsp;<\/span>18.5 x 12 x 9\" [ 47 x 31 x 23cm ]<div><ul><li>Limited Lifetime Warranty<\/li><li>600D Polyester<\/li><li>Fits most 14\" laptops<\/li><li>Insulated cooler pocket<\/li><li>Organiser pocket<\/li><li>Fleece lined pocket for sunglasses<\/li><li>Mesh side pockets<\/li><li>Adjustable sternum strap<\/li><\/ul><\/div><br>" 
    }, { 
     "attribute_code": "barcode", 
     "value": "610934177053" 
    }, { 
     "attribute_code": "category_ids", 
     "value": [350] 
    }, { 
     "attribute_code": "meta_title", 
     "value": "Dakine Campus 25L Backpack - Dark Navy" 
    }, { 
     "attribute_code": "meta_keyword", 
     "value": "dakine,campus,25l,backpack,-,dark,navy,urbansurfer,urban,surfer,mens,backpacks" 
    }, { 
     "attribute_code": "meta_description", 
     "value": "Dakine Campus 25L Backpack - Dark Navy - Shop online for a large range of including Dakine with fast, free shipping from an official stockist." 
    }, { 
     "attribute_code": "news_from_date", 
     "value": "2017-12-22 10:56:59" 
    }, { 
     "attribute_code": "news_to_date", 
     "value": "2018-01-22 10:56:59" 
    }] 
}, 
"save_options": true 
} 

을 그리고 여기 :

{ 
"product": { 
    "sku": "226787-705-29", 
    "name": "Levis Dawson Lace Up Boots - Dark Brown", 
    "price": "99.9900", 
    "status": "1", 
    "visibility": "4", 
    "type_id": "configurable", 
    "weight": 1, 
    "extension_attributes": { 
     "stock_item": { 
      "manage_stock": 1, 
      "qty": "0.0000", 
      "is_in_stock": true 
     } 
    }, 
    "options": [], 
    "tier_prices": [], 
    "media_gallery_entries": [{ 
     "media_type": "image", 
     "label": "Levis Dawson Lace Up Boots - Dark Brown", 
     "position": "0", 
     "disabled": 0, 
     "types": [], 
     "file": "\/media\/catalog\/product\/i\/\/i\/m\/image_8637.jpg", 
     "content": { 
      "base64_encoded_data": "IMAGE BASE64 HERE", 
      "type": "image\/jpeg", 
      "name": "226787 705 29" 
     } 
    }, { 
     "media_type": "image", 
     "label": "Levis Dawson Lace Up Boots - Dark Brown", 
     "position": "0", 
     "disabled": 0, 
     "types": [], 
     "file": "\/media\/catalog\/product\/i\/\/i\/m\/image_8638.jpg", 
     "content": { 
      "base64_encoded_data": "IMAGE BASE64 HERE", 
      "type": "image\/jpeg", 
      "name": "226787 705 29" 
     } 
    }, { 
     "media_type": "image", 
     "label": "Levis Dawson Lace Up Boots - Dark Brown", 
     "position": "0", 
     "disabled": 0, 
     "types": ["image", "small_image", "thumbnail", "swatch_image"], 
     "file": "\/media\/catalog\/product\/i\/\/i\/m\/image_8639.jpg", 
     "content": { 
      "base64_encoded_data": "IMAGE BASE64 HERE", 
      "type": "image\/jpeg", 
      "name": "226787 705 29" 
     } 
    }], 
    "attribute_set_id": 44, 
    "custom_attributes": [{ 
     "attribute_code": "manufacturer", 
     "value": "537" 
    }, { 
     "attribute_code": "color", 
     "value": "453" 
    }, { 
     "attribute_code": "short_description", 
     "value": "<span>Levis Dawson Lace Up Boots Dark Brown from Levi's are a great style option for your off-duty look. Featuring a soft leather outer, this pair has padded ankles for comfort and will team well with denim.<\/span><br><ul><li>Leather Comfort Insole<\/li><li>Anatomical Design<\/li><li>High Shock Absorption<\/li><li>Genuine Leather Coating<\/li><\/ul>" 
    }, { 
     "attribute_code": "barcode", 
     "value": "" 
    }, { 
     "attribute_code": "category_ids", 
     "value": [347] 
    }, { 
     "attribute_code": "meta_title", 
     "value": "Levis Dawson Lace Up Boots - Dark Brown" 
    }, { 
     "attribute_code": "meta_keyword", 
     "value": "levis,dawson,lace,up,boots,-,dark,brown,urbansurfer,urban,surfer,levi's,mens,shoes" 
    }, { 
     "attribute_code": "meta_description", 
     "value": "Levis Dawson Lace Up Boots - Dark Brown - Shop online for a large range of including Levi's with fast, free shipping from an official stockist." 
    }, { 
     "attribute_code": "news_from_date", 
     "value": "2017-12-15 14:56:33" 
    }, { 
     "attribute_code": "news_to_date", 
     "value": "2018-01-15 14:56:33" 
    }] 
}, 
"save_options": true 
} 

은 여기에 잘 작동 단일 제품 REST 호출입니다

두 유형 모두 "유형"이 동일하게 설정되어 있지만 Configurable Product에서는 무시 된 것처럼 보일 수 있습니다. Magento 2 로그에는 아무 것도 추적 할 수 없습니다.

이것은 우리가 가지고있는 모든 구성 가능 제품에 대해 일관되게 발생하지만, 모든 단일 제품은 훌륭하게 작동합니다. 어린이 제품에는 의도 한대로 이미지가 전혀 설정되어 있지 않습니다. 또한 하위 제품이없는 구성 가능 제품을 추가하여 테스트했으며 결과도 동일합니다.

Magento 2 관리자에서 수동으로 축소판 등을 설정할 수 있지만 이러한 REST 호출을 통해 자동화해야합니다. 나는 모든 종류의 것을 시도해 왔고, 잘못되어 가고있는 것을 고정시킬 수 없다.

답변

0

나는 동일한 문제가있었습니다.

솔루션 :

내가 모든 미디어 갤러리 항목을 나열 catalogProductAttributeMediaGalleryManagementV1을 사용 (GET을 통해 ".../V1/제품/TEST_SKU이/미디어"목록 "ID"및 기타 분야).

"media_type"= "image"로 첫 번째 이미지를 선택한 후 새 JSON 객체를 만들었습니다. PUT을 사용하여 전송 한 후

{ 
    "entry": 
    { 
     "id": 1086, 
     "media_type": "image", 
     "label": "This is my image description", 
     "position": 1, 
     "disabled": false, 
     "types": [ "image", "small_image", "thumbnail" ] 
    } 
} 

(예를 들어 ".../V1/제품/TEST_SKU/미디어/1086")가 올바르게 저장된 이미지.