1requirejs([ 2 'algoliaBundle', 3 'mage/utils/wrapper', 4 'mage/translate' 5], function (algoliaBundle, wrapper, $t) { 6 algoliaBundle.$(function ($) { 7 var optionsListTemplate = algoliaBundle.Hogan.compile(algoliaBundle.$('#instant-product-options-template').html()), 8 instantConfig = window.algoliaConfig.instant; 9 10 window.transformHit = wrapper.wrap(transformHit, function (originalAction, hit, price_key, helper) { 11 var hit = originalAction(hit, price_key, helper), 12 productOptions = []; 13 if (instantConfig.isShowProductOptions && hit.config_attributes) { 14 var swatchesData = instantConfig.swatchesData; 15 hit.config_attributes.forEach(function (attribute) { 16 var swatches = swatchesData[attribute]; 17 if (Array.isArray(hit[attribute]) && swatches !== undefined) { 18 var data = { 19 attributeId: swatches.attribute_id, 20 attributeCode: swatches.attribute_code, 21 displayMode: swatches.display_mode, 22 options: [] 23 }; 24 25 data.options.push({ 26 optionId : 0, 27 value : $t('Choose an Option...') 28 }); 29 30 hit[attribute].forEach(function (option) { 31 var swatchOptionData = swatches.options[option]; 32 if (swatchOptionData !== undefined) { 33 data.options.push({ 34 optionId: swatchOptionData.option_id, 35 value: swatchOptionData.value 36 }); 37 } 38 }); 39 productOptions.push(data); 40 } 41 }); 42 } 43 44 hit._productOptionsList = optionsListTemplate.render({ 45 productOptions: productOptions 46 }); 47 48 return hit; 49 }); 50 }); 51})
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.