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 (
    8962, 8961, 8960, 9014, 9015, 10122, 
    10127, 10128, 10133, 10217, 10216, 
    10309, 10227, 10226, 10312, 10315, 
    10317, 10407, 10406, 10436, 10437, 
    10485, 10486, 10956, 10957, 10958, 
    10959, 10960, 11255, 11257, 11258, 
    11275, 11276, 11277, 11278, 11279, 
    11280, 11281, 11452, 11456, 11457, 
    11155, 11571
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00188

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "114.76"
    },
    "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": 130,
            "rows_produced_per_join": 130,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (8962,8961,8960,9014,9015,10122,10127,10128,10133,10217,10216,10309,10227,10226,10312,10315,10317,10407,10406,10436,10437,10485,10486,10956,10957,10958,10959,10960,11255,11257,11258,11275,11276,11277,11278,11279,11280,11281,11452,11456,11457,11155,11571))",
            "cost_info": {
              "read_cost": "56.26",
              "eval_cost": "13.00",
              "prefix_cost": "69.26",
              "data_read_per_join": "2K"
            },
            "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": 6,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "32.50",
              "eval_cost": "0.65",
              "prefix_cost": "114.76",
              "data_read_per_join": "20K"
            },
            "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
8960 583M
8961 583M
8962 583M
9014 584M
9015 584M
10122 372,454,453,190,174,166M
10127 372,454,453,190,174,166M
10128 372,454,453,190,174,166M
10133 372,454,453,190,174,166M
10216 190,454,174,372,453,166M
10217 174,453,454,372,190,166M
10226 459M
10227 459M
10309 190,454,174,372,453,166M
10312 372,454,453,190,174,166M
10315 372,454,453,190,174,166M
10317 372,454,453,190,174,166M
10406 574M
10407 574M
10436 587M
10437 587M
10485 574M
10486 574M
10956 667,666M
10957 667,666M
10958 667,666M
10959 667,666M
10960 667,666M
11155 581M
11255 556,554M
11257 556,554M
11258 556,554M
11275 556,554M
11276 556,554M
11277 556,554M
11278 556,554M
11279 556,554M
11280 556,554M
11281 556,554M
11452 599M
11456 599M
11457 599M
11571 581M