SELECT 
  SQL_CALC_FOUND_ROWS products.product_id, 
  popularity.total as popularity, 
  IF(
    products.amount > 0, 
    0, 
    IF(products.datahub_amount > 0, 1, 0)
  ) dh_stock_only, 
  products.product_type, 
  products.parent_product_id 
FROM 
  cscart_products as products 
  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
    )
  ) 
  LEFT JOIN cscart_product_popularity as popularity ON popularity.product_id = products.product_id 
WHERE 
  1 
  AND pos_availabilty IN ('S', 'N') 
  AND popularity.total >= 1 
  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.parent_product_id = 0 
GROUP BY 
  products.product_id 
ORDER BY 
  dh_stock_only ASC, 
  popularity.total desc 
LIMIT 
  0, 10

Query time 0.07901

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "1333.61"
    },
    "ordering_operation": {
      "using_filesort": true,
      "grouping_operation": {
        "using_temporary_table": true,
        "using_filesort": false,
        "nested_loop": [
          {
            "table": {
              "table_name": "products",
              "access_type": "ref",
              "possible_keys": [
                "PRIMARY",
                "status",
                "idx_parent_product_id"
              ],
              "key": "status",
              "used_key_parts": [
                "status"
              ],
              "key_length": "3",
              "ref": [
                "const"
              ],
              "rows_examined_per_scan": 3747,
              "rows_produced_per_join": 749,
              "filtered": "19.99",
              "cost_info": {
                "read_cost": "172.32",
                "eval_cost": "74.92",
                "prefix_cost": "547.03",
                "data_read_per_join": "3M"
              },
              "used_columns": [
                "product_id",
                "product_type",
                "status",
                "amount",
                "usergroup_ids",
                "parent_product_id",
                "pos_availabilty",
                "datahub_amount"
              ],
              "attached_condition": "((`dbggbern`.`products`.`parent_product_id` = 0) and (`dbggbern`.`products`.`pos_availabilty` in ('S','N')) and ((`dbggbern`.`products`.`usergroup_ids` = '') or (0 <> find_in_set(0,`dbggbern`.`products`.`usergroup_ids`)) or (0 <> find_in_set(1,`dbggbern`.`products`.`usergroup_ids`))))"
            }
          },
          {
            "table": {
              "table_name": "popularity",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "total"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "product_id"
              ],
              "key_length": "3",
              "ref": [
                "dbggbern.products.product_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 249,
              "filtered": "33.33",
              "cost_info": {
                "read_cost": "187.30",
                "eval_cost": "24.97",
                "prefix_cost": "809.24",
                "data_read_per_join": "7K"
              },
              "used_columns": [
                "product_id",
                "total"
              ],
              "attached_condition": "(`dbggbern`.`popularity`.`total` >= 1)"
            }
          },
          {
            "table": {
              "table_name": "products_categories",
              "access_type": "ref",
              "possible_keys": [
                "PRIMARY",
                "pt"
              ],
              "key": "pt",
              "used_key_parts": [
                "product_id"
              ],
              "key_length": "3",
              "ref": [
                "dbggbern.products.product_id"
              ],
              "rows_examined_per_scan": 3,
              "rows_produced_per_join": 749,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "187.28",
                "eval_cost": "74.91",
                "prefix_cost": "1071.43",
                "data_read_per_join": "11K"
              },
              "used_columns": [
                "product_id",
                "category_id"
              ]
            }
          },
          {
            "table": {
              "table_name": "cscart_categories",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "c_status",
                "p_category_id"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "category_id"
              ],
              "key_length": "3",
              "ref": [
                "dbggbern.products_categories.category_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 749,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "187.28",
                "eval_cost": "74.91",
                "prefix_cost": "1333.61",
                "data_read_per_join": "2M"
              },
              "used_columns": [
                "category_id",
                "usergroup_ids"
              ],
              "attached_condition": "((`dbggbern`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`dbggbern`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`dbggbern`.`cscart_categories`.`usergroup_ids`)))"
            }
          }
        ]
      }
    }
  }
}

Result

product_id popularity dh_stock_only product_type parent_product_id
5204 93373 0 P 0
5205 92713 0 P 0
5203 90618 0 P 0
5201 78908 0 P 0
5859 78518 0 P 0
5199 77701 0 P 0
3894 76793 0 P 0
5173 70881 0 P 0
5175 68185 0 P 0
5174 66784 0 P 0