HomeWiki
HomeWiki
  1. Components
  • Back to home
  • 1. Themes
  • Layout
    • New Layout
    • Legacy Layout
  • Components
    • Announcement
    • Banner Carousel
    • Banner With Products Carousel
    • Blog Category List
    • Blog List
    • Brand List
    • Brands Carousel
    • Breadcrumb
    • Call To Action
    • Cart
    • Categories List
    • Change Password
    • Checkout
    • Cookie Manager
    • Filter list
    • Footer
    • Forgot Password
    • Form
    • Hero Carousel
    • Icon Block
    • Invitation
    • Last Visited Products
    • Layout
    • Login
    • Map
    • Nav Bar
    • Offer
    • Product Attachments
    • Product Attributes
    • Product Documentation
    • Product Expected
    • Product Modal
    • Products Block
    • Products Carousel
    • Product Single
    • Profile
    • Quote
    • Register
    • Related Products
    • Search
    • Stores
    • Subscribe Newsletter
    • Text with Image
    • Top Bar
    • Video
  • Reusables
    • Getting Started
  • Assets
    • Getting Started
  • SDK
    • Products
      • _findProductsByCategory
      • _findProductsByIds
      • _findProductsByTitle
      • _findProductsByFilter
      • _findProductsByCriteria
      • _findProductsAndCalculate
      • _findProductsThenCalculate
      • _getProductAttributeSet
      • _setLastVisited
    • Categories
      • _findCategoryTreeById
      • _findCategoriesByIds
      • _findCategoryByAlias
      • _findCategoryTreeByAlias
      • _getCategoryContent
    • Collections
      • _getCollectionContent
      • _findCollectionsByIds
      • _findCollectionsByIdsThenCalculate
    • Brands
      • _getBrandContent
      • _findBrandsByIds
    • Cart
      • _addToCartMulti
      • _addToCart
      • _setCart
      • _clearCart
      • _setCartListener
      • _removeFromCart
      • _calculateCart
    • Checkout
      • _startCheckout
      • _updateCheckout
      • _completeCheckout
    • Shopping Lists
      • _getShoppingLists
      • _updateShoppingList
      • _createShoppingList
      • _deleteShoppingList
      • _getShoppingListByAlias
    • Navigation
      • _getFooterMenu
      • _getHeaderMenu
    • Users
      • _getUserById
    • Utils
      • _calculateCurrency
      • _getCurrencySymbol
      • _getCulture
      • _subscribeToNewsletter
      • _findUnitsByIds
  • Vs Code
    • Getting Started
  1. Components

Search

Search Component Documentation#

Overview#

The Search component is a component designed to provide a search interface for products or items. It includes a search bar where users can input search terms, and dynamically displays search results with pagination controls. The component manages search queries, displays results with images and titles, and handles pagination and loading states.

Model Documentation#

Model Structure#

The Search component relies on a data model that includes:
model: The component's configuration object.
timerId: Identifier for the debounce timer used in the search functionality.
filterData: Array holding the search results.
SearchText: The current search query entered by the user.
url: The current URL, used for search state management.
pageSize: Number of items displayed per page in the search results.
currentPage: The current page number in the search results.
isLoading: Boolean indicating whether the search results are currently being loaded.

Example Model#

Here's a sample model configuration:

Component Structure#

The Search component consists of the following parts:
1.
HTML Template: Defines the layout of the search section, including the search input field, result display, and pagination controls.
2.
JavaScript: Contains logic for handling search functionality, loading states, and pagination.
3.
Methods: Includes functions for searching, managing pagination, and handling UI updates.
4.
Computed Properties: Provides reactive calculations for pagination controls.

HTML Template#

The HTML template defines the structure of the search component. It includes:
Search Input: An input field for entering search queries and a search icon.
Loading State: Displayed when search results are being fetched.
No Results State: Displayed when no search results are found.
Search Results: Displays a list of products that match the search query.
Pagination Controls: Allows users to navigate between pages of search results.
Here’s the HTML template for the search component:

JavaScript#

The JavaScript part of the Search component handles the logic for searching and pagination.

Component Definition#

Explanation#

Props: The component accepts a model object that provides configuration details such as sorting order.
Data: Manages internal state, including search text, filter data, loading status, and pagination settings.
Methods:
getUrlParam: Retrieves and sets the search query from URL parameters.
delayedSearch: Handles search input with a debounce mechanism to reduce the number of search requests.
Search: Executes the search operation and updates results.
sendFilterRequest: Manages pagination by updating the current page and re-fetching results.
Computed Properties: Calculate pagination visibility and state, such as showing the next or previous page links.

Usage#

To use the Search component, include it in your Vue application and provide a model configuration. Here’s how you can incorporate it into your template:

Example of Model Data#

This setup allows the Search component to display a functional search interface with results and pagination controls. Ensure that your application includes methods like _findProductsByTitle and _addToCartAsync to handle data fetching and cart operations.
Previous
Related Products
Next
Stores
Built with