0

I want to get all Pending order Status Orders using GraphQL, Anyone can share a complete example or module. How to I'll do that ?

I have create Custom module Admin Grid, Now i want to display Only Pending Orders in that grid. So i want to get all those orders using GraphQL. So Kindly help me on this. How to I'll do that ?

Thanks

1 Answer 1

0

For Check What is GraphQL in Magento 2, Read Blog, GraphQl in Magento 2

Check the link, Get List of Orders of Customer using GraphQl Magento 2 full module

For Get List of orders of Customer by customer id, You need to create a schema file for getting a response from Query.

In above you have declared schema file for getting multiple records of order for a specific customer.

type SalesOrder @doc(description: "Sales Order graphql gather Data of specific order information") {
    order_array: [String] @doc(description: "Array of order list.") }

In above order_array is used for getting an array of records but in your resolver, you made mistakes for multiple records.

In $orderCollection[] you need to pass array key for each record and you forgot to add that in your code.

You can try with,

foreach($orders as $k => $order) {
            $orderCollection['order_array'][$k] = [
                'increment_id' => $order->getIncrementId(),
                'grand_total' => $order->getGrandTotal(),
                'customer_id' => $order->getCustomerId(),
            ];
        }

Let me know if you have any query.

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.