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 = 7168 
WHERE 
  cscart_products_categories.product_id IN (
    100302, 100303, 100304, 100305, 100306, 
    100307, 100308, 100309, 100310, 100311, 
    100312, 100313, 100314, 100315, 100316, 
    100317, 100318, 100319, 100320, 100327, 
    100328, 100329, 100330, 100331, 100332, 
    100333, 100334, 100335, 100336, 100337, 
    100338, 100339, 100340, 100341, 100342, 
    100343, 100344, 100345, 100346, 100347, 
    100348, 100349, 100350, 100351, 100352, 
    100353, 100354, 100355, 100356, 100357, 
    100359, 100360, 100438, 100439, 100440, 
    100441, 100442, 100443, 100444, 100445, 
    100446, 100447, 100448, 100449, 100450, 
    100451, 100452, 100453, 100454, 100455, 
    100456, 100457, 100458, 100459, 100460, 
    100461, 100462, 100463, 100464, 100465, 
    100466, 100467, 100468, 100469, 100470, 
    100471, 100472, 100473, 100474, 100475, 
    100476, 100928, 100929, 100944, 100945, 
    100948
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00096

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 (100302,100303,100304,100305,100306,100307,100308,100309,100310,100311,100312,100313,100314,100315,100316,100317,100318,100319,100320,100327,100328,100329,100330,100331,100332,100333,100334,100335,100336,100337,100338,100339,100340,100341,100342,100343,100344,100345,100346,100347,100348,100349,100350,100351,100352,100353,100354,100355,100356,100357,100359,100360,100438,100439,100440,100441,100442,100443,100444,100445,100446,100447,100448,100449,100450,100451,100452,100453,100454,100455,100456,100457,100458,100459,100460,100461,100462,100463,100464,100465,100466,100467,100468,100469,100470,100471,100472,100473,100474,100475,100476,100928,100929,100944,100945,100948))"
          }
        },
        {
          "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
100302 7168M 0
100303 7174M
100304 7174M
100305 7174M
100306 7174M
100307 7174M
100308 7174M
100309 7168M 0
100310 7168M 0
100311 7175M
100312 7168M 0
100313 7175M
100314 7168M 0
100315 7175M
100316 7168M 0
100317 7168M 0
100318 7175M
100319 7168M 0
100320 7175M
100327 7168M 0
100328 7177M
100329 7177M
100330 7177M
100331 7168M 0
100332 7168M 0
100333 7168M 0
100334 7168M 0
100335 7177M
100336 7177M
100337 7168M 0
100338 7173M
100339 7173M
100340 7173M
100341 7168M 0
100342 7168M 0
100343 7173M
100344 7168M 0
100345 7173M
100346 7173M
100347 7168M 0
100348 7179M
100349 7168M 0
100350 7179M
100351 7168M 0
100352 7168M 0
100353 7168M 0
100354 7168M 0
100355 7168M 0
100356 7168M 0
100357 7176M
100359 7176M
100360 7176M
100438 7177M
100439 7177M
100440 7177M
100441 7177M
100442 7177M
100443 7177M
100444 7177M
100445 7176M
100446 7176M
100447 7176M
100448 7179M
100449 7179M
100450 7174M
100451 7174M
100452 7174M
100453 7174M
100454 7174M
100455 7174M
100456 7174M
100457 7174M
100458 7173M
100459 7173M
100460 7173M
100461 7176M
100462 7176M
100463 7176M
100464 7174M
100465 7174M
100466 7176M
100467 7174M
100468 7174M
100469 7176M
100470 7174M
100471 7174M
100472 7173M
100473 7173M
100474 7173M
100475 7176M
100476 7176M
100928 7168M 0
100929 7168M 0
100944 7168M 0
100945 7168M 0
100948 7168M 0