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

_findProductsByFilter

How to Use _findProductsByFilter Method#

The _findProductsByFilter method allows you to search for products based on custom filters, providing flexible search capabilities with support for pagination, calculations, and sorting.

Usage Steps:#

1.
Define Parameters:
page: The page number for pagination.
pagesize: The number of products per page.
filter: The filter criteria to apply to the search. This is typically a query string of filter parameters.
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 _findProductsByFilter 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 _findProductsByFilter method is called with a filter that specifies a category ID and price range, along with other parameters.
The handleResults function will process the retrieved products and total count.

Common Use Cases:#

1.
Custom Product Filtering:
Use this method to implement advanced search features where users can apply various filters (e.g., category, price range, brand) to find products that meet their specific criteria.
2.
Dynamic Search Capabilities:
This method allows for flexible and dynamic search queries, making it suitable for applications with complex filtering requirements.
3.
Efficient Data Handling:
With support for pagination, calculations, and sorting, this method efficiently manages large sets of filtered products, improving performance and user experience.

Notes:#

Filter Construction:
The filter parameter is passed directly as a query string. Ensure it is properly formatted according to your API's filtering requirements.
Sorting:
The sort parameter determines the order of the results. Customize this parameter based on your sorting needs (e.g., -Price for descending price or Name for alphabetical order).
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 Filter:
If the filter parameter is empty or null, consider handling this scenario in your application to avoid unnecessary API calls or default to a broader search.
By following these guidelines, you can effectively use the _findProductsByFilter method to implement versatile and powerful product search functionality in your application, accommodating a wide range of user search criteria and preferences.
Previous
_findProductsByTitle
Next
_findProductsByCriteria
Built with