11
11
use Magento \Catalog \Model \Attribute \ScopeOverriddenValue ;
12
12
use Magento \Catalog \Model \Locator \LocatorInterface ;
13
13
use Magento \Catalog \Model \Product ;
14
+ use Magento \Catalog \Model \Product \Type as ProductType ;
14
15
use Magento \Catalog \Model \ResourceModel \Eav \Attribute as EavAttribute ;
15
16
use Magento \Catalog \Model \ResourceModel \Eav \AttributeFactory as EavAttributeFactory ;
16
17
use Magento \Catalog \Ui \DataProvider \CatalogEavValidationRules ;
@@ -419,7 +420,7 @@ public function modifyData(array $data)
419
420
420
421
foreach ($ attributes as $ attribute ) {
421
422
if (null !== ($ attributeValue = $ this ->setupAttributeData ($ attribute ))) {
422
- if ($ attribute -> getFrontendInput () === ' price ' && is_scalar ( $ attributeValue )) {
423
+ if ($ this -> isPriceAttribute ( $ attribute , $ attributeValue )) {
423
424
$ attributeValue = $ this ->formatPrice ($ attributeValue );
424
425
}
425
426
$ data [$ productId ][self ::DATA_SOURCE_DEFAULT ][$ attribute ->getAttributeCode ()] = $ attributeValue ;
@@ -430,6 +431,32 @@ public function modifyData(array $data)
430
431
return $ data ;
431
432
}
432
433
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
+
433
460
/**
434
461
* Resolve data persistence
435
462
*
0 commit comments