Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cif livesearch widget (Reference only) #320

Draft
wants to merge 46 commits into
base: cif-livesearch-popover
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
e935b3c
update .content.xml
rkdmen Sep 8, 2023
8934b5e
Updated commerce/productlist, WIP
rkdmen Sep 8, 2023
3765384
clean up, will need to get category url/name
rkdmen Sep 11, 2023
5960cad
get categoryUrlPath categoryName from sly model
rkdmen Sep 14, 2023
bbe9527
added api_Key from data-service-gql
rkdmen Sep 20, 2023
c7ce447
add .content.xml for ca_dialog
rkdmen Sep 21, 2023
5511dc3
add <sly> model
rkdmen Sep 22, 2023
ea7b3cc
fix redirect/clean up
rkdmen Sep 27, 2023
d063b12
added ProductList.java
rkdmen Sep 27, 2023
9e5cf6f
remove `async`
rkdmen Sep 27, 2023
d86a65d
fix z-index
rkdmen Sep 27, 2023
e020cc2
add route func for plp
rkdmen Sep 28, 2023
45a7251
add `searchQuery` prop for plp-widget
rkdmen Oct 3, 2023
2a993a2
removed ProductList sling model
rkdmen Oct 3, 2023
52c6440
Fix js path
rkdmen Oct 4, 2023
c1a2c02
clean up
rkdmen Oct 5, 2023
9291f10
added console.log
rkdmen Oct 24, 2023
21973b2
init plp on setTimeout
rkdmen Oct 24, 2023
89bc1c8
update searchresults to use plp
rkdmen Oct 24, 2023
bd78bf0
update package.json, searchresult
rkdmen Oct 26, 2023
3621d0f
update searchresults resourceSuperType
rkdmen Oct 26, 2023
1392d0f
update resourceSuperType searchresults
rkdmen Oct 26, 2023
346de04
clean up
rkdmen Oct 26, 2023
6e2f2ca
add query for snowplow
rkdmen Oct 26, 2023
d86e87a
fix typo
rkdmen Oct 26, 2023
5acd187
clean up
rkdmen Oct 26, 2023
bc195e7
Merge branch 'cif-livesearch-popover' into cif-livesearch-widget
rkdmen Oct 26, 2023
e670add
lint fix
rkdmen Oct 26, 2023
4ce9e8d
fix store_view_currency_code
rkdmen Oct 27, 2023
23b3a5f
clean up
rkdmen Oct 27, 2023
d87916c
update to v2/productlist
rkdmen Oct 27, 2023
9e2580b
update to use prod popover/widget
rkdmen Oct 27, 2023
bbbdb83
revert to qa cdn
rkdmen Oct 27, 2023
c76f7c1
update to prod widget
rkdmen Oct 30, 2023
670edeb
Merge branch 'cif-livesearch-popover' into cif-livesearch-widget
rkdmen Nov 3, 2023
21e4e71
remove hardcode store config
rkdmen Nov 3, 2023
b0de0e5
clean up
rkdmen Nov 6, 2023
93cbea9
Merge branch 'cif-livesearch-popover' into cif-livesearch-widget
rkdmen Nov 13, 2023
bd997cb
Merge branch 'cif-livesearch-popover' into cif-livesearch-widget
rkdmen Nov 14, 2023
6de1ee7
update dataServicesSessionContext with min_query_length
rkdmen Nov 14, 2023
0b55355
testing on qa, will revert to prod
rkdmen Nov 17, 2023
6f5cbaa
Revert "testing on qa, will revert to prod"
rkdmen Nov 17, 2023
3cf9924
clean up
rkdmen Dec 11, 2023
dfe4070
chore: update cif core components
buuhuu Dec 12, 2023
da5fab6
fix: increase socket timeout
buuhuu Dec 12, 2023
6b4f81e
removed SDK
rkdmen Dec 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"maxHttpConnections": 20,
"connectionTimeout": 5000,
"requestPoolTimeout": 2000,
"socketTimeout": 5000,
"socketTimeout": 15000,
"cacheConfigurations": [
"venia/components/commerce/navigation:true:5:300",
"com.adobe.cq.commerce.core.search.services.SearchFilterService:true:10:300",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"maxHttpConnections": 20,
"connectionTimeout": 5000,
"requestPoolTimeout": 2000,
"socketTimeout": 5000,
"socketTimeout": 15000,
"cacheConfigurations": [
"venia/components/commerce/navigation:true:5:300",
"com.adobe.cq.commerce.core.search.services.SearchFilterService:true:10:300",
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<vault.user>admin</vault.user>
<vault.password>admin</vault.password>
<core.wcm.components.version>2.18.6</core.wcm.components.version>
<core.cif.components.version>2.12.0</core.cif.components.version>
<core.cif.components.version>2.12.4</core.cif.components.version>
<graphql.client.version>1.7.10</graphql.client.version>
<magento.graphql.version>9.1.0-magento242ee</magento.graphql.version>
<bnd.version>5.1.2</bnd.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:ClientLibraryFolder"
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:ClientLibraryFolder"
allowProxy="{Boolean}true"
cssProcessor="[default:none,min:none]"
jsProcessor="[default:none,min:none]"
categories="[venia.cif]"
embed="[core.cif.components.common,core.cif.components.product.v3,core.cif.components.productcarousel.v1,core.cif.components.productcollection.v2,core.cif.components.productteaser.v1,core.cif.components.searchbar.v2,core.cif.components.header.v1,core.cif.components.carousel.v1,core.cif.components.categorycarousel.v1,core.cif.components.featuredcategorylist.v1,core.cif.components.storefront-events.v1,core.cif.components.extensions.product-recs.storefront-events-collector.v1,core.wcm.components.commons.site.link]" />
categories="[venia.cif]"
embed="[core.cif.components.common,core.cif.components.product.v3,core.cif.components.productcarousel.v1,core.cif.components.productcollection.v2,core.cif.components.productteaser.v1,core.cif.components.searchbar.v2,core.cif.components.header.v1,core.cif.components.carousel.v1,core.cif.components.categorycarousel.v1,core.cif.components.featuredcategorylist.v1,core.cif.components.storefront-events.v1,core.cif.components.extensions.product-recs.storefront-events-collector.v1,core.wcm.components.commons.site.link,core.cif.productlist.v1]" />
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:description="Product List Component"
jcr:primaryType="cq:Component"
jcr:title="Product List"
sling:resourceSuperType="core/cif/components/commerce/productlist/v2/productlist"
componentGroup="Venia - Commerce"/>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:description="Product List Component" jcr:primaryType="cq:Component" jcr:title="Product List" componentGroup="Venia - Commerce" sling:resourceSuperType="core/cif/components/commerce/productlist/v2/productlist" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:ClientLibraryFolder"
allowProxy="{Boolean}true"
categories="[core.cif.productlist.v1]"
jsProcessor="[default:none,min:none]"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#base=css

productlist.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* #search-plp-root */

html {
font-size: 62.5% !important;
}

body {
font-size: 1.6rem;
}

.root.container {
max-width: inherit;
}

.container {
margin-left: auto;
margin-right: auto;
}

div.ds-sdk-sort-dropdown {
z-index: 9;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
js/productlist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2023 Adobe
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
"use strict";

class ProductList {
constructor() {
const stateObject = {
categoryName: null,
currentCategoryUrlPath: null,
};
this._state = stateObject;
this._init();
}

_init() {
this._initWidgetPLP();
}

_injectStoreScript(src) {
const script = document.createElement("script");
script.type = "text/javascript";
script.src = src;

document.head.appendChild(script);
}

async _getStoreData() {
// get from session storage
const sessionData = sessionStorage.getItem(
"WIDGET_STOREFRONT_INSTANCE_CONTEXT"
);
// WIDGET_STOREFRONT_INSTANCE_CONTEXT is set from searchbar/clientlibs/js/searchbar.js
// if not, we will need to retrieve from graphql separately here.

if (sessionData) {
this._state.dataServicesSessionContext = JSON.parse(sessionData);
return;
}
}

getStoreConfigMetadata() {
const storeConfig = JSON.parse(
document
.querySelector("meta[name='store-config']")
.getAttribute("content")
);

const { storeRootUrl } = storeConfig;
const redirectUrl = storeRootUrl.split(".html")[0];
return { storeConfig, redirectUrl };
}

async _initWidgetPLP() {
if (!window.LiveSearchPLP) {
const liveSearchPlpSrc =
"https://plp-widgets-ui.magento-ds.com/v1/search.js";
this._injectStoreScript(liveSearchPlpSrc);
// wait until script is loaded
await new Promise((resolve) => {
const interval = setInterval(() => {
if (window.LiveSearchPLP && window.LiveSearchAutocomplete) {
// Widget expects LiveSearchAutocomplete already loaded to rely on data-service-graphql
clearInterval(interval);
resolve();
}
}, 200);
});
}
await this._getStoreData();
const { dataServicesSessionContext } = this._state;
if (!dataServicesSessionContext) {
console.log("no dataServicesSessionContext");
return;
}

const root = document.getElementById("search-plp-root");
if (!root) {
console.log("plp root not found.");
return;
}
// get dataset from root
const categoryUrlPath = root.getAttribute("data-plp-urlPath") || "";
const categoryName = root.getAttribute("data-plp-title") || "";
const storeDetails = {
environmentId: dataServicesSessionContext.environment_id,
environmentType: dataServicesSessionContext.environment,
apiKey: dataServicesSessionContext.api_key,
websiteCode: dataServicesSessionContext.website_code,
storeCode: dataServicesSessionContext.store_code,
storeViewCode: dataServicesSessionContext.store_view_code,
config: {
pageSize: dataServicesSessionContext.page_size,
perPageConfig: {
pageSizeOptions: dataServicesSessionContext.page_size_options,
defaultPageSizeOption:
dataServicesSessionContext.default_page_size_option,
},
minQueryLength: dataServicesSessionContext.min_query_length,
currencySymbol: dataServicesSessionContext.currency_symbol,
currencyRate: dataServicesSessionContext.currency_rate,
displayOutOfStock: dataServicesSessionContext.display_out_of_stock,
allowAllProducts: dataServicesSessionContext.allow_all_products,
locale: dataServicesSessionContext.locale,
currentCategoryUrlPath: categoryUrlPath,
categoryName,
displayMode: "", // "" for plp || "PAGE" for category/catalog
},
context: {
customerGroup: dataServicesSessionContext.customer_group,
},
route: ({ sku }) => {
return `${
this.getStoreConfigMetadata().redirectUrl
}.cifproductredirect.html/${sku}`;
},
searchQuery: "search_query",
};

setTimeout(() => {
window.LiveSearchPLP({ storeDetails, root });
console.log("LiveSearchPLP loaded");
}, 0);
}
}

(function () {
function onDocumentReady() {
new ProductList({});
}

if (document.readyState !== "loading") {
onDocumentReady();
} else {
document.addEventListener("DOMContentLoaded", onDocumentReady);
}
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div
data-sly-use.productList="com.adobe.cq.commerce.core.components.models.productlist.ProductList"
id="search-plp-root"
class="productlist__root"
data-plp-urlPath="${productList.storefrontContext.urlPath}"
data-plp-title="${productList.title}"
></div>
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ class SearchBar {
console.log("no dataServicesStorefrontInstanceContext");
return;
}

// initialize live-search
new window.LiveSearchAutocomplete({
environmentId: dataServicesStorefrontInstanceContext.environment_id,
Expand Down Expand Up @@ -245,6 +244,7 @@ class SearchBar {
query: "search_query",
},
});
console.log("LiveSearch loaded");

const formEle = document.getElementById("search_mini_form");

Expand Down Expand Up @@ -291,7 +291,7 @@ class SearchBar {
website_name,
} = dataServicesStorefrontInstanceContext;

console.log("initializing magento extension");
console.log("magento extension loaded");
mse.context.setMagentoExtension({
magentoExtensionVersion: this._state.magentoExtensionVersion,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
jcr:description="Search Result Component"
jcr:primaryType="cq:Component"
jcr:title="Search Results"
sling:resourceSuperType="core/cif/components/commerce/searchresults/v2/searchresults"
sling:resourceSuperType="venia/components/commerce/productlist"
componentGroup="Venia - Commerce"/>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:Page">
<jcr:content
cq:allowedTemplates="[/conf/venia/settings/wcm/templates/page-content]"
Expand All @@ -10,16 +10,16 @@
jcr:title="Venia Demo Store - Search Results"
sling:resourceType="venia/components/page"
hideInNav="true">
<root jcr:primaryType="nt:unstructured"
sling:resourceType="venia/components/container"
<root jcr:primaryType="nt:unstructured"
sling:resourceType="venia/components/container"
layout="responsiveGrid">
<container jcr:primaryType="nt:unstructured"
<container jcr:primaryType="nt:unstructured"
sling:resourceType="venia/components/container">
<container jcr:primaryType="nt:unstructured"
sling:resourceType="venia/components/container"
<container jcr:primaryType="nt:unstructured"
sling:resourceType="venia/components/container"
layout="responsiveGrid">
<searchresults jcr:primaryType="nt:unstructured"
sling:resourceType="venia/components/commerce/searchresults"
<searchresults jcr:primaryType="nt:unstructured"
sling:resourceType="venia/components/commerce/productlist"
defaultSortField="relevance"
defaultSortOrder="desc"/>
</container>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:Page">
<jcr:content
cq:allowedTemplates="[/conf/venia/settings/wcm/templates/page-content]"
cq:template="/conf/venia/settings/wcm/templates/page-content"
cq:robotsTags="[noindex]"
jcr:primaryType="cq:PageContent"
jcr:mixinTypes="[cq:LiveRelationship]"
jcr:mixinTypes="[cq:LiveRelationship]"
jcr:title="Venia Demo Store - Search Results"
sling:resourceType="venia/components/page"
sling:resourceType="venia/components/page"
hideInNav="true">
<root jcr:primaryType="nt:unstructured"
jcr:mixinTypes="[cq:LiveRelationship]"
sling:resourceType="venia/components/container"
sling:resourceType="venia/components/container"
layout="responsiveGrid">
<container jcr:primaryType="nt:unstructured"
jcr:mixinTypes="[cq:LiveRelationship]"
sling:resourceType="venia/components/container">
<container jcr:primaryType="nt:unstructured"
jcr:mixinTypes="[cq:LiveRelationship]"
sling:resourceType="venia/components/container"
sling:resourceType="venia/components/container"
layout="responsiveGrid">
<searchresults jcr:primaryType="nt:unstructured"
jcr:mixinTypes="[cq:LiveRelationship]"
sling:resourceType="venia/components/commerce/searchresults"
sling:resourceType="venia/components/commerce/productlist"
defaultSortField="relevance"
defaultSortOrder="desc"/>
</container>
Expand Down
Loading