/** * Build product collection * @param int $storeId Store id * @return Mage_Catalog_Model_Resource_Product_Collection * * The collection is formed thus: * 1. Since we are working with multiple stores, we use Mage:getResourceModel('catalog/product_collection') instead of * Mage::getModel('catalog/product')->getCollection() because the latter will load some store context we * prefer to control explicitly. * 2. setStore() is a method that will set up store context we do need. It does not set filtering. * 3. addAttributeToSelect() to get only the fields we need. Each product's _data will contain only these fields. * 4. addFieldToFilter() basically our 'where' clauses * 5. addStoreFilter() called without arguments defaults to the store most recently setStore()'d. Admin store is explicitly * ignored by addStoreFilter(). * 6. setPageSize() in order to limit collection's use of memory. This is the number of products we'll load at once. */ protected function _buildProductCollection($storeId) { $collection = Mage::getResourceModel('eems_display/product_collection')->setStore($storeId)->addAttributeToSelect(array('sku', 'name', 'short_description', 'price', 'special_price', 'special_from_date', 'special_to_date', 'url_key', 'image'))->addFieldToFilter('visibility', array('neq' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE))->addFieldToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->addStoreFilter()->addAttributeCharLimitToFilter('name', $this->_config->getProductTitleCharLimit())->addInStockToFilter()->setPageSize($this->_config->getProductFeedPageSize()); return $collection; }