Skip to content

Import product CSV url_key for the default (without store_view_code) should not update the url key in the frontend #36905

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

Closed
1 of 5 tasks
erwinschaap opened this issue Feb 22, 2023 · 51 comments
Assignees
Labels
Area: Admin UI Component: Url Issue: needs update Additional information is require, waiting for response Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: dev in progress Reported on 2.4.3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@erwinschaap
Copy link

Preconditions and environment

  • Magento version 2.4.3
  • Anything else that would help a developer reproduce the bug: multistore setup with products

Steps to reproduce

  1. Create one product and update the url key so in each store view there is a different url key (see result for an example)
  2. After the creation, upload a product import CSV with that specific product sku, store_view_code empty and for the url_key a different URL-key than already used in the product (see result for an example)

Expected result

The default URL key is updating to the new url key and for the specific store_views the value for the url_key in the backoffice AS in the frontend visible is the same

default: jacked
en: (default) jacked
nl: jas
fr: veste

import for default:
sku,store_view_code,url_key
1,,jack

backoffice:
default: jack
en: (default) jack
nl: jas
fr: veste

frontend:
default: jack
en: (default) jack
nl: jas
fr: veste

The overrides are still doing their work.. This is expected

Actual result

The url_key in the backoffice for a specific store view is still the initial url_key provided by the store, but the url_key in the frontend visible is now the url_key uploaded by product CSV import.

default: jacked
en: (default) jacked
nl: jas
fr: veste

import for default:
sku,store_view_code,url_key
1,,jack

backoffice:
default: jack
en: (default) jack
nl: jas
fr: veste

frontend:
default: jack
en: (default) jack
nl: jack
fr: jack

So all urls in the frontend are now the same url for each store but in the backoffice there are overiddes. This is NOT correct!

Additional information

No response

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
@m2-assistant
Copy link

m2-assistant bot commented Feb 22, 2023

Hi @erwinschaap. 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:


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 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.

@m2-assistant
Copy link

m2-assistant bot commented Feb 22, 2023

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: 👇

    1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    1. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
    1. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
    1. Verify that the issue is reproducible on 2.4-develop branch
      Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
      - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
      - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

@engcom-Dash engcom-Dash added the Reported on 2.4.3 Indicates original Magento version for the Issue report. label Feb 22, 2023
@engcom-Dash
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

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

@magento-deployment-service
Copy link

@engcom-Dash
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

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

@magento-deployment-service
Copy link

@engcom-Dash
Copy link
Contributor

Hi @erwinschaap ,

Could you please the share CSV file which you are utilising while import to reproduce the issue.That would be helpful for us to understand the expected result more clearly.

Thanks.

@engcom-Dash engcom-Dash added the Issue: needs update Additional information is require, waiting for response label Feb 23, 2023
@ryanpalmerweb
Copy link
Contributor

We are experiencing this issue on 2.4.5-p1 too, the url keys for the store views in the admin area are ignored and the frontend is still using default scope url keys, "use default" is not ticked.

@engcom-Dash
Copy link
Contributor

Hi @ryanpalmerweb ,

Could please share your CSV file which is utilising for this issue ,It will be very useful for to reproduce this issue.

Regards,

@erwinschaap
Copy link
Author

erwinschaap commented Mar 7, 2023

first.csv
update.csv

If you first import first.csv you have the basic settings for the product. If you then update it with the update.csv you will see that the url key in the frontend is not correct and in each store the same as the default, but in the backoffice you will see the existing url key overrides. @engcom-Dash

@engcom-Dash
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

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

@magento-deployment-service
Copy link

@engcom-Dash
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

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

@magento-deployment-service
Copy link

@engcom-Dash
Copy link
Contributor

Hi @erwinschaap ,

Thanks for Collaboration and Contribution,

Verified the issue in 2.4-develop instance,and the issue is not reproducible.

Preconditions:
Magento Version 2.4-develop Instance
PHP Version 8.1
Multiple Store Created.

Steps to Reproduce :

  • Install fresh magento instance
  • Create multi store in admin panel
  • Create one Product with URL key
  • After the creation, upload a product import CSV with that specific product sku, store_view_code empty with new URL key.
  • After import the CSV file Verify the URL key in Backend and Frontend.

Kindly Refer the below Screenshots:

Below Screenshots before Update the URL
url1
url2
url3
url4
url5

Below Screenshots After update the CSV(New URL) file with
url6
url7
url8

We are getting expected result which is the default URL key is updating to the new url key and for the specific store_views the value for the url_key in the Backend As well as in the frontend visible is the same.So this issue is not reproducible and Kindly provide more information if the issue is still reproducible.

Let us know if we are missing anything

Regards

