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 (
    461262, 461261, 461263, 461264, 461265, 
    461266, 461267, 461268, 461269, 460948, 
    461036, 461270, 230, 170, 227, 461033, 
    461242, 190, 461277, 312414, 325, 460946, 
    312456, 391037, 391032, 391031, 391030, 
    460955, 242, 243, 241, 240, 460947, 
    288, 214, 217, 218, 207, 312926, 199, 
    198, 201, 391002, 390979, 390978, 460951, 
    114, 192, 391013, 312901, 391014, 390986, 
    312443, 111835, 111837, 112217, 116529, 
    116541, 116547, 391009, 131, 177, 186, 
    185, 179, 400923, 400937, 400971, 391023, 
    22384, 312928, 312930, 312931, 312929, 
    312409, 312417, 172, 312421, 390994, 
    312424, 312425, 312426, 312427, 312428, 
    312429, 312430, 312431, 312432, 312433, 
    195, 233, 312854, 312855, 312864, 312852, 
    312853
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00120

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.365479454,
    "nested_loop": [
      {
        "table": {
          "table_name": "cscart_products_categories",
          "access_type": "range",
          "possible_keys": ["PRIMARY", "pt"],
          "key": "pt",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "loops": 1,
          "rows": 122,
          "cost": 0.17669501,
          "filtered": 100,
          "attached_condition": "cscart_products_categories.product_id in (461262,461261,461263,461264,461265,461266,461267,461268,461269,460948,461036,461270,230,170,227,461033,461242,190,461277,312414,325,460946,312456,391037,391032,391031,391030,460955,242,243,241,240,460947,288,214,217,218,207,312926,199,198,201,391002,390979,390978,460951,114,192,391013,312901,391014,390986,312443,111835,111837,112217,116529,116541,116547,391009,131,177,186,185,179,400923,400937,400971,391023,22384,312928,312930,312931,312929,312409,312417,172,312421,390994,312424,312425,312426,312427,312428,312429,312430,312431,312432,312433,195,233,312854,312855,312864,312852,312853)",
          "using_index": true
        }
      },
      {
        "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": ["u985510652_ecartify.cscart_products_categories.category_id"],
          "loops": 122,
          "rows": 1,
          "cost": 0.10994088,
          "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
114 243M
131 209M
170 212M
172 199M
177 212M
179 212M
185 214M
186 214M
190 200M
192 232M
195 232M
198 229M
199 229M
201 230M
207 171M
214 168M
217 168M
218 168M
227 170M
230 287M
233 217M
240 165M
241 165M
242 178M
243 178M
288 270,271,269M
325 304,305,287M
22384 454,455,458,456M
111835 289
111837 450
112217 225,288
116529 455,456,458
116541 166
116547 166
312409 304M
312414 304M
312417 224M
312421 223,224M
312424 288M
312425 288M
312426 225M
312427 225M
312428 225M
312429 225M
312430 225M
312431 225M
312432 225M
312433 225M
312443 461,460M
312456 461,460M
312852 475M
312853 475M
312854 475M
312855 475M
312864 475M
312901 454M
312926 454M
312928 454M
312929 454M
312930 454M
312931 454M
390978 223M
390979 223M
390986 223M
390994 223M
391002 223M
391009 223M
391013 223M
391014 223M
391023 223M
391030 478,166M
391031 478,166M
391032 478,166M
391037 478,166M
400923 223M
400937 498M
400971 305M
460946 304,305,287M
460947 165M
460948 200M
460951 287M
460955 478,166M
461033 527M
461036 529M
461242 530M
461261 530M
461262 530M
461263 530M
461264 530M
461265 530M
461266 530M
461267 530M
461268 530M
461269 530M
461270 530M
461277 196M