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 = 7170 
WHERE 
  cscart_products_categories.product_id IN (
    85396, 85447, 85498, 86463, 86464, 86739, 
    86740, 89740, 89741, 83228, 83229, 
    83230, 83231, 85328, 85329, 85425, 
    85426, 85476, 85477, 85527, 85528, 
    86605, 86606, 86674, 86675, 83458, 
    84299, 84300, 85042, 85043, 85090, 
    85176, 85222, 85268, 85345, 82842, 
    82915, 82988, 83066, 83067, 83472, 
    83480, 83619, 83620, 87312, 87313, 
    87324, 87325
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00145

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "46.82"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "link_type",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 82,
            "rows_produced_per_join": 82,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "8.49",
              "eval_cost": "8.20",
              "prefix_cost": "16.69",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (85396,85447,85498,86463,86464,86739,86740,89740,89741,83228,83229,83230,83231,85328,85329,85425,85426,85476,85477,85527,85528,86605,86606,86674,86675,83458,84299,84300,85042,85043,85090,85176,85222,85268,85345,82842,82915,82988,83066,83067,83472,83480,83619,83620,87312,87313,87324,87325))"
          }
        },
        {
          "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": [
              "nuie_scalesta_net.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 4,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "20.50",
              "eval_cost": "0.41",
              "prefix_cost": "45.39",
              "data_read_per_join": "10K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`nuie_scalesta_net`.`cscart_categories`.`storefront_id` in (0,1)) and ((`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids`))) and (`nuie_scalesta_net`.`cscart_categories`.`status` in ('A','H')))"
          }
        },
        {
          "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",
              "nuie_scalesta_net.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 4,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "1.03",
              "eval_cost": "0.41",
              "prefix_cost": "46.82",
              "data_read_per_join": "65"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
82842 7170,7171M 0
82915 7170,7171M 0
82988 7170,7171M 0
83066 7192M
83067 7192M
83228 7170,7171M 0
83229 7170,7171M 0
83230 7170,7171M 0
83231 7170,7171M 0
83458 7170,7191M 0
83472 7170,7171M 0
83480 7170,7171M 0
83619 7192M
83620 7192M
84299 7223M
84300 7223M
85042 7170,7191,7310M 0
85043 7170,7191,7310M 0
85090 7192M
85176 7192M
85222 7192M
85268 7192M
85328 7192M
85329 7192M
85345 7192M
85396 7192M
85425 7192M
85426 7192M
85447 7192M
85476 7192M
85477 7192M
85498 7192M
85527 7192M
85528 7192M
86463 7170,7191,7310M 0
86464 7170,7191,7310M 0
86605 7170,7191,7310M 0
86606 7170,7191,7310M 0
86674 7170,7191,7310M 0
86675 7170,7191,7310M 0
86739 7170,7191M 0
86740 7170,7191M 0
87312 7170,7171M 0
87313 7170,7171M 0
87324 7170,7171M 0
87325 7170,7171M 0
89740 7170,7191M 0
89741 7170,7191M 0