電子商務架構可與任何電子商務解決方案搭配使用。 在此處理的特定細節和範例,請參考 hybris 解決方案。
整合架構包含具有API的整合層。 這可讓您:
外掛電子商務系統,並將產品資料提取至Adobe Experience Manager (AEM)
建置AEM元件,用於獨立於特定電子商務引擎的商務功能
API檔案 也可供使用。
提供幾個現成的AEM元件,以供使用整合層。 目前包括:
針對搜尋,整合勾點可讓您使用AEM搜尋、電子商務系統搜尋、第三方搜尋或其組合。
電子商務架構可與任何電子商務解決方案搭配使用,所使用的引擎必須可由AEM識別:
電子商務引擎是支援的OSGi服務 CommerceService
介面
commerceProvider
服務屬性AEM支援 Resource.adaptTo()
的 CommerceService
和 Product
此 adaptTo
實施會尋找 cq:commerceProvider
資源階層中的屬性:
如果找到,則會使用值來篩選商務服務查閱。
如果找不到,則會使用排名最高的商務服務。
A cq:Commerce
mixin用於 cq:commerceProvider
可新增至強型別資源。
此 cq:commerceProvider
屬性也可用來參考適當的商務工廠定義。
例如, cq:commerceProvider
具有值的屬性 hybris
與的OSGi設定相關 Day CQ Commerce Factory for Hybris (com.adobe.cq.commerce.hybris.impl.HybrisServiceFactory) — 其中的引數 commerceProvider
還具有值 hybris
.
這裡是其他屬性,例如 目錄版本 可以進行設定(在適當且可用時)。
請參閱下列範例:
cq:commerceProvider = geometrixx |
在標準AEM安裝中,需要特定實施。 例如,Geometrixx範例,其中包含一般API的最低擴充功能 |
---|---|
cq:commerceProvider = hybris |
hybris實施 |
/content/store
+ cq:commerceProvider = hybris
+ mens
+ polo-shirt-1
+ polo-shirt-2
+ employee
+ cq:commerceProvider = jcr
+ adobe-logo-shirt
+ cq:commerceType = product
+ price = 12.50
+ adobe-logo-shirt_S
+ cq:commerceType = variant
+ size = S
+ adobe-logo-shirt_XL
+ cq:commerceType = variant
+ size = XL
+ price = 14.50
您可以使用CRXDE Lite檢視在Hybris實作的產品元件中如何處理這項作業:
/apps/geometrixx-outdoors/components/hybris/product/product.jsp
已更新eCommerce Integration Framework的hybris擴充功能,以支援Hybris 5,同時保持與Hybris 4的回溯相容性。
程式碼中的預設設定是針對Hybris 5調整的。
若要針對Hybris 4開發,需要下列專案:
叫用maven時,將下列命令列引數新增到命令中
-P hybris4
它會下載預先設定的Hybris 4散發,並將其嵌入套件組合中 cq-commerce-hybris-server
.
在OSGi設定管理員中:
停用預設回應剖析器服務的Hybris 5支援。
請確定Hybris基本驗證處理常式服務的服務排名低於Hybris OAuth處理常式服務。
hybris會使用使用者工作階段來儲存資訊,例如客戶的購物車。 工作階段ID會從hybris傳回,位於 JSESSIONID
後續要求必須傳送給hybris的Cookie。 為避免將工作階段ID儲存在存放庫中,它會編碼到儲存在購物者瀏覽器中的另一個Cookie。 將執行下列步驟:
在第一個要求中,購物者的要求上不會設定Cookie,因此會傳送要求給hybris執行個體以建立工作階段。
工作階段Cookie會從回應中擷取,並在新的Cookie中編碼(例如 hybris-session-rest
),並在對購物者的回應上設定。 新Cookie中的編碼為必填,因為原始Cookie僅對特定路徑有效,否則在後續請求中不會從瀏覽器傳回。 必須將路徑資訊新增至Cookie的值。
在後續的請求中,會將Cookie解碼自 hybris-session-<*xxx*>
Cookie ,以及在用來向hybris要求資料的HTTP使用者端上設定。
當原始工作階段不再有效時,會建立新的匿名工作階段。
此工作階段「擁有」 購物車
執行新增/移除/等
在購物車上執行各種計算;
commerceSession.getProductPrice(Product product)
擁有 儲存位置 針對 訂購 資料
CommerceSession.getUserContext()
擁有 付款 正在處理連線
擁有 履行 連線
在Hybris中維護的產品資料必須在AEM中可用。 已實作下列機制:
匯入工具(b)是用來在AEM中設定目錄的頁面樹狀結構。
Hybris中的目錄變更會透過摘要顯示給AEM,然後傳播給AEM (b)
有關目錄版本的新增/刪除/變更產品。
產品已核准。
hybris擴充功能提供輪詢匯入工具(「hybris」配置),可設定為以指定的間隔(例如,每24小時將間隔指定為秒)將變更匯入AEM:
http://localhost:4502/content/geometrixx-outdoors/en_US/jcr:content.json
{
* "jcr:mixinTypes": ["cq:PollConfig"],
* "enabled": true,
* "source": "hybris:outdoors",
* "jcr:primaryType": "cq:PageContent",
* "interval": 86400
}
AEM中的目錄設定可辨識 已分段 和 線上 目錄版本。
在目錄版本之間同步產品需要啟用或停用對應的AEM頁面(a、c)
將產品新增至 線上 目錄版本需要啟動產品頁面。
移除產品需要停用。
在AEM ©中啟用頁面需要核取(b),且只有在
產品位於 線上 產品頁面的目錄版本。
參考的產品位於 線上 其他頁面(例如行銷活動頁面)的目錄版本。
啟用的產品頁面必須存取產品資料的 線上 版本(d)。
AEM Publish執行個體需要存取hybris,以擷取產品和個人化資料(d)。
單一產品可以有多個變數,例如可能因顏色和/或大小而異。 產品必須定義哪些屬性會帶動變化;Adobe術語如下 變數軸.
不過,並非所有屬性都是變數軸。 變化也可能會影響其他屬性;例如,價格可能取決於大小。 購物者無法選取這些屬性,因此不會視為變數軸。
每個產品和/或變體由資源表示,因此將1:1對應到存放庫節點。 必然結果是,特定產品和/或變體可由其路徑唯一識別。
產品/變體資源並非總是包含實際產品資料。 它可能是其他系統上所保留資料的表示法(例如hybris)。 例如,產品說明和定價不會儲存在AEM中,而是從電子商務引擎即時擷取。
任何產品資源都可以以下列專案表示: Product API
. 產品API中的大部分呼叫都是變異專用(雖然變異可能會繼承來自祖先的共用值),但也會有列出變異集合的呼叫( getVariantAxes()
, getVariants()
、等等)。
實際上,變體軸由任何決定 Product.getVariantAxes()
傳回:
雖然產品(一般)可以有許多變體軸,但現成可用的產品元件僅處理兩個變體:
size
再加一個
若要選取此額外變體,請透過 variationAxis
產品參考的屬性(通常 color
(適用於Geometrixx Outdoors)。
一般而言,產品資料位於 /etc
,以及下的產品參考 /content
.
產品變數和產品資料節點之間必須是1:1對應。
產品參考也必須針對呈現的每個變數有一個節點,但不需要呈現所有變數。 例如,如果產品有S、M、L等變數,則產品資料可能是:
etc
|──commerce
| |──products
| |──shirt
| |──shirt-s
| |──shirt-m
| |──shirt-l
雖然「大而高」目錄可能只有:
content
|──big-and-tall
| |──shirt
| |──shirt-l
最後,不需要使用產品資料。 您可以將所有產品資料放置在目錄中的參照下;但這樣一來,您就無法在不複製所有產品資料的情況下擁有多個目錄。
API
public interface Product extends Adaptable {
public String getPath(); // path to specific variation
public String getPagePath(); // path to presentation page for all variations
public String getSKU(); // unique ID of specific 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 getThumbnailUrl(); // 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 filter) throws CommerceException;
}
/**
* Interface for filtering variants and AxisFilter provided as common implementation
*
* The <code>VariantFilter</code> is used to filter variants,
* for example, when using {@link Product#getVariants(VariantFilter filter)}.
*/
public interface VariantFilter {
public boolean includes(Product product);
}
/**
* A {@link VariantFilter} for filtering variants by the given
* axis and value. The following example returns a list of
* variant products that have a value of <i>blue</i> on the
* <i>color</i> axis.
*
* <p>
* <code>product.getVariants(new AxisFilter("color", "blue"));</code>
*/
public class AxisFilter implements VariantFilter {
private String axis;
private String value;
public AxisFilter(String axis, String value) {
this.axis = axis;
this.value = value;
}
/**
* {@inheritDoc}
*/
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;
}
}
一般儲存機制
產品節點為 nt:unstructured
.
產品節點可以是:
具有儲存在其他位置的產品資料的參考:
產品引用包含 productData
屬性,指向產品資料(通常位於 /etc/commerce/products
)。
產品資料為階層式;產品屬性繼承自產品資料節點的祖先。
產品參考也可以包含本機屬性,這些屬性會覆寫產品資料中指定的屬性。
產品本身:
不含 productData
屬性。
在本機持有所有屬性(且不包含productData屬性)的產品節點,會直接從自己的祖先繼承產品屬性。
AEM-generic產品結構
每個變體都必須有自己的葉節點。
產品介面同時代表產品與變體,但相關的存放庫節點會針對具體專案而有所不同。
product節點會說明產品屬性和變體軸。
+ banyan_shirt
- cq:commerceType = product
- cq:productAttributes = [jcr:title, jcr:description, size, price, color]
- cq:productVariantAxes = [color, size]
- jcr:title = Banyan Shirt
- jcr:description = Flowery, all-cotton shirt.
- price = 14.00
+ banyan_shirt_s
- cq:commerceType = variant
- size = S
+ banyan_shirt_s_red
- cq:commerceType = variant
- color = red
+ banyan_shirt_s_blue
- cq:commerceType = variant
- color = blue
+ banyan_shirt_m
- cq:commerceType = variant
- size = M
+ banyan_shirt_m_red
- cq:commerceType = variant
- color = red
+ banyan_shirt_m_blue
- cq:commerceType = variant
- color = blue
+ banyan_shirt_l
- cq:commerceType = variant
- size = L
+ banyan_shirt_l_red
- cq:commerceType = variant
- color = red
+ banyan_shirt_l_blue
- cq:commerceType = variant
- color = blue
+ banyan_shirt_xl
- cq:commerceType = variant
- size = XL
- price = 18.00
元件
該購物車屬於 CommerceSession:
CommerceSession
執行新增/移除/等等。CommerceSession
也會在購物車上執行各種計算。"雖然並非直接與購物車相關,但 CommerceSession
也必須提供型錄訂價資訊(因為它擁有訂價)
訂價可能有數個修正因子:
修飾詞使用以下介面為開放式:
int CommerceSession.getQuantityBreakpoints(Product product)
String CommerceSession.getProductPrice(Product product)
儲存空間
儲存空間
個人化
一律透過 ClientContext.
ClientContext /version/
會在所有情況下建立的Cart中:
CommerceSession.addCartEntry()
方法。以下說明ClientContext購物車中的購物車資訊範例:
購物車與訂單資料
此 CommerceSession
擁有三個元素:
購物車內容
定價
訂單詳細資料
購物車內容
購物車內容結構已由API修正:
public void addCartEntry(Product product, int quantity);
public void modifyCartEntry(int entryNumber, int quantity);
public void deleteCartEntry(int entryNumber);
定價
API也會修正此定價結構:
public String getCartPreTaxPrice();
public String getCartTax();
public String getCartTotalPrice();
public String getOrderShipping();
public String getOrderTotalTax();
public String getOrderTotalPrice();
訂單詳細資料
不過,訂單詳細資料如下 非 由API修正:
public void updateOrderDetails(Map<String, String> orderDetails);
public Map<String, String> getOrderDetails();
public void submitOrder();
送貨計算
訂購單通常必須提供多種送貨選項(和價格)。
價格可能會以訂單的專案和詳細資訊為依據,例如重量和/或交貨地址。
此 CommerceSession
可存取所有相依性,因此可將其視為類似產品定價的方式:
CommerceSession
擁有送貨定價。updateOrder(Map<String, Object> delta)
您可以實作送貨選擇器;例如:
yourProject/commerce/components/shippingpicker
:
基本上,這可以是 foundation/components/form/radio
,但對 CommerceSession
針對:
正在檢查方法是否可用
新增定價資訊
讓購物者能夠在AEM中更新訂單頁面(包括送貨方法的超集以及描述這些方法的文字),同時仍擁有公開相關資訊的控制權 CommerceSession
資訊。
付款處理
此 CommerceSession
也擁有付款處理連線。
實作者應將特定通話(至其選擇的付款處理服務)新增至 CommerceSession
實作。
訂單履行
CommerceSession
也擁有履行連線。CommerceSession
實作。遵循標準服務API模型,電子商務專案提供一組可由個別商務引擎實作的搜尋相關API。
目前,只有Hybris引擎會實作立即可用的Search API。
不過,搜尋API是通用的,可由每個CommerceService個別實作。
電子商務專案包含中的預設搜尋元件:
/libs/commerce/components/search
這會使用搜尋API來查詢所選的商務引擎(請參閱 電子商務引擎選擇):
核心專案提供了幾個通用/協助程式類別:
CommerceQuery
說明搜尋查詢(包含有關查詢文字、目前頁面、頁面大小、排序和所選多面的資訊)。 所有實作搜尋API的電子商務服務都會收到此類別的執行個體,以執行其搜尋。 A CommerceQuery
可以從請求物件具現化( HttpServletRequest
)。
FacetParamHelper
是一個公用程式類別,提供一個靜態方法 — toParams
— 用於產生 GET
多面清單的引數字串和一個切換值。 這在UI端相當實用,您必須針對每個Facet的每個值顯示超連結,如此一來,當使用者按一下超連結時,就會切換個別值。 也就是說,如果選取它,它會從查詢中移除,否則會新增。 這會負責處理多個/單一值Facet、覆寫值等作業的所有邏輯。
搜尋API的進入點為 CommerceService#search
傳回 CommerceResult
物件。 請參閱 API檔案 以取得有關本主題的詳細資訊。
提供AEM與各種電子商務系統之間的整合。 這需要在不同系統之間同步處理購物者的策略,以便AEM的特定程式碼只需瞭解AEM,反之亦然:
驗證
AEM被推定為 僅限 Web前端,因此執行 全部 驗證。
Hybris中的帳戶
AEM會為每個購物者以hybris建立對應的(下屬)帳戶。 此帳戶的使用者名稱與AEM的使用者名稱相同。 加密隨機密碼會自動產生,並儲存在AEM中(加密)。
AEM前端可放置在現有Hybris實作的前面。 您也可以將hybris引擎新增至現有的AEM安裝。 為此,系統必須能夠正確地處理任一系統中的現有使用者:
AEM -> hybris
登入Hybris時,如果AEM使用者不存在:
請參閱: com.adobe.cq.commerce.hybris.impl.HybrisSessionImpl#login()
hybris -> AEM
登入AEM時,如果系統辨識出使用者:
上述演演算法是在Sling中實作 AuthenticationInfoPostProcessor
com.adobe.cq.commerce.hybris.impl.user.LazyUserImporter.java
若要在現有功能上建置自訂匯入處理常式:
必須實作 ImportHandler
介面
可以擴充 DefaultImportHandler
.
/**
* Services implementing the <code>ImportHandler</code> interface are
* called by the {@link HybrisImporter} to create actual commerce entities
* such as products.
*/
public interface ImportHandler {
/**
* Not used.
*/
public void createTaxonomie(ImporterContext ctx);
/**
* Creates a catalog with the given name.
* @param ctx The importer context
* @param name The catalog's name
* @return Path of created catalog
*/
public String createCatalog(ImporterContext ctx, String name) throws Exception;
/**
* Creates a product from the given values.
* @param ctx The importer context
* @param values The product's properties
* @param parentCategoryPath The containing category's path
* @return Path of created product
*/
public String createProduct(ImporterContext ctx, ValueMap values, String parentCategoryPath) throws Exception;
/**
* Creates a variant product from the given values.
* @param ctx The importer context
* @param values The product's properties
* @param baseProductPath The base product's path
* @return Path of created product
*/
public String createVariantProduct(ImporterContext ctx, ValueMap values, String baseProductPath) throws Exception;
/**
* Creates an asset for a product. This is usually a product
* image.
* @param ctx The importer context
* @param values The product's properties
* @param baseProductPath The product's path
* @return Path of created asset
*/
public String createAsset(ImporterContext ctx, ValueMap values, String productPath) throws Exception;
/**
* Creates a category from the given values.
* @param ctx The importer context
* @param values The category's properties
* @param parentPath Path of parent category or base path of import in case of root category
* @return Path of created category
*/
public String createCategory(ImporterContext ctx, ValueMap values, String parentCategoryPath) throws Exception;
}
若要讓匯入工具識別您的自訂處理常式,該處理常式必須指定 service.ranking
屬性值高於0的屬性。
@Component
@Service
@Property(name = "service.ranking", value = 100)
public class MyImportHandler extends DefaultImportHandler
{
...
}