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 (
    89759, 90742, 91149, 91150, 86480, 86756, 
    82799, 82800, 82872, 82873, 82945, 
    82946, 83255, 83257, 83262, 83264, 
    85348, 86655, 86656, 86724, 86725, 
    84494, 84560, 85073, 85159, 85205, 
    85251, 82613, 83416, 82797, 82870, 
    82943, 83252, 83259, 84804, 84805, 
    84822, 84823, 84834, 84835, 86516, 
    86792, 91089, 91175, 91230, 83031, 
    83033, 83588, 83590, 90867, 90869, 
    90946, 90948, 82623, 83012, 83013, 
    83488, 83544, 83545, 90845, 90846, 
    90924, 90925, 85070, 85156, 85202, 
    85248, 85113, 88895, 90823, 91464, 
    91465, 91468, 91469, 83233, 83234, 
    83028, 83581, 90012, 90740, 90741, 
    90864, 90943, 82843, 82916, 82989, 
    83473, 83481, 85110, 84510, 84514, 
    84576, 84580, 83293, 83300, 84884
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00235

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "103.61"
    },
    "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": 182,
            "rows_produced_per_join": 182,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "18.53",
              "eval_cost": "18.20",
              "prefix_cost": "36.73",
              "data_read_per_join": "2K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (89759,90742,91149,91150,86480,86756,82799,82800,82872,82873,82945,82946,83255,83257,83262,83264,85348,86655,86656,86724,86725,84494,84560,85073,85159,85205,85251,82613,83416,82797,82870,82943,83252,83259,84804,84805,84822,84823,84834,84835,86516,86792,91089,91175,91230,83031,83033,83588,83590,90867,90869,90946,90948,82623,83012,83013,83488,83544,83545,90845,90846,90924,90925,85070,85156,85202,85248,85113,88895,90823,91464,91465,91468,91469,83233,83234,83028,83581,90012,90740,90741,90864,90943,82843,82916,82989,83473,83481,85110,84510,84514,84576,84580,83293,83300,84884))"
          }
        },
        {
          "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": 9,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "45.50",
              "eval_cost": "0.91",
              "prefix_cost": "100.43",
              "data_read_per_join": "23K"
            },
            "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": 9,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "2.28",
              "eval_cost": "0.91",
              "prefix_cost": "103.61",
              "data_read_per_join": "145"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
82613 7170,7171M 0
82623 7170,7171M 0
82797 7170,7191M 0
82799 7170,7191M 0
82800 7170,7191M 0
82843 7170,7171M 0
82870 7170,7191M 0
82872 7170,7191M 0
82873 7170,7191M 0
82916 7170,7171M 0
82943 7170,7191M 0
82945 7170,7191M 0
82946 7170,7191M 0
82989 7170,7171M 0
83012 7170,7191M 0
83013 7170,7191M 0
83028 7170,7171M 0
83031 7170,7171M 0
83033 7170,7171M 0
83233 7170,7171M 0
83234 7170,7171M 0
83252 7170,7191M 0
83255 7170,7191M 0
83257 7170,7191M 0
83259 7170,7191M 0
83262 7170,7191M 0
83264 7170,7191M 0
83293 7170,7192M 0
83300 7170,7192M 0
83416 7170,7171M 0
83473 7170,7171M 0
83481 7170,7171M 0
83488 7170,7171M 0
83544 7170,7191M 0
83545 7170,7191M 0
83581 7170,7171M 0
83588 7170,7171M 0
83590 7170,7171M 0
84494 7223M
84510 7170,7201M 0
84514 7170,7191M 0
84560 7223M
84576 7170,7201M 0
84580 7170,7191M 0
84804 7170,7191M 0
84805 7170,7191M 0
84822 7170,7191M 0
84823 7170,7191M 0
84834 7170,7191M 0
84835 7170,7191M 0
84884 7170,7191M 0
85070 7170,7171M 0
85073 7170,7171M 0
85110 7170,7171M 0
85113 7170,7171M 0
85156 7170,7171M 0
85159 7170,7171M 0
85202 7170,7171M 0
85205 7170,7171M 0
85248 7170,7171M 0
85251 7170,7171M 0
85348 7192M
86480 7170,7171M 0
86516 7192M
86655 7192M
86656 7192M
86724 7192M
86725 7192M
86756 7170,7171M 0
86792 7192M
88895 7170,7191M 0
89759 7192M
90012 7170,7191M 0
90740 7170,7191M 0
90741 7170,7191M 0
90742 7170,7191M 0
90823 7170,7191M 0
90845 7191,7170M 0
90846 7191,7170M 0
90864 7171,7170M 0
90867 7171,7170M 0
90869 7171,7170M 0
90924 7191,7170M 0
90925 7191,7170M 0
90943 7171,7170M 0
90946 7171,7170M 0
90948 7171,7170M 0
91089 7191,7170M 0
91149 7171,7170M 0
91150 7171,7170M 0
91175 7191,7170M 0
91230 7191,7170M 0
91464 7191,7170M 0
91465 7191,7170M 0
91468 7191,7170M 0
91469 7191,7170M 0