Skip to content
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

Duplicate Simple Product Throws Error: Undefined offset: 0 in SaveHandler.php on line 122 #11532

Closed
lee586 opened this issue Oct 17, 2017 · 18 comments
Assignees
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 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 Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@lee586
Copy link

lee586 commented Oct 17, 2017

Preconditions

  1. Magento CE 2.2
  2. PHP 7.1.10

Steps to reproduce

  1. Click on an existing simple product in the catalog manager
  2. Click the "Save & Duplicate" option

Expected result

  1. The product saves and creates a duplicate item

Actual result

  1. Saves the product but doesn't duplicate it. Throws the following error:
    Notice: Undefined offset: 0 in /home/store/public_html/vendor/magento/module-catalog/Model/Category/Link/SaveHandler.php on line 122
@lee586 lee586 changed the title Duplicate Simple Product: Notice: Undefined offset: 0 in SaveHandler.php on line 122 Duplicate Simple Product Throws Error: Undefined offset: 0 in SaveHandler.php on line 122 Oct 17, 2017
@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Oct 17, 2017
@lee586
Copy link
Author

lee586 commented Oct 18, 2017

Only able to replicate error on simple products that were created before version 2.2. Products I had created under 2.18 won't duplicate. New products created under 2.2 successfully duplicate.

@magento-engcom-team magento-engcom-team added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Oct 18, 2017
@alen9788
Copy link

Same issue here for the M2.2 can not duplicate the products.

After click the " save&duplicate"

Notice: Undefined offset: 0 in /var/www/wowlla.com/vendor/magento/module-catalog/Model/Category/Link/SaveHandler.php on line 122

@magento-engcom-team
Copy link
Contributor

@lee586, thank you for your report.
We've created internal ticket(s) MAGETWO-82173 to track progress on the issue.

@magento-engcom-team magento-engcom-team added 2.2.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Oct 18, 2017
@hezide
Copy link

hezide commented Oct 20, 2017

Same issue on 2.2.0...
Never happened before

@cih95
Copy link

cih95 commented Oct 27, 2017

The same problem to me.
after upgrade to 2.2.0

@keanass
Copy link

keanass commented Oct 27, 2017

same problem here 2.2.0
the product dosen't duplicate and show it saved bu nothing happen with the same error :
Notice: Undefined offset: 0 in /vendor/magento/module-catalog/Model/Category/Link/SaveHandler.php on line 122

@keanass
Copy link

keanass commented Oct 27, 2017

here is the solution for duplicate product :
go to your magento root dir then : /vendor/magento/module-catalog/Model/Category/Link/SaveHandler.php

replace the tset in mergeCategoryLinks function by this :

if ($key === false) {
$result[] = $newCategoryPosition;
} elseif (isset($oldCategoryPositions[$key])) {
if(intval($oldCategoryPositions[$key]['position']) != $newCategoryPosition['position']){
$result[] = $newCategoryPositions[$key];
unset($oldCategoryPositions[$key]);
}

}

@cih95
Copy link

cih95 commented Oct 28, 2017

When i change the code the result is:
The value specified in the URL Key field would generate a URL that already exists.

To resolve this conflict, you can either change the value of the URL Key field (located in the Search Engine Optimization section) to a unique value, or change the Request Path fields in all locations listed below:

  • laptop-asus-rog-g752vy-gc100d-1.html

  • kompjutri-i-laptopi/laptopi/laptopi-novi/laptop-asus-rog-g752vy-gc100d-1.html

  • gamers-1/gejm-rski-laptopi/laptop-asus-rog-g752vy-gc100d-1.html

@Userr017
Copy link

@keanass , This show for me http error 500 and No data to save. Error log, PHP Parse error: syntax error, unexpected end of file, expecting function (T_FUNCTION) in /vendor/magento/module-catalog/Model/Category/Link/SaveHandler.php on line 133

I have magento 2.2 same problem duplicate Simple Product doesn't work.

@cih95
Copy link

cih95 commented Nov 2, 2017

do anybody have a decision for this problem?

@sitiodocanoamarelo
Copy link

Does anyone knows if is this fixed in 2.2.1 ? I'm also facing this issue in 2.2.0

@alen9788
Copy link

Here we meet with anther issue "Invalid option value" when save the products at MCE 2.2.1

@okorshenko
Copy link
Contributor

The issue has been fixed and delivered to 2.2-develop branch. Will be available with 2.2.2 release

@okorshenko okorshenko added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Nov 13, 2017
@fwolfst
Copy link

fwolfst commented Nov 20, 2017

@sitiodocanoamarelo Same issue here on a 2.2.1 . I confirm the fix given by @keanass works for us. We also have the "follow-up" error about URL rewrites - not sure if that is related. Dealing with imported products I suspect it has something to do with the store_id of relevant attribute_values.

Btw from my experience and code reading, ugly workaround is to remove the product from all categories (or all but one?).

@sitiodocanoamarelo
Copy link

Thanks @fwolfst ,
I confirm both advices.
If I remove all the categories except one the issue is gone.
Fix by @keanass works for me on a 2.2.0 (thanks @keanass ;)

@magento-engcom-team
Copy link
Contributor

Hi @lee586. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#1289 by @magento-engcom-team in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming patch release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Jan 27, 2018
@lalitmalav
Copy link

lalitmalav commented Oct 23, 2018

configurable products ......Save and Duplicated product not working??

Throws the following error:
Notice: Undefined offset: 0 in /home/store/public_html/vendor/magento/module-catalog/Model/Category/Link/SaveHandler.php on line 122

do you have any solution ??

@shoetrees
Copy link

still broken in 2.3, fix not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 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 Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests