Shares of Chewy (CHWY -0.64%) have taken a massive drubbing this year thanks to the stock market sell-off, and the company's results for the second quarter of fiscal 2022 (ended July 31) further dented investor confidence in the stock. Are the pessimists right? Or is there any hope for the online pet retailer?

Chewy stock plunged after the company released its results on Aug. 30. The online pet supplies retailer swung to a profit last quarter while analysts were expecting a loss, but inflation has put the brakes on its sales growth. As a result, Chewy has slashed its revenue forecast for the full year, with CEO Sumit Singh pointing this out on the earnings conference call:

Across the pet category, pricing escalated throughout the second quarter. Consumers in the pet category responded to growing economic uncertainty by curtailing some of their purchase activity, leading to industrywide declines in unit volume.

The company now expects revenue to increase between 11% and 12% this year to $9.9 billion to $10 billion. It was earlier anticipating revenue growth of 15% to 17% in fiscal 2022 to $10.2 billion to $10.4 billion.

However, there were several positive takeaways from Chewy's latest quarterly results.

Making the right moves in a tough environment

Chewy's revenue increased 13% year over year last quarter to $2.43 billion. While that was below the consensus estimate of $2.45 billion, it is worth noting that Chewy's margins expanded despite escalating costs. The company enjoyed solid price growth during the quarter and strengthened its supply chain and logistics operations, which led to year-over-year growth of 60 basis points in the gross margin to 28.1%.

Chewy also reported an adjusted net margin of 2.6% last quarter as compared to 0.4% in the prior-year period. The margin gains helped it deliver adjusted earnings of $0.05 per share as compared to a loss of $0.04 per share in the prior-year period. Analysts were expecting a loss of $0.11 per share.

So Chewy's quarterly report wasn't an outright disaster, especially considering that the company has raised its profitability forecast for the fiscal year. The company expects an adjusted EBITDA (earnings before interest, taxes, depreciation, and amortization) margin of 1.75% to 2% this year, up from its prior range of breakeven to 1%.

Even better, Chewy managed to drive higher customer spending last quarter despite inflationary pressures. Its net sales per active customer increased 14.4% year over year to $462. A higher share of customers' wallets helped Chewy record double-digit revenue growth, especially considering that its customer growth nearly stagnated last quarter.

Chewy reported 20.5 million active customers last quarter, which was an increase of just 2.1% over the prior-year period. However, the stickiness of Chewy's existing customer base shows that the company is building a sustainable revenue stream that could help it grow at a nice pace in the long run.

Another point worth noting is that the subscription business produced a bigger chunk of its top line last quarter. The auto-ship subscription business accounted for 73.1% of Chewy's revenue in fiscal Q2, up from 70.3% in the prior-year period. All this indicates that Chewy is progressing in the right direction and is setting itself up to take advantage of the impressive long-term opportunity in the online pet retail space.

The stock looks like a bargain

While the tepid guidance is not good news for Chewy investors, the company is expected to deliver solid double-digit revenue growth in the coming years. What's more, analysts expect the company's bottom line to increase at a brisk pace over the next five years.

It won't be surprising to see Chewy match up to Wall Street's ambitious targets thanks to the company's expanding margins, as well as a solid catalyst in the form of a maturing customer base that's likely to spend more on its e-commerce platform.

Finally, the stock's valuation is another reason why savvy investors looking to buy an e-commerce stock for the long run may want to take a closer look at Chewy. The stock trades at just 1.6 times sales, which is a nice discount to the S&P 500's price-to-sales ratio of 2.5. So investors are getting a good deal on Chewy right now thanks to the market sell-off, and they may not want to miss this opportunity as the stock could regain its mojo in the future as its growth picks up.