0

I've been having problems with product attributes in Magento 2 showing N/A and No instead of being hidden, all solutions refer you to locate the attributes.phtml file. However I cannot trace that file, is there another solution?

3
  • So you're saying this file doesn't exist? vendor/magento/module-catalog/view/frontend/templates/product/view/attributes.phtml. It should do as it's part of Magento 2's core.
    – Ben Crook
    Commented Aug 31, 2017 at 13:20
  • Well there it is, thank you! I've been looking just under app/design/... and had no luck! Commented Aug 31, 2017 at 13:24
  • Ah right, I thought you meant it wasn't there at all that's why I was confused! I've included it as an answer now, if it's correct please mark it as an accepted answer.
    – Ben Crook
    Commented Aug 31, 2017 at 13:32

2 Answers 2

0

The file is located under the vendor folder, you will need to copy it over to your theme. Never make changes to files inside vendor (core files) as you will likely lose them when you update/upgrade.

vendor/magento/module-catalog/view/frontend/templates/produc‌​t/view/attributes.ph‌​tml
0

The code I used that also actually works to replace the N/A and No on the product attributes is this:

    <?php
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

/**
 * Product additional attributes template
 *
 * @var $block \Magento\Catalog\Block\Product\View\Attributes
 */
?>
<?php
    $_helper = $this->helper('Magento\Catalog\Helper\Output');
    $_product = $block->getProduct()
?>
<?php if ($_additional = $block->getAdditionalData()): ?>
    <div class="additional-attributes-wrapper table-wrapper">
        <table class="data table additional-attributes" id="product-attribute-specs-table">
            <caption class="table-caption"><?php /* @escapeNotVerified */ echo __('More Information') ?></caption>
            <tbody>
            <?php foreach ($_additional as $_data): ?>
                <?php if($_data['value'] == 'N/A') continue;?>
                <?php if($_data['value'] == 'No') continue;?>
                <tr>
                    <th class="col label" scope="row"><?php echo $block->escapeHtml(__($_data['label'])) ?></th>
                    <td class="col data" data-th="<?php echo $block->escapeHtml(__($_data['label'])) ?>"><?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
    </div>
<?php endif;?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.