HomeWiki
HomeWiki
  1. Products
  • 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. Products

_findProductsByTitle

How to Use _findProductsByTitle Method#

The _findProductsByTitle method is designed to search for products based on a title or keyword. It allows you to paginate the results, perform optional calculations, and specify sorting options.

Usage Steps:#

1.
Define Parameters:
page: The page number for pagination.
pagesize: The number of products per page.
search: The search term or title to filter products by.
calc: A boolean indicating whether to perform calculations on the products.
sort: The sorting order for the results.
callback: A function to handle the results.
2.
Call the Method:
Invoke the _findProductsByTitle method with the required parameters.
3.
Handle Results:
The callback function will receive the products and total count as parameters, allowing you to process or display the results.

Example:#

In this example:
The _findProductsByTitle method is called with the search term "Laptop" and other parameters.
The handleResults function will process the retrieved products and total count.

Common Use Cases:#

1.
Product Search Functionality:
Use this method to implement a search feature on your product listing pages, allowing users to find products by title or keyword.
2.
Pagination and Sorting:
The method supports pagination and sorting, making it suitable for managing large sets of search results and providing a smooth user experience.
3.
Dynamic Calculations:
If calculations (e.g., for promotions or stock levels) are needed, set the calc parameter to true to include them in the API request.

Notes:#

Filter Construction:
The filter parameter is constructed by appending the search term with the prefix search=. This formats the query string for the API request to fetch products that match the search criteria.
Sorting:
The sort parameter allows you to specify the order in which results are returned. By default, the sorting is done by -SortDate, but you can customize this based on your requirements (e.g., -Price for descending price).
Initialization:
The _findProducts function is used internally to handle the API request. Ensure that _initializeProductProperties is implemented to format or enrich the product data as needed.
Handling Empty Search:
Ensure that the search parameter is valid and not empty to avoid unnecessary API calls. Handle cases where the search term is empty or null as needed in your application.
By following these guidelines, you can effectively use the _findProductsByTitle method to search for products based on a title or keyword, providing enhanced search capabilities and user experience in your application.
Previous
_findProductsByIds
Next
_findProductsByFilter
Built with