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 = 308 
WHERE 
  cscart_products_categories.product_id IN (
    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, 1829, 1830, 1831, 1832, 
    1833, 1834, 1835, 1836, 1837, 1838, 
    1839, 1840, 1841, 1842, 1843, 1844, 
    1845, 1846, 1847, 1848, 1849, 1850, 
    1851, 1852, 1853, 1854, 1855, 1856, 
    1857, 1858, 1859, 1860, 1861, 1862, 
    1863, 1864, 1865, 1866, 1867
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00274

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "68.48"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "1.61"
      },
      "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.92",
            "index_condition": "(`gaseus`.`cscart_products_categories`.`product_id` in (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,1829,1830,1831,1832,1833,1834,1835,1836,1837,1838,1839,1840,1841,1842,1843,1844,1845,1846,1847,1848,1849,1850,1851,1852,1853,1854,1855,1856,1857,1858,1859,1860,1861,1862,1863,1864,1865,1866,1867))",
            "cost_info": {
              "read_cost": "44.00",
              "eval_cost": "0.16",
              "prefix_cost": "66.30",
              "data_read_per_join": "25"
            },
            "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.40",
              "eval_cost": "0.16",
              "prefix_cost": "66.87",
              "data_read_per_join": "25"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
1423 308M 0
1424 308M 0
1425 308M 0
1426 308M 0
1427 308M 0
1445 308M 0
1446 308M 0
1448 308M 0
1455 308M 0
1456 308M 0
1458 308M 0
1459 308M 0
1820 308M 0
1821 308M 0
1822 308M 0
1823 308M 0
1824 308M 0
1825 308M 0
1826 308M 0
1827 308M 0
1828 308M 0
1829 308M 0
1830 308M 0
1831 308M 0
1832 308M 0
1833 308M 0
1834 308M 0
1835 308M 0
1836 308M 0
1837 308M 0
1838 308M 0
1839 308M 0
1840 308M 0
1841 308M 0
1842 308M 0
1843 308M 0
1844 308M 0
1845 308M 0
1846 308M 0
1847 308M 0
1848 308M 0
1849 308M 0
1850 308M 0
1851 308M 0
1852 308M 0
1853 308M 0
1854 308M 0
1855 308M 0
1856 308M 0
1857 308M 0
1858 308M 0
1859 308M 0
1860 308M 0
1861 308M 0
1862 308M 0
1863 308M 0
1864 308M 0
1865 308M 0
1866 308M 0
1867 308M 0
5136 308M 0
5137 308M 0
5138 308M 0
5139 308M 0
5140 308M 0
5141 308M 0
5154 308M 0
5155 308M 0
5157 308M 0
5158 308M 0
5164 308M 0
5165 308M 0
5167 308M 0
5168 308M 0
5592 308M 0
5593 308M 0
5594 308M 0
5595 308M 0
5596 308M 0
5597 308M 0
5598 308M 0
5599 308M 0
5600 308M 0
5601 308M 0
5602 308M 0
5603 308M 0
5604 308M 0
5605 308M 0
5606 308M 0
5607 308M 0
5608 308M 0
5609 308M 0
5610 308M 0
5611 308M 0
5612 308M 0
6711 308M 0