Open kushaljindal92 opened 1 year ago
Hi @kushaljindal92. 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:
@magento give me 2.4-develop instance
- upcoming 2.4.x release@magento I am working on this
Join Magento Community Engineering Slack and ask your questions in #github channel. :warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting. :clock10: You can find the schedule on the Magento Community Calendar page. :telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.
Hi @engcom-Dash. 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:
Area: XXXXX
label to the ticket, indicating the functional areas it may be related to.2.4-develop
branch@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure. 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.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:
Area: XXXXX
label to the ticket, indicating the functional areas it may be related to.2.4-develop
branch@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure. 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.Issue: Confirmed
once verification is complete. Hi @kushaljindal92,
Thank you for reporting and collaboration.
Verified the issue on Magento 2.4-develop instance and the issue is reproducible.Kindly refer the screenshots.
Steps to reproduce
The role is assigned to the base store only and does not get assigned to another store.
Hence Confirming this issue.
Thanks.
:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-9083 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-Bravo. Thank you for verifying the issue.
Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
any fix to this? How something like this gets overlooked lmao, its 2024 such a important thing, I have to manually go trough each of my store views and update manually my image roles for each product I duplicate and I have a store with 10 languages...
Any updates?
Probably not a fix that Magento themselves want to have in the core but we have a work around which involves two plugins. The issue seems to stem from the fact that in the duplicate product process the default store is used and for the images this does not always match. For example if the image and roles are only set on store level then the values will be copied during the eav attribute copy section but not the image roles themselves as \Magento\Catalog\Model\Product\Gallery\CreateHandler::processMediaAttribute
will not be able to match the "new_image" with the values on the product as the product values will be null on the default store.
The first plugin in our workaround is an around plugin on \Magento\Catalog\Model\Product\Gallery\CreateHandler::execute
. Here we check if the product has the duplicate flag set. When the flag is set then we do not do the normal execute as this is what causes issues.
if ($product->getIsDuplicate() != true) {
return $proceed($product, $arguments);
}
return $product;
Our second plugin is an after plugin on \Magento\Catalog\Model\Product\Copier::copy
. Here we use the default Magento\Catalog\Model\Product\Gallery\CopyHandler
to copy the images from the original product to the new one. This means rather than creating new images for each duplicate product we just reference the original product's images on our new product.
$arguments = [
'original_link_id' => $product->getId()
];
$this->copyHandler->execute($result, $arguments);
return $result;
From our test cases this seems to be working and the images have the correct roles, can be updated and deleted as expected.
Preconditions and environment
Steps to reproduce
Example
Expected result
Roles in both stores level should be assigned correctly.
Actual result
The role is assigned to the base store only and does not get assigned to another store.
Additional information
No response
Release note
No response
Triage and priority