Skip to content

Commit e2f7977

Browse files
committed
Merge branch 'MC-3103-product-attribute-full-width' into cms-team-1-delivery-sprint-12
2 parents 9909d00 + 903969c commit e2f7977

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

app/code/Magento/Catalog/Block/Product/View/Attributes.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,19 @@ public function getProduct()
6767
}
6868

6969
/**
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
7271
*
7372
* @param array $excludeAttr
7473
* @return array
75-
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
74+
* @throws \Magento\Framework\Exception\LocalizedException
7675
*/
7776
public function getAdditionalData(array $excludeAttr = [])
7877
{
7978
$data = [];
8079
$product = $this->getProduct();
8180
$attributes = $product->getAttributes();
8281
foreach ($attributes as $attribute) {
83-
if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), $excludeAttr)) {
82+
if ($this->isVisibleOnFrontend($attribute, $excludeAttr)) {
8483
$value = $attribute->getFrontend()->getValue($product);
8584

8685
if ($value instanceof Phrase) {
@@ -100,4 +99,18 @@ public function getAdditionalData(array $excludeAttr = [])
10099
}
101100
return $data;
102101
}
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+
}
103116
}

0 commit comments

Comments
 (0)