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 (
    59836, 59835, 59834, 59833, 59832, 59831, 
    59830, 59829, 59828, 59827, 59826, 
    59825, 59824, 59823, 59822, 59821, 
    59820, 59819, 59818, 59817, 59816, 
    59815, 59814, 59813, 59812, 59811, 
    59810, 59809
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00052

Explain
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cscart_products_categories range PRIMARY,pt pt 3 28 Using where; Using index
1 SIMPLE cscart_categories eq_ref PRIMARY,c_status,p_category_id PRIMARY 3 toolboxdigitalshop_dev.cscart_products_categories.category_id 1 Using where

Result

product_id category_ids
59809 6M
59810 6M
59811 6M
59812 6M
59813 6M
59814 6M
59815 6M
59816 6M
59817 6M
59818 6M
59819 6M
59820 6M
59821 6M
59822 6M
59823 6M
59824 6M
59825 6M
59826 6M
59827 6M
59828 6M
59829 6M
59830 6M
59831 6M
59832 6M
59833 6M
59834 6M
59835 6M
59836 6M