We’re happy to announce a new feature that gives more power and flexibility to your store! 

Specifically we improved Marketcloud's product search capabilities in two ways:

  • We added a new parameter "category" on GET /products requests. This allows you to filter products by a category, showing not only products belonging to that category but also to sub-categories.
  • Improved "search by text" query, now supporting partial word matching.
  • Improved multi-language search


Let's see these two improvements in more detail by providing some examples.


​Search by category

Before this new feature, to look for products belonging to a particular category, you had to do something like this:

// Supposing we have a category 'Smartphones' and that its Id is 123: 

client.products.list({
  category_id : 123
})
.then( (response) => {
  var categories = response.data;
  console.log(categories);
}) 
.catch((error) => {
  console.log("An error has occurred", error);
}) 

This works correctly and displays all your products in the category 'Smartphones', but it doesn't show products in sub-categories.


Let's say that you have other two categories, Mobile devices, which is one level above Smartphones with id 122 and Tablets with id 125 at the same level as Smartphones. Now what if you want to show all your mobile devices? Querying by category id is not enough, because if you look for products with category_id equal to 122 you will get 0 results.


Let's see how the new parameter "category" solves this problem:

client.categories.getById(122)
.then((response) => {
  var myCategory = response.data;
   
  // A category path is a string describing the "path" to find in the category tree
  // When you create a category, marketcloud generates a category path for you.

  return client.product.list({ category: myCategory.path });
})
.then((response) => {
  var products = response.data;
  // Use your products here
})
.catch( (error) => {
  console.log("An error has occurred", error);
}) 

In this way you are able to fetch all products that belongs to that category and to its subcategories.


Improved full text search

We improved full text product search, now using the "q" parameter in GET /products requests you will get more results.

Before this improvement, to match the product "Classic shoes" you had to look for product using whole words, in this case, "classic" or "shoes".


Now you can also search by incomplete words, and this can be anywhere in the product document, not only in the name.


client.products.list({
  q : "class"
})
.then((response)  => {
  // All products matching "class" somehow
})
.catch( (error) => {
  // Handle the error
})


This is something we really wanted to improve in marketcloud after we added support for multilanguage, because in this way your store's users can search for products using their language.


If you have feedback about these new features, feel free to add a comment below!