-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unused product attributes display with value N/A or NO on storefront #9961
Comments
app/code/Magento/Catalog/Block/Product/View/Attributes.php
remove ($value instance Phrase || and return to prior value to fix this! |
Hello, @thomasnordkvist. Based on Your issue an internal ticket was created - MAGETWO-69919. You'll be informed when the issue is fixed. Thank's for applying. |
If you don't want to create a module and inject a block you can fix it in the template too. It needs some rather ugly looking code. Override module-catalog/view/frontend/templates/product/view/attributes.phtml and adjust the appropriate bit to look like this.
Delete the file, if the patch ever makes it into a release. |
Any update on this one? |
Hi. Not yet. |
It looks like this problem is being addressed in: #10619 The patch to apply to Magento 2.1.7/2.1.8 is slightly different then the one in #10619, because Magento 2.1.7 had already a more correct fix (introduced in d977dc3#diff-8bb5f6b700bf55d266640da3251af32cL89) then the one in the develop branch (introduced in #8623): diff --git a/app/code/Magento/Catalog/Block/Product/View/Attributes.php b/app/code/Magento/Catalog/Block/Product/View/Attributes.php
index 6960ff0b8e5..1da3f1d66e0 100644
--- a/app/code/Magento/Catalog/Block/Product/View/Attributes.php
+++ b/app/code/Magento/Catalog/Block/Product/View/Attributes.php
@@ -81,13 +81,15 @@ class Attributes extends \Magento\Framework\View\Element\Template
if (!$product->hasData($attribute->getAttributeCode())) {
$value = __('N/A');
+ } elseif ($value instanceof Phrase) {
+ $value = (string)$value;
} elseif ((string)$value == '') {
$value = __('No');
} elseif ($attribute->getFrontendInput() == 'price' && is_string($value)) {
$value = $this->priceCurrency->convertAndFormat($value);
}
- if (($value instanceof Phrase || is_string($value)) && strlen($value)) {
+ if (is_string($value) && strlen($value)) {
$data[$attribute->getAttributeCode()] = [
'label' => __($attribute->getStoreLabel()),
'value' => $value, Testing by applying the patch above to Magento 2.1.7 seems to fix the problem. It still feels kind of strange that Phrases aren't being outputted, so maybe the two Phrases ( |
Expected result does not seem to be valid to me. Why "visible on catalog storefront" needs to be set to Yes in this scenario? The fact such attribute was not displayed before due to a bug does not justify the expected result. |
Because sometimes a product doesn't have a value set for a certain attribute on product level, and we (in our case, not sure if everybody wants this) want to see the attribute when it is filled in, and not see it when it is empty. Thinking about it, it's probably more correct like you are saying and still display I think the reason why it surprised so many people is that the behavior changed between 2.1.6 and 2.1.7 and this change of behavior was considered a new bug, but that's probably not true thinking it through. I think you are correct @orlangur, thanks for persisting :) |
Ok, it becomes more and more clear. Not sure where the requirement to display Let's get back to current PR to understand the necessary changes. |
I think it's better to hide the attributes without values, like 2.1.6 and earlier versions did. Please make that an option. |
@thomasnordkvist, thank you for your report. |
@hostep I implemented your fix and it seems to work well on the productpage in my local dev environment, but when we test it (unit testing using Travis), Travis fails to accept this solution. Any idea why this error shows up and how to fix this error?
|
@Tristan-N please continue work on top of https://github.com/magento/magento2/pull/10619/files branch. The only problem left there was integrity test for translations didn't like Another case which would be nice to be covered is to not perform string casting when |
The issue has been fixed and delivered to 2.2-develop branch. Will be available with upcoming patch release |
I had a template fix against 'N/A' in 2.2.x but now in 2.2.4 it is 'No' 'Non' etc in all languages and __('No') doesn't translate ... so I have to check against all translation of 'No'. Any clue ? |
Preconditions
Steps to reproduce
Expected result
Actual result
This "Fix" introduced this behavior
The text was updated successfully, but these errors were encountered: