I am trying to display supplementary information in the grid/list view of my products categories (see example page ( http://marsden.robertobertuol.com/index.php/industrial-scales/bench-scales.html?mode=grid ). I manage to print out the meta title as follows:
echo $_product->getMetaTitle();
But I also want to print out another attribute namely "capacity". Can anyone point me in the right direction? Thanks
if attribute is text than use as below
echo $_product->getCapacity();
if attribute is dropdown
$capacity_id = $_product->getData('capacity');
$productModel = Mage::getModel('catalog/product');
$attr = $productModel->getResource()->getAttribute('capacity'); if ($attr->usesSource()) {
echo $capacity_text = $attr->getSource()->getOptionText($capacity_id);
}
if attribute is multiselect
$attr = $productModel->getResource()->getAttribute("capacity");
$exploded = explode(',',$productModel->getCapacity());
foreach ($exploded as $key => $value) {
if ($attr->usesSource()) {
$capacity_title[] = $attr->getSource()->getOptionText($value);
}
}
print_r($capacity_title);
I found the reason why the value was not printing.
In order for the attribute to be available on other pages (other than the product page), in the backend, the setting "Product Listing" should be set to "Yes". In this case, it is possible to print the value of the attribute ("capacity") by using
echo $_product->getCapacity();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.