Code Monkey home page Code Monkey logo

search's Introduction

📢 Use this project, contribute to it or open issues to help evolve it using Store Discussion.

Search

All Contributors

The VTEX Search app handles the new Intelligent Search solution in IO stores by providing new UI components to enhance the search experience, such as the autocomplete feature.

search-app-gif

Configuration

The Search app requires the [email protected] and [email protected] apps to be installed in your store. For more information, read the Intelligent Search documentation.

To configure the Search app, see the sections below.

Adding the Search app to your theme dependencies

Add the search app to your theme dependencies in the manifest.json as shown below:

  "dependencies": {
    "vtex.search": "2.x"
  }

You can now use all blocks exported by the search app. See the full list below:

Block name Description
autocomplete-result-list.v2 Provides customized autocomplete features in the search bar component, such as top searches, search history, product suggestions, or term suggestions. You can read more about the Intelligent Search autocomplete feature in the VTEX Help Center.
search-banner Renders a customized banner based on the search query.
did-you-mean Helps users with possible misspelling corrections for the current search query.
search-suggestions Renders a list of similar search terms for the current search.

ℹ️ The search-banner, did-you-mean, and search-suggestions blocks require Search Result app version 3.x or higher installed in your theme.

Adding Search blocks to the theme

First, declare the autocomplete-result-list.v2 block as a child block of the search-bar block, exported by the Store Components app. Example:

{
  "search-bar": {
    "blocks": ["autocomplete-result-list.v2"],
    "props": {
      "openAutocompleteOnFocus": true
    }
  }
}

autocomplete-result-list.v2 props

Prop name Type Description Default value
maxTopSearches number Maximum number of items in the top searches list. 10
maxHistory number Maximum number of items in the search history. 5
maxSuggestedProducts number Maximum number of items in the suggested products list. 3
maxSuggestedTerms number Maximum number of items in the suggested terms list. 3
autocompleteWidth number Autocomplete list width (percentage). This value must be between 0 and 100. undefined
productLayout enum Determines the layout the suggested products list will have when rendered. Possible values are HORIZONTAL and VERTICAL. undefined
hideTitles boolean Determines whether all component titles will be hidden when rendered (true) or not (false). false
hideUnavailableItems boolean Determines whether autocomplete should hide unavailable items (true) or not (false). This prop only hides items that are unavailable according to indexed information, without taking into account simulationBehavior. false
historyFirst boolean Determines whether the search history list should be prioritized over the other lists (true) or not (false). false
customBreakpoints object Determines the maximum number of recommended products per breakpoints. Possible values are md, lg, or xlg. -
simulationBehavior "skip" or "default" If you want faster searches and are not so concern about having the most up-to-date prices and promotions, use "skip". default
HorizontalProductSummary product-summary block By default, the mobile autocomplete uses the CustomListItem component to render the suggested products using a horizontal layout. But sending a product-summary block here will render your customized Product Summary component. Read our documentation to learn how to build a horizontal Product Summary component. undefined
The customBreakpoints object
Prop name Type Description Default value
md object Defines the maximum number of recommended products for the md breakpoint. undefined
lg object Defines the maximum number of recommended products for the lg breakpoint. undefined
xlg object Defines the maximum number of recommended products for the xlg breakpoint. undefined
The md, lg, and xlg objects
Prop name Type Description Default value
width number Breakpoint minimum width. undefined
maxSuggestedProducts number Maximum number of suggested products. undefined

The autocomplete-result-list.v2 block also allows you to add a list of child blocks to it. You can declare a theme block and have it rendered among the autocomplete features. Example:

{
  "autocomplete-result-list.v2": {
    "blocks": ["product-summary"]
  }
}

Now, you can add the last three search blocks: search-banner, did-you-mean, and search-suggestions.

These blocks, as opposed to autocomplete-result-list.v2, need to be added under the search-result-layout.desktop or the search-result-layout.mobile blocks, following the Search Results block hierarchy.

Once added, the blocks can be declared using their respective props for configuration. Example:

{
  "search-result-layout.desktop": {
    "children": [
      "flex-layout.row#did-you-mean",
      "flex-layout.row#suggestion",
      "flex-layout.row#banner-one",
      "flex-layout.row#result"
    ],
    "props": {
      "pagination": "show-more",
      "preventRouteChange": true,
      "mobileLayout": {
        "mode1": "small",
        "mode2": "normal"
      }
    }
  },

  "flex-layout.row#did-you-mean": {
    "children": ["did-you-mean"]
  },
  "flex-layout.row#suggestion": {
    "children": ["search-suggestions"]
  },
  "flex-layout.row#banner-one": {
    "children": ["search-banner#one"]
  },

  "search-banner#one": {
    "props": {
      "area": "one",
      "blockClass": "myBanner",
      "horizontalAlignment": "center"
    }
  }
}

search-banner props

Prop name Type Description Default value
area string Area where the banner will be displayed in the store. This needs to match the predefined area value in the banner configuration. undefined
blockClass string Unique block ID to be used in CSS customizations. undefined
horizontalAlignment string Defines the horizontal alignment of the banner. Possible values are left, center, or right. center

App behavior: Improving search experience

