Dipping cocoa prices could be a big boon for Hershey Co. (HSY) - Get Report .

That could be sweet news indeed for investors. 

Bernstein analyst Alexia Howard on Thursday, Aug. 17, upgraded Hershey stock to outperform from market perform and raised her price target to $127 from $109, noting that the price of cocoa has fallen by about 37% over the past year and may decline more. For example, privately held Mars Inc., along with the U.S. Department of Agriculture and IBM (IBM) - Get Report , mapped the cocoa genome in 2010, which could increase yields 500% over the next decade.

  • Wendy's and McDonald's Are Cooking Up Greatness But It Oddly Has Nothing to Do With Cheap Burgers

"Easing cocoa prices could be a major tailwind as we move out into 2018, more than offsetting the relatively mild inflation in dairy prices," Howard wrote, estimating that cocoa prices make up 10% to 15% of Hershey's cost of goods sold (COGS). "The last time cocoa prices declined in 2011, the company saw its gross margin improve from 42.4% in 2011 to 46% by 2013." Hershey already cited lower input costs in its first-quarter earnings report, when it raised full-year gross margin expansion guidance to 50 basis points from 15 to 25 basis points.

According to Howard's estimates, assuming cocoa accounts for 10% of Hershey COGS, a 30% fall in input prices could increase gross margin expansion to 47.8% from 46.2% in one year, lifting earnings per share by 8.6% or 42 cents.

"Given the complexity and variability of the timing of Hershey's commodity hedges, it is difficult to predict exactly when meaningful margin expansion will start to kick in," she noted. "However, we believe it is likely that Hershey will start seeing more substantial margin improvement at some point over the next year."

Image placeholder title

The chocolate category is expected to grow beyond input price declines, Howard continued: "Millennials love to snack, so snacks are holding up much better than center-of-plate or meal-based categories," with chocolate holding up well despite the popularity of healthier snack. Additionally, Hershey, Mars, Mondelez International Inc. (MDLZ) - Get Report and Nestle SA (NSRGY) - Get Report are all increasing "innovation and marketing spend," growing the category as a whole.

TheStreet Recommends

  • This Is the Big Reason McDonald's Wants to Have 4,500 Restaurants in China

The Food and Drug Administration's decision to delay implementation of new food labels indicating daily allowance of added sugars, which were set to be introduced in July, is another boon, as the labels would highlight that a single Hershey bar contains about two thirds of the recommended allowance, "potentially raising consumer concerns about added sugar in Hershey products and the chocolate category more broadly," Howard added.

In the longer term, however, "e-commerce could eventually start to reduce store trips and penalize impulse categories" like Hershey chocolate, but "this is likely to be a slower burn effect."

Hershey shares, which rose 1.71% to $107.85 in Thursday trading, are up 5.2% year to date, trailing the S&P 500's 10.2% increase during the same period. On Aug. 29 of last year, Mondelez dropped a $23 billion offer to acquire Hershey, which is a difficult takeover target due to its controlling shareholder, the $12 billion Hershey Trust charitable foundation.

Cocoa prices might be down, but this expert says Gold prices might explode..

More of What's Trending on TheStreet:

Editors' Pick: Originally published Aug. 17.