[僅限PaaS]{class="badge informative" title="僅適用於雲端專案(Adobe管理的PaaS基礎結構)和內部部署專案的Adobe Commerce 。"}
設定以透過Live Search成功
Adobe Commerce Live Search與Catalog Service共同合作,提供效能、相關且直覺式的搜尋解決方案,讓您的客戶快速找到他們所需的專案。 具體來說,Catalog Service會呈現您的目錄資料以供SaaS服務使用,例如Live Search。
本文提供使用Live Search實作Catalog Service的逐步指示。
客群
本文適用於負責安裝和設定Adobe Commerce執行個體的開發人員或團隊中的系統整合商。
需求
- Adobe Commerce 2.4.4+
- PHP 8.1、8.2或8.3
- Composer
- 執行cron工作和索引子
重要更新
- 截至Live Search 3.0.2,Catalog Service擴充功能已隨安裝一併提供。
支援平台
- 雲端上的Adobe Commerce (ECE) : 2.4.4+
- Adobe Commerce內部部署(EE) : 2.4.4+
工作流程概觀
從高層面來看,上線Live Search需要您:
1.安裝Live Search擴充功能
已從Live SearchAdobe Marketplace透過Composer將安裝為擴充功能。 安裝並設定Live Search後,Adobe Commerce會開始與SaaS服務共用搜尋和目錄資料。 此時,管理員使用者可以設定、自訂及管理搜尋Facet、同義字及銷售規則。
如果您在新的Commerce執行個體上安裝Live Search,請依照這些指示操作。
-
使用Composer將「即時搜尋」模組新增至您的專案:
code language-bash composer require magento/live-search --no-update
-
更新相依性並安裝擴充功能:
code language-bash composer update magento/live-search --with-dependencies
-
停用OpenSearch及相關模組,並安裝Live Search。 OpenSearch和Live Search無法同時在同一Commerce執行個體上啟用。
code language-bash bin/magento module:disable Magento_Elasticsearch Magento_Elasticsearch8 Magento_Elasticsearch7 Magento_OpenSearch Magento_ElasticsearchCatalogPermissions Magento_InventoryElasticsearch Magento_ElasticsearchCatalogPermissionsGraphQl
Elasticsearch會繼續從店面管理搜尋要求,而Live Search服務會在背景同步目錄資料和索引產品。
-
安裝更新。
code language-bash bin/magento setup:upgrade
-
確認下列索引子已設定為「依排程更新」:
- 產品摘要
- 產品變體摘要
- 目錄屬性摘要
- 產品價格摘要
- 範圍網站資料摘要
- 範圍客戶群組資料摘要
- 類別摘要
- 類別許可權摘要
驗證索引器後,下一步是設定API金鑰。
如果您要在現有的Commerce執行個體上安裝Live Search,請依照這些指示操作。
-
使用Composer將「即時搜尋」模組新增至您的專案:
code language-bash composer require magento/live-search --no-update
-
更新相依性並安裝擴充功能:
code language-bash composer update magento/live-search --with-dependencies
-
停用提供店面搜尋結果的Live Search模組。
code language-bash bin/magento module:disable Magento_LiveSearchAdapter Magento_LiveSearchStorefrontPopover Magento_LiveSearchProductListing
Elasticsearch會繼續從店面管理搜尋要求,而Live Search服務會在背景同步目錄資料和索引產品。
-
安裝更新。
code language-bash bin/magento setup:upgrade
-
確認下列索引子已設定為「依排程更新」:
- 產品摘要
- 產品變體摘要
- 目錄屬性摘要
- 產品價格摘要
- 範圍網站資料摘要
- 範圍客戶群組資料摘要
- 類別摘要
- 類別許可權摘要
-
啟用Live Search擴充功能,並停用OpenSearch (Magento Elasticsearch和OpenSearch模組)。
code language-bash bin/magento module:enable Magento_LiveSearchAdapter Magento_LiveSearchStorefrontPopover Magento_LiveSearchProductListing
code language-none bin/magento module:disable Magento_Elasticsearch Magento_Elasticsearch6 Magento_Elasticsearch7 Magento_Elasticsearch8 Magento_OpenSearch Magento_ElasticsearchCatalogPermissions Magento_InventoryElasticsearch Magento_ElasticsearchCatalogPermissionsGraphQl
note note NOTE disable命令包含支援OpenSearch的Commerce模組清單。 如果您的Commerce執行個體未安裝模組,您將會看到 module does not exist
錯誤。 -
安裝更新。
code language-bash bin/magento setup:upgrade
驗證索引器後,下一步是設定API金鑰。
2.設定API金鑰
必須有Adobe Commerce API金鑰及其相關的私密金鑰,才能將Live Search連線至Adobe Commerce的安裝。 API金鑰是在Commerce授權持有者的帳戶中產生和維護的,該帳戶可與開發人員或系統整合商共用。 開發人員可以代表授權持有人建立和管理SaaS資料空間。 如果您已經有一組API金鑰,則不需要重新產生。
在Commerce Services Connector文章中瞭解如何設定您的API金鑰。
3.同步處理您的目錄資料
Live Search將目錄資料移動到Adobe的SaaS基礎結構。 資料會編制索引,而搜尋結果會從此索引直接傳送到店面。 根據大小和複雜性,索引可能需要30分鐘到數小時的時間。
若要開始將目錄資料初始同步至SaaS服務,請依此順序執行下列命令:
bin/magento saas:resync --feed productattributes
bin/magento saas:resync --feed products
bin/magento saas:resync --feed scopesCustomerGroup
bin/magento saas:resync --feed scopesWebsite
bin/magento saas:resync --feed prices
bin/magento saas:resync --feed productoverrides
bin/magento saas:resync --feed variants
bin/magento saas:resync --feed categories
bin/magento saas:resync --feed categoryPermissions
當您執行這些命令時,會開始將目錄資料與SaaS服務進行初始同步。
監視同步處理進度
使用資料管理儀表板監視同步處理進度。 此儀表板提供您店面產品資料可用性的寶貴見解,確保可及時向客戶顯示。
您也可以使用Commerce CLI和資料匯出擴充功能記錄檔,執行同步處理命令並疑難排解同步處理程式。
未來的產品更新
初始同步後,增量產品更新最多可能需要15分鐘才能用於店面搜尋。 若要深入瞭解,請參閱索引檔案中的串流產品更新。
4.確認資料已匯出
若要檢查您的目錄資料是否已從Adobe Commerce匯出並與Live Search同步,您有幾個選擇:
-
在下清單格中尋找專案:
cde_products_feed
cde_product_attributes_feed
note note NOTE 如果您收到 table does not exist
錯誤,請尋找catalog_data_exporter_products
和catalog_data_exporter_product_attributes
表格中的專案。 這些資料表名稱用於4.2.1之前的Live Search版本。 -
搭配預設查詢使用GraphQL遊樂場 (如需詳細資訊,請參閱GraphQL參考資料)以驗證下列專案:
- 傳回的產品計數接近您對商店檢視的預期。
- 會傳回多面向。
如需其他說明,請參閱支援知識庫中的Live Search 目錄未同步。
5.設定資料
正確設定您的產品資料可確保為您的客戶帶來良好的搜尋結果。 您可以在此區段中啟用產品清單Widget並指派類別。
啟用產品清單Widget
安裝Live Search 4.0.0+時,預設會啟用產品清單Widget。 Widget啟用時,搜尋結果和類別瀏覽產品清單頁面會使用不同的UI元件。 此UI元件會直接呼叫目錄服務API,如此可加快回應時間。
如果您的Live Search版本早於4.0.0+,則必須手動啟用產品清單Widget。
-
從管理員,前往Stores > Settings>Configuration。
-
在 Live Search 下,選取Storefront Features。
-
將 Enable Product Listing Widgets 設為
Yes
。
當您變更此設定時,會出現訊息Page cache is invalidated
。 您需要清除Magento快取以儲存變更。
-
執行下列其中一項作業來存取快取管理頁面:
- 按一下工作區上方訊息中的 Cache Management 連結。
- 在 管理員 側邊欄上,移至System > Tools>Cache Management。
-
選取組態 Cache Type並按一下Flush Magento Cache。
排清快取後,立即變更店面。
指派類別
在Live Search中傳回的產品必須指派給類別。 例如,在Luma中,產品分為「男性」、「女性」和「齒輪」等類別。 也會為「Top」、「Bottoms」和「Watch」設定子類別。 這些類別指派可改善篩選時的精細度。
6.測試連線
現在,如果您的目錄資料在SaaS中,請進行測試以確保在以下情況下傳回產品資料:
- Search方塊正確傳回結果
- 類別瀏覽正確傳回結果
- Facet在搜尋結果頁面上可作為篩選使用
如果一切正常運作,Live Search已安裝、連線且隨時可使用。
如果在店面發生問題,請檢查var/log/system.log
檔案中的API通訊失敗或服務端發生錯誤。
若要允許Live Search通過防火牆,請新增commerce.adobe.io
至允許清單。
7.確認事件正在擷取資料
確保部署到您網站的店面事件可正常運作。 此檢查對Headless實施尤其重要。
8.為您的店面量身打造
您已安裝Live Search擴充功能、同步處理、驗證及設定您的資料。 下一步是確保Live Search Widget符合您商店的外觀與風格。
您可以視需要定義自訂CSS規則,以設定彈出視窗和PLP Widget的樣式。 請參閱樣式彈出視窗元素和產品清單頁面Widget。
如果您想要擴充Widget的功能,每個元件的原始碼都可在公用存放庫中取得。
在這種情況下,您可以根據自己的需求自訂JavaScript,然後在CDN上託管自訂程式碼。 此自訂指令碼會與Live Search服務通訊,並傳回正常的結果,讓您控制Widget的功能。
正在更新Live Search
更新Live Search之前,請檢查使用撰寫器安裝的Live Search版本。
composer show magento/module-live-search | grep version
若要更新Live Search,請從命令列執行下列動作:
composer update magento/live-search --with-dependencies
若要更新至主要版本,例如從3.1.1到4.0.0,請編輯專案的根Composer .json
檔案,如下所示:
-
如果您目前安裝的
magento/live-search
版本是3.1.1
或更低,而且您正在升級至版本4.0.0
或更新版本,請在升級之前執行下列命令:code language-bash bin/magento module:enable Magento_AdvancedSearch
如需目前所安裝
magento/live-search
版本的相關資訊,請執行以下命令:code language-bash composer show magento/live-search
-
開啟根
composer.json
檔案並搜尋magento/live-search
。 -
在
require
區段中,更新版本號碼,如下所示:code language-json "require": { ... "magento/live-search": "^4.0", ... }
-
儲存
composer.json
。 然後,從命令列執行下列動作:code language-bash composer update magento/live-search --with-dependencies
正在解除安裝Live Search
若要解除安裝Live Search,請參閱解除安裝模組。
Live Search個套件
Live Search擴充功能包含下列封裝:
module-live-search
module-live-search-adapter
module-live-search-storefront-popover
Live Search相依性
安裝Composer擴充功能的Live Search中繼套件包含下列模組相依性。
magento/module-saas-catalog
magento/module-saas-category
magento/module-saas-category-permissions
magento/module-saas-product-override
magento/module-saas-product-variant
magento/module-saas-price
magento/module-saas-scopes
magento/module-bundle-product-data-exporter
magento/module-catalog-inventory-data-exporter
magento/module-catalog-url-rewrite-data-exporter
magento/module-configurable-product-data-exporter
magento/module-parent-product-data-exporter
magento/module-gift-card-product-data-exporter
magento/module-bundle-product-override-data-exporter
data-services
services-id
進階概念
下列章節提供使用Live Search和Catalog Service時更進階的主題。
端點
Live Search透過https://catalog-service.adobe.io/graphql
的端點通訊。
由於Live Search沒有完整產品資料庫的存取權,Live Search GraphQL與Commerce核心GraphQL API沒有完整的同位檢查。
Adobe建議直接呼叫SaaS API,尤其是目錄服務端點。
- 略過Commerce資料庫/Graphql程式,獲得效能並降低處理器負載
- 利用Catalog Service同盟從單一端點呼叫Live Search、Catalog Service和Product Recommendations。
對於某些使用案例,最好是呼叫Catalog Service以取得產品詳細資料和類似案例。 如需詳細資訊,請參閱refineProduct。
如果您有自訂Headless實作,請檢視Live Search參考實作:
如果您未使用標準元件(例如搜尋轉接器、Luma Widget或AEM CIF Widget),預設將無法自動收集使用者互動資料。 Adobe Sensei會使用這項收集到的資料進行智慧型銷售與效能追蹤。 若要解決此問題,您需要開發自訂解決方案,以透過Headless方式實施此資料收集。
Live Search的最新版本已使用Catalog Service。
語言支援
Live Search Widget支援下列語言:
如果Widget偵測到Commerce管理語言設定符合支援的語言,則會預設為該語言。 否則,Widget會預設為英文。 在Admin中,語言設定是透過導覽至Stores> Settings >Configuration > General> Country Options來設定。
管理員也可以設定搜尋索引的語言,以協助確保更好的搜尋結果。
Widget程式碼存放庫
產品清單頁面Widget和Live Search欄位Widget的程式碼可從GitHub下載。
有權存取程式碼的開發人員可完全自訂其運作和外觀方式。 他們在自己的伺服器上代管程式碼,但仍使用Live Search服務。
Data Export擴充功能
啟用Live Search後,資料匯出擴充功能會在Commerce應用程式和Live Search之間同步Commerce資料。 此程式可確保店面上有最新的Commerce資料。 在Admin中,您可以使用「資料管理」控制面板檢查同步狀態。 您可以使用Commerce CLI和記錄檔來管理和疑難排解資料匯出程式。 如需詳細資訊,請參閱資料匯出指南。
Inventory management
Live Search在Commerce中支援Inventory management功能(先前稱為多Source詳細目錄,或MSI)。 若要啟用完整支援,您必須將相依性模組commerce-data-export
更新為102.2.0+版。
Live Search傳回布林值,指出產品是否可在Inventory management中使用,但不包含有關哪個來源有庫存的資訊。
價格索引器
Live Search客戶可以使用SaaS價格索引器,提供更快的價格變更更新和同步處理時間。
價格支援
Live Search Widget支援大部分(但不是所有)Adobe Commerce支援的價格型別。
目前支援基本價格。 不支援的進階價格為:
- 成本
- 最低廣告價格
檢視API Mesh,瞭解更複雜的價格計算。
價格格式支援Commerce執行個體中的地區設定設定: 商店 >設定> 設定 >一般> 一般 >本機選項>地區設定。
Headless店面支援
您可以選擇安裝module-data-services-graphql
模組,該模組會擴充應用程式的現有GraphQL涵蓋範圍,以包含店面行為資料收集所需的欄位。
composer require magento/module-data-services-graphql
此模組會將其他內容新增至GraphQL查詢:
dataServicesStorefrontInstanceContext
dataServicesMagentoExtensionContext
dataServicesStoreConfigurationContext
B2B支援
PWA支援
Live Search可與PWA Studio搭配使用,但使用者在其他Commerce實作中可能會看到細微的差異。 在Venia中,基本功能(例如搜尋和產品清單頁面)可正常運作,但Graphql的某些排列可能無法正常運作。 可能也會有效能差異。
- 目前Live Search的PWA實作需要比Live Search更長的處理時間才能傳回搜尋結果(使用原生Commerce店面)。
- PWA中的Live Search不支援事件處理。 因此,搜尋報告和智慧型銷售無法在PWA商店上運作。
- 使用PWA Studio時,GraphQL不支援直接篩選
description
、name
、short_description
,但這些欄位可透過較一般的篩選傳回。
若要搭配PWA Studio使用Live Search,整合經銷商也必須:
-
在
environmentId
物件中設定storeDetails
。code language-javascript const storeDetails: StoreDetailsProps = { environmentId: <Storefront_ID>, websiteCode: "base", storeCode: "main_website_store", storeViewCode: "default", searchUnitId: searchUnitId, config: { minQueryLength: 5, pageSize: 8, currencySymbol: "$", }, };
Cookie
Live Search會收集使用者互動資料以改進搜尋功能,並將此資訊儲存在瀏覽器Cookie中。 啟用Cookie限制時,此資料收集需要使用者同意。 Live Search和Product Recommendations共用相同的資料收集機制和Cookie處理。 如需Cookie限制和隱私權法規遵循的詳細資訊,請參閱處理Cookie限制。