Your problem lies inside the order repository extensions this call:
OrderRepository.Service.Load<IPurchaseOrder>()
Will always just load IPurchaseOrder for the current user and with the "Default" name.
It is called Load and not List for a reason.
The way we normally solve this is to write raw sql to list the Ids of those PurchaseOrders we want and then use the Load overload that takes an Id and retrieve them one by one.
Yes I know raw sql isn't encouraged in anyway, but if you find an alternative let me know.
Although if you prefer you could try and navigate the old Mediachase library:
Mediachase.Commerce.Orders.OrderContext.Current.FundPurchaseOrders(...)
Was a long time since I tried using those thou and I can't vouch for their performance. :P
First of all I'd suggest to use the term of "purchase order" here. I know "transactions" might have same meaning in some context, but for the consistency and to avoid confusion, we should use the term "purchase order".
If you want to find purchase orders which were created in a period, you would need to use OrderContext.FindPurchaseOrders.
SqlMetaWhereClause can be like "META.Created BETWEEN {startTime} AND {endTime}"
I have created a schedule job to get commerce transactions from episerver commerce and process into our backend systems.
In development it appeared to be working fine – getting transactions from episerver commerce putting the information into a csv file
and then FTPing to a remote server (and this worked whether the job was run manually or via the schedule). But it seemed only to have
worked because it was only getting the transactions which I had created on the development setup.
However, when I moved the schedule job to a test server where transactions have been done by other users, I noticed it was only picking-up
transactions which were created under my user and no others – and this was I presume because I am running the scheduler under the context of
an Administrator user (my user).
Obviously, this is a far from satisfactory situation – I need to get all transactions and not just those associated with a particular user – so my question is:
How do I get ALL transactions out of episerver commerce using a schedule job and not just the transactions created by the user which is being
used as the context to run the schedule job? Note that if you run under the context of a no user, you get no transactions back.
Alternatively, how do I run a schedule job under the context of the user which runs the Commerce Manager tool as this can see ALL of the
transactions? In other words, how do I run a schedule job under the context of a Commerce Manager user?
Relevant Code is:
Use this function to get PO's:
I use this function to set the user in the schedule code: