2

I am confused. What is the point of that label if I always get Admin label? I want to get Default Store View title. I want this title to be displayed for configurable products. I can get it through <?php echo $_product->getResource()->getAttribute('test')->getStoreLabel() ?> but I still have to see how to get attribute code. Is there any simpler solution to achieve this?enter image description here

Denisa
  • 508
  • 1
  • 10
  • 26
  • I don't agree that is a duplicate :) I mean I don't want the entire list and also I am in another context – Denisa Oct 14 '14 at 08:50

1 Answers1

7

please try the below code. with the using of this code you got the attribute Label.

// Here you can have whole model of perticular attribute.
$productAttribute = $_product->getResource()->getAttribute($attrCode);

// Now you can get it by store or can get all.
$_label = $productAttribute->getStoreLabel(Mage::app()->getStore()->getId());
echo $_label;
Keyul Shah
  • 7,219
  • 12
  • 37
  • 60
  • where attribute code $attrCode is? I know what it is ..but how can I get it in my context? I am in configurable.phtml. What I don't get why the things aren't simple like instead of <?php echo $_attribute->getLabel() ?> to have <?php echo $_attribute->getStoreLabel() ?> – Denisa Oct 14 '14 at 08:48
  • I can achieve what I want through <?php foreach($_attributes as $_attribute): $attribute = Mage::getModel('catalog/resource_eav_attribute')->load($_attribute->getAttributeId());?> <dt><label class="required"><em>*</em><?php echo $attribute->getStoreLabel() ?></label></dt> but I wanted something simpler. I mean..why should I load a model to get a label which should have been there....Am I missing something? – Denisa Oct 14 '14 at 08:49
  • $attrCode means for example color is attribute then when you edit the color you can see the attribute code you have to use that attribute code – Keyul Shah Oct 14 '14 at 09:00
  • I think you didn't understand what I said. I know what is attribute but how can I get there..because that file is used for all configurable attributes, I can't just hardcode 'color' – Denisa Oct 14 '14 at 09:06
  • so you can fetch the attribute code from id – Keyul Shah Oct 14 '14 at 09:15