1
votes

Magento version: 1.9.2.4 I have file /app/design/frontend/MY_THEME_NAME/default/template/catalog/product/view.phtml

with code:

<?php if ($detailedInfoGroup = $this->getChildGroup('detailed_info', 'getChildHtml')):?>
    <!-- fix full size backround start-->
    </div>
    </div>
    </div>
    <!-- fix full size backround start-->
<div class="specific">
    <div class="container">
    <div class="row">
        <div class="col-sm-12">
            <div class="specific__tab">
                <div class="tabs">
                    <ul class="tabs-ctrl">
                        <?php
                            reset($detailedInfoGroup);
                            $first_key = key($detailedInfoGroup);
                        ?>
                        <?php foreach ($detailedInfoGroup as $alias => $html):?>
                        <li class="tabs-ctrl-item <?php  if($alias == $first_key): ?>active<?php endif; ?>" data-class="<?php echo $alias?>"><?php echo $this->escapeHtml($this->getChildData($alias, 'title')) ?></li>
                        <?php endforeach;?>
                    </ul>
                    <ul class="tabs-list">
                        <?php foreach ($detailedInfoGroup as $alias => $html):?>
                        <li class="tabs-list-item list-<?php echo $alias?> <?php  if($alias == $first_key): ?>active<?php endif; ?>">
                            <?php echo $html ?>
                        </li>
                        <?php endforeach;?>


                    </ul>
                </div>
            </div><!-- specific__tab-->
        </div>
    </div>
    </div>
</div><!-- specific-->
    <!-- fix full size backround end-->
    <div class="container">
    <div class="row">
    <div class="col-xs-12">
    <!-- fix full size backround end-->
<?php endif; ?>

That show Description and Additional Tabs.

In file /app/design/frontend/MY_THEME_NAME/default/template/catalog/product/view/description.phtml

I have following code:

<?php $_description = $this->getProduct()->getDescription(); ?>
<?php if ($_description): ?>
    <h2><?php echo $this->__('Details') ?></h2>
    <div class="std">
        <?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $_description, 'description') ?>
    </div>
<?php endif; ?>

And in file /app/design/frontend/MY_THEME_NAME/default/template/catalog/product/view/attributes.phtml

I have following code:

<?php
    $_helper = $this->helper('catalog/output');
    $_product = $this->getProduct()
?>
<?php if($_additional = $this->getAdditionalData()): ?>
    <h2><?php echo $this->__('Additional Information') ?></h2>
    <table class="data-table" id="product-attribute-specs-table">
        <col width="25%" />
        <col />
        <tbody>
        <?php foreach ($_additional as $_data): ?>
            <tr>
                <th class="label"><?php echo $this->escapeHtml($this->__($_data['label'])) ?></th>
                <td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
            </tr>
        <?php endforeach; ?>
        </tbody>
    </table>
    <script type="text/javascript">decorateTable('product-attribute-specs-table')</script>
<?php endif;?>

If I just copy and paste this code to description.phtml — It's not work, $_additional is empty or doesn't exist.

So, how I can show all attributes on Description tab? I read a lot of topics here and still don't found solution. Thank's a lot!

2

2 Answers

1
votes

Found solution of my problem:

Create file /app/code/local/Mage/Catalog/Block/Product/View/Description.php

with followind code:

class Mage_Catalog_Block_Product_View_Description extends Mage_Core_Block_Template
{
    protected $_product = null;

    function getProduct()
    {
        if (!$this->_product) {
            $this->_product = Mage::registry('product');
        }
        return $this->_product;
    }

    /**
     * $excludeAttr is optional array of attribute codes to
     * exclude them from additional data array
     *
     * @param array $excludeAttr
     * @return array
     */
    public function getAdditionalData(array $excludeAttr = array())
    {
        $data = array();
        $product = $this->getProduct();
        $attributes = $product->getAttributes();
        foreach ($attributes as $attribute) {
            if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), $excludeAttr)) {
                $value = $attribute->getFrontend()->getValue($product);

                if (!$product->hasData($attribute->getAttributeCode())) {
                    $value = Mage::helper('catalog')->__('N/A');
                } elseif ((string)$value == '') {
                    $value = Mage::helper('catalog')->__('No');
                } elseif ($attribute->getFrontendInput() == 'price' && is_string($value)) {
                    $value = Mage::app()->getStore()->convertPrice($value, true);
                }

                if (is_string($value) && strlen($value)) {
                    $data[$attribute->getAttributeCode()] = array(
                        'label' => $attribute->getStoreLabel(),
                        'value' => $value,
                        'code'  => $attribute->getAttributeCode()
                    );
                }
            }
        }
        return $data;
    }

}

And now I can use $_additional = $this->getAdditionalData(); in Description tab.

0
votes

This works for me in tabs.phtml Magento ver. 1.9.3.4

$_product = Mage::registry('current_product');