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 = 7171 
WHERE 
  cscart_products_categories.product_id IN (
    83590, 90867, 90869, 90946, 90948, 82623, 
    83488, 85070, 85156, 85202, 85248, 
    85113, 83233, 83234, 83028, 83581, 
    90864, 90943, 82843, 82916, 82989, 
    83473, 83481, 85110, 85071, 85157, 
    85203, 85249, 83029, 83227, 83232, 
    83586, 90865, 90944, 85111, 86620, 
    86622, 86689, 86691, 83042, 83044, 
    90878, 90880, 90957, 90959, 84810, 
    84811, 84828
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00167

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "54.77"
    },
    "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": 96,
            "rows_produced_per_join": 96,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "9.89",
              "eval_cost": "9.60",
              "prefix_cost": "19.49",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (83590,90867,90869,90946,90948,82623,83488,85070,85156,85202,85248,85113,83233,83234,83028,83581,90864,90943,82843,82916,82989,83473,83481,85110,85071,85157,85203,85249,83029,83227,83232,83586,90865,90944,85111,86620,86622,86689,86691,83042,83044,90878,90880,90957,90959,84810,84811,84828))"
          }
        },
        {
          "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": "24.00",
              "eval_cost": "0.48",
              "prefix_cost": "53.09",
              "data_read_per_join": "12K"
            },
            "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.20",
              "eval_cost": "0.48",
              "prefix_cost": "54.77",
              "data_read_per_join": "76"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
82623 7170,7171M 0
82843 7170,7171M 0
82916 7170,7171M 0
82989 7170,7171M 0
83028 7170,7171M 0
83029 7170,7171M 0
83042 7170,7171M 0
83044 7170,7171M 0
83227 7170,7171M 0
83232 7170,7171M 0
83233 7170,7171M 0
83234 7170,7171M 0
83473 7170,7171M 0
83481 7170,7171M 0
83488 7170,7171M 0
83581 7170,7171M 0
83586 7170,7171M 0
83590 7170,7171M 0
84810 7170,7171M 0
84811 7170,7171M 0
84828 7170,7171M 0
85070 7170,7171M 0
85071 7170,7171M 0
85110 7170,7171M 0
85111 7170,7171M 0
85113 7170,7171M 0
85156 7170,7171M 0
85157 7170,7171M 0
85202 7170,7171M 0
85203 7170,7171M 0
85248 7170,7171M 0
85249 7170,7171M 0
86620 7170,7171M 0
86622 7170,7171M 0
86689 7170,7171M 0
86691 7170,7171M 0
90864 7171,7170M 0
90865 7171,7170M 0
90867 7171,7170M 0
90869 7171,7170M 0
90878 7171,7170M 0
90880 7171,7170M 0
90943 7171,7170M 0
90944 7171,7170M 0
90946 7171,7170M 0
90948 7171,7170M 0
90957 7171,7170M 0
90959 7171,7170M 0