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 = 266 
WHERE 
  cscart_products_categories.product_id IN (
    431199, 392169, 339707, 430908, 431115, 
    339829, 431133, 339758, 339809, 339769, 
    339677, 339729, 381702, 431050, 431150, 
    339807, 431158, 339648, 431026, 430747, 
    431195, 339479, 430748, 339851, 430681, 
    339712, 339746, 381696, 339847, 430924, 
    431102, 431122, 430907, 339654, 339704, 
    339664, 339735, 430696, 431201, 430648, 
    339760, 339485, 430824, 430916, 387047, 
    430771, 339720, 339817, 430636, 430638, 
    430915, 430998, 431139, 339812, 430646, 
    430857, 431120, 430743, 339835, 430831, 
    430935, 339714, 430803, 430821, 430823, 
    431151, 430813, 381698, 339668, 339715, 
    431145, 387049, 430649, 430665, 430751, 
    381699, 339671, 339820, 431127, 431109, 
    339761, 430647, 339694, 339650, 430848, 
    430766, 339593, 431114, 430660, 430817, 
    339849, 430903, 431097, 431103, 430902, 
    431163, 431194, 339484, 339755, 430818
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00380

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "281.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 (431199,392169,339707,430908,431115,339829,431133,339758,339809,339769,339677,339729,381702,431050,431150,339807,431158,339648,431026,430747,431195,339479,430748,339851,430681,339712,339746,381696,339847,430924,431102,431122,430907,339654,339704,339664,339735,430696,431201,430648,339760,339485,430824,430916,387047,430771,339720,339817,430636,430638,430915,430998,431139,339812,430646,430857,431120,430743,339835,430831,430935,339714,430803,430821,430823,431151,430813,381698,339668,339715,431145,387049,430649,430665,430751,381699,339671,339820,431127,431109,339761,430647,339694,339650,430848,430766,339593,431114,430660,430817,339849,430903,431097,431103,430902,431163,431194,339484,339755,430818))"
          }
        },
        {
          "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": 100,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "100.00",
              "eval_cost": "20.00",
              "prefix_cost": "161.15",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        },
        {
          "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": "281.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')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
339479 9940M
339484 9940M
339485 9940M
339593 395M
339648 395M
339650 395M
339654 395M
339664 395M
339668 395M
339671 395M
339677 395M
339694 395M
339704 395M
339707 395M
339712 395M
339714 395M
339715 395M
339720 395M
339729 9940M
339735 395M
339746 395M
339755 395M
339758 395M
339760 395M
339761 395M
339769 395M
339807 9940M
339809 9940M
339812 9940M
339817 395M
339820 395M
339829 395M
339835 395M
339847 395M
339849 395M
339851 395M
381696 10411M
381698 10410M
381699 10410M
381702 10410M
387047 2578M
387049 2578M
392169 2577M
430636 2601M
430638 2601M
430646 2601M
430647 2601M
430648 2601M
430649 2601M
430660 2601M
430665 2601M
430681 2601M
430696 2601M
430743 2601M
430747 2601M
430748 2601M
430751 2601M
430766 2601M
430771 2601M
430803 2601M
430813 2601M
430817 2601M
430818 2601M
430821 2601M
430823 2601M
430824 2601M
430831 2601M
430848 2601M
430857 2601M
430902 2601M
430903 2601M
430907 2601M
430908 2601M
430915 2601M
430916 2601M
430924 2601M
430935 2601M
430998 2601M
431026 2601M
431050 2601M
431097 2601M
431102 2601M
431103 2601M
431109 2601M
431114 2601M
431115 2601M
431120 2601M
431122 2601M
431127 2601M
431133 2601M
431139 2601M
431145 2601M
431150 2601M
431151 2601M
431158 2601M
431163 2601M
431194 2601M
431195 2601M
431199 2601M
431201 2601M