Skip to content

Commit 0b003ba

Browse files
@W-20026654 Merge einstein suggested phrases in search feature into develop (#3422)
* @W-19677915 Use einstein suggested phrases in search (#3390) * skip changelog * skip changelog * skip changelog * Remove unnecessary translation files - Remove en-GB.json, en-US.json, en-XA.json from compiled translations - Remove en-GB.json, en-US.json from source translations - These are generated files that are not needed for Einstein suggestions functionality * Generate translation files for Einstein suggestions - Add compiled translation files (en-GB.json, en-US.json, en-XA.json) - Add source translation files (en-GB.json, en-US.json) - These files include translations for new Einstein suggestions features: - Popular Searches - Recent Searches - Generated using npm run build-translations * increase bundle size * Add changelog entry for Einstein suggestions feature * Updated changelog
1 parent 9765651 commit 0b003ba

File tree

9 files changed

+151
-3
lines changed

9 files changed

+151
-3
lines changed

packages/template-retail-react-app/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
## v8.2.0-dev (Sep 26, 2025)
2+
- Added Einstein suggestions support for popular and recent searches in search functionality. Users can now see personalized search suggestions based on Einstein AI recommendations. [#3422](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/3422)
23
- [Bugfix] Fix footer heading semantic consistency and alignment. Fix accessibility compliance by adding proper h1 headings to checkout pages to resolve the page-has-heading-one accessibility rule violation. [#3398](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/3398)
34
- [Bugfix] Use `serverSafeEncode` util for address mutations. [#3380](https://github.com/SalesforceCommerceCloud/pwa-kit/pull/3380)
45
- Added Hybrid Proxy support for local and ODS hybrid development [#3409] (https://github.com/SalesforceCommerceCloud/pwa-kit/pull/3409)

packages/template-retail-react-app/app/components/search/index.jsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,25 @@ const formatSuggestions = (searchSuggestions) => {
9898
}
9999
}
100100
),
101+
// Einstein suggestions for popular and recent searches
102+
popularSearchSuggestions:
103+
searchSuggestions?.einsteinSuggestedPhrases?.popularSearchPhrases?.map((phrase) => {
104+
return {
105+
type: 'popular',
106+
name: phrase.phrase,
107+
link: searchUrlBuilder(phrase.phrase),
108+
exactMatch: phrase.exactMatch
109+
}
110+
}),
111+
recentSearchSuggestions:
112+
searchSuggestions?.einsteinSuggestedPhrases?.recentSearchPhrases?.map((phrase) => {
113+
return {
114+
type: 'recent',
115+
name: phrase.phrase,
116+
link: searchUrlBuilder(phrase.phrase),
117+
exactMatch: phrase.exactMatch
118+
}
119+
}),
101120
searchPhrase: searchSuggestions?.searchPhrase
102121
}
103122
}
@@ -134,7 +153,8 @@ const Search = (props) => {
134153
{
135154
parameters: {
136155
q: searchQuery,
137-
expand: 'images,prices'
156+
expand: 'images,prices',
157+
includeEinsteinSuggestedPhrases: true
138158
}
139159
},
140160
{
@@ -160,7 +180,9 @@ const Search = (props) => {
160180
const searchSuggestionsAvailable =
161181
searchSuggestions &&
162182
(searchSuggestions?.categorySuggestions?.length ||
163-
searchSuggestions?.phraseSuggestions?.length)
183+
searchSuggestions?.phraseSuggestions?.length ||
184+
searchSuggestions?.popularSearchSuggestions?.length ||
185+
searchSuggestions?.recentSearchSuggestions?.length)
164186

165187
const saveRecentSearch = (searchText) => {
166188
// Get recent searches or an empty array if undefined.

packages/template-retail-react-app/app/components/search/partials/search-suggestions-section.jsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const SuggestionSection = ({searchSuggestions, closeAndNavigate, styles}) => {
1818
const hasCategories = searchSuggestions?.categorySuggestions?.length
1919
const hasProducts = searchSuggestions?.productSuggestions?.length
2020
const hasPhraseSuggestions = searchSuggestions?.phraseSuggestions?.length
21+
const hasPopularSearches = searchSuggestions?.popularSearchSuggestions?.length
22+
const hasRecentSearches = searchSuggestions?.recentSearchSuggestions?.length
2123

2224
return (
2325
<Fragment>
@@ -65,6 +67,34 @@ const SuggestionSection = ({searchSuggestions, closeAndNavigate, styles}) => {
6567
/>
6668
</Fragment>
6769
)}
70+
{hasPopularSearches && (
71+
<Fragment>
72+
<Box {...styles.sectionHeader}>
73+
<FormattedMessage
74+
defaultMessage="Popular Searches"
75+
id="search.suggestions.popular"
76+
/>
77+
</Box>
78+
<Suggestions
79+
closeAndNavigate={closeAndNavigate}
80+
suggestions={searchSuggestions?.popularSearchSuggestions}
81+
/>
82+
</Fragment>
83+
)}
84+
{hasRecentSearches && (
85+
<Fragment>
86+
<Box {...styles.sectionHeader}>
87+
<FormattedMessage
88+
defaultMessage="Recent Searches"
89+
id="search.suggestions.recent"
90+
/>
91+
</Box>
92+
<Suggestions
93+
closeAndNavigate={closeAndNavigate}
94+
suggestions={searchSuggestions?.recentSearchSuggestions}
95+
/>
96+
</Fragment>
97+
)}
6898
</HideOnDesktop>
6999
{/* Desktop - Vertical and Horizontal alignment */}
70100
<HideOnMobile>
@@ -100,6 +130,34 @@ const SuggestionSection = ({searchSuggestions, closeAndNavigate, styles}) => {
100130
/>
101131
</Fragment>
102132
)}
133+
{hasPopularSearches && (
134+
<Fragment>
135+
<Box {...styles.sectionHeader}>
136+
<FormattedMessage
137+
defaultMessage="Popular Searches"
138+
id="search.suggestions.popular"
139+
/>
140+
</Box>
141+
<Suggestions
142+
closeAndNavigate={closeAndNavigate}
143+
suggestions={searchSuggestions?.popularSearchSuggestions}
144+
/>
145+
</Fragment>
146+
)}
147+
{hasRecentSearches && (
148+
<Fragment>
149+
<Box {...styles.sectionHeader}>
150+
<FormattedMessage
151+
defaultMessage="Recent Searches"
152+
id="search.suggestions.recent"
153+
/>
154+
</Box>
155+
<Suggestions
156+
closeAndNavigate={closeAndNavigate}
157+
suggestions={searchSuggestions?.recentSearchSuggestions}
158+
/>
159+
</Fragment>
160+
)}
103161
</Box>
104162
<Box flex="3">
105163
{hasProducts && (

packages/template-retail-react-app/app/components/search/partials/search-suggestions.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ const SearchSuggestions = ({recentSearches, searchSuggestions, closeAndNavigate}
1515
const hasCategories = searchSuggestions?.categorySuggestions?.length
1616
const hasProducts = searchSuggestions?.productSuggestions?.length
1717
const hasBrands = searchSuggestions?.brandSuggestions?.length
18-
const hasSuggestions = hasCategories || hasProducts || hasBrands
18+
const hasPopularSearches = searchSuggestions?.popularSearchSuggestions?.length
19+
const hasRecentSearches = searchSuggestions?.recentSearchSuggestions?.length
20+
const hasSuggestions =
21+
hasCategories || hasProducts || hasBrands || hasPopularSearches || hasRecentSearches
1922

2023
return (
2124
<Stack {...styles.container}>

packages/template-retail-react-app/app/static/translations/compiled/en-GB.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3621,12 +3621,24 @@
36213621
"value": "Did you mean"
36223622
}
36233623
],
3624+
"search.suggestions.popular": [
3625+
{
3626+
"type": 0,
3627+
"value": "Popular Searches"
3628+
}
3629+
],
36243630
"search.suggestions.products": [
36253631
{
36263632
"type": 0,
36273633
"value": "Products"
36283634
}
36293635
],
3636+
"search.suggestions.recent": [
3637+
{
3638+
"type": 0,
3639+
"value": "Recent Searches"
3640+
}
3641+
],
36303642
"search.suggestions.viewAll": [
36313643
{
36323644
"type": 0,

packages/template-retail-react-app/app/static/translations/compiled/en-US.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3621,12 +3621,24 @@
36213621
"value": "Did you mean"
36223622
}
36233623
],
3624+
"search.suggestions.popular": [
3625+
{
3626+
"type": 0,
3627+
"value": "Popular Searches"
3628+
}
3629+
],
36243630
"search.suggestions.products": [
36253631
{
36263632
"type": 0,
36273633
"value": "Products"
36283634
}
36293635
],
3636+
"search.suggestions.recent": [
3637+
{
3638+
"type": 0,
3639+
"value": "Recent Searches"
3640+
}
3641+
],
36303642
"search.suggestions.viewAll": [
36313643
{
36323644
"type": 0,

packages/template-retail-react-app/app/static/translations/compiled/en-XA.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7621,6 +7621,20 @@
76217621
"value": "]"
76227622
}
76237623
],
7624+
"search.suggestions.popular": [
7625+
{
7626+
"type": 0,
7627+
"value": "["
7628+
},
7629+
{
7630+
"type": 0,
7631+
"value": "Ƥǿǿƥŭŭŀȧȧř Şḗḗȧȧřƈħḗḗş"
7632+
},
7633+
{
7634+
"type": 0,
7635+
"value": "]"
7636+
}
7637+
],
76247638
"search.suggestions.products": [
76257639
{
76267640
"type": 0,
@@ -7635,6 +7649,20 @@
76357649
"value": "]"
76367650
}
76377651
],
7652+
"search.suggestions.recent": [
7653+
{
7654+
"type": 0,
7655+
"value": "["
7656+
},
7657+
{
7658+
"type": 0,
7659+
"value": "Řḗḗƈḗḗƞŧ Şḗḗȧȧřƈħḗḗş"
7660+
},
7661+
{
7662+
"type": 0,
7663+
"value": "]"
7664+
}
7665+
],
76387666
"search.suggestions.viewAll": [
76397667
{
76407668
"type": 0,

packages/template-retail-react-app/translations/en-GB.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,9 +1514,15 @@
15141514
"search.suggestions.didYouMean": {
15151515
"defaultMessage": "Did you mean"
15161516
},
1517+
"search.suggestions.popular": {
1518+
"defaultMessage": "Popular Searches"
1519+
},
15171520
"search.suggestions.products": {
15181521
"defaultMessage": "Products"
15191522
},
1523+
"search.suggestions.recent": {
1524+
"defaultMessage": "Recent Searches"
1525+
},
15201526
"search.suggestions.viewAll": {
15211527
"defaultMessage": "View All"
15221528
},

packages/template-retail-react-app/translations/en-US.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,9 +1514,15 @@
15141514
"search.suggestions.didYouMean": {
15151515
"defaultMessage": "Did you mean"
15161516
},
1517+
"search.suggestions.popular": {
1518+
"defaultMessage": "Popular Searches"
1519+
},
15171520
"search.suggestions.products": {
15181521
"defaultMessage": "Products"
15191522
},
1523+
"search.suggestions.recent": {
1524+
"defaultMessage": "Recent Searches"
1525+
},
15201526
"search.suggestions.viewAll": {
15211527
"defaultMessage": "View All"
15221528
},

0 commit comments

Comments
 (0)