SELECT 
  cscart_products_categories.product_id, 
  GROUP_CONCAT(
    IF(
      cscart_products_categories.link_type = "M", 
      CONCAT(
        cscart_products_categories.category_id, 
        "M"
      ), 
      cscart_products_categories.category_id
    )
  ) AS category_ids 
FROM 
  cscart_products_categories 
  INNER JOIN cscart_categories ON cscart_categories.category_id = cscart_products_categories.category_id 
  AND cscart_categories.storefront_id IN (0, 1) 
  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') 
WHERE 
  cscart_products_categories.product_id IN (
    827, 840, 842, 889, 1085, 1100, 1106, 
    1150, 1201, 1212, 1216, 1226, 1242, 
    1253, 1309, 1434, 1436, 1462, 1514, 
    1570, 1618, 1851, 1969, 1979, 2036, 
    2046, 2047, 2063, 2165, 2185, 2315, 
    2345
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00128

JSON explain

{
  "query_block": {
    "select_id": 1,
    "table": {
      "table_name": "cscart_products_categories",
      "access_type": "range",
      "possible_keys": ["PRIMARY", "pt"],
      "key": "pt",
      "key_length": "3",
      "used_key_parts": ["product_id"],
      "rows": 32,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (827,840,842,889,1085,1100,1106,1150,1201,1212,1216,1226,1242,1253,1309,1434,1436,1462,1514,1570,1618,1851,1969,1979,2036,2046,2047,2063,2165,2185,2315,2345)"
    },
    "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.cscart_products_categories.category_id"],
      "rows": 1,
      "filtered": 100,
      "attached_condition": "cscart_categories.storefront_id in (0,1) 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')"
    }
  }
}

Result

product_id category_ids
827 44M
840 44M
842 44M
889 44M
1085 114M
1100 114M
1106 114M
1150 70M
1201 71M
1212 71M
1216 71M
1226 156M
1242 135M
1253 51M
1309 97M
1434 114M
1436 114M
1462 136M
1514 44M
1570 44M
1618 44M
1851 44M
1969 44M
1979 44M
2036 44M
2046 44M
2047 44M
2063 44M
2165 44M
2185 44M
2315 44M
2345 44M