I have a product attribute called remote_image_link. When I retrieve a product using this code:

$mageProduct = Mage::getModel('catalog/product')

And then try and get the value of the attribute RemoteImageLink,


Nothing is returned. But when I add this code:

$mageProduct = Mage::getModel('catalog/product')->load($mageProduct->getId());

Then it works and I can get a value for the remote_image attribute.

How come I have to call load, aren't I loading using the addFieldToFileter


First of all use addAttributeToFilter instead of addFieldToFilter. It's cleaner that way.
And retrieve your product like this:

$mageProduct = Mage::getModel('catalog/product')

When getting a collection not all attributes are added to the collection. You need to add manually the attributes you need.
If for some reason that doesn't work, set the attribute remote_image_link to be Used in product listing.

| improve this answer | |
  • so load will pull in everything but a collection won't pull in all attributes. That is confusing from a developers perspective. I would assume both actions would return the same result. – jstrez77 Dec 3 '13 at 15:28
  • I know it can be confusing at first, but there is a reason for that. Performance. When getting a collection you may not need all the attributes so there is no point in loading all. If you want to load all you can add ->addAttributeToSelect('*') – Marius Dec 3 '13 at 15:30

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.