Admin Panel JS API

To manage the Searchanise settings, connect the JS widget that will upload and display the Searchanise (Smart Search & Filter) control panel.

An example of connecting the Searchanise control panel JS Widget

<div class="snize" id="snize_container"></div>
<script type="text/javascript">
    SearchaniseAdmin = {};
    SearchaniseAdmin.host = 'https://searchserverapi.com';
    SearchaniseAdmin.PrivateKey = 'XXXXXXXXXXXXXXXXXXXX';
    SearchaniseAdmin.ReSyncLink = 'https://example.com/admin/searchanise/start_resync';
    SearchaniseAdmin.LastRequest = '12.06.2018';
    SearchaniseAdmin.LastResync  = '12.06.2018';
    SearchaniseAdmin.ConnectLink = 'https://example.com/admin/searchanise/connect';
    SearchaniseAdmin.AddonStatus = 'enabled';
    SearchaniseAdmin.ShowResultsControlPanel = true;
    SearchaniseAdmin.Engines = [];
    SearchaniseAdmin.Engines.push({
        PrivateKey: 'XXXXXXXXXXXXXXXXXXXX',
        LangCode: 'EN',
        Name : 'English',
        ExportStatus: 'done',
        PriceFormat: {
            rate : 1.0,
            symbol: '$',
            decimals: 2,
            decimals_separator: '.',
            thousands_separator: ',',
            after: false
        }
    });
    SearchaniseAdmin.Engines.push({
        PrivateKey: 'YYYYYYYYYYYYYYYYYYYY',
        LangCode: 'ES',
        Name : 'Spanish',
        ExportStatus: 'done',
        PriceFormat: {
            rate : 1.0,
            symbol: '$',
            decimals: 2,
            decimals_separator: '.',
            thousands_separator: ',',
            after: false
        }
    });
</script>
<script type="text/javascript" src="https://searchserverapi.com/js/init.js"></script>

Connection parameters

Parameter Description Value type
PrivateKey Required parameter, parent private key (if the store is connected one search engine, the private key to this engine should be specified). string(private_key)
ReSyncLink URL within your store that will start full data re-synchronization. The code by this address should redirect the user back to the page with the Searchanise Admin Panel after starting re-synchronization. string(valid url)
ConnectLink URL within your store that starts registration string(valid url)
LastResync Line with formatted end time of the full re-synchronization string(datetime)
LastRequest Line with formatted time of the last request for data update string(datetime)
AddonStatus Status of the connector add-on string(enabled, disabled)
ShowResultsControlPanel Defines whether to show the search results widget settings or not bool(true, false) 
Engines Array with parameters of the search engine group. See the parameters below. array of engines

Parameters for Engines array

Parameter Description Value type
PrivateKey Required parameter, private key for engine string(private_key)
Name Line with the name for the engine that will be displayed in the admin panel. Most often it matches the language name. string
LangCode Two-symbol language code (not used anywhere yet) 2-char string
ExportStatus Status of the export process of products to the server none, queued, processing, sent, done, sync_error
PriceFormat Object with parameters of price displaying; used for showing prices based on location. See the parameters below. object

Parameters for PriceFormat object

Parameter Description Value type
rate Currency exchange rate float
symbol Currency symbol string
decimals Number of symbols after the comma int
decimals_separator Symbol used to separate the integer part from the fractional part  string
thousands_separator Thousands separator symbol string
after Defines whether to show the currency symbol before or after bool

HTTP and HTTPS addresses are supported.

If ConnectLink is specified instead of PrivateKey, the “Connect store to Searchanise” button will be displayed instead of the control panel. Clicking the button will redirect the user to the ConnectLink URL.

If AddonStatus = ”disabled”, the “Addon is disabled. Please enable it” line will be displayed instead of the control panel.

The <div class="snize" id="snize_container"></div> container for the control panel can be located on any line, but it is desirable that it has a sufficient size to display the entire admin content. 

Note

All parameters must be specified in the PriceFormat array.

Updated on February 16, 2023

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you

Let us improve this post!

Please tell us how we can improve this post

Related Articles

Back to top