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, 
  product_position_source.position AS position 
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') 
  LEFT JOIN cscart_products_categories AS product_position_source ON cscart_products_categories.product_id = product_position_source.product_id 
  AND product_position_source.category_id = 22 
WHERE 
  cscart_products_categories.product_id IN (
    40629, 79914, 40775, 40774, 40621, 40620, 
    40616, 40948, 40187, 40186, 40185, 
    40779, 40778, 40231, 40174, 79928, 
    40167, 40166, 40165, 40531, 40773, 
    40772, 40157, 40156, 40152, 40151, 
    40150, 40069, 40111, 40110, 40857, 
    40106, 40102, 40101, 40099, 40098, 
    40097, 40096, 40088, 40087, 40081, 
    40092, 40007, 40006, 40005, 39997, 
    39994, 39982, 39980, 39977, 39976, 
    39975, 39974, 39973, 39972, 39971, 
    39970, 39969, 39968, 39967, 39966, 
    39962, 39950, 79918, 40105, 39991, 
    39960, 39923, 39916, 39907, 39906, 
    91051, 91050, 91049, 91048, 91047, 
    91046, 91045, 91044, 91043
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00101

Explain
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cscart_products_categories range PRIMARY,pt pt 3 91 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
1 SIMPLE product_position_source eq_ref PRIMARY,pt PRIMARY 6 const,toolboxdigitalshop_dev.cscart_products_categories.product_id 1

Result

product_id category_ids position
39906 22M 0
39907 22M 0
39916 22M 0
39923 22M 0
39950 22M 0
39960 22M 0
39962 22M 0
39966 22M 0
39967 22M 0
39968 22M 0
39969 22M 0
39970 22M 0
39971 22M 0
39972 22M 0
39973 22M 0
39974 22M 0
39975 22M 0
39976 22M 0
39977 22M 0
39980 22M 0
39982 22M 0
39991 22M 0
39994 22M 0
39997 22M 0
40005 22M 0
40006 22M 0
40007 22M 0
40069 22M 0
40081 22M 0
40087 22M 0
40088 22M 0
40092 22M 0
40096 22M 0
40097 22M 0
40098 22M 0
40099 22M 0
40101 22M 0
40102 22M 0
40105 22M 0
40106 22M 0
40110 22M 0
40111 22M 0
40150 22M 0
40151 22M 0
40152 22M 0
40156 22M 0
40157 22M 0
40165 22M 0
40166 22M 0
40167 22M 0
40174 22M 0
40185 22M 0
40186 22M 0
40187 22M 0
40231 22M 0
40531 22M 0
40616 22M 0
40620 22M 0
40621 22M 0
40629 22M 0
40772 22M 0
40773 22M 0
40774 21,22M 0
40775 21,22M 0
40778 22M 0
40779 22M 0
40857 22M 0
40948 22M 0
79914 22M 0
79918 22M 0
79928 22M 0
91043 33,22M 0
91044 33,22M 0
91045 33,22M 0
91046 33,22M 0
91047 33,22M 0
91048 33,22M 0
91049 33,22M 0
91050 33,22M 0
91051 33,22M 0