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 (
    96688, 96689, 96690, 96691, 96692, 96694, 
    96695, 96696, 96697, 96708, 96718, 
    96719, 96720, 96724, 96734, 96735, 
    96738, 96739, 96743, 96746, 96747, 
    96749, 96751, 96758, 96759, 96764, 
    96775, 96778, 96779, 96780, 96789, 
    96790, 96791, 96839, 96840, 96841, 
    96918, 96919, 96985, 96986, 96987, 
    96988, 96989, 96990, 96991, 96992, 
    96993, 96994
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00170

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "57.05"
    },
    "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": 100,
            "rows_produced_per_join": 100,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "10.30",
              "eval_cost": "10.00",
              "prefix_cost": "20.30",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (96688,96689,96690,96691,96692,96694,96695,96696,96697,96708,96718,96719,96720,96724,96734,96735,96738,96739,96743,96746,96747,96749,96751,96758,96759,96764,96775,96778,96779,96780,96789,96790,96791,96839,96840,96841,96918,96919,96985,96986,96987,96988,96989,96990,96991,96992,96993,96994))"
          }
        },
        {
          "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": 5,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "25.00",
              "eval_cost": "0.50",
              "prefix_cost": "55.30",
              "data_read_per_join": "13K"
            },
            "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": 5,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "1.25",
              "eval_cost": "0.50",
              "prefix_cost": "57.05",
              "data_read_per_join": "80"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
96688 7313,7338,7219M
96689 7313,7338,7219M
96690 7313,7338,7219M
96691 7313,7338,7219M
96692 7313,7338,7219M
96694 7341,7342,7343,7157M
96695 7263M
96696 7263M
96697 7263M
96708 7301,7151M
96718 7301,7151M
96719 7301,7151M
96720 7301,7151M
96724 7301,7151M
96734 7301,7151M
96735 7301,7151M
96738 7301,7151M
96739 7303,7161M
96743 7301,7151M
96746 7162M
96747 7162M
96749 7305,7160M
96751 7162M
96758 7301,7151M
96759 7301,7151M
96764 7301,7151M
96775 7301,7151M
96778 7226,7225M
96779 7226,7225M
96780 7226,7225M
96789 7305,7160M
96790 7305,7160M
96791 7226,7225M
96839 7226,7225M
96840 7226,7225M
96841 7183,7283,7167M
96918 7183,7283,7167M
96919 7183,7283,7167M
96985 7303,7161M
96986 7303,7161M
96987 7303,7161M
96988 7303,7161M
96989 7303,7161M
96990 7303,7161M
96991 7303,7161M
96992 7303,7161M
96993 7303,7161M
96994 7303,7161M