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 = 7229 
WHERE 
  cscart_products_categories.product_id IN (
    99708, 99709, 99710, 99711, 99712, 99713, 
    99714, 99715, 99716, 99719, 99721, 
    99722, 99723, 99724, 99725, 99726, 
    99727, 99728, 99729, 99730, 99731, 
    99732, 99733, 99734, 99735, 99736, 
    99737, 99738, 99739, 99740, 99741, 
    99742, 99743, 99744, 99745, 99746, 
    99747, 99748, 99749, 99750, 99751, 
    99752, 99753, 99754, 99755, 99756, 
    99757, 99758, 99759, 99760, 99761, 
    99762, 99763, 99764, 99765, 99766, 
    99767, 99768, 99769, 99770, 99771, 
    99772, 99773, 99774, 99775, 99776, 
    99777, 99778, 99779, 99780, 99781, 
    99782, 99783, 99784, 99785, 99786, 
    99787, 99788, 99789, 99790, 99791, 
    99792, 99793, 99794, 99795, 99796, 
    99797, 99798, 99799, 99800, 99801, 
    99802, 99803, 99804, 99805, 99806
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00198

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "54.77"
    },
    "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": 96,
            "rows_produced_per_join": 96,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "9.89",
              "eval_cost": "9.60",
              "prefix_cost": "19.49",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (99708,99709,99710,99711,99712,99713,99714,99715,99716,99719,99721,99722,99723,99724,99725,99726,99727,99728,99729,99730,99731,99732,99733,99734,99735,99736,99737,99738,99739,99740,99741,99742,99743,99744,99745,99746,99747,99748,99749,99750,99751,99752,99753,99754,99755,99756,99757,99758,99759,99760,99761,99762,99763,99764,99765,99766,99767,99768,99769,99770,99771,99772,99773,99774,99775,99776,99777,99778,99779,99780,99781,99782,99783,99784,99785,99786,99787,99788,99789,99790,99791,99792,99793,99794,99795,99796,99797,99798,99799,99800,99801,99802,99803,99804,99805,99806))"
          }
        },
        {
          "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": 4,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "24.00",
              "eval_cost": "0.48",
              "prefix_cost": "53.09",
              "data_read_per_join": "12K"
            },
            "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": 4,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "1.20",
              "eval_cost": "0.48",
              "prefix_cost": "54.77",
              "data_read_per_join": "76"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
99708 7229M 0
99709 7229M 0
99710 7229M 0
99711 7229M 0
99712 7229M 0
99713 7229M 0
99714 7229M 0
99715 7229M 0
99716 7229M 0
99719 7229M 0
99721 7229M 0
99722 7229M 0
99723 7229M 0
99724 7229M 0
99725 7229M 0
99726 7229M 0
99727 7229M 0
99728 7229M 0
99729 7229M 0
99730 7229M 0
99731 7229M 0
99732 7229M 0
99733 7229M 0
99734 7229M 0
99735 7229M 0
99736 7229M 0
99737 7229M 0
99738 7229M 0
99739 7229M 0
99740 7229M 0
99741 7229M 0
99742 7229M 0
99743 7229M 0
99744 7229M 0
99745 7229M 0
99746 7229M 0
99747 7229M 0
99748 7229M 0
99749 7229M 0
99750 7229M 0
99751 7229M 0
99752 7229M 0
99753 7229M 0
99754 7229M 0
99755 7229M 0
99756 7229M 0
99757 7229M 0
99758 7229M 0
99759 7229M 0
99760 7229M 0
99761 7229M 0
99762 7229M 0
99763 7229M 0
99764 7229M 0
99765 7229M 0
99766 7229M 0
99767 7229M 0
99768 7229M 0
99769 7229M 0
99770 7229M 0
99771 7229M 0
99772 7229M 0
99773 7229M 0
99774 7229M 0
99775 7229M 0
99776 7229M 0
99777 7229M 0
99778 7229M 0
99779 7229M 0
99780 7229M 0
99781 7229M 0
99782 7229M 0
99783 7229M 0
99784 7229M 0
99785 7229M 0
99786 7229M 0
99787 7229M 0
99788 7229M 0
99789 7229M 0
99790 7229M 0
99791 7229M 0
99792 7229M 0
99793 7229M 0
99794 7229M 0
99795 7229M 0
99796 7229M 0
99797 7229M 0
99798 7229M 0
99799 7229M 0
99800 7229M 0
99801 7229M 0
99802 7229M 0
99803 7229M 0
99804 7229M 0
99805 7229M 0
99806 7229M 0