June 4, 2016 1:26 pm
image_round

Magento 2: How to get custome attribute ?

 

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$_product = $objectManager->get('Magento\Catalog\Model\Product')->load($_item->getProduct()->getId());

<?php 
      $attr = $_product->getResource()->getAttribute('brand');
      if ($attr->usesSource()) {
        $optionText = $attr->getSource()->getOptionText($_product->getBrand()); ?>
      <div class="brand">
        <span><?php echo $optionText; ?></span>
      </div>
    <?php 	} ?>

 

 

Magento 2: How to get custome attribute ?

 

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$_product = $objectManager->get('Magento\Catalog\Model\Product')->load($_item->getProduct()->getId());

<?php 
      $attr = $_product->getResource()->getAttribute('brand');
      if ($attr->usesSource()) {
        $optionText = $attr->getSource()->getOptionText($_product->getBrand()); ?>
      <div class="brand">
        <span><?php echo $optionText; ?></span>
      </div>
    <?php 	} ?>