Recently, I have worked with magento site which supports multiple languages. Unfortunately, somethings went wrong with label of attribute in configurable products. It always is displayed the label of default admin label. It does not make sense. As I figured out this is a bug of magento ( I currently worked with magento 1.8.).
The summarize is we must adjust code to display attribute label and attribute option label by store view in magento correctly.
So, there are the ways you can fix this bug by the following steps:
1/ First, adjust the wrong label attribute display in detailed product page. This is due to the wrong label at line 35
<dt><label><em>*</em><?php echo $this->__($_attribute->getLabel()); ?></label></dt>
in app\design\frontend\base\default\template\catalog\product\view\type\options\configurable.phtml
Copy this file template\catalog\product\view\type\options\configurable.phtml to app\design\frontend\your_current_package\your_current_theme and fix it.
Fix :
echo $_attribute->getProductAttribute()->getStoreLabel() instead of echo $this->__($_attribute->getLabel());
2/ Show attribute option label by store view :
You can create an extension override this model or hard-code in magento core:
app\code\core\Mage\Catalog\Model\Product\Type\Configurable.php
Wrong code is : $attribute->getLabel() in fucntion getSelectedAttributesInfo() in line 541 .
So we have to replace this code by $attribute->getProductAttribute()->getStoreLabel();
public function getSelectedAttributesInfo($product = null) { $attributes = array(); Varien_Profiler::start('CONFIGURABLE:'.__METHOD__); if ($attributesOption = $this->getProduct($product)->getCustomOption('attributes')) { $data = unserialize($attributesOption->getValue()); $this->getUsedProductAttributeIds($product); $usedAttributes = $this->getProduct($product)->getData($this->_usedAttributes); foreach ($data as $attributeId => $attributeValue) { if (isset($usedAttributes[$attributeId])) { $attribute = $usedAttributes[$attributeId]; $label = $attribute->getProductAttribute()->getStoreLabel();//replace $attribute->getLabel(); $value = $attribute->getProductAttribute(); if ($value->getSourceModel()) { $value = $value->getSource()->getOptionText($attributeValue); } else { $value = ''; } $attributes[] = array('label'=>$label, 'value'=>$value); } } } Varien_Profiler::stop('CONFIGURABLE:'.__METHOD__); return $attributes; }
Now, the label of attribute and label option attribute are displayed correctly depend on store view.
Enjoy coding.
jafor iqbal
August 21
Thank you.