Item Search Displays Incorrect Results
In some implementations of the Elbrus release of SuiteCommerce Advanced, the application returns incorrect results when entering more than one term in the search criteria.
The following patch corrects a problem in ItemsSearcher.View.js, which is part of the ItemsSearcher module. To implement this patch, create a custom module to change the defaultOptions.highlightFirst
property. You can download the code samples described in this procedure here: ElbrusItemSearchResultsIncorrect.zip.
Before proceeding, familiarize yourself with Best Practices for Customizing SCA.
Step 1: Extend ItemsSearcher.View.js
-
Create an extensions directory to store your custom module. Depending on your implementation, this directory might already exist.
-
Within this directory, create a custom module with a name similar to the module being customized.
For example:
Modules/extensions/ItemsSearcherExtension@1.0.0
. -
In your new ItemsSearcherExtension@1.0.0 module, create a subdirectory called
JavaScript
.For example:
Modules/extensions/ItemsSearcherExtension/JavaScript
-
In your new JavaScript subdirectory, create a JavaScript file.
Name this file according to best practices. For example:
ItemsSearcher.View.Extend.js
-
Open this file and extend ItemsSearcher.View.js to customize the
highlightFirst
property fromtrue
tofalse
, as shown in the following code snippet.define( 'ItemsSearcher.View.Extend' , [ 'ItemsSearcher.View' ] , function ( ItemsSearcherView ) { 'use strict'; ItemSearcherView.prototype.defaultOptions.highlightFirst = false });
-
Save the file.
Step 2: Prepare the Developer Tools For Your Customization
-
Open your new ItemsSearcherExtension@1.0.0 module directory.
-
Create a file in this directory and name it ns.package.json.
Modules/extensions/ItemsSearcherExtension@1.0.0/ns.package.json
-
Paste the following code into your new ns.package.json file:
{ "gulp": { "javascript": [ "JavaScript/*.js" ] } }
-
Open the distro.json file. This is located in your root directory.
-
Add your custom module to the
modules
object.Your code should look similar to the following example:
{ "name": "SuiteCommerce Advanced Elbrus", "version": "2.0", "buildToolsVersion": "1.3.0", "folders": { "modules": "Modules", "suitecommerceModules": "Modules/suitecommerce", "extensionsModules": "Modules/extensions", "thirdPartyModules": "Modules/third_parties", "distribution": "LocalDistribution", "deploy": "DeployDistribution" }, "modules": { "extensions/ItemsSearcherExtension": "1.0.0", "extensions/MyExampleCartExtension1": "1.0.0", //...
This ensures that the Gulp tasks include your module when you deploy. In this example, the custom modules are added at the beginning of the list of modules. However, you can add the modules anywhere in the
modules
object. The order of precedence in this list does not matter. -
Add
ItemsSearcher.View.Extend
as a dependency to SCA entry point within theSC.Shopping.Starter
entrypoint of the JavaScript array.Your distro.js file should look similar to the following:
"tasksConfig": { //... "javascript": [ //... { "entryPoint": "SC.Shopping.Starter", "exportFile": "shopping.js", "dependencies": [ //... "StoreLocator", "SC.CCT.Html", "ItemsSearcher.View.Extend" ], //...
-
Save the distro.json file.
Step 3: Test and Deploy Your Customization
-
Test your source code customizations on a local server (see Test SCA Customizations on a Local Server) or deploy them to your NetSuite account (see Deploy SCA Customizations to NetSuite). If you are currently running SCA on a local server, your changes should appear on your local site immediately.
-
Confirm your results.
Upon successful deployment, item search strings should display correct results.