@Bertriz , you don’t need to code to do disable the sidebar. It’s there in the Customizer settings to enable/disable the sidebar.
All you need to do is go to Customize → Click on Products link in your website (in the Customize frame) or choose Collection pages from the dropdown:
and it should take you to an options page which should look like this:
Click on Collection and it should display these options:
All you need to do is uncheck the Enable sidebar option.