title: Magento: Walking a collection of configurables in a module Observer.php file
body: <p>In my model observer class I have:</p>
  
  <pre><code>$products = Mage::getResourceModel('catalog/product_collection')
                  -&gt;addAttributeToSelect('sku')
                  -&gt;addAttributeToSelect(array('name', 'short_description', 'description', 'price', 'image', 'status', 'manufacturer', 'url_path'), 'inner');
  </code></pre>
  
  <p>I then try to iterate:</p>
  
  <pre><code>Mage::getSingleton('core/resource_iterator')-&gt;walk($products-&gt;getSelect(), array('productCallback'), array('arg1' =&gt; '===='));
  </code></pre>
  
  <p>This is cribbed from the Fontis tutorial:</p>
  
  <p><a href="http://www.fontis.com.au/blog/magento/loading-large-collections" rel="nofollow">http://www.fontis.com.au/blog/magento/loading-large-collections</a></p>
  
  <p>Now I want to add my function into my class:</p>
  
  <pre><code>private function xproductCallback($args)
  {
  $product = Mage::getModel('catalog/product');
  $product-&gt;setData($args['row']);
  
    if ($product-&gt;getTypeId()=="configurable") {
      echo $args['arg1'] . "\n";
      echo $product-&gt;getSku() . ': ' . $product-&gt;getName() . "TYPE ". $product-&gt;getTypeId() ."\n";
      }
  }
  </code></pre>
  
  <p>Now does it work? Don't think so:</p>
  
  <p><code>Warning: call_user_func() expects parameter 1 to be a valid callback, function 'productCallback' not found or invalid function name app/code/core/Mage/Core/Model/Resource/Iterator.php on line 50</code></p>
  
  <p>So where should I put my callback function?</p>
  
  <p>Also weird is how the collection works. I only want product type configurable but when I add </p>
  
  <p><code>-&gt;addAttributeToFilter('type_id', array('eq' =&gt; Mage_Catalog_Model_Product_Type::CONFIGURABLE))</code> (or any variant thereof) it doesn't give me a collection of configurables to walk. Why is that?</p>