0

I am using this API "http://localhost/test/rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=product_id&searchCriteria[filter_groups][0][filters][0][value]=24" to filter orders by product id.

But getting this message

"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'product_id' in 'where clause', query was: SELECT main_table.* FROM sales_order AS main_table WHERE ((product_id = '24'))".

If I am using filter on entity_id then it is working fine.I found in response that both of the fields stored at different positions.

eg. {
    "items": [
        {
            "entity_id": 1,
            "items": [
                {

                    "product_id": 14,
                }
            ]
        }
    ]
}

That's why API is not accepting "product_id" filter. So how can a I apply filter on "product_id"

  • a order itself doesn't have a productId. the productId is stored in the order-item – Philipp Sander Jul 24 '19 at 12:43
0

Magneto 2 does not allow to filter Orders by product's IDs so you have to write custom API(code) for it by Joining "sales_order_item" table.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.