BROOKLYN — Midtown electronics and photography hub B&H Photo will shut down its Bushwick and Navy Yard warehouses, opting to consolidate operations at one massive warehouse in New Jersey, marking the end 17 years of work in the borough, the company said.

The move, announced Thursday and slated to take place in the second half of 2017, has blindsided union representatives, who were still in the process of negotiating a contract for roughly 300 B+H warehouse employees, they said.

In total, New York city will lose 335 jobs spread between the two locations.

Company executives said they'd tried for several years to find another location in New York City, but blamed their inability to do so on its hot real estate market.

"Large warehouses are not available on the market in NYC due to the booming real estate industry here," wrote Menashe Horowitz, a top executive at B&H, in a memo sent to all employees on Jan. 12 obtained by DNAinfo New York.

"We worked closely with New York State government leaders to find a new home here in New York, but unfortunately we were unable to find a facility here that came even close to meeting our needs."

The Navy Yard facility will become a movie studio when the company leaves at the end of this year, according to David Ehrenberg, the head of the Brooklyn Navy Yard's Development Corporation.

The company will begin moving operations to Florence Township, N.J. in the second half of 2017, where they've secured a a 500,000-square-foot facility, in B&H officials said.

The main Midtown retail outlet, which includes corporate offices and a store warehouse, will remain open with roughly 1,500 employees, management said.

Current warehouse workers at the Navy Yard and Evergreen Avenue warehouse in Bushwick can join the company in New Jersey if they choose.

B&H first opened in 1973 in TriBeCa and moved to various locations before opening its current 34th Street location in 1997. The company used a warehouse in the basement at the beginning and expanded operations to the Navy Yard in 2000, and in 2013 opened their Bushwick warehouse at 105 Evergreen Ave.

But over the years, reports and lawsuits have raised concerns about conditions for workers inside those warehouses.

B&H was sued for racist and sexist labor practices, discrimination and cited for unsafe work standards.

In October 2015, around 300 warehouse workers voted to unionize.

Union spokesman Wayne Ranick said United Steelworkers had been in ongoing talks with B+H to hammer out a contract and only learned earlier this week that the rug had been pulled out of those negotiations.

"We had been bargaining in good faith,” he said. “It was totally unexpected."

The mayor's press office didn't immediately respond to a request for comment.