Page 1 of 1

Specific attribute in a tab

PostPosted: Thu Dec 22, 2011 10:45 pm
by hollister
I have an attribute that I would like to show in a tab.
I have looked at other-magento-extensions-itoris/insert-custom-options-tabs-slider-t2024.html but to be honest, it's a bit over my head.
On the view.phtml page I just enter in this code:
Code: Select all
<?php echo $_product->getResource()->getAttribute('height')->getFrontend()->getValue($_product) ?>
and it echo's the attribute data. How can I get that into a tab?

Re: Specific attribute in a tab

PostPosted: Fri Jan 20, 2012 10:26 pm
by hollister
is this something that is possible?

Re: Specific attribute in a tab

PostPosted: Fri Nov 03, 2017 12:36 pm
by robohaus

It took me a few days (weeks) of research but I did it in three parts...

1 - Create the attribute.

2 - Create a tab and in the tab's text field enter ->
Code: Select all
{{block class="Itoris\Producttabsslider\Block\Frontend\Description" display_Attribute="specifications" template="Itoris_Producttabsslider::product/view/displayattribute.phtml}}

Note: the text display_Attribute="specifications" is the name of the attribute.

Note: you can display multiple attributes and place the content anywhere you like, you just need to change the name of the attribute you want to display i.e. change specifications to whatever.

3 - Using FTP go to /public_html/app/code/Itoris/Producttabsslider/view/frontend/templates/product/view/

then create a file called displayattribute.html

then in the file displayattribute.html enter...

Code: Select all
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.

// @codingStandardsIgnoreFile

* Product view template
* @see \Magento\Catalog\Block\Product\View
$_helper = $this->helper('Magento\Catalog\Helper\Output');
$_product = $block->getProduct();
$_call = $block->getAtCall();
$_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();
if ($_attributeType && $_attributeType == 'text') {
    $_attributeValue = ($_helper->productAttribute($_product, $_product->$_call(), $_code)) ? $_product->getAttributeText($_code) : '';
} else {
    $_attributeValue = $_helper->productAttribute($_product, $_product->$_call(), $_code);

echo $_product->getResource()->getAttribute($block->getData('display_Attribute'))->getFrontend()->getValue($_product);