2

Really the title explains it!

I'm trying to perform some extra checks on products in the cart, however in order to do so I need to grab some extra attributes from the product.

Calling

 $item->getProduct() 

only returns a small subset of the product's attributes, and doesn't include what I need.

At the moment, I'm re-loading the product using

 Mage::getModel('catalog/product')->load($item->getProductId()); 

but this seems a really in-efficient way of doing it.

Is there a way to add extra attributes to the

 $item->getProduct()

call without extending the class method?

Thanks!

1

You can use magento collections and specify which attributes to load, try this:

Mage::getModel('catalog/product')->getCollection()
    ->addAttributeToFilter('entity_id', $productId)
    ->addAttributeToSelect('some_attribute')
    ->addAttributeToSelect('one_more_attribute');
|improve this answer|||||
  • Hi @lloiacono - that's essentially what I am doing at the moment, except I am using load(). The question was more if there was a way to avoid loading the product twice. – Liam Wiltshire Jun 15 '15 at 13:56
  • When you use load it will get everything, if you want to get just the attributes you need then you should do it with collections, as far as I know there is no other way to prevent loading twice. But you could replace the first load with the collection load, this way you are loading the product only once with the information you need – lloiacono Jun 15 '15 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.