0

I've created a phtml file to display some custom product attributes on my product page however I am unsure how I can get the product attribute to display?

I've tried

 <?php 
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); 

$_product = $objectManager->get('Magento\Catalog\Model\Product')->load($product_id);
echo $_product->getData('fld_sub_title');
?>

but keep getting internal server error from this :(

Any help would be appreciated

1
  1. please check the custom product attribute assigned corresponding attribute set.

  2. To Display, the new attribute in List Page, set the value “YES” to “Used in Product Listing” under storefront Properties while creating the attribute.

  3. To display the attribute value in product list page, add the below code in app/design/frontend/YOUR_VENDOR/YOUR_THEME/Magento_Catalog/templates/product/list.phtml.

for detailed answer please follow the below link

http://www.dckap.com/blog/display-custom-attribute-value-product-viewlist-page-magento-2/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.