Retrieve products with type "Variant"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rainers24
    Junior Member
    • Mar 2025
    • 4

    Retrieve products with type "Variant"

    Hey,

    I have an issue regarding retrieval of products through API. I can get all of the template type products from /api/v1/product, but the issue arises when I need to push in a new InventoryNumber and find already created product variant.

    Is there an endpoint or other way how I can retrieve all of the products also the ones where type = Variant ?

    Regards,
    Rainers
  • yuri
    Member
    • Mar 2014
    • 8826

    #2
    Hi Rainers,

    Try the 'allVariants' primary filter.

    In query parameters:
    Code:
    primaryFilter=allVariants
    Additionally, there's also a primary filter 'availableVariants', that returns product variants with the status 'Active'.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment


    • yuri
      yuri commented
      Editing a comment
      Note that it does not include non-variant products.
  • rainers24
    Junior Member
    • Mar 2025
    • 4

    #3
    Bingo, this solved the issue!

    Thanks Yuri!

    Comment

    • rainers24
      Junior Member
      • Mar 2025
      • 4

      #4
      yuri Another question while we are almost on the same topic here.

      By looking at the documentation i could now find what is the correct way to form "where" param and the searchParams ?

      headers = {'X-Api-Key': api_key}
      search_params = {
      "select": "id,name",
      "where": [
      {
      "type": "equals",
      "attribute": "name",
      "value": full_product_name
      }
      ]
      }
      params = {
      "primaryFilter": "allVariants",
      "searchParams": json.dumps(search_params)
      }
      print(params)
      response = requests.get(url, headers=headers, params=params)

      im doing it like this now but looks like im getting error 400

      Comment

      • rainers24
        Junior Member
        • Mar 2025
        • 4

        #5
        all good, looks like i need to use whereGroup and a textFilter

        Comment

        Working...