Skip to content

Short Description attribute label showing up as translated string from 'none' in non-english storeview product/view page #9295

Closed
@pguedesbr

Description

@pguedesbr

Preconditions

  1. Have a storeview in a language other than en_US
  2. Have a language pack / dictionary with translated string for 'none'

Steps to reproduce

  1. Add a product with some text for the short description attribute
  2. Visit the product view/detail page in a storeview for a different language (eg, pt_BR)

Expected result

  1. The short description text should appear right bellow the add to and send email blocks

Actual result

  1. There is an attribute label just before the short description text. This label is the equivalent to 'none' ('nenhum' in pt-br)translation for the current storeview locale

image

I traced the code and found out the following:

  • The attribute label is set in catalog_product_view.xml
<block class="Magento\Catalog\Block\Product\View\Description" name="product.info.overview" template="product/view/attribute.phtml" group="detailed_info" after="product.info.extrahint">
    <arguments>
        <argument name="at_label" translate="true" xsi:type="string">none</argument>
    </arguments>
</block>
  • The product/view/attribute.phtml template has a condition to only show the attribute label if it's different than 'none'
$_attributeLabel = $block->getAtLabel();
<?php if ($_attributeLabel != 'none'): ?><strong class="type"><?php /* @escapeNotVerified */ echo $_attributeLabel?></strong><?php endif; ?>
  • Since the attribute label tag has translate="true", it's not always equal to 'none' in the template, therefore resulting in the printing of the undesired attribute label.

My suggested solution is to either:

  • Remove the translate="true" of the xml tag; or
  • Consider the translated string in the if condition, like so:
    <?php if ($_attributeLabel != __('none')): ?><strong class="type"><?php /* @escapeNotVerified */ echo $_attributeLabel?></strong><?php endif; ?>

As of now, our temporary solution has been to insert 'none' = 'none' in our pt_BR language pack, hence not needing to rewrite template files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions