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

How can I define the product listing order within a category?

Started by graemian, December 29, 2007, 10:00:30 pm

Previous topic - Next topic

graemian

Hello,

I'd like the products in a category to appear in a certain order. Is this possible in the base product, or will I have to customize? If it requires customization, what approach is recommended? Perhaps using a custom field to indicate sort order?

Thanks,
Graeme

trevor

Hi,

At the moment the Ordering of the products through the API call can be set using the DataDescriptorIf. The options are :

com.konakart.app.DataDescConstants.ORDER_BY_NAME_DESCENDING com.konakart.app.DataDescConstants.ORDER_BY_NAME_ASCENDING com.konakart.app.DataDescConstants.ORDER_BY_MANUFACTURER com.konakart.app.DataDescConstants.ORDER_BY_PRICE_DESCENDING com.konakart.app.DataDescConstants.ORDER_BY_PRICE_ASCENDING com.konakart.app.DataDescConstants.ORDER_BY_DATE_ADDED com.konakart.app.DataDescConstants.ORDER_BY_TIMES_READ
com.konakart.app.DataDescConstants.ORDER_BY_RATING com.konakart.app.DataDescConstants.ORDER_BY_TIMES_VIEWED com.konakart.app.DataDescConstants.ORDER_BY_TIMES_ORDERED

There is no order by custom field although this could be a useful feature and so we'll try to include it in a future release.
If you don't have many products, you can always retrieve them all from the DB and order them manually using the data in the custom fields. Alternatively you could change the products_date_added attribute in the DB (using SQL) and use that to order them.

Regards,

Trevor


Anni

hi everyone,

I have just a short question. in the ProductsBody.jsp I inserted

<%prodMgr.orderCurrentProds(prodMgr.getObDate());%>

to the top of the page, to sort the products by date. this worked fine, but recently I realised that this prevents me from using prev and next to view all products, if there are more than 20. I can still press the links (i.e. only next, as I'm on the first page) but I will always stay on that page.
deleting that line solved the problem but now the products are in random order again.

is there another place where I specify the product order?

regards,

anni

trevor

Hi Anni,

Take a look at SortProductAction.java. It calls kkAppEng.getProductMgr().orderCurrentProds() with a constant to define the sort order.

Trevor

Anni

thanks for the answer, but that action class is basically doing just the same as I did ...

and whenever I try to pre-sort the items, I can't browse through the product list. sorting the products by using the sort action works, of course. but I just need them sorted without using the action class.

regards

trevor

What API call do you use to get the products in the first place ?

Anni

as I said in my first post:

Quote
in the ProductsBody.jsp I inserted


<%prodMgr.orderCurrentProds(prodMgr.getObDate());%>


to the top of the page, to sort the products by date.


the top of the page means, where all bean definitions are done. but I've also tried it within the actual content part of that jsp, with slightly different results, but still I wasn't able to browse through the pages  ???

trevor

That jsp is used in many situations. It is called in order to display the product data after many different action classes have executed (you can see this from the struts-config.xml file). If you need to sort the products in a specific way, you must edit the action classes so that the data is retrieved from the database sorted correctly when the action class makes the API call.