Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
aa40112
MAGE-1002: algoliaBundle removed
mrahman3177 Sep 2, 2024
2910739
MAGE-1002 Update autocomplete template reference
cammonro Sep 3, 2024
367ed6b
MAGE-1002 Update analytics alias
cammonro Sep 4, 2024
c53b03f
Merge pull request #12 from algolia/feature/MAGE-1002-remove-algoliab…
cammonro Sep 4, 2024
5f6f666
MAGE-1015 Provide sample template engine mixin
cammonro Sep 4, 2024
48c47a0
Merge pull request #13 from algolia/feature/MAGE-1002-update-path-ali…
cammonro Sep 4, 2024
835059f
MAGE-1015 Provide sample instantsearch mixin to stuff mock bundle
cammonro Sep 6, 2024
fde9075
MAGE-1015 Add versioning / dependency
cammonro Sep 6, 2024
e6d4dc0
Merge pull request #14 from algolia/feature/MAGE-1015-bundle-stuffing
mrahman3177 Sep 9, 2024
9180cc5
MAGE-1061 Basic mixins for extension common and autocomplete libs
cammonro Sep 23, 2024
18443e5
MAGE-1014 bump version compatibility
cammonro Jan 22, 2025
402f3d3
MAGE-1014 add range slider sample hook
cammonro Jan 22, 2025
c6ef3a8
MAGE-1061 Change injected dependencies in sample hooks and clean up s…
cammonro Jan 24, 2025
f111d21
MAGE-1061 Add sample hooks and mixins
cammonro Jan 24, 2025
8e4d81a
MAGE-1061 Reorg and augment example code incl. autocomplete mixins
cammonro Jan 26, 2025
7cbe6c3
MAGE-1061 Add sample mixin for modifying runtime search parameters vi…
cammonro Jan 26, 2025
41e0803
MAGE-1061 Demonstrate specific version frontend library overrides
cammonro Jan 26, 2025
1ea3ab6
Merge branch 'feat/MAGE-1014-template-engine' into feature/MAGE-1061-…
cammonro Jan 26, 2025
cea8564
MAGE-1061 Merge beforeWidgetInitialization examples
cammonro Jan 26, 2025
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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"license": [
"MIT"
],
"version": "1.3.0",
"version": "1.4.0",
"require": {
"algolia/algoliasearch-magento-2": "^3.14.0",
"algolia/algoliasearch-magento-2": "^3.15.0",
"magento/magento-composer-installer": "*"
},
"extra": {
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Algolia_CustomAlgolia" setup_version="1.2.2">
<module name="Algolia_CustomAlgolia" setup_version="1.4.0">
<sequence>
<module name="Algolia_AlgoliaSearch"/>
<module name="Magento_Theme"/>
Expand Down
89 changes: 68 additions & 21 deletions view/frontend/requirejs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,33 @@
/**
* This starter file provides a means to override the Algolia search experience using RequireJS.
*
*
*
* You can customize Autocomplete in 2 ways:
* 1. Via a complete override of the underlying functional template
* 2. Via a JavaScript mixin (recommended)
* You can customize Algolia's JavaScript in one of 3 ways:
* 1. Via a complete override of the underlying dependency
* 2. Via a JavaScript mixin (recommended especially for templates)
* 3. Via front end custom events (hooks.js is included to demonstrate how to handle custom front end events)
*/

const config = {
map: {
"*": {
// Include your own hooks to handle front end events - see https://www.algolia.com/doc/integration/magento-2/customize/custom-front-end-events/
algoliaHooks: 'Algolia_CustomAlgolia/js/hooks',

// Additional lib for recent searches plugin - OPTIONAL
algoliaRecentSearches: 'Algolia_CustomAlgolia/js/internals/autocomplete-plugin-recent-searches'
// Add any dependencies you might need for your own customizations
// For instance, this lib supplies the "recent searches" plugin
// How this might be used is demonstrated in hooks.js using the `afterAutocompletePlugins` event
algoliaRecentSearchesPluginLib: 'Algolia_CustomAlgolia/js/lib/autocomplete-plugin-recent-searches',

////////////////////////////////////
// ALGOLIA FRONTEND LIB OVERRIDE //
////////////////////////////////////

// Uncomment to load your own specific version of InstantSearch e.g. 4.65.0
// algoliaInstantSearchLib: 'Algolia_CustomAlgolia/js/lib/algolia-instantsearch.local.min',

/**
* This can be done for other libraries as well such as Autocomplete, Recommend etc.
* Check the `lib` directory in the core module for versioned dependency source files
*/

////////////////////////////////////
// AUTOCOMPLETE TEMPLATE OVERRIDE //
Expand All @@ -30,21 +42,23 @@ const config = {
},
},

////////////////////////
// AUTOCOMPLETE MIXIN //
////////////////////////

/**
* You can add a mixin to customize only a single portion of a template based on the corresponding function.
* Use the `html` tagged template literal supplied via the function arguments to return your custom content as HTML.
*/

config: {
// Use mixins where possible to only override *specific functions* within the Algolia implementation
// This makes upgrades easier in the future since you will not have to merge all changes into your template overrides
mixins: {
//////////////////////////////////
// AUTOCOMPLETE TEMPLATE MIXINS //
//////////////////////////////////

/**
* You can add a mixin to customize only a single portion of a template based on the corresponding function.
* Use the `html` tagged template literal supplied via the function arguments to return your custom content as HTML.
*/

// Uncomment the following mixins to override the hit template via a JavaScript mixin for a given source
"Algolia_AlgoliaSearch/js/template/autocomplete/products": {
"Algolia_CustomAlgolia/js/template/autocomplete/products-mixin": true,
}
// "Algolia_AlgoliaSearch/js/template/autocomplete/products": {
// "Algolia_CustomAlgolia/js/template/autocomplete/products-mixin": true,
// },
// "Algolia_AlgoliaSearch/js/template/autocomplete/categories": {
// "Algolia_CustomAlgolia/js/template/autocomplete/categories-mixin": true,
// },
Expand All @@ -57,6 +71,39 @@ const config = {
// "Algolia_AlgoliaSearch/js/template/autocomplete/suggestions": {
// "Algolia_CustomAlgolia/js/template/autocomplete/suggestions-mixin": true,
// },

//////////////////////////////////
// OTHER AUTOCOMPLETE MIXINS //
//////////////////////////////////

// Uncomment the following mixin to see a demonstration of how you can modify the logic behind how Autocomplete functions
// "Algolia_AlgoliaSearch/js/autocomplete": {
// "Algolia_CustomAlgolia/js/autocomplete-mixin": true,
// },

//////////////////////////////////
// INSTANTSEARCH MIXINS //
//////////////////////////////////

// Uncomment the following mixin to see a demonstration of how you can modify the logic behind how InstantSearch functions
// Some examples include: Changing runtime behaviors and adding libraries to the algoliaBundle used in legacy front end hooks
// "Algolia_AlgoliaSearch/js/instantsearch": {
// "Algolia_CustomAlgolia/js/instantsearch-mixin": true,
// },

//////////////////////////////////
// INTERNAL LIB MIXINS //
//////////////////////////////////

// Uncomment the following mixin to change the template parsing engine from Mustache to Hogan
// "Algolia_AlgoliaSearch/js/internals/template-engine": {
// "Algolia_CustomAlgolia/js/internals/template-engine-mixin": true,
// },

// Uncomment the following mixin to change the behavior of common util functions
// "Algolia_AlgoliaSearch/js/internals/common": {
// "Algolia_CustomAlgolia/js/internals/common-mixin": true,
// },
},
},
}
};
30 changes: 30 additions & 0 deletions view/frontend/web/js/autocomplete-mixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SAMPLE AUTOCOMPLETE MIXIN
// These mixins demonstrate ways that you can override behaviors and configurations in the core Autocomplete implementation

define(['uiComponent'], function (Component) {
"use strict";

return function (target) {
const mixin = {
initialize: function () {
this._super();
console.log("The original debounce was:", target.prototype.DEBOUNCE_MS);
console.log("The updated debounce is:", this.DEBOUNCE_MS);

console.log("The original minimum characters before search was:", target.prototype.MIN_SEARCH_LENGTH_CHARS);
console.log("The updated minimum characters before search is:", this.MIN_SEARCH_LENGTH_CHARS);

},
// Set debounce to 600ms
DEBOUNCE_MS: 600,
// Set minimum number of characters before search to 5
MIN_SEARCH_LENGTH_CHARS: 5,

handleAutocompleteStateChange: function(state) {
console.log("In mixin to listen to changes to Autocomplete state:", state);
}
};

return target.extend(mixin);
};
});
Loading