Even good companies fall on hard times. The state of the economy, elevated inflation, slumping consumer confidence, and the impact of demand being pulled forward during the pandemic are reasons some companies are struggling. Consumer electronics retailer Best Buy (BBY -0.25%) and home audio specialist Sonos (SONO -0.93%) are two great examples.

But there's a lot to like about Best Buy and Sonos, even if both are suffering from slumping sales. For long-term investors, these two struggling stocks look like solid buy-and-hold candidates.

Best Buy

Consumers snapped up laptops and other gadgets during the pandemic, boosting Best Buy's revenue and profit. In fiscal 2022, which ended in January 2022, comparable sales jumped 10.4% on top of a 9.7% increase in the previous year. Adjusted earnings shot up to more than $10 per share.

The hangover from that buying binge is now hitting Best Buy hard, and a tough economy isn't helping, either. In Best Buy's fiscal third quarter, which ended on Oct. 29, comparable sales dropped 6.9% on top of a 10.4% decline in the prior-year period. Sales of computers, smartphones, consumer electronics, and appliances all suffered as consumers pulled back.

Best Buy expects to produce adjusted earnings between $6.00 and $6.30 per share for the full year, nearly 40% below its pandemic peak. While this steep earnings decline isn't good news, the stock has tumbled far enough to make Best Buy an interesting long-term investment.

It may take a while, but Best Buy's sales will eventually bottom out. The PC market is finally starting to improve after two years of declines, with shipment growth expected to return in the fourth quarter. The smartphone market is also looking better, with retail sales breaking a 27-month streak of declines in October.

As Best Buy muddles through this difficult period, the company has done a great job keeping costs in check. Gross margin actually improved in the third quarter on a year-over-year basis despite the sales decline, and the company chipped away at its operating expenses and slightly boosted its operating margin.

Best Buy has continued to keep staffing levels high in its stores, which improves customer service and reduces the impact of theft. In a recent call with analysts, Best Buy CEO Corie Barry said the rate of losses due to theft, fraud, and other causes has been stable over the past few years. Best Buy could cut costs further in the short term by gutting its in-store staffing levels, but such a move would likely hurt the business in the long run.

With Best Buy stock trading for around $70 per share, nearly 50% below its pandemic-era high, the price-to-earnings ratio based on fiscal 2024 guidance works out to roughly 11. Best Buy's earnings are likely depressed, although it may take a while for the company to return to pandemic-era profitability levels.

Once the economy improves and the hangover from the pandemic fully runs its course, Best Buy will be better positioned to grow the bottom line. For long-term investors able to look past Best Buy's recent results, the stock looks like a solid value.

Sonos

Spending hundreds or thousands of dollars on home audio equipment is something consumers tend to do less when economic uncertainty ramps up. Sonos has a strong brand and is well known for the quality of its products, but demand is weak right now.

Sonos' fiscal 2023 ended Sept. 30, and the results were not encouraging. Revenue dropped 5.5%, gross margin declined, and generally accepted accounting principles (GAAP) earnings fell into negative territory. Sonos still produced positive adjusted earnings and free cash flow, but there was little to like about the company's results. A round of layoffs in June helped reduce costs, and the company is reportedly cutting additional jobs in product development.

Fiscal 2024 isn't going to be much better for Sonos. The company expects revenue to be flat to down 3%, although it does expect gross margin to improve. New products will be the key to preventing sales from falling further. The company is widely expected to launch its first headphones next year, and it's also reportedly working on a TV streaming device. On top of those launches, Sonos will likely refresh some of its existing products and add additional audio gear to its lineup.

Sonos' long-term growth depends on existing customers coming back for additional products. The company's various speakers work well together, enabling whole-home audio in a way not tied to a specific big-tech ecosystem. Sonos now has its products in just over 15 million homes, and 44% of new product registrations came from existing households in fiscal 2023.

Sonos' turnaround will take time and likely require the economy to improve. With a market capitalization of about $1.86 billion, not much higher than the $1.60 to $1.65 billion in revenue the company expects for fiscal 2024, Sonos stock could be in for a strong recovery once the company returns to growth. Shares of the audio specialist are down about 67% off their pandemic-era high.

Sonos is battling a tough macroeconomic environment, and its business is just about the opposite of recession-proof. But with the company expected to enter multiple new product categories while continuing to iterate on its bread-and-butter speaker products, growth could come roaring back in fiscal 2025. For long-term investors willing to wait a few years, now looks like a good time to pick up shares of this struggling company.