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 = 27 
WHERE 
  cscart_products_categories.product_id IN (
    878, 877, 879, 876, 870, 891, 869, 890, 
    871, 892, 277, 785, 784, 1081, 1079, 
    1080, 1078, 1082, 1083, 1077, 248, 919, 
    269, 821, 822, 278, 279, 302, 303, 720, 
    986, 921, 922, 920, 923, 960, 674, 679, 
    948, 678, 526, 677, 680, 527, 959, 676, 
    675, 896, 881, 894, 882, 895, 893, 950, 
    957, 949, 956, 953, 954, 951, 952, 958, 
    1090, 955, 335, 334, 156, 336, 961, 965, 
    963, 964, 962, 966, 219, 270, 1302, 272, 
    273, 274, 973, 223, 222, 160, 194, 164, 
    174, 158, 183, 192, 188, 163, 172, 184, 
    173, 191
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00296

JSON explain

{
  "query_block": {
    "select_id": 1,
    "table": {
      "table_name": "cscart_products_categories",
      "access_type": "range",
      "possible_keys": ["PRIMARY", "pt"],
      "key": "pt",
      "key_length": "3",
      "used_key_parts": ["product_id"],
      "rows": 97,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (878,877,879,876,870,891,869,890,871,892,277,785,784,1081,1079,1080,1078,1082,1083,1077,248,919,269,821,822,278,279,302,303,720,986,921,922,920,923,960,674,679,948,678,526,677,680,527,959,676,675,896,881,894,882,895,893,950,957,949,956,953,954,951,952,958,1090,955,335,334,156,336,961,965,963,964,962,966,219,270,1302,272,273,274,973,223,222,160,194,164,174,158,183,192,188,163,172,184,173,191)"
    },
    "table": {
      "table_name": "cscart_categories",
      "access_type": "eq_ref",
      "possible_keys": ["PRIMARY", "c_status", "p_category_id"],
      "key": "PRIMARY",
      "key_length": "3",
      "used_key_parts": ["category_id"],
      "ref": ["bacpvdev_db.cscart_products_categories.category_id"],
      "rows": 1,
      "filtered": 100,
      "attached_condition": "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')"
    },
    "table": {
      "table_name": "product_position_source",
      "access_type": "eq_ref",
      "possible_keys": ["PRIMARY", "pt"],
      "key": "PRIMARY",
      "key_length": "6",
      "used_key_parts": ["category_id", "product_id"],
      "ref": ["const", "bacpvdev_db.cscart_products_categories.product_id"],
      "rows": 1,
      "filtered": 100
    }
  }
}

Result

product_id category_ids position
156 27M 0
158 27M 0
160 27M 0
163 27M 0
164 27M 0
172 27M 0
173 27M 0
174 27M 0
183 27M 0
184 27M 0
188 27M 0
191 27M 0
192 27M 0
194 27M 0
219 27M 0
222 27M 0
223 27M 0
248 27M 0
269 27M 0
270 27M 0
272 27M 0
273 27M 0
274 27M 0
277 27M 0
278 27M 0
279 27M 0
302 27M 0
303 27M 0
334 27M 0
335 27M 0
336 27M 0
526 27M 0
527 27M 0
674 27M 0
675 27M 0
676 27M 0
677 27M 0
678 27M 0
679 27M 0
680 27M 0
720 27M 0
784 27M 0
785 27M 0
821 27M 0
822 27M 0
869 27M 0
870 27M 0
871 27M 0
876 27M 0
877 27M 0
878 27M 0
879 27M 0
881 27M 0
882 27M 0
890 27M 0
891 27M 0
892 27M 0
893 27M 0
894 27M 0
895 27M 0
896 27M 0
919 27M 0
920 27M 0
921 27M 0
922 27M 0
923 27M 0
948 27M 0
949 27M 0
950 27M 0
951 27M 0
952 27M 0
953 27M 0
954 27M 0
955 27M 0
956 27M 0
957 27M 0
958 27M 0
959 27M 0
960 27M 0
961 27M 0
962 27M 0
963 27M 0
964 27M 0
965 27M 0
966 27M 0
973 27M 0
986 27M 0
1077 27M 0
1078 27M 0
1079 27M 0
1080 27M 0
1081 27M 0
1082 27M 0
1083 27M 0
1090 27M 0
1302 27M 0