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

Attribute options are unexpectably modified during attribute update REST call #10157

Closed
okovalov-commer opened this issue Jul 5, 2017 · 4 comments
Labels
bug report Component: Catalog Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch 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

Comments

@okovalov-commer
Copy link

okovalov-commer commented Jul 5, 2017

Preconditions

  1. Magento 2.1.7

Steps to reproduce

  1. Install magento
  2. create an admin user and obtain a token to be used for rest calls
  3. create one more store view (to have two store views in total. those ids would be used in the payload as values for 'store_id'
  4. create a product attribute by making a POST call to {{baseurl}}/rest/V1/products/attributes and using given json payload
{
  "attribute": {
    "is_wysiwyg_enabled": false,
    "is_html_allowed_on_front": false,
    "used_for_sort_by": true,
    "is_filterable": false,
    "is_filterable_in_search": false,
    "position": 0,
    "apply_to": ["simple","virtual","configurable"],
    "is_searchable": "1",
    "is_visible_in_advanced_search": "1",
    "is_comparable": "0",
    "is_used_for_promo_rules": "0",
    "is_visible_on_front": "1",
    "used_in_product_listing": "1",
    "is_visible": true,
    "scope": "store",
    "extension_attributes": {},
    "attribute_code": "web_attribute_4",
    "frontend_input": "multiselect",
    "entity_type_id": "4",
    "is_required": false,
    "is_user_defined": true,
    "default_frontend_label": "web_attribute_4_def_frontend_label",
    "frontend_labels": [
      {
        "store_id": 1,
        "label": "web_attribute_4_label_en"
      }
    ] ,    
    "options": [
        {
            "label": "label opt1",
            "value": "value_opt1",
            "is_default": true,
            "store_labels": [
          {
            "store_id": 0,
            "label": "option_1_labl_adm"
          },
          {
            "store_id": 1,
            "label": "option_1_labl_en"
          }
         ]   
        },
        {
            "label": "label opt2",
            "value": "value_opt2",
            "store_labels": [
          {
            "store_id": 0,
            "label": "option_2_labl_adm"
          },
          {
            "store_id": 1,
            "label": "option_2_labl_en"
          }
         ]   
        }        
    ],
    "note": "dummy note",
    "backend_type": "varchar",
    "default_value": "0",
    "is_unique": "0",
    "custom_attributes": [
      {
        "attribute_code": "web_attribute_4",
        "value": "web_attribute_4_value"
      }
    ]
  }
}
  1. update an attribute using given json payload (NOTE replace YOUR_ID with an actual attribute_id from the previous step response )
{
  "attribute": {
    "attribute_id": **YOUR_ID**,
    "frontend_labels": [
      {
        "store_id": 1,
        "label": "web_attribute_4_label_en_new2"
      }
    ]    
  }
}

Expected result

  1. Only frontend label should be updated and NO changes in attribute options should be made when no option element is given in the payload
    image
    image

Actual result

  1. Options have been changed - one empty option being inserted at the top of the list, two remained options lost their Admin values which are replaced with Default store view values , wheare Default store values became empty.

image

image

PLEASE NOTE

Sending an array of options within an update payload does not help either (example of the payload below)

{
  "attribute": {
  	"attribute_id": **YOUR_ID**,
    "options": [
        {
            "label": "label opt1",
            "value": "value_opt1",
            "is_default": true,
            "store_labels": [
          {
            "store_id": 0,
            "label": "option_1_labl_adm"
          },
          {
            "store_id": 1,
            "label": "option_1_labl_en"
          }
         ]   
        },
        {
            "label": "label opt2",
            "value": "value_opt2",
            "store_labels": [
          {
            "store_id": 0,
            "label": "option_2_labl_adm"
          },
          {
            "store_id": 1,
            "label": "option_2_labl_en"
          }
         ]   
        }        
    ],  	
    "frontend_labels": [
      {
        "store_id": 1,
        "label": "web_attribute_4_label_en_new2"
      }
    ]    
  }
}

This way it causes options duplication

image

@misha-kotov misha-kotov added 2.1.x bug report Component: Catalog Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog labels Jul 6, 2017
@misha-kotov
Copy link

@okovalov-commer Do you need to have multiple store views set up to reproduce this (your payload refers to store_id=0 and store_id=1)? If that's the case, can you add this to preconditions? I was testing with one store view and am seeing somewhat different results.
The extra option being inserted on PUT is an existing issue reported in a previous GH issue: #5963. It is fixed in the develop branch.
I will try to reproduce the duplication next.

@okovalov-commer
Copy link
Author

@misha-kotov good point, thank you. that note has been added to the list of steps to reproduce

@RomanKrut
Copy link

@okovalov-commer Hi. Thanks for your report. The internal ticket was created MAGETWO-70522

@veloraven veloraven added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Jul 7, 2017
@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 Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed G1 Passed labels Sep 5, 2017
@magento-engcom-team
Copy link
Contributor

@okovalov-commer, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.
We tested the issue on 2.3.0, 2.2.0, 2.1.9

@magento-engcom-team magento-engcom-team added the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Catalog Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch 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
Projects
None yet
Development

No branches or pull requests

5 participants