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 (
    1958, 1959, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 
    1957, 1892, 1956, 1955, 1954, 1953, 
    1870, 1948, 1745, 1952, 1951, 1950, 
    1949, 1924, 1947, 1906, 1946, 1945, 
    1944, 1943, 1939, 1927, 1942, 1900, 
    1941, 1940, 1907, 1938, 1937, 1936, 
    1935, 1934, 1933, 1932, 1931, 1930
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00177

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": 97,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (1958,1959,2,3,4,5,6,7,8,9,10,1,1957,1892,1956,1955,1954,1953,1870,1948,1745,1952,1951,1950,1949,1924,1947,1906,1946,1945,1944,1943,1939,1927,1942,1900,1941,1940,1907,1938,1937,1936,1935,1934,1933,1932,1931,1930)"
    },
    "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": ["bacpvdev_db.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
1 1M
2 1M
3 1M
4 1M
5 2M
6 2M
7 2M
8 2M
9 3M
10 3M
1745 13M
1870 13M
1892 24M
1900 13M
1906 13M
1907 13M
1924 13M
1927 13M
1930 13M
1931 13M
1932 13M
1933 13M
1934 13M
1935 13M
1936 13M
1937 13M
1938 13M
1939 8M
1940 13M
1941 13M
1942 13M
1943 8M
1944 13M
1945 13M
1946 13M
1947 35M
1948 13M
1949 13M
1950 13M
1951 13M
1952 13M
1953 13M
1954 13M
1955 13M
1956 13M
1957 13M
1958 24M
1959 12M