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 (
    10242, 8381, 10072, 10231, 10246, 10251, 
    10262, 10269, 10271, 10280, 10158, 
    10021, 10030, 10044, 10045, 10076, 
    10099, 10106, 10123, 10164, 10166, 
    10235, 10253, 10256, 10257, 10268, 
    10270, 10279, 10281, 10297, 9714, 10046, 
    10107, 10155, 10163, 10168, 10203, 
    10240, 10252, 10263, 10266, 10298, 
    10094, 10096, 10108, 10153, 10162, 
    10165, 10169, 10170, 10220, 10259, 
    10031, 10070, 10173, 10245, 10258, 
    10260, 10041, 10241, 10184, 10296, 
    10067, 10149, 10064
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00233

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "69.86"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 67,
            "rows_produced_per_join": 67,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (10242,8381,10072,10231,10246,10251,10262,10269,10271,10280,10158,10021,10030,10044,10045,10076,10099,10106,10123,10164,10166,10235,10253,10256,10257,10268,10270,10279,10281,10297,9714,10046,10107,10155,10163,10168,10203,10240,10252,10263,10266,10298,10094,10096,10108,10153,10162,10165,10169,10170,10220,10259,10031,10070,10173,10245,10258,10260,10041,10241,10184,10296,10067,10149,10064))",
            "cost_info": {
              "read_cost": "39.71",
              "eval_cost": "6.70",
              "prefix_cost": "46.41",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ]
          }
        },
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "softwarepirmam_hewadelivard_cscart_4.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 3,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "16.75",
              "eval_cost": "0.34",
              "prefix_cost": "69.86",
              "data_read_per_join": "10K"
            },
            "used_columns": [
              "category_id",
              "storefront_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "((`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`storefront_id` in (0,1)) and ((`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`usergroup_ids`))) and (`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`status` in ('A','H')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids
8381 573M
9714 369M
10021 660M
10030 662M
10031 662M
10041 574M
10044 449M
10045 466M
10046 449M
10064 372M
10067 372M
10070 587M
10072 587M
10076 443M
10094 369M
10096 328,402M
10099 424M
10106 492M
10107 424M
10108 492M
10123 575M
10149 372M
10153 378M
10155 384M
10158 578M
10162 492M
10163 474M
10164 578M
10165 492M
10166 492M
10168 378M
10169 575M
10170 474M
10173 372M
10184 467M
10203 378M
10220 459M
10231 459M
10235 394M
10240 578M
10241 466M
10242 424M
10245 372,250M
10246 492M
10251 466M
10252 466M
10253 459M
10256 424M
10257 459M
10258 578M
10259 578M
10260 459M
10262 340M
10263 474M
10266 347M
10268 459M
10269 459M
10270 459M
10271 459M
10279 459M
10280 459M
10281 459M
10296 459M
10297 384M
10298 378M