Candy giant The Hershey Company (NYSE:HSY) is a legendary dividend stock. It has a long history of richly rewarding shareholders with tasty dividends, quarter after quarter. In fact, Hershey has paid 342 consecutive quarterly dividends to stockholders.

More recently, Hershey has fallen on hard times. The stock is down 9% during the past year. And it's up just 3% in the past two years, while the S&P 500 Index has rallied 35% in that time. This probably makes Hershey look very unappetizing as an investment opportunity.

Hershey's poor performance, however, could make it a great buying opportunity. The stock is now more attractively valued than at any time in the past several years.

Outlook leaves a bad taste in investors' mouths
On Friday, June 19, Hershey announced that it will slash 300 jobs as part of a broad cost-cutting effort. It also cut its profit forecast for this year, based on slowing international growth.

Adjusted profit, which strips out certain one-time items like effects from acquisitions and divestitures, is now expected to clock in between $4.10 per share and $4.18 per share, down from a previous forecast of $4.30 per share to $4.38 per share. The midpoint of Hershey's updated guidance, $4.14 per share, was significantly below the average analyst forecast, which at the time called for $4.32 per share in profit.

The reason for the reduced forecast is that Hershey now expects worse results in China than initially anticipated. Hershey said its sales in April and May were below expectations, due to the slowing Chinese economy and constrained consumer spending there.

In addition, Hershey noted a fiercer competitive environment than it previously expected. To combat these challenges, Hershey will focus on pushing through the products that generate the highest return going forward, as well as improving distribution in smaller stores.

But while all this looks bad, Hershey still has a profitable future ahead of it.

Take advantage of this tasty buying opportunity
Historically, Hershey has traded for an above-average valuation. Premium companies command premium valuations, and Hershey definitely qualifies as a premium company. Hershey has grown both revenue and earnings per share each year over the past five years. Revenue and EPS are up 30% and 70%, respectively, in that time. Hershey also has a long track record of rewarding shareholders, since it's paid a quarterly dividend for 85 consecutive years.

Only now, Hershey's declining stock price has pushed down its valuation. The stock now trades for 22 times earnings, which isn't too far from the market's valuation of close to 20 times earnings. And Hershey's valuation multiple is close to a three-year low. This could signify an attractive entry point.

Plus, Hershey's international business, which looks like a drag on the company now, should still turn into a source of meaningful long-term growth. Hershey generates approximately 85% of its revenue from North America. Clearly, there's plenty of room left for future international growth, and China is the perfect place to start. China, the world's most populous country, is still projected to become a major market for the company.

In fact, Hershey believes China will generate $450 million in sales this year, which would make it Hershey's second-largest market. Because Hershey is one of the world's most recognizable brands, it's not a stretch to think it can hit its target. Its efforts in China will also be greatly aided by the acquisition of Shanghai Golden Monkey, as its acquisitions added 1.6% to sales growth in the first quarter this year.

Take a bite out of Hershey
It's worth remembering that Hershey remains a growing and highly profitable business. Hershey grew organic revenue -- which excludes currency fluctuations and acquisitions -- and EPS by 4% last year. Even though the company took down its 2015 forecast, it still expects as much as 5% organic revenue growth this year.

The key takeaway for investors is that even though Hershey moderated its forecast for this year, it's still a very successful company that rewards its shareholders. Hershey trades for a modest valuation, and has a very sweet 2.3% dividend yield. The stock price drop, while difficult to swallow, now makes for a tasty buying opportunity.

Bob Ciura has no position in any stocks mentioned. The Motley Fool has no position in any of the stocks mentioned. 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.