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 = 4 
WHERE 
  cscart_products_categories.product_id IN (
    5618, 5676, 5661, 5634, 5619, 6216, 2458, 
    2457, 2456, 2455, 2454, 2451, 2450, 
    6164, 2443, 2448, 2447, 2446, 2445, 
    2444, 85065, 85064, 78818, 78817, 2441, 
    2440, 2439, 5885, 2442, 78201, 5897, 
    2434, 2435, 2437, 2438, 2436, 6059, 
    2433, 2432, 2431, 2430, 6189, 6130, 
    6129, 6126, 6125, 6124, 6123, 6122, 
    5940, 2428, 2427, 2426, 2425, 6183, 
    2422, 2423, 2421, 2420, 2424, 2419, 
    2418, 2416, 2414, 6181, 5985, 77579, 
    6321, 26680, 6174, 6306, 2408, 2412, 
    2413, 2411, 2410, 2409, 2407, 6186, 
    103458
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00100

Explain
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE cscart_products_categories range PRIMARY,pt pt 3 86 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
2407 4M 0
2408 4M 0
2409 4M 0
2410 4M 0
2411 4M 0
2412 4M 0
2413 4M 0
2414 4M 0
2416 4M 0
2418 4M 0
2419 4M 0
2420 4M 0
2421 4M 0
2422 4M 0
2423 4M 0
2424 4M 0
2425 4M 0
2426 4M 0
2427 4M 0
2428 4M 0
2430 4M 0
2431 4M 0
2432 4M 0
2433 4M 0
2434 4M 0
2435 4M 0
2436 4M 0
2437 4M 0
2438 4M 0
2439 4M 0
2440 4M 0
2441 4M 0
2442 4M 0
2443 4M 0
2444 4M 0
2445 4M 0
2446 4M 0
2447 4M 0
2448 4M 0
2450 4M 0
2451 4M 0
2454 21,4M 0
2455 4M 0
2456 4M 0
2457 4M 0
2458 4M 0
5618 4M 0
5619 4M 0
5634 29,4M 0
5661 4M 0
5676 29,4M 0
5885 4M 0
5897 4M 0
5940 29,4M 0
5985 4M 0
6059 4M 0
6122 4M 0
6123 4M 0
6124 4M 0
6125 4M 0
6126 4M 0
6129 4M 0
6130 4M 0
6164 4M 0
6174 4M 0
6181 4M 0
6183 30,4M 0
6186 4M 0
6189 4M 0
6216 4M 0
6306 4M 0
6321 4M 0
26680 29,4M 0
77579 4M 0
78201 4M 0
78817 4M 0
78818 4M 0
85064 4M 0
85065 4M 0
103458 4M 0