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 = 7338 
WHERE 
  cscart_products_categories.product_id IN (
    95574, 95575, 95578, 95579, 95580, 95581, 
    95587, 95588, 95589, 95590, 95591, 
    95629, 95630, 95631, 95632, 95633, 
    95634, 95635, 95636, 95637, 95641, 
    95642, 95643, 95644, 95647, 95648, 
    95649, 95650, 95651, 95652, 95935, 
    95938, 95939, 95942, 95943, 96341, 
    96342, 96343, 96344, 96345, 96346, 
    96347, 96348, 96602, 96603, 96606, 
    96608, 96610, 96612, 96613, 96616, 
    96617, 96618, 96619, 96625, 96626, 
    96627, 96628, 96629, 96668, 96669, 
    96670, 96671, 96672, 96673, 96674, 
    96675, 96676, 96680, 96681, 96682, 
    96683, 96686, 96687, 96688, 96689, 
    96690, 96691, 96692, 97874, 97883, 
    97884, 97885, 97887, 97889, 98421, 
    98424, 98425, 98426, 98428, 98432, 
    98434, 98436, 98437, 98438, 98442
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.01744

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "136.86"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "11.20"
      },
      "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": 11,
            "filtered": "1.14",
            "cost_info": {
              "read_cost": "2.33",
              "eval_cost": "1.12",
              "prefix_cost": "121.75",
              "data_read_per_join": "179"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (95574,95575,95578,95579,95580,95581,95587,95588,95589,95590,95591,95629,95630,95631,95632,95633,95634,95635,95636,95637,95641,95642,95643,95644,95647,95648,95649,95650,95651,95652,95935,95938,95939,95942,95943,96341,96342,96343,96344,96345,96346,96347,96348,96602,96603,96606,96608,96610,96612,96613,96616,96617,96618,96619,96625,96626,96627,96628,96629,96668,96669,96670,96671,96672,96673,96674,96675,96676,96680,96681,96682,96683,96686,96687,96688,96689,96690,96691,96692,97874,97883,97884,97885,97887,97889,98421,98424,98425,98426,98428,98432,98434,98436,98437,98438,98442))"
          }
        },
        {
          "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": 11,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "2.80",
              "eval_cost": "1.12",
              "prefix_cost": "125.67",
              "data_read_per_join": "179"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
95574 7219M,7313,7338 0
95575 7219M,7313,7338 0
95578 7219M,7313,7338 0
95579 7219M,7313,7338 0
95580 7219M,7313,7338 0
95581 7219M,7313,7338 0
95587 7219M,7313,7338 0
95588 7219M,7313,7338 0
95589 7219M,7313,7338 0
95590 7219M,7313,7338 0
95591 7219M,7313,7338 0
95629 7219M,7313,7338 0
95630 7219M,7313,7338 0
95631 7219M,7313,7338 0
95632 7219M,7313,7338 0
95633 7219M,7313,7338 0
95634 7219M,7313,7338 0
95635 7219M,7313,7338 0
95636 7219M,7313,7338 0
95637 7219M,7313,7338 0
95641 7219M,7313,7338 0
95642 7219M,7313,7338 0
95643 7219M,7313,7338 0
95644 7219M,7313,7338 0
95647 7219M,7313,7338 0
95648 7219M,7313,7338 0
95649 7219M,7313,7338 0
95650 7219M,7313,7338 0
95651 7219M,7313,7338 0
95652 7219M,7313,7338 0
95935 7219M,7313,7338 0
95938 7219M,7313,7338 0
95939 7219M,7313,7338 0
95942 7219M,7313,7338 0
95943 7219M,7313,7338 0
96341 7219M,7313,7338 0
96342 7219M,7313,7338 0
96343 7219M,7313,7338 0
96344 7219M,7313,7338 0
96345 7219M,7313,7338 0
96346 7219M,7313,7338 0
96347 7219M,7313,7338 0
96348 7219M,7313,7338 0
96602 7219M,7313,7338 0
96603 7219M,7313,7338 0
96606 7219M,7313,7338 0
96608 7219M,7313,7338 0
96610 7219M,7313,7338 0
96612 7219M,7313,7338 0
96613 7219M,7313,7338 0
96616 7219M,7313,7338 0
96617 7219M,7313,7338 0
96618 7219M,7313,7338 0
96619 7219M,7313,7338 0
96625 7219M,7313,7338 0
96626 7219M,7313,7338 0
96627 7219M,7313,7338 0
96628 7219M,7313,7338 0
96629 7219M,7313,7338 0
96668 7219M,7313,7338 0
96669 7219M,7313,7338 0
96670 7219M,7313,7338 0
96671 7219M,7313,7338 0
96672 7219M,7313,7338 0
96673 7219M,7313,7338 0
96674 7219M,7313,7338 0
96675 7219M,7313,7338 0
96676 7219M,7313,7338 0
96680 7219M,7313,7338 0
96681 7219M,7313,7338 0
96682 7219M,7313,7338 0
96683 7219M,7313,7338 0
96686 7219M,7313,7338 0
96687 7219M,7313,7338 0
96688 7219M,7313,7338 0
96689 7219M,7313,7338 0
96690 7219M,7313,7338 0
96691 7219M,7313,7338 0
96692 7219M,7313,7338 0
97874 7219M,7313,7338 0
97883 7219M,7313,7338 0
97884 7219M,7313,7338 0
97885 7219M,7313,7338 0
97887 7219M,7313,7338 0
97889 7219M,7313,7338 0
98421 7219M,7313,7338 0
98424 7219M,7313,7338 0
98425 7219M,7313,7338 0
98426 7219M,7313,7338 0
98428 7219M,7313,7338 0
98432 7219M,7313,7338 0
98434 7219M,7313,7338 0
98436 7219M,7313,7338 0
98437 7219M,7313,7338 0
98438 7219M,7313,7338 0
98442 7219M,7313,7338 0