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 (
    101335, 101336, 101337, 101338, 101339, 
    101340, 101341, 101342, 101343, 101344, 
    101345, 101346, 101347, 101348, 101349, 
    101350, 101351, 101352, 101353, 101354, 
    101355, 101356, 101357, 101358, 101359, 
    101360, 101361, 101362, 101363, 101364, 
    101365, 101366, 101367, 101368, 101369, 
    101370, 101371, 101372, 101373, 101374, 
    101375, 101376, 101377, 101378, 101379, 
    101380, 101381, 101382, 101383, 101384, 
    101385, 101386, 101387, 101388, 101389, 
    101390, 101391, 101392, 101393, 101394, 
    101395, 101396, 101397, 101398, 101399, 
    101400, 101401, 101402, 101403, 101404, 
    101405, 101406, 101407, 101408, 101409, 
    101410, 101411, 101412, 101413, 101414, 
    101415, 101416, 101417, 101418, 101419, 
    101420, 101421, 101422, 101423, 101424, 
    101425, 101426, 101427, 101428, 101429, 
    101430
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00237

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 (101335,101336,101337,101338,101339,101340,101341,101342,101343,101344,101345,101346,101347,101348,101349,101350,101351,101352,101353,101354,101355,101356,101357,101358,101359,101360,101361,101362,101363,101364,101365,101366,101367,101368,101369,101370,101371,101372,101373,101374,101375,101376,101377,101378,101379,101380,101381,101382,101383,101384,101385,101386,101387,101388,101389,101390,101391,101392,101393,101394,101395,101396,101397,101398,101399,101400,101401,101402,101403,101404,101405,101406,101407,101408,101409,101410,101411,101412,101413,101414,101415,101416,101417,101418,101419,101420,101421,101422,101423,101424,101425,101426,101427,101428,101429,101430))"
          }
        },
        {
          "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
101335 7200M
101336 7200M
101337 7200M
101338 7200M
101339 7200M
101340 7200M
101341 7200M
101342 7200M
101343 7200M
101344 7200M
101345 7200M
101346 7200M
101347 7200M
101348 7200M
101349 7200M
101350 7200M
101351 7200M
101352 7200M
101353 7200M
101354 7200M
101355 7200M
101356 7200M
101357 7200M
101358 7200M
101359 7200M
101360 7200M
101361 7200M
101362 7200M
101363 7200M
101364 7200M
101365 7200M
101366 7200M
101367 7200M
101368 7200M
101369 7200M
101370 7200M
101371 7200M
101372 7200M
101373 7200M
101374 7200M
101375 7200M
101376 7200M
101377 7200M
101378 7200M
101379 7200M
101380 7200M
101381 7200M
101382 7200M
101383 7200M
101384 7200M
101385 7200M
101386 7200M
101387 7200M
101388 7200M
101389 7200M
101390 7200M
101391 7200M
101392 7200M
101393 7200M
101394 7200M
101395 7200M
101396 7200M
101397 7200M
101398 7200M
101399 7200M
101400 7200M
101401 7200M
101402 7200M
101403 7200M
101404 7200M
101405 7200M
101406 7200M
101407 7200M
101408 7200M
101409 7200M
101410 7200M
101411 7200M
101412 7200M
101413 7200M
101414 7200M
101415 7200M
101416 7200M
101417 7200M
101418 7200M
101419 7200M
101420 7200M
101421 7200M
101422 7200M
101423 7200M
101424 7200M
101425 7200M
101426 7200M
101427 7200M
101428 7200M
101429 7200M
101430 7200M