3

I'm using SOAP V1 API in PHP and have set up a number of scripts using this API, all are working as expected. However, I've been asked to look at finding orders based on certain criteria and I'm not sure if there's a way I can do this.

I've got the following set up:

$filters = array(
             "complex_filter" => array(
                    array(
                        "key" => "customer_email",
                        "value" => array(
                            "key" => "like",
                            "value" => "%gmail%"
                        )
                    )
                )
                );
    $result = $client->salesOrderList($session, $filters);

This is looking at the salesOrderList call and asking for it to bring back any order where the email address contains the word "gmail". The results are as expected but I'd like to add the ability to be able to filter even more.

Is there a way I can go on to filter on the first name containing "Robert" OR the surname containing "Robert"?

I know if I use the following, it would look up any order where the first name contains "Robert" AND the surname contains "Robert", which brings back no results (because there's no orders with the first and last name being "Robert"):

$filters = array(
             "complex_filter" => array(
                    array(
                        "key" => "customer_email",
                        "value" => array(
                            "key" => "like",
                            "value" => "%gmail%"
                        )
                    ),
                    array(
                        "key" => "customer_firstname",
                        "value" => array(
                            "key" => "like",
                            "value" => "Robert%"
                        )
                    ),
                    array(
                        "key" => "customer_lastname",
                        "value" => array(
                            "key" => "like",
                            "value" => "Robert%"
                        )
                    )
                )
                );
    $result = $client->salesOrderList($session, $filters);

How can I add the "or" logical operator using this API?

1 Answer 1

0

Hope this helps you.

SearchCriteria OR Example for Magento 2

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.