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 = 2916 
WHERE 
  cscart_products_categories.product_id IN (
    349736, 349943, 358420, 355716, 351470, 
    352364, 354432, 354737, 358745, 349826, 
    352111, 352597, 354793, 355136, 358867, 
    359065, 352613, 354825, 357476, 354601, 
    356325, 359419, 351436, 352333, 354866, 
    355987, 356197, 351538, 351595, 354545, 
    355124, 355811, 358485, 358866, 349896, 
    351591, 352307, 355889, 352480, 352507, 
    356296, 356615, 357642, 358415, 351551, 
    355742, 357553, 359053, 351448, 352528, 
    354847, 355899, 356640, 359091, 352724, 
    354785, 352671, 358340, 352149, 352672, 
    353117, 357503, 352217, 352560, 356354, 
    356586, 352556, 355069, 355667, 352670, 
    349905, 356488, 358706, 349816, 351266, 
    352110, 352212, 352475, 352344, 352504, 
    352721, 354787, 355097, 355903, 355937, 
    356238, 356448, 351347, 351354, 351820, 
    352134, 352727, 354376, 356478, 358976, 
    359011, 352476, 352557, 352594, 352756
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00349

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "167.15"
    },
    "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": "21.15",
              "eval_cost": "20.00",
              "prefix_cost": "41.15",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`webmarco`.`cscart_products_categories`.`product_id` in (349736,349943,358420,355716,351470,352364,354432,354737,358745,349826,352111,352597,354793,355136,358867,359065,352613,354825,357476,354601,356325,359419,351436,352333,354866,355987,356197,351538,351595,354545,355124,355811,358485,358866,349896,351591,352307,355889,352480,352507,356296,356615,357642,358415,351551,355742,357553,359053,351448,352528,354847,355899,356640,359091,352724,354785,352671,358340,352149,352672,353117,357503,352217,352560,356354,356586,352556,355069,355667,352670,349905,356488,358706,349816,351266,352110,352212,352475,352344,352504,352721,354787,355097,355903,355937,356238,356448,351347,351354,351820,352134,352727,354376,356478,358976,359011,352476,352557,352594,352756))"
          }
        },
        {
          "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": [
              "webmarco.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 5,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "100.00",
              "eval_cost": "1.00",
              "prefix_cost": "161.15",
              "data_read_per_join": "29K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`webmarco`.`cscart_categories`.`storefront_id` in (0,1)) and ((`webmarco`.`cscart_categories`.`usergroup_ids` = '') or find_in_set(0,`webmarco`.`cscart_categories`.`usergroup_ids`) or find_in_set(1,`webmarco`.`cscart_categories`.`usergroup_ids`)) and (`webmarco`.`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",
              "webmarco.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 5,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "5.00",
              "eval_cost": "1.00",
              "prefix_cost": "167.15",
              "data_read_per_join": "80"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
349736 2916M 0
349816 2916M 0
349826 2916M 0
349896 2916M 0
349905 2916M 0
349943 2916M 0
351266 2916M 0
351347 2916M 0
351354 2916M 0
351436 2916M 0
351448 2916M 0
351470 2916M 0
351538 2916M 0
351551 2916M 0
351591 2916M 0
351595 2916M 0
351820 2916M 0
352110 2916M 0
352111 2916M 0
352134 2916M 0
352149 2916M 0
352212 2916M 0
352217 2916M 0
352307 2916M 0
352333 2916M 0
352344 2916M 0
352364 2916M 0
352475 2916M 0
352476 2916M 0
352480 2916M 0
352504 2916M 0
352507 2916M 0
352528 2916M 0
352556 2916M 0
352557 2916M 0
352560 2916M 0
352594 2916M 0
352597 2916M 0
352613 2916M 0
352670 2916M 0
352671 2916M 0
352672 2916M 0
352721 2916M 0
352724 2916M 0
352727 2916M 0
352756 2916M 0
353117 2916M 0
354376 2916M 0
354432 2916M 0
354545 2916M 0
354601 2916M 0
354737 2916M 0
354785 2916M 0
354787 2916M 0
354793 2916M 0
354825 2916M 0
354847 2916M 0
354866 2916M 0
355069 2916M 0
355097 2916M 0
355124 2916M 0
355136 2916M 0
355667 2916M 0
355716 2916M 0
355742 2916M 0
355811 2916M 0
355889 2916M 0
355899 2916M 0
355903 2916M 0
355937 2916M 0
355987 2916M 0
356197 2916M 0
356238 2916M 0
356296 2916M 0
356325 2916M 0
356354 2916M 0
356448 2916M 0
356478 2916M 0
356488 2916M 0
356586 2916M 0
356615 2916M 0
356640 2916M 0
357476 2916M 0
357503 2916M 0
357553 2916M 0
357642 2916M 0
358340 2916M 0
358415 2916M 0
358420 2916M 0
358485 2916M 0
358706 2916M 0
358745 2916M 0
358866 2916M 0
358867 2916M 0
358976 2916M 0
359011 2916M 0
359053 2916M 0
359065 2916M 0
359091 2916M 0
359419 2916M 0