Tweaking Solr Attributes and Facets


This trail will explain how to add our own index property to the existing solr index.
It explains the customer to refine search results based on the average of the ratings given products by other customersdgd

Create ranges for your New Ranged Index Property:

1. First we need to add the solr value ranges of reviews from 1 to 5 and we also need to add the solr value range prices of all the types of currencies. we only display the folating point number i.e, nearest integer value.

It explains customer to refine search results based on the average of the ratings given products by other customers
Ex: 0.5 to 1.49 , 1.5 to 2.49....

a) Adding slor range value to the solr.impex file:
For Prices:
We need to add the range reference of prices and Range value of prices of all types of currencies in the impex.


In HMC:





For Rating:


We need to add the average rating reference and Range value of rating.



 In HMC:


b) Defining Price and Rating range set:

Create a value range set to collect our range values of prices and average rating of type double and give it a name to be referenced by our indexed property:

Create our Index Property:
2. Create a new indexed property (reviewAvgRatingRange) for the

product type (hybrisProductType).It includes all the product related details and their types.



In HMC:

Change the Update Query:


3. An update query fetches the products that need to be updated in the solr index.As the solr index  contains information about customer reviews for a seperate item along with the updated reviews given by the customer.


In HMC:

Localize Facet Display Names for the new Indexed Property:

4. It mentions the types that product has and also define the available sorts with type of sort mentioned in impex.



In HMC:


Implement Value Provider for the new Index Property:


This value provider "ProductReviewAverageRatingValueProvider"will provide the product average review rating.It also create,add the collection of field values and their names.It is a standard class which hybris commerce will provide.



It also calculates the product rating. We give the rating and check the status whether it is approved or not.

 This is a standard class given by hybris suite where these functions get performed.

Create the new extension:
Create the new extension named "karmab2ccommerceservices" by following the below steps:
1. Call the ant extgen for creating new extension named "karmab2ccommerceservices".
2. After ant extgen it will ask to choose the default template.Select the default template as "yempty" and click enter.
3. Later on it will ask for the extension name so that enter the "karmab2ccommerceservices" as the extension name.
4. It will ask for the default package, give the package name as "de.hybris.karmab2c" and click enter.
5.Change the extensioninfo.xml file of the new extension to require the commerceservices extension





6. Add the new extension to localextensions.xml and build the system.

Value Provider Implementation:
a. Create the class "MerchandiseProductReviewAverageRatingValueProvider" which extends the standard class "ProductReviewAverageRatingValueProvider " which has fieldValues with the range name list.

b. Mention in "karmab2ccommerceservices-spring.xml".

Rebuild and Test:
1. Rebuild the system with "ant all".
2. Update the system with "karmab2cinitialdata" and  Select Yes for 'Import Core Data' and 'Activate Solr Cron Jobs'.
3. check these changes in hmc.
4. Add customer reviews to products. Select a product and click on 'Write a review' to add product reviews.


5. In hmc - Marketing - Product Reviews, Search the latest product reviews will get the product with approval Status 'Pending' which will display the reviews just added.



Create the review and change the pending to approved.


6. Change the approval status to "Approved". Save the status to approved.


7. If the reviews of products are not visible for we can trigger a solr index update in the HMC: System Facet search Indexer operation wizard.


Check the site and review the products with the specified rating after doing Indexer operation wizard the product must be visible.








Comments

Popular posts from this blog