I have to develop a Magento plugin to export products. I know other plugin already exist, but I must do it.
Export products is not really difficult, I use something like that (in condensed) :
public function __construct()
{
$this->_productModel = Mage::getModel('catalog/product');
//Other actions ..
}
public function _toHtml()
{
$products = $this->_productModel->getCollection()
->addStoreFilter($storeId)
->addAttributeToFilter('type_id',array('in'=>$_types))
->joinTable('cataloginventory/stock_item', 'product_id=entity_id', array('qty'=>'qty','is_in_stock' => 'is_in_stock'), $this->_getStockSQL(), 'inner');
foreach($product_list as $product)
{
$_p = $this->_productModel->load($product);
$p = $_p->getData();
//Export data, parse and return it ..
}
}
So like you can see, I use a private var to stock Mage::getModel('catalog/product') object. I thought to call this method each time consumed a lot of resources, that is what I wanted to store this variable.
But with this process, if a product is child of a configurable product, data are data are those of the parent.
So, can I clear this objet ? Called Mage::getModel('catalog/product') he requires a lot of resources? Can I force it to load the child data ?
Thanks ;)