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 = 475 
WHERE 
  cscart_products_categories.product_id IN (
    312881, 312873, 312841, 312842, 312847, 
    312848, 312840, 312846, 312838, 312839, 
    312854, 312876, 312843, 312845, 312837, 
    312855, 312834, 312864, 312852, 312853, 
    312851, 312866, 312844, 312867, 312862, 
    312833, 312835, 312856, 312857, 312859, 
    312860, 312861, 312872, 312869, 312858, 
    312863, 312879, 312875, 312878, 312836, 
    312880, 312865, 312874, 312868, 312849, 
    312850, 312877
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00053

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.238644108,
    "nested_loop": [
      {
        "table": {
          "table_name": "cscart_products_categories",
          "access_type": "range",
          "possible_keys": ["PRIMARY", "pt"],
          "key": "pt",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "loops": 1,
          "rows": 47,
          "cost": 0.085043555,
          "filtered": 100,
          "attached_condition": "cscart_products_categories.product_id in (312881,312873,312841,312842,312847,312848,312840,312846,312838,312839,312854,312876,312843,312845,312837,312855,312834,312864,312852,312853,312851,312866,312844,312867,312862,312833,312835,312856,312857,312859,312860,312861,312872,312869,312858,312863,312879,312875,312878,312836,312880,312865,312874,312868,312849,312850,312877)",
          "using_index": true
        }
      },
      {
        "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": ["u985510652_ecartify.cscart_products_categories.category_id"],
          "loops": 47,
          "rows": 1,
          "cost": 0.04285788,
          "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')"
        }
      },
      {
        "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",
            "u985510652_ecartify.cscart_products_categories.product_id"
          ],
          "loops": 47,
          "rows": 1,
          "cost": 0.08054108,
          "filtered": 100
        }
      }
    ]
  }
}

Result

product_id category_ids position
312833 475M 0
312834 475M 0
312835 475M 0
312836 475M 0
312837 475M 0
312838 475M 0
312839 475M 0
312840 475M 0
312841 475M 0
312842 475M 0
312843 475M 0
312844 475M 0
312845 475M 0
312846 475M 0
312847 475M 0
312848 475M 0
312849 475M 0
312850 475M 0
312851 475M 0
312852 475M 0
312853 475M 0
312854 475M 0
312855 475M 0
312856 475M 0
312857 475M 0
312858 475M 0
312859 475M 0
312860 475M 0
312861 475M 0
312862 475M 0
312863 475M 0
312864 475M 0
312865 475M 0
312866 475M 0
312867 475M 0
312868 475M 0
312869 475M 0
312872 475M 0
312873 475M 0
312874 475M 0
312875 475M 0
312876 475M 0
312877 475M 0
312878 475M 0
312879 475M 0
312880 475M 0
312881 475M 0