You need to extend product catalog repository for your requirement.
This can be done in multiple ways depending on your requirement.
A typical requirement will be to display popular items in a category when a user visits the category page. This can be achieved by adding a set property at the category level to store the popular items in that category. Your catalog administrator need to manage this setting.
Hope this helps.
If you are looking for something else, please be more specific on your requirements.
Keep posting the updates / questions.
Here is my requirement to show the "most purchase items" .How to full fill this requirement .
I would do the below high level approach ideally.
1. Add a property to sku item - number of purchases
2. In the CommitOrderFormHandler, add the qty of each commerce item to the number of purchases property of the corresponding sku
3. When user visits a category page, query the repository to get the top N number of most purchased items based on this new property (use might need to sort the results using queryoptions, type of caching also need to be discussed here)
Alternatively or more commonly, you can still have a property at sku level to say most purchased items and you can set them using BCC projects based on your sales data or by running offline queries against you DB.
The approach might be much simpler if you create an Endeca cartridge for the same, in case if you have Endeca in your technical stack.
Hope this helps.
Keep posting your questions / updates.
Thanks a lot for given approach,
In the 1st approach when there is an update in any SKU Item in versioned DB,I guess the value of newly added property(number of purchase)will be overridden from versioned DB, where the value is not incremented when any order is placed with this SKU. I understand that sku item's property will updated in non versinoed DB only. Please correct me if I'm wrong.
In the 2nd approach, I understand that the newly added property (most purchased items)to the sku need to be setup manually by a person to the sku whether the sku is the most purchase item or not.
You are right, the first approach suggested by Gopinath will not work properly and it is not recommended to update any catalog property during purchase journey. The second approach is driven by the Merchandiser where Merchandiser will be able to decide which are top selling to boost the sale of particular items in a marketing way.
If you need Top Selling items based on real purchase, design a new repository that contains SKU Id and/or productid, orderid and date. You can fill the data to this repository in two ways,
1) Update this table on submit of order i.e after authorizing the payment. The problem with this approach is that in some cases the customer will have a lead time to cancel or amend the order, you may need consider removing item in this case
2) Run a scheduler every day to get the items from the orders purchased on that day and update the repository.
Using this repository you can identify all the top selling items even for a given day and display to the customer.
Much thanks for given reply.
I am using the 2nd approach ,and I created the new repository as below.
<item-descriptor name="popularItem" display-property="popularDate" item-cache-size="1000" query-cache-size="1000" id-space-name="popularItem" cache-mode="disabled" display-name-resource="popularItem">
<table name="popular_item" type="primary" id-column-name="popular_item_id">
<property name="popularItem" column-name="popular_id" data-type="int" display-name-resource="popularItem" queryable="true" category-resource="popolarItemsInformationCategory">
<attribute name="propertySortPriority" value="1"/>
<property name="popularSku" column-name="sku_id" item-type="sku" repository="/atg/commerce/catalog/ProductCatalog" category-resource="popolarItemsInformationCategory"
<attribute name="propertySortPriority" value="2" />
Correct me if any thing wrong in the above .Could you please give me any information for writing an schedulers in atg.
You may need to add additional properties in your repository based on your requirements, considering for a a base solution this should be ok.
For scheduler implementation refer, Oracle ATG Web Commerce - Scheduler Services (Go through this chapter) and post your queries if required.
Could you please tell me how to get all the items from the orders(purchased on that day) ,I Guess there is a method in CRS module to get all the orders(doPostCommitOrderProcessing).But in my requirement we are not using the CRS module.
Could you please tell me how to get the orders.
I dont think there is any OOTB method you can directly use. You can define an RQL query like 'select order_id from order where date =?' and write a method in your OrderManager say List[<RepositoryItem>] getOrdersByDate(Date currentDate) and execute the RQL and return the list of orders.