Search code examples
apishopware

How to get product data using productName with the help of API in shopware 6?


Which structure we can use to get product data using API.

I have tried the below filter but getting multiple product results.

{  "search": {
"products": {
    "limit": 1,
    "filter": [
        { "type": "equals", "field": "productNumber", "value": "test_sku" }
    ],
    "sort": [
        { "field": "name", "order": "ASC" }    
    ]
}  }}

Thank you in advance..


Solution

  • To search for a product by product number you can use the Admin API or the Store API:

    Admin API: POST /api/search/product

    Store API: POST /store-api/product

    The filter content is the same for both:

    {
        "filter": [
            {
                "type": "equals",
                "field": "productNumber",
                "value": "test_sku"
            }
        ]
    }