To improve the user's search experience in stores where the Intelligent Search engine is supported, the app have the following options:

  • Stores using Universal Analytics (UA):

    The Search app provides blocks that, when rendered as components, will improve the user's search experience in stores where the Intelligent Search engine is supported.

    These components use _q as the query-string for the search term, meaning that if you want to track user searches in these components, you will need to add the _q query-string to the store's Google Analytics. To activate this behavior, refer to Set up Site Search Google's documentation.

      >❗ Please note that although the Search app's blocks enhance the search experience in VTEX stores, this feature is only compatible with VTEX stores using UA. As UA will be discontinued on July 1st, 2023, **we highly recommend that you update your store to GA4**. For more information on the migration, see the [release notes](https://developers.vtex.com/updates/release-notes/2023-05-04-google-tag-manager-new-version) and follow the option below.
    
  • Store using Google Analytics 4 (GA4):

    Install the VTEX Google Tag Manager app, which includes the search event within the app's data layer. This app is responsible for tracking the user's search activity. For instructions on setting up Google Tag Manager, consult the Setting up Google Tag Manager documentation.

Customization

In order to apply CSS customizations to this and other blocks, follow the instructions given in the recipe on Using CSS handles for store customizations.

CSS handles
searchBanner
didYouMeanPrefix
didYouMeanTerm
suggestionsList
suggestionsListItem
suggestionsListLink
itemListSubItemLink
itemListLink
itemListLinkTitle

Contributors ✨

Thanks goes out to these wonderful people:

This project follows the all-contributors specification. Contributions of any kind are welcome!

search's People

Contributors

aprando avatar brendacdmoura avatar brunorodmoreira avatar camilavcoutinho avatar caroladao avatar chrsmutti avatar danzanzini avatar feraraujofilho avatar fernandocodeby avatar fernandowashimi avatar georgelimadev avatar guerreirobeatriz avatar gustavopvasconcellos avatar hiagolcm avatar iago1501 avatar icazevedo avatar julia-rabello avatar karenkrieger avatar klynger avatar klzns avatar lucasecdb avatar mariana-caetano avatar marlonfrancisco avatar mateussaggin avatar sheilagomes avatar thalytafabrine avatar viniagostini avatar vwraposo avatar weslyacct avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

search's Issues

Autocomplete not showing {listPriceWithTax} & {sellingPriceWithTax}

Hi!

The autocomplete is not shoing the prices. We had similar issues on the search page, but they were fixed when adding the "__unstableProductOriginVtex" prop. It doesn't seem to work on the autocomplete block. I've added our code bellow. You can test / edit / see in this workspace: https://beta--dacris.myvtex.com/

Thanks!

"search-bar": { "blocks": ["autocomplete-result-list.v2"], "props": { "openAutocompleteOnFocus": true, "placeholder": "Cauta orice, avem atatea solutii ...", "displayMode":"clear-button" } }, "autocomplete-result-list.v2": { "blocks": ["product-summary.shelf#defaultShelf"], "props": { "__unstableProductOriginVtex": true } },

Autocomplete show more link redirect bug

Describe the bug
Show more link is not getting the parent URL and is redirecting to another website.
To Reproduce
Go to https://shop.samsung.com/br/, search galaxy and wait for the autocomplete be filled.
Hover the show more link and you'll see that the query is wrong and is not having the /br/ in the URL neither.
Expected behavior
Correct query and /br/ before the query.
Video
https://www.loom.com/share/863979ad51e54d1b99100de5bac083b0
Additional context
https://github.com/vtex-apps
vtex.search: 1.x

Lack of class to style the search-bar

Is your feature request related to a problem? Please describe.
There is no class to manipulate the element that is absolute.

alt text

Describe the solution you'd like
With a class in the element, I can manipulate (force) the position and the ideal size to match the layout.

search-bar doesn't work properly on mobile

When the search-bar block is declared inside a header-layout block, the search bar doesn't work properly on mobile.

https://i.imgur.com/PDlNpot.png

But if we declare the search-bar block directly in header and header.full it works as expected.

https://i.imgur.com/z4H3RRb.gif

This workaround doesn't work for us because we need to declare search-bar inside a layout component to set component position and styles.

Error example

Given the following code:

{
  "header": {
    "blocks": ["header-layout.mobile"]
  },

  "header.full": {
    "blocks": ["header-layout.mobile"]
  },

  "header-layout.mobile": {
    "children": ["sticky-layout#header-row-mobile"]
  },

  "sticky-layout#header-row-mobile": {
    "children": ["flex-layout.row#header-row-mobile"]
  },

  "flex-layout.row#header-row-mobile": {
    "children": [
      "drawer",
      "logo",
      "minicart.v2"
    ],
    "props": {
      "fullWidth": true
    }
  },
}

The expected behavior on mobile is:

  • render a button
  • when the button is clicked, show the search input.

The actual behavior is:

  • render the search input as in desktop

But if we make a few changes in code, it'll work properly, but there's blocks that we can't declare inside header and header.full, such as drawer and flex-layout.

{
  "header": {
    "blocks": ["search-bar"]
  },

  "header.full": {
    "blocks": ["search-bar"]
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.