New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Url rewrites are all removed when mass updating visibility on store view when set to not visible indivudually. #34937
Comments
Hi @leonhelmus. Thank you for your report.
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:
For more details, review the Magento Contributor Assistant documentation. Add a comment to assign the issue: To learn more about issue processing workflow, refer to the Code Contributions.
🕙 You can find the schedule on the Magento Community Calendar page. 📞 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. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
Hi @engcom-Hotel. Thank you for working on this issue.
|
@magento give me 2.4-develop instance |
Hi @engcom-Hotel. Thank you for your request. I'm working on Magento instance for you. |
Hi @engcom-Hotel, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later. |
It seems it did not work @engcom-Hotel |
@magento give me 2.4-develop instance |
Hi @igorwulff. Thank you for your request. I'm working on Magento instance for you. |
Hi @igorwulff, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later. |
This is a proposition to solve the issue. The idea is to pass store ID to appropriate methods:
--- a/vendor/magento/module-catalog-url-rewrite/Observer/ProcessUrlRewriteOnChangeProductVisibilityObserver.php
+++ b/vendor/magento/module-catalog-url-rewrite/Observer/ProcessUrlRewriteOnChangeProductVisibilityObserver.php (date 1642437502101)
@@ -43,12 +43,13 @@
$event = $observer->getEvent();
$attrData = $event->getAttributesData();
$productIds = $event->getProductIds();
+ $storeId = $event->getStoreId();
$visibility = $attrData[ProductInterface::VISIBILITY] ?? 0;
if (!$visibility || !$productIds) {
return;
}
- $this->adaptUrlRewritesToVisibility->execute($productIds, (int)$visibility);
+ $this->adaptUrlRewritesToVisibility->execute($productIds, (int)$visibility, $storeId);
}
}
diff --git a/vendor/magento/module-catalog-url-rewrite/Model/Products/AdaptUrlRewritesToVisibilityAttribute.php b/vendor/magento/module-catalog-url-rewrite/Model/Products/AdaptUrlRewritesToVisibilityAttribute.php
--- a/vendor/magento/module-catalog-url-rewrite/Model/Products/AdaptUrlRewritesToVisibilityAttribute.php
+++ b/vendor/magento/module-catalog-url-rewrite/Model/Products/AdaptUrlRewritesToVisibilityAttribute.php (date 1642437629598)
@@ -65,9 +65,10 @@
*
* @param array $productIds
* @param int $visibility
+ * @param int $storeId
* @throws UrlAlreadyExistsException
*/
- public function execute(array $productIds, int $visibility): void
+ public function execute(array $productIds, int $visibility, int $storeId): void
{
$products = $this->getProductsByIds($productIds);
@@ -78,6 +79,7 @@
[
UrlRewrite::ENTITY_ID => $product->getId(),
UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
+ UrlRewrite::STORE_ID => $storeId,
]
);
} elseif ($visibility !== Visibility::VISIBILITY_NOT_VISIBLE) {``` |
@magento give me 2.4-develop instance |
The solution given above solve this issue. But it is not complete, problem still occurs when we change visibility back to "Catalog, Search", take a look at #35036 |
Hi @engcom-November. Thank you for working on this issue.
|
Verified the issue on Magento 2.4-develop branch and the issue is reproducible. |
✅ Jira issue https://jira.corp.magento.com/browse/AC-2535 is successfully created for this GitHub issue. |
✅ Confirmed by @engcom-Hotel. Thank you for verifying the issue. |
We also have a fix when doing this with the api will share it tomorrow |
This patch i applied for apis, sorry for the delay.
|
Hi @reporter , Kindly upgrade to the latest Magento version In case of any Magento related issues found in For any Magento related references, you may refer to the Magento user guide. Thanks! |
@engcom-Alfa thanks for solving it! |
Preconditions (*)
Steps to reproduce (*)
Expected result (*)
Actual result (*)
What my two cents tells me what it is.
I have debugged the issue and found out that the following observer does not take into account that the mass action can be done on store level (see
magento2/app/code/Magento/Catalog/Setup/CategorySetup.php
Line 722 in 8afdb98
While it does take account for the global way it does not take account that it can be set on store view. When you look at the dispatch of the event:
magento2/app/code/Magento/Catalog/Model/Product/Action.php
Line 92 in 8afdb98
It does pass a store id. I think the store level should be taken into account to resolve this issue.
I believe this is a S1 problem there are workarounds by changing it in the database or changing everything manual but it's a lot of work to fix. And this could give merchant problems with their SEO while they are not aware of it.
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
The text was updated successfully, but these errors were encountered: