In Endeca Assembler 11.1 all are defined as
the components, even the Sorting’s are also defined as the Component . We can
see the tutorials how to write the sorting component, and how to inject it.
Create a Custom component, in the Follwing path
/com/endeca/infront/cartridge/model/sort
$class=com.infront.cartridge.model.SortOptionsRatingsConfig
$scope=request
label=By Rating
create a class that extends SortOptionConfig
import com.endeca.infront.cartridge.model.SortOptionConfig;
public class SortOptionsRatingsConfig extends
SortOptionConfig {
public String RATING_HIGH=”Rating|1”;
public SortOptionsRatingsConfig()
{
super();
}
public SortOptionsRatingsConfig(String
pLabel) {
mLabel
= pLabel;
}
private
String mLabel;
public
String getLabel() {
return
mLabel;
}
public
void setLabel(String pLabel) {
mLabel
= pLabel;
}
public
String getValue() {
// if the Soring value is Dynamically Dependent
then we can write the Business logic for generating Sort Dynamically.
return
RATING_HIGH;
}
}
Go to ResultsList
Component
atg\endeca\assembler\cartridge\handler\ResultsList.properties
and Register
the Component in the Sorteres property.
sorters=\
/com/endeca/infront/cartridge/model/sort/Ratings
/com/endeca/infront/cartridge/model/sort/Ratings
That’s It You will be getting the Sorting
by Reviews, while fetching the Results. The Main Constarint is you have to
define the Sorting Property as the
Double or the Alpha during indexing.
Hi Syed,
ReplyDeleteI was referring this blog to set sort options. I am getting error saying unable to
atg.nucleus.ConfigurationException: Unable to resolve component /com/endeca/infront/cartridge/model/sort/sku.listPrice
(I am performing a sort for sku.listPrice prperty.)
Do we need to pass prperty name in the path or below is fine,
/com/endeca/infront/cartridge/model/sort
Thanks,
Vishal
I Vishal,
ReplyDeleteIt is enough you define this sortComponent path in the ResultsList Component . For this sort component , you should mention two values Label and value from the compoennt file . label should be name to display and value should be like the this property|1 . once you define then it will automatically consider in results .
Thanks and regards,
Syed Ghouse Habib
Thanks for the reply Syed. I have a one more question, what if I want to use more than one sort options. Above example explains a single sort option.
ReplyDeletehi vishal,
ReplyDeletesorters property in resultslist is a list , you can configure the multiple sortoption to it .
Hi Syed,
ReplyDeleteWe have a list of stockStatuses defined and indexed, we want to implement sort on this stockStatuses field. The issue we are having is as follows
1. stockStatuses values list of storeId:stockStatus Eg(1000:InStock, 2000:OutofStock, etc)
2. So now if we are in storeId = 1000, we need t sort items only on the 1000:<> values and not other values in the list as mentioned in Point 1
Kindly suggest.
Thanks & Regards,
Kunal
Hi Kunal,
DeleteWe also had the Same Requirement , We Achieved by doing the Below.
While Indexing itself make Sure you are Indexing as below
eg
Inventory@1000 : 1
Inventory@2000 : 0
In the Sorter Component , Get the Current StoreId from the Profile and Set the return Dynamically as Below
Ns=Inventory@|1 and tats all
When the Sorters Load then you will gets the Records Sorted in this Order.
Or Else if you want During the Intial Records Load , Set the Same in the CartrideCofig you will be able to get the Results Based on Your Requirement .
Hope this Helps.
Regards,
Syed Ghouse Habib