Most investors gauge the health of the market by the action of an index like the S&P 500. That's appropriate, but it only provides a surface view of a vast market made up of individual stocks. You don't need to wait for a market crash to find stocks that are on sale. In fact, consumer staples icons Clorox (CLX -0.69%) and Hershey (HSY -0.53%), names you likely know well already, appear to be dealing with their own personal bear markets right now. Here's why you might want to buy them.

Clorox is getting back on track

Clorox stock has lagged the S&P 500 index over the past year, down nearly 5% compared to the index's gain of 17%. But go back a little further and Clorox is down nearly 30% over the trailing three-year period compared to a 25% gain for the S&P. The company is clearly in its own personal bear market. There are good reasons for this circumstance.

SPY Chart

SPY data by YCharts

For starters, the consumer staples maker's margins got crushed coming out of the coronavirus pandemic. High operating costs, rising inflation, and a decline in demand for cleaning products, a key category for Clorox, created a triple whammy. Management moved quickly to address the problems, cutting costs and raising prices, but it was clear that it would be a multi-year effort to return profit margins back toward historical levels. Investors reacted by dumping the stock. A recent cyber attack hasn't helped as it forced the company to use, effectively, pen and paper to track the business.

However, behind this series of less-than-desirable headlines has been steady progress on management's promise to improve margins. As the chart below shows, while still down from its recent peak, the gross profit margin appears to have bottomed out in late 2022 and has been improving steadily since that point. Meanwhile, the company has increased its dividend annually for 46 consecutive years and offers a historically attractive dividend yield of 3.3%.

With the stock still well off of its highs from a few years ago, long-term investors have a chance to buy this reliable dividend payer at what look like depressed levels.

CLX Gross Profit Margin Chart

CLX Gross Profit Margin data by YCharts

Hershey is getting walloped by cocoa prices

Although inflation played a big role in Clorox's problems, inflation's rise has started to ebb in most areas. But, unfortunately for chocolate maker Hershey, cocoa prices have continued to rise. In other words, the company's margins remain under pressure and it has to tread carefully with additional price increases at a time when other consumer staples companies are pulling back on charging customers more.

Then there's the concern about new weight-loss medications, which could lead people to spend less on sweets and other snacks.

SPY Chart

SPY data by YCharts

Indeed, there are good reasons why Hershey's stock has fallen 21% over the past year. That drop has pushed the dividend yield up to 2.5%, which isn't huge but is toward the higher side for this food maker. It is probably most appropriate to look at the stock as fairly priced. But given the 14-year streak of annual dividend increases and the hefty 9% annualized dividend increase rate over the past decade, that could be pretty attractive for long-term dividend growth types.

As for the future, well, don't get too excited over the near term. The cost headwind is real and will likely limit near-term growth. However, the company has a long history of innovation in the candy space that suggests it will remain a leading company in the food niche. It is also expanding its reach into salty snacks, like pretzels and popcorn, which should support growth.

And it is spreading out into global markets, which have been a mixed bag so far but, given the iconic brands Hershey owns, it seems likely that it will eventually figure out a way to succeed.

Betting on the laggards

Companies usually fall out of favor for good reasons, which is true of both Clorox and Hershey. However, they are both companies with iconic brands and long histories of being well run. You could wait for a stock market correction to find bargains, or you could look for companies that are in their own personal bear markets.

Clorox appears to be turning an important corner, which suggests its downturn could be nearly over. Hershey is probably going to linger in a bad space for a while, but long-term it seems likely that consumers will come back for its sweets and bring investors along with them.