Posts

Showing posts with the label SAP hybris developer

How to add custom Sort logic for Sort By in Hybris?

Sometimes you may be required to have custom sorting logic for Sort By options in your category or products listing page. In this post, I will explain to you all the required steps. All you need is to define custom SortProvider. I'm taking the example of sort by size. Note:  This post is based on Hybris version  V6.0 ,  facetSort(code)  is deprecated in  SolrIndexedProperty  type so it might be removed from the latest release. Define your SortProvider( sizeAttributeSortProvider ) bean First, you need to define comparator class ( SizeAttributeComparator ) and bean definition for the same. Now declare sortProvider( sizeAttributeSortProvider ) bean as below which point to OOTB class ( DefaultFacetSortProvider ). <bean id="sizeAttributeSortProvider" class="de.hybris.platform.solrfacetsearch.config.impl.DefaultFacetSortProvider"> <property name="comparator" ref="sizeFacetAttributeComparator"/> </bean> <b

How to setup user account on linux systems for Hybris?

Why you should avoid running applications as root I've often come across posts on forums or other websites where you see people joking in such a manner about running/logging in as root as if it's something awful and everyone ought to know about it. However, there isn't much that a search reveals on the matter. It may be widely known to Linux experts, but I really don't know why. I remember always running as root when I first tried Linux years ago (Redhat and Mandrake) and don't remember running into any problems because of that. There are actually some distros that have a bright red background with alert signs all over it as wallpaper for the root user (SuSe?). I still use the "Administrator" account for regular use on my Windows installation and haven't ever run into any problems there either.  [source] How to create a User Account on Linux systems for Hybris Setup? Open a shell prompt. If you are not logged in as root, type the command

How to add or update Sort by Options in the Hybris?

Case1: Update/remove existing Sort by option If you are looking for update/remove existing Sort by option then you can do it by simply through hmc/backoffice/impex. Go to back-office  SolrIndexedType  and open your Indexed type Go to Solr Sorts tab: Here you can see the list of Sort By option which you can update/delete Case2: Add a custom Sort by option without custom sort logic In case if you want to add new custom Sort by option without any custom sorting logic then you can do it without changing any code. Let's assume I want a new sort by option based on  isPromotedProduct  (boolean) of the Product type. Just  follow the below steps... 1) Define SolrIndexedProperty You need to have SolrIndexedProperty for your attribute and you need to do Solr indexing to reflect its value in the Solr server. Here, I am assuming you know this part very well or you may already have SolrIndexedProperty defined. INSERT_UPDATE SolrIndexedProperty ; solrIndexedType(identifier)[un

[yjavac] 1. ERROR cannot be resolved to a type in Hybris?

Extensions can have dependencies on one another. While working with Hybris you come across a scenario, where you want to import a class from the different extension. The build only works if the required extension is available. Ensure the below steps to works it smoothly. Dependencies to Non-Platform(not located in  /platform/ext ) Extension The required extension should be there in  localextensions.xml Add the required extension in  extensioninfo.xml  (e.g  <requires-extension name="hmc"/> ) of the dependent extension In your eclipse(IDE), add required extension in  build path  of the dependent extension to resolve IDE dependecy. Note:  Adding required extension in IDE build path won't resolve extension dependency of your platform. It only resolved by  extensioninfo.xml Rebuild the system ( ant clean all ) Dependencies to Platform Extension By default, all extensions have the dependency on Platform extension(located at  /platform/ext ). There

How to change fromEmail Address of an email in Hybris?

If you want to reset or change  from emailAddress  for Hybris email, you can do that using Impex. You need to find emailPage for your email. then you can set or change  fromEmail  and  fromName  like below. # Email Pages UPDATE EmailPage ; $contentCV[unique=true] ; uid[unique=true] ; fromEmail[lang=$lang] ; fromName[lang=$lang] ; ; CustomerRegistrationEmail ; "helpdesk@gmail.com" ; "Customer Services Team" ; ; DeliverySentEmail ; "contact@gmail.com" ; "Customer Support Team" ; ; ForgottenPasswordEmail ; "test@gmail.com" ; "Customer Services Team"

Delete Hybris Products having duplicate name from HAC

How to delete duplicate product using the flexible search in Hybris? Open  HAC > console > scripting languages Now you can run the below  groovy script 1. Groovy script to get the list of pks to be removed import de.hybris.platform.servicelayer.search.FlexibleSearchQuery; flexibleSearchService = spring.getBean("flexibleSearchService") modelService = spring.getBean("modelService") def findProductWithSameName() { query = """ select MIN({p.pk}) as pks from {Product! as p JOIN CatalogVersion as CV on {p.catalogversion}={CV:PK} and {CV:version} = 'Online' JOIN Catalog as C on {CV:catalog}={C:PK} and {C:id}='myProductCatalog' } group by {p:name} having count(*) > 1"""; flexibleSearchService.search(query).result; } findProductWithSameName().each { println it.code; //modelService.remove(it); } 2. Test Remove script import de.hybris.platform.servicelayer.search.FlexibleS