How to write a Abortable Cron Job in Hybris | explain how to make Abortable Cron Job

In my latest Hybris Interview, I got question related Abortable Cron Job means How to Abort a Cron Job?
Let’s first understand it, first assume that from last few hours your Cron Job is running and now i want to Abort this Cron Job then how can i do it.
Concept: You can only abort those Cron Job which satisfies below two conditions 
A. During creation of your cron job override method isAbortable() and make return      it TRUE means now you can Abort this Cron job.
B. Second through Configurable in your Spring.xml file as below
   <property name="abortable" value="true"/>
After above those you can abort your cron job means your Cron Job is Abortable 
Also you can abort by below code
cronJobService.requestAbortCronJob(running_cronjob_code);

A abortable cron job's result as ERROR and status as ABORTED

Explain Solr boost in Hybris | How can add more index property in free text search in Hybris ?

Sometime in Hybris interview we get question which I heard first time so obviously unable to give answer of that question

Yesterday i got question about solr boost So first we need understand what is Solr boost
> Suppose you using
 free text search on storefront in hybris means doing search something text like "123" then at hybris side solr query fire on solr server and display result on screen what he found in result so result will definitely happen on some index property of your Solr item type's index property like ean,code,name etc
Let's suppose of text "123" match in all these 3 index property (ean,code,name) and you want display product (Ean match first) top on result so these type of result we can achieve through solr boost where we boost the search result by providing high score (boost) to index property.

Before going to
 solr boost first another question is How can we add more index property in free text search in hybris

Technical

in
 hybris there one file name commerceservices-spring-solrfacetsearch.xml(hybris 5.5) where you can found defaultCommerceSearchTextPopulator where we need to add your index property to apply free text search
suppose there is index property (description) on which you want to apply free text search then you need to add this property as below

<alias name="defaultCommerceSearchTextPopulator" alias="commerceSearchTextPopulator"/>
<bean id="defaultCommerceSearchTextPopulator" class="de.hybris.platform.commerceservices.search.solrfacetsearch.populators.SearchTextPopulator">
        <property name="freeTextQueryBuilders">
            <list>
 <bean class="de.hybris.platform.commerceservices.search.solrfacetsearch.querybuilder.impl.DefaultFreeTextQueryBuilder">
                    <property name="propertyName" value="ean"/>
                    <property name="boost" value="100"/>
                </bean>
<bean class="de.hybris.platform.commerceservices.search.solrfacetsearch.querybuilder.impl.DefaultFreeTextQueryBuilder">
                    <property name="propertyName" value="code"/>
                    <property name="boost" value="90"/>
                </bean>
 <bean class="de.hybris.platform.commerceservices.search.solrfacetsearch.querybuilder.impl.DefaultFreeTextQueryBuilder">
                    <property name="propertyName" value="name"/>
                    <property name="boost" value="50"/>
                </bean>
                <bean class="de.hybris.platform.commerceservices.search.solrfacetsearch.querybuilder.impl.DefaultFreeTextQueryBuilder">
                    <property name="propertyName" value="manufacturerName"/>
                    <property name="boost" value="40"/>
                </bean>
<bean class="de.hybris.platform.commerceservices.search.solrfacetsearch.querybuilder.impl.ClassificationFreeTextQueryBuilder">
                    <property name="boost" value="30"/>
                </bean>
                <bean class="de.hybris.platform.commerceservices.search.solrfacetsearch.querybuilder.impl.DefaultFreeTextQueryBuilder">
                    <property name="propertyName" value="keywords"/>
                    <property name="boost" value="20"/>
                </bean>
<bean class="de.hybris.platform.commerceservices.search.solrfacetsearch.querybuilder.impl.DefaultFreeTextQueryBuilder">
                    <property name="propertyName" value="categoryName"/>
                    <property name="boost" value="10"/>
                </bean>
<bean class="de.hybris.platform.commerceservices.search.solrfacetsearch.querybuilder.impl.DefaultFreeTextQueryBuilder">
                    <property name="propertyName" value="description"/>
                    <property name="boost" value="10"/>
                </bean>
               
            </list>
        </property>
    </bean>
In above for every indexproperty there is given boost value
So in above boost value score the search result means suppose you want to search text "demo" and result is match in ean, name, description and i want to see description result first then i will give higher boost value for description like below
<bean class="de.hybris.platform.commerceservices.search.solrfacetsearch.querybuilder.impl.DefaultFreeTextQueryBuilder">
                    <property name="propertyName" value="description"/>
                    <property name="boost" value="110"/>
</bean>
So Finally, In interview if you get question like suppose search text is match in more than one index property but i want to see any specific property result first then you can give answer of Solr boost

Solr boost can achieve
1. index-time boosts
2. Field Based Boosting
In hybris used Field Based Boosting - adding an optional query clause that "boosts" documents for matching an "important: true" query,


