Apollo Global Management LLC agreed to buy Shutterfly Inc. for $51 a share in cash, according to a statement.

The deal values the online retailer at about $1.74 billion, based on the company’s outstanding shares at the end of March. Apollo will also assume Shutterfly’s more than $1 billion in debt.

The buyout firm plans to merge Shutterfly with rival Snapfish LLC, whose owners will become minority shareholders in the combined business, Apollo said.

The offer for Shutterfly represents a 31 percent premium to its closing share price of $38.91 on April 23, a day before Bloomberg News reported that the Redwood City, California-based company had drawn interest from suitors including Apollo. Shutterfly’s board unanimously approved the deal and has recommended that shareholders vote in favor of the transaction.

The deals are expected to close in the fourth quarter.

"Shutterfly has cultivated a deep connection with customers," Apollo senior partner David Sambur said in a statement. "At a time when billions of photos are taken every day, Shutterfly has led the charge as a pioneer of personalized photo products and school photography."

Shutterfly, which sells personalized frames and photo albums online, announced in February that it had retained an adviser to review strategic alternatives after receiving interest from potential buyers.

Shutterfly closed up 2.7% to $50.25 Monday, giving the company a market value of about $1.7 billion. Its shares have fallen about 48% in the past year.

LionTree Advisors is advising Apollo on the deal. Barclays Plc, Citigroup Inc. and SunTrust Banks Inc. are providing financing for the transaction and also serving as financial advisers to Apollo. Apollo is getting legal counsel from Paul, Weiss, Rifkand, Wharton & Garrison LLP.

Morgan Stanley acted as Shutterfly’s financial adviser while Fenwick & West LLP is its legal adviser.