title: Magento: serialization error on caching Collection
body: <p>I wrote an extension in which a base abstract class contains a function that will extract a product collection:</p>
  
  <pre><code>$cache = Mage::app()-&gt;getCache();
          if(!$cache-&gt;load('itserv_feed_collection')) {
              $_productCollection = Mage::getModel('catalog/product')-&gt;getCollection();
              $_productCollection-&gt;addAttributeToSelect('*');                        
              $_productCollection-&gt;addAttributeToSelect('stock_status');        
              $_productCollection-&gt;addAttributeToSelect(Mage::getStoreConfig('feed_options/mappa_attributi/produttore'));
              $_productCollection-&gt;addAttributeToSelect(Mage::getStoreConfig('feed_options/mappa_attributi/ean'));
              $_productCollection-&gt;addAttributeToSelect(Mage::getStoreConfig('feed_options/mappa_attributi/mpn'));      
              $_productCollection-&gt;addAttributeToFilter('type_id', Mage_Catalog_Model_Product_Type::TYPE_SIMPLE);                                                                       
              $cache-&gt;save(serialize($_productCollection), "itserv_feed_collection", array("itserv_feed_collection"), 120);                
          }
          else {                
              $_productCollection = unserialize($cache-&gt;load('itserv_feed_collection'));
          }
          return $_productCollection;
  </code></pre>
  
  <p>Each of the child classes extending from this class will use the same collection in the same runtime stack. I want to save this collection within the cache (as you can see looking at the code), so since the second time a child class will use it, the script will not need to load it again.</p>
  
  <p>The problem is that it is impossible to use cache, because cache needs a serialized Collection and, in this case, i cannot do it because the collection contains the Mage_Core_Model_Config_Element that can't be serialized (it triggers the famous error "Serialization of 'Mage_Core_Model_Config_Element' is not allowed").</p>
  
  <p>I tried different solutions, even json_encode/json_decode instead of serialize/unserialize, but i can't solve the problem.</p>
  
  <p>Do you have some solution? Thanks!</p>