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 = 7165 
WHERE 
  cscart_products_categories.product_id IN (
    83938, 84082, 82497, 90169, 90174, 90175, 
    91472, 90206, 90217, 90193, 84050, 
    84058, 90226, 82495, 90237, 90242, 
    90253, 90261, 91471, 90186, 85961, 
    82498, 86856, 89547, 89533, 90252, 
    90260, 82493, 82435, 87375, 85606, 
    82496, 85610, 89539, 85605, 90251, 
    90259, 90279, 90287, 90176, 90192, 
    90309, 90236, 90241, 82494, 87372, 
    89543, 82487, 85960, 89532, 90235, 
    90240, 89540, 82492, 90225, 90183, 
    90234, 90239, 87371, 90224, 90199, 
    89546, 89538, 90173, 90308, 89554, 
    90223, 90278, 90286, 91481, 90198, 
    85620, 85634, 91480, 89544, 85618, 
    89542, 85616, 85619, 85633, 90222, 
    82491, 89563, 90221, 90197, 85617, 
    82490, 85615, 90205, 90216, 90220, 
    82489, 90191, 90277, 91478, 91885
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.01581

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "129.62"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "5.83"
      },
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "ALL",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "rows_examined_per_scan": 208,
            "rows_produced_per_join": 8,
            "filtered": "4.00",
            "cost_info": {
              "read_cost": "20.72",
              "eval_cost": "0.83",
              "prefix_cost": "21.55",
              "data_read_per_join": "21K"
            },
            "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": "cscart_products_categories",
            "access_type": "ref",
            "possible_keys": [
              "PRIMARY",
              "link_type",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "nuie_scalesta_net.cscart_categories.category_id"
            ],
            "rows_examined_per_scan": 117,
            "rows_produced_per_join": 5,
            "filtered": "0.60",
            "cost_info": {
              "read_cost": "2.33",
              "eval_cost": "0.58",
              "prefix_cost": "121.75",
              "data_read_per_join": "93"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (83938,84082,82497,90169,90174,90175,91472,90206,90217,90193,84050,84058,90226,82495,90237,90242,90253,90261,91471,90186,85961,82498,86856,89547,89533,90252,90260,82493,82435,87375,85606,82496,85610,89539,85605,90251,90259,90279,90287,90176,90192,90309,90236,90241,82494,87372,89543,82487,85960,89532,90235,90240,89540,82492,90225,90183,90234,90239,87371,90224,90199,89546,89538,90173,90308,89554,90223,90278,90286,91481,90198,85620,85634,91480,89544,85618,89542,85616,85619,85633,90222,82491,89563,90221,90197,85617,82490,85615,90205,90216,90220,82489,90191,90277,91478,91885))"
          }
        },
        {
          "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": 5,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "1.46",
              "eval_cost": "0.58",
              "prefix_cost": "123.79",
              "data_read_per_join": "93"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
82435 7173M
82487 7173M
82489 7173M
82490 7173M
82491 7173M
82492 7174M
82493 7174M
82494 7174M
82495 7174M
82496 7174M
82497 7174M
82498 7174M
83938 7193M,7319
84050 7193M,7319
84058 7193M,7319
84082 7193M,7319
85605 7172M
85606 7172M
85610 7169M
85615 7175M
85616 7175M
85617 7175M
85618 7175M
85619 7175M
85620 7175M
85633 7177M
85634 7177M
85960 7193M,7319
85961 7193M,7319
86856 7149M,7182,7300
87371 7173M
87372 7173M
87375 7173M
89532 7172M
89533 7172M
89538 7174M
89539 7174M
89540 7174M
89542 7175M
89543 7175M
89544 7175M
89546 7175M
89547 7175M
89554 7177M
89563 7173M
90169 7193M,7319
90173 7193M,7319
90174 7193M,7319
90175 7193M,7319
90176 7193M,7319
90183 7193M,7319
90186 7193M,7319
90191 7193M,7319
90192 7193M,7319
90193 7193M,7319
90197 7193M,7319
90198 7193M,7319
90199 7193M,7319
90205 7193M,7319
90206 7193M,7319
90216 7193M,7319
90217 7193M,7319
90220 7193M,7319
90221 7193M,7319
90222 7193M,7319
90223 7193M,7319
90224 7193M,7319
90225 7193M,7319
90226 7193M,7319
90234 7193M,7319
90235 7193M,7319
90236 7193M,7319
90237 7193M,7319
90239 7193M,7319
90240 7193M,7319
90241 7193M,7319
90242 7193M,7319
90251 7193M,7319
90252 7193M,7319
90253 7193M,7319
90259 7193M,7319
90260 7193M,7319
90261 7193M,7319
90277 7193M,7319
90278 7193M,7319
90279 7193M,7319
90286 7193M,7319
90287 7193M,7319
90308 7193M,7319
90309 7193M,7319
91471 7174M
91472 7174M
91478 7173M
91480 7173M
91481 7173M
91885 7225M,7226