SELECT 
  jmj_products_categories.product_id, 
  GROUP_CONCAT(
    IF(
      jmj_products_categories.link_type = "M", 
      CONCAT(
        jmj_products_categories.category_id, 
        "M"
      ), 
      jmj_products_categories.category_id
    )
  ) AS category_ids, 
  product_position_source.position AS position 
FROM 
  jmj_products_categories 
  INNER JOIN jmj_categories ON jmj_categories.category_id = jmj_products_categories.category_id 
  AND jmj_categories.storefront_id IN (0, 1) 
  AND (
    jmj_categories.usergroup_ids = '' 
    OR FIND_IN_SET(0, jmj_categories.usergroup_ids) 
    OR FIND_IN_SET(1, jmj_categories.usergroup_ids)
  ) 
  AND jmj_categories.status IN ('A', 'H') 
  LEFT JOIN jmj_products_categories AS product_position_source ON jmj_products_categories.product_id = product_position_source.product_id 
  AND product_position_source.category_id = 20 
WHERE 
  jmj_products_categories.product_id IN (
    1676, 811, 812, 891, 892, 893, 929, 930, 
    982, 950, 955, 957, 959, 961, 964, 966, 
    834, 835, 836, 837, 838, 839, 840, 841, 
    842, 843, 845, 846, 847, 849, 850, 851, 
    852, 853, 854, 855, 859, 860, 861, 910, 
    916, 1531, 1534, 1439
  ) 
GROUP BY 
  jmj_products_categories.product_id

Query time 0.01104

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "64.51"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "2.34"
      },
      "nested_loop": [
        {
          "table": {
            "table_name": "jmj_categories",
            "access_type": "ALL",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "rows_examined_per_scan": 120,
            "rows_produced_per_join": 4,
            "filtered": "4.00",
            "cost_info": {
              "read_cost": "28.46",
              "eval_cost": "0.96",
              "prefix_cost": "29.42",
              "data_read_per_join": "18K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`jmj_test`.`jmj_categories`.`storefront_id` in (0,1)) and ((`jmj_test`.`jmj_categories`.`usergroup_ids` = '') or find_in_set(0,`jmj_test`.`jmj_categories`.`usergroup_ids`) or find_in_set(1,`jmj_test`.`jmj_categories`.`usergroup_ids`)) and (`jmj_test`.`jmj_categories`.`status` in ('A','H')))"
          }
        },
        {
          "table": {
            "table_name": "jmj_products_categories",
            "access_type": "ref",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "jmj_test.jmj_categories.category_id"
            ],
            "rows_examined_per_scan": 5,
            "rows_produced_per_join": 2,
            "filtered": "9.73",
            "index_condition": "(`jmj_test`.`jmj_products_categories`.`product_id` in (1676,811,812,891,892,893,929,930,982,950,955,957,959,961,964,966,834,835,836,837,838,839,840,841,842,843,845,846,847,849,850,851,852,853,854,855,859,860,861,910,916,1531,1534,1439))",
            "cost_info": {
              "read_cost": "25.15",
              "eval_cost": "0.47",
              "prefix_cost": "59.37",
              "data_read_per_join": "37"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ]
          }
        },
        {
          "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",
              "jmj_test.jmj_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 2,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "2.34",
              "eval_cost": "0.47",
              "prefix_cost": "62.17",
              "data_read_per_join": "37"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
811 20M 0
812 20M 0
834 20M 0
835 20M 0
836 20M 0
837 20M 0
838 20M 0
839 20M 0
840 20M 0
841 20M 0
842 20M 0
843 20M 0
845 20M 0
846 20M 0
847 20M 0
849 20M 0
850 20M 0
851 20M 0
852 20M 0
853 20M 0
854 20M 0
855 20M 0
859 20M 0
860 20M 0
861 20M 0
891 20M 0
892 20M 0
893 20M 0
910 20M 0
916 20M 0
929 20M 0
930 20M 0
950 20M 0
955 20M 0
957 20M 0
959 20M 0
961 20M 0
964 20M 0
966 20M 0
982 20M 0
1439 20M 0
1531 20M 0
1534 20M 0
1676 20M 0