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 (
    438300, 438310, 438321, 438143, 438152, 
    438177, 438180, 438188, 438195, 438212, 
    438218, 438052, 438076, 438086, 438088, 
    438091, 438098, 438102, 438114, 438117, 
    438128, 438135, 437939, 437947, 437960, 
    437962, 437993, 438009, 438012, 438027, 
    437839, 437842, 437850, 437861, 437876, 
    437879, 437895, 437901, 437836, 437741, 
    437755, 437768, 437794, 437811, 437653, 
    437661, 437686, 437696
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00059

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.161436522,
    "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": 48,
          "cost": 0.08683616,
          "filtered": 100,
          "attached_condition": "cscart_products_categories.product_id in (438300,438310,438321,438143,438152,438177,438180,438188,438195,438212,438218,438052,438076,438086,438088,438091,438098,438102,438114,438117,438128,438135,437939,437947,437960,437962,437993,438009,438012,438027,437839,437842,437850,437861,437876,437879,437895,437901,437836,437741,437755,437768,437794,437811,437653,437661,437686,437696)",
          "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": 48,
          "rows": 1,
          "cost": 0.04375232,
          "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
437653 289M
437661 498M
437686 305M
437696 289M
437741 289M
437755 289M
437768 289M
437794 498M
437811 500M
437836 305M
437839 495M
437842 289M
437850 498M
437861 498M
437876 289M
437879 289M
437895 495M
437901 500M
437939 498M
437947 305M
437960 498M
437962 289M
437993 305M
438009 500M
438012 495M
438027 498M
438052 495M
438076 495M
438086 289M
438088 498M
438091 289M
438098 305M
438102 500M
438114 289M
438117 305M
438128 500M
438135 305M
438143 305M
438152 498M
438177 500M
438180 289M
438188 289M
438195 495M
438212 495M
438218 305M
438300 498M
438310 498M
438321 500M