How to circumvent another of Magento’s usability quirks.
While developing a Magento store, we came across one of those head-scratching moments where everything looks right yet still refuses to play nicely. This time around, we had added a media image attribute to allow the client to upload an alternative view of the product. This was to appear in the category product list when a visitor hovered over the item.
However, after adding the attribute (code:
alt_image), reindexing the catalogue (Product Flat Data) and uploading a file, calls to
$_product->getAlt_image(); in catalog/product/list.phtml simply returned
NULL, despite coming through fine in catalog/product/view.phtml.
Simply? We’d missed out setting the “Used in Product Listing” option to Yes when defining the attribute.
Unfortunately, Magento’s UI makes this both easy to miss and awkward to rectify.
“Easy to miss” considering “Used in Product Listing” is hidden 600px below “Catalog Input Type” (below the fold in a 1280×1024 resolution). Also, the field auto-hides when the Media Image type option is selected, so if you don’t remember to start at the bottom of the page, you’re out of luck.
“Awkward to rectify” as once a Magento attribute is saved, the “Catalog Input Type” field is disabled for editing. This means that administrators can’t reveal and alter the field without outside intervention. Or you could delete the attribute, re-add it correctly and hope you don’t have too many products to update the media gallery values of!
Thankfully, there are a couple of tools which allow you to update the “Used in Product Listing” option after the attribute has been saved; both of which should already be familiar to you.
The Web Developer Toolbar > Forms > Enable Form Fields function will make all disabled inputs editable again.
A slightly more long-winded way is to inspect the disabled element in Firebug and delete the “disabled” attribute, which has the same effect.
Once the field is enabled, selecting any value but Fixed Product Tax will reveal the Frontend Properties again, allowing you to update the attributes’ settings.
Once you’re happy, simply save the attribute and re-index your Product Flat Data – you don’t have to worry about changing back to Media Image: Magento will ignore this value when updating the database.
Hopefully this is of help to others stuck in this situation, at least until this is resolved in a future release.
And for anybody wanting to follow this issue’s progress, its number is 26586.