Skip to content

Commit f4c9477

Browse files
ENGCOM-3361: #17638: [Forwardport] Bundle Special Prices not correctly rounded. #18987
- Merge Pull Request #18987 from p-bystritsky/magento2:ISSUE-17638 - Merged commits: 1. fe82167
2 parents da1a96c + fe82167 commit f4c9477

File tree

1 file changed

+28
-1
lines changed
  • app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier

1 file changed

+28
-1
lines changed

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Catalog\Model\Attribute\ScopeOverriddenValue;
1212
use Magento\Catalog\Model\Locator\LocatorInterface;
1313
use Magento\Catalog\Model\Product;
14+
use Magento\Catalog\Model\Product\Type as ProductType;
1415
use Magento\Catalog\Model\ResourceModel\Eav\Attribute as EavAttribute;
1516
use Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory as EavAttributeFactory;
1617
use Magento\Catalog\Ui\DataProvider\CatalogEavValidationRules;
@@ -419,7 +420,7 @@ public function modifyData(array $data)
419420

420421
foreach ($attributes as $attribute) {
421422
if (null !== ($attributeValue = $this->setupAttributeData($attribute))) {
422-
if ($attribute->getFrontendInput() === 'price' && is_scalar($attributeValue)) {
423+
if ($this->isPriceAttribute($attribute, $attributeValue)) {
423424
$attributeValue = $this->formatPrice($attributeValue);
424425
}
425426
$data[$productId][self::DATA_SOURCE_DEFAULT][$attribute->getAttributeCode()] = $attributeValue;
@@ -430,6 +431,32 @@ public function modifyData(array $data)
430431
return $data;
431432
}
432433

434+
/**
435+
* Obtain if given attribute is a price
436+
*
437+
* @param \Magento\Catalog\Api\Data\ProductAttributeInterface $attribute
438+
* @param string|integer $attributeValue
439+
* @return bool
440+
*/
441+
private function isPriceAttribute(ProductAttributeInterface $attribute, $attributeValue)
442+
{
443+
return $attribute->getFrontendInput() === 'price'
444+
&& is_scalar($attributeValue)
445+
&& !$this->isBundleSpecialPrice($attribute);
446+
}
447+
448+
/**
449+
* Obtain if current product is bundle and given attribute is special_price
450+
*
451+
* @param \Magento\Catalog\Api\Data\ProductAttributeInterface $attribute
452+
* @return bool
453+
*/
454+
private function isBundleSpecialPrice(ProductAttributeInterface $attribute)
455+
{
456+
return $this->locator->getProduct()->getTypeId() === ProductType::TYPE_BUNDLE
457+
&& $attribute->getAttributeCode() === ProductAttributeInterface::CODE_SPECIAL_PRICE;
458+
}
459+
433460
/**
434461
* Resolve data persistence
435462
*

0 commit comments

Comments
 (0)