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 = 7170 
WHERE 
  cscart_products_categories.product_id IN (
    94778, 94779, 94780, 94781, 94782, 94783, 
    94784, 94785, 94786, 94787, 94788, 
    94789, 94790, 94791, 94792, 94793, 
    94794, 94795, 94814, 94815, 94833, 
    94834, 94835, 94836, 94837, 95443, 
    95444, 95445, 95446, 95447, 95791, 
    95792, 95793, 95794, 95795, 95796, 
    95797, 95798, 95799, 95800, 95801, 
    95802, 95804, 95806, 95808, 95810, 
    95812, 96564, 96565, 96566, 96567, 
    96568, 97716, 97717, 97718, 97774, 
    97786, 98146, 98148, 98152, 98155, 
    98407, 98408, 98409, 98410, 98552, 
    98553, 98554, 98555, 98556, 98763, 
    98764, 98765, 98766, 98767, 98768, 
    98818, 98822, 98826, 98830, 98859, 
    98860, 98861, 98862, 98863, 98865, 
    98867, 98869, 98871, 98873, 98910, 
    98911, 98912, 98913, 99313, 99314
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00119

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "54.77"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "link_type",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 96,
            "rows_produced_per_join": 96,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "9.89",
              "eval_cost": "9.60",
              "prefix_cost": "19.49",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (94778,94779,94780,94781,94782,94783,94784,94785,94786,94787,94788,94789,94790,94791,94792,94793,94794,94795,94814,94815,94833,94834,94835,94836,94837,95443,95444,95445,95446,95447,95791,95792,95793,95794,95795,95796,95797,95798,95799,95800,95801,95802,95804,95806,95808,95810,95812,96564,96565,96566,96567,96568,97716,97717,97718,97774,97786,98146,98148,98152,98155,98407,98408,98409,98410,98552,98553,98554,98555,98556,98763,98764,98765,98766,98767,98768,98818,98822,98826,98830,98859,98860,98861,98862,98863,98865,98867,98869,98871,98873,98910,98911,98912,98913,99313,99314))"
          }
        },
        {
          "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": [
              "nuie_scalesta_net.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 4,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "24.00",
              "eval_cost": "0.48",
              "prefix_cost": "53.09",
              "data_read_per_join": "12K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`nuie_scalesta_net`.`cscart_categories`.`storefront_id` in (0,1)) and ((`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids`))) and (`nuie_scalesta_net`.`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",
              "nuie_scalesta_net.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 4,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "1.20",
              "eval_cost": "0.48",
              "prefix_cost": "54.77",
              "data_read_per_join": "76"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
94778 7223M
94779 7223M
94780 7223M
94781 7223M
94782 7223M
94783 7223M
94784 7223M
94785 7223M
94786 7223M
94787 7223M
94788 7223M
94789 7223M
94790 7223M
94791 7223M
94792 7223M
94793 7223M
94794 7223M
94795 7223M
94814 7201M
94815 7201M
94833 7192M
94834 7192M
94835 7192M
94836 7192M
94837 7201M
95443 7201M
95444 7201M
95445 7201M
95446 7201M
95447 7201M
95791 7201M
95792 7201M
95793 7201M
95794 7201M
95795 7201M
95796 7201M
95797 7201M
95798 7201M
95799 7201M
95800 7201M
95801 7201M
95802 7201M
95804 7201M
95806 7201M
95808 7201M
95810 7201M
95812 7201M
96564 7201M
96565 7201M
96566 7201M
96567 7201M
96568 7201M
97716 7201M
97717 7201M
97718 7201M
97774 7201M
97786 7201M
98146 7201M
98148 7201M
98152 7201M
98155 7201M
98407 7201M
98408 7201M
98409 7201M
98410 7201M
98552 7201M
98553 7201M
98554 7201M
98555 7201M
98556 7201M
98763 7201M
98764 7201M
98765 7201M
98766 7201M
98767 7201M
98768 7201M
98818 7201M
98822 7201M
98826 7201M
98830 7201M
98859 7201M
98860 7201M
98861 7201M
98862 7201M
98863 7201M
98865 7201M
98867 7201M
98869 7201M
98871 7201M
98873 7201M
98910 7201M
98911 7201M
98912 7201M
98913 7201M
99313 7201M
99314 7201M