This paper describes research on the harmonic-distortion capacity of a single-stage photovoltaic (PV) 3.68 kWp generator in a microgrid configuration. An overview of various harmonic compensator methods used in PV generators is presented to evaluate their advantages and disadvantages. Proportional-resonant (PR) structures with harmonic compensators (HCs) are designed, modeled, and validated through real-time tests. The modeling of harmonic compensation structures for a photovoltaic inverter using MATLAB/SIMULINK R2022a is explained in detail. The harmonic compensation capacity of a PV generator inverter is studied under voltage harmonics, grid frequency variation, and voltage unbalance. The contributions of this work are, firstly a bibliographic analysis of various strategies currently used for harmonic compensation in grid-connected inverters and secondly, a detailed explanation of the modeling of harmonic compensation structures using MATLAB/SIMULINK. Finally, a demonstration of the improvement in energy quality that results from using harmonic compensation techniques in photovoltaic generators in microgrid configurations affected by grid disturbances is performed. The obtained results show that harmonic compensation strategies based on resonant filters are a good alternative for the reduction of harmonic voltage distortion in the presence of grid disturbances such as frequency variation and voltage unbalance.