will a 2006 nissan 350z engine and transmission fit in a 2004 nissan 350z

I Have a 2004 Nissan 350Z and was told that I need a new engine. I just found a 2006 engine with transmission for a really good deal and don’t want to past it up. Before I go and get more excited to purchase this 2006 engine and tran. Can anyone tell me if this will be a straight fit or will there be any modifications to having this 06 being put in, wiring and all?

prolly same engine no?

pm “SG Sash”