When using third-party tools to power search pages (and categories) it is critical that the product data they have in their system is as up to date as possible to prevent the display of stale data.
Searchspring provides a “Live Indexing API” which allows Miva to push up product changes in real time as they happen. That means Searchspring does not have to wait for the next interval of a bulk feed import to get the product changes. This is extremely helpful when new products are being added frequently, prices are being changed or inventory changes are causing products to go into or out of stock.
The Searchspring Live indexing API is intended to be used in conjunction with a nightly bulk product feed which can be done using Miva Product Data Fields & Feeds.
If you use data transformations on your Bulk Imported Data Feed, the Searchspring Live indexing API does not yet support data transformations and should not be used. Doing so will cause your product data in Searchspring to be inaccurate. Please reach out to Searchspring and confirm this before setting up Live Indexing.
In addition, Live Indexing requires a SeachSpring Enterprise plan to use. Please contact your SearchSpring account representative to gain access to this feature before proceeding with the setup.
To install the module, click the Settings header on the left side of the page, then click Modules and search for "Searchspring."
When installation is complete, click the User Interface header on the left side of the page, then click Global Settings. Next, click More and then click Searchspring Live Indexing and Pricing.
The module maintains its own queue of products that need to be updated in Searchspring. A product could need to be pushed back to Searchspring for any number of reasons including:
The only way to add/update/delete a product from the Searchspring Queue is via the template-level functions defined below.
The main benefit of queueing products is it allows Miva to group the request together and have greater control over the 2.5Mb data limit or a Max of 500 records.
Under the module settings, there is a button to force clear any products from the Searchspring queue. Its located under the More menu in the module's admin configuration screen.
Upon installation of the module, a new item is automatically created named “searchspringlive.” This item needs to be assigned to any page template you wish to use the following functions:
Flags: may be an empty string or "replace." If "replace" is specified, any existing entry with status "Q" for the product_id/feed_id combination of the same type, is replaced by the new one. Otherwise, any existing entries are retained and will be processed in the order in which they were queued.
For example, let’s say there were multiple updates to the same product with each update adding the product to the Searchspring queue. If you place a flag value of “replace,” only the latest record in the queue will be processed. If the flag parameter is empty, each record will be sent to Searchspring, processed in the order in which they were queued, creating duplicate data that Searchspring must consume.
product_id: The id of the product to add to the queue.
feed_id: The Searchspring feed_id. You must email firstname.lastname@example.org to get this value for your account.
data: This is a JSON object of the full product record to be updated. You cannot update partial records, for example, just sending the price. It must be the full data set for the product you wish to send to Searchspring. These fields could be different on a per customer basis as custom fields you send to Searchspring are unique to you.
When using the delete function to add a product to be deleted to the queue, the data value needs to be a JSON encoded array of product ids to delete from Searchspring. When using this function it is up to the caller to ensure the data is properly formatted. Whatever value you pass into for the data parameter will be wrapped in the records array:
A common place to utilize these template functions to add/update/delete products from Searchspring is in the Product Data Fields and Feeds module. It allows you to hook into the new Product Notification APIs and conditionally send the product to Searchspring if warranted.
The Searchspring queue is processed via a Scheduled Task. This scheduled task needs to be added after the module has been installed.
To set this up, click the Settings header on the left side of the page, then click Store Settings. Finally, click the Scheduled Tasks tab. Once there, click Create New Scheduled Task.
In the Operation dropdown, choose Searchspring Live Indexing and Pricing: Process Searchspring Live Update Queue.
Below is a diagram of the data flow with the Searchspring Live Integration
The timing of how often this scheduled task runs can be configured from this screen. However, in most cases, since you want the data updated in Searchspring as soon as possible after the update occurs, it will be better to leverage triggers to tell Miva to processes the queue.
See an example of how to leverage triggers with the Product Data Field & Feeds module here.
Just before the Scheduled Task is set to run, Miva will make a call to Searchspring to see if there is currently a Bulk Index in process. If yes, this means that Searchspring is currently processing a bulk data feed and the live indexing updates will wait until this process is complete. An informational message will be logged in Miva if the task is prevented from running.
The module provides a runtime JSON API function that is used on the website to get real-time, customer-level pricing and inventory levels for an array of products. This is useful when needing to update the pricing returned from the Searchspring API for specific customers.
Below are the XML provisioning tags available:
One of the primary ways to add a product to the Searchspring Queue to be sent to Searchspring's Live Indexing is to use the Product Data Fields and Feeds module. It allows you to use a page template to generate and store product data that can eventually be output on a feed. The benefit of this module is that as product data changes it regenerates the output immediately rather than in bulk with traditional feeds. The benefit is that very large product data feeds can output in seconds instead of hours.
Searchspring provides a bulk feed format using line delimited JSON. Using the product data Field and Feeds module, you can use a single data field page template to both generate the JSON for the bulk feed as well as add the product to the live indexing queue. Below is a simplified example, which would need to be modified to your specific data set to be valid.
Important: The structure of the JSON sent in the Live Indexing call must be indentical to that used in the Bulk Indexing Feed. This is why it is recommended the same code be used to generate both these data formats to ensure no data is lost.
The Searchspring Live Indexing Scheduled Task to process the feed can also be setup run in conjunction with a Product Data Field Scheduled task. For example, if you update prices for 10,000 products either via an API integration to your ERP, or just a simple CSV import, this will trigger the Product Change notification and add those 10,000 products to the Queue to be processed by the Product Data Fields and Feeds module.
However, these changes also need to be pushed to Searchspring. By default all 10,000 products would get added to and processed for Product Data Fields then a seperate task would process the Searchspring Queue. This means there could be a delay from when the change was made in Miva and when we tell Searchspring about it.
In the Scheduled Task for Product Data Field and Feeds, there are settings to limit how many records get processed and then hand over execution to the scheduled task for Searchspring to process its queue. In the example below, only 1,000 records will get processed, then the trigger on completion setting will start the Searchspring scheduled task pushing up those 1,000 records to Searchspring. This gives you control to fine tune how quickly the product changes get pushed to Searchspring.