Expand my Community achievements bar.

SOLVED

XPATH Query Question

Avatar

Level 5

Hi,

I am trying to get all the orders under user. I am using below XPTAH query.

/jcr:root/home/users/a/admin/commerce/orders//element(*)[@orderId] this result below records :

/home/users/a/admin/commerce/orders/order-2014-Apr-12 /home/users/a/admin/commerce/orders/order-2015-Apr-15 /home/users/a/admin/commerce/orders/order-2015-Apr-13

Now i have requirements that order should be in the sorted order as per booked(that i am looking for) , Other is i will have dynamic parameter which will I pass through the method in which i have the XPTH query executed e.g. 6 or ALL . 6 will display the last 6 months order only (that i am looking for). For all orders i can use the above query with sort condition. 

Below is QueryBuilder Query which also give me records but not for 6 months:

type=unstructured
path=/home/users/a/admin/commerce/orders
path.flat=true
orderby=@orderPlaced
orderby.sort=desc

Or some one has any idea about SQL2 Query for same use-case, Please tell.

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 5

vdhim23 wrote...

Hi,

I am trying to get all the orders under user. I am using below XPTAH query.

/jcr:root/home/users/a/admin/commerce/orders//element(*)[@orderId] this result below records :

  1. /home/users/a/admin/commerce/orders/order-2014-Apr-12
  2. /home/users/a/admin/commerce/orders/order-2015-Apr-15
  3. /home/users/a/admin/commerce/orders/order-2015-Apr-13

Now i have requirements that order should be in the sorted order as per booked(that i am looking for) , Other is i will have dynamic parameter which will I pass through the method in which i have the XPTH query executed e.g. 6 or ALL . 6 will display the last 6 months order only (that i am looking for). For all orders i can use the above query with sort condition. 

Thanks

 

 

This solved my problem :

1_relativedaterange.property=orderPlaced
1_relativedaterange.lowerBound=-6M
1_relativedaterange.upperBound=0

View solution in original post

2 Replies

Avatar

Correct answer by
Level 5

vdhim23 wrote...

Hi,

I am trying to get all the orders under user. I am using below XPTAH query.

/jcr:root/home/users/a/admin/commerce/orders//element(*)[@orderId] this result below records :

  1. /home/users/a/admin/commerce/orders/order-2014-Apr-12
  2. /home/users/a/admin/commerce/orders/order-2015-Apr-15
  3. /home/users/a/admin/commerce/orders/order-2015-Apr-13

Now i have requirements that order should be in the sorted order as per booked(that i am looking for) , Other is i will have dynamic parameter which will I pass through the method in which i have the XPTH query executed e.g. 6 or ALL . 6 will display the last 6 months order only (that i am looking for). For all orders i can use the above query with sort condition. 

Thanks

 

 

This solved my problem :

1_relativedaterange.property=orderPlaced
1_relativedaterange.lowerBound=-6M
1_relativedaterange.upperBound=0

Avatar

Level 10

Thank you for posting the solution.