@erwinschaap
Copy link
Author

@engcom-Dash The only difference is that we had an override in the second store view (US in your case, so not default value but another URL key). If you then update the global url key via import (so with an empty store_view_code) you will find an reproductible path

@engcom-Dash
Copy link
Contributor

engcom-Dash commented Mar 14, 2023

Hi @erwinschaap,

Thanks for quick response,

Issue confimred !

Verified the issue in 2.4-develop instance and its reproducible,Hence we are confirming the issue.

Preconditions:
Magento Version 2.4-develop
PHP version 8.1
Multi store created in admin panel

Kindly refer the below screenshots:
After importing the new csv file without store view code

1.Default URL key is Update as per the New CSV file.
im2
2.The New URL key(Which is create by admin)is not Updated,its showing with Initial url key
im3
3.Front end image with Updated URL key.
im1

Steps to Reproduce:

  • Install fresh magento instance
  • Create multi store in admin panel
  • Create one Product with URL key
  • After the creation, upload a product import CSV with that specific product sku, store_view_code empty with new URL key.
  • After import the CSV file Verify the URL key of Specific store view(US) and Default Store view and Front end

After we update with New CSV file with New URL key,It is updated in default store view and front end customer view.But the the New url key is not updated in Specific store view(US) its showing with initial URL key.So we are getting actual result as per the description and the issue is reproducible in 2.4-develop instance,Hence we are confirming the issue.

Regards,

@engcom-Dash engcom-Dash added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Component: Url Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch and removed Issue: needs update Additional information is require, waiting for response labels Mar 14, 2023
@erwinschaap
Copy link
Author

Hi @engcom-Dash, Before importing you first need to override in e.g. the US store the url key to another url key and after that you do exactly the same as in the video. You will see the difference at that moment,

@engcom-Dash
Copy link
Contributor

Hi @erwinschaap ,

Verified the issue in 2.4-develop and the issue is reproducible,Hence we are confirming the issue.
The url_key in the back-end for a specific store view is still the initial url_key provided by the store, but the url_key in the frontend visible is now the url_key uploaded by product CSV import.

Kindly refer the below screenshots:

Behaviour of Default store view and Specific store view After Updating the new URL key with store view code empty:
1.This is for Specific Store
Screenshot 2023-05-19 at 7 31 31 AM
2.This is for Default Store view
Screenshot 2023-05-19 at 7 31 44 AM
3.In front end Url key is updated with New URL key.
Screenshot 2023-05-19 at 7 31 21 AM
Screenshot 2023-05-19 at 7 32 45 AM

Thanks.

@engcom-Dash engcom-Dash added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Component: Url Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Area: Admin UI labels May 19, 2023
@github-jira-sync-bot
Copy link

❌ Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.adobe.com/browse/AC-8251

@m2-community-project m2-community-project bot added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: needs update Additional information is require, waiting for response labels May 19, 2023
@github-jira-sync-bot
Copy link

❌ You don't have permission to export this issue.

@engcom-Bravo
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

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

@magento-deployment-service
Copy link

@engcom-Bravo
Copy link
Contributor

Hi @erwinschaap,

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
1.Create multiple store views.
2.create a product.
3.change the url key for one of the store view by unchecking the default value.
4.Import the CSV file.

We have changed URL-KEY for english store view to Config after importing it should not change to global because we have unchecked use default value.After importing it is showing correctly in admin but with that URL-KEY we are not able to access the product.

Simple-Products-Inventory-Catalog-Magento-Admin (4)

Screenshot 2023-05-23 at 5 47 10 PM

For default store view it is working fine because we have not unchecked the use default value.When we import CSV file with store view code it will update values for all store views.for english store view it will not update because we have unchecked use default value.

Screenshot 2023-05-23 at 5 31 19 PM

Hence confirming the issue.

Thanks.

@engcom-Bravo engcom-Bravo added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label May 23, 2023
@engcom-Hotel engcom-Hotel moved this to Dev In Progress in High Priority Backlog Aug 19, 2024
@leonhelmus
Copy link

leonhelmus commented Aug 28, 2024

I have the same issue on 2.4.6. Im now trying to create a patch for this issue. If anyone has an idea please let me know :).

@leonhelmus
Copy link

leonhelmus commented Aug 28, 2024

I have resolved it for me by adding this code to the catalog-url-rewrite module. It now checks if the url_key is set. Tested on 2.4.6-p7 and your magento installation should be higher than php 8.1

# When importing a product using the magento product importer check if url_key is set.
#
# Github link: https://github.com/magento/magento2/issues/36905

