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

M2.1.1 : Re-saving a product attribute with a different name than it's code results in an error #6770

Closed
kanduvisla opened this issue Sep 27, 2016 · 6 comments
Labels
bug report Component: Catalog Fixed in 2.1.x The issue has been fixed in 2.1 release line 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.1.x The issue has been reproduced on latest 2.1 release 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

@kanduvisla
Copy link
Contributor

Preconditions

  1. Magento 2.1.1
  2. I have product attribute of the type 'dropdown', which name is 'Afmetingen uitwendig (BxDxH) in mm' and it's code is 'afmetingen_uitwendig'.

Steps to reproduce

  1. Add a couple of options
  2. Save the attribute
  3. Add a couple of options more
  4. Re-save the attribute

Expected result

  1. Options should be added
  2. No errors should be shown

Actual result

Upon re-saving, Magento tries to re-create the attribute code:

screen shot 2016-09-27 at 15 33 34

As you can see, it seems that the existing attribute code is ignored. Further inspection of the form confirms this:

screen shot 2016-09-27 at 15 34 19

screen shot 2016-09-27 at 15 34 27

The problem here is obvious: setting the form to disabled="disabled" disables the form value from submitting. You can check this in the form data send in the request. The field attribute_code is missing here, thus Magento will generate a new attribute code.

The solution in my opinion is to change disabled="disabled" to readonly="readonly". This makes sure the field isn't editable, but it's value is still submitted.

@sevos1984
Copy link
Contributor

Problem is in attribute code length that can't be more than 30 symbols. If add code manually all works fine. I've create internal ticket for that MAGETWO-59153. Thanks for posting.

@sevos1984 sevos1984 added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Sep 29, 2016
@kanduvisla
Copy link
Contributor Author

This error still persists in M2.1.2. Is there any sight on when this is going to be fixed?

@kanduvisla
Copy link
Contributor Author

I've created a pull request that fixes this issue. What it does:

$attributeId = $this->getRequest()->getParam('attribute_id');

$attributeCode = $attributeId ?
    $this->attributeRepository->get($attributeId)->getAttributeCode() :
    $this->getRequest()->getParam('attribute_code');

if (!$attributeCode) {
    $attributeCode = $this->generateCode($this->getRequest()->getParam('frontend_label')[0]);
}

In other words:

When there is an attribute ID (which is the case with existing attributes), load the already known attribute code. If there is no attribute ID, try the 'old behaviour'. Which is: check for a param called attribute_code or try to generate a code according to the frontend_label.

@magento-engcom-team magento-engcom-team added 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Component: Catalog Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed labels Sep 11, 2017
@magento-engcom-team magento-engcom-team added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Oct 6, 2017
@magento-engcom-team
Copy link
Contributor

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

@magento-engcom-team magento-engcom-team added 2.2.x Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release 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 11, 2017
@raumatbel
Copy link
Contributor

@magento-engcom-team can you assign me please?

@okorshenko
Copy link
Contributor

@kanduvisla The issue has been fixed and delivered in 2.2-develop branch. Will be available with upcoming patch release.

@okorshenko okorshenko added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Dec 4, 2017
@okorshenko okorshenko added Fixed in 2.3.x The issue has been fixed in 2.3 release line Fixed in 2.1.x The issue has been fixed in 2.1 release line labels Dec 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Catalog Fixed in 2.1.x The issue has been fixed in 2.1 release line 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.1.x The issue has been reproduced on latest 2.1 release 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

6 participants