@@ -67,20 +67,19 @@ public function getProduct()
67
67
}
68
68
69
69
/**
70
- * $excludeAttr is optional array of attribute codes to
71
- * exclude them from additional data array
70
+ * $excludeAttr is optional array of attribute codes to exclude them from additional data array
72
71
*
73
72
* @param array $excludeAttr
74
73
* @return array
75
- * @SuppressWarnings(PHPMD.CyclomaticComplexity)
74
+ * @throws \Magento\Framework\Exception\LocalizedException
76
75
*/
77
76
public function getAdditionalData (array $ excludeAttr = [])
78
77
{
79
78
$ data = [];
80
79
$ product = $ this ->getProduct ();
81
80
$ attributes = $ product ->getAttributes ();
82
81
foreach ($ attributes as $ attribute ) {
83
- if ($ attribute -> getIsVisibleOnFront () && ! in_array ( $ attribute-> getAttributeCode () , $ excludeAttr )) {
82
+ if ($ this -> isVisibleOnFrontend ( $ attribute , $ excludeAttr )) {
84
83
$ value = $ attribute ->getFrontend ()->getValue ($ product );
85
84
86
85
if ($ value instanceof Phrase) {
@@ -100,4 +99,18 @@ public function getAdditionalData(array $excludeAttr = [])
100
99
}
101
100
return $ data ;
102
101
}
102
+
103
+ /**
104
+ * Determine if we should display the attribute on the front-end
105
+ *
106
+ * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
107
+ * @param array $excludeAttr
108
+ * @return bool
109
+ */
110
+ protected function isVisibleOnFrontend (
111
+ \Magento \Eav \Model \Entity \Attribute \AbstractAttribute $ attribute ,
112
+ array $ excludeAttr
113
+ ) {
114
+ return ($ attribute ->getIsVisibleOnFront () && !in_array ($ attribute ->getAttributeCode (), $ excludeAttr ));
115
+ }
103
116
}
0 commit comments