Skip to content

url_key is empty by product import even if not wanted #12641

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
benjamin-volle opened this issue Dec 11, 2017 · 10 comments
Closed

url_key is empty by product import even if not wanted #12641

benjamin-volle opened this issue Dec 11, 2017 · 10 comments
Labels
Component: ImportExport Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Progress: needs update

Comments

@benjamin-volle
Copy link

benjamin-volle commented Dec 11, 2017

url_redirect value is overrrided by each product import, even if it is not wanted

Preconditions

  1. Tested on Magento 2.2

Steps to reproduce

  1. Add some products to your instance
  2. Change url_key for one of them
  3. Import a file (append behavior) with only two columns : sku,price (including the previous product)

Expected result

  1. Prce is updated, url_key is not changed

Actual result

  1. Price is updated, but url_key is empty

The problem is that url_key is always generated by import, because of this addition :
ebc946a

In the past (before 2.2, the url_key value was stripped by the function :
\Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType::clearEmptyData

But now, since there was a modification from "empty" to "!isset", the '' (empty) value is not stripped.

@magento-engcom-team magento-engcom-team added Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed labels Dec 11, 2017
@magento-engcom-team
Copy link
Contributor

@synolia-bvo, thank you for your report.
This seems to be correct Magento behavior. Please refer to the Community Forums or the Magento Stack Exchange site for advice or general discussion about this.
Otherwise you may submit Pull Request with the suggested changes.

@benjamin-volle
Copy link
Author

benjamin-volle commented Dec 12, 2017

Well, I'm a little bit suprised by your answer.

I don't understand why any product import replaces the "url_key" of the imported products by an empty value, even if the column "url_key" is not in the imported file.

To fix this, I replaced the line :

if (!$attrParams['is_static'] && empty($rowData[$attrCode])) {
by
if (!$attrParams['is_static'] && (!isset($rowData[$attrCode]) || $rowData[$attrCode] === '')) {

in the \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType::clearEmptyData function.

@magento-engcom-team
Copy link
Contributor

@synolia-bvo, We are sorry for that reply - it concerned another reporter's issue. We posted it here accidentally. Now we've been trying to reproduce Your's one and we'll be back with the answer as soon as possible.

@magento-engcom-team
Copy link
Contributor

Hello again @synolia-bvo. For unknown reason the rows from the commit you refer to (ebc946a) are no more present in release version of 2.2.0 and as far as we tested in 2.2.1 either. Could You please specify what is the exact release name of the version You use (f. e. 2.2.0-rc13). Thank You.

@benjamin-volle
Copy link
Author

benjamin-volle commented Dec 13, 2017

The main problem is the row
$rowData[self::URL_KEY] = $this->getUrlKey($rowData);
and it is still present in last 2.2 : https://github.com/magento/magento2/blob/2.2/app/code/Magento/CatalogImportExport/Model/Import/Product.php , line 1589

(The deleted "if" has been transfered to the "clearEmptyData" function)

@magento-engcom-team
Copy link
Contributor

Yes @synolia-bvo, we confirm it. But not going deeply into details lets assume that in this context the code peace we are talking about does not cause the issue. At least we've been not able to reproduce it on neither of the versions we've tested including the very one You provided us with in the Last comment. Could You please try to reproduce it on a freshly installed branch. Thank You.

@benjamin-volle
Copy link
Author

benjamin-volle commented Dec 13, 2017

Yes excuse me, the problem is only in branch 2.2-develop :

https://github.com/magento/magento2/tree/2.2-develop

which is the only one where the "empty" of the \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType::clearEmptyData function has been replaced by "!isset".

To summarize :
Either we cannot import a "0" value (this is why empty has been replaced by "!isset")
Or the url_key is empty by each import

@magento-engcom-team
Copy link
Contributor

@synolia-bvo, thank you for your report.
The issue is already fixed in 2.2.1

@magento-engcom-team magento-engcom-team added Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Dec 14, 2017
@sylvainraye
Copy link
Contributor

@magento-engcom-team fixed in 2.2.1 but reappeared in latest releases (2.2.4, 2.3) => #14478 cause of #12083

@peterjaap
Copy link
Contributor

I think this is now fixed in 2.2-develop (staged for 2.2.8 release) here; #17882

krisdante pushed a commit to magesuite/magento-patches that referenced this issue Jul 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: ImportExport Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Progress: needs update
Projects
None yet
Development

No branches or pull requests

5 participants