Uploaded image for project: 'PUBLIC - Liferay Commerce'
  1. PUBLIC - Liferay Commerce
  2. COMMERCE-6505

Cannot update custom field in commerce product using PATCH method

    Details

    • Severity of Issue:
      Major

      Description

      Greetings Team

       

      The client has problems to update custom fields of a product in commerce through PATCH request. For this task, the client uses the response of a GET from to the following endpoint:

       

      http://hom-editora-portal-dxp.cloud.sp.senac.br/o/headless-commerce-admin-catalog/v1.0/products/{id}

       

      After modifying the request body, they proceed to use the PATCH method. However, they receive the following response:

       

      {
       "status": "INTERNAL_SERVER_ERROR",
       "title": "java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Locale"
       }

       

       

      They detected that the error is produced by the custom fields that the product has configured:

       

      "expando": {
        "area": {
          "pt_BR": "Comunicação Social"
         },
        "subarea": {
          "pt_BR": "Comunicação e Marketing"
         },
        "autor": {
          "pt_BR": "Rubens Ricupero"
         }
      }

       

       

      We have managed to reproduce the behaviour in a clean environment and we verified that these fields were created as "Make Field Localizable". We did another test by creating a new custom field without checking this option, when doing the PATCH request it works without problems. Below we show the steps taken to reproduce the behaviour:

       

      Custom Field Localizable

       

      1. We create the custom field "TestField" with the property "Make Field Localizable" selected (See Fig1).
      2. We obtain the information of a product with a GET request (See Fig2).
      3. We pass the response to the body of a PATCH request.
      4. We modify the value of the custom field and execute the request (See Fig3).
      5. The error message "INTERNAL_SERVER_ERROR" is received (See Fig4)

       

      Expected result:

      Custom fields are updated when using the PATCH request.

      Actual result:

      An error message is displayed when updating the field via PATCH request.

      Custom Field Not Localizable

       

      1. We create the custom field "TestField" and with the property "Make Field Localizable" deselected.
      2. We obtain the information of a product with a GET request (See Fig5).
      3. We pass the response to the body of a PATCH request.
      4. We modify the value of the custom field and execute the request (See Fig6).
      5. No error message was received, and we verified the change (See Fig7).

       

      Expected result:

      Custom fields are updated when using the PATCH request.

      Actual result:

      Custom field is updated when using the PATCH request.

       

      We ask for your support in fixing this issue.

      Thanks in advance

       

      * Please see Zendesk Support tab for further comments and attachments.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              marco.leo Marco Leo
              Reporter:
              piernicolo.pinna Pier Nicolò Pinna
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Packages

                  Version Package
                  7.4.3 CE GA4