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 (
    38067, 38037, 38036, 38034, 38033, 38032, 
    38031, 38030, 38029, 38028, 38027, 
    38026, 38025, 38022, 38021, 38020, 
    38019, 38018, 38017, 38016, 38015, 
    38014, 38013, 38012, 38011, 38010, 
    38009, 38008, 38007, 38006, 38005, 
    38004, 38003, 38002, 38001, 38000, 
    37999, 37998, 37997, 37996, 37995, 
    37994, 37993, 37992, 37991, 37990, 
    37989, 40283, 38872, 38159, 79896, 
    38226, 38078, 38077, 38076, 37988, 
    37987, 37986, 38458, 38423, 38422, 
    38421, 38420, 38419, 38418, 38417, 
    38400, 38399, 38244, 38227, 38172, 
    37985, 40512, 38181, 38180, 40355, 
    38884, 38062, 38043, 38042
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00086

Explain
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cscart_products_categories range PRIMARY,pt pt 3 82 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
37985 22M 0
37986 22M 0
37987 22M 0
37988 22M 0
37989 22M 0
37990 22M 0
37991 22M 0
37992 22M 0
37993 22M 0
37994 22M 0
37995 22M 0
37996 22M 0
37997 22M 0
37998 22M 0
37999 22M 0
38000 22M 0
38001 22M 0
38002 22M 0
38003 22M 0
38004 22M 0
38005 22M 0
38006 22M 0
38007 22M 0
38008 22M 0
38009 22M 0
38010 22M 0
38011 22M 0
38012 22M 0
38013 22M 0
38014 22M 0
38015 22M 0
38016 22M 0
38017 22M 0
38018 22M 0
38019 22M 0
38020 22M 0
38021 22M 0
38022 22M 0
38025 22M 0
38026 22M 0
38027 22M 0
38028 22M 0
38029 22M 0
38030 22M 0
38031 22M 0
38032 22M 0
38033 22M 0
38034 22M 0
38036 22M 0
38037 22M 0
38042 22M 0
38043 22M 0
38062 22M 0
38067 22M 0
38076 22M 0
38077 22M 0
38078 22M 0
38159 22M 0
38172 22M 0
38180 33,22M 0
38181 33,22M 0
38226 22M 0
38227 22M 0
38244 22M 0
38399 22M 0
38400 22M 0
38417 22M 0
38418 22M 0
38419 22M 0
38420 22M 0
38421 22M 0
38422 22M 0
38423 22M 0
38458 22M 0
38872 22M 0
38884 22M 0
40283 22M 0
40355 22M 0
40512 22M 0
79896 22M 0