Load product attributes more performant

Recently I had performance issues when importing several ten tausend products. The problem was, that I always used the “normal” product entity model to load attribute values. The following snippet shows, how to load product attributes directly instead. Therefore I use the product resource singleton. <?php $iProductId = $aChange[‘pid’]; $oItem = new Varien_Object; /** * […]

Performance optimized attribute saving

Sometimes, when you have to handle many data-sets, it is more efficient to save only those attributes that have changed: // load product $product = Mage::getModel(“catalog/product”)->load(142);   // change attribute $product->setTitle(“Test”);   // tell resource attribute to save only the specified field $product->getResource()->saveAttribute($product, “title”);  

Automatically load custom product attribute with collection (every time)

You can do this with the following XML in your config.xml: <frontend> <product> <collection> <attributes> <ATTRIBUTECODE/> </attributes> </collection> </product> </frontend> But ATTENTION: This can become a performance issue, because it loads the attribute every time the product collection is loaded! If you added too many attributes, the performance can get worse!