cancel
Showing results for 
Search instead for 
Did you mean: 

Using "or" logical operator in Magento SOAP V1 API

Using "or" logical operator in Magento SOAP V1 API

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 look 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 containing "Robert" AND the surname containing "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?