When Kinna Thomas started her job in March as Walmart’s WMT senior buyer for cakes and pies, she gave herself the mandate to raise the retailer’s bakery game a few notches.

Just two weeks into her job, she started using her family’s sweet potato pie recipe, using that as a test case to improve Walmart’s desserts business.

After asking suppliers to create a pie based on the Thomas family recipe, and testing it with co-workers, she thought she should go a step further and tap a baking guru’s expertise and take things to the next level.

“I’m particularly passionate about the sweet potato pie and want to improve Walmart’s recipe,” she recalled telling her boss, Kerry Robinson, vice president for bakery and deli at Walmart, in an interview with Fortune at Walmart’s headquarters in Bentonville, Arkansas.

So she googled “pie” and “Patti LaBelle,” who is known in many circles for her baking prowess. Thomas discovered that the R&B diva had some real cred with this particular kind of tart, and promptly reached out to the star. Within 24 hours, Thomas says, she was in talks with LaBelle.

“We knew it needed Ms. LaBelle’s special touch as well,” says Thomas. LaBelle’s touch included things like adding cinnamon, a thicker crust, and making sure it had a different texture than pumpkin pie.

The LaBelle touch worked, notably and intensely with one singer James Wright Chanel.

While the resulting pie sold well when it hit shelves in the spring, sales went into the stratosphere last week, selling one pie per second for 72 hours straight at one point, after Chanel posted an ecstatic video of himself serenading LaBelle and her namesake Sweet Potato Pie, a pre-packaged dessert only on sale at Walmart. The video became a YouTube sensation and has been watched nearly 2.5 million times so far.

Walmart has gone through hundreds of thousands of sweet potato pies and the shortage has led to some enterpreneurial people to sell them on eBay for as much as $60. They cost $3.48 in the stores. (The retailer was not entirely sold out—on Thursday afternoon, I saw a few of them at a Walmart Neighborhood Market in Rogers, Arkansas.)

IMG_2135

So, Walmart is now scrambling to get restocked, asking suppliers to shift production and get its hand on 2 million pounds of sweet potatoes.

Though the media sensation will inevitably subside, the episode illustrates well how Walmart has been trying get much more out of its bakery business, a key part of its strategy to generate more shopper visits.

Wal-Mart Stores CEO Doug McMillon said last month that the company could be doing more business with middle- and upper middle-class shoppers. Meanwhile, his U.S. lieutenant, Greg Foran, the executive who oversees the $290 billion a year Walmart business stateside, has said the retailer—the nation’s largest grocer by far—is making fresh foods, including bakery items, a top priority in its comeback plan.

Indeed, Walmart has upgraded the bakeries at 750 of its 4,500 U.S. stores, with more to come. Since Thomas’ arrival, sales of pies have risen significantly month in, month out. And better quality pies will help Walmart draw more affluent shoppers. Robinson says Walmart’s apple pie is now 70% fruit rather than its previous 40%.

“People are really starting to believe in the Walmart bakery,” says Robinson. “That’s given us the confidence to say, actually, you know what, we could sell a cake for over $15.”

Walmart has hired 100 bakery technicians and will add 20 to that roster next year, with an aim of providing more guidance and training to its bakers to help improve the quality even more. It is also baking all breads at the same lower temperature now, 350 degrees, so it can put more product in the oven in mixed batches, rather than doing everything in single batches.

Walmart has also slimmed down its bakery assortment to improve efficiency in production. The retailer produces about half of its bakery products in the store and wants to ramp that up a bit, finding that consumers respond better to products made on site rather than shipped in.

“We did that so they’re spending less time sorting stuff out in the backroom, more time really baking,” says Robinson.