diff --git a/app/code/Magento/Catalog/Observer/ChangePriceAttributeScopeOnCreate.php b/app/code/Magento/Catalog/Observer/ChangePriceAttributeScopeOnCreate.php new file mode 100644 index 0000000000000..55a343817fad8 --- /dev/null +++ b/app/code/Magento/Catalog/Observer/ChangePriceAttributeScopeOnCreate.php @@ -0,0 +1,48 @@ +getEvent()->getAttribute(); + if (empty($attribute->getId) && $attribute->getFrontendInput() == 'price') { + $scope = $this->catalogData->getPriceScope(); + $scope = ($scope == Store::PRICE_SCOPE_WEBSITE) + ? ProductAttributeInterface::SCOPE_WEBSITE_TEXT + : ProductAttributeInterface::SCOPE_GLOBAL_TEXT; + $attribute->setScope($scope); + } + return $this; + } +} diff --git a/app/code/Magento/Catalog/etc/events.xml b/app/code/Magento/Catalog/etc/events.xml index 64505d8c18105..dba27c0b155e1 100644 --- a/app/code/Magento/Catalog/etc/events.xml +++ b/app/code/Magento/Catalog/etc/events.xml @@ -70,4 +70,7 @@ + + + diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Save/AttributePriceTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Save/AttributePriceTest.php index 8eda6be968946..0cf324e175a90 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Save/AttributePriceTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/Save/AttributePriceTest.php @@ -1,12 +1,13 @@ assertTrue($this->getAttribute()->isScopeWebsite()); + } + /** * @inheritdoc */