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 (
    177, 179, 180, 181, 183, 184, 185, 186, 
    187, 188, 189, 190, 191, 7, 11, 12, 15, 
    27, 28, 29, 30, 31, 32, 33, 34, 37, 38, 
    39, 40, 41, 42, 43, 47, 48, 49, 50, 51, 
    52, 53, 54, 55, 56, 57, 58, 59, 60, 62, 
    63, 64, 65, 67, 68, 69, 70, 71, 72, 73, 
    74, 75, 76
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00137

JSON explain

{
  "query_block": {
    "select_id": 1,
    "nested_loop": [
      {
        "read_sorted_file": {
          "filesort": {
            "sort_key": "cscart_products_categories.product_id",
            "table": {
              "table_name": "cscart_products_categories",
              "access_type": "ALL",
              "possible_keys": ["PRIMARY", "pt"],
              "rows": 281,
              "filtered": 21.7081852,
              "attached_condition": "cscart_products_categories.product_id in (177,179,180,181,183,184,185,186,187,188,189,190,191,7,11,12,15,27,28,29,30,31,32,33,34,37,38,39,40,41,42,43,47,48,49,50,51,52,53,54,55,56,57,58,59,60,62,63,64,65,67,68,69,70,71,72,73,74,75,76)"
            }
          }
        }
      },
      {
        "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": ["cscart.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
7 224M
11 224M
12 224M
15 224M
27 225M
28 225M
29 176M
30 176M
31 225M
32 176M
33 176M
34 225M
37 185M
38 225M
39 185M
40 185M
41 225M
42 185M
43 185M
47 247M
48 186M
49 186M
50 186M
51 186M
52 202M
53 202M
54 202M
55 187M
56 187M
57 187M
58 188M
59 188M
60 176M
62 189M
63 189M
64 189M
65 189M
67 236M
68 236M
69 236M
70 236M
71 236M
72 240M
73 240M
74 240M
75 240M
76 240M
177 212M
179 212M
180 200M
181 212M
183 200M
184 200M
185 214M
186 214M
187 214M
188 213M
189 200M
190 200M
191 231M