title: Magento: Product collection filtered by two categories
body: <p>I am writing a module that loads for me a list of featured products. All featured products are seated in their own category + hidden category "featured". The script returns me an error.</p>
  
  <p>On category view (list.phtml) I call for <code>gettopproducts.phtml</code> (which works fine):</p>
  
  <pre><code>&lt;?php $currentCategory = Mage::registry('current_category'); ?&gt;
  &lt;?php $_products = $this-&gt;getTopProducts($currentCategory); ?&gt;
  &lt;?php echo $this-&gt;__('Available products: ').$_products-&gt;count(); ?&gt;
  </code></pre>
  
  <p>From <code>gettopproducts.phtml</code> I call a function <code>getTopProducts()</code> of <code>Gettopproducts.php</code> passing a current category. In <code>Gettopproducts.php</code> I have this:</p>
  
  <pre><code>public function getTopProducts($currentCategory)
  {
      $_productCollection = Mage::getResourceModel('reports/product_collection')
      -&gt;addAttributeToSelect('*')
      -&gt;addCategoryFilter($currentCategory)
      -&gt;addAttributeToFilter('category_ids',array('finset'=&gt;'87'));
      $_productCollection-&gt;load();
      return $_productCollection;
  }
  </code></pre>
  
  <p>This row:<code>-&gt;addAttributeToFilter('category_ids',array('finset'=&gt;'87'));</code> should add a second category filter (ID of the "featured" category). But when I use this, I get an error. When I remove this row: <code>-&gt;addAttributeToFilter('category_ids',array('finset'=&gt;'87'));</code> it works perfectly.</p>
  
  <p>I am using Magento 1.7.2</p>