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 = 7166 
WHERE 
  cscart_products_categories.product_id IN (
    94177, 94178, 94179, 94180, 94181, 94182, 
    94183, 94184, 94185, 94186, 94187, 
    94188, 94189, 94190, 94191, 94192, 
    94193, 94194, 94195, 94196, 94197, 
    94198, 94199, 94200, 94201, 94202, 
    94203, 94204, 94205, 94206, 94207, 
    94208, 94209, 94210, 94211, 94212, 
    94213, 94214, 94215, 94216, 94217, 
    94218, 94219, 94220, 94221, 94222, 
    94223, 94224, 94225, 94226, 94227, 
    94228, 94229, 94230, 94231, 94232, 
    94233, 94234, 94235, 94236, 94237, 
    94238, 94239, 94240, 94241, 94242, 
    94243, 94244, 94245, 94246, 94247, 
    94248, 94249, 94250, 94251, 94252, 
    94253, 94254, 94255, 94256, 94257, 
    94258, 94259, 94260, 94261, 94262, 
    94263, 94264, 94265, 94266, 94267, 
    94268, 94269, 94270, 94271, 94272
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.01663

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "86.69"
    },
    "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 (94177,94178,94179,94180,94181,94182,94183,94184,94185,94186,94187,94188,94189,94190,94191,94192,94193,94194,94195,94196,94197,94198,94199,94200,94201,94202,94203,94204,94205,94206,94207,94208,94209,94210,94211,94212,94213,94214,94215,94216,94217,94218,94219,94220,94221,94222,94223,94224,94225,94226,94227,94228,94229,94230,94231,94232,94233,94234,94235,94236,94237,94238,94239,94240,94241,94242,94243,94244,94245,94246,94247,94248,94249,94250,94251,94252,94253,94254,94255,94256,94257,94258,94259,94260,94261,94262,94263,94264,94265,94266,94267,94268,94269,94270,94271,94272))"
          }
        },
        {
          "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": 96,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "24.00",
              "eval_cost": "9.60",
              "prefix_cost": "53.09",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        },
        {
          "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": "86.69",
              "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')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
94177 7166M 0
94178 7166M 0
94179 7166M 0
94180 7166M 0
94181 7166M 0
94182 7166M 0
94183 7166M 0
94184 7166M 0
94185 7166M 0
94186 7166M 0
94187 7166M 0
94188 7166M 0
94189 7166M 0
94190 7166M 0
94191 7166M 0
94192 7166M 0
94193 7166M 0
94194 7166M 0
94195 7166M 0
94196 7166M 0
94197 7166M 0
94198 7166M 0
94199 7166M 0
94200 7166M 0
94201 7166M 0
94202 7166M 0
94203 7166M 0
94204 7166M 0
94205 7166M 0
94206 7166M 0
94207 7166M 0
94208 7166M 0
94209 7166M 0
94210 7166M 0
94211 7166M 0
94212 7166M 0
94213 7166M 0
94214 7166M 0
94215 7166M 0
94216 7166M 0
94217 7166M 0
94218 7166M 0
94219 7166M 0
94220 7166M 0
94221 7166M 0
94222 7166M 0
94223 7166M 0
94224 7166M 0
94225 7166M 0
94226 7166M 0
94227 7166M 0
94228 7166M 0
94229 7166M 0
94230 7166M 0
94231 7166M 0
94232 7166M 0
94233 7166M 0
94234 7166M 0
94235 7166M 0
94236 7166M 0
94237 7166M 0
94238 7166M 0
94239 7166M 0
94240 7166M 0
94241 7166M 0
94242 7166M 0
94243 7166M 0
94244 7166M 0
94245 7166M 0
94246 7166M 0
94247 7166M 0
94248 7166M 0
94249 7166M 0
94250 7166M 0
94251 7166M 0
94252 7166M 0
94253 7166M 0
94254 7166M 0
94255 7166M 0
94256 7166M 0
94257 7166M 0
94258 7166M 0
94259 7166M 0
94260 7166M 0
94261 7166M 0
94262 7166M 0
94263 7166M 0
94264 7166M 0
94265 7166M 0
94266 7166M 0
94267 7166M 0
94268 7166M 0
94269 7166M 0
94270 7166M 0
94271 7166M 0
94272 7166M 0