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.company_id = 3 
  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 (
    8862, 8860, 9845, 9853, 9843, 10065, 
    10101, 10172, 8878, 3315, 381, 480, 
    10067, 9851, 9842, 10063, 8861, 9849, 
    10076, 10945, 8864, 479, 10219, 3317, 
    9848, 8880, 8875, 8869, 8886, 9838, 
    8891, 10211, 8870, 9850, 8868, 10173, 
    8887, 8884, 10213, 10220, 10078, 8863, 
    9839, 10174, 8873, 9855, 8894, 10212, 
    8885, 8893, 8871, 10210, 9822, 3316, 
    8888, 9821, 8877, 9823, 10066, 10095, 
    10206, 10713, 9824, 10208, 556, 9854, 
    10139, 9844, 9840, 10946, 10096, 9841, 
    557, 10138, 558, 9852, 10217, 10142, 
    10141, 10140
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00861

Explain
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cscart_products_categories range PRIMARY,pt,product_id_idx,category_id_idx,product_category_idx,category_product_idx pt 3 676 Using index condition
1 SIMPLE cscart_categories eq_ref PRIMARY,c_status,p_category_id,idx_category_id PRIMARY 3 mahm3t_cs443.cscart_products_categories.category_id 1 Using where

Result

product_id category_ids
381 936
479 814,1006
480 814,1006
556 973
557 973
558 973
3315 971
3316 971
3317 971
8860 747,961,963,966
8861 747,961,963,967
8862 747,961,964,966
8863 747,961,964,967
8864 747,961,963,966
8868 747,961,964,966
8869 747,961,964,966
8870 747,961,964,966
8871 747,961,963,966
8873 747,961,964,966
8875 747,961,963,966,970
8877 747,961,964,966,970
8878 747,962,963,966
8880 747,962,963,966
8884 747,962,964,966
8885 747,962,964,966
8886 747,962,964,966
8887 747,962,964,966
8888 747,962,963,966
8891 747,962,963,966,970
8893 747,962,964,966,970
8894 747,962,964,966,970
9821 747,961,964,966
9822 747,962,964,966
9823 747,961,964,967
9824 747,962,964,967
9838 814,1002
9839 814,1002
9840 814,1002
9841 814,1002
9842 814,1001,1002
9843 814,1001
9844 814,1001
9845 1001,814
9848 814,1003
9849 814,1005
9850 814,1009
9851 814,1009
9852 814,1009
9853 814,1005
9854 814,1005
9855 814,1005
10063 973
10065 973
10066 973
10067 973
10076 747,962,963,967
10078 747,961,964,966
10095 971
10096 971
10101 973
10138 935
10139 935
10140 935
10141 935
10142 935
10172 747,962,964,966
10173 747,962,964,967
10174 747,962,964,966
10206 747,961,964,966
10208 747,962,964,966
10210 747,961,964,966,970
10211 747,962,964,968
10212 747,961,964,966
10213 747,962,964,966
10217 935
10219 973
10220 973
10713 972
10945 747,961,964,966
10946 972