-
diff --git a/app/code/Magento/Customer/view/frontend/email/change_email.html b/app/code/Magento/Customer/view/frontend/email/change_email.html
index 4853adf638066..bd961ad99ec40 100644
--- a/app/code/Magento/Customer/view/frontend/email/change_email.html
+++ b/app/code/Magento/Customer/view/frontend/email/change_email.html
@@ -8,13 +8,12 @@
{{template config_path="design/email/header_template"}}
-
{{trans "Hello,"}}
-
-
+{{trans "%name," name=$customer.name}}
{{trans "We have received a request to change the following information associated with your account at %store_name: email." store_name=$store.frontend_name}}
{{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}.
diff --git a/app/code/Magento/Customer/view/frontend/email/change_email_and_password.html b/app/code/Magento/Customer/view/frontend/email/change_email_and_password.html
index 49867bdedc9e0..4f5c85b2381f3 100644
--- a/app/code/Magento/Customer/view/frontend/email/change_email_and_password.html
+++ b/app/code/Magento/Customer/view/frontend/email/change_email_and_password.html
@@ -8,13 +8,12 @@
{{template config_path="design/email/header_template"}}
-
{{trans "Hello,"}}
-
-
+{{trans "%name," name=$customer.name}}
{{trans "We have received a request to change the following information associated with your account at %store_name: email, password." store_name=$store.frontend_name}}
{{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}.
diff --git a/app/code/Magento/Customer/view/frontend/email/password_reset.html b/app/code/Magento/Customer/view/frontend/email/password_reset.html
index 79015117c2280..cab05a89227b6 100644
--- a/app/code/Magento/Customer/view/frontend/email/password_reset.html
+++ b/app/code/Magento/Customer/view/frontend/email/password_reset.html
@@ -9,13 +9,12 @@
"var customer.name":"Customer Name",
"var store.frontend_name":"Store Name",
"var store_email":"Store Email",
-"var store_phone":"Store Phone"
+"var store_phone":"Store Phone",
+"var customer.name":"Customer Name"
} @-->
{{template config_path="design/email/header_template"}}
-
{{trans "Hello,"}}
-
-
+{{trans "%name," name=$customer.name}}
{{trans "We have received a request to change the following information associated with your account at %store_name: password." store_name=$store.frontend_name}}
{{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}.
diff --git a/app/code/Magento/Customer/view/frontend/templates/messages/confirmAccountErrorMessage.phtml b/app/code/Magento/Customer/view/frontend/templates/messages/confirmAccountErrorMessage.phtml
new file mode 100644
index 0000000000000..134ff3f142cfb
--- /dev/null
+++ b/app/code/Magento/Customer/view/frontend/templates/messages/confirmAccountErrorMessage.phtml
@@ -0,0 +1,17 @@
+
+= $escaper->escapeHtml(
+ __(
+ 'This account is not confirmed. Click here to resend confirmation email.',
+ $block->getData('url')
+ ),
+ ['a']
+);
diff --git a/app/code/Magento/Directory/Helper/Data.php b/app/code/Magento/Directory/Helper/Data.php
index 3a5558e6d6f3d..3133e3d4c1957 100644
--- a/app/code/Magento/Directory/Helper/Data.php
+++ b/app/code/Magento/Directory/Helper/Data.php
@@ -6,11 +6,13 @@
namespace Magento\Directory\Helper;
+use Magento\Directory\Model\AllowedCountries;
use Magento\Directory\Model\Currency;
use Magento\Directory\Model\CurrencyFactory;
use Magento\Directory\Model\ResourceModel\Country\Collection;
use Magento\Directory\Model\ResourceModel\Region\CollectionFactory;
use Magento\Framework\App\Cache\Type\Config;
+use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\Json\Helper\Data as JsonData;
use Magento\Store\Model\ScopeInterface;
@@ -21,6 +23,7 @@
*
* @api
* @since 100.0.2
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
@@ -156,6 +159,7 @@ public function getRegionCollection()
{
if (!$this->_regionCollection) {
$this->_regionCollection = $this->_regCollectionFactory->create();
+ // phpstan:ignore
$this->_regionCollection->addCountryFilter($this->getAddress()->getCountryId())->load();
}
return $this->_regionCollection;
@@ -185,7 +189,9 @@ public function getRegionJson()
{
\Magento\Framework\Profiler::start('TEST: ' . __METHOD__, ['group' => 'TEST', 'method' => __METHOD__]);
if (!$this->_regionJson) {
- $cacheKey = 'DIRECTORY_REGIONS_JSON_STORE' . $this->_storeManager->getStore()->getId();
+ $scope = $this->getCurrentScope();
+ $scopeKey = $scope['value'] ? '_' . implode('_', $scope) : null;
+ $cacheKey = 'DIRECTORY_REGIONS_JSON_STORE' . $scopeKey;
$json = $this->_configCacheType->load($cacheKey);
if (empty($json)) {
$regions = $this->getRegionData();
@@ -344,10 +350,13 @@ public function getDefaultCountry($store = null)
*/
public function getRegionData()
{
- $countryIds = [];
- foreach ($this->getCountryCollection() as $country) {
- $countryIds[] = $country->getCountryId();
- }
+ $scope = $this->getCurrentScope();
+ $allowedCountries = $this->scopeConfig->getValue(
+ AllowedCountries::ALLOWED_COUNTRIES_PATH,
+ $scope['type'],
+ $scope['value']
+ );
+ $countryIds = explode(',', $allowedCountries);
$collection = $this->_regCollectionFactory->create();
$collection->addCountryFilter($countryIds)->load();
$regions = [
@@ -392,4 +401,31 @@ public function getWeightUnit()
{
return $this->scopeConfig->getValue(self::XML_PATH_WEIGHT_UNIT, ScopeInterface::SCOPE_STORE);
}
+
+ /**
+ * Get current scope from request
+ *
+ * @return array
+ */
+ private function getCurrentScope(): array
+ {
+ $scope = [
+ 'type' => ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
+ 'value' => null,
+ ];
+ $request = $this->_getRequest();
+ if ($request->getParam(ScopeInterface::SCOPE_WEBSITE)) {
+ $scope = [
+ 'type' => ScopeInterface::SCOPE_WEBSITE,
+ 'value' => $request->getParam(ScopeInterface::SCOPE_WEBSITE),
+ ];
+ } elseif ($request->getParam(ScopeInterface::SCOPE_STORE)) {
+ $scope = [
+ 'type' => ScopeInterface::SCOPE_STORE,
+ 'value' => $request->getParam(ScopeInterface::SCOPE_STORE),
+ ];
+ }
+
+ return $scope;
+ }
}
diff --git a/app/code/Magento/Directory/Test/Unit/Helper/DataTest.php b/app/code/Magento/Directory/Test/Unit/Helper/DataTest.php
index 6ff0f8ea0f30b..f5cc60b5dfb99 100644
--- a/app/code/Magento/Directory/Test/Unit/Helper/DataTest.php
+++ b/app/code/Magento/Directory/Test/Unit/Helper/DataTest.php
@@ -6,59 +6,79 @@
namespace Magento\Directory\Test\Unit\Helper;
use Magento\Directory\Helper\Data;
+use Magento\Directory\Model\AllowedCountries;
+use Magento\Directory\Model\CurrencyFactory;
+use Magento\Directory\Model\ResourceModel\Country\Collection as CountryCollection;
+use Magento\Directory\Model\ResourceModel\Region\Collection as RegionCollection;
+use Magento\Directory\Model\ResourceModel\Region\CollectionFactory;
+use Magento\Framework\App\Cache\Type\Config;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\Helper\Context;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\DataObject;
+use Magento\Framework\Json\Helper\Data as JsonDataHelper;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Store\Model\ScopeInterface;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\Constraint\IsIdentical;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class DataTest extends \PHPUnit\Framework\TestCase
+class DataTest extends TestCase
{
/**
- * @var \Magento\Directory\Model\ResourceModel\Country\Collection|\PHPUnit_Framework_MockObject_MockObject
+ * @var CountryCollection|MockObject
*/
protected $_countryCollection;
/**
- * @var \Magento\Directory\Model\ResourceModel\Region\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CollectionFactory|MockObject
*/
protected $_regionCollection;
/**
- * @var \Magento\Framework\Json\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
+ * @var JsonDataHelper|MockObject
*/
protected $jsonHelperMock;
/**
- * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
+ * @var Store|MockObject
*/
protected $_store;
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
protected $scopeConfigMock;
/**
- * @var \Magento\Directory\Helper\Data
+ * @var Data
*/
protected $_object;
protected function setUp()
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
+ $objectManager = new ObjectManager($this);
+ $this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class);
$this->scopeConfigMock->expects($this->any())->method('isSetFlag')->willReturn(false);
- $context = $this->createMock(\Magento\Framework\App\Helper\Context::class);
+ $requestMock = $this->createMock(RequestInterface::class);
+ $context = $this->createMock(Context::class);
+ $context->method('getRequest')
+ ->willReturn($requestMock);
$context->expects($this->any())
->method('getScopeConfig')
->willReturn($this->scopeConfigMock);
+ $configCacheType = $this->createMock(Config::class);
- $configCacheType = $this->createMock(\Magento\Framework\App\Cache\Type\Config::class);
+ $this->_countryCollection = $this->createMock(CountryCollection::class);
- $this->_countryCollection = $this->createMock(\Magento\Directory\Model\ResourceModel\Country\Collection::class);
-
- $this->_regionCollection = $this->createMock(\Magento\Directory\Model\ResourceModel\Region\Collection::class);
+ $this->_regionCollection = $this->createMock(RegionCollection::class);
$regCollectionFactory = $this->createPartialMock(
- \Magento\Directory\Model\ResourceModel\Region\CollectionFactory::class,
+ CollectionFactory::class,
['create']
);
$regCollectionFactory->expects(
@@ -69,13 +89,13 @@ protected function setUp()
$this->returnValue($this->_regionCollection)
);
- $this->jsonHelperMock = $this->createMock(\Magento\Framework\Json\Helper\Data::class);
+ $this->jsonHelperMock = $this->createMock(JsonDataHelper::class);
- $this->_store = $this->createMock(\Magento\Store\Model\Store::class);
- $storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
+ $this->_store = $this->createMock(Store::class);
+ $storeManager = $this->createMock(StoreManagerInterface::class);
$storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->_store));
- $currencyFactory = $this->createMock(\Magento\Directory\Model\CurrencyFactory::class);
+ $currencyFactory = $this->createMock(CurrencyFactory::class);
$arguments = [
'context' => $context,
@@ -86,32 +106,31 @@ protected function setUp()
'storeManager' => $storeManager,
'currencyFactory' => $currencyFactory,
];
- $this->_object = $objectManager->getObject(\Magento\Directory\Helper\Data::class, $arguments);
+ $this->_object = $objectManager->getObject(Data::class, $arguments);
}
public function testGetRegionJson()
{
- $countries = [
- new \Magento\Framework\DataObject(['country_id' => 'Country1']),
- new \Magento\Framework\DataObject(['country_id' => 'Country2'])
- ];
- $countryIterator = new \ArrayIterator($countries);
- $this->_countryCollection->expects(
- $this->atLeastOnce()
- )->method(
- 'getIterator'
- )->will(
- $this->returnValue($countryIterator)
- );
-
+ $this->scopeConfigMock->method('getValue')
+ ->willReturnMap(
+ [
+ [
+ AllowedCountries::ALLOWED_COUNTRIES_PATH,
+ ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
+ null,
+ 'Country1,Country2'
+ ],
+ [Data::XML_PATH_STATES_REQUIRED, ScopeInterface::SCOPE_STORE, null, '']
+ ]
+ );
$regions = [
- new \Magento\Framework\DataObject(
+ new DataObject(
['country_id' => 'Country1', 'region_id' => 'r1', 'code' => 'r1-code', 'name' => 'r1-name']
),
- new \Magento\Framework\DataObject(
+ new DataObject(
['country_id' => 'Country1', 'region_id' => 'r2', 'code' => 'r2-code', 'name' => 'r2-name']
),
- new \Magento\Framework\DataObject(
+ new DataObject(
['country_id' => 'Country2', 'region_id' => 'r3', 'code' => 'r3-code', 'name' => 'r3-name']
)
];
@@ -148,7 +167,7 @@ public function testGetRegionJson()
)->method(
'jsonEncode'
)->with(
- new \PHPUnit\Framework\Constraint\IsIdentical($expectedDataToEncode)
+ new IsIdentical($expectedDataToEncode)
)->will(
$this->returnValue('encoded_json')
);
@@ -220,7 +239,7 @@ public function testGetDefaultCountry()
->method('getValue')
->with(
Data::XML_PATH_DEFAULT_COUNTRY,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$storeId
)->will($this->returnValue($country));
@@ -237,7 +256,7 @@ public function testGetCountryCollection()
$this->returnValue(0)
);
- $store = $this->createMock(\Magento\Store\Model\Store::class);
+ $store = $this->createMock(Store::class);
$this->_countryCollection->expects(
$this->once()
)->method(
@@ -257,7 +276,7 @@ public function testGetCountryCollection()
public function testGetTopCountryCodesReturnsParsedConfigurationValue($topCountriesValue, $expectedResult)
{
$this->scopeConfigMock->expects($this->once())
- ->method('getValue')->with(\Magento\Directory\Helper\Data::XML_PATH_TOP_COUNTRIES)
+ ->method('getValue')->with(Data::XML_PATH_TOP_COUNTRIES)
->willReturn($topCountriesValue);
$this->assertEquals($expectedResult, $this->_object->getTopCountryCodes());
diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminAddDefaultVideoDownloadableProductTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminAddDefaultVideoDownloadableProductTest.xml
deleted file mode 100644
index ddc11fa6420ec..0000000000000
--- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminAddDefaultVideoDownloadableProductTest.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml
index 9ae046210181b..317f2abdf2f23 100644
--- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml
+++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml
@@ -97,8 +97,7 @@
-
-
+
diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminRemoveDefaultVideoDownloadableProductTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminRemoveDefaultVideoDownloadableProductTest.xml
deleted file mode 100644
index bd2e7615ac252..0000000000000
--- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminRemoveDefaultVideoDownloadableProductTest.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/EditDownloadableProductWithSeparateLinksFromCartTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/EditDownloadableProductWithSeparateLinksFromCartTest.xml
index 30e31be6c8ec4..0ac2dc9b04825 100644
--- a/app/code/Magento/Downloadable/Test/Mftf/Test/EditDownloadableProductWithSeparateLinksFromCartTest.xml
+++ b/app/code/Magento/Downloadable/Test/Mftf/Test/EditDownloadableProductWithSeparateLinksFromCartTest.xml
@@ -95,8 +95,7 @@
-
-
+
diff --git a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/DownloadablePanel.php b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/DownloadablePanel.php
index a34ef79d70d30..813fcaf863412 100644
--- a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/DownloadablePanel.php
+++ b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/DownloadablePanel.php
@@ -45,7 +45,7 @@ public function __construct(LocatorInterface $locator, ArrayManager $arrayManage
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function modifyData(array $data)
{
@@ -58,7 +58,7 @@ public function modifyData(array $data)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function modifyMeta(array $meta)
{
@@ -97,7 +97,8 @@ protected function addMessageBox()
'visible' => false,
'imports' => [
'visible' => '${$.provider}:' . self::DATA_SCOPE_PRODUCT . '.'
- . ProductAttributeInterface::CODE_HAS_WEIGHT
+ . ProductAttributeInterface::CODE_HAS_WEIGHT,
+ '__disableTmpl' => ['visible' => false],
],
];
@@ -122,7 +123,8 @@ protected function addCheckboxIsDownloadable()
'sortOrder' => 10,
'imports' => [
'disabled' => '${$.provider}:' . self::DATA_SCOPE_PRODUCT . '.'
- . ProductAttributeInterface::CODE_HAS_WEIGHT
+ . ProductAttributeInterface::CODE_HAS_WEIGHT,
+ '__disableTmpl' => ['disabled' => false],
],
'valueMap' => [
'false' => '0',
@@ -130,6 +132,7 @@ protected function addCheckboxIsDownloadable()
],
'samplesFieldset' => 'ns = ${ $.ns }, index=' . Composite::CONTAINER_SAMPLES,
'linksFieldset' => 'ns = ${ $.ns }, index=' . Composite::CONTAINER_LINKS,
+ '__disableTmpl' => ['samplesFieldset' => false, 'linksFieldset' => false],
];
$this->meta = $this->arrayManager->set($checkboxPath, $this->meta, $checkboxConfig);
diff --git a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Links.php b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Links.php
index 8c98d871a12d2..d4c81763c7d11 100644
--- a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Links.php
+++ b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Links.php
@@ -287,7 +287,8 @@ protected function getPriceColumn()
'imports' => [
'linksPurchasedSeparately' => '${$.provider}:data.product'
. '.links_purchased_separately',
- 'useDefaultPrice' => '${$.parentName}.use_default_price:checked'
+ 'useDefaultPrice' => '${$.parentName}.use_default_price:checked',
+ '__disableTmpl' => ['linksPurchasedSeparately' => false, 'useDefaultPrice' => false],
],
];
@@ -485,6 +486,7 @@ protected function getMaxDownloadsColumn()
],
'exports' => [
'checked' => '${$.parentName}.number_of_downloads:disabled',
+ '__disableTmpl' => ['checked' => false],
],
];
diff --git a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/UsedDefault.php b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/UsedDefault.php
index d0e24ce7c4aca..b00dfef81a705 100644
--- a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/UsedDefault.php
+++ b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/UsedDefault.php
@@ -11,6 +11,9 @@
use Magento\Framework\Stdlib\ArrayManager;
use Magento\Ui\Component\Form;
+/**
+ * Class for Product Form Modifier User Default
+ */
class UsedDefault extends AbstractModifier
{
/**
@@ -49,7 +52,7 @@ public function __construct(
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function modifyData(array $data)
{
@@ -57,7 +60,7 @@ public function modifyData(array $data)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function modifyMeta(array $meta)
{
@@ -124,6 +127,7 @@ protected function priceUsedDefault()
],
'imports' => [
'linksPurchasedSeparately' => '${$.provider}:data.product.links_purchased_separately',
+ '__disableTmpl' => ['linksPurchasedSeparately' => false],
],
];
$this->meta = $this->arrayManager->set($checkboxPath, $this->meta, $useDefaultConfig);
@@ -159,6 +163,7 @@ protected function titleUsedDefaultInGrid($indexTitle)
],
'exports' => [
'checked' => '${$.parentName}.' . $indexTitle . ':disabled',
+ '__disableTmpl' => ['checked' => false],
],
];
$this->meta = $this->arrayManager->set($checkboxPath, $this->meta, $useDefaultConfig);
diff --git a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php
index 9e4ad6fb53a33..c8780341271ac 100644
--- a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php
+++ b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php
@@ -6,14 +6,21 @@
namespace Magento\Eav\Model\ResourceModel\Entity;
+use Magento\Eav\Api\Data\AttributeInterface;
use Magento\Eav\Model\Config;
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
use Magento\Eav\Model\Entity\Attribute as EntityAttribute;
+use Magento\Eav\Model\Entity\Attribute\FrontendLabel;
+use Magento\Eav\Model\Entity\Attribute\Source\Table;
use Magento\Framework\App\ObjectManager;
+use Magento\Framework\DataObject;
use Magento\Framework\DB\Select;
use Magento\Framework\Exception\CouldNotDeleteException;
+use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
+use Magento\Framework\Model\ResourceModel\Db\Context;
+use Magento\Store\Model\StoreManagerInterface;
/**
* EAV attribute resource model
@@ -32,7 +39,7 @@ class Attribute extends AbstractDb
protected static $_entityAttributes = [];
/**
- * @var \Magento\Store\Model\StoreManagerInterface
+ * @var StoreManagerInterface
*/
protected $_storeManager;
@@ -49,15 +56,15 @@ class Attribute extends AbstractDb
/**
* Class constructor
*
- * @param \Magento\Framework\Model\ResourceModel\Db\Context $context
- * @param \Magento\Store\Model\StoreManagerInterface $storeManager
+ * @param Context $context
+ * @param StoreManagerInterface $storeManager
* @param Type $eavEntityType
* @param string $connectionName
* @codeCoverageIgnore
*/
public function __construct(
- \Magento\Framework\Model\ResourceModel\Db\Context $context,
- \Magento\Store\Model\StoreManagerInterface $storeManager,
+ Context $context,
+ StoreManagerInterface $storeManager,
Type $eavEntityType,
$connectionName = null
) {
@@ -94,14 +101,14 @@ protected function _initUniqueFields()
/**
* Load attribute data by attribute code
*
- * @param EntityAttribute|\Magento\Framework\Model\AbstractModel $object
+ * @param EntityAttribute|AbstractModel $object
* @param int $entityTypeId
* @param string $code
* @return bool
*/
public function loadByCode(AbstractModel $object, $entityTypeId, $code)
{
- $bind = [':entity_type_id' => $entityTypeId];
+ $bind = [':entity_type_id' => (int) $entityTypeId];
$select = $this->_getLoadSelect('attribute_code', $code, $object)->where('entity_type_id = :entity_type_id');
$data = $this->getConnection()->fetchRow($select, $bind);
@@ -145,10 +152,10 @@ private function _getMaxSortOrder(AbstractModel $object)
/**
* Delete entity
*
- * @param \Magento\Framework\Model\AbstractMode $object
+ * @param AbstractModel $object
* @return $this
*/
- public function deleteEntity(\Magento\Framework\Model\AbstractModel $object)
+ public function deleteEntity(AbstractModel $object)
{
if (!$object->getEntityAttributeId()) {
return $this;
@@ -167,7 +174,7 @@ public function deleteEntity(\Magento\Framework\Model\AbstractModel $object)
*
* @param EntityAttribute|AbstractModel $object
* @return $this
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @throws LocalizedException
*/
protected function _beforeSave(AbstractModel $object)
{
@@ -184,7 +191,7 @@ protected function _beforeSave(AbstractModel $object)
*/
if (!$object->getId()) {
if ($object->getFrontendInput() == 'select') {
- $object->setSourceModel(\Magento\Eav\Model\Entity\Attribute\Source\Table::class);
+ $object->setSourceModel(Table::class);
}
}
@@ -200,7 +207,7 @@ protected function _beforeSave(AbstractModel $object)
*/
protected function _beforeDelete(AbstractModel $attribute)
{
- /** @var $attribute \Magento\Eav\Api\Data\AttributeInterface */
+ /** @var $attribute AttributeInterface */
if ($attribute->getId() && !$attribute->getIsUserDefined()) {
throw new CouldNotDeleteException(__("The system attribute can't be deleted."));
}
@@ -232,12 +239,12 @@ protected function _afterSave(AbstractModel $object)
/**
* Perform actions after object delete
*
- * @param \Magento\Framework\Model\AbstractModel|\Magento\Framework\DataObject $object
+ * @param AbstractModel|DataObject $object
* @return $this
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @since 100.0.7
*/
- protected function _afterDelete(\Magento\Framework\Model\AbstractModel $object)
+ protected function _afterDelete(AbstractModel $object)
{
$this->getConfig()->clear();
return $this;
@@ -260,7 +267,7 @@ private function getConfig()
/**
* Save store labels
*
- * @param EntityAttribute|\Magento\Framework\Model\AbstractModel $object
+ * @param EntityAttribute|AbstractModel $object
* @return $this
*/
protected function _saveStoreLabels(AbstractModel $object)
@@ -287,7 +294,7 @@ protected function _saveStoreLabels(AbstractModel $object)
/**
* Save additional data of attribute
*
- * @param EntityAttribute|\Magento\Framework\Model\AbstractModel $object
+ * @param EntityAttribute|AbstractModel $object
* @return $this
*/
protected function _saveAdditionalAttributeData(AbstractModel $object)
@@ -296,7 +303,7 @@ protected function _saveAdditionalAttributeData(AbstractModel $object)
if ($additionalTable) {
$connection = $this->getConnection();
$data = $this->_prepareDataForTable($object, $this->getTable($additionalTable));
- $bind = [':attribute_id' => $object->getId()];
+ $bind = [':attribute_id' => (int) $object->getId()];
$select = $connection->select()->from(
$this->getTable($additionalTable),
['attribute_id']
@@ -410,12 +417,12 @@ protected function _processAttributeOptions($object, $option)
*
* @param array $values
* @return void
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @throws LocalizedException
*/
protected function _checkDefaultOptionValue($values)
{
if (!isset($values[0])) {
- throw new \Magento\Framework\Exception\LocalizedException(
+ throw new LocalizedException(
__("The default option isn't defined. Set the option and try again.")
);
}
@@ -797,8 +804,8 @@ public function __sleep()
public function __wakeup()
{
parent::__wakeup();
- $this->_storeManager = \Magento\Framework\App\ObjectManager::getInstance()
- ->get(\Magento\Store\Model\StoreManagerInterface::class);
+ $this->_storeManager = ObjectManager::getInstance()
+ ->get(StoreManagerInterface::class);
}
/**
@@ -807,14 +814,14 @@ public function __wakeup()
* @param AbstractModel $object
* @param string|null $frontendLabel
* @return void
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @throws LocalizedException
*/
private function setStoreLabels(AbstractModel $object, $frontendLabel)
{
$resultLabel = [];
$frontendLabels = $object->getFrontendLabels();
if (isset($frontendLabels[0])
- && $frontendLabels[0] instanceof \Magento\Eav\Model\Entity\Attribute\FrontendLabel
+ && $frontendLabels[0] instanceof FrontendLabel
) {
foreach ($frontendLabels as $label) {
$resultLabel[$label->getStoreId()] = $label->getLabel();
@@ -830,13 +837,13 @@ private function setStoreLabels(AbstractModel $object, $frontendLabel)
* @param array|string|null $frontendLabel
* @param array $resultLabels
* @return void
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @throws LocalizedException
*/
private function checkDefaultFrontendLabelExists($frontendLabel, $resultLabels)
{
$isAdminStoreLabel = (isset($resultLabels[0]) && !empty($resultLabels[0]));
if (empty($frontendLabel) && !$isAdminStoreLabel) {
- throw new \Magento\Framework\Exception\LocalizedException(__('The storefront label is not defined.'));
+ throw new LocalizedException(__('The storefront label is not defined.'));
}
}
}
diff --git a/app/code/Magento/Eav/etc/db_schema.xml b/app/code/Magento/Eav/etc/db_schema.xml
index 8dc917b22d09f..0e0b599290ca2 100644
--- a/app/code/Magento/Eav/etc/db_schema.xml
+++ b/app/code/Magento/Eav/etc/db_schema.xml
@@ -305,6 +305,11 @@
+
+
+
+
+