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 = 7336 
WHERE 
  cscart_products_categories.product_id IN (
    100521, 100522, 100523, 100524, 100525, 
    100526, 100527, 100528, 100529, 100530, 
    100531, 100532, 100533, 100534, 100535, 
    100642, 100644, 100646, 100648, 100789, 
    100790, 100791, 100792, 100793, 100794, 
    100795, 100796, 100797, 100798, 100799, 
    100800, 100801, 100802, 100803, 100804, 
    100805, 100806, 100807, 100808, 100809, 
    100810, 100811, 100812, 100813, 100814, 
    100815, 100816, 100817
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.01669

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "112.80"
    },
    "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": 125,
            "rows_produced_per_join": 125,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "12.81",
              "eval_cost": "12.50",
              "prefix_cost": "25.31",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (100521,100522,100523,100524,100525,100526,100527,100528,100529,100530,100531,100532,100533,100534,100535,100642,100644,100646,100648,100789,100790,100791,100792,100793,100794,100795,100796,100797,100798,100799,100800,100801,100802,100803,100804,100805,100806,100807,100808,100809,100810,100811,100812,100813,100814,100815,100816,100817))"
          }
        },
        {
          "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": 125,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "31.25",
              "eval_cost": "12.50",
              "prefix_cost": "69.06",
              "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": 6,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "31.25",
              "eval_cost": "0.63",
              "prefix_cost": "112.81",
              "data_read_per_join": "16K"
            },
            "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
100521 7217M,7337
100522 7217M,7337
100523 7217M,7337
100524 7217M,7337
100525 7217M,7337
100526 7217M,7337
100527 7217M,7337
100528 7217M,7337
100529 7217M,7337
100530 7217M,7337
100531 7217M,7337
100532 7217M,7337
100533 7217M,7337
100534 7217M,7337
100535 7217M,7337
100642 7217M,7337
100644 7217M,7337
100646 7217M,7337
100648 7217M,7337
100789 7219M,7313,7338
100790 7219M,7313,7338
100791 7219M,7313,7338
100792 7219M,7313,7338
100793 7219M,7313,7338
100794 7219M,7313,7338
100795 7219M,7313,7338
100796 7219M,7313,7338
100797 7219M,7313,7338
100798 7219M,7313,7338
100799 7219M,7313,7338
100800 7219M,7313,7338
100801 7219M,7313,7338
100802 7219M,7313,7338
100803 7219M,7313,7338
100804 7219M,7313,7338
100805 7219M,7313,7338
100806 7219M,7313,7338
100807 7219M,7313,7338
100808 7219M,7313,7338
100809 7219M,7313,7338
100810 7219M,7313,7338
100811 7219M,7313,7338
100812 7219M,7313,7338
100813 7219M,7313,7338
100814 7219M,7313,7338
100815 7219M,7313,7338
100816 7219M,7313,7338
100817 7219M,7313,7338