SELECT 
  SQL_CALC_FOUND_ROWS products.product_id, 
  descr1.product as product, 
  companies.company as company_name, 
  MIN(
    IF(
      prices.percentage_discount = 0, 
      prices.price, 
      prices.price - (
        prices.price * prices.percentage_discount
      )/ 100
    )
  ) as price, 
  SUBSTRING_INDEX(
    cscart_categories.id_path, "/", 1
  ) AS root_category, 
  user.firstname AS user_firstname, 
  user.lastname AS user_lastname, 
  user.user_id AS user_id, 
  profi_i.image_path AS avatar_image_image_path, 
  profi_i.image_x AS avatar_image_image_x, 
  profi_i.image_y AS avatar_image_image_y, 
  profi_i.is_high_res AS avatar_image_is_high_res, 
  profi_d.image_path AS avatar_detailed_image_path, 
  profi_d.image_x AS avatar_detailed_image_x, 
  profi_d.image_y AS avatar_detailed_image_y, 
  profi_d.is_high_res AS avatar_detailed_is_high_res, 
  profil.pair_id AS avatar_pair_id, 
  profil.image_id AS avatar_image_id, 
  profil.detailed_id AS avatar_detailed_id, 
  c4pcmain.unit_size as unit_size, 
  c4pcmain.unit_size * prices.price as unit_price, 
  products.paused AS paused, 
  (products.amount * prices.price) AS total_amount, 
  prices.price_piloted as price_piloted, 
  prices.price_selfplay as price_selfplay 
FROM 
  cscart_products as products 
  LEFT JOIN cscart_product_descriptions as descr1 ON descr1.product_id = products.product_id 
  AND descr1.lang_code = 'en' 
  LEFT JOIN cscart_product_prices as prices ON prices.product_id = products.product_id 
  AND prices.lower_limit = 1 
  LEFT JOIN cscart_companies AS companies ON companies.company_id = products.company_id 
  INNER JOIN cscart_products_categories as products_categories ON products_categories.product_id = products.product_id 
  INNER JOIN cscart_categories ON cscart_categories.category_id = products_categories.category_id 
  AND (
    cscart_categories.usergroup_ids = '' 
    OR FIND_IN_SET(
      0, cscart_categories.usergroup_ids
    ) 
    OR FIND_IN_SET(
      1, cscart_categories.usergroup_ids
    )
  ) 
  AND cscart_categories.status IN ('A', 'H') 
  AND cscart_categories.storefront_id IN (0, 1) 
  LEFT JOIN cscart_users as user ON user.user_id = (
    SELECT 
      user_id 
    FROM 
      cscart_users as tu 
    WHERE 
      tu.company_id = companies.company_id 
    LIMIT 
      1
  ) LEFT JOIN cscart_profile_images_links as profil ON user.user_id = profil.profile_id 
  AND field_name = "avatar" 
  LEFT JOIN cscart_profile_images as profi_i ON profi_i.image_id = profil.image_id 
  LEFT JOIN cscart_profile_images as profi_d ON profi_d.image_id = profil.detailed_id 
  LEFT JOIN cscart_products_categories as pcmain ON pcmain.product_id = products.product_id 
  AND pcmain.link_type = "M" 
  LEFT JOIN cscart_categories as c4pcmain ON c4pcmain.category_id = pcmain.category_id 
WHERE 
  1 
  AND products.product_id NOT IN (2247) 
  AND companies.status IN ('A') 
  AND products.paused IN ('N') 
  AND (
    products.usergroup_ids = '' 
    OR FIND_IN_SET(0, products.usergroup_ids) 
    OR FIND_IN_SET(1, products.usergroup_ids)
  ) 
  AND products.status IN ('A') 
  AND prices.usergroup_id IN (0, 0, 1) 
  AND (
    products.min_qty IS NULL 
    OR products.min_qty = 0 
    OR products.min_qty <= products.amount
  ) 
  AND products.product_id IN (
    SELECT 
      product_id 
    FROM 
      cscart_category_filter_products AS cfp 
    WHERE 
      (
        cfp.value IN ('967')
      ) 
      AND cfp.category_filter_id = 19 
      OR (cfp.value = '331') 
      AND cfp.category_filter_id = 20 
    GROUP BY 
      cfp.product_id 
    having 
      count(product_id) = 2
  ) 
  AND products.paused != 'Y' 
