Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use Magento\Ui\DataProvider\Mapper\FormElement as FormElementMapper;
use Magento\Ui\DataProvider\Mapper\MetaProperties as MetaPropertiesMapper;
use Magento\Eav\Model\ResourceModel\Entity\Attribute\CollectionFactory as AttributeCollectionFactory;
use \Magento\Catalog\Model\Product\Type as ProductType;

/**
* Class Eav
Expand Down Expand Up @@ -398,7 +399,7 @@ public function modifyData(array $data)

foreach ($attributes as $attribute) {
if (null !== ($attributeValue = $this->setupAttributeData($attribute))) {
if ($attribute->getFrontendInput() === 'price' && is_scalar($attributeValue)) {
if ($this->isPriceAttribute($attribute, $attributeValue)) {
$attributeValue = $this->formatPrice($attributeValue);
}
$data[$productId][self::DATA_SOURCE_DEFAULT][$attribute->getAttributeCode()] = $attributeValue;
Expand All @@ -409,6 +410,32 @@ public function modifyData(array $data)
return $data;
}

/**
* Obtain if given attribute is a price
*
* @param \Magento\Catalog\Api\Data\ProductAttributeInterface $attribute
* @param string|integer $attributeValue
* @return bool
*/
private function isPriceAttribute(ProductAttributeInterface $attribute, $attributeValue)
{
return $attribute->getFrontendInput() === 'price'
&& is_scalar($attributeValue)
&& !$this->isBundleSpecialPrice($attribute);
}

/**
* Obtain if current product is bundle and given attribute is special_price
*
* @param \Magento\Catalog\Api\Data\ProductAttributeInterface $attribute
* @return bool
*/
private function isBundleSpecialPrice(ProductAttributeInterface $attribute)
{
return $this->locator->getProduct()->getTypeId() === ProductType::TYPE_BUNDLE
&& $attribute->getAttributeCode() === ProductAttributeInterface::CODE_SPECIAL_PRICE;
}

/**
* Resolve data persistence
*
Expand Down