mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 15:36:58 +00:00
Merge pull request #4 from agility/product-search-patch
Updated product search url
This commit is contained in:
commit
649c78938f
@ -251,6 +251,31 @@ var ChooseProductCustomField = function () {
|
||||
|
||||
$pnl = $(".product-picker-field", options.$elem);
|
||||
|
||||
var websiteName = ContentManager.ViewModels.Navigation.currentWebsite()
|
||||
var searchAPIUrl = ""
|
||||
ContentManager.DashboardDataAccess.GetAllDigitalChannelsWithDomains(websiteName,
|
||||
function (channels) {
|
||||
|
||||
for (var channel in channels) {
|
||||
|
||||
var channelObj = channels[channel]
|
||||
for (var i = 0; i < channelObj.length; i++) {
|
||||
var domain = channelObj[i]
|
||||
if (domain.IsPreviewDomain) {
|
||||
//calculate the url to search for products by using the preview url...
|
||||
var searchUrl = domain.DomainUrl
|
||||
if (searchUrl.lastIndexOf("/") == searchUrl.length - 1) {
|
||||
searchUrl = searchUrl.substring(0, searchUrl.length - 1)
|
||||
}
|
||||
|
||||
searchAPIUrl = searchUrl + "/api/search-products"
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//bind our viewmodel to this
|
||||
var viewModel = function () {
|
||||
@ -265,7 +290,7 @@ var ChooseProductCustomField = function () {
|
||||
/// </param>
|
||||
var self = this;
|
||||
|
||||
ContentManager.DataAccess.GetPreviewUrl()
|
||||
|
||||
|
||||
self.ajaxRequest = null;
|
||||
|
||||
@ -285,6 +310,7 @@ var ChooseProductCustomField = function () {
|
||||
};
|
||||
self.ajaxRequest = null;
|
||||
|
||||
|
||||
self.select2 = {
|
||||
label: 'Product',
|
||||
readOnly: false,
|
||||
@ -307,8 +333,7 @@ var ChooseProductCustomField = function () {
|
||||
},
|
||||
|
||||
ajax: { // instead of writing the function to execute the request we use Select2's convenient helper
|
||||
url: "https://nextjs-commerce-agility-cms.vercel.app/api/search-products",
|
||||
//url: "http://localhost:3000/api/search-products",
|
||||
url: searchAPIUrl,
|
||||
dataType: 'json',
|
||||
type: "get",
|
||||
quietMillis: 250,
|
||||
@ -388,6 +413,7 @@ var ChooseProductCustomField = function () {
|
||||
}
|
||||
|
||||
ko.applyBindings(viewModel, $pnl.get(0));
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user