The 2D extended homogenization model based on molecular chain network theory is employed to investigate the micro-to macroscopic mechanical behavior of polymer with randomly distributed voids under macroscopic compaction. A parametric study is performed to quantify the effect of the volume fraction of voids and the macroscopic stress triaxiality of loading conditions on the compaction behavior of porous polymer. The results suggest that the onset of localized shear band at the ligament between voids leads to the macroscopic yield of porous polymer. Furthermore, the microscopic localized shear deformation behavior is promoted in the polymer with high-volume fraction of voids under high macroscopic stress triaxiality loading condition, which results in the early appearance of the macroscopic yield. After the macroscopic yield, a remarkable strain hardening is shown in the macroscopic response of porous polymer under high macroscopic stress triaxiality loading condition, which is due to the onset and propagation of a large number of shear bands at the ligaments between voids. On the other hand, microscopic buckling develops at the narrowest ligament in the polymer with high-volume fraction of voids under high macroscopic stress triaxiality loading condition, which leads to the relative low macroscopic deformation resistance. Furthermore, to develop the macroscopic constitutive model of polymer with high-volume fraction of voids under high macroscopic stress triaxiality loading condition, a modified Gurson model is proposed which takes account of microscopic buckling and gives a good agreement with the unit cell computational results.