2

I am using below curl_init like this,

$webSiteUrl = 'mydomain.com'

$last2DayUpdated = date('Y-m-d',(strtotime ('-1 day', strtotime(date('Y-m-d')))));

$ch = curl_init("{$webSiteUrl}/rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=updated_at&searchCriteria[filter_groups][0][filters][0][value]={$last2DayUpdated}&searchCriteria[filter_groups][0][filters][0][condition_type]=gteq");

But I want to fetch particular info like billing_address,customer_firstname,customer_lastname

For this, I need to use fields parameter.

But both parameters searchCriteria and fields are not working with each other. Only single parameter is working.

Anyone knows how can I use these both parameters together?

UPDATED:

I have tried as below, but not working.

$ch = curl_init("{$webSiteUrl}/rest/V1/orders?searchCriteria[filter_groups][0][filters][0][field]=updated_at&searchCriteria[filter_groups][0][filters][0][value]={$last2DayUpdated}&searchCriteria[filter_groups][0][filters][0][condition_type]=gteq&fields=billing_address,customer_firstname,customer_lastname");

2 Answers 2

0

I believe you need two different filters.

Not same API call but demonstrates how to do it

/magento/index.php/rest/V1/products/attributes?searchCriteria[filter_groups][0][filters][0][field]=attribute_code&searchCriteria[filter_groups][0][filters][0][value]=color&searchCriteria[filter_groups][0][filters][0][condition_type]=eq&searchCriteria[filter_groups][0][filters][1][field]=attribute_code&searchCriteria[filter_groups][0][filters][1][value]=size&searchCriteria[filter_groups][0][filters][1][condition_type]=eq

Although I've also just read online that there was a bug where didn't like this but it's been fixed since

1
  • You gave demo but used only 1 parameter 'searchCriteria', not both. I have updated the question that I am using both parameters but not working. Have you any demo of fetch order as I have explained in a question? Commented Jul 8, 2019 at 4:15
0

According to the devdocs:

GET /rest/V1/orders? searchCriteria[filter_groups][0][filters][0][field]=status& searchCriteria[filter_groups][0][filters][0][value]=pending& searchCriteria[sortOrders][0][field]=increment_id& fields=items[increment_id,entity_id]

fields query parameter requires the items key which is array of fields you want to expose.

Your Answer

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

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