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.company_id = 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 = 1571 
WHERE 
  cscart_products_categories.product_id IN (
    58884, 62123, 29986, 60914, 29983, 60749, 
    29992, 29989, 60748, 63034, 62012, 
    60739, 60745, 61430, 62240, 63755, 
    60753, 64625, 62259, 64624, 61340, 
    61337, 64616, 60746, 64617, 60736, 
    64615, 62252, 61336, 62253, 64614, 
    60731, 60726, 60750, 60734, 61388, 
    64622, 60741, 64623, 64626, 60747, 
    62254, 60730, 62260, 60740, 61387, 
    60742, 61171
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00164

JSON explain

{
  "query_block": {
    "select_id": 1,
    "table": {
      "table_name": "cscart_products_categories",
      "access_type": "range",
      "possible_keys": ["PRIMARY", "pt"],
      "key": "pt",
      "key_length": "3",
      "used_key_parts": ["product_id"],
      "rows": 177,
      "filtered": 100,
      "attached_condition": "cscart_products_categories.product_id in (58884,62123,29986,60914,29983,60749,29992,29989,60748,63034,62012,60739,60745,61430,62240,63755,60753,64625,62259,64624,61340,61337,64616,60746,64617,60736,64615,62252,61336,62253,64614,60731,60726,60750,60734,61388,64622,60741,64623,64626,60747,62254,60730,62260,60740,61387,60742,61171)",
      "using_index": true
    },
    "table": {
      "table_name": "product_position_source",
      "access_type": "eq_ref",
      "possible_keys": ["PRIMARY", "pt"],
      "key": "PRIMARY",
      "key_length": "6",
      "used_key_parts": ["category_id", "product_id"],
      "ref": ["const", "cscart_migrate.cscart_products_categories.product_id"],
      "rows": 1,
      "filtered": 100
    },
    "table": {
      "table_name": "cscart_categories",
      "access_type": "eq_ref",
      "possible_keys": ["PRIMARY", "c_status", "p_category_id"],
      "key": "PRIMARY",
      "key_length": "3",
      "used_key_parts": ["category_id"],
      "ref": ["cscart_migrate.cscart_products_categories.category_id"],
      "rows": 1,
      "filtered": 100,
      "attached_condition": "cscart_categories.company_id = 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')"
    }
  }
}

Result

product_id category_ids position
29983 1676,1917,1573M
29986 1676,1917,1573M
29989 1676,1917,1573M
29992 1676,1796,1917,1573M
58884 1676,1917,1573M
60726 1675,1916,1576M
60730 1675,1916,1576M
60731 1675,1916,1576M
60734 1675,1916,1576M
60736 1675,1916,1576M
60739 1675,1916,1576M
60740 1675,1916,1576M
60741 1675,1916,1576M
60742 1675,1916,1576M
60745 1675,1916,1576M
60746 1675,1916,1576M
60747 1675,1916,1576M
60748 1675,1916,1576M
60749 1675,1916,1576M
60750 1675,1916,1576M
60753 1675,1916,1576M
60914 1676,1917,1573M
61171 1675,1916,1576M
61336 1676,1917,1573M
61337 1676,1796,1917,1573M
61340 1676,1917,1573M
61387 1675,1916,1576M
61388 1675,1916,1576M
61430 1676,1835,1907,1917,1573M
62012 1676,1917,1573M
62123 1676,1917,1573M
62240 1676,1796,1917,1573M
62252 1840,1918,1573M
62253 1840,1918,1573M
62254 1840,1918,1573M
62259 1676,1917,1573M
62260 1676,1917,1573M
63034 1676,1917,1573M
63755 1756,1840,1918,1573M
64614 1612,1839,1865,1913,1943,1575M
64615 1612,1839,1865,1913,1943,1575M
64616 1612,1839,1865,1913,1943,1575M
64617 1612,1839,1865,1913,1943,1575M
64622 1612,1839,1865,1913,1943,1575M
64623 1612,1839,1865,1913,1943,1575M
64624 1612,1839,1865,1913,1943,1575M
64625 1612,1839,1865,1913,1943,1575M
64626 1612,1839,1865,1913,1943,1575M