• Welcome to KonaKart Community Forum. Please login or sign up.
 

get a list of orders that contains a product

Started by vpod, January 04, 2010, 09:26:17 pm

Previous topic - Next topic

vpod

Hello,

I need to create a jsp that shows a group of orders that contains a product.
Is there any way to make this using some api function?

Thanks.
Vpod

vpod

Well, I figured it out.
I'll share the solution with you. it may be usefull for someone else:

KKWSAdminIf adm = new KKWSAdminIfServiceLocator().getKKWSAdmin();

List<AdminOrder> ordenes = new ArrayList<AdminOrder>();

List<Record> records;
try {
Torque.init("torque.properties");

records = BasePeer
  .executeQuery("select orders_id, products_id " +
                       "from orders_products " +
                       "where products_id = " + products_id);

if (records != null) {
for (Iterator<Record>
         iterator = records.iterator();
         iterator.hasNext();)
{
Record rec = (Record) iterator.next();
int orders_id = rec.getValue(1).asInt();
AdminOrder orden = adm.getOrderForOrderId(sessionId, orders_id);
ordenes.add(orden);
}
}
} catch (TorqueException e) {
e.printStackTrace();
} catch (DataSetException e) {
e.printStackTrace();
}