KonaKart Community Forum

Installation / Configuration => Programming of KonaKart => Topic started by: ckool on April 02, 2008, 12:15:20 pm

Title: Getting option id and option value id in AdminOption object
Post by: ckool on April 02, 2008, 12:15:20 pm
I'm trying to get the option id and the the option value id from a Product Order but always get the value 0 (zero) for both attributes using the methods getId() and getValueId() in the object AdminOption.

I've got an Array of AdminOption objects using the the method getOpts() from an object AdminOrderProduct and my Konakart version  2.2.0.0.

Am I doing something wrong? How can I get the correct values for those attributes?

Thank you in advance.
Title: Re: Getting option id and option value id in AdminOption object
Post by: kate on April 02, 2008, 12:22:59 pm
Hi,

How did you get your AdminOrderProduct object in the first place?

Can you post a snippet of code?

Regards,
Kate
Title: Re: Getting option id and option value id in AdminOption object
Post by: ckool on April 02, 2008, 12:36:30 pm
Hi Kate,

Here is a snippet of code:

KKAdmin eng = new KKAdmin();
sessionId = eng.login(DEFAULT_USERNAME, DEFAULT_PASSWORD);

AdminOrder[] orders = eng.getOrdersCreatedSince(sessionId, yesterday, com.konakartadmin.bl.AdminLanguageMgr.DEFAULT_LANG);
for(int i=0;i<orders.length;i++)
{
  AdminOrder tmpOrder = orders;
  int orderId = tmpOrder.getId();
         
  AdminOrder order = eng.getOrderForOrderId(sessionId, orderId);

  AdminOrderProduct[] products = order.getOrderProducts();
  for(int j=0;j<numProducts;j++)
  {
    AdminOrderProduct orderProduct = products[j];
    AdminOption[] options = orderProduct.getOpts();
    for(int k=0;k<options.length;k++)
    {
      int optionId = option.getId();
      int valueId = option.getValueId();
    }
  }

}

Thank you for your help.
Title: Re: Getting option id and option value id in AdminOption object
Post by: ckool on April 02, 2008, 12:38:10 pm
I'm sorry, i forgot a line of code in the previous snippet, here is the correct snippet:

KKAdmin eng = new KKAdmin();
sessionId = eng.login(DEFAULT_USERNAME, DEFAULT_PASSWORD);

AdminOrder[] orders = eng.getOrdersCreatedSince(sessionId, yesterday, com.konakartadmin.bl.AdminLanguageMgr.DEFAULT_LANG);
for(int i=0;i<orders.length;i++)
{
  AdminOrder tmpOrder = orders;
  int orderId = tmpOrder.getId();
         
  AdminOrder order = eng.getOrderForOrderId(sessionId, orderId);

  AdminOrderProduct[] products = order.getOrderProducts();
  for(int j=0;j<numProducts;j++)
  {
    AdminOrderProduct orderProduct = products[j];
    AdminOption[] options = orderProduct.getOpts();
    for(int k=0;k<options.length;k++)
    {
      AdminOption option = options[k];
      int optionId = option.getId();
      int valueId = option.getValueId();
    }
  }

}

Thank you very much
Title: Re: Getting option id and option value id in AdminOption object
Post by: kate on April 02, 2008, 02:49:02 pm
Hi ckool,

The IDs aren't populated there but the values are:

Try using..

option.getName()
option.getValue()


.. in your final inner loop.

Regards,
Kate