Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions cartridges/algolia_sg_changes/cartridge/static/default/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ function initializeEvents() {
e.preventDefault();
consentTracking.show();
});

// main menu toggle
$('.menu-toggle').on('click', function () {
$('#wrapper').toggleClass('menu-active');
Expand Down Expand Up @@ -1043,11 +1043,11 @@ var consentTracking = {
if (consent == null && SitePreferences.CONSENT_TRACKING_HINT) { // eslint-disable-line no-undef
getConsent();
}

if (consent != null && SitePreferences.CONSENT_TRACKING_HINT){ // eslint-disable-line no-undef
showPrivacyDialog();
}

},
show: function () {
getConsent();
Expand Down Expand Up @@ -1404,7 +1404,7 @@ var login = {
$('.oAuthIcon').on('click', function () {
$('#OAuthProvider').val(this.id);
});


//toggle the value of the rememberme checkbox
$('#dwfrm_login_rememberme').on('change', function () {
Expand All @@ -1414,7 +1414,7 @@ var login = {
$('#rememberme').val('false');
}
});

$('#password-reset').on('click', function (e) {
e.preventDefault();
dialog.open({
Expand Down Expand Up @@ -23268,7 +23268,7 @@ function denodeifyWithoutCount(fn) {
'args[argLength] = cb;',
'res = fn.apply(self, args);',
'}',

'if (res &&',
'(typeof res === "object" || typeof res === "function") &&',
'typeof res.then === "function"',
Expand Down
2 changes: 2 additions & 0 deletions cartridges/bm_algolia/cartridge/controllers/AlgoliaBM.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function handleSettings() {
var adminApikey = params.AdminApiKey.value || '';
var searchApikey = params.SearchApiKey.value || '';
var indexPrefix = params.IndexPrefix.value || '';
var algoliaAttributeSlicedRecordModel_GroupingAttribute = params.AttributeSlicedRecordModel_GroupingAttribute.value || '';

var adminValidation = {};

Expand Down Expand Up @@ -79,6 +80,7 @@ function handleSettings() {
algoliaData.setPreference('AdminApiKey', adminApikey);
algoliaData.setPreference('IndexPrefix', indexPrefix);
algoliaData.setPreference('RecordModel', params.RecordModel.value);
algoliaData.setPreference('AttributeSlicedRecordModel_GroupingAttribute', algoliaAttributeSlicedRecordModel_GroupingAttribute);
algoliaData.setSetOfStrings('LocalesForIndexing', params.LocalesForIndexing.value);
algoliaData.setPreference('EnableInsights', params.EnableInsights.submitted);
algoliaData.setPreference('EnableSSR', params.EnableSSR.submitted);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,11 @@ tr {
}
.customModule-card {
font-family: Helvetica Neue, sans-serif !important;
}
}
input[readonly] {
background-color: #eee;
color: #666;
cursor: not-allowed;
border: 1px solid rgb(118, 118, 118);
border-radius: 2px;
}
9 changes: 9 additions & 0 deletions cartridges/bm_algolia/cartridge/static/default/js/algolia.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/* globals jQuery */
/* @deprecated */

(function ($) {
$(document).ready(function () {
var $siteStatusRow = $('.site-status-row');
Expand Down Expand Up @@ -105,6 +106,14 @@
$dialogContainer.dialog('open');
});

// Disables the "Grouping attribute for the Attribute-sliced record model"
// text input unless "Record model" is "Attribute-sliced"
$('select#RecordModel').on('change', function() {
var isAttributeSlicedRecordModelSelected = $(this).val() === 'attribute-sliced';
$('input#AttributeSlicedRecordModel_GroupingAttribute').prop('readonly', !isAttributeSlicedRecordModelSelected);
}).trigger('change');

$resumeIndexingBtn.on('click', handleActionClick);

});
}(jQuery));
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
</tr>

<iscomment> Algolia_RecordModel </iscomment>
<isset name="recordModel" value="${pdict.algoliaData.getPreference('RecordModel')}" scope="page"/>
<tr>
<td class="table_detail w s" colspan="1">
<isprint value="${Resource.msg('algolia.label.preference.recordmodel', 'algolia', null)}" encoding="jshtml" />
Expand All @@ -166,18 +167,35 @@
</td>
<td class="table_detail w e s">
<select name="RecordModel" id="RecordModel">
<isif condition="${pdict.algoliaData.getPreference('RecordModel') === 'variant-level'}">
<option value="variant-level" selected="selected">Variation Product</option>
<option value="master-level">Base Product</option>
<iselse>
<option value="variant-level">Variation Product</option>
<option value="master-level" selected="selected">Base Product</option>
</iselse>
</isif>
<option value="variant-level"
<isif condition="${recordModel === 'variant-level'}"> selected="selected"</isif>>
<isprint value="${Resource.msg('algolia.preference.recordmodel.variantlevel', 'algolia', null)}"/>
</option>
<option value="master-level"
<isif condition="${recordModel === 'master-level'}"> selected="selected"</isif>>
<isprint value="${Resource.msg('algolia.preference.recordmodel.masterlevel', 'algolia', null)}"/>
</option>
<option value="attribute-sliced"
<isif condition="${recordModel === 'attribute-sliced'}"> selected="selected"</isif>>
<isprint value="${Resource.msg('algolia.preference.recordmodel.attributesliced', 'algolia', null)}"/>
</option>
</select>
</td>
</tr>

<iscomment> Algolia_AttributeSlicedRecordModel_GroupingAttribute </iscomment>
<tr>
<td class="table_detail w s" colspan="1">
<isprint value="${Resource.msg('algolia.label.preference.attributesliced.groupingattribute', 'algolia', null)}" />
<i class="fa fa-info-circle dw-nc-text-info info-hover"></i>
<div class="tooltip">${Resource.msg('algolia.label.preference.attributesliced.groupingattribute.help', 'algolia', null)}</div>
</td>

<td class="table_detail w e s">
<input type="text" value="${pdict.algoliaData.getPreference('AttributeSlicedRecordModel_GroupingAttribute') ? pdict.algoliaData.getPreference('AttributeSlicedRecordModel_GroupingAttribute') : ''}" id="AttributeSlicedRecordModel_GroupingAttribute" name="AttributeSlicedRecordModel_GroupingAttribute" placeholder="${Resource.msg('algolia.label.util.optional.onlyusedwithattributeslicedrecordmodel', 'algolia', null)}"/>
</td>
</tr>

<iscomment> Algolia_LocalesForIndexing </iscomment>
<tr>
<td class="table_detail w s" colspan="1">
Expand Down Expand Up @@ -432,6 +450,7 @@
document.getElementById("EnableContentSearch").disabled = !storefrontEnabled;
document.getElementById("EnableRecommend").disabled = !storefrontEnabled;
}

updateStorefrontCheckboxes();
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ algolia.label.algolia=Algolia
algolia.label.settings=Algolia settings page
algolia.label.dashboard=Algolia dashboard


# site preferences table
algolia.label.enable=Enable
algolia.label.preference.name=Preference Name
algolia.label.preference.enable=Enable Algolia frontend cartridge
algolia.label.preference.applicationid=Application ID
algolia.label.preference.searchkey=Search API key
algolia.label.preference.adminkey=Write API Key
algolia.label.preference.instock=InStock Threshold
algolia.label.preference.instock=In-Stock Threshold
algolia.label.preference.custom=Additional Product Attributes
algolia.label.preference.indexprefix=Index Prefix. If set, it replaces the default index prefix:
algolia.label.preference.indexprefix=Index Prefix. If set, it replaces the default index prefix
algolia.label.preference.recordmodel=Record model
algolia.label.preference.attributesliced.groupingattribute=Grouping attribute for the Attribute-sliced record model, e.g. color
algolia.label.preference.locales=Locales for indexing
algolia.label.preference.insights=insights events
algolia.label.preference.enablessr=Enable server-side rendering
Expand All @@ -27,6 +27,7 @@ algolia.label.preference.clientpassword=OCAPI Client password
algolia.label.button.apply=Apply
algolia.label.util.optional=(Optional)
algolia.label.util.optional.headless=(Optional for Headless)
algolia.label.util.optional.onlyusedwithattributeslicedrecordmodel=(Only used with the Attribute-sliced record model)
algolia.label.util.required=*
algolia.label.util.version=Cartridge Version:

Expand All @@ -38,7 +39,16 @@ algolia.label.preference.adminkey.help=The Write API Key is used to perform inde
algolia.label.preference.instock.help=The InStock Threshold is used to determine if a product is in stock or not. If the stock level is below the threshold, the product is considered out of stock. The default value is 0,0.
algolia.label.preference.custom.help=The Additional Product Attributes is a comma-separated list of product attributes that will be indexed in Algolia. The default value is empty.
algolia.label.preference.indexprefix.help=By default the index name generated by the system looks like this: <hostname>__<siteID>__<"product" | "category">__<locale>. Setting this preference replaces the first two segments, the final index name becoming '<Algolia_IndexPrefix>__<"product" | "category">__<locale>'.
algolia.label.preference.recordmodel.help='Variation Product': create one record per variation product. 'Base Product': create one record per base product, containing all variants in a 'variants' attribute.
algolia.label.preference.recordmodel.help='Variation product': create one record per variation / simple product. All attributes of all products are stored at the record's root level. \
'Base product': create one record per master. Properties common to all attributes are stored at root level, variant attributes are stored inside the 'variants' array. Simple products also have a 'variants' array for consistency. \
'Attribute-sliced': create one record per custom variation group (e.g. per color), containing the variants in that group. \
The product doesn't need to be an SFCC variation group; masters with multiple variation attributes are split by the given variation attribute, resulting in one record per variation attribute value. \
(e.g. one record for all sizes of color red, another one for all sizes of color blue), for each locale. \
Like with the Base product record type, all records (incl. simple products) have a 'variants' array for consistency and easy faceting.
algolia.label.preference.attributesliced.groupingattribute.help=Choose the variation attribute that base products with multiple variation attributes are grouped by when using the Attribute-sliced record model.\
Example: if a base product has four sizes and three colors (12 variants total) and the variation attribute to group by is "color", it will be split up into three records, one for each color value (red, green, blue), with each record having four size variants.\
This preference is only used with the "Attribute-sliced" record model.\
Note: the attribute needs to be a variation attribute (not just any attribute that multiple variations have), but an explicit SFCC variation group doesn't need to be defined in advance in order to use the grouping feature offered by this model.
algolia.label.preference.locales.help=Specify which locales to index in a comma-separated list, for all job types. Default is all locales assigned to your site if not specified.
algolia.label.preference.enableinsights.help=Send Algolia insights events from the Storefront: views, clicks, addToCart and purchases.
algolia.label.preference.enablessr.help=Server-side rendering for SFRA's CLP (category landing page) and search results pages. Improves SEO. Only triggered when the User-Agent advertise itself as a bot. May result in extra search requests.
Expand All @@ -48,6 +58,11 @@ algolia.label.preference.enablePricingLazyLoad.help=When enabled, prices are fet
algolia.label.preference.indexoutofstock.help=Index out of stock products. When disabled, only in-stock (ATS higher than the InStock Threshold) products are indexed.
algolia.label.preference.enableRealTimeInventoryHook.help=Sends inventory updates to Algolia in real-time after each order.

# Algolia_RecordModel options display names
algolia.preference.recordmodel.variantlevel=Variation product
algolia.preference.recordmodel.masterlevel=Base product
algolia.preference.recordmodel.attributesliced=Attribute-sliced

# v2 job report table
algolia.label.jobtype=job type:
algolia.label.start=start
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,33 +56,33 @@ function hasOnlineCategory(product) {
/**
* Product index filter function
* Note: if you want to check filter status for master products, you should use isOnline and isSearchable, hasOnlineCategory functions separately.
* @param {dw.catalog.Product} product - Product
* @param {dw.catalog.Product | dw.catalog.Variant} product - Product
* @returns {boolean} - True if product should be included in the index, false if not.
*/
function isInclude(product) {
// Do not include Master product
if (product.master || product.variationGroup) return false;
if (product.isMaster() || product.isVariationGroup()) return false;
// Do not include Option products
// if (product.optionProduct) return false;
// Do not include bundled product
if (product.bundled && !(product.priceModel && product.priceModel.price && product.priceModel.price.available)) return false;

// Check online status
if (!isOnline(product)) return false;

// Check searchable status
if (!isSearchable(product)) return false;

// Check if product has at least one online category
// Note: In SFCC, variant products don't have their own categories - getOnlineCategories() returns empty for variants
// We must check categories on the master product instead
if (product.variant && product.getMasterProduct) {
if (product.isVariant()) { // dw.catalog.Variant
var masterProduct = product.getMasterProduct();
if (masterProduct && !hasOnlineCategory(masterProduct)) return false;
} else {
if (!hasOnlineCategory(product)) return false;
}

return true;
}

Expand All @@ -99,7 +99,7 @@ function isInStock(product, threshold) {
}

// even if one variant is in stock, we consider the product as in stock
if (product.master || product.variationGroup) {
if (product.isMaster() || product.isVariationGroup()) {
const variantsIt = product.variants.iterator();
while (variantsIt.hasNext()) {
let variant = variantsIt.next();
Expand All @@ -121,6 +121,25 @@ function isInStock(product, threshold) {
return atsValue >= threshold;
}

/**
* Checks if at least one variant in a variation model is in stock.
* @param {dw.catalog.ProductVariationModel} variationModel
* @param {Number} threshold
* @returns {Boolean} whether at least one of the variants is in stock
*/
function isCustomVariationGroupInStock(variationModel, threshold) {
const variantsIt = variationModel.getSelectedVariants().iterator();
while (variantsIt.hasNext()) {
let variant = variantsIt.next();
let variantAtsValue = variant.getAvailabilityModel().getInventoryRecord().getATS().getValue();
if (variantAtsValue >= threshold) {
return true;
}
}

return false;
}

/**
* Checks store inventory for a given product and determines
* whether it meets the ATS threshold for being in stock.
Expand All @@ -146,6 +165,7 @@ function isInStoreStock(product, storeId, threshold) {

module.exports = {
isInStock: isInStock,
isCustomVariationGroupInStock: isCustomVariationGroupInStock,
isInclude: isInclude,
isInStoreStock: isInStoreStock,
isOnline: isOnline,
Expand Down
Loading
Loading