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 (
    1925, 1926, 1927, 1928, 1929, 1930, 1931, 
    5560, 5561, 5562, 5563, 5564, 5565, 
    5566, 5567, 5568, 5569, 5570, 5571, 
    5572, 5573, 5574, 5575, 5576, 5577, 
    5578, 5579, 5580, 5581, 5582, 5583, 
    5584, 5585, 5586, 5587, 5588, 5589, 
    5590, 5591, 5592, 5593, 5594, 5595, 
    5596, 5597, 5598, 5599, 5600, 5601, 
    5602, 5603, 5604, 5605, 5606, 5607, 
    5608, 5609, 5610, 5611, 5612, 1423, 
    1424, 1425, 1426, 1427, 5136, 5137, 
    5138, 5139, 5140, 5141, 6711, 1455, 
    5164, 1445, 5154, 1456, 5165, 1446, 
    5155, 1458, 5167, 1448, 5157, 1459, 
    5168, 5158, 1820, 1821, 1822, 1823, 
    1824, 1825, 1826, 1827, 1828
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00262

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "68.54"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "1.66"
      },
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "ALL",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "rows_examined_per_scan": 40,
            "rows_produced_per_join": 1,
            "filtered": "4.00",
            "cost_info": {
              "read_cost": "4.54",
              "eval_cost": "0.16",
              "prefix_cost": "4.70",
              "data_read_per_join": "6K"
            },
            "used_columns": [
              "category_id",
              "storefront_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "((`gaseus`.`cscart_categories`.`storefront_id` in (0,1)) and ((`gaseus`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`gaseus`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`gaseus`.`cscart_categories`.`usergroup_ids`))) and (`gaseus`.`cscart_categories`.`status` in ('A','H')))"
          }
        },
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "ref",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "gaseus.cscart_categories.category_id"
            ],
            "rows_examined_per_scan": 110,
            "rows_produced_per_join": 1,
            "filtered": "0.94",
            "index_condition": "(`gaseus`.`cscart_products_categories`.`product_id` in (1925,1926,1927,1928,1929,1930,1931,5560,5561,5562,5563,5564,5565,5566,5567,5568,5569,5570,5571,5572,5573,5574,5575,5576,5577,5578,5579,5580,5581,5582,5583,5584,5585,5586,5587,5588,5589,5590,5591,5592,5593,5594,5595,5596,5597,5598,5599,5600,5601,5602,5603,5604,5605,5606,5607,5608,5609,5610,5611,5612,1423,1424,1425,1426,1427,5136,5137,5138,5139,5140,5141,6711,1455,5164,1445,5154,1456,5165,1446,5155,1458,5167,1448,5157,1459,5168,5158,1820,1821,1822,1823,1824,1825,1826,1827,1828))",
            "cost_info": {
              "read_cost": "44.00",
              "eval_cost": "0.17",
              "prefix_cost": "66.30",
              "data_read_per_join": "26"
            },
            "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",
              "gaseus.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 1,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "0.42",
              "eval_cost": "0.17",
              "prefix_cost": "66.88",
              "data_read_per_join": "26"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
1423 308M
1424 308M
1425 308M
1426 308M
1427 308M
1445 308M
1446 308M
1448 308M
1455 308M
1456 308M
1458 308M
1459 308M
1820 308M
1821 308M
1822 308M
1823 308M
1824 308M
1825 308M
1826 308M
1827 308M
1828 308M
1925 308M
1926 308M
1927 308M
1928 308M
1929 308M
1930 308M
1931 308M
5136 308M
5137 308M
5138 308M
5139 308M
5140 308M
5141 308M
5154 308M
5155 308M
5157 308M
5158 308M
5164 308M
5165 308M
5167 308M
5168 308M
5560 308M
5561 308M
5562 308M
5563 308M
5564 308M
5565 308M
5566 308M
5567 308M
5568 308M
5569 308M
5570 308M
5571 308M
5572 308M
5573 308M
5574 308M
5575 308M
5576 308M
5577 308M
5578 308M
5579 308M
5580 308M
5581 308M
5582 308M
5583 308M
5584 308M
5585 308M
5586 308M
5587 308M
5588 308M
5589 308M
5590 308M
5591 308M
5592 308M
5593 308M
5594 308M
5595 308M
5596 308M
5597 308M
5598 308M
5599 308M
5600 308M
5601 308M
5602 308M
5603 308M
5604 308M
5605 308M
5606 308M
5607 308M
5608 308M
5609 308M
5610 308M
5611 308M
5612 308M
6711 308M