documentgh
Post on 24-Dec-2015
54 Views
Preview:
DESCRIPTION
TRANSCRIPT
Q.1. Explain model architecture & model methods?
Ans: A Model represents a state in the database. The representation is not live, that means that modified Model values are not written to the database automatically. Instead, when you modify a Model, you must explicitly save it to the database to have its state reflected there.
The corresponding phases in a Model's life cycle include:
Instantiating the Model
This can be done by either creating a new Model instance or by loading a Model from the database.
Creating a Model instance
This can be done by either of these ways.
Through its constructor.
Through the factory method in the ModelService.
Loading an existing Model from the database is possible either by using the pk or by using a query expression.
Modifying Model Values if desired: Set the properties of a Model.
Saving Model Values if created or modified: You save back the Model to update the database. If you have used a new Model, a new record is created in the database; otherwise the existing record is updated.
Removing the model: If the Model is no longer needed, the database record is deleted.
You can use Interceptors to hook into the Model's life cycle.
ModelService
The ModelService is a service that deals with all aspects of a Model's life-cycle. It is available in Spring under the ID modelService and implements the de.hybris.platform.servicelayer.model.ModelService interface. Its main tasks include the following:
Loading Models by pk
Loading Models from items
Creating Models
Updating Models
Deleting Models
Creating a Model Instance
There are two ways to create a new Model instance:
Using a constructor
Using a factory method
Using a Constructor
You do not need a special create method or other kind of factory. You simply create the new instance using new, such as:
ProductModel product = new ProductModel();
Values of Models are not written to the database directly but only on explicit save. Due to this, you do not have to specify values for mandatory attributes when instantiating the Model. However, by the time you try to save the Model, the values for mandatory attributes must be set, except for the default values.
Model Constructor Methods From 4.1.1
Starting with hybris Platform 4.1.1, constructor methods for mandatory attributes are deprecated. To instantiate Models, use only the non-argument constructor method, and set the values afterwards, such as:
ProductModel product = new ProductModel();
product.setCatalogVersion(catalogVersion);
product.setCode(code);
Furthermore you can use constructor defined at items.xml as explained in Modifying the Model Generation
When you create a Model like this.There are two ways to do it:
Using the ModelService 's save(Object) method: The Model is saved to the database and automatically attached.
modelService.save(Object)
Using the ModelService 's attach(Object) method: The Model is attached but not saved. Consequently, you either have to manually save it later or do a bulk save.
modelService.attach(Object)
In addition, a Model created that way is not filled with default values as defined in the items.xml file. You can fill it as follows:
modelService.initDefaults(model);
If you do not explicitly call it, the default values are automatically applied during the save process.
Using a Factory Method
You also can use the ModelService to create a Model instance, for example by specifying the Model class:
ProductModel product = modelService.create(ProductModel.class)
Alternatively, you can specify the type's identifier (code):
ProductModel product = modelService.create("Product")
This is very useful at runtime if you dynamically wish to determine the type of a Model to create. Also, this method immediately puts the Model in the Model context. Consequently, you do not have to manually add the Model to the Model context, and the default values are assigned automatically.
Loading an Existing Model
To load an existing Model, you can look up by one of the following:
Using the Model pk
Using a FlexibleSearch query
Loading by Primary Key
The simplest case to load a Model is based on its primary key (pk). You call the get method from ModelService:
ProductModel product = modelService.get(pk)
Loading by Query Expression
Commonly, you wish to look up Models based on a FlexibleSearch query. To do this use the flexibleSearchService. It implements the de.hybris.platform.servicelayer.search.FlexibleSearchService interface. It is available as a Spring bean with the ID flexibleSearchService:
FlexibleSearchQuery query = new FlexibleSearchQuery("SELECT {pk} FROM {Product} WHERE {code}
=?" + Product.CODE);
query.addQueryParameter(Product.CODE, code);
SearchResult<ProductModel> result = flexibleSearchService.search(query);
List<ProductModel> = result.getResult();
If no Model is found, search() method may throw ModelNotFoundException.
Since version 4.2.2 you may use searchUnique() method from the FlexibleSearchService that is similar to search() method. The difference is that searchUnique() method returns exactly one model or throws one of two types of exceptions:
ModelNotFoundException: If no Model is found
AmbiguousIdentifierException: If more than one Model fulfilling search parameters is found, for example, if you search for Products without a WHERE clause
FlexibleSearchQuery query = new FlexibleSearchQuery("SELECT {pk} FROM {Product} WHERE {code}
=?code");
query.addQueryParameter("code", code);
ProductModel result = flexibleSearchService.searchUnique(query);
Saving a Model
There are two basic means of saving Models:
Saving an individual Model with referenced Models, under certain circumstances.
To save a Model, call the modelService 's save(...) method:
modelService.save(model);
If a Model holds a reference to another Model and is to be saved, the referenced Models are also saved if they have not been saved before. The referenced Models that have already been saved before are not saved. Other, non-referenced Models are not saved.
For example, if a catalog version holds a new, unsaved CategoryModel and the catalog version is saved, then the CategoryModel is also saved. This function relies on the Model context. See also section Model Context above.
Saving all Models at once:
modelService.saveAll();
This saves all modifications as registered with the Model context.
Removing a Model
To remove a Model just call the remove method of the modelService:
modelService.remove(product)
Refresh a Model
Refreshing retrieves the Model's values directly from the database, thus overriding the current values. Therefore unsaved changes are lost.
modelService.refresh(product)
Q.2. Explain interceptors and its uses in life cycle of a model?
Ans: To intercept the behavior of life cycles of Models, there are various types of interceptors. Each interceptor addresses a particular step of the life cycle. When the life cycle of a model reaches a certain step, a corresponding interceptor is activated. During the interception, it's possible to modify the model or raise an exception to interrupt the step. For example, you can check that certain values are set for a model before the model is saved.
To intercept the behavior of life cycles of Models, there are various types of interceptors. Each interceptor addresses a particular step of the life cycle. When the life cycle of a model reaches a certain step, a corresponding interceptor is activated. During the interception, it's possible to modify the model or raise an exception to interrupt the step. For example, you can check that certain values are set for a model before the model is saved.
After implementing an interceptor, you need to register it as a Spring bean.
Register an Interceptor
After implementing an interceptor you register it as a Spring bean.
To register an interceptor, add it to the Spring application context XML:
myextension-spring.xml
<bean id="myValidateInterceptor" class="mypackage.MyValidateInterceptor"
autowire="byName"/>
The id is used in the following bean.
Add a de.hybris.platform.servicelayer.interceptor.impl.InterceptorMapping to the XML file:
myextension-spring.xml
<bean id="MyValidateInterceptorMapping"
class="de.hybris.platform.servicelayer.interceptor.impl.InterceptorMapping">
<property name="interceptor" ref="myValidatInterceptor"/>
<property name="typeCode" value="MyType"/>
<property name="replacedInterceptors" ref="uniqueCatalogItemValidator"/>
<property name="order" value="5000"/>
</bean>
Type of
Intercept
or
Description Interface to be Implemented
Load
Interceptor
The Load Interceptor is called
whenever a model is loaded from
the database. You may want to use
this interceptor if you want to
change values of the model after
load. An exception raised during
execution prevents the model from
being loaded.
LoadInterceptor interface
(
de.hybris.platform.servicelayer.interceptorpack
age):
public interface LoadInterceptor extends Interceptor{ void onLoad(Object model, InterceptorContext ctx) throws InterceptorException;}
Init
Defaults
Interceptor
The Init Defaults Interceptor is
called when a model is filled with its
default values. This happens either
when it is created via
the modelService.create method
or when
the modelService.initDefaults met
hod is called. You can use this
interceptor to fill the model with
additional default values, apart from
the values defined in the items.xml file;
seeitems.xml for details.
InitDefaultsInterceptor interface
(
de.hybris.platform.servicelayer.interceptorpack
age):
public interface InitDefaultsInterceptor
extends Interceptor{ void onInitDefaults(Object model, InterceptorContext ctx)
throws InterceptorException;}
Prepare
Interceptor
The Prepare Interceptor is called
before a model is saved to the
database before it is validated by
Validate interceptors, see below.
Use this to add values to the model
or modify existing ones before they
are saved. An exception raised
during execution prevents the
PrepareInterceptor interface
(
de.hybris.platform.servicelayer.interceptorpack
age):
public interface PrepareInterceptor extends Interceptor
Type of
Intercept
or
Description Interface to be Implemented
model from being saved.
Note
Icon
Prepare interceptor is called before
the impex translators.
{ void onPrepare(Object model, InterceptorContext ctx)
throws InterceptorException;}
Note
Icon
Do not use this interceptor to perform validation.
Use the Validate Interceptor instead.
Validate
Interceptor
The Validate Interceptor is called
before a model is saved to the
database after is been prepared by
the Prepare interceptors, above.
You can use Validate Interceptors
to validate values of the model and
raise anInterceptorException if
any values are not valid.
ValidateInterceptor interface
(
de.hybris.platform.servicelayer.interceptorpack
age):
public interface ValidateInterceptor extends Interceptor{ void onValidate(Object model, InterceptorContext ctx)
throws InterceptorException;}
Note
Icon
Do not use this interceptor to fill the model with
values or otherwise prepare it for saving. Use
the Prepare Interceptor instead.
Remove
Interceptor
The Remove Interceptor is called
before a model is removed from the
database. You can use this
interceptor, for example:
To remove models that are related
to the model but are not in the
model context.
To prevent the removal of the model
by raising
an InterceptorException.
RemoveInterceptor interface
(
de.hybris.platform.servicelayer.interceptorpack
age):
public interface RemoveInterceptor extends Interceptor{ void onRemove(Object model, InterceptorContext ctx) throws InterceptorException;}
Q.3. How to implement Populators and Converters ?
Ans:
OMS has been made more extensible by enhancing the converters and populators. It is now possible to support multiple populators for each converter. The populators are also easily interchangeable.
Conversion API
The com.hybris.commons.conversion.Converter is an interface for creating a target object based on a source object:
Converter.java
public interface Converter<S, T>
{
T convert(S source) throws ConversionException;
}
The com.hybris.commons.conversion.Populator is an interface for updating an existing target object based on a given source object:
Populator.java
public interface Populator<S, T>
{
void populate(S source, T target) throws ConversionException, IllegalArgumentException;
void populateFinals(S source, T target) throws ConversionException, IllegalArgumentException;
}
The com.hybris.commons.conversion.ConversionException is used to signal problems with data conversion. This exception may be thrown when calling populateFinals if a final field is being updated more than once.
Additionally there is a utility class, com.hybris.oms.facade.conversion.util.Converters, that provides a method for converting a list of source objects into a list of target objects:
Converters.java
<S, T> List<T> convertAll(final Collection<? extends S> sourceList, final Converter<S, T> converter)
This method converts every element from the source list using a given converter. It also takes care of null checks.
This class is defined as a Spring bean with the converters ID, which is located in the commons-conversion-spring.xml file.
<bean id="converters" class="com.hybris.commons.conversion.util.Converters" />
Implementing Converters and Populators
The following sections provide details if you need to implement a new converter and populator for a new type.
Creating the Converter Directly
You may choose to write a converter directly; this means that you will write the conversion logic directly in the converter and that you may not make use of populators or the extensibility provided by the AbstractPopulatingConverter.
This approach has only been used for reverse converters for Value Types since these are immutable and their attributes must be set in the constructor.
Here is an example of using a direct converter for converting an address value type:
/**
* Converts {@link Address} DTO into {@link AddressVT} value type instance.
*/
public class AddressReverseConverter implements Converter<Address, AddressVT>
{
@Override
public AddressVT convert(final Address source) throws ConversionException
{
if (source == null)
{
return null;
}
else
{
return new AddressVT(source.getAddressLine1(), source.getAddressLine2(), source.getCityName(),
source.getCountrySubentity(), source.getPostalZone(), source.getLatitudeValue(), source.getLongitudeValue(),
source.getCountryIso3166Alpha2Code(), source.getCountryName(), source.getName(), source.getPhoneNumber());
}
}
}
Creating the Converter by Extending the AbstractPopulatingConverter
The AbstractPopulatingConverter
The abstract populating converter implements both the Converter and the Populator interface and acts as a converter which will also perform the population. It contains a single populator and demands that all child implementations implement a createTarget method to create an actual instance of the target.
public abstract class AbstractPopulatingConverter<S, T> implements Converter<S, T>, Populator<S, T>
{
private Populator<S, T> populator;
/**
* Override this method to create the instance of target type.
*
* @return the new target instance
*/
protected abstract T createTarget();
...
}
The convert method of this class will perform the following tasks:
Create a new instance of the target class.
Populate all final fields.
Populate all remaining fields.
Return the new converted and populated instance of the target class.
@Override
public T convert(final S source) throws ConversionException
{
if (source == null)
{
return null;
}
final T target = this.createTarget();
// Populate final fields explicitly during create.
this.populateFinals(source, target);
// Populate all remaining fields
this.populate(source, target);
return target;
}
This class is defined as a Spring bean with the abstractPopulatingConverter ID which is located in the commons-conversion-spring.xml file.
<bean id="abstractPopulatingConverter" class="com.hybris.oms.facade.conversion.impl.AbstractPopulatingConverter" abstract="true">
<property name="persistenceManager" ref="persistenceManager" />
</bean>
Creating the Populator
The first thing you need is a populator (or reverse populator) that implements the Populator interface above. You can choose to either extend the existing AbstractPopulator or simply implement the Populator interface.
If the target in your conversion does not have any final fields to populate, then it is suggested to extend the AbstractPopulator.
Implementing the Populator Interface
Here is an example of a class that implements the Populator interface directly. Note that the populateFinals method has been overridden to set just the final field for this type.
BinReversePopulator.java
public class BinReversePopulator implements Populator<Bin, BinData>
{
private PersistenceManager persistenceManager;
@Override
public void populateFinals(final Bin source, final BinData target) throws ConversionException
{
target.setBinCode(source.getBinCode().toLowerCase());
}
@Override
public void populate(final Bin source, final BinData target) throws ConversionException
{
target.setStockroomLocation(this.persistenceManager.getByIndex(StockroomLocationData.UX_STOCKROOMLOCATIONS_LOCATIONID,
source.getLocationId()));
target.setDescription(source.getDescription());
target.setPriority(source.getPriority());
}
@Required
public void setPersistenceManager(final PersistenceManager persistenceManager)
{
this.persistenceManager = persistenceManager;
}
}
All reverse populators (DTO to ManagedObject) where the ManagedObject has final fields that should implement this interface directly.
Extending the Abstract Populator
If your target type does not require the conversion of final fields, then simply override the following AbstractPopulator to avoid having to redundantly override the populateFinals method.
AbstractPopulator.java
/**
* Basic {@link Populator} implementation that assumes that there are no final fields to populate.
*/
public abstract class AbstractPopulator<S, T> implements Populator<S, T>
{
@Override
public void populateFinals(final S source, final T target) throws ConversionException, IllegalArgumentException
{
// By default, do nothing
}
}
All forward populators (ManagedObject to DTO) should extend this abstract class.
The CompositePopulator
If you require more than one populator to perform your population for a given type, then you should use the CompositePopulator bean to group your populator beans.
The populateFinals method will iterate over all populators and call their populateFinals method.
@Override
public void populateFinals(final S source, final T target)
{
for (final Populator<S, T> populator : getPopulators())
{
populator.populateFinals(source, target);
}
}
The populate method will iterate over all populators and call their populate method.
@Override
public void populate(final S source, final T target)
{
for (final Populator<S, T> populator : getPopulators())
{
populator.populate(source, target);
}
}
Define All XML Beans
All of the magic behind the converters lies in the oms-facade-conversion-spring.xml Spring XML file.
Define the Populator
For a Regular Populator
<bean id="binPopulator" class="com.hybris.oms.facade.conversion.impl.inventory.BinPopulator" />
For a Reverse Populator
<bean id="binReversePopulator" class="com.hybris.oms.facade.conversion.impl.inventory.BinReversePopulator">
<property name="persistenceManager" ref="persistenceManager" />
</bean>
If your reverse populator requires a search to retrieve another ManagedObject by its unique index, then you must remember to inject the PersistenceManager dependency. You may also need to inject a service to properly populate your ManagedObject.
For a Composite Populator
Most types to be converted are entities that may contain schemaless attributes and this requires the PropertyAwarePopulator. To combine these populators, define your final populator as follows:
<alias name="propertyAwareBinPopulator" alias="binPopulator" />
<bean id="propertyAwareBinPopulator" parent="compositePopulator">
<property name="populators">
<list>
<ref bean="defaultBinPopulator" />
<ref bean="propertyAwarePopulator" />
</list>
</property>
</bean>
Define a Prototype Bean
For a Regular Converter
You will have to define a prototype scoped bean representing an instance of your DTO.
<bean id="binDTO" class="com.hybris.oms.domain.inventory.Bin" scope="prototype" />
For a Reverse Converter
You will have to define a prototype scoped bean representing an instance of your ManagedObject.
<bean id="binMO" parent="abstractMO">
<property name="arguments">
<list>
<value type="java.lang.Class">com.hybris.oms.service.managedobjects.inventory.BinData</value>
</list>
</property>
</bean>
The following abstractMO abstract bean is provided simply as a means to avoid XML duplication.
<bean id="abstractMO" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" abstract="true">
<property name="singleton" value="false" />
<property name="targetObject" ref="persistenceManager"/>
<property name="targetMethod" value="create"/>
</bean>
Define the Converter
When you define your converter via this method, you will not actually create a concrete Converter class, instead you will opt for extending the abstractPopulatingConverter bean and override the createTarget method as well as the list of populators.
For a Regular Converter
<bean id="defaultBinConverter" parent="abstractPopulatingConverter">
<lookup-method name="createTarget" bean="binDTO" />
<property name="populator" ref="binPopulator" />
</bean>
For a Reverse Converter
<bean id="defaultBinReverseConverter" parent="abstractPopulatingConverter">
<lookup-method name="createTarget" bean="binMO" />
<property name="populator" ref="binReversePopulator" />
</bean>
Q.4. when we have to use collection and when we have to use relation?
Ans: Collection Type
A CollectionType contains a typed number of instances of types - a dozen Strings, for example. A CollectionType has a unique identifier (referred to as code) and a definition of the type of elements it contains (elementtype). This type definition may include any type of item within the hybris Commerce Suite - even other CollectionTypes.
Relation Type
To model dependencies between various numbers of items on both dependency sides, RelationTypes are the way to go. They represent n:m relations in the hybris Commerce Suite. RelationTypes allow you to reflect scenarios like various products belonging into several categories and vice versa.
Q.5. Explain checkout and its processes in Hybris
Ans: The Checkout allows the customer to complete their purchase of the items in their cart. Due to the sensitive nature of the data provided by the customer to the storefront, the checkout section of the storefront should be accessed via a secure protocol (HTTPS).
Unauthenticated users are taken to the Proceed To Checkout Page.
Authenticated users are taken straight to the Checkout Summary Page.
Steps to checkout:
a) The Proceed To Checkout page:
It is generally considered to be the first page in the checkout flow. Unauthenticated customers are required to login to their account using the Returning Customer form. Customers who do not yet have an account are also able to register using the New Customer form.
b) Checkout summary page:
The default checkout in the hybris Multichannel Accelerator is implemented as a single page, with the use of lightboxes to enter the details for placing the order.
Existing customers who choose not to save their details, and new customers see the unpopulated view of the Checkout Summary Page, with no default details selected.
c) Delivery method rules:
Delivery methods are restricted in their use to specific territories.
When the delivery address of the order is updated, the delivery method currently selected should be re-evaluated.
If the delivery method currently applied to the order is no longer applicable for the selected delivery address, the delivery method should be removed, and a message should be shown to the user informing them of the change.
Selection of delivery methods should be restricted to those applicable to the currently selected delivery address.
If no delivery address is selected, the delivery methods applicable to the default territory of the storefront should be used.
Where a delivery method is not constrained to a zone, this delivery method is always displayed.
The customer is eligible for a promotional delivery method, this should be added to the list of available delivery methods.
d) The Order Confirmation Page:
It is the final page in the Checkout flow. It provides the customer with a summary of the order they have placed.
NOTE:
a) Multistep Checkout:
The Multistep Checkout allows customers to complete their purchase of the items in their cart. Due to the sensitive nature of the data provided by the customer to the storefront, the checkout section of the storefront should be accessed via a secure protocol (HTTPS). The Multistep Checkout is a procedure including few steps to follow. The customer is directed from one page to another to place an order.
b) B2B Checkout:
The B2B Checkout allows the customer to complete their purchase of the items in their cart. Due to the sensitive nature of the data provided by the customer to the storefront, the checkout section of the storefront should be accessed via a secure protocol (HTTPS).
The user arrives at the B2B Checkout page having either populated a cart and chosen Checkout, or having been directed to the checkout following an action such as re-ordering from order history. In order to continue the checkout, the user is required to be authenticated, to be a customer and have products in his cart. On successfully satisfying these criteria the user will reach the B2B Checkout Summary Page.
Manual checkout, as well as auto-replenishment set up during checkout, are available to registered customers. Payment onto account or by credit card is available to registered customers.
Manual Checkout Process
Existing customers are taken through a checkout process where the customers:
Have the choice of paying onto their account or by credit card.
Choose a delivery location from those associated with the account or chosen cost center.
Choose the delivery service required.
Enter a PO number.
Allow the customer to setup an auto-replenishment order.
Allow the customer to request a quote for the order
Automatic Replenishment Checkout
At the point of checkout an automatic replenishment order can be scheduled. This is an option on the B2B Checkout Summary Page. It can also be set up after at a later date in the Manage My Orders area. The can be scheduled to replenish, as follows:
After X number of days
Weekly
Monthly.
Q.6. What is persistence layer?
Ans: In Core there is a dedicated layer that is responsible for the data repository abstraction.This is called the persistence layer. This abstraction enables possibility to provide many data repository implementations (persistence engines) based on different databases and benefit from strengths offered by relational (SQL) and NoSQL databases simultaneously. Right now the following persistence engines are offered with Core+:
JDBC: Classic implementation for relational databases (Oracle, MySQL, MS SQL and HSQL are supported).
MongoDB: Document based database.
Q.7. What is Payment Gateway? Describe is hybris Payment Module?
Ans: Payment Gateway:
A payment gateway is an e-commerce application service provider service that authorizes credit card payments for e-businesses, online retailers, bricks and clicks, or traditional brick and mortar. It is the equivalent of a physical point of sale terminal located in most retail outlets.
Hybris Payment Module:
The hybris Payment Module answers the customer's expectations for the flexible and modular solution able to support complexity of the on-line payment processing. Its main purpose is to help the larger number of merchants integrating with Payment Service Providers (PSP) to map their commerce applications to the existing payment networks. This is necessary to reduce dependency on the financial institutions and eliminate the need to directly establish individual connections.
The hybris Payment Module is ready to coordinate the flow of transactions among a complex network of financial institutions and processors. The module supports integrating payment gateways into the hybris Commerce Suite by grouping the adapters supporting the cooperation with external payment service providers.
What is Payment Module
The hybris Payment Module enables you to use the services of the external payment service providers in order to handle the electronic payments. The module can support you by its flexible approach to the multi-channel on-line payment methods depending on the available payment service adapters.
Benefits of the Payment Module
The Payment Module can help you to connect to the payment service providers accessible through the PSP-specific payment adapter. Currently, the communication with the CyberSource is supported. However, the Payment Module can be easily enhanced with your customized adapters to support flexible and efficient cooperation with any other payment service providers. This approach to the efficient modularity gives you freedom of choice and flexibility with picking up those PSPs that suit you at best.
Use the hybris Payment Module to:
Increase revenue by providing customers with multiple payment options
Eliminate complexity and reduce cost by connecting to major PSP
Enable immediate authorization through automated payment validation
Centralize management of payment processing for one or more sales channels
Ensure a secure link between you, your customer, and your credit card processor
Payment Module Features
The features available for the Payment Module depend on the PSP adapters that were implemented and attached to the module. Currently the Payment Module comes with thecybersourceextension, that is an adapter supporting the payment process with the CyberSource company. The following features are thus available through the CyberSource oriented adapter. However, it is possible for the customers to create and implement their own PSP adapters that can extend this list by additional features.
Embedded Credit Card Payment Processing: The support for the credit cards. It depends on the chosen payment service provider. The validation of all details is performed by the payment service provider. Nevertheless, the hybris Platform provides facilities to store payment details that an e-commerce store is legally entitled to store.
Embedded Debit Card Payments Processing: Another form of payment involves using debit cards in the process. All functionality mentioned in previous credit card related section applies here, too. Debit card payment might not be available in all countries.
Payment Authorization: Payments always have to be authorized by the card issuer. The customers do not have to wait for the result while they are placing their order. However, in some cases it may not recommended, for example when selling digital goods. In such case this step is a synchronized order placing process. Both processes can exist in the same store, since one store might sell digital goods as well as physical goods.
Multiple Credit Card Payment: In some countries, for example United States, it is possible to pay for the products within one order using multiple credit cards. This ability may prove useful, for example in situations when the customers need to pay the amount that is higher than a daily limit on the single credit card. In such a case, they may provide the payment details with the credit card information for authorization and in the next step provide the payment information for another credit card. Both transactions will together realize the payment for the single order. The form of this service offered to the customer is technically realized by the particular sellers who offer this to their customers.
Voiding Transaction: To void a transaction means to cancel it. Voiding transaction cannot be undone. Once voided, the transaction cease to exist. Transaction can be voided only if payment provider has not already submitted the transaction capture to the payment processor. Payment providers, like CyberSource, often submit that type of information to your processor not instantaneously. So there is usually some time when voiding transaction is possible. Check details with your payment service provider. Once the capture is sent to the payment processor you are no longer able to void transaction.
Refund: Sometimes it is necessary to send the financial means back to the customer. This may be related to the order or previous transactions of the customer. However, it may also be the case that the money returning to the customer account is not associated with any previous transaction. The hybris Payment Module with support of thecybersourceextension supports both cases. This is a way of assuring that in any case the money refund is possible to the eligible consumers.
Customization Options
Currently, the hybris Payment Module comes with the hybriscybersourceextension responsible for the secure communication with the CyberSource, a company providing the payment services. However, the Payment Module may also be extended by other, customer designed extensions, that would support other payment service providers. As a result customers are not bound by one particular method but can use several methods available depending on their business context, geographical location, law regulation, technological environment, and other possible factors.
Q.8. Explain Type System in Hybris
Ans: A type is a template for objects. Types:
-Define product data that objects may carry and specify relations between objects.
-Make product data persistent by categorizing the data and relating it to database fields.
Every object stored in the platform is a type instance.
Main Functions of Type System
The hybris Commerce Suite uses a system of types to organize data, for example product information, customer data, addresses, or orders.
Types define persistent objects in several aspects:
attributes manage and store data for the object,
the deployment defines the database table the object is stored in the Java class of the object.
Type = type definition in items.xml + its Java implementation
An object instance of a type is called an item
Items and Types
There are two major kinds of types: System-related types and business-related types.
System-related types make up or extend the type system itself and deal with internal data management:
Infrastructure types: ComposedTypes (also referred to as ItemTypes) set up type definitions and may carry attributes to hold information. In the end, every persistent object in the hybris Commerce Suite is an instance of ComposedType or of one of its subtypes.
Data types: CollectionTypes, MapTypes, EnumerationTypes, and AtomicTypes - these are used to describe attributes: carrying attribute values or representations for these values or creating links between objects
Business-related types (like Order, Discount, Shoe) allow you to manage product and / or customer information so that you can run your business.
The following diagram gives you an overview on a part of the type hierarchy defined by an out-of-the-box hybris Commerce Suite.
Q.9. if we are creating an item, does the model get created or not? If yes what services are created in terms of architecture?
Ans: Models are generated to match the type system definitions in the items.xml files into the modelclasses inside bootstrap/gensrc folder of the platform once items are created in items.xml and ant all is performed.
During this the model services are created as per the model life cycle architechture
The ModelService is a service that deals with all aspects of a Model's life-cycle. It is available in Spring under the ID modelService and implements the de.hybris.platform.servicelayer.model.ModelService interface. Its main tasks include the following:
Loading Models by pk
Loading Models from items
Creating Models
Updating Models
Deleting Models
Q.10. Which controller class is responsible to your component in a jsp in Hybris?
Ans: AbstractCMSComponentController
Q.11. What are the ecommerce features provided by Hybris
Ans:
hybris Commerce Features – B2C
Standard eCommerce content pages with WCMS integration for desktop and mobile with device detection Full text search capability and integration with Apache Solr Product details with stock availability indicators Store locator with Google Maps integration Customer reviews and Social Network integration Persistent shopping cart with multiple checkout strategies Guest and Express Checkout Address Verification and Localized Addresses Standard fulfillment or Buy online pickup in store (BOPIS)
Customer account management and order history Integration with payment service providers with Hosted Order Page (HOP) or Silent Order Post (SOP) Integration with Customer Service and In Store channels Reporting and analytics integration Integration with hybris OMS and CIS
hybris Commerce Accelerator Features – B2B
B2B Organization Management
B2B Spend Control
B2B Self-Service Customer Account Management (Order history, Quotes, Replenishment orders)
B2B Quote Negotiation
B2B Special Pricing
B2B Order Replenishment
B2B Order Approval
B2B Checkout
B2B Order Management
Q.12. What is Cart functionality in Hybris?
Ans: The Cart section of the storefront allows the customer to manage the products and quantities in their cart before they check out.
Page Flow
There are two kind of cart page:
a) The Cart Page allows a customer to manage the contents of their shopping cart.
b) The Empty Cart page is displayed when the customer views the cart page with no products in their cart. This page provides a number of content slots, enabling the merchant to provide helpful tips on shopping on the website, and potentially merchandise the page with promotional content.
Q.13. if you want to display some content(component) in particular page how to do it using cms?
Ans:
Adding the YourComponent to respective content slots
a) In the hMC, expand the WCMS menu and click on Websites.b) Search for and select the your website.c) Edit the Required Page property by right-clicking in the fieldd) In the Content Page editor, edit the Page Template propertye) In the Page Template editor, right-click in the Respective content slot and select Edit in new
window or click on the blue box next to the fieldf) In the Valid Component Types table, right-click and select Add Component Typeg) Search for and select YourComponent.h) Click Save and Close in the top bar of the pop-out window.
Using the new component type in the particular page using CMS cockpit
a) Login to the cmscockpit.b) In the left navigation menu, select your Site and yourSite Content Catalog / Staged.c) In the browser area, double-click on required page to activate it.d) In the respective Slot for your page, click on Create an iteme) Select Your Component as the type and Create a new item.f) Enter a name for your new component and click on Done.g) Right-click on the yourSite Content Catalog / Staged option in the left navigation menu and click
on Synchronize content catalog.
Q.14. What is strict mode in impex?
Ans: Import Strict - Mode for import where all checks relevant for import are enabled. This is the preferred one for an import and is also the default one.
Check Description Thrown Exception Import
Sctrict
Clashing of columns
(columns referencing same
attribute descriptor)
Ambiguous columns columns-related code.
Column type within item
expression is jalo-only.
Attribute attribute-related code is jalo-only - cannot use to
resolve item reference.
Column within item
expression not searchable or
has no persistence
representation
Attribute attribute-related code is not searchable - cannot
use to resolve item reference via pattern.
Dumping is disabled and a
line has to be dumped
Line line-related code could not be imported completely
Empty column expression No attributes specified for header with type type-related
code.
Mandatory columns without
value (no default value, no
allowNull modifier)
Value is NULL for mandatory attribute attribute-related code.
Missing mandatory columns Type type-related code requires missing column(s) column-
related code.
Missing unique column Type type-related code has no unique columns.
Missing unique modifier Missing unique modifier inside header-related code - at
least one attribute has to be declared as unique
(attributename[internal:unique=true]).
No abstract type Type type-related code is abstract.
Q.15. What all kinds of relations that hybris support?
Ans: a) one-to-many b) many-to-many
Q.16. How do we add new attributes to product itemtype? Which way is the best?
OR
how to add attribues to product in pdp page?
Ans:
Adding Types And Attributes
There are two methods to add an attribute to existing types.
a) Creating a subtype and adding the attributes to the subtypeb) Adding the attribute to the type directly
Section below discusses these two methods and their consequences.
Creating a Subtype and Adding the Attributes to the Subtype
This is the method recommended by hybris as it keeps the hybris Commerce Suite's core types untouched. On the Jalo Layer, you also have an individual Java class available where you can implement your business logic.
You reference the type from which to extend, specify a name for the subtype, and add the attribute. For example, the following items.xml snippet creates a subtype MyProduct extending from Product and adds an attribute oldPrice of type java.lang.Double:
<itemtype code="MyProduct" autocreate="true" generate="true" extends="Product" jaloclass="org.training.jalo.MyProduct">
<attributes>
<attribute qualifier="oldPrice" type="java.lang.Double" generate="true">
<persistence type="property"/>
<modifiers read="true" write="true" optional="true"/>
</attribute>
</attributes>
</itemtype>
In this case, you need to set the value of the autocreate element to true, which lets the hybris Commerce Suite create a new database entry for this type at initialization/update process. Setting the autocreate modifier to false causes a build failure; the first definition of a type has to enable this flag.
Jalo Layer: Setting the generate modifier to true results in Java class files being generated for this type (additional details). Setting the generate modifier to false results in no Java class file being generated for this type. Having no Java class file available means that you are not able to implement a custom business logic (such as getter and / or setter methods) for the type. You have to make use of the supertype's business logic implementation.
Adding Attributes to a Type Directly
This method is generally discouraged by hybris unless you know the implications and side effects very well and you know that you have no alternative to taking this manner.
Where extending a type and using the subtype is complex or not feasible, it is possible to extend the hybris Commerce Suite type directly, such as Product or Customer:
<itemtype code="Product" autocreate="false" generate="false">
<attributes>
<attribute qualifier="oldPrice" type="java.lang.Double" generate="true">
<persistence type="property"/>
<modifiers read="true" write="true" optional="true"/>
</attribute>
</attributes>
</itemtype>
This manner is not recommended by hybris for these reasons:
You create a direct dependency to a hybris Commerce Suite type.
Jalo Layer: The generated methods for the attributes are written into your extension's manager, but not into the corresponding type class. In essence, this means that you have to address your extension's manager class to set values for these attributes.
As the type basically exists already, you need to set the autocreate modifier for the type definition to false:
<itemtype code="Product" autocreate="false" generate="true">
Setting the autocreate modifier to true results in a build failure.
The value of the generate modifier is ignored.
Q.17. What is the syntax to delete the data from the table which is there in database?
Ans: the best way is to use the REMOVE header indeed. You have the possibility of using the batchmode where all instances matching the unique attributes will be processed. So you only have to find an attribute that all instances have in common and I think here the itemtype is the best onde.
REMOVE MYVALUES[batchmode=true];itemtype(code)[unique=true]
;myValues
OR
You should open the Hybris administration console first, go to Console->FlexibleSearch. open SQL Query tab, then you can write any delete SQLs to excute. Remember to change to COMMIT mode before you excute any DML sqls.
Q.18. Difference between static and non static variable?
Ans:
Static Variables:
A static variable is associated with the class has only one copy per class but not for each object. An instance of a class does not have static variables.
Static variables can be accessed by static or instance methods
Memory is allocated when the class is loaded in context area at run time.
Non-Static Variables:
Non-static variables will have one copy each per object. Each instance of a class will have one copy of non-static variables.
Instance variables can be accessed only by the instance methods.
Instance variables are allocated at compile time.
Q.19. Why we use redeclare=”true”
Ans: To override an existing attribute of an itemtype, we add redeclare=”true” against that attribute
Q.20. How to create a Page Template?
Ans: Page Templates are the base for all types of pages. Each page–independent from its type–is assigned a page template. In addition to a name and an ID, a page template defines the names and number of content slots that can be filled with CMS Components. Before you can add page templates to our system, you must determine the number of page templates you need and the number and names of the content slots for each page template.
Next, you have to define the areas in the template where content editors can place content. It depends on which parts of the page should be editable. You should discuss this with your customer.
To simplify the page design, you only define four content slots for the Home page template: Top Links, Navigation, Main Body and Banner, and three content slots for the Main page template: Navigation, Main Body and Banner. All other sections, such as Logo and the contents on the top and bottom of the page, cannot be edited in the WCMS Cockpit.
Once you have defined the number of page templates and content slots, you can add them to the system. To add page templates and content slots:
1) In the hMC, navigate to the WCMS folder.
2) Right-click on the Page Templates option and select Create Page Template.
When creating a page template, keep in mind these guidelines:
The ID of a page template must be unique.
The Name of the page template is the name that appears in the WCMS Cockpit when a new page is created.
You must make sure to tick the Active checkbox to activate the template. An inactive page template cannot be used as a template when creating a new page.
The list of available content slots is the list of names you just defined.
You can also bind some content slots to the page template, so that every new page instance that uses this template has predefined contents.
Q.21. What is Classification in Hybris?
Ans: The classification functionality of the Catalog module enables you to define product attributes in a way different to the typing method.
Classification based attributes are called category features, sometimes also referred to as classification attributes.
Through classification you can flexibly allocate category features that may change frequently. Their definition and modification is easy because they are managed independently of the product type.
Available category features can be organized independently from product catalog structures in separate classification systems. Here they can be structured into classifying categories. Through such classifying categories, you can assign a category feature to one or multiple product categories used in catalogs. That means that all category features of the classifying categories are available within all products included in the assigned product categories. In addition, each category feature assigned to a category of a catalog structure is inherited by all subcategories.
Q.22. What are the two kind of user which we cannot delete?
Ans: There are three special system user items, that are essential to the platform and cannot be modified nor deleted. These are:
employee: admin
customer: anonymous
usergroup: admingroup
Both the anonymous and admin users are crucial for the internal processes of the hybris Multichannel Suite. Therefore, both accounts are protected from removal and against renaming. The hybris Multichannel Suite blocks all attempts of removing or renaming these user accounts.
Q.23. How we can create a new website page in wcms with or without pre-defined page template?
Ans:
Creating pages is possible only in the WCMS page view. In the live edit perspective you can only edit previously created pages
In the WCMS Cockpit you can only use predefined page templates. Creating new page templates is possible only in the hMC
To create a new website page, follow the steps below:
1) Open the catalog version in which you wish to have a new page. The main area displays all default pages from the selected catalog.
2) Click the Create an item button . A wizard displays in a pop-up dialog box.3) Select a type of page, for example a Content Page. Click the Next button to go to next step.4) Select a page template, for example a Home Template. Click the Next button.
In case there is a restriction of only one page template allowed for your selected page type, this step can be skipped and the following wizard dialog box is not displayed.
5) Enter the name of your new page. In the example screenshot below a name Test Page is entered. Click the Done button.
The Open Page in edit mode check box is selected by default. When selected it automatically opens your new page in edit mode, enabling for immediate editing.
If you want to edit a page immediately after creating it, you can select the Open page in edit mode check box. If the value is set to true, you are then redirected to the edit mode with the newly created page opened in editor. If you don't set this option to true, the system remains in the grid view.
For this you need to configure:
In the project.properties file of the cmscockpit extension, you can find the following line which by default marks the check box in the wizard for opening the page after creation as selected.
cmscockpit.default.pagewizard.activateaftercreate=true
Setting the value to false cause the check box in the wizard to be cleared by default.
6) You successfully created a new page.
Q.24. What are promotions and vouchers in Hybris?
Ans:
PROMOTIONS:
The promotions extension consists of a code component that may be used to implement customer sales promotion functionality within web sites and a hybris Management Console (hMC) component for creating and managing promotion data.
The promotions extension uses the BaseStore type, which is a part of the basecommerce extension
A promotion defines a single customer sales promotion. Promotions contain a rule set that defines the conditions for activation and a set of operations that define the effect of the promotion when activated.
Promotion Classes and Types
The following classes of promotion are included with the promotions extension:
Product level promotions are activated based upon the products within the line items of a shopping cart or order.
Order level promotions are activated based upon shopping cart or order attributes.
Additional promotion types may be developed as required.
Product Level Promotions
The complete list of out-of-the-box promotions is given below. It is possible to identify what products qualify for a promotion by the direct assignment of products and/or categories. Any product that belongs to a qualifying category is deemed qualified for the promotion. Promotion restrictions are required to further filter the qualifying product list.
Promotion Description
Bundle Purchase one of each product from a defined set for a combined total price. E.g.
buy A, B, and C for €50.
Buy X get Y free Purchase a certain number of products from within a defined set and add further
products from the same set at no additional cost. E.g. buy one get one free.
Fixed price Purchase from within a defined set at a fixed unit price. E.g. all shirts €5 each.
Multi-buy Purchase a certain number of products from within a defined set for a fixed price.
E.g. buy any 3 shirts for €50.
One to one perfect
partner bundle
Purchase a certain product and another defined partner product for a fixed total
price. The cart must contain the base product and the partner product to qualify.
E.g. buy this game and the selected partner accessory together for €25.00.
Percentage
discount
Receive a percentage discount on all products within a defined set. E.g. 20% off all
cameras.
Perfect partner Purchase a certain product from within a defined set and another partner product
from a different defined set and pay a fixed price for the partner product. E.g. buy a
game for €10 with each games console.
Perfect partner
bundle
Purchase a certain product along with a specified number of products from within a
defined set for a combined total price. E.g. buy a games console and 3 accessories
for €200.
Stepped multi-buy Purchase a number of products from within a defined set, there are multiple tiers of
Promotion Description
product quantities and fixed prices. E.g. buy any 3 shirts for €50, 5 for €65, and 7 for
€75.
Order Level Promotions
Promotion Description
Order threshold free gift A free gift is added to the order when the threshold order value is exceeded.
E.g. spend over €50 to receive a free t-shirt.
Order threshold free
voucher
A free voucher is given out when the order reaches a certain value. E.g. get a
free €5 voucher when you spend over €150.00.
Get a free voucher when your order subtotal is at least the threshold value.
Order threshold fixed
discount
A fixed value discount is applied to the order when the threshold order value is
exceeded. E.g. spend over €50 to receive a €3 discount.
Order threshold change
delivery mode
A different delivery mode is applied to the order when the threshold order value
is exceeded. E.g. spend over €10 to get free shipping.
Order threshold perfect
partner
Purchase a certain product from within a defined set for a fixed price when the
threshold order value is exceeded. E.g. spend over €50 to get any shirt for €5.
VOUCHERS:
The hybris voucher extension enables you to create and manage vouchers redeemable by your customers.
Vouchers present a special form of discounts in the hybris Commerce Suite that can be applied to an order. While ordinary discounts are automatically calculated for an order when their defined prerequisites are met by the content, time and/or customer of that order, vouchers have to be actively redeemed by the customer, typically as part of the order process of the shop frontend.
Like normal discounts within the hybris E-Business Platform vouchers can be set to discount prices in two different ways:
fixed discount value (e.g. 10 off)
percentual discount (e.g. 20% off)
The calculation of the discount called for by a given voucher is done on the total value of the applicable product prices, inclusive of VAT. Since vouchers can be restricted to apply to certain products only there may be order entries in an order that qualify as non-applicable products. Such products are then not subject to the voucher discount rules.
A voucher can optionally have one or more restrictions affecting the user, product, date, etc it can apply to. In addition, a voucher can be set to offer free shipping.
The number of redemptions possible with a voucher is be defined depending on the nature of the voucher. Serial Vouchers contain a list of generated valid voucher codes. Each voucher code of a Serial Voucher can only be redeemed once. Promotional vouchers only have a single voucher code. Such vouchers can be redeemed according to the settings of the total amount of redemptions for that voucher and the maximum amount of redemptions
possible by one and the same customer (typically 1 redemption per customer)
Q.25. I want to create a new kind of restricted type? How to do it?
Ans:
Configuring a Restriction Type in the hMC
You can create a Restriction type item in the hMC and use it to add restrictions to the Web Content Management System (WCMS) pages. Once you have configured the Restriction type item, you can use it to apply restrictions to pages.
Creating a Restriction Type
To create a restriction type item:
1) Create a new Restriction and assign it to a CMSPageType:
Open the hMC and navigate to the Restriction Types node in the navigation tree.
Right-click the node and select the Create Restriction Type option.
2) The window appears where you can provide required information for the Restriction type item: Identifier and Supertype. When done, click Create to create the type.
3) After the type has been created, click the Save button.
4) To assign a page type to the newly created Restriction type item:
Click the Assigned Page Types tab.
Right-click the Page Types table and select Add Page Type.
5) You can add more page types to the current restriction type or you can edit details of the assigned page type. Right-click on the page type entry in the table and from the context menu select the desired option.
Assigning Restrictions to WCMS Pages
1) In the hMC, go to the WCMS -- Page Types node. Search for the required page type. Double-click the entry of the particular page type for which you want to configure the Restriction type.
2) Click the Applicable Restriction Types tab. The list of applicable restriction types assigned to the selected page type are displayed. You can add, edit, or remove restrictions assigned to the page type by selecting the appropriate option from the context menu that displays after right-clicking within the area of the Applicable Restrictions Types table.
Configuring a Restriction Type Using an ImpEx Script
You can assign a Restriction item type to a particular page type. With the ImpEx script you, can create Restriction type or modify an existing one. The sample ImpEx script below uses the INSERT_UPDATE instruction to update the existing items, or to create an item if it has not previously existed. If you want to modify the Restriction types assigned to a certain page type, for example CMSPageType, you can do it by updating the essential data ImpEx script file.
essentialDataApplicableRestrictionTypes.impex
INSERT_UPDATE CmsPageType;code[unique=true];restrictionTypes(code)
;CatalogPage;CMSCatalogRestriction,CMSTimeRestriction,CMSUserRestriction,CMSUserGroupRestriction
;CategoryPage;CMSCategoryRestriction,CMSTimeRestriction,CMSUserRestriction,CMSUserGroupRestriction
;ContentPage;CMSTimeRestriction,CMSUserRestriction,CMSUserGroupRestriction
;ProductPage;CMSProductRestriction,CMSTimeRestriction,CMSUserRestriction,CMSUserGroupRestriction
Q.26. What is dependency injection? Where we are using it in hybris?
Ans: In Spring frameowork, Dependency Injection (DI) design pattern is used to define the object dependencies between each other. It exits in two major types :
Setter Injection
Constructor Injection
We are using DI in hybris especially to bind the related beans inside extensionname-spring.xml
Q.27. Where are we configuring JUNIT in Hybris?
Ans:
We should create db configuration specific to junit tenant in the administration console -> Platform -> Tenants.
http://localhost:9001/hac/tenants/junit/edit
top related