{"id":4522,"date":"2016-09-26T17:25:37","date_gmt":"2016-09-26T16:25:37","guid":{"rendered":"https:\/\/www.utilewebsites.nl\/knowledgebase\/magento-2-0-x-problem-product-attributes-type-yes-no-not-showing-on-front-boolean-product-attributes\/"},"modified":"2023-04-06T07:29:11","modified_gmt":"2023-04-06T06:29:11","slug":"magento-2-0-x-problem-product-attributes-type-yes-no-not-showing-on-front-boolean-product-attributes","status":"publish","type":"wz_knowledgebase","link":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/magento-2-0-x-problem-product-attributes-type-yes-no-not-showing-on-front-boolean-product-attributes\/","title":{"rendered":"Magento 2.0.x Problem product attributes Type Yes\/No, not showing on front (Boolean product attributes)"},"content":{"rendered":"<p>\nIf product has boolean attribute, this attribute is not visible on product page view.<\/p>\n<p>We don't have the best solution but for the time being it works in one of our Magento 2.07 projects. We rewrote a function in : vendormagento-module-catalog.php to<\/p>\n<pre class=\"lang-php prettyprint prettyprinted\"><code>\n \n public function getAdditionalData(array $excludeAttr = ['media_gallery'])\n    {\n        $data = [];\n          $product = $this-&gt;getProduct();\n        $attributes = $product-&gt;getAttributes();\n\n        foreach ($attributes as $attribute) {\n    \n     \n            if ($attribute-&gt;getIsVisibleOnFront() &amp;&amp; !in_array($attribute-&gt;getAttributeCode(), $excludeAttr)) {\n                $value =  str_replace('\"',\"\",json_encode($attribute-&gt;getFrontend()-&gt;getValue($product)));\/\/$attribute-&gt;getFrontend()-&gt;getValue($product);\n                if ($value == '' or $value == 'null'){\n                    $value = -1;\n                    \n                }\n\n                    \n            \n                if (!$product-&gt;hasData($attribute-&gt;getAttributeCode())) {\n                    $value = __('N\/A');\n                } elseif ((string)$value == '') {\n                    $value = __('No');\n                } elseif ($attribute-&gt;getFrontendInput() == 'price' &amp;&amp; is_string($value)) {\n                    $value = $this-&gt;priceCurrency-&gt;convertAndFormat($value);\n                }\n\n                if (is_string($value) &amp;&amp; strlen($value)) {\n                    $data[$attribute-&gt;getAttributeCode()] = [\n                        'label' =&gt; __($attribute-&gt;getStoreLabel()),\n                        'value' =&gt; $value,\n                        'code' =&gt; $attribute-&gt;getAttributeCode(),\n                    ];\n                }\n            }\n        }\n   \n        return $data;\n    }\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If product has boolean attribute, this attribute is not visible on product page view. We don't have the best solution but for the time being it works in one of our Magento 2.07 projects. We rewrote a function in : vendormagento-module-catalog.php to public function getAdditionalData(array $excludeAttr = ['media_gallery']) { $data = []; $product = $this-&gt;getProduct(); $attributes = $product-&gt;getAttributes(); foreach ($attributes as $attribute) { if ($attribute-&gt;getIsVisibleOnFront() &amp;&amp; !in_array($attribute-&gt;getAttributeCode(), $excludeAttr)) { $value = str_replace('\"',\"\",json_encode($attribute-&gt;getFrontend()-&gt;getValue($product)));\/\/$attribute-&gt;getFrontend()-&gt;getValue($product); if ($value == '' or $value == 'null'){ $value = -1; } if (!$product-&gt;hasData($attribute-&gt;getAttributeCode())) { $value = __('N\/A'); } elseif ((string)$value == '') { $value = __('No'); }&nbsp;<a href=\"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/magento-2-0-x-problem-product-attributes-type-yes-no-not-showing-on-front-boolean-product-attributes\/\" class=\"read-more\">Continue Reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"wzkb_category":[61],"wzkb_tag":[],"class_list":["post-4522","wz_knowledgebase","type-wz_knowledgebase","status-publish","hentry","wzkb_category-magento-2-0-x"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Magento 2.0.x Problem product attributes Type Yes\/No, not showing on front (Boolean product attributes) - Utilewebsites<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/magento-2-0-x-problem-product-attributes-type-yes-no-not-showing-on-front-boolean-product-attributes\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Magento 2.0.x Problem product attributes Type Yes\/No, not showing on front (Boolean product attributes) - Utilewebsites\" \/>\n<meta property=\"og:description\" content=\"If product has boolean attribute, this attribute is not visible on product page view. We don&#039;t have the best solution but for the time being it works in one of our Magento 2.07 projects. We rewrote a function in : vendormagento-module-catalog.php to public function getAdditionalData(array $excludeAttr = [&#039;media_gallery&#039;]) { $data = []; $product = $this-&gt;getProduct(); $attributes = $product-&gt;getAttributes(); foreach ($attributes as $attribute) { if ($attribute-&gt;getIsVisibleOnFront() &amp;&amp; !in_array($attribute-&gt;getAttributeCode(), $excludeAttr)) { $value = str_replace(&#039;&quot;&#039;,&quot;&quot;,json_encode($attribute-&gt;getFrontend()-&gt;getValue($product)));\/\/$attribute-&gt;getFrontend()-&gt;getValue($product); if ($value == &#039;&#039; or $value == &#039;null&#039;){ $value = -1; } if (!$product-&gt;hasData($attribute-&gt;getAttributeCode())) { $value = __(&#039;N\/A&#039;); } elseif ((string)$value == &#039;&#039;) { $value = __(&#039;No&#039;); }&nbsp;Continue Reading\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/magento-2-0-x-problem-product-attributes-type-yes-no-not-showing-on-front-boolean-product-attributes\/\" \/>\n<meta property=\"og:site_name\" content=\"Utilewebsites\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-06T06:29:11+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/magento-2-0-x-problem-product-attributes-type-yes-no-not-showing-on-front-boolean-product-attributes\\\/\",\"url\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/magento-2-0-x-problem-product-attributes-type-yes-no-not-showing-on-front-boolean-product-attributes\\\/\",\"name\":\"Magento 2.0.x Problem product attributes Type Yes\\\/No, not showing on front (Boolean product attributes) - Utilewebsites\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#website\"},\"datePublished\":\"2016-09-26T16:25:37+00:00\",\"dateModified\":\"2023-04-06T06:29:11+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/magento-2-0-x-problem-product-attributes-type-yes-no-not-showing-on-front-boolean-product-attributes\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/magento-2-0-x-problem-product-attributes-type-yes-no-not-showing-on-front-boolean-product-attributes\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/magento-2-0-x-problem-product-attributes-type-yes-no-not-showing-on-front-boolean-product-attributes\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Knowledge Base\",\"item\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/knowledgebase\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Magento 2.0.x Problem product attributes Type Yes\\\/No, not showing on front (Boolean product attributes)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/\",\"name\":\"Utilewebsites\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#organization\",\"name\":\"Utilewebsites\",\"url\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.utilewebsites.nl\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/logo-Utilewebsites-2017.png\",\"contentUrl\":\"https:\\\/\\\/www.utilewebsites.nl\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/logo-Utilewebsites-2017.png\",\"width\":3000,\"height\":593,\"caption\":\"Utilewebsites\"},\"image\":{\"@id\":\"https:\\\/\\\/www.utilewebsites.nl\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Magento 2.0.x Problem product attributes Type Yes\/No, not showing on front (Boolean product attributes) - Utilewebsites","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/magento-2-0-x-problem-product-attributes-type-yes-no-not-showing-on-front-boolean-product-attributes\/","og_locale":"en_US","og_type":"article","og_title":"Magento 2.0.x Problem product attributes Type Yes\/No, not showing on front (Boolean product attributes) - Utilewebsites","og_description":"If product has boolean attribute, this attribute is not visible on product page view. We don't have the best solution but for the time being it works in one of our Magento 2.07 projects. We rewrote a function in : vendormagento-module-catalog.php to public function getAdditionalData(array $excludeAttr = ['media_gallery']) { $data = []; $product = $this-&gt;getProduct(); $attributes = $product-&gt;getAttributes(); foreach ($attributes as $attribute) { if ($attribute-&gt;getIsVisibleOnFront() &amp;&amp; !in_array($attribute-&gt;getAttributeCode(), $excludeAttr)) { $value = str_replace('\"',\"\",json_encode($attribute-&gt;getFrontend()-&gt;getValue($product)));\/\/$attribute-&gt;getFrontend()-&gt;getValue($product); if ($value == '' or $value == 'null'){ $value = -1; } if (!$product-&gt;hasData($attribute-&gt;getAttributeCode())) { $value = __('N\/A'); } elseif ((string)$value == '') { $value = __('No'); }&nbsp;Continue Reading","og_url":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/magento-2-0-x-problem-product-attributes-type-yes-no-not-showing-on-front-boolean-product-attributes\/","og_site_name":"Utilewebsites","article_modified_time":"2023-04-06T06:29:11+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/magento-2-0-x-problem-product-attributes-type-yes-no-not-showing-on-front-boolean-product-attributes\/","url":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/magento-2-0-x-problem-product-attributes-type-yes-no-not-showing-on-front-boolean-product-attributes\/","name":"Magento 2.0.x Problem product attributes Type Yes\/No, not showing on front (Boolean product attributes) - Utilewebsites","isPartOf":{"@id":"https:\/\/www.utilewebsites.nl\/en\/#website"},"datePublished":"2016-09-26T16:25:37+00:00","dateModified":"2023-04-06T06:29:11+00:00","breadcrumb":{"@id":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/magento-2-0-x-problem-product-attributes-type-yes-no-not-showing-on-front-boolean-product-attributes\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/magento-2-0-x-problem-product-attributes-type-yes-no-not-showing-on-front-boolean-product-attributes\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/magento-2-0-x-problem-product-attributes-type-yes-no-not-showing-on-front-boolean-product-attributes\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.utilewebsites.nl\/en\/"},{"@type":"ListItem","position":2,"name":"Knowledge Base","item":"https:\/\/www.utilewebsites.nl\/en\/knowledgebase\/"},{"@type":"ListItem","position":3,"name":"Magento 2.0.x Problem product attributes Type Yes\/No, not showing on front (Boolean product attributes)"}]},{"@type":"WebSite","@id":"https:\/\/www.utilewebsites.nl\/en\/#website","url":"https:\/\/www.utilewebsites.nl\/en\/","name":"Utilewebsites","description":"","publisher":{"@id":"https:\/\/www.utilewebsites.nl\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.utilewebsites.nl\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.utilewebsites.nl\/en\/#organization","name":"Utilewebsites","url":"https:\/\/www.utilewebsites.nl\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.utilewebsites.nl\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.utilewebsites.nl\/wp-content\/uploads\/2019\/08\/logo-Utilewebsites-2017.png","contentUrl":"https:\/\/www.utilewebsites.nl\/wp-content\/uploads\/2019\/08\/logo-Utilewebsites-2017.png","width":3000,"height":593,"caption":"Utilewebsites"},"image":{"@id":"https:\/\/www.utilewebsites.nl\/en\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wz_knowledgebase\/4522","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wz_knowledgebase"}],"about":[{"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/types\/wz_knowledgebase"}],"author":[{"embeddable":true,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/comments?post=4522"}],"version-history":[{"count":1,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wz_knowledgebase\/4522\/revisions"}],"predecessor-version":[{"id":4523,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wz_knowledgebase\/4522\/revisions\/4523"}],"wp:attachment":[{"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/media?parent=4522"}],"wp:term":[{"taxonomy":"wzkb_category","embeddable":true,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wzkb_category?post=4522"},{"taxonomy":"wzkb_tag","embeddable":true,"href":"https:\/\/www.utilewebsites.nl\/en\/wp-json\/wp\/v2\/wzkb_tag?post=4522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}