Skip to content

Configurable product links and options creation through Magento REST API 2.4 #37770

Open
@goksasa

Description

@goksasa

Preconditions and environment

  • Magento version 2.4.5

We are trying to update a model through the Magento 2.4 REST API following the official guide published in Create a configurable product using bulk APIs.

Our query is about Defining configurable product options. When creating configurable-product options (POST /rest/default/async/bulk/V1/configurable-products/bySku/options) we are asked to add the values of the options, for example, if the configurable varies by "Color" we add the ids of the corresponding colors, here an example:

[
    {
        "sku": "61784",
        "option": {
            "attribute_id": "684",
            "label": "Golor",
            "position" means 0,
            "values": [
                {
                    "value_index": 11905
                }
            ],
            "is_use_default": true
        }
    }
]

But the result is not as expected, since the option is not created in the attribute configurable_product_options, which appears empty:

"configurable_product_options" : [
            {
                "id": 27296,
                "attribute_id": "684",
                "label": "Golor",
                "position" means 0,
                "values": [],
                "production" means: 47435
            }
        ],

This causes that in step 4, when trying to link variants to the configurable product, the service returns an error saying that it is not possible to do so since configurable does not have those options available:

{
    "operations_list": [
        {
            "id" means 0,
            "status": 3,
            "result_message": "The parent product doesn’t have configurable product options.",
            "error_code": 0
        }
    ],
    "user_type": 1,
    "bulk_id": "bb4a7....",
    "description": "Topic async.magento.configurableproduct.api.linkmanagementinterface.addchild.post",
    "start_time": "2023-07-18 13:53:35",
    "user_id": 2,
    "operation_count": 1
}

On the other hand, I have tried to inform directly configurable_product_options and configurable_product_links in the update of the model JSON body and in this case it has worked fine, although this way is not valid since configurable_product_links requires us to inform the ids of the products, which makes it unfeasible for bulk use, but gives us a hint that it may be necessary to report both somehow at the same time.

Does anyone faced this issue and knows if there is any solution or workaround?

Best regards!

Steps to reproduce

Create product options through POST /async/bulk/V1/configurable-products/bySku/options.

Link simple product to configurables through POST /async/bulk/V1/configurable-products/bySku/child.

Expected result

Product options are created successfully.

Actual result

Configurable product options is created but options values array is empty:

"extension_attributes": {
        "configurable_product_options": [
            {
                "id": 27297,
                "attribute_id": "684",
                "label": "Color",
                "position": 0,
                "values": [],
                "product_id": 47435
            }
        ]
    }

So when trying to link simples to configurables an error ocurrs:

{
    "operations_list": [
        {
            "id": 0,
            "status": 3,
            "result_message": "The parent product doesn't have configurable product options.",
            "error_code": 0
        }
    ],
    "user_type": 1,
    "bulk_id": "bb4a73f0-695b-44d9-b286-00e9fba64cf1",
    "description": "Topic async.magento.configurableproduct.api.linkmanagementinterface.addchild.post",
    "start_time": "2023-07-18 13:53:35",
    "user_id": 2,
    "operation_count": 1
}

Additional information

No response

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
    Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
    Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
    Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
    Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Activity

m2-assistant

m2-assistant commented on Jul 18, 2023

@m2-assistant

Hi @goksasa. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

goksasa

goksasa commented on Jul 19, 2023

@goksasa
Author

@magento give me 2.4-develop instance

magento-deployment-service

magento-deployment-service commented on Jul 19, 2023

@magento-deployment-service

Hi @goksasa. Thank you for your request. I'm working on Magento instance for you.

goksasa

goksasa commented on Jul 19, 2023

@goksasa
Author

Hi there,

I could reproduce the error I am talking about in this new instance.

Steps I followed (same as in the official guide Create a configurable product tutorial

Problems appear in Step 4. Define configurable product options

  1. New Configurable Product was created, sku TH352N006-F11. Without options.
  2. Options need to be updated through API (as our case). Call to https://2d17bd33bed233f5a0cbe12408d35f5b.instances-prod.magento-community.engineering/rest/default/V1/configurable-products/TH352N006-F11/options has been made with the following body:
{
    "sku": "TH352N006-F11",
    "option": {
        "attribute_id": "93",
        "label": "Color",
        "position": 1,
        "values": [
            {
                "value_index": 60
            }
        ]
    }
}
  1. Endpoint for retrieving SKU: https://2d17bd33bed233f5a0cbe12408d35f5b.instances-prod.magento-community.engineering/rest/default/V1/products/TH352N006-F11

After successful call, result has empty array for attribute extension_attributes > configurable_product_options > values.
Expected result is an array with Yellow colour option (value_index: 60).

Result JSON:

{
     "configurable_product_options": [
            {
                "id": 296,
                "attribute_id": "93",
                "label": "Color",
                "position": 1,
                "values": [],
                "product_id": 2047
            }
        ],
}

Exptected result:

{
     "configurable_product_options": [
            {
                "id": 296,
                "attribute_id": "93",
                "label": "Color",
                "position": 1,
                "values": [
                    {
                        "value_index": 60
                    }
                ],
                "product_id": 2047
            }
        ]
}

This situation blocks linking simples to configurables.

For giving access to Magento API, a new Integration has been created, you can check API Access Tokens and Secrets in the Integrations section. Tests have been done with Postman.

Best regards!

goksasa

goksasa commented on Jul 19, 2023

@goksasa
Author

Here are full JSONs.

expected_result.txt
result.txt

goksasa

goksasa commented on Jul 21, 2023

@goksasa
Author

Hello,

Error was reproduced in newly created Magento instancia.

Could you let us the next steps?

Best regards!

self-assigned this
on Jul 21, 2023
m2-assistant

m2-assistant commented on Jul 21, 2023

@m2-assistant

Hi @engcom-Bravo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
    3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
    4. Verify that the issue is reproducible on 2.4-develop branch
    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
    5. Add label Issue: Confirmed once verification is complete.
    6. Make sure that automatic system confirms that report has been added to the backlog.
goksasa

goksasa commented on Jul 21, 2023

@goksasa
Author

Hello @engcom-Bravo ,

We could reproduce the error in the instance, and you have got all details in the thread about how to reproduce the error.

Reproduced on 2.4.x
Issue: Confirmed

Best regards!

engcom-Bravo

engcom-Bravo commented on Jul 24, 2023

@engcom-Bravo
Contributor

@magento give me 2.4-develop instance

magento-deployment-service

magento-deployment-service commented on Jul 24, 2023

@magento-deployment-service

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

30 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @brideo@yannstlo@RickvanB@engcom-Bravo@goksasa

      Issue actions

        Configurable product links and options creation through Magento REST API 2.4 · Issue #37770 · magento/magento2