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 
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') 
WHERE 
  cscart_products_categories.product_id IN (
    17792, 17791, 17790, 17789, 17788, 17787, 
    17786, 17785, 17784, 17775, 17774, 
    17773, 17772, 17753, 17752, 17751, 
    17750, 17749, 17748, 17747, 17746, 
    17745, 17744, 17743, 17742, 17783, 
    17782, 17781, 17780, 17779, 17778, 
    17777, 17776, 17741, 17740, 17739, 
    17738, 17737, 17771, 17770, 17769, 
    17768, 17767, 17766, 17765, 17764, 
    17763, 17762, 17761, 17760, 17759, 
    17758, 17757, 17756, 17755, 17754, 
    17736, 17735, 17734, 17733, 17730, 
    17732, 17731, 17729, 17728, 17727, 
    17726, 17725, 17667, 17679, 17678, 
    17677, 17676, 17675, 17674, 17673, 
    17672, 17671, 17670, 17669
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00082

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": 141,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (17792,17791,17790,17789,17788,17787,17786,17785,17784,17775,17774,17773,17772,17753,17752,17751,17750,17749,17748,17747,17746,17745,17744,17743,17742,17783,17782,17781,17780,17779,17778,17777,17776,17741,17740,17739,17738,17737,17771,17770,17769,17768,17767,17766,17765,17764,17763,17762,17761,17760,17759,17758,17757,17756,17755,17754,17736,17735,17734,17733,17730,17732,17731,17729,17728,17727,17726,17725,17667,17679,17678,17677,17676,17675,17674,17673,17672,17671,17670,17669)"
    },
    "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": ["noframes_angrybeaver.cscart_products_categories.category_id"],
      "rows": 1,
      "filtered": 100,
      "attached_condition": "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')"
    }
  }
}

Result

product_id category_ids
17667 1689M
17669 1689M
17670 1690M
17671 1690M
17672 1690M
17673 1690M
17674 1690M
17675 1690M
17676 1690M
17677 1690M
17678 1690M
17679 1690M
17725 1751M
17726 1751M
17727 1751M
17728 1751M
17729 1751M
17730 1751M
17731 1751M
17732 1751M
17733 1754M
17734 1754M
17735 1754M
17736 1754M
17737 1754M
17738 1754M
17739 1754M
17740 1754M
17741 1754M
17742 1753M
17743 1753M
17744 1753M
17745 1753M
17746 1753M
17747 1753M
17748 1753M
17749 1753M
17750 1753M
17751 1753M
17752 1753M
17753 1753M
17754 1756M
17755 1756M
17756 1756M
17757 1756M
17758 1756M
17759 1756M
17760 1756M
17761 1755M
17762 1755M
17763 1755M
17764 1755M
17765 1755M
17766 1755M
17767 1755M
17768 1755M
17769 1755M
17770 1755M
17771 1755M
17772 1759M
17773 1759M
17774 1759M
17775 1759M
17776 1752M
17777 1752M
17778 1752M
17779 1752M
17780 1752M
17781 1752M
17782 1752M
17783 1752M
17784 1691M
17785 1691M
17786 1691M
17787 1691M
17788 1691M
17789 1691M
17790 1691M
17791 1691M
17792 1691M