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 (
    1, 228, 8, 9, 10, 71, 4, 1549, 5851, 1550, 
    1548, 5737, 5995, 5728, 5879, 5968, 
    5920, 1551, 5876, 5902, 5860, 1546, 
    5846, 5897, 5880, 5782, 5985, 5784, 
    1547, 5767, 5780, 5844, 5764, 5872, 
    5971, 5841, 5768, 5835, 5910, 5873, 
    5853, 5901, 8266, 5763, 5855, 5921, 
    5883, 5904, 8265, 5769, 5772, 8267, 
    5886, 5906, 5996, 5783, 5913, 5781, 
    5842, 5840, 5986, 8264, 5770, 5916, 
    5865, 5867, 5907, 5771, 5903, 5776, 
    5889, 5874, 5834, 5878, 5875, 5877, 
    5905, 5963, 5863, 5909
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00297

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "163.21"
    },
    "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": 179,
            "rows_produced_per_join": 179,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (1,228,8,9,10,71,4,1549,5851,1550,1548,5737,5995,5728,5879,5968,5920,1551,5876,5902,5860,1546,5846,5897,5880,5782,5985,5784,1547,5767,5780,5844,5764,5872,5971,5841,5768,5835,5910,5873,5853,5901,8266,5763,5855,5921,5883,5904,8265,5769,5772,8267,5886,5906,5996,5783,5913,5781,5842,5840,5986,8264,5770,5916,5865,5867,5907,5771,5903,5776,5889,5874,5834,5878,5875,5877,5905,5963,5863,5909))",
            "cost_info": {
              "read_cost": "82.66",
              "eval_cost": "17.90",
              "prefix_cost": "100.56",
              "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": 8,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "44.75",
              "eval_cost": "0.90",
              "prefix_cost": "163.21",
              "data_read_per_join": "28K"
            },
            "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
1 174,166,372,453,454,190M
4 166,174,372,453,454,190M
8 166,174,372,453,454,190M
9 174,166,372,454,453,190M
10 174,166,372,454,453,190M
71 453,454,166,174,190M
228 453,454,372,174,166,190M
1546 329,166,347M
1547 329,166,347M
1548 170,166,358M
1549 170,166,358M
1550 170,166,358M
1551 170,166,358M
5728 461,372,462M
5737 461,372,462M
5763 572,372,582M
5764 572,372,582M
5767 454,453,372,174,166,190M
5768 170,166,358M
5769 466,372,579M
5770 372,583M
5771 372,583M
5772 372,583M
5776 372,583M
5780 372,583M
5781 372,583M
5782 372,583M
5783 372,583M
5784 372,583M
5834 372,583M
5835 372,583M
5840 372,583M
5841 372,583M
5842 372,583M
5844 372,583M
5846 372,583M
5851 372,583M
5853 372,583M
5855 572,372,582M
5860 572,372,582M
5863 572,372,582M
5865 572,372,582M
5867 572,372,582M
5872 572,372,582M
5873 572,372,582M
5874 466,372,579M
5875 466,372,579M
5876 466,372,579M
5877 466,372,579M
5878 466,372,579M
5879 466,372,579M
5880 566,372,595M
5883 566,372,595M
5886 566,372,595M
5889 566,372,595M
5897 566,372,595M
5901 566,372,595M
5902 566,372,595M
5903 566,372,595M
5904 566,372,595M
5905 595M
5906 595M
5907 595M
5909 595M
5910 595M
5913 584M
5916 584M
5920 584M
5921 584M
5963 594M
5968 593M
5971 454,190M
5985 454,190M
5986 454,190M
5995 358M
5996 358M
8264 454,190M
8265 454,190M
8266 454,190M
8267 454,190M