magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Bug Report: Existing Image Name removed when image added via api #37835

Closed brideo closed 1 year ago

brideo commented 1 year ago

Preconditions and environment

Steps to reproduce

POST https://exmple.com/rest/V1/products/some-sku/media

{ "entry": { "position": 9999, "media_type": "image", "label": "Some Product Label", "disabled": false, "types": [ "image", "thumbnail", "small_image" ], "file": "1234.jpeg", "content": { "base64_encoded_data": "image_data", "type": "image\/jpeg", "name": "1001110080394.jpeg" } } }

Expected result

Actual result

Additional information

Replace the existing code within Magento\Catalog\Model\Product\Gallery\GalleryManagement::create:

// Existing code snippet
$product = $this->productInterfaceFactory->create();
$product->setSku($sku);
$product->setMediaGalleryEntries($existingMediaGalleryEntries);
try {
    $product = $this->productRepository->save($product);
} catch (\Exception $e) {
    if ($e instanceof InputException) {
        throw $e;
    } else {
        throw new StateException(__("The product can't be saved."));
    }
}

with

// Corrected code snippet
$product = $this->productRepository->get($sku);
$product->setMediaGalleryEntries($existingMediaGalleryEntries);
try {
    $product = $this->productRepository->save($product);
} catch (\Exception $e) {
    if ($e instanceof InputException) {
        throw $e;
    } else {
        throw new StateException(__("The product can't be saved."));
    }
}

Release note

No response

Triage and priority

m2-assistant[bot] commented 1 year ago

Hi @brideo. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

brideo commented 1 year ago

https://github.com/magento/magento2/pull/37836 - fixed and created a PR here

m2-assistant[bot] commented 1 year ago

Hi @engcom-Bravo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Bravo commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Bravo, here is your Magento Instance: https://e57249666a8a1edd856c4d4b991e2333.instances-prod.magento-community.engineering Admin access: https://e57249666a8a1edd856c4d4b991e2333.instances-prod.magento-community.engineering/admin_9d5f Login: c4d6f8f3 Password: 0278c3d85036

engcom-Bravo commented 1 year ago

Hi @brideo,

Thank you for reporting and collaboration.

Verified the issue on Magento 2.4-develop instance and the issue is not reproducible.Kindly refer the screenshots.

Steps to reproduce

{ "entry": { "position": 9999, "media_type": "image", "label": "Some Product Label", "disabled": false, "types": [ "image", "thumbnail", "small_image" ], "file": "1234.jpeg", "content": { "base64_encoded_data": "image_data", "type": "image\/jpeg", "name": "1001110080394.jpeg" } } }

Screenshot 2023-08-03 at 3 16 31 PM Screenshot 2023-08-03 at 3 37 24 PM

We have added image via REST API(name as Magento) and we are getting image name also could you please let us know if we are missing anything and also provide screenshots where exactly image name will be populated it will helps us to reproduce the issue.

Thanks.

brideo commented 1 year ago

when you send images it removes the name attribute.

https://patch-diff.githubusercontent.com/raw/magento/magento2/pull/37836.patch

See how before it creates an empty object, assigns an a sku, adds images then saves it?

engcom-Bravo commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Bravo, here is your Magento Instance: https://e57249666a8a1edd856c4d4b991e2333.instances-prod.magento-community.engineering Admin access: https://e57249666a8a1edd856c4d4b991e2333.instances-prod.magento-community.engineering/admin_4c59 Login: 23c951ec Password: f6f323258dbb

engcom-Bravo commented 1 year ago

Hi @brideo,

Thanks for your update.

Verified the issue on Magento 2.4-develop instance and the issue is not reproducible.Kindly refer the screenshots.

We have send the images using API

Screenshot 2023-08-17 at 4 11 08 PM Screenshot 2023-08-17 at 4 16 40 PM

After sending the images we are able to get the name attribute.

Screenshot 2023-08-17 at 4 13 01 PM

kindly let us know still if we are missing anything.Please provide screenshots if possible it will help us to proceed further.

Could you please elaborate the steps to reproduce regarding this comment https://github.com/magento/magento2/issues/37835#issuecomment-1676553454

Thanks.

engcom-Bravo commented 1 year ago

Hi @brideo,

Kindly provide latest update on this comment https://github.com/magento/magento2/issues/37835#issuecomment-1682195010 still you are working on this issue if you are able to reproduce the issue please elaborate the steps to reproduce.Please let us know still if you are facing any issue.

Thanks.

engcom-Bravo commented 1 year ago

Hi @brideo,

We have noticed that this issue has not been updated since long time.
Hence we assume that this issue is fixed now, so we are closing it. Please feel to raise a fresh ticket or reopen this ticket if you need more assistance on this.

Thanks.

brideo commented 1 month ago

hi @engcom-Bravo - I am still seeing this on 2.4.7-p2 but my patch is no longer working, how do I get a develop instance?