Skip to content

Commit 1944299

Browse files
author
Magently
committed
Separate the logic of checking if the attribute is the price in Catalog EavModifier
1 parent 36570de commit 1944299

File tree

1 file changed

+15
-4
lines changed
  • app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier

1 file changed

+15
-4
lines changed

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,7 @@ public function modifyData(array $data)
399399

400400
foreach ($attributes as $attribute) {
401401
if (null !== ($attributeValue = $this->setupAttributeData($attribute))) {
402-
if ($attribute->getFrontendInput() === 'price'
403-
&& is_scalar($attributeValue)
404-
&& !$this->isBundleSpecialPrice($attribute)
405-
) {
402+
if ($this->isPriceAttribute($attribute, $attributeValue)) {
406403
$attributeValue = $this->formatPrice($attributeValue);
407404
}
408405
$data[$productId][self::DATA_SOURCE_DEFAULT][$attribute->getAttributeCode()] = $attributeValue;
@@ -413,6 +410,20 @@ public function modifyData(array $data)
413410
return $data;
414411
}
415412

413+
/**
414+
* Obtain if given attribute is a price
415+
*
416+
* @param \Magento\Catalog\Api\Data\ProductAttributeInterface $attribute
417+
* @param string|integer $attributeValue
418+
* @return bool
419+
*/
420+
private function isPriceAttribute(ProductAttributeInterface $attribute, $attributeValue)
421+
{
422+
return $attribute->getFrontendInput() === 'price'
423+
&& is_scalar($attributeValue)
424+
&& !$this->isBundleSpecialPrice($attribute);
425+
}
426+
416427
/**
417428
* Obtain if current product is bundle and given attribute is special_price
418429
*

0 commit comments

Comments
 (0)