Please see attached screenshot: [![enter image description here][1]][1]
I created one custom product attributes ETA_DATE and I want to display same as attached image. How to display this attribute on product page?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityPlease see attached screenshot: [![enter image description here][1]][1]
I created one custom product attributes ETA_DATE and I want to display same as attached image. How to display this attribute on product page?
Try below code to get custom attribute value.
<?php echo $this->helper('Magento\Catalog\Helper\Output')->productAttribute($block->getProduct(), $block->getProduct()->getEtaDate(), 'Eta_Date')); ?>
Update:
app/design/frontend/CUSTOM/THEME/Magento_Catalog/templates/product/list.phtml
$attribute = $_product->getResource()->getAttribute('attribute_code');
// Get Value
$attributeValue = $attribute->getFrontend()->getValue($_product);
// Get Label
$attributeLabel = $attribute->getStoreLabel();
Note: Make sure “Visible on Product View Page on Front-end” and “Used in Product Listing” options under storefront Properties are set to Yes.
Update:
<?php
if(!$_product->getIsSalable()):
$attribute = $_product->getResource()->getAttribute('eta_date');
$etaDate = $attribute->getFrontend()->getValue($_product);
$newDate = date("d/m/Y", strtotime($etaDate));
$etaLabel = $attribute->getStoreLabel();
echo $etaLabel." ".$etaDate;
endif;
?>
app\design\frontend\Vendor\theme\Magento_Catalog\templates\product\view\addtocart.phtml
use this file.
Nov 29, 2018 at 21:51