GROUP BY 
  products.product_id 
ORDER BY 
  price asc, 
  products.product_id ASC 
LIMIT 
  0, 5

Query time 0.01990

JSON explain

{
  "query_block": {
    "select_id": 1,
    "filesort": {
      "sort_key": "min(if(prices.percentage_discount = 0,prices.price,prices.price - prices.price * prices.percentage_discount / 100)), products.product_id",
      "temporary_table": {
        "table": {
          "table_name": "prices",
          "access_type": "ALL",
          "possible_keys": [
            "usergroup",
            "product_id",
            "lower_limit",
            "usergroup_id"
          ],
          "rows": 3010,
          "filtered": 99.83388519,
          "attached_condition": "prices.lower_limit = 1 and prices.product_id <> 2247 and prices.usergroup_id in (0,0,1)"
        },
        "table": {
          "table_name": "products",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY", "status"],
          "key": "PRIMARY",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "ref": ["dev.prices.product_id"],
          "rows": 1,
          "filtered": 99.53488159,
          "attached_condition": "products.paused = 'N' and (products.usergroup_ids = '' or find_in_set(0,products.usergroup_ids) or find_in_set(1,products.usergroup_ids)) and products.`status` = 'A' and (products.min_qty is null or products.min_qty = 0 or products.min_qty <= products.amount)"
        },
        "table": {
          "table_name": "companies",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY"],
          "key": "PRIMARY",
          "key_length": "4",
          "used_key_parts": ["company_id"],
          "ref": ["dev.products.company_id"],
          "rows": 1,
          "filtered": 100,
          "attached_condition": "companies.`status` = 'A'"
        },
        "table": {
          "table_name": "<subquery3>",
          "access_type": "eq_ref",
          "possible_keys": ["distinct_key"],
          "key": "distinct_key",
          "key_length": "4",
          "used_key_parts": ["product_id"],
          "ref": ["dev.prices.product_id"],
          "rows": 1,
          "filtered": 100,
          "attached_condition": "prices.product_id = `<subquery3>`.product_id",
          "materialized": {
            "unique": 1,
            "materialization": {
              "query_block": {
                "select_id": 3,
                "having_condition": "count(cfp.product_id) = 2",
                "temporary_table": {
                  "table": {
                    "table_name": "cfp",
                    "access_type": "ALL",
                    "possible_keys": ["PRIMARY"],
                    "rows": 5774,
                    "filtered": 71.75268555,
                    "attached_condition": "(cfp.category_filter_id = 19 and cfp.`value` = '967' or cfp.category_filter_id = 20 and cfp.`value` = '331') and cfp.product_id <> 2247"
                  }
                }
              }
            }
          }
        },
        "table": {
          "table_name": "user",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY"],
          "key": "PRIMARY",
          "key_length": "3",
          "used_key_parts": ["user_id"],
          "ref": ["func"],
          "rows": 1,
          "filtered": 100,
          "attached_condition": "trigcond(`user`.user_id = (subquery#2))"
        },
        "table": {
          "table_name": "products_categories",
          "access_type": "ref",
          "possible_keys": ["PRIMARY", "pt"],
          "key": "pt",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "ref": ["dev.prices.product_id"],
          "rows": 1,
          "filtered": 100
        },
        "table": {
          "table_name": "cscart_categories",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY", "c_status", "p_category_id"],
          "key": "PRIMARY",
          "key_length": "3",
          "used_key_parts": ["category_id"],
          "ref": ["dev.products_categories.category_id"],
          "rows": 1,
          "filtered": 100,
          "attached_condition": "(cscart_categories.usergroup_ids = '' or find_in_set(0,cscart_categories.usergroup_ids) or find_in_set(1,cscart_categories.usergroup_ids)) and cscart_categories.`status` in ('A','H') and cscart_categories.storefront_id in (0,1)"
        },
        "table": {
          "table_name": "descr1",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY", "product_id"],
          "key": "PRIMARY",
          "key_length": "9",
          "used_key_parts": ["product_id", "lang_code"],
          "ref": ["dev.prices.product_id", "const"],
          "rows": 1,
          "filtered": 100,
          "attached_condition": "trigcond(descr1.lang_code = 'en')"
        },
        "table": {
          "table_name": "profil",
          "access_type": "ref",
          "possible_keys": ["profile_id"],
          "key": "profile_id",
          "key_length": "102",
          "used_key_parts": ["profile_id", "field_name"],
          "ref": ["dev.user.user_id", "const"],
          "rows": 2,
          "filtered": 100,
          "attached_condition": "trigcond(`user`.user_id = profil.profile_id and profil.field_name = 'avatar' and trigcond(`user`.user_id is not null))"
        },
        "table": {
          "table_name": "profi_i",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY"],
          "key": "PRIMARY",
          "key_length": "4",
          "used_key_parts": ["image_id"],
          "ref": ["dev.profil.image_id"],
          "rows": 1,
          "filtered": 100,
          "attached_condition": "trigcond(trigcond(profil.image_id is not null))"
        },
        "table": {
          "table_name": "profi_d",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY"],
          "key": "PRIMARY",
          "key_length": "4",
          "used_key_parts": ["image_id"],
          "ref": ["dev.profil.detailed_id"],
          "rows": 1,
          "filtered": 100,
          "attached_condition": "trigcond(trigcond(profil.detailed_id is not null))"
        },
        "table": {
          "table_name": "pcmain",
          "access_type": "ref",
          "possible_keys": ["link_type", "pt"],
          "key": "pt",
          "key_length": "6",
          "used_key_parts": ["product_id", "link_type"],
          "ref": ["dev.prices.product_id", "const"],
          "rows": 1,
          "filtered": 100,
          "attached_condition": "trigcond(pcmain.link_type = 'M')"
        },
        "table": {
          "table_name": "c4pcmain",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY", "p_category_id"],
          "key": "PRIMARY",
          "key_length": "3",
          "used_key_parts": ["category_id"],
          "ref": ["dev.pcmain.category_id"],
          "rows": 1,
          "filtered": 100,
          "attached_condition": "trigcond(trigcond(pcmain.category_id is not null))"
        },
        "subqueries": [
          {
            "expression_cache": {
              "state": "uninitialized",
              "query_block": {
                "select_id": 2,
                "table": {
                  "table_name": "tu",
                  "access_type": "ALL",
                  "rows": 89,
                  "filtered": 100,
                  "attached_condition": "tu.company_id = companies.company_id"
                }
              }
            }
          }
        ]
      }
    }
  }
}

Result

product_id product company_name price root_category user_firstname user_lastname user_id avatar_image_image_path avatar_image_image_x avatar_image_image_y avatar_image_is_high_res avatar_detailed_image_path avatar_detailed_image_x avatar_detailed_image_y avatar_detailed_is_high_res avatar_pair_id avatar_image_id avatar_detailed_id unit_size unit_price paused total_amount price_piloted price_selfplay
2512 Any realm - Alliance user_76 0.4400000000000000 43 lilLol 76 55931f274f7e.png 25 25 8 0 8 1.00 0.440000000000 N 375303.7200000000
2509 Any realm - Alliance SOME SELLER 1.0000000000000000 43 Nikita990 86 1.00 1.000000000000 N 500.0000000000