0

In magento 2.4.6 I have a custom module that adds some configuration in the admin panel. I also have a Helper/Data.php with methods to collect the value of each field of this configuration. On the other hand I am using this endpoint to obtain product data:

http://domain.com/rest/V1/products?searchCriteria[filter_groups][0][filters][0][field]=status&searchCriteria[filter_groups][0][filters][0][value]=1

and its output is like this:

{
"items": [
    {
        "id": 266,
        "sku": "TEST",
        "name": "Test product",
        "attribute_set_id": 4,
        "price": 0.006001,
        "status": 1,
        "visibility": 4,
        "type_id": "simple",
        "created_at": "2023-06-07 10:24:30",
        "updated_at": "2024-05-31 09:31:53",
        "weight": 1,
        "extension_attributes": {
            "website_ids": [
                1,
                4
            ],
            "category_links": [
                {
                    "position": -681624,
                    "category_id": "2"
                },
                {
                    "position": 25,
                    "category_id": "5"
                }
            ]
        },
        "product_links": [],
        "options": [],
        "media_gallery_entries": [
            {
                "id": 65,
                "media_type": "image",
                "label": "Test image",
                "position": 1,
                "disabled": false,
                "types": [
                    "image",
                    "small_image"
                ],
                "file": "/j/p/jp.png"
            }
        ],
        "tier_prices": [],
        "custom_attributes": [
            {
                "attribute_code": "tax_class_id",
                "value": "2"
            },
            {
                "attribute_code": "category_ids",
                "value": [
                    "2",
                    "5"
                ]
            }
        ]
    },
],
"search_criteria": {
    "filter_groups": [
        {
            "filters": [
                {
                    "field": "status",
                    "value": "1",
                    "condition_type": "eq"
                }
            ]
        }
    ]
},
"total_count": 117

}

I need to add in a different node, such as search_criteria or total_count, the content of the module configuration like this:

{
"items": [
    {
        "id": 266,
        "sku": "TEST",
        "name": "Test product",
        "attribute_set_id": 4,
        "price": 0.006001,
        "status": 1,
        "visibility": 4,
        "type_id": "simple",
        "created_at": "2023-06-07 10:24:30",
        "updated_at": "2024-05-31 09:31:53",
        "weight": 1,
        "extension_attributes": {
            "website_ids": [
                1,
                4
            ],
            "category_links": [
                {
                    "position": -681624,
                    "category_id": "2"
                },
                {
                    "position": 25,
                    "category_id": "5"
                }
            ]
        },
        "product_links": [],
        "options": [],
        "media_gallery_entries": [
            {
                "id": 65,
                "media_type": "image",
                "label": "Test image",
                "position": 1,
                "disabled": false,
                "types": [
                    "image",
                    "small_image"
                ],
                "file": "/j/p/jp.png"
            }
        ],
        "tier_prices": [],
        "custom_attributes": [
            {
                "attribute_code": "tax_class_id",
                "value": "2"
            },
            {
                "attribute_code": "category_ids",
                "value": [
                    "2",
                    "5"
                ]
            }
        ]
    },
],
"search_criteria": {
    "filter_groups": [
        {
            "filters": [
                {
                    "field": "status",
                    "value": "1",
                    "condition_type": "eq"
                }
            ]
        }
    ]
},
"total_count": 117,
"fields_config": {
    "field1" : {
        "value": "field 1 value"
    },
    "field2" : {
        "value": "field 2 value"
    }
}

}

How can I add this content to already existing Magento endpoint? Thanks in advance

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.