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 = 25 
WHERE 
  cscart_products_categories.product_id IN (
    6612, 10171, 6611, 16473, 16469, 16405, 
    16463, 16461, 16421, 16445, 16432, 
    21717, 16411, 16420, 16443, 16406, 
    16544, 16410, 16577, 16419, 16476, 
    16474, 16490, 16429, 16431, 16451, 
    16475, 16500, 54979, 54978, 71348, 
    71385, 72178, 71357, 71382, 72171, 
    72175, 71360, 71363, 71366, 71373, 
    71379, 72157, 72163, 72164, 72168, 
    72181, 71351, 72160, 71354
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00234

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "118.31"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 92,
            "rows_produced_per_join": 92,
            "filtered": "100.00",
            "index_condition": "(`cscartdb`.`cscart_products_categories`.`product_id` in (6612,10171,6611,16473,16469,16405,16463,16461,16421,16445,16432,21717,16411,16420,16443,16406,16544,16410,16577,16419,16476,16474,16490,16429,16431,16451,16475,16500,54979,54978,71348,71385,72178,71357,71382,72171,72175,71360,71363,71366,71373,71379,72157,72163,72164,72168,72181,71351,72160,71354))",
            "cost_info": {
              "read_cost": "44.71",
              "eval_cost": "9.20",
              "prefix_cost": "53.91",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ]
          }
        },
        {
          "table": {
            "table_name": "product_position_source",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id",
              "product_id"
            ],
            "key_length": "6",
            "ref": [
              "const",
              "cscartdb.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 92,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "23.00",
              "eval_cost": "9.20",
              "prefix_cost": "86.11",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        },
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "cscartdb.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 4,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "23.00",
              "eval_cost": "0.46",
              "prefix_cost": "118.31",
              "data_read_per_join": "15K"
            },
            "used_columns": [
              "category_id",
              "storefront_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "((`cscartdb`.`cscart_categories`.`storefront_id` in (0,1)) and ((`cscartdb`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`cscartdb`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`cscartdb`.`cscart_categories`.`usergroup_ids`))) and (`cscartdb`.`cscart_categories`.`status` in ('A','H')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
6611 283,25M 0
6612 283,25M 0
10171 399,25M 0
16405 631,25M 0
16406 631,25M 0
16410 631,25M 0
16411 631,25M 0
16419 631,25M 0
16420 631,25M 0
16421 631,25M 0
16429 631,25M 0
16431 631,25M 0
16432 631,25M 0
16443 631,25M 0
16445 631,25M 0
16451 631,25M 0
16461 631,25M 0
16463 631,25M 0
16469 631,25M 0
16473 631,25M 0
16474 631,25M 0
16475 631,25M 0
16476 631,25M 0
16490 631,25M 0
16500 631,25M 0
16544 631,25M 0
16577 631,25M 0
21717 784,25M 0
54978 155,25M 0
54979 1273,25M 0
71348 1548,25M 0
71351 1548,25M 0
71354 1548,25M 0
71357 1548,25M 0
71360 1548,25M 0
71363 1548,25M 0
71366 1548,25M 0
71373 1548,25M 0
71379 1548,25M 0
71382 1548,25M 0
71385 1548,25M 0
72157 1548,25M 0
72160 1548,25M 0
72163 1548,25M 0
72164 1548,25M 0
72168 1548,25M 0
72171 1548,25M 0
72175 1548,25M 0
72178 1548,25M 0
72181 1548,25M 0