If you want to filter a product collection by categories as well, the following code may help. Once the category filter is applied, the collection contains only products from the specified categories, in this example category IDs 123 and 456.

Filtering product collections by category
Need help implementing this solution, or still looking for a fix to your Magento problem? Get in touch and I will be happy to help with your project.
Tags: