Show product attributes in list.phtml - Magento

喜你入骨 提交于 2019-11-30 16:01:17

you can just config it in attribute edit page

Used in Product Listing -> Yes

Another way

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

If you create an attribute like yours "shoesize" then you can access by following code.

If your attribute type Text Field ( $_product should loaded ) :

<?php
  echo $_product->getShoesize();
  // if your arribute was shoe_size then
  echo $_product->getShoeSize();
?>

If your attribute type Multiple Select or Dropdown, to get all attribute value :

<?php
   echo $_product->getAttributeText('shoesize');
?>

Here is the code get attribute name and value that that doesn't belongs to any product

$attributeCode = 'YOUR_ATTRIBUTE_CODE';

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

$productCollection = Mage::getResourceModel('eav/entity_attribute_collection')
   ->setEntityTypeFilter($product->getResource()->getTypeId())
   ->addFieldToFilter('attribute_code', $attributeCode);

$attribute = $productCollection->getFirstItem()->setEntity($product->getResource());
print_r($attribute->getData()); // print out the available attributes

$options = $attribute->getSource()->getAllOptions(false);
print_r($options); // print out attribute options

Try this:

$_pp2 = Mage::getModel('catalog/product')->load(    $_product->getId()    );
echo $_pp2->getdm();

in:

 <?php $i=0; foreach ($_productCollection as $_product): ?>
        <?php if ($i++%$_columnCount==0): ?>

Attribute Code:dm

Type: Text area

in view.phtml

echo $_product->get>getdm(); ?>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!