@nuskin/ns-shop 7.1.0-brw-988.1 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -4
- package/src/cart/cart.js +12 -1
- package/src/cart/cartService.js +35 -5
- package/src/cart/csProductHelper.js +274 -0
- package/src/cart/equinoxCartService.js +25 -14
- package/src/cart/productService.js +54 -46
- package/src/order/orderAdapter.js +17 -7
- package/src/payment/externalPaymentService.js +7 -1
- package/src/product/SolrQueryService.js +181 -218
- package/src/product/productSearchService.js +1 -8
- package/src/salesEventService.js +60 -72
- package/src/shipping/pickupUtil.js +96 -2
- package/src/product/productSearchAPIQueryService.js +0 -389
|
@@ -5,6 +5,7 @@ import {RunConfigService, events, util, PersonalOfferStorageService, BrowserDete
|
|
|
5
5
|
import {getCachedConfigField} from '@nuskin/configuration-sdk';
|
|
6
6
|
import {UserService} from "@nuskin/ns-account";
|
|
7
7
|
import PaymentAdapter from '../payment/PaymentAdapter';
|
|
8
|
+
import pickupUtil from '../shipping/pickupUtil';
|
|
8
9
|
|
|
9
10
|
let splitLineItems = [];
|
|
10
11
|
|
|
@@ -600,6 +601,7 @@ const syncProductItems = async (order, sapProducts, adr, includeSapItems) => {
|
|
|
600
601
|
newItem.priceType = ShopContextService.getPriceType(isAdrItem);
|
|
601
602
|
newItem.pv = sapItem.PSV;
|
|
602
603
|
newItem.backOrderDate = sapItem.BackorderAvailableDate;
|
|
604
|
+
newItem.eventName = sapItem.LineItem.Event;
|
|
603
605
|
|
|
604
606
|
if (sapItem.LineItem.Custom) {
|
|
605
607
|
let code = null, name = null, label = null;
|
|
@@ -634,7 +636,7 @@ const syncProductItems = async (order, sapProducts, adr, includeSapItems) => {
|
|
|
634
636
|
newItem.isBusinessPortfolio = matchedItem.isBusinessPortfolio;
|
|
635
637
|
newItem.redeem = matchedItem.redeem;
|
|
636
638
|
newItem.qtyRedeemWithPoints = matchedItem.qtyRedeemWithPoints;
|
|
637
|
-
newItem.eventName = matchedItem.eventName;
|
|
639
|
+
newItem.eventName = !newItem.eventName ? matchedItem.eventName : newItem.eventName;
|
|
638
640
|
}
|
|
639
641
|
if (existingItem) {
|
|
640
642
|
newItem.thumbnail = existingItem.thumbnail;
|
|
@@ -864,13 +866,14 @@ let setSelectedShipMethod = function(order, matchMethod = {}) {
|
|
|
864
866
|
|
|
865
867
|
/**
|
|
866
868
|
* Parses pickup points from SAP response, in case shipping method is set to pickup points!
|
|
867
|
-
* @param {Object[]}
|
|
869
|
+
* @param {Object[]} oldPup The Custom array on the salesorderrequest
|
|
870
|
+
* @param {Object[]} newPup The Custom array on the salesorderrequest
|
|
868
871
|
* @param {Object} order
|
|
869
872
|
*/
|
|
870
|
-
function setPickupPoints(
|
|
871
|
-
const pupLocations =
|
|
873
|
+
function setPickupPoints(oldPup, newPup, order) {
|
|
874
|
+
const pupLocations = oldPup || [];
|
|
872
875
|
if (order.selectedShippingMethod && PickupUtil.supports(order.selectedShippingMethod.Code)) {
|
|
873
|
-
order.pickupPoints = PickupUtil.parse(pupLocations);
|
|
876
|
+
order.pickupPoints = newPup ? newPup : PickupUtil.parse(pupLocations);
|
|
874
877
|
if (order.selectedPickupPoint) {
|
|
875
878
|
order.selectedPickupPoint = order.pickupPoints.find(pickupPoint => order.selectedPickupPoint.id === pickupPoint.id);
|
|
876
879
|
}
|
|
@@ -1089,13 +1092,19 @@ const toOrder = async (salesOrderDetail, adr, createResponse) => {
|
|
|
1089
1092
|
}
|
|
1090
1093
|
|
|
1091
1094
|
if (salesOrderDetail.ShippingAvailableMethods && salesOrderDetail.ShippingAvailableMethods.length > 0) {
|
|
1092
|
-
|
|
1095
|
+
const useShipMethodsApi = getCachedConfigField('useShipMethodsApi');
|
|
1096
|
+
const shipMethods = useShipMethodsApi ? await pickupUtil.getShipMethods() : salesOrderDetail.ShippingAvailableMethods;
|
|
1097
|
+
order.shippingAvailableMethods = sortShippingAvailableMethods(shipMethods);
|
|
1093
1098
|
setShippingAvailableMethodsPickupInfo(order.shippingAvailableMethods);
|
|
1094
1099
|
setSelectedShipMethod(order, salesOrderDetail.Shipping.ShippingMethod);
|
|
1095
1100
|
// When an order or ADR is created. The response from the create call is missing the list of pickup locations
|
|
1096
1101
|
// The list isn't needed in this case since the user has already created the order so we don't need to update the pickup points
|
|
1097
1102
|
if (!createResponse) {
|
|
1098
|
-
|
|
1103
|
+
let oldPup = null;
|
|
1104
|
+
if (!useShipMethodsApi) oldPup = salesOrderDetail.Custom;
|
|
1105
|
+
let newPup = null;
|
|
1106
|
+
if (useShipMethodsApi) newPup = await pickupUtil.getPickupPoints();
|
|
1107
|
+
setPickupPoints(oldPup, newPup, order);
|
|
1099
1108
|
}
|
|
1100
1109
|
}
|
|
1101
1110
|
shippingHack(order, salesOrderDetail.OrderTotals.Shipping, salesOrderDetail.Currency);
|
|
@@ -1107,6 +1116,7 @@ const toOrder = async (salesOrderDetail, adr, createResponse) => {
|
|
|
1107
1116
|
await syncProductItems(order, salesOrderDetail.LineItemDetails, order.adr ? adr : null);
|
|
1108
1117
|
syncOrderTotals(salesOrderDetail.OrderTotals, order.orderTotals);
|
|
1109
1118
|
syncPayment(salesOrderDetail.Payment, order.selectedPayment);
|
|
1119
|
+
OrderManager.saveOrders();
|
|
1110
1120
|
return order;
|
|
1111
1121
|
};
|
|
1112
1122
|
|
|
@@ -142,15 +142,21 @@ const getAdrOverrideId = () => {
|
|
|
142
142
|
const _doNewExternalPaymentProcess = (order) => {
|
|
143
143
|
// We only redirect if there is a redirect Url.
|
|
144
144
|
if (order.redirectUrl) {
|
|
145
|
+
const redirectUrl = new URL(order.redirectUrl);
|
|
145
146
|
// The landing page should be the checkout page.
|
|
146
147
|
const protocol = window.location.href.split('://')[0];
|
|
147
148
|
const domain = UrlService.extractDomain();
|
|
148
149
|
const path = encodeURIComponent(CartService.getCheckoutPage({route: 'orderSummary'}));
|
|
149
150
|
|
|
151
|
+
// If we are on mynuskin.com we want to keep external payment on mynuskin.com. For developing localhost we don't want to stay on localhost
|
|
152
|
+
if (!domain.includes('localhost')) {
|
|
153
|
+
redirectUrl.hostname = window.location.hostname;
|
|
154
|
+
}
|
|
155
|
+
|
|
150
156
|
// Append the landing page URL
|
|
151
157
|
// Example of order.redirectUrl: "redirectUrl":
|
|
152
158
|
// "https://test.nuskin.com/external-payment/api/v1/redirect?orderId=NS002761827&verify=null&ofsOrderId=0149707745"
|
|
153
|
-
window.location = `${
|
|
159
|
+
window.location = `${redirectUrl.toString()}&landingUrl=${protocol}://${domain}${path}`;
|
|
154
160
|
}
|
|
155
161
|
};
|
|
156
162
|
|
|
@@ -4,8 +4,7 @@ import {ProductResultsEnum} from "./productResultsEnum.js";
|
|
|
4
4
|
import OrderType from "./orderType.js";
|
|
5
5
|
import {SolrProductAdaptor} from "./solrProductAdaptor.js";
|
|
6
6
|
import {SolrQueryUrlService} from "./solrQueryUrlService.js";
|
|
7
|
-
import {getCachedConfigField
|
|
8
|
-
import {productSearchAPI} from "./productSearchAPIQueryService.js"
|
|
7
|
+
import {getCachedConfigField} from '@nuskin/configuration-sdk';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
*
|
|
@@ -437,136 +436,119 @@ let SolrQueryService = function() {
|
|
|
437
436
|
productResultType, searchTerm, productSearchFields, language, market, searchByOrderType ? rows*5 : rows, start
|
|
438
437
|
);
|
|
439
438
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
439
|
+
// Search for language nodes for the given market that match the search term.
|
|
440
|
+
let queryResponsePromise = $.ajax({
|
|
441
|
+
url: solrUrl,
|
|
442
|
+
type: "GET",
|
|
443
|
+
contentType: 'application/json; charset=utf-8',
|
|
444
|
+
headers: {
|
|
445
|
+
"client_id": getCachedConfigField('solrClientId'),
|
|
446
|
+
"client_secret": getCachedConfigField('solrClientSecret')
|
|
447
|
+
},
|
|
448
|
+
timeout: SolrTimeout,
|
|
449
|
+
success: function () {
|
|
450
|
+
//console.log("Search success!");
|
|
451
|
+
},
|
|
452
|
+
error: function (xmlHttpRequest, textStatus) {
|
|
453
|
+
deferred.reject(textStatus);
|
|
454
|
+
//console.log('Search failed!');
|
|
455
|
+
}
|
|
456
|
+
});
|
|
452
457
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
let
|
|
456
|
-
url: solrUrl,
|
|
457
|
-
type: "GET",
|
|
458
|
-
contentType: 'application/json; charset=utf-8',
|
|
459
|
-
headers: {
|
|
460
|
-
"client_id": getCachedConfigField('solrClientId'),
|
|
461
|
-
"client_secret": getCachedConfigField('solrClientSecret')
|
|
462
|
-
},
|
|
463
|
-
timeout: SolrTimeout,
|
|
464
|
-
success: function () {
|
|
465
|
-
//console.log("Search success!");
|
|
466
|
-
},
|
|
467
|
-
error: function (xmlHttpRequest, textStatus) {
|
|
468
|
-
deferred.reject(textStatus);
|
|
469
|
-
//console.log('Search failed!');
|
|
470
|
-
}
|
|
471
|
-
});
|
|
458
|
+
queryResponsePromise.then(function(responseData) {
|
|
459
|
+
let retValue;
|
|
460
|
+
let docs, totalNumFound/*, responseHeader*/;
|
|
472
461
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
462
|
+
if (typeof(responseData) === "string") {
|
|
463
|
+
docs = $.parseJSON(responseData).response.docs;
|
|
464
|
+
totalNumFound = $.parseJSON(responseData).response.numFound;
|
|
465
|
+
// responseHeader = $.parseJSON(responseData).responseHeader;
|
|
466
|
+
} else {
|
|
467
|
+
docs = responseData.response.docs;
|
|
468
|
+
totalNumFound = responseData.response.numFound;
|
|
469
|
+
// responseHeader = responseData.responseHeader;
|
|
470
|
+
}
|
|
476
471
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
472
|
+
if (searchByOrderType) {
|
|
473
|
+
solrUrl = SolrQueryUrlService.getProductsByRoots(docs, language, market, rows, 0, orderTypes);
|
|
474
|
+
let _orderTypes = orderTypes;
|
|
475
|
+
if (solrUrl.url) {
|
|
476
|
+
let productDocuments = [];
|
|
477
|
+
queryResponsePromise = $.ajax({
|
|
478
|
+
url: solrUrl.url,
|
|
479
|
+
type: "POST",
|
|
480
|
+
contentType: 'application/json; charset=utf-8',
|
|
481
|
+
headers: {
|
|
482
|
+
"client_id": getCachedConfigField('solrClientId'),
|
|
483
|
+
"client_secret":getCachedConfigField('solrClientSecret')
|
|
484
|
+
},
|
|
485
|
+
timeout: SolrTimeout,
|
|
486
|
+
data: JSON.stringify(solrUrl.postData),
|
|
487
|
+
success: function (responseData) {
|
|
488
|
+
if (typeof(responseData) === "string") {
|
|
489
|
+
docs = $.parseJSON(responseData).response.docs;
|
|
490
|
+
totalNumFound = $.parseJSON(responseData).response.numFound;
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
docs = responseData.response.docs;
|
|
494
|
+
totalNumFound = responseData.response.numFound;
|
|
495
|
+
}
|
|
486
496
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
type: "POST",
|
|
495
|
-
contentType: 'application/json; charset=utf-8',
|
|
496
|
-
headers: {
|
|
497
|
-
"client_id": getCachedConfigField('solrClientId'),
|
|
498
|
-
"client_secret":getCachedConfigField('solrClientSecret')
|
|
499
|
-
},
|
|
500
|
-
timeout: SolrTimeout,
|
|
501
|
-
data: JSON.stringify(solrUrl.postData),
|
|
502
|
-
success: function (responseData) {
|
|
503
|
-
if (typeof(responseData) === "string") {
|
|
504
|
-
docs = $.parseJSON(responseData).response.docs;
|
|
505
|
-
totalNumFound = $.parseJSON(responseData).response.numFound;
|
|
506
|
-
}
|
|
507
|
-
else {
|
|
508
|
-
docs = responseData.response.docs;
|
|
509
|
-
totalNumFound = responseData.response.numFound;
|
|
510
|
-
}
|
|
497
|
+
// Wrap the products in an adaptor for ease of use.
|
|
498
|
+
for (let i = 0; i < docs.length; i++) {
|
|
499
|
+
//ONLY RETURN PRODUCTS THAT HAVE A MARKET
|
|
500
|
+
if (docs[i]._childDocuments_) {
|
|
501
|
+
for (let m = 0; m < docs[i]._childDocuments_.length; m++) {
|
|
502
|
+
if ((docs[i]._childDocuments_[m].path_exact === "product/" + docs[i].sku + '/' + market.toUpperCase()) &&
|
|
503
|
+
!docs[i]._childDocuments_[m].excludeFromSearch) {
|
|
511
504
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
if (existsInArray(marketChild.getOrderType(), _orderTypes)) {
|
|
525
|
-
productDocuments.push({
|
|
526
|
-
sku: docs[i].sku,
|
|
527
|
-
fullImage: marketChild.getFullImageUrl(),
|
|
528
|
-
name: languageChild.getTitle(),
|
|
529
|
-
_root_: "product/" + docs[i].sku,
|
|
530
|
-
isExclusive: languageChild.getIsExclusive()
|
|
531
|
-
});
|
|
532
|
-
}
|
|
505
|
+
if (!skuExistsInProductArray(productDocuments, docs[i].sku.toString())) {
|
|
506
|
+
let prodAdaptor = new SolrProductAdaptor(docs[i]);
|
|
507
|
+
let marketChild = prodAdaptor.getMarketChild(market);
|
|
508
|
+
let languageChild = prodAdaptor.getLanguageChild(language);
|
|
509
|
+
if (existsInArray(marketChild.getOrderType(), _orderTypes)) {
|
|
510
|
+
productDocuments.push({
|
|
511
|
+
sku: docs[i].sku,
|
|
512
|
+
fullImage: marketChild.getFullImageUrl(),
|
|
513
|
+
name: languageChild.getTitle(),
|
|
514
|
+
_root_: "product/" + docs[i].sku,
|
|
515
|
+
isExclusive: languageChild.getIsExclusive()
|
|
516
|
+
});
|
|
533
517
|
}
|
|
534
518
|
}
|
|
535
519
|
}
|
|
536
520
|
}
|
|
537
521
|
}
|
|
522
|
+
}
|
|
538
523
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
524
|
+
let retValue = {
|
|
525
|
+
products: productDocuments,
|
|
526
|
+
totalNumFound: totalNumFound
|
|
527
|
+
};
|
|
543
528
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
} else {
|
|
552
|
-
retValue = {
|
|
553
|
-
products: docs,
|
|
554
|
-
totalNumFound: totalNumFound
|
|
555
|
-
};
|
|
556
|
-
deferred.resolve(retValue);
|
|
557
|
-
}
|
|
529
|
+
deferred.resolve(retValue);
|
|
530
|
+
},
|
|
531
|
+
error: function (xmlHttpRequest, textStatus) {
|
|
532
|
+
deferred.reject(textStatus);
|
|
533
|
+
//console.log('Search failed!');
|
|
534
|
+
}
|
|
535
|
+
});
|
|
558
536
|
} else {
|
|
559
537
|
retValue = {
|
|
560
538
|
products: docs,
|
|
561
539
|
totalNumFound: totalNumFound
|
|
562
540
|
};
|
|
563
|
-
|
|
564
541
|
deferred.resolve(retValue);
|
|
565
542
|
}
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
543
|
+
} else {
|
|
544
|
+
retValue = {
|
|
545
|
+
products: docs,
|
|
546
|
+
totalNumFound: totalNumFound
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
deferred.resolve(retValue);
|
|
550
|
+
}
|
|
551
|
+
});
|
|
570
552
|
|
|
571
553
|
return deferred;
|
|
572
554
|
}
|
|
@@ -591,132 +573,113 @@ let SolrQueryService = function() {
|
|
|
591
573
|
productResultType, searchTerm, productSearchFields, language, market, rows, start
|
|
592
574
|
);
|
|
593
575
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
} else {
|
|
607
|
-
|
|
608
|
-
// Search for language nodes for the given market that match the search term.
|
|
609
|
-
let queryResponsePromise = $.ajax({
|
|
610
|
-
url: solrUrl,
|
|
611
|
-
type: "GET",
|
|
612
|
-
contentType: 'application/json; charset=utf-8',
|
|
613
|
-
headers: {
|
|
614
|
-
"client_id": getCachedConfigField('solrClientId'),
|
|
615
|
-
"client_secret": getCachedConfigField('solrClientSecret')
|
|
616
|
-
},
|
|
617
|
-
timeout: SolrTimeout,
|
|
618
|
-
success: function () {
|
|
576
|
+
// Search for language nodes for the given market that match the search term.
|
|
577
|
+
let queryResponsePromise = $.ajax({
|
|
578
|
+
url: solrUrl,
|
|
579
|
+
type: "GET",
|
|
580
|
+
contentType: 'application/json; charset=utf-8',
|
|
581
|
+
headers: {
|
|
582
|
+
"client_id": getCachedConfigField('solrClientId'),
|
|
583
|
+
"client_secret": getCachedConfigField('solrClientSecret')
|
|
584
|
+
},
|
|
585
|
+
timeout: SolrTimeout,
|
|
586
|
+
success: function () {
|
|
619
587
|
//console.log("Search success!");
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
588
|
+
},
|
|
589
|
+
error: function (xmlHttpRequest, textStatus) {
|
|
590
|
+
deferred.reject(textStatus);
|
|
623
591
|
//console.log('Search failed!');
|
|
624
|
-
|
|
625
|
-
|
|
592
|
+
}
|
|
593
|
+
});
|
|
626
594
|
|
|
627
|
-
|
|
628
|
-
|
|
595
|
+
queryResponsePromise.then(function(responseData){
|
|
596
|
+
let matchingRootProducts, totalNumFound, responseHeader;
|
|
629
597
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
598
|
+
if (typeof(responseData) === "string") {
|
|
599
|
+
matchingRootProducts = $.parseJSON(responseData).response.docs;
|
|
600
|
+
totalNumFound = $.parseJSON(responseData).response.numFound;
|
|
601
|
+
responseHeader = $.parseJSON(responseData).responseHeader;
|
|
602
|
+
} else {
|
|
603
|
+
matchingRootProducts = responseData.response.docs;
|
|
604
|
+
totalNumFound = responseData.response.numFound;
|
|
605
|
+
responseHeader = responseData.responseHeader;
|
|
606
|
+
}
|
|
639
607
|
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
608
|
+
// If the zkConnected header is true, we count on the data returned from the query being accurate.
|
|
609
|
+
// If it's false, we will re-try the Solr query so that we are sure we have the most up-to-date information
|
|
610
|
+
// (We only try again once, which is what sets the retrySolrRequest variable)
|
|
611
|
+
if (responseHeader.zkConnected || !retrySolrRequest) {
|
|
644
612
|
// eslint-disable-next-line
|
|
645
613
|
// Example solrUrl: http://dev-gateway-mulesoft-21:8080/mec/solr/oak/select?fl=*,[child%20parentFilter=path_exact:product/????????%20childFilter=path_exact:product/????????/en],[child%20parentFilter=path_exact:product/????????%20childFilter=path_exact:product/????????/US]&q=path_exact:product/01003611&rows=5&wt=json
|
|
646
614
|
// Always start at 0 so we get all the rows we are asking for.
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
615
|
+
solrUrl = SolrQueryUrlService.getProductsByRoots(matchingRootProducts, language, market, rows, 0, orderTypes);
|
|
616
|
+
|
|
617
|
+
if (solrUrl.url) {
|
|
618
|
+
let productDocuments = [];
|
|
619
|
+
|
|
620
|
+
// Return the complete records for the given matches
|
|
621
|
+
queryResponsePromise = $.ajax({
|
|
622
|
+
url: solrUrl.url,
|
|
623
|
+
type: "POST",
|
|
624
|
+
contentType: 'application/json; charset=utf-8',
|
|
625
|
+
headers: {
|
|
626
|
+
"client_id": getCachedConfigField('solrClientId'),
|
|
627
|
+
"client_secret": getCachedConfigField('solrClientSecret')
|
|
628
|
+
},
|
|
629
|
+
data: JSON.stringify(solrUrl.postData),
|
|
630
|
+
timeout: SolrTimeout,
|
|
631
|
+
success: function (responseData) {
|
|
632
|
+
let docs;
|
|
633
|
+
|
|
634
|
+
if (typeof(responseData) === "string") {
|
|
635
|
+
docs = $.parseJSON(responseData).response.docs;
|
|
636
|
+
}
|
|
637
|
+
else {
|
|
638
|
+
docs = responseData.response.docs;
|
|
639
|
+
}
|
|
672
640
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
641
|
+
for (let i = 0; i < matchingRootProducts.length; i++) {
|
|
642
|
+
matchingRootProducts[i].path_exact = matchingRootProducts[i]._root_[0];
|
|
643
|
+
}
|
|
676
644
|
|
|
677
|
-
|
|
678
|
-
|
|
645
|
+
// Wrap the products in an adaptor for ease of use.
|
|
646
|
+
for (let i = 0; i < docs.length; i++) {
|
|
679
647
|
//ONLY RETURN PRODUCTS THAT HAVE A MARKET
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
648
|
+
if (docs[i]._childDocuments_) {
|
|
649
|
+
for (let m = 0; m < docs[i]._childDocuments_.length; m++) {
|
|
650
|
+
if ((docs[i]._childDocuments_[m].path_exact === "product/" + docs[i].sku + '/' + market.toUpperCase()) &&
|
|
683
651
|
!docs[i]._childDocuments_[m].excludeFromSearch) {
|
|
684
652
|
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
}
|
|
653
|
+
if (!skuExistsInSolrProductAdaptorArray(productDocuments, docs[i].sku.toString())) {
|
|
654
|
+
const match = matchingRootProducts.find(root => root.path_exact === docs[i].path_exact) || null;
|
|
655
|
+
const score = match ? match.score : 0;
|
|
656
|
+
productDocuments.push(new SolrProductAdaptor(docs[i], score));
|
|
690
657
|
}
|
|
691
658
|
}
|
|
692
659
|
}
|
|
693
660
|
}
|
|
661
|
+
}
|
|
694
662
|
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
663
|
+
let retValue = {
|
|
664
|
+
products: productDocuments,
|
|
665
|
+
totalNumFound: totalNumFound
|
|
666
|
+
};
|
|
699
667
|
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
668
|
+
deferred.resolve(retValue);
|
|
669
|
+
},
|
|
670
|
+
error: function (xmlHttpRequest, textStatus) {
|
|
671
|
+
deferred.reject(textStatus);
|
|
704
672
|
//console.log('Search failed!');
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
}
|
|
708
|
-
else {
|
|
709
|
-
deferred.resolve(undefined);
|
|
710
|
-
}
|
|
711
|
-
} else {
|
|
712
|
-
getProductsBySearchFields(productResultType, searchTerm, productSearchFields, language, market, rows, start, orderTypes, deferred)
|
|
673
|
+
}
|
|
674
|
+
});
|
|
713
675
|
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
676
|
+
else {
|
|
677
|
+
deferred.resolve(undefined);
|
|
678
|
+
}
|
|
679
|
+
} else {
|
|
680
|
+
getProductsBySearchFields(productResultType, searchTerm, productSearchFields, language, market, rows, start, orderTypes, deferred)
|
|
681
|
+
}
|
|
682
|
+
});
|
|
720
683
|
|
|
721
684
|
return deferred;
|
|
722
685
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {ProductSearchFieldsEnum, ProductSortOrderEnum, ProductSortTypeEnum} from "./productSearchFieldsEnum.js";
|
|
2
2
|
import {ProductResultsEnum} from "./productResultsEnum.js";
|
|
3
3
|
import {util, BrowserDetection, UrlService} from '@nuskin/ns-util';
|
|
4
|
-
import {getCachedConfigField
|
|
4
|
+
import {getCachedConfigField} from "@nuskin/configuration-sdk";
|
|
5
5
|
import {AccountManager} from '@nuskin/ns-account';
|
|
6
6
|
import SolrQueryService from "./SolrQueryService.js";
|
|
7
7
|
import SynonymService from "./synonymService";
|
|
@@ -600,8 +600,6 @@ let productSearchService = function() {
|
|
|
600
600
|
const createProductFromBasicProduct = function(basicProduct) {
|
|
601
601
|
let siteUrl = UrlService.getSiteUrl();
|
|
602
602
|
let productData = {};
|
|
603
|
-
const {active, MySite_search_API_Base_URLs} = getCachedConfiguration('Equinox_Markets');
|
|
604
|
-
|
|
605
603
|
if (basicProduct.sku) {
|
|
606
604
|
if (typeof(basicProduct.sku) === 'object') {
|
|
607
605
|
productData.sku = basicProduct.sku[0];
|
|
@@ -610,11 +608,6 @@ let productSearchService = function() {
|
|
|
610
608
|
}
|
|
611
609
|
// eslint-disable-next-line
|
|
612
610
|
productData.thumbnail = siteUrl + "/content/products/" + productData.sku.substring(0,2) +"/" + productData.sku.substring(2,4) + "/" + productData.sku.substring(4,6) +"/" + productData.sku +"/_jcr_content/fullImage.img.160.160.png"
|
|
613
|
-
|
|
614
|
-
//use equinox image when using product-search-api and market is active
|
|
615
|
-
if(MySite_search_API_Base_URLs !== '' && active) {
|
|
616
|
-
productData.thumbnail = basicProduct.fullImage
|
|
617
|
-
}
|
|
618
611
|
}
|
|
619
612
|
if (basicProduct.name) {
|
|
620
613
|
if (typeof(basicProduct.name) === 'object') {
|