You could change the query in the getProducts method(class Category), where you can add stock check (this function is used to bring the products), or you could change the settings for product visibility, i.e. when a product is out of stock, you change its visibility to nowhere, and when it comes back in stock, you make it visible again (there are modules that do this, you can even find free ones).