The U.S. Department of Labor released its June inflation reading recently. The Consumer Price Index (CPI) showed a 2.7% year-over-year increase. The figure includes volatile food and energy prices.

Consumer staple companies should have an edge during an inflationary environment. That's because they sell basic necessities like food, beverages, and everyday items. These types of companies should have the ability to pass along cost increases to their customers.

However, people seem wary about further price increases, since inflation has been running high for some time. How have these two consumer staple companies been faring?

Tired-looking person with cart of groceries in a store aisle.

Image source: Getty Images.

1. PepsiCo

PepsiCo (PEP 0.99%) sells beverages, snacks, and convenience foods. It produces these products under well-known brands like Pepsi-Cola, Gatorade, Doritos, and Quaker.

Nonetheless, despite these products' long-standing popularity, people seem tired of paying higher prices given elevated overall inflation. You can see that by looking at PepsiCo's results, which have seen sluggish volumes in the face of price increases.

The company's second-quarter revenue, adjusted to remove foreign-currency translation effects and the effect of acquisitions/divestitures, rose a tepid 2%. This was due entirely to higher prices, which contributed 4 percentage points. Meanwhile, lower volume subtracted about 1.5 percentage points.

The price hikes weren't sufficient to offset higher costs, however. PepsiCo's adjusted operating income fell 3%.

Investors haven't been too pleased with the company's results. PepsiCo's share price has dropped 16.9% over the last year through July 28. Meanwhile, the S&P 500 index gained 16.8% during this time.

When inflation abates and PepsiCo can hold the line on prices, volume and sales growth should increase. That will likely boost profitability. Investors perhaps see the light at the end of the tunnel.

The valuation has become more expensive over the last month, with the price-to-earnings (P/E) ratio increasing from 19 to 26. Still, that's cheaper than the S&P 500's P/E multiple of 30. Given the valuation and prospects for better results down the line, patient investors may find themselves rewarded.

2. Procter & Gamble

Procter & Gamble (PG 0.11%) sells items that people use every day. These include shampoo, deodorant, razor blades, toothbrushes, laundry detergent, and diapers. It sells these products under popular brands like Head & Shoulders, Old Spice, Gillette, Crest, Tide, and Pampers.

These basic items should be fairly impervious to price increases. After all, people will still use them no matter what's going on with their personal finances.

Nonetheless, consumers have been shying away from its products. Procter & Gamble's fiscal third-quarter adjusted sales grew a scant 1%. Higher prices accounted for the entire increase, with volumes flat versus a year ago. The company's earnings per share increased 1%. The period ended on March 31.

It was a similar story in the recently reported fourth quarter. Procter & Gamble's adjusted sales increased 2%, with higher prices and mix each adding 1 percentage point. Volume was constant compared to last year. Management expects a range of 0% to 4% sales growth this year.

Procter & Gamble's stock price has dropped 7.9% over the last year. The share's P/E multiple has contracted from 28 to less than 25 during this time.

Despite the better valuation, I'd hold off on purchasing the stock. Given the type of products it sells, I'd expect Procter & Gamble to have performed better during an inflationary environment.