Office supply company Staples (NASDAQ:SPLS) has been struggling to reverse declining sales in its retail stores amid shrinking demand for office supplies. Staples' stock has been struggling as well, with some chaotic swings over the past year ultimately leaving the share price well below the 52-week high. With all of Staples' problems, along with the potential for a more competitive Office Depot (NASDAQ:ODP), is it a good time to buy Staples' stock?

SPLS Chart

SPLS data by YCharts.

The state of the business
Most of Staples' revenue comes from two segments: North American Stores and Online, and North American Commercial. The first segment contains Staples' retail stores as well as Staples.com, the company's consumer and small-business-oriented website. The second segment is Staples' commercial delivery business, which caters to larger businesses.

During the most recent quarter, comparable-store sales at Staples' retail stores declined by 5%. Sales from Staples.com grew by 8% year over year, but operating income from the segment was decimated, declining by 72% year over year. The commercial business was much stronger. Sales grew by 2.6% year over year, and while the operating margin declined slightly, the segment still generated a healthy operating profit, accounting for the bulk of the company's total.

In an effort to fix the retail side of the business, Staples is closing in excess of 200 stores over the next few years. Office Depot is being even more aggressive, with plans to close over 400 stores, and the effect of these store closings should lead to the consolidation of sales, and therefore improved profitability at the store level.

The commercial business has been strong because Staples has dramatically expanded the range of products it sells to businesses. Along with office supplies, Staples sells other products businesses typically need, like cleaning supplies, snacks, and retail supplies, and the result has been a successful diversification away from the category that's causing the retail stores so much trouble.

Overall, Staples is not nearly in as much trouble as it may seem on the surface, thanks to its robust commercial delivery business. The retail side is performing poorly, but the commercial business is Staples' bread and butter, and as long as that segment remains strong, there's not too much to worry about.

Valuation
Staples has been a very profitable and very consistent company over the past decade. This is in contrast to Office Depot, which is hoping that its merger with Office Max will improve upon its inconsistent record.

SPLS Operating Income (Annual) Chart

SPLS Operating Income (Annual) data by YCharts.

It may be easy to draw the conclusion that Staples is in decline, but the commercial business is actually growing, and there are more growth opportunities ahead as Staples further expands its product offerings. Office Depot may put up a fight, with greater scale thanks to its merger with Office Max, but there's no guarantee the combined company will be any more effective than before.

Staples stock has fallen to around $13 per share, although it broke below $11 per share in August. Analysts are expecting just about $1 per share in earnings during the current fiscal year, putting the P/E ratio at roughly 13. Staples' best year over the past decade was 2011, when it earned $1.40 per share.

Staples' earnings are depressed thanks to the poor performance of the stores. As both Staples and Office Depot stores are closed, profitability should improve, and that should drive earnings higher. This may take years, but overcapacity seems to be the biggest problem facing Staples' retail operation, and that's a fixable problem.

Staples also pays a dividend that yields about 3.75%, although it yielded as high as 4.5% when the stock was below $11. Staples' payout ratio is only about 50% based on expected earnings for this year, so there's no near-term threat that the dividend will be slashed.

Verdict: It's time to buy Staples stock
If Staples were strictly a retailer, I wouldn't even consider the company as an investment. But the commercial delivery business appears to be extremely resilient, and the potential for earnings to grow as Staples closes underperforming stores makes the P/E ratio of 13 seem very attractive. Throw in an extremely high dividend thoroughly covered by earnings, and Staples looks like a great buy for long-term investors.

Timothy Green owns shares of Staples. The Motley Fool owns shares of Staples. Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.