evolve13 cq-commerce-framework
TRANSCRIPT
AEM Commerce Framework
Paolo Mo!adelli - Sr. Mgr. Technical Marketing@paolomoz
Adobe® Marketing Cloud
Adobe® Experience Manager
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Architecture of the framework1
Commerce Integrated Platform
JCR repo product DB
Experience Manager PIM/ecommerce
surfer
content editor PIM editor
1 2
PIM synch
3
4
dynamic PIM
Commerce Integrated Platform
surfer
content editor PIM editor
1. Product display component2. Shopping cart3. Promotions and vouchers4. Catalog blueprints5. Check-out6. Search
1. Product information integrity2. Pricing3. Stock-keeping inventory4. Variations on shopping cart
AEM eCommerce Integration Modules
1. !e integration framework (API used for eCommerce implementations)
2. AEM native (JCR) implementation
3. hybris implementation
4. A number of out-of-the-box AEM components
5. Search (AEM, eCommerce, 3rd party)
6. Catalog management
7. Promotions management
8. Client context cart storeJCR repo product DB
Experience Manager PIM/ecommerce
Architecture of the Commerce Framework
AEM Commerce API
Implementation
AEM Commerce Components
AEM native impl
JCR Repository
hybris impl
hybris DB
other impl
other
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Commerce providersWith code samples2
eCommerce Engine Selection
CommerceService commerceService = resource.adaptTo(CommerceService.class);
CommerceSession session = commerceService.login(slingRequest, slingResponse);
Product baseProduct = resource.adaptTo(Product.class);
GeoImpl(geometrixx) hybrisImpl
(hybris)
otherImpl(xyz)
Site Component
OSGi container
bundle
bundlebundle
cq:commerceProvider = geometrixx
1
2
3
TrainingCommerceServiceFactory
@Component(metatype = true, label = "Day CQ Commerce Factory for Training")@Service@Properties(value = { @Property(name = "service.description", value = "Factory for training commerce service"), @Property(name = "commerceProvider", value = "training")})
public class TrainingCommerceServiceFactory extends AbstractJcrCommerceServiceFactory implements CommerceServiceFactory {
public CommerceService getCommerceService(Resource res) { return new TrainingCommerceServiceImpl(getServices(), res); }
}
TrainingCommerceServiceImpl
public class TrainingCommerceServiceImpl extends AbstractJcrCommerceService implements CommerceService {
[...]
public CommerceSession login(SlingHttpServletRequest request, SlingHttpServletResponse response) throws CommerceException { return new TrainingCommerceSessionImpl(this, request, response, resource); }
public Product getProduct(final String path) throws CommerceException { [...] return new TrainingProductImpl(resource); [...] }
TrainingCommerceSessionImpl
public class TrainingCommerceSessionImpl extends AbstractJcrCommerceSession {
[..]}
TrainingCommerceSessionImpl
public class TrainingCommerceSessionImpl extends AbstractJcrCommerceSession {
protected void loadCart() protected void saveCart() public String getProductPrice(Product product) public String getCartPrice(Predicate filter) protected void doAddCartEntry(Product product, int quantity) protected void calcCart() public List<Promotion> getActivePromotions() protected void calcOrder()}
TrainingCommerceServiceFactory
public class TrainingProductImpl extends AbstractJcrProduct {
[...]
public String getSKU() { return "todo-get-sku-method"; }}
eCommerce Engine Selection
CommerceService commerceService = resource.adaptTo(CommerceService.class);
CommerceSession session = commerceService.login(slingRequest, slingResponse);
Product baseProduct = resource.adaptTo(Product.class);
GeoImpl(geometrixx) hybrisImpl
(hybris)
trainingImpl(training)
Site Component
OSGi container
bundle
bundlebundle
cq:commerceProvider = training
1
2
3
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
(more on) CommerceSessionWith code samples3
•updateOrderDetails(Map<String, String> orderDetails);•getOrderDetails();•submitOrder();
CommerceSession responsibilities
• addCartEntry(Product product, int quantity);• modifyCartEntry(int entryNumber, int quantity);• deleteCartEntry(int entryNumber);
•updateOrderDetails(Map<String, String> orderDetails);•getOrderDetails();•submitOrder();
cart content
pricing
order details
1
2
3
•getPromotions();•addVoucher(String code);•removeVoucher(String code);
promotions3
CommerceSession is RESTful style (2)
ORDER%3a%3dorderId%253d9c1346bf-3813-4205-80ec-2fdfd1644143%7cCART%3a%3dquantity3%253d1%252cquantity0%253d1%252cquantity1%253d1%252cpromotionCoun
t%253d2%252cquantity2%253d1%252cvoucherCount%253d0%252cpromotion1%253d%252fcontent%252fcampaigns%252fgeometrixx-outdoors%252fcosy-up-to-winter%252fwinter-female%252fcosy-companions%252cpromotion0%253d%252fcontent
%252fcampaigns%252fgeometrixx-outdoors%252!ig-spender%252fordervalueover100%252ffree-shipping%252cproduct3%253d%252fcontent
%252fgeometrixx-outdoors%252fen%252fequipment%252fskiing%252#alifax-winter%252$cr%253acontent%252fpar%252fproduct%252cproduct0%253d%252fcontent
%252fgeometrixx-outdoors%252fen%252fwomen%252fcoats%252fcalgary-winter%252$cr%253acontent%252fpar%252fproduct%252f397122-s%252cproduct2%253d%252fcontent
%252fgeometrixx-outdoors%252fen%252fseasonal%252fwinter%252fequipment%252%amloops-snow%252$cr%253acontent%252fpar%252fproduct
%252f37924450-7%252centryCount%253d4%252cproduct1%253d%252fcontent%252fgeometrixx-outdoors%252fen%252fequipment%252fskiing%252%elowna-snow
%252$cr%253acontent%252fpar%252fproduct%7c
Name: CommercePersistence, Host: geometrixx.com, Path: /
CommerceSession is RESTful style (3)
protected void loadCart() {
[...]
// // Load cart from the cookie: // Map<String, String> cartStore = ContextSessionPersistence.getStore(request, "CART", CommerceConstants.COMMERCE_COOKIE_NAME);
[...]
}
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.
Managing productsIncludes solutions for scalability, performance, etc..4
Products and Variants architecture:
- variant - color: purple- id: 397122.1
- variant - size: S
- variant - size: L
- variant - size: M
- variant - size: XL
- variant - color: purple-id: 397122.2- price: 199
- variant - size: S
- variant - size: L
- variant - size: M
- variant - size: XL
- type: product- axes: color, size - id: 397122- title: Saskatoon- price: 299
11
1
1 1
1 1
1 1
1 1
Product interface
public interface Product extends Adaptable { public String getPath(); // path to speci!c variation public String getPagePath(); // path to presentation page for all variations public String getSKU(); // unique ID of speci!c variation public String getTitle(); // shortcut to getProperty(TITLE) public String getDescription(); // shortcut to getProperty(DESCRIPTION) public String getImageUrl(); // shortcut to getProperty(IMAGE_URL) public String get"umbnailUrl(); // shortcut to getProperty(THUMBNAIL_URL) public <T> T getProperty(String name, Class<T> type); public Iterator<String> getVariantAxes(); public boolean axisIsVariant(String axis); public Iterator<Product> getVariants(VariantFilter !lter) throws CommerceException;}
AxisFilter implements VariantFilter
public class AxisFilter implements VariantFilter { ...
public boolean includes(Product product) { ValueMap values = product.adaptTo(ValueMap.class); if(values != null) { String v = values.get(axis, String.class); return v != null && v == value; } return false; }}
Product Data admin UI
•Double click from Content Finder to open
•Based on Scaffolding
•Create/Change data in /etc/commerce/products
•Can change destination path from Scaffolding page
•Can navigate and change variants (overrides higher level data)
5.6.1
Hardening Product Importer
•ROBUSTNESS: product importer more $exible with products/variants
•EXTENSIBILITY: abstracted-out common parts of product importer
•PERFORMANCE: importing 1000s products takes 80% less
•SCALABILITY: support $at hierarchies through bucketing, proxy pages, scalable search
5.6.1
Catalog Generation V2
•Regional Catalog support (based on MSM)
•Catalog Design Changes support
•Custom Catalog Pages support
•Blueprint & Catalog converter for 5.6.0 to current
5.6.1
Shopping Cart architecture (CommerceSession)
"e CommerceSession performs add, remove, etc."e CommerceSession also performs the various calculations on the cart."e CommerceSession also applies vouchers and promotions that have !red to the cart.
Pricing modi&ers:- Quantity discounts. - Different currencies.- VAT-liable and VAT-free.
session.calcCart()
protected void calcCart() { ... for (int i = 0; i < cart.size(); i++) { ... for (Promotion p : promotions) { try { PromotionHandler ph = p.adaptTo(PromotionHandler.class); PriceInfo discount = ph.applyCartEntryPromotion(this, p, entry); if (discount != null && discount.getAmount().compareTo(BigDecimal.ZERO) > 0) { ... entry.calcPrices(); ... } ... cartTotalPrice = cartTotalPrice.add(entry.getPriceInfo(new PriceFilter("POST_TAX", currencyCode)).get(0).getAmount()); } setPrice(new PriceInfo(cartPreTaxPrice, currency), "CART", "PRE_TAX"); setPrice(new PriceInfo(cartTax, currency), "CART", "TAX"); setPrice(new PriceInfo(cartTotalPrice, currency), "CART", "POST_TAX"); ... }
Shopping Cart architecture (Storage)
In AEM-native carts are stored in the ClientContext
Personalization should always be driven through the ClientContext.CommerceSession.addCartEntry()
Checkout architecture (order details)
Order details are not !xed by the API: updateOrderDetails(Map<String, String> orderDetails);
Shipping options (and prices) depend on weight, delivery address, etc...
"e CommerceSession owns shipping pricing; to retrieve and update delivery details:updateOrder(Map<String, Object> delta)
hybris integration: product data #ow
hybris: Omni Commerce Connect
CQ:/etc/commerce/products
CQ:/content/site
hybris importer catalog publishing
hybris integration: product data display
JCR repo
CQhybris
CQ hybris importer
CQ component volatile data
PIM data
hybris integration: user synchronisation
•Lazy import of hybris users into CQ
•Lazy creation of CQ users in hybris
•CQ stores hybris authentication data for later re-use
•Pluggable architecture for custom authentication schemes (SAML, OAuth)
hybris integration: customising the product import process
•Need to add PIM a%ributes? Extend HybrisResponseParser.
•Need to change the imported data hierarchy? Extend ImportHandler.
•Need to customize what services are called when importing data? Extend HybrisImporter.
hybris integration: customising the user import process
•Pro!leSynchronizer#syncPro!le is responsible for sync the user’s CQ pro!le to the respective
hybris account
hybris integration: customising product and price loading
•HybrisFactory#getProduct is responsible for creating Product instances
•HybrisSession#getProductPriceInfo is responsible for ge%ing the correct price for a product for
the current user
hybris integration: how to install
AEM 5.6.1
3
cq-hybris-content 5.6.22
cq-hybris-server 5.6.01
cq-geometrixx-hybris-content 5.6.100
install packages
5.6.1
hybris with AEM 5.6.1
•Supports hybris 5.0
•hybris 5.0 server embedded by default
•Backward compatible with hybris 4.8.1
•Geometrixx-speci!c hybris connector
•Extend the default hybris components to a speci!c implementation;
•Remove internal references in the hybris components to allow for be%er extensibility
•hybris connector source code included in the content package
5.6.1