View file | ||
---|---|---|
|
Hawksearch to Salesforce CC B2B
The goal of the project is to implement Hawksearch Search functionalities within Salesforce.The latest version of the package:
...
Hawksearch Search API and Indexing API will be consumed for building the Landing Pages, Search Bar functionalities, and products synchronizations between Salesforce and Hawksearch.
Technologies
Mostly Lightning Web Components are used for the visual part display and standard Apex classes for the business logic and communication to the API.
Setup
Salesforce B2B CC Setup:
If you are hosting the product images outside the org:
1. External Images Source base URL should be allowed:
Go to Experience Builder (When you are configuring your B2B CC store)
Settings -> Security
Set 'Security Level' -> 'Relaxed CSP: Permit Access to Inline Scripts and Allowed Host
Under Trusted Sites For Scripts add the base URL for your product images
Publish the changes
2. Custom Search Page Creation
...
:
Go to Experience Builder (Again when you are configuring your B2B CC store)
On the top bar on the left side click the gear where it says Home to open Pages List
On the bottom click '+ Next Page'
Follow the instructions and create a page with name 'HWSSearch'
From the same drop-down select the page and drag the custom "hwsSearchMainComponent"
Publish the changes
Now when searching in the HWS Search Component - you will get redirected to this custom page
Prerequisite setup if developing on a brand new Salesforce OrgOn Salesforce B2B setup without prior Hawksearch integration:
Create Named Credentials:
Go to Setup -> Named Credentials -> New Named Credential
Create the following Named Credential:
Label: HawksearchSearchAPI
Name: HawksearchSearchAPI
URL: {URL for Hawksearch Search API without /api..}
Identity Type: Named Principle
Authentication Protocol: Password Authentication
Username: 'username'
Password: {Hawksearch Search API Key}
Generate Authorization Header: False
Allow Merge Fields in HTTP Header: true
Allow Merge Fields in HTTP Body: true
4. Create Custom Metadata records:
5. Go to Setup -> Custom Metadata Type -> New Custom Metadata Type
6. Create a new Custom Metadata Type with Label 'Hawksearch Credential'
7. Click on the Custom Metadata Type created and add 3 new Custom Fields:DatabaseNo Number(18, 0) (Required)
EngineName Text(255) (Required)
TrackingKey Text(255) (Required)
BaseImageUrl URL (Required) - This is the base URL for product images
8. After adding the fields click 'Manage Hawksearch Credentials' and create a new record with the appropriate values
9. Add Static Resources:
10. Go to Setup -> Static Resources -> New
11. Click on new:Name: HawksearchResources
File: Choose a .zip with a static resource (there should be now base folder - directly /img /js etc.)
Cache-Control: Public
User permissions and adding the Customer Community Plus License:
There are a couple of steps that need to be taken in order for products to be properly viewed by the user.Create Account. The user that creates the Account should have a Role specified that has the proper permissions.
Create Contact. Use the created account for the contact you are about to create.
Go to the contact you created on the right dropdown arrow select 'Enable Customer User'
Select User License -> 'Customer Community Plus'. Profile => 'HWSBuyerUserProfile'
Now that we have set up the user we need to adjust some configurations in the B2B Commerce.
Go to Commerce -> Buyer Groups from the top dropdown
Create a new Buyer Group
In 'Related' Tab of the Buyer Group under Buyer Group Members assign the Account you created
Under Stores - assign your B2B Commerce Store
At this point the user will be able to login to the store but he won't be having access to view any of the products. We need to create now Commerce Entitlement Policy. The Entitlement Policies configure which products can be accessed by a specific Buyer Group.
In Commerce in the dropdown select 'Entitlement Policies'
Create new Entitlement Policy
Go to your newly created Entitlement Policy and click on 'Related Tab'
Add the Buyer Group you have just created under Buyer Groups and all the products that you want this buyer group to have access to under 'Products'