0

I want all orders from a particular orderId.

  <?php 
    namespace Racom\Chatbotapi\Model;

    use Racom\Chatbotapi\Api\ChatbotapiInterface;

    class Chatbotapi implements ChatbotapiInterface
    {
        protected $order;

        public function __construct(
            \Magento\Sales\Model\Order $order
        ) {
            $this->order = $order;
        }



        /**
         * Returns the Orders list.
         *
         * @api
         * @param Integer $orderId order Id.
         * @return string Greeting message with users name.
         */
        public function getOrder($orderId) 
        {
            $productCollection = $this->order->load($orderId);

            $a = $productCollection->getItems();

            $v = json_encode($a);

            return $v;
        }
    }
2

First we need to create api token an consumer key.

Goto the admin system->Extensions->Intergration->Add new Intergration.

error_reporting(E_ALL);
ini_set('display_errors', 1);

require('vendor/zendframework/zend-server/src/Client.php');
require('vendor/zendframework/zend-soap/src/Client.php');
require('vendor/zendframework/zend-soap/src/Client/Common.php');

$wsdlurl = 'http://127.0.0.1/magentoee2.5/soap/defaultwsdl&services=salesOrderManagementV1';

$token = 'uruw86n0pywpfcp11yk39cpgxh0dn4rq';

$opts = ['http' => ['header' => "Authorization: Bearer ".$token]];

$opts = ['http' => ['header' => "Authorization: Bearer "]];

$context = stream_context_create($opts);

$serviceArgs = array('searchCriteria'=> 
    array('filterGroups' => 
        [ 
            array ('filters' => 
                [
                    array('field' =>'id',
                          'value' => '1' , 
                          'condition_type' => 'eq')
                ]
            )
        ]
    )
);

$soapClient = new \Zend\Soap\Client($wsdlurl);

$soapClient->setSoapVersion(SOAP_1_2);

$soapClient->setStreamContext($context);

$result = $soapClient->salesOrderManagementV1GetStatus(array('id' => 20));

echo "<pre>"; print_r($result); 

Hope it helps.

| 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.