I want to display my custom attribute on "Detail" Tab. (now it display on "More information" tab)
Thanks !
Override vendor/magento/module-catalog/view/frontend/templates/product/view/attribute.phtml
in your custom theme
app/design/frontend/Vendor/theme/Magento_Catalog/templates/product/view/attribute.phtml
Here you need to check if $_code == "description"
and show product custom attribute like
<?php if ($_attributeValue): ?>
<div class="product attribute <?= /* @escapeNotVerified */ $_className ?>">
....
....
<?php
if($_code == "description") {
echo $_product->getCustomAttribute(); // Get product custom attribute
}
?>
</div>
<?php endif; ?>
Add this below code in your catalog_product_view.xml
file.
app/design/frontend/ThemePackage/themename/Magento_Catalog/layout/catalog_product_view.xml
<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<container name="product.info.main" htmlTag="div" htmlClass="product-info-main product-shop col-md-7 col-sm-7 col-xs-12" after="product.info.media">
<block class="Magento\Catalog\Block\Product\View\Description" name="product.info.measurements" template="product/view/customattribute.phtml" after="product.info.overview">
<arguments>
<argument name="at_call" xsi:type="string">getMeasurements</argument>
<argument name="at_code" xsi:type="string">measurements</argument>
<argument name="css_class" xsi:type="string">measurements</argument>
<argument name="at_label" xsi:type="string">measurements</argument>
<argument name="add_attribute" xsi:type="string">itemprop="measurements"</argument>
</arguments>
</block>
</container>
</referenceContainer>
</body>
</page>
Now, create customattribute.phtml
for your custom attribute display in details tab
app/design/frontend/ThemePackage/themename/Magento_Catalog/templates/product/view/customattribute.phtml
<?php
$_helper = $this->helper('Magento\Catalog\Helper\Output');
$_product = $block->getProduct();
$_code = $block->getAtCode();
$_className = $block->getCssClass();
$_attributeLabel = $block->getAtLabel();
$_attributeType = $block->getAtType();
$_attributeAddAttribute = $block->getAddAttribute();
if ($_attributeLabel && $_attributeLabel == 'default') {
$_attributeLabel = $_product->getResource()->getAttribute($_code)->getFrontendLabel();
}
$_attributeValue =$_product->getResource()->getAttribute($_code)->getFrontend()->getValue($_product);
?>
<?php if ($_attributeValue) { ?>
<div class="product attibute <?php echo $_className?>">
<div class="value" <?php echo $_attributeAddAttribute;?>>
<?php echo $_attributeValue;
if($_code == "description") {
echo $_product->getCustomAttribute();
}
?>
</div>
</div>
<?php } ?>