diff --git a/vendor/magento/module-catalog-url-rewrite/Observer/AfterImportDataObserver.php b/vendor/magento/module-catalog-url-rewrite/Observer/AfterImportDataObserver.php
--- a/vendor/magento/module-catalog-url-rewrite/Observer/AfterImportDataObserver.php	
+++ b/vendor/magento/module-catalog-url-rewrite/Observer/AfterImportDataObserver.php	(date 1724916404936)
@@ -22,6 +22,7 @@
 use Magento\Framework\App\Config\ScopeConfigInterface;
 use Magento\Framework\App\ObjectManager;
 use Magento\Framework\DataObject;
+use Magento\Framework\EntityManager\MetadataPool;
 use Magento\Framework\Event\Observer;
 use Magento\Framework\Event\ObserverInterface;
 use Magento\Framework\Exception\LocalizedException;
@@ -36,6 +37,8 @@
 use Magento\UrlRewrite\Model\UrlPersistInterface;
 use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
 use Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory;
+use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Model\Attribute\ScopeOverriddenValue;
 
 /**
  * @SuppressWarnings(PHPMD.TooManyFields)
@@ -212,10 +215,12 @@
         UrlPersistInterface $urlPersist,
         UrlRewriteFactory $urlRewriteFactory,
         UrlFinderInterface $urlFinder,
+        private readonly MetadataPool $metadataPool,
         MergeDataProviderFactory $mergeDataProviderFactory = null,
         CategoryCollectionFactory $categoryCollectionFactory = null,
         ScopeConfigInterface $scopeConfig = null,
-        CollectionFactory $collectionFactory = null
+        CollectionFactory $collectionFactory = null,
+        private ?ScopeOverriddenValue $scopeOverriddenValue = null
     ) {
         $this->urlPersist = $urlPersist;
         $this->catalogProductFactory = $catalogProductFactory;
@@ -234,6 +239,8 @@
             ObjectManager::getInstance()->get(ScopeConfigInterface::class);
         $this->productCollectionFactory = $collectionFactory ?:
             ObjectManager::getInstance()->get(CollectionFactory::class);
+        $this->scopeOverriddenValue = $scopeOverriddenValue ?: \Magento\Framework\App\ObjectManager::getInstance()
+            ->create(ScopeOverriddenValue::class);
     }
 
     /**
@@ -382,7 +389,27 @@
         if ($product->getVisibility() == (string)Visibility::getOptionArray()[Visibility::VISIBILITY_NOT_VISIBLE]) {
             return;
         }
-        $products[$product->getId()][$storeId] = $product;
+
+        $metadata = $this->metadataPool->getMetadata(ProductInterface::class);
+        $product->setData($metadata->getLinkField(), $product->getId());
+
+        $overwritten = $this->scopeOverriddenValue->containsValue(
+            ProductInterface::class,
+            $product,
+            \Magento\Catalog\Api\Data\ProductAttributeInterface::CODE_SEO_FIELD_URL_KEY,
+            $storeId
+        );
+
+        $product->unsetData($metadata->getLinkField());
+
+        if (
+            $this->isGlobalScope($product->getStoreId()) &&
+            !$overwritten
+        ) {
+            $products[$product->getId()][$storeId] = $product;
+        } elseif (!$this->isGlobalScope($product->getStoreId())) {
+            $products[$product->getId()][$storeId] = $product;
+        }
     }
 
     /**

@engcom-Delta
Copy link
Contributor

Hi @erwinschaap ,

Thanks for your reporting and collaboration.
We have tried to reproduce the issue again in Latest 2.4-develop instance and we are not able to reproduce the issue.Kindly refer the screenshot.

Steps to reproduce :
Steps to reproduce
1.Create multiple store views.
2.create a product.
3.change the url key for one of the store view by unchecking the default value.
4.Import the CSV file.

update.csv

We have changed URL-KEY for german store view to Config after importing it should not change to global because we have unchecked use default value.After importing it is showing correctly in admin and frontend.

Image

For default store view it is working fine because we have not unchecked the use default value.When we import CSV file with store view code it will update values for all store views.for german store view it will not update because we have unchecked use default value.

Image

Can you please re-verify in latest 2.4-develop instance and confirm.
Thanks.

@engcom-Delta engcom-Delta added Issue: needs update Additional information is require, waiting for response and removed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Apr 11, 2025
@engcom-Hotel engcom-Hotel moved this to Ready for Development in High Priority Backlog Apr 14, 2025
@engcom-Delta
Copy link
Contributor

Hi @erwinschaap ,

This issue is being closed since it has not been updated in a long time.
Please feel free to reopen or raise a new ticket if the issue still exists.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Admin UI Component: Url Issue: needs update Additional information is require, waiting for response Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: dev in progress Reported on 2.4.3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
Status: Ready for Development
Development

No branches or pull requests

9 participants