Last active
          September 10, 2020 11:36 
        
      - 
      
- 
        Save enis-ismail/7786211 to your computer and use it in GitHub Desktop. 
    Magento: Get attribute option's label by ID and vice versa
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| $productModel = Mage::getModel('catalog/product'); | |
| $attr = $productModel->getResource()->getAttribute("color"); | |
| if ($attr->usesSource()) { | |
| echo $color_id = $attr->getSource()->getOptionId("Red"); | |
| echo $color_label = $attr->getSource()->getOptionText("8"); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment