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

Problems update attribute with rest API #5963

Closed
CodeGlitcher opened this issue Aug 3, 2016 · 11 comments
Closed

Problems update attribute with rest API #5963

CodeGlitcher opened this issue Aug 3, 2016 · 11 comments
Assignees
Labels
bug report Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@CodeGlitcher
Copy link

Preconditions

  1. Install Magento 2.1.0

Steps to reproduce

  1. Create a selectable attribute.
    image
  2. Update the attribute with the rest api

put /rest/V1/products/attributes/{attribute_code}
body:

{
    "attribute":
        {

              "attribute_id": 192,
              "default_frontend_label": "Color2"
        }
}

Expected result

  1. The default frontend label is set to Color2

Actual result

  1. An new empty option is added to the attribute
    image

Sending an empty options array has the same result.

{
    "attribute": {
        "attribute_id": 192,
        "attribute_code": "color",
        "default_frontend_label": "Color2",
        "options": []
    }
}

Another little thing. If you update the attribute labels using frontend_labels:

{
    "attribute": {
        "attribute_id": 192,
        "attribute_code": "color",
                "default_frontend_label": "color",
        "frontend_labels": [
        {
            "store_id": 1,
            "label": "kleur"
        },
        {
            "store_id": 2,
            "label": "test"
        }]
    }
}

the field default_frontend_label is ignored.

@j4hangir
Copy link

This might be relevant, but here having the same exact version of Magento, it is impossible to create a new attribute:

post /rest/V1/products/attributes
body:
{ 'attribute': { 'default_frontend_label': 'azmun', 'frontend_labels': [{'store_id': 1, 'label': 'azmun'}], 'is_required ': False, 'frontend_input': 'azmun' } }

While the same exception will be thrown:
Exception: {"message":"%fieldName is a required field.","parameters":{"fieldName":"frontend_label"}}

@SerhiyShkolyarenko SerhiyShkolyarenko self-assigned this Sep 12, 2016
@SerhiyShkolyarenko SerhiyShkolyarenko added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Sep 12, 2016
@SerhiyShkolyarenko
Copy link
Contributor

Hi @RobG66!
Thank you for reporting the issue. I managed to reproduce it on the latest develop branch. default_frontend_label is set properly in my case, but empty value is added on each request.
Also, I reproduced inability to reset options. Our internal issue is MAGETWO-58290.

@SerhiyShkolyarenko
Copy link
Contributor

Hi @j4hangir!
'attribute_code" is required field for any attribute, but I don't see it in your data.
I managed to create new attribute with the following data:
{ "attribute": { "is_visible": true, "extension_attributes": {}, "attribute_code": "azmun", "frontend_input": "text", "entity_type_id": 4, "is_required": false, "options": [ ], "is_user_defined": true, "default_frontend_label": "azmun", "frontend_labels": [ { "store_id": 0, "label": "azmun_front_lagel" } ] } }

@SerhiyShkolyarenko
Copy link
Contributor

SerhiyShkolyarenko commented Sep 13, 2016

@RobG66 we investigated that service(put /rest/V1/products/attributes/{attribute_code}) a bit.
When it works with options, it is oriented on merging new options only, so resetting doesn't work.
For more fine-grained attribute options management please use /V1/products/attributes/:attributeCode/options service.
In the issue MAGETWO-58290 we will fix adding empty value to the options list.

@SerhiyShkolyarenko
Copy link
Contributor

Created a separate issue for default_frontend_label ignoring(MAGETWO-58609).

mmansoor-magento pushed a commit that referenced this issue Sep 20, 2016
Bug
MAGETWO-56699 [GITHUB] Paypal checkout not possible with products that have custom options #5938 - for mainline
MAGETWO-58290 [Github]Empty product option is added on each PUT request #5963
MAGETWO-58136 [Github] Shipping and billing address are not set if order placed with payment action Sale #6438
MAGETWO-55608 [GITHUB] M2.1: Not scrollable picture on mobile / product page #5302
MAGETWO-58285 Ajax error message doesn't display in backend
MAGETWO-58338 [Github]Problem adding attribute options that start with a number via REST Api #5715
MAGETWO-52575 Unable to apply free shipping to specified method when creating order in admin
MAGETWO-57078 [GITHUB] Can't set customer group when creating a new order in the admin. #6162
MAGETWO-58039 Table rate shipping not applying correctly - for mainline
@SerhiyShkolyarenko
Copy link
Contributor

MAGETWO-58290 is delivered to develop branch

@SerhiyShkolyarenko
Copy link
Contributor

MAGETWO-58609 is delivered to develop branch. Closing the issue. Please feel free to leave comments if the issue is still reproducible for you.

@Ctucker9233
Copy link

@SerhiyShkolyarenko Is MAGETWO-58290 going to be included in 2.1.3?

@SerhiyShkolyarenko
Copy link
Contributor

@Ctucker9233 unfortunately, no. Internal issue for backporting to 2.1 is MAGETWO-61922.

@Ctucker9233
Copy link

@SerhiyShkolyarenko Thanks. Do you have the commit numbers for MAGETWO-58609? Do you know if those commits are safe to integrate into a 2.1.2 production environment with a live website as they currently exist?

@SerhiyShkolyarenko
Copy link
Contributor

@Ctucker9233 commits are 421ded5 and d3853ae. These changes were not tested on v.2.1.x.

magento-engcom-team pushed a commit that referenced this issue Aug 9, 2020
[TSG] MC-36343: Unnecessary quotes causes invalid HTML in tracking.phtml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests

5 participants