0

I'm unable to get the value of sales_order_address table custom column value in

rest/V1/orders/?searchCriteria[filter_groups][0][filters][0][field]=status&searchCriteria[filter_groups][0][filters][0][value]=processing");

5
  • is this question still something you do need an answer for? Jun 16, 2020 at 17:00
  • Yes I have not get any solution Jun 18, 2020 at 5:37
  • are you able to describe what you are trying to do? it seems you want to retrive the list of orders that are with the status processing? Jun 18, 2020 at 8:45
  • We have a partner vendor they just run order REST API with the search criteria order status in processing. While they run the order REST API they get all the values related to orders and shipping address under extension attributes. once they get shipping address id from this they will run the rest api to get customer address as hey are unable to get the door number value as this is a custom column in sales order address table. But they don't want to run the address api. they want door number in the order api itself. could you please suggest me a workaround. Jun 25, 2020 at 4:54
  • I have replied to 2 questions to date for you and add no answers accepted and no feedback whatsoever. You might see that is time wasted at my end. Apologies, I tried to help people who have a genuine sense of wha community is about Jun 25, 2020 at 5:08

1 Answer 1

0

If you append the searchCriteria to the url, the API tries to us the api call

 <route url="/V1/orders/:id" method="GET">
        <service class="Magento\Sales\Api\OrderRepositoryInterface" method="get"/>
        <resources>
            <resource ref="Magento_Sales::actions_view" />
        </resources>
    </route>

The below will returns the data your are looking for. It is more advanced and has the constraint to require Zend dependency. Fortunately, Magento uses Zend and so do most frameworks.

<?php
    $token = 'yourtoken';
            $httpHeaders = new \Zend\Http\Headers();
            $httpHeaders->addHeaders([
                'Authorization' => 'Bearer ' . $token,
                'Accept' => 'application/json',
                'Content-Type' => 'application/json'
            ]);
    
            $request = new \Zend\Http\Request();
            $request->setHeaders($httpHeaders);
            $request->setUri('http://<magentoroot>/index.php/rest/V1/orders');
            $request->setMethod(\Zend\Http\Request::METHOD_GET);
    
            $params = new \Zend\Stdlib\Parameters([
                'searchCriteria' => [
                    'filterGroups' => [
                        0 => [
                            'filters' => [
                                0 => [
                                    'field' => 'status',
                                    'value' => $input->getArgument('status'),
                                    'condition_type' => 'eq'
                                ]
                            ]
                        ]
                    ],
                    'current_page' => 1,
                    'page_size' => 10
                ],
            ]);
    
            $request->setQuery($params);
    
            $client = new \Zend\Http\Client();
            $options = [
                'adapter'   => 'Zend\Http\Client\Adapter\Curl',
                'curloptions' => [CURLOPT_FOLLOWLOCATION => true],
                'maxredirects' => 0,
                'timeout' => 30
            ];
            $client->setOptions($options);
    
            $response = $client->send($request);
    
            $response = $response->getBody();

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.