Final Conclusion about Solr Boost : If we want to improve the sale of the product we can boosting the product by some score. Based on the score the product will be displayed on search. This is called solr boost. We can do this by HMC or Back Office.

Explain core concept and working of Calculate() and recalculate() methods of calculationService in Hybris ?

During customizing order and cart there is used calculation service which is very important for customizing as well as in interview. SO today I decided to write my outcomes related to calculate() and recalculate() methods of calculation service.
As you know both Cart and Order is subtype of AbstractOrder so more or less every attributed is same for both item
FYI – During checkout finally Cart is into converted to Order means Copy all data from Cart to Order and cart number converted to order number.
Both Carts and Orders have an attribute called calculated of type Boolean that states whether they are calculated, or not. Now next what will calculate?
Boolean calculated;
In every cart or an order have price, tax, discount etc so this need to be calculate.
So on basis of Boolean attribute calculated there is call of CalulationService's method calculate() and recalculate() methods.
So whenever below action is performed on a Cart or an Order, the Cart or Order’s Boolean property (calculated) which is set to be FALSE
1. Product is be added to the cart
2. Product is be removed from the cart
3. User is changed
4. Currency is changed

So two important method call on basis of calculated=FALSE which is CalculationService.calculate() or CalculationService.recalculate() method
Before going in deep let’s see below
CART
<itemtype code="Cart" extends="AbstractOrder" jaloclass="de.hybris.platform.jalo.order.Cart" autocreate="true" generate="true">
<deployment table="Carts" typecode="43"/>
<attributes>
<attribute autocreate="true" redeclare="true" qualifier="entries" type="CartEntryCollection"/>
<attribute type="java.lang.String" qualifier="sessionId">
 <persistence type="property"/>
 <modifiers read="true" write="true"/>
 </attribute>
 </attributes>
</itemtype>

ORDER

<itemtype code="Order" extends="AbstractOrder" jaloclass="de.hybris.platform.jalo.order.Order" autocreate="true" generate="true">
<deployment table="Orders" typecode="45" propertytable="OrderProps"/>
<attributes>
<attribute autocreate="true" redeclare="true" qualifier="entries" type="OrderEntryCollection"/>
</attributes>
 </itemtype>
                               
Form above item definition every cart has cartEntry and every order has OrderEntry 
FYI- Every cartEntry and orderEntry their is also has Boolean attribute calculated
So depending on  every cartEntry's Boolean attribute value it call CalculationService.calculate() method to calculate their price, tax, discount etc of that cartEntry.
Concept: If there is something change in cartEntry then after also Cart’s calculated Boolean attribute become FALSE 
 Final Conclusion
1. If you adding any product into cart then
 CartEntry's calculated attribute = FALSE
Cart's calculated attribute = FALSE
So first there will call CalculationService.calculate to calculate cartEntry total after finish this call CartEntry's calculated attribute will set to TRUE then after will call CalculationService.recalculate()  to calculate cart TOTAL and after finish this call cart' calculated attribute will set to TRUE
   
2. If again any product is add to same cart then
 CartEntry's calculated attribute = FALSE. If it is FALSE then again Cart's calculated attribute = FALSE So there will again call CalculationService.calculate() method to calculate for these cartEntry and finally again it set to= TRUE after calculate for these newly entered cartEntry and after again call CalculationService.recalculate() to calculate Cart Total.


Core difference between platformwebservice and Ycommercewebservice in hybris? hybris interview question collection

Before release of Hybris 4.6 there was only platformwebservice and after release with hybris 4.6 introduce Ycommercewebservice extension

So here to understand the core difference between these two extension just need to get answer why Ycommercewebservice is require if there is already platformwebservice

And reason is that platformwebservice is only use of CRUD operation on data model and nothing else but Ycommercewebservice provide web service nature to provide eCommerce features like  registration, cart handling, checkout, orders etc

So you can better understanding with below

 

platformwebservice
Ycommercewebservice
Only use for CRUD operation on data model
Provide ecommerce features like card handling , checkout, orders
There is skip of business logic
Use business logic

Introduce in relases of Hybris 4.6

Core concept of running Cron Job in Clustering environment in Hybris | Cron job tutorial

Hello Guys,
Have you ever think that How Cron Job is run in cluster environment. is it run on every nodes or only in a single node ?. SO lets discuss it.
Core Concept : Cron job Always run in Single Node only 
During to creation of Cron Job you can define on which node it can execute mean you can set Node on which it always execute
everyReplyCronJob.setNodeID(1);
modelService.save(everyReplyCronJob);
After above code everyReplyCronJob will always run on node 1 in that cluster environment and if you not set node then it can be run any one of node in that cluster environment but only one node for that time

Now  After  release of Hybris 5.5.1 and later version , you can assign your cron job to group of nodes means if there is no available a node then it will execute on any other node of that groups
For that you need to do below
You need to define group of node in Local.properties file as below
cluster.node.groups= group name, another group name
After that you need to do code as below


 everyReplyCronJob.setNodeGroup(“your node group”);