Greenhouses may be affected by food shortages, but not nearly as much as a grocery store would be. One of the only factors a food shortage that may interfere a greenhouse would be the supply of seeds in stores for purchase. Even then, it is an option to culminate crops from already existing fruits and veggies by taking their seeds and planting them.
Greenhouses are the best option when faced with food shortages. It is not directly affected by production, labor, and pandemic issues that a lot of grocery stores have to go through. It is mostly self sustainable with the hand of a farmer and can carry a household through a food shortage of national proportions.