To show the custom attribute value on the wishlist section of customer dashboard do the following thing
- From admin panel go to the below location
Admin_panel > STORES > Attributes > Products > select the attribute
- Go to the storefront properties please refer this
- Look for the Used in Product Listing change it to yes please refer this
- Save the attribute
- Now copy the
name.phtml
file from the below location
magento_root/vendor/magento/module-wishlist/view/frontend/templates/item/column/name.phtml
- Paste it to the below location
magento_root/app/design/frontend/Vendor/theme/Magento_Wishlist/templates/item/column/name.phtml
- Paste the below code to the newly created name.phtml
name.phtml
<?php if(!empty($product)) : ?>
<?php $attributeValue = $product->getResource()->getAttribute('attibute_name')->getFrontend()->getValue($product);
$attributeLabel = $product->getResource()->getAttribute('attibute_name')->getFrontend()->getLabel($product);
if(!empty($attributeValue)) { ?>
<h2 class="product-<?php echo $attributeLabel?>"><strong><?php echo __($attributeLabel);?></strong> <?php echo __($attributeValue); ?></h2>
<?php }
endif; ?>
Note: Replace the attribute_name with the name of your attribute that
you can copy from the Admin panel.
You can also use some other phtml file but make sure to call it using the layout.xml file for the wishlist you can use wishlist_index_index.xml
file
If the content is not loading then to flush the cache run the below
command
php bin/magento cache:flush