Skip to content

Commit 82f4aa1

Browse files
author
Bohdan Korablov
committed
MAGETWO-49193: Price field doesn't show currency symbol and validation doesn't work
1 parent 985c3a8 commit 82f4aa1

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,25 @@ protected function setupMetaProperties(ProductAttributeInterface $attribute)
462462
}
463463

464464
$meta = $this->addWysiwyg($attribute, $meta);
465+
$meta = $this->customizePriceAttribute($attribute, $meta);
466+
467+
return $meta;
468+
}
469+
470+
/**
471+
* Customize attribute that has price type
472+
*
473+
* @param ProductAttributeInterface $attribute
474+
* @param array $meta
475+
* @return array
476+
*/
477+
private function customizePriceAttribute(ProductAttributeInterface $attribute, array $meta)
478+
{
479+
if ($attribute->getFrontendInput() === 'price') {
480+
$meta['arguments']['data']['config']['addbefore'] = $this->locator->getStore()
481+
->getBaseCurrency()
482+
->getCurrencySymbol();
483+
}
465484

466485
return $meta;
467486
}

app/code/Magento/Ui/DataProvider/EavValidationRules.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public function build(AbstractAttribute $attribute, array $data)
3535
if (!empty($data['arguments']['data']['config']['required'])) {
3636
$rules['required-entry'] = true;
3737
}
38+
if ($attribute->getFrontendInput() === 'price') {
39+
$rules['validate-zero-or-greater'] = true;
40+
}
41+
3842
$validation = $attribute->getValidateRules();
3943
if (!empty($validation)) {
4044
foreach ($validation as $type => $ruleName) {

0 commit comments

Comments
 (0)