-
Notifications
You must be signed in to change notification settings - Fork 34
/
dev-template.html
152 lines (136 loc) · 4.66 KB
/
dev-template.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<head>
<title>Live Search PLP</title>
<!-- reset css -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"
integrity="sha512-NmLkDIU1C/C88wi324HBc+S2kLhi08PN5GDeUVVVC/BVt/9Izdsc9SVeVfA1UZbY3sHUlDSyRXhCzHfr6hmPPw=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<script
type="text/javascript"
src="https://unpkg.com/@adobe/magento-storefront-events-sdk@qa/dist/index.js"
></script>
<script
type="text/javascript"
src="https://unpkg.com/@adobe/magento-storefront-event-collector@qa/dist/index.js"
></script>
</head>
<body>
<div class="search-plp-root"></div>
<style>
body {
margin: 0 auto;
max-width: 1280px;
padding-left: 20px;
padding-right: 20px;
font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-style: normal;
font-weight: 400;
}
.ds-widgets {
--color-primary: black;
}
.ds-sdk-product-item__product-name {
text-transform: uppercase;
}
</style>
<script type="text/javascript" src="search.js"></script>
<script type="text/javascript">
const root = document.querySelector('div.search-plp-root');
const storeDetails = {
environmentId: '',
websiteCode: '',
storeCode: '',
storeViewCode: '',
config: {
minQueryLength: '2',
pageSize: 8,
perPageConfig: {
pageSizeOptions: '12,24,36',
defaultPageSizeOption: '24',
},
currencySymbol: '$',
currencyRate: '1',
displaySearchBox: true, // display search box
displayOutOfStock: true,
allowAllProducts: false,
// currentCategoryUrlPath?: '', // current category url path
// categoryName: '', // name of category to display
// displaySearchBox: false, // display search box
// displayOutOfStock: '', // "1" will return from php escapeJs and boolean is returned if called from data-service-graphql
// displayMode: '', // "" for search || "PAGE" for category search
// locale: '', //add locale for translations
// priceSlider: false, //enable slider for price - EXPERIMENTAL, default is false
// imageCarousel: false, //enable multiple image carousel - EXPERIMENTAL, default is false
// listview: false; //add listview as an option - EXPERIMENTAL, default is false
// optimizeImages: true, // optimize images with Fastly
// imageBaseWidth: 200,
// resolveCartId?: resolveCartId, // Luma specific addToCart method. Enabled with the extension
// refreshCart?: refreshCart, // Luma specific addToCart method. Enabled with the extension
// addToCart?: (sku, options, quantity)=>{} // custom add to cart callback function. Called on addToCart action
},
context: {
customerGroup: '',
},
apiKey: '',
environmentType: '',
// searchQuery: 'search_query', // Optional: providing searchQuery will override 'q' query param
// route: ({ sku, urlKey }) => {
// const storeConfig = JSON.parse(
// document
// .querySelector("meta[name='store-config']")
// .getAttribute('content')
// );
// const { storeRootUrl } = storeConfig;
// const redirectUrl = storeRootUrl.split('.html')[0];
// return `${redirectUrl}/${sku}`;
// },
// Will result to `http://localhost:8081/v1/MT11`
};
const mse = window.magentoStorefrontEvents;
mse.context.setMagentoExtension({
magentoExtensionVersion: '1.0.0',
});
mse.context.setSearchExtension({
version: '2.0.3',
});
mse.context.setShopper({ shopperId: 'logged-in' });
mse.context.setPage({
pageType: 'plp',
maxXOffset: 0,
maxYOffset: 0,
minXOffset: 0,
minYOffset: 0,
ping_interval: 5,
pings: 1,
});
mse.context.setStorefrontInstance({
environmentId: '',
instanceId: 'bbbbbb',
environment: 'ccccccc',
storeUrl: '',
websiteId: 123456,
websiteCode: '',
storeId: 123456,
storeCode: '',
storeViewId: 123456,
storeViewCode: '',
websiteName: '',
storeName: '',
storeViewName: '',
baseCurrencyCode: 'USD',
storeViewCurrencyCode: 'USD',
catalogExtensionVersion: '1.0.0',
});
setTimeout(async () => {
while (typeof window.LiveSearchPLP !== 'function') {
console.log('waiting for window.LiveSearchPLP to be available');
await new Promise((resolve) => setTimeout(resolve, 500));
}
window.LiveSearchPLP({ storeDetails, root });
}, 1000);
</script>
</body>