3

In Magento 1, we get the 'order_increment_id' when we use the 'order_creditmemo.info' parameter in SOAP API.

The same thing I want to fetch in Magento 2 SOAP API. But when I am trying to get order_increment_id by using 'salesCreditmemoRepositoryV1'. It does not return the 'order_increment_id'.

Can someone please help me to get 'order_increment_id' by using any other Repository?

$response = $request->salesCreditmemoRepositoryV1GetList(array('searchCriteria' => ''));

    $fullData = objectToArray($response);

    function objectToArray($d) {
    if (is_object($d)) {
        // Gets the properties of the given object
        // with get_object_vars function
        $d = get_object_vars($d);
    }

    if (is_array($d)) {
        /*
        * Return array converted to object
        * Using __FUNCTION__ (Magic constant)
        * for recursive call
        */
        return array_map(__FUNCTION__, $d);
    }
    else {
        // Return array
        return $d;
    }
} 
$creditmemos = $fullData['result']['items']['item'];

      foreach ($creditmemos as $creditmemo) {
                $response1 = $request->salesCreditmemoRepositoryV1Get(array('id' => $creditmemo['incrementId']));
                 $fullMemoResult = $this->objectToArray($response1);
                echo "<pre>";print_r($fullMemoeResult);
            }

    ?>
1

You have to pass \Magento\Sales\Api\OrderRepositoryInterface in construct of your class.

Then try this one,

$order = $this->orderRepository->get($orderId);
$orderIncrementId = $order->getIncrementId();

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.