title: Magento - joinField() query to add store_id to products in collection
body: <p>I've been trying for months now to filter a product collection by it's store root category. I've tried numerous different ways ( <a href="https://stackoverflow.com/questions/5069318/magento-addstorefilter-not-working">Magento - addStoreFilter not working?</a> , <a href="https://stackoverflow.com/questions/5078752/magento-addcategoryfilter-filtering-product-collection-by-root-category">Magento -&gt;addCategoryFilter - filtering product collection by root category</a> , <a href="https://stackoverflow.com/questions/5382484/magento-loading-root-collection-loads-all-products">Magento - Loading root collection loads all products</a> ) but still haven't found anything that works. </p>
  
  <p>So I want to try adding in the store_id to the products in a collection. I can call the collection using the following, but I need to join some fields in order to add the store_id:</p>
  
  <pre><code>$_testproductCollection = Mage::getResourceModel('catalog/product_collection');
  $_testproductCollection-&gt;getSelect()-&gt;distinct(true);
  $_testproductCollection-&gt;addAttributeToSelect('*')-&gt;load();
  </code></pre>
  
  <p>The joinField I need is something like the following (which was given in a post linked above) but the <strong>store_id=1</strong> part changes every products store_id to 1, which I don't want, I just want a way to add it's designated store so I can then filter by it.</p>
  
  <pre><code>$_testproductCollection-&gt;joinField('store_id', 'catalog_category_product_index', 'store_id', 'product_id=entity_id', '{{table}}.store_id = 1', 'left');
  </code></pre>
  
  <p>Can anyone point me in the right direction? Cheers!</p>