cancel
Showing results for 
Search instead for 
Did you mean: 

Feting List Of Orders and Customers

Feting List Of Orders and Customers

I have gone through Adobe Commerce API Docs for GraphQL, But in Orders API there is no Options to fetch the List of Orders.  https://developer.adobe.com/commerce/webapi/graphql/schema/orders/

For Customers API There are Options to fetch the Customer Using Customer Token, But for this we need to have customer username and password. But using Admin token I want to fetch list of Customers. Can anyone please guide me how can i do that?

 

Also i want to use date filter for customer, Orders, and Products, As per documentation i can use filter or search Attribute, but can't use Datetime filter on 'created_on' or 'modified_on' attribute in Adobe Commerce GraphQL API. 

3 REPLIES 3

Re: Feting List Of Orders and Customers

Hi @krishnendu9de9 

 

You may be looking for the customerOrders query 

 

Thanks

---
Problem Solved Click Accept as Solution!:Magento Community India Forum

Re: Feting List Of Orders and Customers

Hi @Mukesh Tiwari 

 

Let's Say i want to fetch all the orders since Last 7 days, and Integrate to any ERP, Then how can i filter Orders on basis of Datetime.

Please Provide the Solution for same scenario for Customers as well. 

 

Thanks!

Re: Feting List Of Orders and Customers

I think solution given here might be helpful for you.

1 Create a new Module HelloWorld.
2.Create a schema.graphqls in HelloWorld/Sales/etc/ folder to extend the CustomerOrderFilterInput.

 

Put following codes in this file:

input CustomerOrdersFilterInput @doc(description: "Identifies the filter to use for filtering orders.") {
    created_at: FilterRangeTypeInput @doc(description: "Filters by created at.")
}

input FilterRangeTypeInput @doc(description: "Defines a filter that matches a range of values, such as prices or dates.") {
    from: String @doc(description: "The beginning of the range")
    to: String @doc(description: "The end of the range")
}

3 Use the following payload and {{your URL}}/graphql to query the customer token.

mutation {
  generateCustomerToken(email: "{{your email address}}", password: "{{your password}}") {
    token
  }
}

4 Put above token in Postman Headers Authorization with Bearer {{your token}}.

5.Use following payload to query the above customer's sales orders.

query {
    customer {
        orders(filter: { 
            created_at: { 
                from: "2021-01-02"
                to: "2021-01-04"
            }}) { 
            items { 
                number  
                created_at 
            }
        }
    }
}

 

Hope this answer helps you.

---
Problem Solved Click Accept as Solution!:Magento Community India Forum