Kind of a spinoff of this question. I'm trying to extend Mage_Catalog_Block_Product_Widget_Link
to make a widget template that displays the product image and an add to cart button along with the product link. Is there any way to get this info without doing Mage::getModel('catalog/product')->load()
?
What Have You Tried
The working-but-ugly way: I know I could split the product id off the
id_path
string supplied by the widget and use it to load the full product, like so:$idPath = explode('/', $this->_getData('id_path')); if (isset($idPath[1])) { $id = $idPath[1]; if ($id) { $product = Mage::getModel('catalog/product')->load($id); /* Use $product to get the needed info */ } }
but this means I'm fetching a big giant product object with lots of data I don't need, possibly several times per page. I'm under the impression that this is not desirable. (Am I wrong?)
- Use getAttributeRawValue in the resource model: I have the resource model available in
$this->_entityResource
but I can't usegetAttributeRawValue
to get the add to cart URL since it's not an attribute. I can get the value of the image attribute this way but can't figure out how to use that to actually display the image. All the templates I've looked at use$this->helper('catalog/image')
which eventually requires a product object. I'd like to be able to use the cache if possible so just straight-up appending it to /media/product/catalog seems like a bad idea. (Wrong?) - Use the getAddToCartUrl function: This also appears to require a product object as the first argument.
Is there a better way I'm not aware of?
This is on CE 1.9, if that makes a difference.