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 (
    55, 92, 143, 280, 337, 339, 506, 510, 516, 
    517, 526, 527, 528, 529, 530, 1562, 1563, 
    1564, 1565, 1566, 1567, 1568, 1569, 
    1570, 5477, 5556, 5473, 1843, 1841, 
    1840, 486, 1842
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.01041

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": 756,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (55,92,143,280,337,339,506,510,516,517,526,527,528,529,530,1562,1563,1564,1565,1566,1567,1568,1569,1570,5477,5556,5473,1843,1841,1840,486,1842)"
    },
    "table": {
      "table_name": "cscart_categories",
      "access_type": "eq_ref",
      "possible_keys": ["PRIMARY", "c_status"],
      "key": "PRIMARY",
      "key_length": "3",
      "used_key_parts": ["category_id"],
      "ref": ["herbaria_cscart_4_18.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
55 261,257,249,243,241,240,237,107,100,75,48,44,27,26,20,18,16,306,1M
92 261,257,243,240,238,107,101,88,72,66,44,40,34,27,26,16,306,1M
143 261,259,258,241,238,237,236,233,217,194,123,75,73,71,60,48,44,43,42,30,20,1,306,242M
280 269,267,264,191,82,67,44,34,33,29,306,228M
337 228,306,269,259,250,241,237,233,208,119,90,71,53,49,48,44,217M
339 258,306,304,295,267,265,264,261,255,251,241,240,238,237,236,235,234,233,230,229,192,179,175,123,120,109,101,94,83,79,74,73,69,68,67,64,60,55,54,53,52,47,46,44,43,41,26,20,19,17,16,15,336,1M
486 83,87,70,90,81,77,76,107,88,95,47,46,94,67,306,261,258,241,236,233,75,73,44,20,1,61,242M
506 261,257,249,243,241,240,237,107,100,75,48,44,27,26,20,18,16,306,1M
510 261,257,243,240,238,107,101,88,72,66,44,40,34,27,26,16,306,1M
516 261,259,258,241,238,237,236,233,217,194,123,75,73,71,60,48,44,43,42,30,20,1,306,242M
517 261,259,258,241,238,237,236,233,217,194,123,75,73,71,60,48,44,43,42,30,20,1,306,242M
526 269,267,264,191,82,67,44,34,33,29,306,228M
527 269,267,264,191,82,67,44,34,33,29,306,228M
528 269,267,264,191,82,67,44,34,33,29,306,228M
529 269,267,264,191,82,67,44,34,33,29,306,228M
530 269,267,264,191,82,67,44,34,33,29,306,228M
1562 228,306,269,259,250,241,237,233,208,119,90,71,53,49,48,44,217M
1563 228,306,269,259,250,241,237,233,208,119,90,71,53,49,48,44,217M
1564 228,306,269,259,250,241,237,233,208,119,90,71,53,49,48,44,217M
1565 306,304,295,267,265,264,261,255,251,241,240,238,237,236,235,234,233,230,229,192,179,175,123,120,109,101,94,83,79,74,73,69,68,67,64,60,55,54,53,52,47,46,44,43,41,26,20,19,17,16,258,15,336,1M
1566 306,304,295,267,265,264,261,255,251,241,240,238,237,236,235,234,233,230,229,192,179,175,123,120,109,101,94,83,79,74,73,69,68,67,64,60,55,54,53,52,47,46,44,43,41,26,20,19,17,16,258,15,336,1M
1567 306,304,295,267,265,264,261,255,251,241,240,238,237,236,235,234,233,230,229,192,179,175,123,120,109,101,94,83,79,74,73,69,68,67,64,60,55,54,53,52,47,46,44,43,41,26,20,19,17,16,258,15,336,1M
1568 306,304,295,267,265,264,261,255,251,241,240,238,237,236,235,234,233,230,229,192,179,175,123,120,109,101,94,83,79,74,73,69,68,67,64,60,55,54,53,52,47,46,44,43,41,26,20,19,17,16,258,15,336,1M
1569 306,304,295,267,265,264,261,255,251,241,240,238,237,236,235,234,233,230,229,192,179,175,123,120,109,101,94,83,79,74,73,69,68,67,64,60,55,54,53,52,47,46,44,43,41,26,20,19,17,16,258,15,336,1M
1570 306,304,295,267,265,264,261,255,251,241,240,238,237,236,235,234,233,230,229,192,179,175,123,120,109,101,94,83,79,74,73,69,68,67,64,60,55,54,53,52,47,46,44,43,41,26,20,19,17,16,258,15,336,1M
1840 83,87,70,90,81,77,76,107,88,95,47,46,94,67,306,261,258,241,236,233,75,73,44,20,1,61,242M
1841 83,87,70,90,81,77,76,107,88,95,47,46,94,67,306,261,258,241,236,233,75,73,44,20,1,61,242M
1842 83,87,70,90,81,77,76,107,88,95,47,46,94,67,306,261,258,241,236,233,75,73,44,20,1,61,242M
1843 83,87,70,90,81,77,76,107,88,95,47,46,94,67,306,261,258,241,236,233,75,73,44,20,1,61,242M
5473 83,61,1,20,44,73,75,233,236,241,258,261,306,67,94,46,47,95,88,107,76,77,81,90,70,87,242M
5477 306,1,20,30,42,43,44,48,60,71,73,75,123,194,217,233,236,237,238,241,258,259,261,242M
5556 261,20,255,26,251,241,240,238,237,236,235,15,234,233,230,229,192,179,336,175,123,120,109,101,94,83,79,74,73,69,68,67,64,60,55,54,53,52,47,46,44,43,41,258,306,304,295,267,16,265,17,264,19,1M