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 = 372 
WHERE 
  cscart_products_categories.product_id IN (
    10479, 10484, 10539, 10541, 10544, 10987, 
    11005, 11050, 11057, 11065, 11076, 
    11091, 11180, 11184, 11248, 11253, 
    11312, 7738, 7748, 7756, 8858, 8871, 
    8946, 10070, 10173, 10245, 10260, 10418, 
    10439, 10441, 10443, 10444, 10464, 
    10489, 10546, 10550, 10567, 10568, 
    10570, 10986
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00180

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "60.69"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 62,
            "rows_produced_per_join": 62,
            "filtered": "100.00",
            "index_condition": "(`softwarepirmam_hewadelivard_cscart_4`.`cscart_products_categories`.`product_id` in (10479,10484,10539,10541,10544,10987,11005,11050,11057,11065,11076,11091,11180,11184,11248,11253,11312,7738,7748,7756,8858,8871,8946,10070,10173,10245,10260,10418,10439,10441,10443,10444,10464,10489,10546,10550,10567,10568,10570,10986))",
            "cost_info": {
              "read_cost": "31.71",
              "eval_cost": "6.20",
              "prefix_cost": "37.91",
              "data_read_per_join": "992"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ]
          }
        },
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "softwarepirmam_hewadelivard_cscart_4.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 3,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "15.50",
              "eval_cost": "0.31",
              "prefix_cost": "59.61",
              "data_read_per_join": "9K"
            },
            "used_columns": [
              "category_id",
              "storefront_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "((`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`storefront_id` in (0,1)) and ((`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`usergroup_ids`))) and (`softwarepirmam_hewadelivard_cscart_4`.`cscart_categories`.`status` in ('A','H')))"
          }
        },
        {
          "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",
              "softwarepirmam_hewadelivard_cscart_4.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 3,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "0.78",
              "eval_cost": "0.31",
              "prefix_cost": "60.70",
              "data_read_per_join": "49"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
7738 466M
7748 574M
7756 466M
8858 372M 0
8871 466,579M
8946 190,454M
10070 587M
10173 372M 0
10245 372,250M 0
10260 459M
10418 466M
10439 573M
10441 573M
10443 573M
10444 573M
10464 597,566M
10479 573M
10484 574M
10489 372M 0
10539 587M
10541 572M
10544 579M
10546 579M
10550 466M
10567 174,453M
10568 174,453M
10570 453,174M
10986 574M
10987 574M
11005 669M
11050 579M
11057 560,562M
11065 579M
11076 667,666M
11091 597M
11180 595M
11184 465M
11248 460M
11253 597M
11312 554,556M