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 (
    358369, 358728, 358826, 352229, 352514, 
    354424, 354429, 357436, 357598, 357601, 
    358801, 350114, 355753, 357812, 352323, 
    354368, 354613, 351386, 351396, 351532, 
    352624, 356082, 356464, 357453, 358599, 
    358840, 352233, 354354, 356667, 358408, 
    358457, 358990, 352358, 352615, 354985, 
    358958, 358991, 352429, 355020, 355042, 
    355133, 356592, 356676, 357463, 358831, 
    358984, 351403, 351620, 357142, 358382, 
    351598, 352319, 354856, 355668, 357528, 
    351323, 351370, 351435, 352362, 354450, 
    354648, 354877, 356424, 356425, 357146, 
    358620, 358920, 351473, 352353, 352591, 
    354399, 354644, 354769, 355676, 355678, 
    355747, 358811, 352510, 354970, 356100, 
    356289, 356603, 358849, 352350, 352586, 
    355053, 356050, 357467, 358275, 358462, 
    358882, 351285, 351474, 354440, 354517, 
    355086, 355612, 355852, 355866, 356002
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00199

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 (358369,358728,358826,352229,352514,354424,354429,357436,357598,357601,358801,350114,355753,357812,352323,354368,354613,351386,351396,351532,352624,356082,356464,357453,358599,358840,352233,354354,356667,358408,358457,358990,352358,352615,354985,358958,358991,352429,355020,355042,355133,356592,356676,357463,358831,358984,351403,351620,357142,358382,351598,352319,354856,355668,357528,351323,351370,351435,352362,354450,354648,354877,356424,356425,357146,358620,358920,351473,352353,352591,354399,354644,354769,355676,355678,355747,358811,352510,354970,356100,356289,356603,358849,352350,352586,355053,356050,357467,358275,358462,358882,351285,351474,354440,354517,355086,355612,355852,355866,356002))"
          }
        },
        {
          "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
350114 2916M 0
351285 2916M 0
351323 2916M 0
351370 2916M 0
351386 2916M 0
351396 2916M 0
351403 2916M 0
351435 2916M 0
351473 2916M 0
351474 2916M 0
351532 2916M 0
351598 2916M 0
351620 2916M 0
352229 2916M 0
352233 2916M 0
352319 2916M 0
352323 2916M 0
352350 2916M 0
352353 2916M 0
352358 2916M 0
352362 2916M 0
352429 2916M 0
352510 2916M 0
352514 2916M 0
352586 2916M 0
352591 2916M 0
352615 2916M 0
352624 2916M 0
354354 2916M 0
354368 2916M 0
354399 2916M 0
354424 2916M 0
354429 2916M 0
354440 2916M 0
354450 2916M 0
354517 2916M 0
354613 2916M 0
354644 2916M 0
354648 2916M 0
354769 2916M 0
354856 2916M 0
354877 2916M 0
354970 2916M 0
354985 2916M 0
355020 2916M 0
355042 2916M 0
355053 2916M 0
355086 2916M 0
355133 2916M 0
355612 2916M 0
355668 2916M 0
355676 2916M 0
355678 2916M 0
355747 2916M 0
355753 2916M 0
355852 2916M 0
355866 2916M 0
356002 2916M 0
356050 2916M 0
356082 2916M 0
356100 2916M 0
356289 2916M 0
356424 2916M 0
356425 2916M 0
356464 2916M 0
356592 2916M 0
356603 2916M 0
356667 2916M 0
356676 2916M 0
357142 2916M 0
357146 2916M 0
357436 2916M 0
357453 2916M 0
357463 2916M 0
357467 2916M 0
357528 2916M 0
357598 2916M 0
357601 2916M 0
357812 2916M 0
358275 2916M 0
358369 2916M 0
358382 2916M 0
358408 2916M 0
358457 2916M 0
358462 2916M 0
358599 2916M 0
358620 2916M 0
358728 2916M 0
358801 2916M 0
358811 2916M 0
358826 2916M 0
358831 2916M 0
358840 2916M 0
358849 2916M 0
358882 2916M 0
358920 2916M 0
358958 2916M 0
358984 2916M 0
358990 2916M 0
358991 2916M 0