-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Problem description:
When use PUT API calls for change "types" field on one image of product, thera are problems.
For exampe, If we want assing Types="Thumbnail" to image with ID 15 and there is other image in the same product that have alrady assigned "thumbnail" and this last image have higher ID, for example ID 19, then PUT action will not update Types field. In the opossite case, if we try assign "Thumbnail" to image with id 19 and image with ID 15 have assigned this type, PUT action will update them successful.
In resume, PUT media API Call apply change at types values only when ID of image is lower than ID image that have "Types" values assigned before.
Preconditions
Magento 2
Version: 2.1.x (tested on 2.1.1 and 2.1.3)
EC2 Instance of AWS Amazon with CentOS
PHP v7.0.10
Mysql 5.6
Also was tested on local environment with Vagrant with CentOS.
Steps to reproduce
- Create with API new product with sku SUN001
- Add 3 different images with API Call POST /V1/products/SUN001/media
- Assing with PUT the Types value "images","small_image","thumbnail". Example:
PUT
{{base_url}}/rest/V1/products/sun-001/media/19
{
"entry": {
"id" : "19"
"media_type": "image",
"label": "image 3",
"disabled": false,
"position" : 0,
"types": [
"images",
"small_images",
"thumbnail"
]
}
}
4. Try now assign types values to image with lower id in the same product, for example:
PUT
{{base_url}}/rest/V1/products/sun-001/media/15
{
"entry": {
"id" : "15"
"media_type": "image",
"label": "image 3",
"disabled": false,
"position" : 0,
"types": [
"images",
"small_images",
"thumbnail"
]
}
}
5. When you check images at backend or with GET of product data at API call, you can see that image with ID 19 and ID 15 is not updated correctly. Image ID 19 keep types value without update.
Expected result
- We wait that image with lower ID get the types values assigned and image with higher ID be emtpy at Types field.
Actual result
- When you check images at backend or with GET of product data at API call, you can see that image with ID 19 and ID 15 is not updated correctly. Image ID 19 keep types value without update.