How does a mushroom obtain its nutrients if it does not photosynthesize?
Although mushrooms grow from the ground, they are not plants! Instead, mushrooms are a part of a completely different kingdom called fungi. Other examples of fungi are yeasts and molds. Fungi can be unicellular or multicellular, use spores to reproduce, are made of a mass (mycelium) of filaments called hyphae, contain chitin in their cell walls, and are heterotrophic.
The fact that fungi are heterotrophs is the point of interest in answering this question. Unlike producers that make their own food (such as plants), heterotrophs are consumers and must eat other things in order to survive. However, fungi are not like animals. They do not have digestive organs. Instead, fungi digest organisms outside of themselves. This is done by releasing digestive enzymes externally. These enzymes break down organic compounds in the ground. Once the organic material is decomposed, the fungi can absorb it using its hyphae.
Mushrooms are heterotrophs and more specifically, decomposers. They obtain their nutrients from the decomposition and breakdown of other organic matter found in organisms. They use enzymes to break down the matter, and then absorb the nutrients and are able to grow.
They are not producers. Producers are organisms capable of making their own food by using sunlight to form food inside the plant.
Mushrooms as fungi are decomposers, they get the nutrients they need by breaking down organic materials.