Cramer says the Fed's efforts to squash inflation are now hurting stocks like Walmart
The Federal Reserve's campaign to squash inflation is a long-term win for the U.S. economy, but investors in companies such as Walmart are paying the price now, CNBC's Jim Cramer said Thursday.

The U.S. retail behemoth, along with cybersecurity firm Palo Alto Networks and energy giant Chevron , all saw their stock prices decline meaningfully Thursday for reasons that can be traced back to the Fed's interest rate hikes, Cramer explained.

"Saying goodbye to inflation is sweet, but there's a little momentary sorrow, too," Cramer said. "That's the sorrow of Walmart or Chevron or Palo Alto Networks and so many other companies that are victims of their own success."

Walmart shares tanked 8% Thursday after the company reported quarterly earnings before the bell. While the top-and-bottom line results topped expectations, Walmart's same-store sales — a closely watched metric in the retail industry — decelerated for the third consecutive quarter.

One reason for that slowdown is emerging deflation, Cramer said. When inflation was raging, he said Walmart's same-store sales were boosted by the company passing on its own higher costs to shoppers with price hikes. Additionally, Cramer said Walmart is grappling with more cautious consumers, who've seen their budgets squeezed by inflation for well over a year.

Meanwhile, shares of Palo Alto Networks slid 5.4% Thursday as its earnings report from the prior evening disappointed investors. The primary issue was Palo Alto lowering its full-year billings outlook, which management chalked up to customers needing to ink shorter contracts due to higher borrowing costs. The reason for elevated borrowing costs, Cramer explained, is the Fed's rate hikes, which have made money more expensive.

Cramer's Charitable Trust, the portfolio used by the CNBC Investing Club, owns Palo Alto shares.

Chevron's stock, on the other hand, fell 2.6% Thursday alongside a steep drop in oil prices. That continues a multiweek downward trend for the commodity, amid concerns about demand. While Chevron and its energy peers benefited from higher oil prices last year, Cramer said the falling oil prices are a direct consequence of a slowing economy. And that's exactly what the Fed wants to see, he said.

"The good news of lower prices finally breaking the inflationary spiral is also bad news for the profits of many companies," Cramer said. "It'll take some sorting out, but never believe that that lower consumer prices are just a magic elixir for long-term stock market gains."