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 = 7148 
WHERE 
  cscart_products_categories.product_id IN (
    94617, 94618, 94619, 94620, 94621, 94622, 
    94623, 94624, 94625, 94626, 94627, 
    94628, 94629, 94630, 94631, 94632, 
    94633, 94634, 94635, 94636, 94637, 
    94638, 94639, 94640, 94654, 94655, 
    94656, 94657, 94658, 94666, 94667, 
    94668, 94669, 94670, 94671, 94672, 
    94673, 94674, 94694, 94695, 94696, 
    94697, 94698, 94699, 94700, 94701, 
    94702, 94707, 94708, 94750, 94751, 
    94752, 94753, 94754, 94755, 94756, 
    94757, 94758, 94759, 94760, 94761, 
    94762, 94763, 94764, 94765, 94816, 
    94822, 94839, 94840, 94841, 94844, 
    94845, 94846, 94847, 94848, 94950, 
    94951, 94952, 94953, 94954, 94955, 
    94958, 95310, 95311, 95314, 95317, 
    95319, 95320, 95361, 95362, 95363, 
    95364, 95365, 95366, 95367, 95368
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00107

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "93.96"
    },
    "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": 165,
            "rows_produced_per_join": 165,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "16.82",
              "eval_cost": "16.50",
              "prefix_cost": "33.32",
              "data_read_per_join": "2K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (94617,94618,94619,94620,94621,94622,94623,94624,94625,94626,94627,94628,94629,94630,94631,94632,94633,94634,94635,94636,94637,94638,94639,94640,94654,94655,94656,94657,94658,94666,94667,94668,94669,94670,94671,94672,94673,94674,94694,94695,94696,94697,94698,94699,94700,94701,94702,94707,94708,94750,94751,94752,94753,94754,94755,94756,94757,94758,94759,94760,94761,94762,94763,94764,94765,94816,94822,94839,94840,94841,94844,94845,94846,94847,94848,94950,94951,94952,94953,94954,94955,94958,95310,95311,95314,95317,95319,95320,95361,95362,95363,95364,95365,95366,95367,95368))"
          }
        },
        {
          "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": 8,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "41.25",
              "eval_cost": "0.83",
              "prefix_cost": "91.07",
              "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": "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": 8,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "2.06",
              "eval_cost": "0.83",
              "prefix_cost": "93.96",
              "data_read_per_join": "132"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
94617 7194M
94618 7194M
94619 7263M
94620 7263M
94621 7263M
94622 7263M
94623 7263M
94624 7263M
94625 7263M
94626 7263M
94627 7263M
94628 7263M
94629 7263M
94630 7263M
94631 7263M
94632 7263M
94633 7263M
94634 7263M
94635 7263M
94636 7263M
94637 7263M
94638 7263M
94639 7263M
94640 7263M
94654 7194M
94655 7194M
94656 7194M
94657 7194M
94658 7194M
94666 7194M
94667 7194M
94668 7194M
94669 7194M
94670 7194M
94671 7263M
94672 7263M
94673 7263M
94674 7263M
94694 7305,7160M
94695 7305,7160M
94696 7301,7151M
94697 7301,7151M
94698 7305,7160M
94699 7305,7160M
94700 7305,7160M
94701 7305,7160M
94702 7305,7160M
94707 7303,7161M
94708 7303,7161M
94750 7313,7338,7219M
94751 7341,7342,7343,7157M
94752 7341,7342,7343,7157M
94753 7341,7342,7343,7157M
94754 7341,7342,7343,7157M
94755 7341,7342,7343,7157M
94756 7341,7342,7343,7157M
94757 7341,7342,7343,7157M
94758 7341,7342,7343,7157M
94759 7313,7338,7219M
94760 7313,7338,7219M
94761 7313,7338,7219M
94762 7341,7342,7343,7157M
94763 7313,7338,7219M
94764 7341,7342,7343,7157M
94765 7313,7338,7219M
94816 7313,7338,7219M
94822 7263M
94839 7265,7247M
94840 7265,7247M
94841 7265,7247M
94844 7263M
94845 7263M
94846 7263M
94847 7263M
94848 7263M
94950 7313,7338,7219M
94951 7313,7338,7219M
94952 7263M
94953 7263M
94954 7263M
94955 7263M
94958 7183,7283,7167M
95310 7263M
95311 7263M
95314 7194M
95317 7263M
95319 7265,7247M
95320 7263M
95361 7263M
95362 7263M
95363 7263M
95364 7263M
95365 7265,7247M
95366 7265,7247M
95367 7265,7247M
95368 7265,7247M