1

I am trying to create a Asos style header on my Magento category page.

In this box I have pulled in the category title and the category description, I am also some how needing to pull in a specific attribute from the layered navigation into the category view.phtml page.

At the moment I have

<?php $prod = Mage::getModel('catalog/product')->load($productId); $att = $prod->getResource()->getAttribute('product')->getFrontend()->getValue($prod); echo $att; ?>

But it is just pulling in the word No instead of the attributes that it is showing in the layered navigation for this specific category.

j0k
  • 22,600
  • 28
  • 79
  • 90
Matt
  • 1,747
  • 8
  • 33
  • 58

3 Answers3

0

Try this:

Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'attribute_code', $storeId);

Thanks to @Daniel Kocherga for the original answer here.

Community
  • 1
  • 1
pzirkind
  • 2,338
  • 2
  • 20
  • 25
  • 1
    I have just changed it to that but now nothing is being pulled in should it just be `getAttributeRawValue($productId, 'product', $storeId); ?>` or should I have to echo it as well somehow? – Matt Aug 22 '12 at 14:45
  • 1
    That dosen't seem to have made a differnace I now have `getAttributeRawValue($productId, 'product', $storeId); ?>` any more ideas? I am using 1.7.0.1 if that helps. – Matt Aug 22 '12 at 15:12
  • 1
    I though I had to change 'attribute_code' parameter to the attribute that I want to show a list of? I have changed it back but still nothing is showing? – Matt Aug 22 '12 at 15:23
  • yes you are correct, i just didn't see it in the code you posted, i'll try to look in to this soon :) – pzirkind Aug 22 '12 at 15:58
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/15674/discussion-between-pzirkind-and-matt) – pzirkind Aug 22 '12 at 16:04
0

From code/core/mage/catalog/block/product/view/attributes.php

   public function getAdditionalData(array $excludeAttr = array())
    {
        $data = array();
        $product = $this->getProduct();
        $attributes = $product->getAttributes();
        foreach ($attributes as $attribute) {
//            if ($attribute->getIsVisibleOnFront() && $attribute->getIsUserDefined() && !in_array($attribute->getAttributeCode(), $excludeAttr)) {
            if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), $excludeAttr)) {
                $value = $attribute->getFrontend()->getValue($product);

                if (!$product->hasData($attribute->getAttributeCode())) {
                    $value = Mage::helper('catalog')->__('N/A');
                } elseif ((string)$value == '') {
                    $value = Mage::helper('catalog')->__('No');
                } elseif ($attribute->getFrontendInput() == 'price' && is_string($value)) {
                    $value = Mage::app()->getStore()->convertPrice($value, true);
                }

                if (is_string($value) && strlen($value)) {
                    $data[$attribute->getAttributeCode()] = array(
                        'label' => $attribute->getStoreLabel(),
                        'value' => $value,
                        'code'  => $attribute->getAttributeCode()
                    );
                }
            }
        }
        return $data;
    }
}

Pretty sure this is the responsible section for displaying a 'No' or 'N/A' with your attributes

Chris
  • 1
-1

I am not sure but see below URL. I think it is help full to you.

How to add attributes to product grid in category

http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/catalog/add-attributes-to-product-grid

Magento Attributes: Using Different Filterable Attributes Per Category

http://www.human-element.com/Blog/ArticleDetailsPage/tabid/91/ArticleID/68/Magento-Attributes-Using-Different-Filterable-Attributes-Per-Category.aspx

Get Data for Magento Category Attribute on Product Page

http://spenserbaldwin.com/magento/get-data-for-new-magento-category-attribute

Abid Hussain
  • 7,724
  • 3
  • 35
  • 53