@@ -28,10 +38,15 @@
require([
'jquery',
'mage/template',
+ 'Magento_Ui/js/lib/validation/validator',
+ 'Magento_Ui/js/modal/alert',
'jquery/file-uploader',
'domReady!',
'mage/translate'
-], function ($, mageTemplate) {
+], function ($, mageTemplate, validator, uiAlert) {
+ var maxFileSize = = $block->escapeJs($block->getFileSizeService()->getMaxFileSize()) ?>,
+ allowedExtensions = '= $block->escapeHtml(implode(' ', $allowedExtensions)) ?>';
+
$('#= $block->getHtmlId() ?> .fileupload').fileupload({
dataType: 'json',
formData: {
@@ -40,17 +55,44 @@ require([
},
sequentialUploads: true,
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
- maxFileSize: = $block->escapeJs($block->getFileSizeService()->getMaxFileSize()) ?>,
+ allowedExtensions: allowedExtensions,
+ maxFileSize: maxFileSize,
+ dropZone: $('#= $block->getHtmlId() ?>').closest('[role="dialog"]'),
add: function (e, data) {
var progressTmpl = mageTemplate('#= $block->getHtmlId() ?>-template'),
fileSize,
- tmpl;
+ tmpl,
+ validationResult;
- $.each(data.files, function (index, file) {
+ data.files = data.files.filter(function (file) {
fileSize = typeof file.size == "undefined" ?
$.mage.__('We could not detect a size.') :
byteConvert(file.size);
+ if (maxFileSize) {
+ validationResult = validator('validate-max-size', file.size, maxFileSize);
+
+ if (!validationResult.passed) {
+ uiAlert({
+ content: validationResult.message
+ });
+
+ return false;
+ }
+ }
+
+ if (allowedExtensions) {
+ validationResult = validator('validate-file-type', file.name, allowedExtensions);
+
+ if (!validationResult.passed) {
+ uiAlert({
+ content: validationResult.message
+ });
+
+ return false;
+ }
+ }
+
data.fileId = Math.random().toString(36).substr(2, 9);
tmpl = progressTmpl({
@@ -62,11 +104,15 @@ require([
});
$(tmpl).data('image', data).appendTo('#= $block->getHtmlId() ?>');
- });
- $(this).fileupload('process', data).done(function () {
- data.submit();
+ return true;
});
+
+ if (data.files.length) {
+ $(this).fileupload('process', data).done(function () {
+ data.submit();
+ });
+ }
},
done: function (e, data) {
var progressSelector = '#' + data.fileId + ' .progressbar-container .progressbar';
diff --git a/app/code/Magento/Cms/view/adminhtml/web/js/folder-tree.js b/app/code/Magento/Cms/view/adminhtml/web/js/folder-tree.js
index 22540ef9d0c..6dd0b39f692 100644
--- a/app/code/Magento/Cms/view/adminhtml/web/js/folder-tree.js
+++ b/app/code/Magento/Cms/view/adminhtml/web/js/folder-tree.js
@@ -114,7 +114,7 @@ define([
metadata: {
node: codeCopy
},
- state: 'closed'
+ state: node.state || 'closed'
};
});
}
diff --git a/app/code/Magento/CmsUrlRewrite/etc/module.xml b/app/code/Magento/CmsUrlRewrite/etc/module.xml
index bce3dce2a40..1e12b5b7497 100644
--- a/app/code/Magento/CmsUrlRewrite/etc/module.xml
+++ b/app/code/Magento/CmsUrlRewrite/etc/module.xml
@@ -6,6 +6,6 @@
*/
-->
-
+
diff --git a/app/code/Magento/CmsUrlRewriteGraphQl/etc/module.xml b/app/code/Magento/CmsUrlRewriteGraphQl/etc/module.xml
index 9cdc305f2f9..d3c65b440aa 100644
--- a/app/code/Magento/CmsUrlRewriteGraphQl/etc/module.xml
+++ b/app/code/Magento/CmsUrlRewriteGraphQl/etc/module.xml
@@ -6,5 +6,5 @@
*/
-->
-
+
diff --git a/app/code/Magento/Config/Console/Command/ConfigSet/ConfigSetProcessorFactory.php b/app/code/Magento/Config/Console/Command/ConfigSet/ConfigSetProcessorFactory.php
index e005747ea5e..1b287573a92 100644
--- a/app/code/Magento/Config/Console/Command/ConfigSet/ConfigSetProcessorFactory.php
+++ b/app/code/Magento/Config/Console/Command/ConfigSet/ConfigSetProcessorFactory.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Config\Console\Command\ConfigSet;
use Magento\Config\Console\Command\ConfigSetCommand;
@@ -27,7 +28,14 @@ class ConfigSetProcessorFactory
* lock - save and lock configuration
*/
const TYPE_DEFAULT = 'default';
+
+ /**
+ * @deprecated
+ * @see TYPE_LOCK_ENV or TYPE_LOCK_CONFIG
+ */
const TYPE_LOCK = 'lock';
+ const TYPE_LOCK_ENV = 'lock-env';
+ const TYPE_LOCK_CONFIG = 'lock-config';
/**#@-*/
/**#@-*/
@@ -65,7 +73,9 @@ public function __construct(
public function create($processorName)
{
if (!isset($this->processors[$processorName])) {
- throw new ConfigurationMismatchException(__('Class for type "%1" was not declared', $processorName));
+ throw new ConfigurationMismatchException(
+ __('The class for "%1" type wasn\'t declared. Enter the class and try again.', $processorName)
+ );
}
$object = $this->objectManager->create($this->processors[$processorName]);
diff --git a/app/code/Magento/Config/Console/Command/ConfigSet/DefaultProcessor.php b/app/code/Magento/Config/Console/Command/ConfigSet/DefaultProcessor.php
index 2f5c10037ef..d7d513bfad4 100644
--- a/app/code/Magento/Config/Console/Command/ConfigSet/DefaultProcessor.php
+++ b/app/code/Magento/Config/Console/Command/ConfigSet/DefaultProcessor.php
@@ -72,7 +72,7 @@ public function process($path, $value, $scope, $scopeCode)
throw new CouldNotSaveException(
__(
'The value you set has already been locked. To change the value, use the --%1 option.',
- ConfigSetCommand::OPTION_LOCK
+ ConfigSetCommand::OPTION_LOCK_ENV
)
);
}
diff --git a/app/code/Magento/Config/Console/Command/ConfigSet/LockProcessor.php b/app/code/Magento/Config/Console/Command/ConfigSet/LockProcessor.php
index 0bd28f0f78d..6fe2adde3c4 100644
--- a/app/code/Magento/Config/Console/Command/ConfigSet/LockProcessor.php
+++ b/app/code/Magento/Config/Console/Command/ConfigSet/LockProcessor.php
@@ -16,7 +16,8 @@
/**
* Processes file lock flow of config:set command.
- * This processor saves the value of configuration and lock it for editing in Admin interface.
+ * This processor saves the value of configuration into app/etc/env.php
+ * and locks it for editing in Admin interface.
*
* {@inheritdoc}
*/
@@ -49,23 +50,30 @@ class LockProcessor implements ConfigSetProcessorInterface
* @var ConfigPathResolver
*/
private $configPathResolver;
+ /**
+ * @var string
+ */
+ private $target;
/**
* @param PreparedValueFactory $preparedValueFactory The factory for prepared value
* @param DeploymentConfig\Writer $writer The deployment configuration writer
* @param ArrayManager $arrayManager An array manager for different manipulations with arrays
* @param ConfigPathResolver $configPathResolver The resolver for configuration paths according to source type
+ * @param string $target
*/
public function __construct(
PreparedValueFactory $preparedValueFactory,
DeploymentConfig\Writer $writer,
ArrayManager $arrayManager,
- ConfigPathResolver $configPathResolver
+ ConfigPathResolver $configPathResolver,
+ $target = ConfigFilePool::APP_ENV
) {
$this->preparedValueFactory = $preparedValueFactory;
$this->deploymentConfigWriter = $writer;
$this->arrayManager = $arrayManager;
$this->configPathResolver = $configPathResolver;
+ $this->target = $target;
}
/**
@@ -97,7 +105,7 @@ public function process($path, $value, $scope, $scopeCode)
* we'll write value just after all validations are triggered.
*/
$this->deploymentConfigWriter->saveConfig(
- [ConfigFilePool::APP_ENV => $this->arrayManager->set($configPath, [], $value)],
+ [$this->target => $this->arrayManager->set($configPath, [], $value)],
false
);
}
diff --git a/app/code/Magento/Config/Console/Command/ConfigSet/ProcessorFacade.php b/app/code/Magento/Config/Console/Command/ConfigSet/ProcessorFacade.php
index 06a01c6686b..fcd7c0d5335 100644
--- a/app/code/Magento/Config/Console/Command/ConfigSet/ProcessorFacade.php
+++ b/app/code/Magento/Config/Console/Command/ConfigSet/ProcessorFacade.php
@@ -9,6 +9,7 @@
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Scope\ValidatorInterface;
use Magento\Config\Model\Config\PathValidator;
+use Magento\Framework\Config\File\ConfigFilePool;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\ConfigurationMismatchException;
use Magento\Framework\Exception\CouldNotSaveException;
@@ -98,12 +99,35 @@ public function __construct(
* @param boolean $lock The lock flag
* @return string Processor response message
* @throws ValidatorException If some validation is wrong
- * @throws CouldNotSaveException If cannot save config value
- * @throws ConfigurationMismatchException If processor can not be instantiated
* @since 100.2.0
+ * @deprecated
+ * @see processWithLockTarget()
*/
public function process($path, $value, $scope, $scopeCode, $lock)
{
+ return $this->processWithLockTarget($path, $value, $scope, $scopeCode, $lock);
+ }
+
+ /**
+ * Processes config:set command with the option to set a target file.
+ *
+ * @param string $path The configuration path in format section/group/field_name
+ * @param string $value The configuration value
+ * @param string $scope The configuration scope (default, website, or store)
+ * @param string $scopeCode The scope code
+ * @param boolean $lock The lock flag
+ * @param string $lockTarget
+ * @return string Processor response message
+ * @throws ValidatorException If some validation is wrong
+ */
+ public function processWithLockTarget(
+ $path,
+ $value,
+ $scope,
+ $scopeCode,
+ $lock,
+ $lockTarget = ConfigFilePool::APP_ENV
+ ) {
try {
$this->scopeValidator->isValid($scope, $scopeCode);
$this->pathValidator->validate($path);
@@ -111,14 +135,24 @@ public function process($path, $value, $scope, $scopeCode, $lock)
throw new ValidatorException(__($exception->getMessage()), $exception);
}
- $processor = $lock
- ? $this->configSetProcessorFactory->create(ConfigSetProcessorFactory::TYPE_LOCK)
- : $this->configSetProcessorFactory->create(ConfigSetProcessorFactory::TYPE_DEFAULT);
- $message = $lock
- ? 'Value was saved and locked.'
- : 'Value was saved.';
+ $processor =
+ $lock
+ ? ( $lockTarget == ConfigFilePool::APP_ENV
+ ? $this->configSetProcessorFactory->create(ConfigSetProcessorFactory::TYPE_LOCK_ENV)
+ : $this->configSetProcessorFactory->create(ConfigSetProcessorFactory::TYPE_LOCK_CONFIG)
+ )
+ : $this->configSetProcessorFactory->create(ConfigSetProcessorFactory::TYPE_DEFAULT)
+ ;
+
+ $message =
+ $lock
+ ? ( $lockTarget == ConfigFilePool::APP_ENV
+ ? 'Value was saved in app/etc/env.php and locked.'
+ : 'Value was saved in app/etc/config.php and locked.'
+ )
+ : 'Value was saved.';
- // The processing flow depends on --lock option.
+ // The processing flow depends on --lock and --share options.
$processor->process($path, $value, $scope, $scopeCode);
$this->hash->regenerate(System::CONFIG_TYPE);
diff --git a/app/code/Magento/Config/Console/Command/ConfigSetCommand.php b/app/code/Magento/Config/Console/Command/ConfigSetCommand.php
index 1df1b3c4bed..cb79daddbf5 100644
--- a/app/code/Magento/Config/Console/Command/ConfigSetCommand.php
+++ b/app/code/Magento/Config/Console/Command/ConfigSetCommand.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Config\Console\Command;
use Magento\Config\App\Config\Type\System;
@@ -10,6 +11,7 @@
use Magento\Deploy\Model\DeploymentConfig\ChangeDetector;
use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\Config\File\ConfigFilePool;
use Magento\Framework\Console\Cli;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
@@ -34,6 +36,8 @@ class ConfigSetCommand extends Command
const OPTION_SCOPE = 'scope';
const OPTION_SCOPE_CODE = 'scope-code';
const OPTION_LOCK = 'lock';
+ const OPTION_LOCK_ENV = 'lock-env';
+ const OPTION_LOCK_CONFIG = 'lock-config';
/**#@-*/
/**#@-*/
@@ -108,11 +112,24 @@ protected function configure()
InputArgument::OPTIONAL,
'Scope code (required only if scope is not \'default\')'
),
+ new InputOption(
+ static::OPTION_LOCK_ENV,
+ 'le',
+ InputOption::VALUE_NONE,
+ 'Lock value which prevents modification in the Admin (will be saved in app/etc/env.php)'
+ ),
+ new InputOption(
+ static::OPTION_LOCK_CONFIG,
+ 'lc',
+ InputOption::VALUE_NONE,
+ 'Lock and share value with other installations, prevents modification in the Admin '
+ . '(will be saved in app/etc/config.php)'
+ ),
new InputOption(
static::OPTION_LOCK,
'l',
InputOption::VALUE_NONE,
- 'Lock value which prevents modification in the Admin'
+ 'Deprecated, use the --' . static::OPTION_LOCK_ENV . ' option instead.'
),
]);
@@ -146,12 +163,23 @@ protected function execute(InputInterface $input, OutputInterface $output)
try {
$message = $this->emulatedAreaProcessor->process(function () use ($input) {
- return $this->processorFacadeFactory->create()->process(
+
+ $lock = $input->getOption(static::OPTION_LOCK_ENV)
+ || $input->getOption(static::OPTION_LOCK_CONFIG)
+ || $input->getOption(static::OPTION_LOCK);
+
+ $lockTargetPath = ConfigFilePool::APP_ENV;
+ if ($input->getOption(static::OPTION_LOCK_CONFIG)) {
+ $lockTargetPath = ConfigFilePool::APP_CONFIG;
+ }
+
+ return $this->processorFacadeFactory->create()->processWithLockTarget(
$input->getArgument(static::ARG_PATH),
$input->getArgument(static::ARG_VALUE),
$input->getOption(static::OPTION_SCOPE),
$input->getOption(static::OPTION_SCOPE_CODE),
- $input->getOption(static::OPTION_LOCK)
+ $lock,
+ $lockTargetPath
);
});
diff --git a/app/code/Magento/Config/Model/Config/Backend/Email/Address.php b/app/code/Magento/Config/Model/Config/Backend/Email/Address.php
index 77fa787bcad..2d12884e7bc 100644
--- a/app/code/Magento/Config/Model/Config/Backend/Email/Address.php
+++ b/app/code/Magento/Config/Model/Config/Backend/Email/Address.php
@@ -25,7 +25,9 @@ public function beforeSave()
{
$value = $this->getValue();
if (!\Zend_Validate::is($value, \Magento\Framework\Validator\EmailAddress::class)) {
- throw new LocalizedException(__('Please correct the email address: "%1".', $value));
+ throw new LocalizedException(
+ __('The "%1" email address is incorrect. Verify the email address and try again.', $value)
+ );
}
return $this;
}
diff --git a/app/code/Magento/Config/Model/Config/Backend/Locale/Timezone.php b/app/code/Magento/Config/Model/Config/Backend/Locale/Timezone.php
index 4e8be3623f3..cac4da2b526 100644
--- a/app/code/Magento/Config/Model/Config/Backend/Locale/Timezone.php
+++ b/app/code/Magento/Config/Model/Config/Backend/Locale/Timezone.php
@@ -24,7 +24,7 @@ class Timezone extends \Magento\Framework\App\Config\Value
public function beforeSave()
{
if (!in_array($this->getValue(), \DateTimeZone::listIdentifiers(\DateTimeZone::ALL))) {
- throw new LocalizedException(__('Please correct the timezone.'));
+ throw new LocalizedException(__('The time zone is incorrect. Verify the time zone and try again.'));
}
return $this;
}
diff --git a/app/code/Magento/Config/Model/Config/Compiler/IncludeElement.php b/app/code/Magento/Config/Model/Config/Compiler/IncludeElement.php
index 961931d6d28..5fc54fa1a8d 100644
--- a/app/code/Magento/Config/Model/Config/Compiler/IncludeElement.php
+++ b/app/code/Magento/Config/Model/Config/Compiler/IncludeElement.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Config\Model\Config\Compiler;
use Magento\Framework\DataObject;
@@ -114,6 +115,6 @@ protected function getContent($includePath)
return $directoryRead->readFile($path);
}
- throw new LocalizedException(__('The file "%1" does not exist', $path));
+ throw new LocalizedException(__('The "%1" file doesn\'t exist.', $path));
}
}
diff --git a/app/code/Magento/Config/Model/Config/Importer.php b/app/code/Magento/Config/Model/Config/Importer.php
index 70ffdaec829..e65a90c593e 100644
--- a/app/code/Magento/Config/Model/Config/Importer.php
+++ b/app/code/Magento/Config/Model/Config/Importer.php
@@ -129,8 +129,10 @@ public function import(array $data)
// Invoke saving of new values.
$this->saveProcessor->process($changedData);
- $this->flagManager->saveFlag(static::FLAG_CODE, $data);
});
+
+ $this->scope->setCurrentScope($currentScope);
+ $this->flagManager->saveFlag(static::FLAG_CODE, $data);
} catch (\Exception $e) {
throw new InvalidTransitionException(__('%1', $e->getMessage()), $e);
} finally {
diff --git a/app/code/Magento/Config/Model/Config/PathValidator.php b/app/code/Magento/Config/Model/Config/PathValidator.php
index c7edbf51b7d..68363bef69d 100644
--- a/app/code/Magento/Config/Model/Config/PathValidator.php
+++ b/app/code/Magento/Config/Model/Config/PathValidator.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Config\Model\Config;
use Magento\Framework\Exception\ValidatorException;
@@ -42,7 +43,7 @@ public function validate($path)
$allPaths = $this->structure->getFieldPaths();
if (!array_key_exists($path, $allPaths)) {
- throw new ValidatorException(__('The "%1" path does not exist', $path));
+ throw new ValidatorException(__('The "%1" path doesn\'t exist. Verify and try again.', $path));
}
return true;
diff --git a/app/code/Magento/Config/Model/Config/Structure/Reader.php b/app/code/Magento/Config/Model/Config/Structure/Reader.php
index 6c53991fcc3..d59f6dd7a40 100644
--- a/app/code/Magento/Config/Model/Config/Structure/Reader.php
+++ b/app/code/Magento/Config/Model/Config/Structure/Reader.php
@@ -6,6 +6,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Config\Model\Config\Structure;
use Magento\Framework\DataObject;
@@ -97,7 +98,10 @@ protected function _readFiles($fileList)
}
} catch (\Magento\Framework\Config\Dom\ValidationException $e) {
throw new LocalizedException(
- new \Magento\Framework\Phrase("Invalid XML in file %1:\n%2", [$key, $e->getMessage()])
+ new \Magento\Framework\Phrase(
+ 'The XML in file "%1" is invalid:' . "\n%2\nVerify the XML and try again.",
+ [$key, $e->getMessage()]
+ )
);
}
}
diff --git a/app/code/Magento/Config/Setup/Patch/Data/UpdateClassAliases.php b/app/code/Magento/Config/Setup/Patch/Data/UpdateClassAliases.php
new file mode 100644
index 00000000000..8986f624c16
--- /dev/null
+++ b/app/code/Magento/Config/Setup/Patch/Data/UpdateClassAliases.php
@@ -0,0 +1,76 @@
+moduleDataSetup = $moduleDataSetup;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ $installer = $this->moduleDataSetup->createMigrationSetup();
+ $this->moduleDataSetup->startSetup();
+
+ $installer->appendClassAliasReplace(
+ 'core_config_data',
+ 'value',
+ Migration::ENTITY_TYPE_MODEL,
+ Migration::FIELD_CONTENT_TYPE_PLAIN,
+ ['config_id']
+ );
+ $installer->doUpdateClassAliases();
+ $this->moduleDataSetup->endSetup();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.0';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ConfigSetProcessorFactoryTest.php b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ConfigSetProcessorFactoryTest.php
index 1fa0310ca62..12b97eb254d 100644
--- a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ConfigSetProcessorFactoryTest.php
+++ b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ConfigSetProcessorFactoryTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Config\Test\Unit\Console\Command\ConfigSet;
use Magento\Config\Console\Command\ConfigSet\ConfigSetProcessorFactory;
@@ -40,7 +41,7 @@ protected function setUp()
$this->model = new ConfigSetProcessorFactory(
$this->objectManagerMock,
[
- ConfigSetProcessorFactory::TYPE_LOCK => LockProcessor::class,
+ ConfigSetProcessorFactory::TYPE_LOCK_ENV => LockProcessor::class,
ConfigSetProcessorFactory::TYPE_DEFAULT => DefaultProcessor::class,
'wrongType' => \stdClass::class,
]
@@ -58,13 +59,13 @@ public function testCreate()
$this->assertInstanceOf(
ConfigSetProcessorInterface::class,
- $this->model->create(ConfigSetProcessorFactory::TYPE_LOCK)
+ $this->model->create(ConfigSetProcessorFactory::TYPE_LOCK_ENV)
);
}
/**
* @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage Class for type "dummyType" was not declared
+ * @expectedExceptionMessage The class for "dummyType" type wasn't declared. Enter the class and try again.
*/
public function testCreateNonExisted()
{
diff --git a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/DefaultProcessorTest.php b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/DefaultProcessorTest.php
index 066b0fbe84b..984e0fe8426 100644
--- a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/DefaultProcessorTest.php
+++ b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/DefaultProcessorTest.php
@@ -166,7 +166,9 @@ private function configMockForProcessTest($path, $scope, $scopeCode)
/**
* @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage The value you set has already been locked. To change the value, use the --lock option.
+ * @codingStandardsIgnoreStart
+ * @expectedExceptionMessage The value you set has already been locked. To change the value, use the --lock-env option.
+ * @codingStandardsIgnoreEnd
*/
public function testProcessLockedValue()
{
diff --git a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/LockConfigProcessorTest.php b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/LockConfigProcessorTest.php
new file mode 100644
index 00000000000..c727184efb4
--- /dev/null
+++ b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/LockConfigProcessorTest.php
@@ -0,0 +1,220 @@
+preparedValueFactory = $this->getMockBuilder(PreparedValueFactory::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->deploymentConfigWriterMock = $this->getMockBuilder(DeploymentConfig\Writer::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->arrayManagerMock = $this->getMockBuilder(ArrayManager::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->configPathResolver = $this->getMockBuilder(ConfigPathResolver::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->valueMock = $this->getMockBuilder(Value::class)
+ ->setMethods(['validateBeforeSave', 'beforeSave', 'setValue', 'getValue', 'afterSave'])
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->model = new LockProcessor(
+ $this->preparedValueFactory,
+ $this->deploymentConfigWriterMock,
+ $this->arrayManagerMock,
+ $this->configPathResolver,
+ ConfigFilePool::APP_CONFIG
+ );
+ }
+
+ /**
+ * Tests process of share flow.
+ *
+ * @param string $path
+ * @param string $value
+ * @param string $scope
+ * @param string|null $scopeCode
+ * @dataProvider processDataProvider
+ */
+ public function testProcess($path, $value, $scope, $scopeCode)
+ {
+ $this->preparedValueFactory->expects($this->once())
+ ->method('create')
+ ->with($path, $value, $scope, $scopeCode)
+ ->willReturn($this->valueMock);
+ $this->configPathResolver->expects($this->once())
+ ->method('resolve')
+ ->willReturn('system/default/test/test/test');
+ $this->arrayManagerMock->expects($this->once())
+ ->method('set')
+ ->with('system/default/test/test/test', [], $value)
+ ->willReturn([
+ 'system' => [
+ 'default' => [
+ 'test' => [
+ 'test' => [
+ 'test' => $value
+ ]
+ ]
+ ]
+ ]
+ ]);
+ $this->valueMock->expects($this->once())
+ ->method('getValue')
+ ->willReturn($value);
+ $this->deploymentConfigWriterMock->expects($this->once())
+ ->method('saveConfig')
+ ->with(
+ [
+ ConfigFilePool::APP_CONFIG => [
+ 'system' => [
+ 'default' => [
+ 'test' => [
+ 'test' => [
+ 'test' => $value
+ ]
+ ]
+ ]
+ ]
+ ]
+ ],
+ false
+ );
+ $this->valueMock->expects($this->once())
+ ->method('validateBeforeSave');
+ $this->valueMock->expects($this->once())
+ ->method('beforeSave');
+ $this->valueMock->expects($this->once())
+ ->method('afterSave');
+
+ $this->model->process($path, $value, $scope, $scopeCode);
+ }
+
+ /**
+ * @return array
+ */
+ public function processDataProvider()
+ {
+ return [
+ ['test/test/test', 'value', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null],
+ ['test/test/test', 'value', ScopeInterface::SCOPE_WEBSITE, 'base'],
+ ['test/test/test', 'value', ScopeInterface::SCOPE_STORE, 'test'],
+ ];
+ }
+
+ /**
+ * @expectedException \Magento\Framework\Exception\LocalizedException
+ * @expectedExceptionMessage Filesystem is not writable.
+ */
+ public function testProcessNotReadableFs()
+ {
+ $path = 'test/test/test';
+ $value = 'value';
+
+ $this->preparedValueFactory->expects($this->once())
+ ->method('create')
+ ->willReturn($this->valueMock);
+ $this->valueMock->expects($this->once())
+ ->method('getValue')
+ ->willReturn($value);
+ $this->configPathResolver->expects($this->once())
+ ->method('resolve')
+ ->willReturn('system/default/test/test/test');
+ $this->arrayManagerMock->expects($this->once())
+ ->method('set')
+ ->with('system/default/test/test/test', [], $value)
+ ->willReturn(null);
+ $this->deploymentConfigWriterMock->expects($this->once())
+ ->method('saveConfig')
+ ->willThrowException(new FileSystemException(__('Filesystem is not writable.')));
+
+ $this->model->process($path, $value, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null);
+ }
+
+ /**
+ * @expectedException \Exception
+ * @expectedExceptionMessage Invalid values
+ */
+ public function testCustomException()
+ {
+ $path = 'test/test/test';
+ $value = 'value';
+
+ $this->configPathResolver->expects($this->once())
+ ->method('resolve')
+ ->willReturn('system/default/test/test/test');
+ $this->preparedValueFactory->expects($this->once())
+ ->method('create')
+ ->willReturn($this->valueMock);
+ $this->arrayManagerMock->expects($this->never())
+ ->method('set');
+ $this->valueMock->expects($this->once())
+ ->method('getValue');
+ $this->valueMock->expects($this->once())
+ ->method('afterSave')
+ ->willThrowException(new \Exception('Invalid values'));
+ $this->deploymentConfigWriterMock->expects($this->never())
+ ->method('saveConfig');
+
+ $this->model->process($path, $value, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null);
+ }
+}
diff --git a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/LockProcessorTest.php b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/LockEnvProcessorTest.php
similarity index 98%
rename from app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/LockProcessorTest.php
rename to app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/LockEnvProcessorTest.php
index 4535e9ad888..4e0248f8860 100644
--- a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/LockProcessorTest.php
+++ b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/LockEnvProcessorTest.php
@@ -23,7 +23,7 @@
* @see LockProcessor
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class LockProcessorTest extends \PHPUnit\Framework\TestCase
+class LockEnvProcessorTest extends \PHPUnit\Framework\TestCase
{
/**
* @var LockProcessor
@@ -81,7 +81,8 @@ protected function setUp()
$this->preparedValueFactory,
$this->deploymentConfigWriterMock,
$this->arrayManagerMock,
- $this->configPathResolver
+ $this->configPathResolver,
+ ConfigFilePool::APP_ENV
);
}
diff --git a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ProcessorFacadeTest.php b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ProcessorFacadeTest.php
index 4e65ab3f4cc..ac4dda2a985 100644
--- a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ProcessorFacadeTest.php
+++ b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ProcessorFacadeTest.php
@@ -11,6 +11,7 @@
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Scope\ValidatorInterface;
use Magento\Config\Model\Config\PathValidator;
+use Magento\Framework\Config\File\ConfigFilePool;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\ValidatorException;
use Magento\Framework\Exception\CouldNotSaveException;
@@ -122,7 +123,13 @@ public function testProcess()
$this->assertSame(
'Value was saved.',
- $this->model->process('test/test/test', 'test', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null, false)
+ $this->model->processWithLockTarget(
+ 'test/test/test',
+ 'test',
+ ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
+ null,
+ false
+ )
);
}
@@ -132,12 +139,19 @@ public function testProcess()
*/
public function testProcessWithValidatorException(LocalizedException $exception)
{
- $this->expectException(ValidatorException::class, 'Some error');
+ $this->expectException(ValidatorException::class);
+ $this->expectExceptionMessage('Some error');
$this->scopeValidatorMock->expects($this->once())
->method('isValid')
->willThrowException($exception);
- $this->model->process('test/test/test', 'test', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null, false);
+ $this->model->processWithLockTarget(
+ 'test/test/test',
+ 'test',
+ ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
+ null,
+ false
+ );
}
/**
@@ -172,7 +186,13 @@ public function testProcessWithConfigurationMismatchException()
$this->configMock->expects($this->never())
->method('clean');
- $this->model->process('test/test/test', 'test', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null, false);
+ $this->model->processWithLockTarget(
+ 'test/test/test',
+ 'test',
+ ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
+ null,
+ false
+ );
}
/**
@@ -198,17 +218,50 @@ public function testProcessWithCouldNotSaveException()
$this->configMock->expects($this->never())
->method('clean');
- $this->model->process('test/test/test', 'test', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null, false);
+ $this->model->processWithLockTarget(
+ 'test/test/test',
+ 'test',
+ ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
+ null,
+ false
+ );
+ }
+
+ public function testExecuteLockEnv()
+ {
+ $this->scopeValidatorMock->expects($this->once())
+ ->method('isValid')
+ ->willReturn(true);
+ $this->configSetProcessorFactoryMock->expects($this->once())
+ ->method('create')
+ ->with(ConfigSetProcessorFactory::TYPE_LOCK_ENV)
+ ->willReturn($this->processorMock);
+ $this->processorMock->expects($this->once())
+ ->method('process')
+ ->with('test/test/test', 'test', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null);
+ $this->configMock->expects($this->once())
+ ->method('clean');
+
+ $this->assertSame(
+ 'Value was saved in app/etc/env.php and locked.',
+ $this->model->processWithLockTarget(
+ 'test/test/test',
+ 'test',
+ ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
+ null,
+ true
+ )
+ );
}
- public function testExecuteLock()
+ public function testExecuteLockConfig()
{
$this->scopeValidatorMock->expects($this->once())
->method('isValid')
->willReturn(true);
$this->configSetProcessorFactoryMock->expects($this->once())
->method('create')
- ->with(ConfigSetProcessorFactory::TYPE_LOCK)
+ ->with(ConfigSetProcessorFactory::TYPE_LOCK_CONFIG)
->willReturn($this->processorMock);
$this->processorMock->expects($this->once())
->method('process')
@@ -217,8 +270,15 @@ public function testExecuteLock()
->method('clean');
$this->assertSame(
- 'Value was saved and locked.',
- $this->model->process('test/test/test', 'test', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null, true)
+ 'Value was saved in app/etc/config.php and locked.',
+ $this->model->processWithLockTarget(
+ 'test/test/test',
+ 'test',
+ ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
+ null,
+ true,
+ ConfigFilePool::APP_CONFIG
+ )
);
}
}
diff --git a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSetCommandTest.php b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSetCommandTest.php
index 39f9c473613..cb3a401e6f1 100644
--- a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSetCommandTest.php
+++ b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSetCommandTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Config\Test\Unit\Console\Command;
use Magento\Config\Console\Command\ConfigSet\ProcessorFacadeFactory;
@@ -94,7 +95,7 @@ public function testExecute()
->method('create')
->willReturn($this->processorFacadeMock);
$this->processorFacadeMock->expects($this->once())
- ->method('process')
+ ->method('processWithLockTarget')
->willReturn('Some message');
$this->emulatedAreProcessorMock->expects($this->once())
->method('process')
diff --git a/app/code/Magento/Config/Test/Unit/Model/Compiler/IncludeElementTest.php b/app/code/Magento/Config/Test/Unit/Model/Compiler/IncludeElementTest.php
index 451c73319d5..3197c04b123 100644
--- a/app/code/Magento/Config/Test/Unit/Model/Compiler/IncludeElementTest.php
+++ b/app/code/Magento/Config/Test/Unit/Model/Compiler/IncludeElementTest.php
@@ -82,7 +82,7 @@ public function testCompileSuccess()
/**
* @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage The file "adminhtml/path/to/file.xml" does not exist
+ * @expectedExceptionMessage The "adminhtml/path/to/file.xml" file doesn't exist.
*/
public function testCompileException()
{
diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/ImporterTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/ImporterTest.php
index 0fdf4532462..4d8eec0aa76 100644
--- a/app/code/Magento/Config/Test/Unit/Model/Config/ImporterTest.php
+++ b/app/code/Magento/Config/Test/Unit/Model/Config/ImporterTest.php
@@ -156,6 +156,9 @@ public function testImport()
$this->scopeMock->expects($this->at(2))
->method('setCurrentScope')
->with('oldScope');
+ $this->scopeMock->expects($this->at(3))
+ ->method('setCurrentScope')
+ ->with('oldScope');
$this->flagManagerMock->expects($this->once())
->method('saveFlag')
->with(Importer::FLAG_CODE, $data);
diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/PathValidatorTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/PathValidatorTest.php
index b1d712a29cb..5a8ea95eff2 100644
--- a/app/code/Magento/Config/Test/Unit/Model/Config/PathValidatorTest.php
+++ b/app/code/Magento/Config/Test/Unit/Model/Config/PathValidatorTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Config\Test\Unit\Model\Config;
use Magento\Config\Model\Config\PathValidator;
@@ -55,7 +56,7 @@ public function testValidate()
/**
* @expectedException \Magento\Framework\Exception\ValidatorException
- * @expectedExceptionMessage The "test/test/test" path does not exist
+ * @expectedExceptionMessage The "test/test/test" path doesn't exist. Verify and try again.
*/
public function testValidateWithException()
{
diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ReaderTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ReaderTest.php
index 7329fa82b73..9e107a545d7 100644
--- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ReaderTest.php
+++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ReaderTest.php
@@ -105,7 +105,7 @@ public function testReadSuccessNotValidatedCase()
* Test the execution with the Validation exception of the 'read' method
*
* @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage Invalid XML in file file:
+ * @expectedExceptionMessage Verify the XML and try again.
*/
public function testReadWithValidationException()
{
diff --git a/app/code/Magento/Config/etc/db_schema.xml b/app/code/Magento/Config/etc/db_schema.xml
index e7be05d4a8c..3f55d582776 100644
--- a/app/code/Magento/Config/etc/db_schema.xml
+++ b/app/code/Magento/Config/etc/db_schema.xml
@@ -6,7 +6,7 @@
*/
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
diff --git a/app/code/Magento/Config/etc/di.xml b/app/code/Magento/Config/etc/di.xml
index bcddd8ceaf2..a5dd18097fb 100644
--- a/app/code/Magento/Config/etc/di.xml
+++ b/app/code/Magento/Config/etc/di.xml
@@ -296,10 +296,21 @@
- Magento\Config\Console\Command\ConfigSet\DefaultProcessor
- - Magento\Config\Console\Command\ConfigSet\LockProcessor
+ - Magento\Config\Console\Command\ConfigSet\VirtualLockEnvProcessor
+ - Magento\Config\Console\Command\ConfigSet\VirtualLockConfigProcessor
+
+
+ app_env
+
+
+
+
+ app_config
+
+
diff --git a/app/code/Magento/Config/etc/module.xml b/app/code/Magento/Config/etc/module.xml
index b64cbe2b726..19051a96a43 100644
--- a/app/code/Magento/Config/etc/module.xml
+++ b/app/code/Magento/Config/etc/module.xml
@@ -6,5 +6,5 @@
*/
-->
-
+
diff --git a/app/code/Magento/ConfigurableImportExport/etc/module.xml b/app/code/Magento/ConfigurableImportExport/etc/module.xml
index 83a4fc4e1a7..7ff81f8d634 100644
--- a/app/code/Magento/ConfigurableImportExport/etc/module.xml
+++ b/app/code/Magento/ConfigurableImportExport/etc/module.xml
@@ -6,6 +6,6 @@
*/
-->
-
+
diff --git a/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php b/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php
index 01981b5dae9..79c2dd812ac 100644
--- a/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php
+++ b/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php
@@ -4,6 +4,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\ConfigurableProduct\Model;
use Magento\Framework\Exception\InputException;
@@ -115,19 +116,24 @@ public function addChild($sku, $childSku)
$childrenIds = array_values($this->configurableType->getChildrenIds($product->getId())[0]);
if (in_array($child->getId(), $childrenIds)) {
- throw new StateException(__('Product has been already attached'));
+ throw new StateException(__('The product is already attached.'));
}
$configurableProductOptions = $product->getExtensionAttributes()->getConfigurableProductOptions();
if (empty($configurableProductOptions)) {
- throw new StateException(__('Parent product does not have configurable product options'));
+ throw new StateException(__("The parent product doesn't have configurable product options."));
}
$attributeIds = [];
foreach ($configurableProductOptions as $configurableProductOption) {
$attributeCode = $configurableProductOption->getProductAttribute()->getAttributeCode();
if (!$child->getData($attributeCode)) {
- throw new StateException(__('Child product does not have attribute value %1', $attributeCode));
+ throw new StateException(
+ __(
+ 'The child product doesn\'t have the "%1" attribute value. Verify the value and try again.',
+ $attributeCode
+ )
+ );
}
$attributeIds[] = $configurableProductOption->getAttributeId();
}
@@ -152,7 +158,7 @@ public function removeChild($sku, $childSku)
if ($product->getTypeId() != \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) {
throw new InputException(
- __('Product with specified sku: %1 is not a configurable product', $sku)
+ __('The product with the "%1" SKU isn\'t a configurable product.', $sku)
);
}
@@ -165,7 +171,9 @@ public function removeChild($sku, $childSku)
$ids[] = $option->getId();
}
if (count($options) == count($ids)) {
- throw new NoSuchEntityException(__('Requested option doesn\'t exist'));
+ throw new NoSuchEntityException(
+ __("The option that was requested doesn't exist. Verify the entity and try again.")
+ );
}
$product->getExtensionAttributes()->setConfigurableProductLinks($ids);
$this->productRepository->save($product);
diff --git a/app/code/Magento/ConfigurableProduct/Model/OptionRepository.php b/app/code/Magento/ConfigurableProduct/Model/OptionRepository.php
index bdf4a367852..b4db0a4db5f 100644
--- a/app/code/Magento/ConfigurableProduct/Model/OptionRepository.php
+++ b/app/code/Magento/ConfigurableProduct/Model/OptionRepository.php
@@ -4,6 +4,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\ConfigurableProduct\Model;
use Magento\Catalog\Api\Data\ProductInterface;
@@ -124,7 +125,9 @@ public function get($sku, $id)
}
}
- throw new NoSuchEntityException(__('Requested option doesn\'t exist: %1', $id));
+ throw new NoSuchEntityException(
+ __('The "%1" entity that was requested doesn\'t exist. Verify the entity and try again.', $id)
+ );
}
/**
@@ -150,14 +153,14 @@ public function delete(OptionInterface $option)
$this->configurableType->resetConfigurableAttributes($product);
} catch (\Exception $exception) {
throw new StateException(
- __('Cannot delete variations from product: %1', $entityId)
+ __('The variations from the "%1" product can\'t be deleted.', $entityId)
);
}
try {
$this->optionResource->delete($option);
} catch (\Exception $exception) {
throw new StateException(
- __('Cannot delete option with id: %1', $option->getId())
+ __('The option with "%1" ID can\'t be deleted.', $option->getId())
);
}
return true;
@@ -173,7 +176,9 @@ public function deleteById($sku, $id)
/** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute $option */
$option = $attributeCollection->getItemById($id);
if ($option === null) {
- throw new NoSuchEntityException(__('Requested option doesn\'t exist'));
+ throw new NoSuchEntityException(
+ __("The option that was requested doesn't exist. Verify the entity and try again.")
+ );
}
return $this->delete($option);
}
@@ -213,11 +218,11 @@ public function save($sku, OptionInterface $option)
try {
$option->save();
} catch (\Exception $e) {
- throw new CouldNotSaveException(__('Something went wrong while saving option.'));
+ throw new CouldNotSaveException(__('An error occurred while saving the option. Please try to save again.'));
}
if (!$option->getId()) {
- throw new CouldNotSaveException(__('Something went wrong while saving option.'));
+ throw new CouldNotSaveException(__('An error occurred while saving the option. Please try to save again.'));
}
return $option->getId();
}
@@ -234,7 +239,7 @@ private function getProduct($sku)
$product = $this->productRepository->get($sku);
if (\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE !== $product->getTypeId()) {
throw new InputException(
- __('Only implemented for configurable product: %1', $sku)
+ __('This is implemented for the "%1" configurable product only.', $sku)
);
}
return $product;
@@ -252,7 +257,7 @@ private function getProductById($id)
$product = $this->productRepository->getById($id);
if (\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE !== $product->getTypeId()) {
throw new InputException(
- __('Only implemented for configurable product: %1', $id)
+ __('This is implemented for the "%1" configurable product only.', $id)
);
}
return $product;
diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/VariationHandler.php b/app/code/Magento/ConfigurableProduct/Model/Product/VariationHandler.php
index a462a5ffd9e..73e7f9053fa 100644
--- a/app/code/Magento/ConfigurableProduct/Model/Product/VariationHandler.php
+++ b/app/code/Magento/ConfigurableProduct/Model/Product/VariationHandler.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\ConfigurableProduct\Model\Product;
use Magento\Catalog\Model\Product\Type as ProductType;
@@ -96,7 +97,9 @@ public function generateSimpleProducts($parentProduct, $productsData)
$configurableAttribute = json_decode($simpleProductData['configurable_attribute'], true);
unset($simpleProductData['configurable_attribute']);
} else {
- throw new LocalizedException(__('Configuration must have specified attributes'));
+ throw new LocalizedException(
+ __('Contribution must have attributes specified. Enter attributes and try again.')
+ );
}
$this->fillSimpleProductData(
diff --git a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Type/Configurable.php
index 3c9689a1c4e..95afba984d5 100644
--- a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Type/Configurable.php
+++ b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Type/Configurable.php
@@ -17,6 +17,7 @@
use Magento\ConfigurableProduct\Model\ResourceModel\Attribute\OptionProvider;
use Magento\Framework\App\ScopeResolverInterface;
use Magento\Framework\App\ObjectManager;
+use Magento\Framework\DB\Adapter\AdapterInterface;
class Configurable extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
@@ -109,27 +110,34 @@ public function saveProducts($mainProduct, array $productIds)
}
$productId = $mainProduct->getData($this->optionProvider->getProductEntityLinkField());
+ $select = $this->getConnection()->select()->from(
+ ['t' => $this->getMainTable()],
+ ['product_id']
+ )->where(
+ 't.parent_id = ?',
+ $productId
+ );
- $data = [];
- foreach ($productIds as $id) {
- $data[] = ['product_id' => (int) $id, 'parent_id' => (int) $productId];
- }
+ $existingProductIds = $this->getConnection()->fetchCol($select);
+ $insertProductIds = array_diff($productIds, $existingProductIds);
+ $deleteProductIds = array_diff($existingProductIds, $productIds);
- if (!empty($data)) {
- $this->getConnection()->insertOnDuplicate(
+ if (!empty($insertProductIds)) {
+ $insertData = [];
+ foreach ($insertProductIds as $id) {
+ $insertData[] = ['product_id' => (int) $id, 'parent_id' => (int) $productId];
+ }
+ $this->getConnection()->insertMultiple(
$this->getMainTable(),
- $data,
- ['product_id', 'parent_id']
+ $insertData
);
}
- $where = ['parent_id = ?' => $productId];
- if (!empty($productIds)) {
- $where['product_id NOT IN(?)'] = $productIds;
+ if (!empty($deleteProductIds)) {
+ $where = ['parent_id = ?' => $productId, 'product_id IN (?)' => $deleteProductIds];
+ $this->getConnection()->delete($this->getMainTable(), $where);
}
- $this->getConnection()->delete($this->getMainTable(), $where);
-
// configurable product relations should be added to relation table
$this->catalogProductRelation->processRelations($productId, $productIds);
diff --git a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Type/Configurable/Attribute.php b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Type/Configurable/Attribute.php
index 7ea83099f25..e93c44893bf 100644
--- a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Type/Configurable/Attribute.php
+++ b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Type/Configurable/Attribute.php
@@ -8,8 +8,8 @@
namespace Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable;
use Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute as ConfigurableAttribute;
+use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Store\Model\Store;
-use Magento\Store\Model\StoreManagerInterface;
class Attribute extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
@@ -85,22 +85,30 @@ public function saveLabel($attribute)
'store_id' => \Magento\Store\Model\Store::DEFAULT_STORE_ID,
];
$valueId = $connection->fetchOne($select, $bind);
+
if ($valueId) {
- $storeId = (int)$attribute->getStoreId() ?: $this->_storeManager->getStore()->getId();
+ $connection->insertOnDuplicate(
+ $this->_labelTable,
+ [
+ 'product_super_attribute_id' => (int)$attribute->getId(),
+ 'store_id' => (int)$attribute->getStoreId() ?: $this->_storeManager->getStore()->getId(),
+ 'use_default' => (int)$attribute->getUseDefault(),
+ 'value' => $attribute->getLabel(),
+ ],
+ ['value', 'use_default']
+ );
} else {
// if attribute label not exists, always store on default store (0)
- $storeId = Store::DEFAULT_STORE_ID;
+ $connection->insert(
+ $this->_labelTable,
+ [
+ 'product_super_attribute_id' => (int)$attribute->getId(),
+ 'store_id' => Store::DEFAULT_STORE_ID,
+ 'use_default' => (int)$attribute->getUseDefault(),
+ 'value' => $attribute->getLabel(),
+ ]
+ );
}
- $connection->insertOnDuplicate(
- $this->_labelTable,
- [
- 'product_super_attribute_id' => (int)$attribute->getId(),
- 'use_default' => (int)$attribute->getUseDefault(),
- 'store_id' => $storeId,
- 'value' => $attribute->getLabel(),
- ],
- ['value', 'use_default']
- );
return $this;
}
diff --git a/app/code/Magento/ConfigurableProduct/Setup/InstallData.php b/app/code/Magento/ConfigurableProduct/Setup/Patch/Data/InstallInitialConfigurableAttributes.php
similarity index 58%
rename from app/code/Magento/ConfigurableProduct/Setup/InstallData.php
rename to app/code/Magento/ConfigurableProduct/Setup/Patch/Data/InstallInitialConfigurableAttributes.php
index 7bc56569dea..c9fea3e74d3 100644
--- a/app/code/Magento/ConfigurableProduct/Setup/InstallData.php
+++ b/app/code/Magento/ConfigurableProduct/Setup/Patch/Data/InstallInitialConfigurableAttributes.php
@@ -4,44 +4,51 @@
* See COPYING.txt for license details.
*/
-namespace Magento\ConfigurableProduct\Setup;
+namespace Magento\ConfigurableProduct\Setup\Patch\Data;
-use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
-use Magento\Framework\Setup\InstallDataInterface;
-use Magento\Framework\Setup\ModuleContextInterface;
+use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Setup\ModuleDataSetupInterface;
+use Magento\Framework\Setup\Patch\DataPatchInterface;
+use Magento\Framework\Setup\Patch\PatchVersionInterface;
+use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
/**
- * @codeCoverageIgnore
+ * Class InstallInitialConfigurableAttributes
+ * @package Magento\ConfigurableProduct\Setup\Patch
*/
-class InstallData implements InstallDataInterface
+class InstallInitialConfigurableAttributes implements DataPatchInterface, PatchVersionInterface
{
/**
- * EAV setup factory
- *
+ * @var ModuleDataSetupInterface
+ */
+ private $moduleDataSetup;
+ /**
* @var EavSetupFactory
*/
private $eavSetupFactory;
/**
- * Init
- *
+ * InstallInitialConfigurableAttributes constructor.
+ * @param ModuleDataSetupInterface $moduleDataSetup
* @param EavSetupFactory $eavSetupFactory
*/
- public function __construct(EavSetupFactory $eavSetupFactory)
- {
+ public function __construct(
+ ModuleDataSetupInterface $moduleDataSetup,
+ EavSetupFactory $eavSetupFactory
+ ) {
+ $this->moduleDataSetup = $moduleDataSetup;
$this->eavSetupFactory = $eavSetupFactory;
}
/**
* {@inheritdoc}
*/
- public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
+ public function apply()
{
/** @var EavSetup $eavSetup */
- $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
+ $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
$attributes = [
'country_of_manufacture',
'minimal_price',
@@ -71,4 +78,28 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
}
}
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.0';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
}
diff --git a/app/code/Magento/ConfigurableProduct/Setup/Patch/Data/UpdateTierPriceAttribute.php b/app/code/Magento/ConfigurableProduct/Setup/Patch/Data/UpdateTierPriceAttribute.php
new file mode 100644
index 00000000000..325fb447d22
--- /dev/null
+++ b/app/code/Magento/ConfigurableProduct/Setup/Patch/Data/UpdateTierPriceAttribute.php
@@ -0,0 +1,94 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->eavSetupFactory = $eavSetupFactory;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ /** @var EavSetup $eavSetup */
+ $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
+ $relatedProductTypes = explode(
+ ',',
+ $eavSetup->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'tier_price', 'apply_to')
+ );
+ $key = array_search(Configurable::TYPE_CODE, $relatedProductTypes);
+ if ($key !== false) {
+ unset($relatedProductTypes[$key]);
+ $eavSetup->updateAttribute(
+ \Magento\Catalog\Model\Product::ENTITY,
+ 'tier_price',
+ 'apply_to',
+ implode(',', $relatedProductTypes)
+ );
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+ InstallInitialConfigurableAttributes::class,
+ ];
+ }
+
+ /**
+ * {@inheritdoc}\
+ */
+ public static function getVersion()
+ {
+ return '2.2.0';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/ConfigurableProduct/Setup/UpgradeData.php b/app/code/Magento/ConfigurableProduct/Setup/UpgradeData.php
deleted file mode 100644
index 326af02fe39..00000000000
--- a/app/code/Magento/ConfigurableProduct/Setup/UpgradeData.php
+++ /dev/null
@@ -1,65 +0,0 @@
-eavSetupFactory = $eavSetupFactory;
- }
-
- /**
- * {@inheritdoc}
- */
- public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
- {
- $setup->startSetup();
- if (version_compare($context->getVersion(), '2.2.0') < 0) {
- /** @var EavSetup $eavSetup */
- $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
- $relatedProductTypes = explode(
- ',',
- $eavSetup->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'tier_price', 'apply_to')
- );
- $key = array_search(Configurable::TYPE_CODE, $relatedProductTypes);
- if ($key !== false) {
- unset($relatedProductTypes[$key]);
- $eavSetup->updateAttribute(
- \Magento\Catalog\Model\Product::ENTITY,
- 'tier_price',
- 'apply_to',
- implode(',', $relatedProductTypes)
- );
- }
- }
-
- $setup->endSetup();
- }
-}
diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php
index acbb976318b..ad2fcd1e593 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php
+++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php
@@ -235,7 +235,7 @@ public function testAddChild()
/**
* @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage Product has been already attached
+ * @expectedExceptionMessage The product is already attached.
*/
public function testAddChildStateException()
{
diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php
index 2d824e52c72..8f3f3979b86 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php
+++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\ConfigurableProduct\Test\Unit\Model;
use Magento\Catalog\Api\ProductRepositoryInterface;
@@ -113,7 +114,7 @@ public function testGet()
/**
* @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Only implemented for configurable product: configurable
+ * @expectedExceptionMessage This is implemented for the "configurable" configurable product only.
*/
public function testGetNotConfigurableProduct()
{
@@ -141,7 +142,7 @@ public function testGetNotConfigurableProduct()
/**
* @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Only implemented for configurable product: 3
+ * @expectedExceptionMessage This is implemented for the "3" configurable product only.
*/
public function testGetNotProductById()
{
@@ -168,7 +169,7 @@ public function testGetNotProductById()
/**
* @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage Cannot delete variations from product: 3
+ * @expectedExceptionMessage The variations from the "3" product can't be deleted.
*/
public function testDeleteCantSaveProducts()
{
@@ -200,7 +201,7 @@ public function testDeleteCantSaveProducts()
/**
* @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage Cannot delete option with id: 33
+ * @expectedExceptionMessage The option with "33" ID can't be deleted.
*/
public function testDeleteCantDeleteOption()
{
@@ -276,7 +277,7 @@ public function testDelete()
/**
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage Requested option doesn't exist: 3
+ * @expectedExceptionMessage The "3" entity that was requested doesn't exist. Verify the entity and try again.
*/
public function testGetEmptyExtensionAttribute()
{
@@ -329,7 +330,7 @@ public function testGetList()
/**
* @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Only implemented for configurable product: configurable
+ * @expectedExceptionMessage This is implemented for the "configurable" configurable product only.
*/
public function testGetListNotConfigurableProduct()
{
diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Product/Type/Configurable/AttributeTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Product/Type/Configurable/AttributeTest.php
index a6c7f00c2df..e7b033ff84f 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Product/Type/Configurable/AttributeTest.php
+++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Product/Type/Configurable/AttributeTest.php
@@ -53,7 +53,7 @@ protected function setUp()
);
}
- public function testSaveLabel()
+ public function testSaveNewLabel()
{
$attributeId = 4354;
@@ -70,7 +70,7 @@ public function testSaveLabel()
]
)->willReturn(0);
- $this->connection->expects($this->once())->method('insertOnDuplicate')->with(
+ $this->connection->expects($this->once())->method('insert')->with(
'catalog_product_super_attribute_label',
[
'product_super_attribute_id' => $attributeId,
@@ -79,12 +79,48 @@ public function testSaveLabel()
'value' => 'test',
]
);
- $attributeMode = $this->getMockBuilder(AttributeModel::class)->setMethods(
+ $attributeMock = $this->getMockBuilder(AttributeModel::class)->setMethods(
['getId', 'getUseDefault', 'getLabel']
)->disableOriginalConstructor()->getMock();
- $attributeMode->expects($this->any())->method('getId')->willReturn($attributeId);
- $attributeMode->expects($this->any())->method('getUseDefault')->willReturn(0);
- $attributeMode->expects($this->any())->method('getLabel')->willReturn('test');
- $this->assertEquals($this->attribute, $this->attribute->saveLabel($attributeMode));
+ $attributeMock->expects($this->atLeastOnce())->method('getId')->willReturn($attributeId);
+ $attributeMock->expects($this->atLeastOnce())->method('getUseDefault')->willReturn(0);
+ $attributeMock->expects($this->atLeastOnce())->method('getLabel')->willReturn('test');
+ $this->assertEquals($this->attribute, $this->attribute->saveLabel($attributeMock));
+ }
+
+ public function testSaveExistingLabel()
+ {
+ $attributeId = 4354;
+
+ $select = $this->getMockBuilder(Select::class)->disableOriginalConstructor()->getMock();
+ $this->connection->expects($this->once())->method('select')->willReturn($select);
+ $select->expects($this->once())->method('from')->willReturnSelf();
+ $select->expects($this->at(1))->method('where')->willReturnSelf();
+ $select->expects($this->at(2))->method('where')->willReturnSelf();
+ $this->connection->expects($this->once())->method('fetchOne')->with(
+ $select,
+ [
+ 'product_super_attribute_id' => $attributeId,
+ 'store_id' => \Magento\Store\Model\Store::DEFAULT_STORE_ID,
+ ]
+ )->willReturn(1);
+
+ $this->connection->expects($this->once())->method('insertOnDuplicate')->with(
+ 'catalog_product_super_attribute_label',
+ [
+ 'product_super_attribute_id' => $attributeId,
+ 'use_default' => 0,
+ 'store_id' => 1,
+ 'value' => 'test',
+ ]
+ );
+ $attributeMock = $this->getMockBuilder(AttributeModel::class)->setMethods(
+ ['getId', 'getUseDefault', 'getLabel', 'getStoreId']
+ )->disableOriginalConstructor()->getMock();
+ $attributeMock->expects($this->atLeastOnce())->method('getId')->willReturn($attributeId);
+ $attributeMock->expects($this->atLeastOnce())->method('getStoreId')->willReturn(1);
+ $attributeMock->expects($this->atLeastOnce())->method('getUseDefault')->willReturn(0);
+ $attributeMock->expects($this->atLeastOnce())->method('getLabel')->willReturn('test');
+ $this->assertEquals($this->attribute, $this->attribute->saveLabel($attributeMock));
}
}
diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Product/Type/ConfigurableTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Product/Type/ConfigurableTest.php
index 5a494d1c7a1..cda9c300cd1 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Product/Type/ConfigurableTest.php
+++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Product/Type/ConfigurableTest.php
@@ -142,19 +142,48 @@ public function testSaveProducts()
$this->optionProvider->expects($this->once())
->method('getProductEntityLinkField')
->willReturnSelf();
- $this->connectionMock->expects($this->once())
- ->method('insertOnDuplicate')
- ->willReturnSelf();
-
$this->resource->expects($this->any())->method('getConnection')->willReturn($this->connectionMock);
$this->resource->expects($this->any())->method('getTableName')->willReturn('table name');
- $statement = $this->getMockBuilder(\Zend_Db_Statement::class)->disableOriginalConstructor()->getMock();
- $statement->method('fetchAll')->willReturn([1]);
+ $select = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
+ ->setMethods(['from', 'where'])
+ ->disableOriginalConstructor()
+ ->getMock();
+ $select->expects($this->exactly(1))->method('from')->willReturnSelf();
+ $select->expects($this->exactly(1))->method('where')->willReturnSelf();
+
+ $this->connectionMock->expects($this->atLeastOnce())
+ ->method('select')
+ ->willReturn($select);
+
+ $existingProductIds = [1, 2];
+ $this->connectionMock->expects($this->once())
+ ->method('fetchCol')
+ ->with($select)
+ ->willReturn($existingProductIds);
+
+ $this->connectionMock->expects($this->once())
+ ->method('insertMultiple')
+ ->with(
+ 'table name',
+ [
+ ['product_id' => 3, 'parent_id' => 3],
+ ['product_id' => 4, 'parent_id' => 3],
+ ]
+ )
+ ->willReturnSelf();
+
+ $this->connectionMock->expects($this->once())
+ ->method('delete')
+ ->with(
+ 'table name',
+ ['parent_id = ?' => 3, 'product_id IN (?)' => [1]]
+ )
+ ->willReturnSelf();
$this->assertSame(
$this->configurable,
- $this->configurable->saveProducts($this->product, [1, 2, 3])
+ $this->configurable->saveProducts($this->product, [2, 3, 4])
);
}
diff --git a/app/code/Magento/ConfigurableProduct/etc/db_schema.xml b/app/code/Magento/ConfigurableProduct/etc/db_schema.xml
index d45c06bea1c..7c6661a5f39 100644
--- a/app/code/Magento/ConfigurableProduct/etc/db_schema.xml
+++ b/app/code/Magento/ConfigurableProduct/etc/db_schema.xml
@@ -6,7 +6,7 @@
*/
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
-
+
diff --git a/app/code/Magento/ConfigurableProductGraphQl/etc/module.xml b/app/code/Magento/ConfigurableProductGraphQl/etc/module.xml
index e86b1bdf604..98e7957d0af 100644
--- a/app/code/Magento/ConfigurableProductGraphQl/etc/module.xml
+++ b/app/code/Magento/ConfigurableProductGraphQl/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/ConfigurableProductSales/etc/module.xml b/app/code/Magento/ConfigurableProductSales/etc/module.xml
index 4da83c9c026..bf5bc4472c8 100644
--- a/app/code/Magento/ConfigurableProductSales/etc/module.xml
+++ b/app/code/Magento/ConfigurableProductSales/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/Contact/Controller/Index/Post.php b/app/code/Magento/Contact/Controller/Index/Post.php
index ee2d23b74df..b51e3c91895 100644
--- a/app/code/Magento/Contact/Controller/Index/Post.php
+++ b/app/code/Magento/Contact/Controller/Index/Post.php
@@ -4,6 +4,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Contact\Controller\Index;
use Magento\Contact\Model\ConfigInterface;
@@ -119,13 +120,13 @@ private function validatedParams()
{
$request = $this->getRequest();
if (trim($request->getParam('name')) === '') {
- throw new LocalizedException(__('Name is missing'));
+ throw new LocalizedException(__('Enter the Name and try again.'));
}
if (trim($request->getParam('comment')) === '') {
- throw new LocalizedException(__('Comment is missing'));
+ throw new LocalizedException(__('Enter the comment and try again.'));
}
if (false === \strpos($request->getParam('email'), '@')) {
- throw new LocalizedException(__('Invalid email address'));
+ throw new LocalizedException(__('The email address is invalid. Verify the email address and try again.'));
}
if (trim($request->getParam('hideit')) !== '') {
throw new \Exception();
diff --git a/app/code/Magento/Contact/etc/module.xml b/app/code/Magento/Contact/etc/module.xml
index ec91859ee2c..64ba1c1fb0f 100644
--- a/app/code/Magento/Contact/etc/module.xml
+++ b/app/code/Magento/Contact/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/Cookie/etc/module.xml b/app/code/Magento/Cookie/etc/module.xml
index 35c5a52f42e..df64e8b3ebf 100644
--- a/app/code/Magento/Cookie/etc/module.xml
+++ b/app/code/Magento/Cookie/etc/module.xml
@@ -6,5 +6,5 @@
*/
-->
-
+
diff --git a/app/code/Magento/Cron/Model/Schedule.php b/app/code/Magento/Cron/Model/Schedule.php
index 39a58ef360c..b127ecae6f9 100644
--- a/app/code/Magento/Cron/Model/Schedule.php
+++ b/app/code/Magento/Cron/Model/Schedule.php
@@ -87,7 +87,7 @@ public function setCronExpr($expr)
{
$e = preg_split('#\s+#', $expr, null, PREG_SPLIT_NO_EMPTY);
if (sizeof($e) < 5 || sizeof($e) > 6) {
- throw new CronException(__('Invalid cron expression: %1', $expr));
+ throw new CronException(__('The "%1" cron expression is invalid. Verify and try again.', $expr));
}
$this->setCronExprArr($e);
@@ -184,7 +184,7 @@ public function matchCronExpression($expr, $num)
}
if ($from === false || $to === false) {
- throw new CronException(__('Invalid cron expression: %1', $expr));
+ throw new CronException(__('The "%1" cron expression is invalid. Verify and try again.', $expr));
}
return $num >= $from && $num <= $to && $num % $mod === 0;
diff --git a/app/code/Magento/Cron/Test/Unit/Model/ScheduleTest.php b/app/code/Magento/Cron/Test/Unit/Model/ScheduleTest.php
index e9f4c61c7f5..dd1fa0e79dc 100644
--- a/app/code/Magento/Cron/Test/Unit/Model/ScheduleTest.php
+++ b/app/code/Magento/Cron/Test/Unit/Model/ScheduleTest.php
@@ -311,7 +311,7 @@ public function matchCronExpressionExceptionDataProvider()
return [
['1/2/3'], //Invalid cron expression, expecting 'match/modulus': 1/2/3
['1/'], //Invalid cron expression, expecting numeric modulus: 1/
- ['-'], //Invalid cron expression
+ ['-'], //The "-" cron expression is invalid. Verify and try again.
['1-2-3'], //Invalid cron expression, expecting 'from-to' structure: 1-2-3
];
}
diff --git a/app/code/Magento/Cron/etc/db_schema.xml b/app/code/Magento/Cron/etc/db_schema.xml
index 9f019d108b2..deff05d3eec 100644
--- a/app/code/Magento/Cron/etc/db_schema.xml
+++ b/app/code/Magento/Cron/etc/db_schema.xml
@@ -6,7 +6,7 @@
*/
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
diff --git a/app/code/Magento/Cron/etc/module.xml b/app/code/Magento/Cron/etc/module.xml
index ce31b046500..8112b9e8c46 100644
--- a/app/code/Magento/Cron/etc/module.xml
+++ b/app/code/Magento/Cron/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php
index b16330f1b3f..38e20355b66 100644
--- a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php
+++ b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php
@@ -4,6 +4,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\CurrencySymbol\Controller\Adminhtml\System\Currency;
use Magento\Framework\Exception\LocalizedException;
@@ -24,14 +25,16 @@ public function execute()
$service = $this->getRequest()->getParam('rate_services');
$this->_getSession()->setCurrencyRateService($service);
if (!$service) {
- throw new LocalizedException(__('Please specify a correct Import Service.'));
+ throw new LocalizedException(__('The Import Service is incorrect. Verify the service and try again.'));
}
try {
/** @var \Magento\Directory\Model\Currency\Import\ImportInterface $importModel */
$importModel = $this->_objectManager->get(\Magento\Directory\Model\Currency\Import\Factory::class)
->create($service);
} catch (\Exception $e) {
- throw new LocalizedException(__('We can\'t initialize the import model.'));
+ throw new LocalizedException(
+ __("The import model can't be initialized. Verify the model and try again.")
+ );
}
$rates = $importModel->fetchRates();
$errors = $importModel->getMessages();
diff --git a/app/code/Magento/CurrencySymbol/Setup/UpgradeData.php b/app/code/Magento/CurrencySymbol/Setup/Patch/Data/ConvertSerializedCustomCurrencySymbolToJson.php
similarity index 52%
rename from app/code/Magento/CurrencySymbol/Setup/UpgradeData.php
rename to app/code/Magento/CurrencySymbol/Setup/Patch/Data/ConvertSerializedCustomCurrencySymbolToJson.php
index 474efde78ea..be2f2c51471 100644
--- a/app/code/Magento/CurrencySymbol/Setup/UpgradeData.php
+++ b/app/code/Magento/CurrencySymbol/Setup/Patch/Data/ConvertSerializedCustomCurrencySymbolToJson.php
@@ -3,64 +3,58 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\CurrencySymbol\Setup;
+
+namespace Magento\CurrencySymbol\Setup\Patch\Data;
use Magento\CurrencySymbol\Model\System\Currencysymbol;
use Magento\Framework\DB\DataConverter\SerializedToJson;
use Magento\Framework\DB\FieldDataConverterFactory;
use Magento\Framework\DB\Select\QueryModifierFactory;
-use Magento\Framework\Setup\UpgradeDataInterface;
-use Magento\Framework\Setup\ModuleContextInterface;
+use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Setup\ModuleDataSetupInterface;
+use Magento\Framework\Setup\Patch\DataPatchInterface;
+use Magento\Framework\Setup\Patch\PatchVersionInterface;
/**
- * Data upgrade script
- *
- * @codeCoverageIgnore
+ * Class ConvertSerializedCustomCurrencySymbolToJson
+ * @package Magento\CurrencySymbol\Setup\Patch
*/
-class UpgradeData implements UpgradeDataInterface
+class ConvertSerializedCustomCurrencySymbolToJson implements DataPatchInterface, PatchVersionInterface
{
/**
- * @var FieldDataConverterFactory
+ * @var ModuleDataSetupInterface
+ */
+ private $moduleDataSetup;
+
+ /**
+ * @param FieldDataConverterFactory $fieldDataConverterFactory
*/
private $fieldDataConverterFactory;
/**
- * @var QueryModifierFactory
+ * @param QueryModifierFactory $queryModifierFactory
*/
private $queryModifierFactory;
/**
- * Constructor
- *
* @param FieldDataConverterFactory $fieldDataConverterFactory
* @param QueryModifierFactory $queryModifierFactory
+ * @param ModuleDataSetupInterface $moduleDataSetup
*/
public function __construct(
FieldDataConverterFactory $fieldDataConverterFactory,
- QueryModifierFactory $queryModifierFactory
+ QueryModifierFactory $queryModifierFactory,
+ ModuleDataSetupInterface $moduleDataSetup
) {
$this->fieldDataConverterFactory = $fieldDataConverterFactory;
$this->queryModifierFactory = $queryModifierFactory;
+ $this->moduleDataSetup = $moduleDataSetup;
}
/**
* {@inheritdoc}
*/
- public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
- {
- if (version_compare($context->getVersion(), '2.0.1', '<')) {
- $this->convertSerializedCustomCurrencySymbolToJson($setup);
- }
- }
-
- /**
- * Converts custom currency symbol configuration in core_config_data table from serialized to JSON format
- *
- * @param ModuleDataSetupInterface $setup
- * @return void
- */
- private function convertSerializedCustomCurrencySymbolToJson(ModuleDataSetupInterface $setup)
+ public function apply()
{
$fieldDataConverter = $this->fieldDataConverterFactory->create(SerializedToJson::class);
$queryModifier = $this->queryModifierFactory->create(
@@ -72,11 +66,35 @@ private function convertSerializedCustomCurrencySymbolToJson(ModuleDataSetupInte
]
);
$fieldDataConverter->convert(
- $setup->getConnection(),
- $setup->getTable('core_config_data'),
+ $this->moduleDataSetup->getConnection(),
+ $this->moduleDataSetup->getTable('core_config_data'),
'config_id',
'value',
$queryModifier
);
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.1';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
}
diff --git a/app/code/Magento/CurrencySymbol/etc/module.xml b/app/code/Magento/CurrencySymbol/etc/module.xml
index f638479031f..2af87335518 100644
--- a/app/code/Magento/CurrencySymbol/etc/module.xml
+++ b/app/code/Magento/CurrencySymbol/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/Customer/Controller/Account/EditPost.php b/app/code/Magento/Customer/Controller/Account/EditPost.php
index 3f895ad2f17..a10795533a2 100644
--- a/app/code/Magento/Customer/Controller/Account/EditPost.php
+++ b/app/code/Magento/Customer/Controller/Account/EditPost.php
@@ -4,6 +4,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Customer\Controller\Account;
use Magento\Customer\Model\AuthenticationInterface;
@@ -168,7 +169,8 @@ public function execute()
$this->messageManager->addError($e->getMessage());
} catch (UserLockedException $e) {
$message = __(
- 'You did not sign in correctly or your account is temporarily disabled.'
+ 'The account sign-in was incorrect or your account is disabled temporarily. '
+ . 'Please wait and try again later.'
);
$this->session->logout();
$this->session->start();
@@ -287,7 +289,9 @@ private function processChangeEmailRequest(\Magento\Customer\Api\Data\CustomerIn
$this->getRequest()->getPost('current_password')
);
} catch (InvalidEmailOrPasswordException $e) {
- throw new InvalidEmailOrPasswordException(__('The password doesn\'t match this account.'));
+ throw new InvalidEmailOrPasswordException(
+ __("The password doesn't match this account. Verify the password and try again.")
+ );
}
}
}
diff --git a/app/code/Magento/Customer/Controller/Account/ForgotPasswordPost.php b/app/code/Magento/Customer/Controller/Account/ForgotPasswordPost.php
index fe92032b1b7..f3024738730 100644
--- a/app/code/Magento/Customer/Controller/Account/ForgotPasswordPost.php
+++ b/app/code/Magento/Customer/Controller/Account/ForgotPasswordPost.php
@@ -66,7 +66,9 @@ public function execute()
if ($email) {
if (!\Zend_Validate::is($email, \Magento\Framework\Validator\EmailAddress::class)) {
$this->session->setForgottenEmail($email);
- $this->messageManager->addErrorMessage(__('Please correct the email address.'));
+ $this->messageManager->addErrorMessage(
+ __('The email address is incorrect. Verify the email address and try again.')
+ );
return $resultRedirect->setPath('*/*/forgotpassword');
}
diff --git a/app/code/Magento/Customer/Controller/Account/LoginPost.php b/app/code/Magento/Customer/Controller/Account/LoginPost.php
index b55863a3b48..31e2a3aeca9 100644
--- a/app/code/Magento/Customer/Controller/Account/LoginPost.php
+++ b/app/code/Magento/Customer/Controller/Account/LoginPost.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Customer\Controller\Account;
use Magento\Customer\Model\Account\Redirect as AccountRedirect;
@@ -175,12 +176,16 @@ public function execute()
$this->session->setUsername($login['username']);
} catch (UserLockedException $e) {
$message = __(
- 'You did not sign in correctly or your account is temporarily disabled.'
+ 'The account sign-in was incorrect or your account is disabled temporarily. '
+ . 'Please wait and try again later.'
);
$this->messageManager->addError($message);
$this->session->setUsername($login['username']);
} catch (AuthenticationException $e) {
- $message = __('You did not sign in correctly or your account is temporarily disabled.');
+ $message = __(
+ 'The account sign-in was incorrect or your account is disabled temporarily. '
+ . 'Please wait and try again later.'
+ );
$this->messageManager->addError($message);
$this->session->setUsername($login['username']);
} catch (LocalizedException $e) {
diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php b/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php
index c0ea38de809..2603ac193e0 100644
--- a/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php
+++ b/app/code/Magento/Customer/Controller/Adminhtml/Cart/Product/Composite/Cart.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Customer\Controller\Adminhtml\Cart\Product\Composite;
use Magento\Backend\App\Action;
@@ -78,7 +79,7 @@ protected function _initData()
{
$this->_customerId = (int)$this->getRequest()->getParam('customer_id');
if (!$this->_customerId) {
- throw new \Magento\Framework\Exception\LocalizedException(__('No customer ID defined.'));
+ throw new \Magento\Framework\Exception\LocalizedException(__("The customer ID isn't defined."));
}
$quoteItemId = (int)$this->getRequest()->getParam('id');
@@ -95,7 +96,7 @@ protected function _initData()
$this->_quoteItem = $this->_quote->getItemById($quoteItemId);
if (!$this->_quoteItem) {
- throw new LocalizedException(__('Please correct the quote items and try again.'));
+ throw new LocalizedException(__('The quote items are incorrect. Verify the quote items and try again.'));
}
return $this;
diff --git a/app/code/Magento/Customer/CustomerData/SectionPool.php b/app/code/Magento/Customer/CustomerData/SectionPool.php
index 26e9140c63d..0e0d7b992e3 100644
--- a/app/code/Magento/Customer/CustomerData/SectionPool.php
+++ b/app/code/Magento/Customer/CustomerData/SectionPool.php
@@ -74,7 +74,7 @@ protected function getSectionDataByNames($sectionNames)
$data = [];
foreach ($sectionNames as $sectionName) {
if (!isset($this->sectionSourceMap[$sectionName])) {
- throw new LocalizedException(__('"%1" section source is not supported', $sectionName));
+ throw new LocalizedException(__('The "%1" section source isn\'t supported.', $sectionName));
}
$data[$sectionName] = $this->get($this->sectionSourceMap[$sectionName])->getSectionData();
}
diff --git a/app/code/Magento/Customer/Model/AccountManagement.php b/app/code/Magento/Customer/Model/AccountManagement.php
index c48680f3cdb..cd5fef73169 100644
--- a/app/code/Magento/Customer/Model/AccountManagement.php
+++ b/app/code/Magento/Customer/Model/AccountManagement.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Customer\Model;
use Magento\Customer\Api\AccountManagementInterface;
@@ -417,7 +418,7 @@ public function resendConfirmation($email, $websiteId = null, $redirectUrl = '')
{
$customer = $this->customerRepository->get($email, $websiteId);
if (!$customer->getConfirmation()) {
- throw new InvalidTransitionException(__('No confirmation needed.'));
+ throw new InvalidTransitionException(__("Confirmation isn't needed."));
}
try {
@@ -464,11 +465,11 @@ private function activateCustomer($customer, $confirmationKey)
{
// check if customer is inactive
if (!$customer->getConfirmation()) {
- throw new InvalidTransitionException(__('Account already active'));
+ throw new InvalidTransitionException(__('The account is already active.'));
}
if ($customer->getConfirmation() !== $confirmationKey) {
- throw new InputMismatchException(__('Invalid confirmation token'));
+ throw new InputMismatchException(__('The confirmation token is invalid. Verify the token and try again.'));
}
$customer->setConfirmation(null);
@@ -503,7 +504,7 @@ public function authenticate($username, $password)
throw new InvalidEmailOrPasswordException(__('Invalid login or password.'));
}
if ($customer->getConfirmation() && $this->isConfirmationRequired($customer)) {
- throw new EmailNotConfirmedException(__('This account is not confirmed.'));
+ throw new EmailNotConfirmedException(__("This account isn't confirmed. Verify and try again."));
}
$customerModel = $this->customerFactory->create()->updateData($customer);
@@ -619,13 +620,15 @@ protected function checkPasswordStrength($password)
if ($length < $configMinPasswordLength) {
throw new InputException(
__(
- 'Please enter a password with at least %1 characters.',
+ 'The password needs at least %1 characters. Create a new password and try again.',
$configMinPasswordLength
)
);
}
if ($this->stringHelper->strlen(trim($password)) != $length) {
- throw new InputException(__('The password can\'t begin or end with a space.'));
+ throw new InputException(
+ __("The password can't begin or end with a space. Verify the password and try again.")
+ );
}
$requiredCharactersCheck = $this->makeRequiredCharactersCheck($password);
@@ -709,7 +712,9 @@ public function createAccount(CustomerInterface $customer, $password = null, $re
try {
$this->credentialsValidator->checkPasswordDifferentFromEmail($customerEmail, $password);
} catch (InputException $e) {
- throw new LocalizedException(__('Password cannot be the same as email address.'));
+ throw new LocalizedException(
+ __("The password can't be the same as the email address. Create a new password and try again.")
+ );
}
$hash = $this->createPasswordHash($password);
} else {
@@ -766,7 +771,7 @@ public function createAccountWithPasswordHash(CustomerInterface $customer, $hash
$customer = $this->customerRepository->save($customer, $hash);
} catch (AlreadyExistsException $e) {
throw new InputMismatchException(
- __('A customer with the same email already exists in an associated website.')
+ __('A customer with the same email address already exists in an associated website.')
);
} catch (LocalizedException $e) {
throw $e;
@@ -880,7 +885,9 @@ private function changePasswordForCustomer($customer, $currentPassword, $newPass
try {
$this->getAuthentication()->authenticate($customer->getId(), $currentPassword);
} catch (InvalidEmailOrPasswordException $e) {
- throw new InvalidEmailOrPasswordException(__('The password doesn\'t match this account.'));
+ throw new InvalidEmailOrPasswordException(
+ __("The password doesn't match this account. Verify the password and try again.")
+ );
}
$customerEmail = $customer->getEmail();
$this->credentialsValidator->checkPasswordDifferentFromEmail($customerEmail, $newPassword);
@@ -996,7 +1003,7 @@ private function validateResetPasswordToken($customerId, $resetPasswordLinkToken
}
if (!is_string($resetPasswordLinkToken) || empty($resetPasswordLinkToken)) {
$params = ['fieldName' => 'resetPasswordLinkToken'];
- throw new InputException(__('%fieldName is a required field.', $params));
+ throw new InputException(__('"%fieldName" is required. Enter and try again.', $params));
}
$customerSecureData = $this->customerRegistry->retrieveSecureData($customerId);
@@ -1004,9 +1011,9 @@ private function validateResetPasswordToken($customerId, $resetPasswordLinkToken
$rpTokenCreatedAt = $customerSecureData->getRpTokenCreatedAt();
if (!Security::compareStrings($rpToken, $resetPasswordLinkToken)) {
- throw new InputMismatchException(__('Reset password token mismatch.'));
+ throw new InputMismatchException(__('The password token is mismatched. Reset and try again.'));
} elseif ($this->isResetPasswordLinkTokenExpired($rpToken, $rpTokenCreatedAt)) {
- throw new ExpiredException(__('Reset password token expired.'));
+ throw new ExpiredException(__('The password token is expired. Reset and try again.'));
}
return true;
@@ -1048,7 +1055,9 @@ protected function sendNewAccountEmail(
$types = $this->getTemplateTypes();
if (!isset($types[$type])) {
- throw new LocalizedException(__('Please correct the transactional account email type.'));
+ throw new LocalizedException(
+ __('The transactional account email type is incorrect. Verify and try again.')
+ );
}
if (!$storeId) {
diff --git a/app/code/Magento/Customer/Model/Address/AbstractAddress.php b/app/code/Magento/Customer/Model/Address/AbstractAddress.php
index 521e233d9cf..aab9a811168 100644
--- a/app/code/Magento/Customer/Model/Address/AbstractAddress.php
+++ b/app/code/Magento/Customer/Model/Address/AbstractAddress.php
@@ -578,36 +578,36 @@ public function validate()
$errors = [];
if (!\Zend_Validate::is($this->getFirstname(), 'NotEmpty')) {
- $errors[] = __('%fieldName is a required field.', ['fieldName' => 'firstname']);
+ $errors[] = __('"%fieldName" is required. Enter and try again.', ['fieldName' => 'firstname']);
}
if (!\Zend_Validate::is($this->getLastname(), 'NotEmpty')) {
- $errors[] = __('%fieldName is a required field.', ['fieldName' => 'lastname']);
+ $errors[] = __('"%fieldName" is required. Enter and try again.', ['fieldName' => 'lastname']);
}
if (!\Zend_Validate::is($this->getStreetLine(1), 'NotEmpty')) {
- $errors[] = __('%fieldName is a required field.', ['fieldName' => 'street']);
+ $errors[] = __('"%fieldName" is required. Enter and try again.', ['fieldName' => 'street']);
}
if (!\Zend_Validate::is($this->getCity(), 'NotEmpty')) {
- $errors[] = __('%fieldName is a required field.', ['fieldName' => 'city']);
+ $errors[] = __('"%fieldName" is required. Enter and try again.', ['fieldName' => 'city']);
}
if ($this->isTelephoneRequired()) {
if (!\Zend_Validate::is($this->getTelephone(), 'NotEmpty')) {
- $errors[] = __('%fieldName is a required field.', ['fieldName' => 'telephone']);
+ $errors[] = __('"%fieldName" is required. Enter and try again.', ['fieldName' => 'telephone']);
}
}
if ($this->isFaxRequired()) {
if (!\Zend_Validate::is($this->getFax(), 'NotEmpty')) {
- $errors[] = __('%fieldName is a required field.', ['fieldName' => 'fax']);
+ $errors[] = __('"%fieldName" is required. Enter and try again.', ['fieldName' => 'fax']);
}
}
if ($this->isCompanyRequired()) {
if (!\Zend_Validate::is($this->getCompany(), 'NotEmpty')) {
- $errors[] = __('%fieldName is a required field.', ['fieldName' => 'company']);
+ $errors[] = __('"%fieldName" is required. Enter and try again.', ['fieldName' => 'company']);
}
}
@@ -620,11 +620,11 @@ public function validate()
'NotEmpty'
)
) {
- $errors[] = __('%fieldName is a required field.', ['fieldName' => 'postcode']);
+ $errors[] = __('"%fieldName" is required. Enter and try again.', ['fieldName' => 'postcode']);
}
if (!\Zend_Validate::is($this->getCountryId(), 'NotEmpty')) {
- $errors[] = __('%fieldName is a required field.', ['fieldName' => 'countryId']);
+ $errors[] = __('"%fieldName" is required. Enter and try again.', ['fieldName' => 'countryId']);
}
if ($this->getCountryModel()->getRegionCollection()->getSize() && !\Zend_Validate::is(
@@ -634,7 +634,7 @@ public function validate()
$this->getCountryId()
)
) {
- $errors[] = __('%fieldName is a required field.', ['fieldName' => 'regionId']);
+ $errors[] = __('"%fieldName" is required. Enter and try again.', ['fieldName' => 'regionId']);
}
if (empty($errors)) {
diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php
index e0a7281776d..6d1c1549216 100644
--- a/app/code/Magento/Customer/Model/Customer.php
+++ b/app/code/Magento/Customer/Model/Customer.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Customer\Model;
use Magento\Customer\Api\CustomerMetadataInterface;
@@ -392,7 +393,7 @@ public function authenticate($login, $password)
$this->loadByEmail($login);
if ($this->getConfirmation() && $this->isConfirmationRequired()) {
throw new EmailNotConfirmedException(
- __('This account is not confirmed.')
+ __("This account isn't confirmed. Verify and try again.")
);
}
if (!$this->validatePassword($password)) {
@@ -762,7 +763,7 @@ public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeI
if (!isset($types[$type])) {
throw new \Magento\Framework\Exception\LocalizedException(
- __('Please correct the transactional account email type.')
+ __('The transactional account email type is incorrect. Verify and try again.')
);
}
@@ -1240,7 +1241,7 @@ public function changeResetPasswordLinkToken($passwordLinkToken)
{
if (!is_string($passwordLinkToken) || empty($passwordLinkToken)) {
throw new AuthenticationException(
- __('Please enter a valid password reset token.')
+ __('A valid password reset token is missing. Enter and try again.')
);
}
$this->_getResource()->changeResetPasswordLinkToken($this, $passwordLinkToken);
diff --git a/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Password.php b/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Password.php
index abdec5535e8..a74838a1a78 100644
--- a/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Password.php
+++ b/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Password.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Customer\Model\Customer\Attribute\Backend;
use Magento\Framework\Exception\LocalizedException;
@@ -50,12 +51,17 @@ public function beforeSave($object)
if ($length > 0) {
if ($length < self::MIN_PASSWORD_LENGTH) {
throw new LocalizedException(
- __('Please enter a password with at least %1 characters.', self::MIN_PASSWORD_LENGTH)
+ __(
+ 'The password needs at least %1 characters. Create a new password and try again.',
+ self::MIN_PASSWORD_LENGTH
+ )
);
}
if (trim($password) !== $password) {
- throw new LocalizedException(__('The password can not begin or end with a space.'));
+ throw new LocalizedException(
+ __("The password can't begin or end with a space. Verify the password and try again.")
+ );
}
$object->setPasswordHash($object->hashPassword($password));
diff --git a/app/code/Magento/Customer/Model/Customer/CredentialsValidator.php b/app/code/Magento/Customer/Model/Customer/CredentialsValidator.php
index b8adeec2f80..a7682bde905 100644
--- a/app/code/Magento/Customer/Model/Customer/CredentialsValidator.php
+++ b/app/code/Magento/Customer/Model/Customer/CredentialsValidator.php
@@ -25,7 +25,9 @@ class CredentialsValidator
public function checkPasswordDifferentFromEmail($email, $password)
{
if (strcasecmp($password, $email) == 0) {
- throw new InputException(__('Password cannot be the same as email address.'));
+ throw new InputException(
+ __("The password can't be the same as the email address. Create a new password and try again.")
+ );
}
}
}
diff --git a/app/code/Magento/Customer/Model/EmailNotification.php b/app/code/Magento/Customer/Model/EmailNotification.php
index 14ae9a885c7..53c16a4b370 100644
--- a/app/code/Magento/Customer/Model/EmailNotification.php
+++ b/app/code/Magento/Customer/Model/EmailNotification.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Customer\Model;
use Magento\Framework\App\Config\ScopeConfigInterface;
@@ -356,7 +357,9 @@ public function newAccount(
$types = self::TEMPLATE_TYPES;
if (!isset($types[$type])) {
- throw new LocalizedException(__('Please correct the transactional account email type.'));
+ throw new LocalizedException(
+ __('The transactional account email type is incorrect. Verify and try again.')
+ );
}
if (!$storeId) {
diff --git a/app/code/Magento/Customer/Model/ResourceModel/Customer.php b/app/code/Magento/Customer/Model/ResourceModel/Customer.php
index 7e5f9d51549..f5102015596 100644
--- a/app/code/Magento/Customer/Model/ResourceModel/Customer.php
+++ b/app/code/Magento/Customer/Model/ResourceModel/Customer.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Customer\Model\ResourceModel;
use Magento\Customer\Model\Customer\NotificationStorage;
@@ -111,7 +112,7 @@ protected function _beforeSave(\Magento\Framework\DataObject $customer)
parent::_beforeSave($customer);
if (!$customer->getEmail()) {
- throw new ValidatorException(__('Please enter a customer email.'));
+ throw new ValidatorException(__('The customer email is missing. Enter and try again.'));
}
$connection = $this->getConnection();
@@ -135,7 +136,7 @@ protected function _beforeSave(\Magento\Framework\DataObject $customer)
$result = $connection->fetchOne($select, $bind);
if ($result) {
throw new AlreadyExistsException(
- __('A customer with the same email already exists in an associated website.')
+ __('A customer with the same email address already exists in an associated website.')
);
}
@@ -242,7 +243,7 @@ public function loadByEmail(\Magento\Customer\Model\Customer $customer, $email)
if ($customer->getSharingConfig()->isWebsiteScope()) {
if (!$customer->hasData('website_id')) {
throw new \Magento\Framework\Exception\LocalizedException(
- __('A customer website ID must be specified when using the website scope.')
+ __("A customer website ID wasn't specified. The ID must be specified to use the website scope.")
);
}
$bind['website_id'] = (int)$customer->getWebsiteId();
diff --git a/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php b/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php
index d004b99c5a3..cb73b7ee1cb 100644
--- a/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php
+++ b/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php
@@ -305,7 +305,7 @@ private function _validate($group)
{
$exception = new InputException();
if (!\Zend_Validate::is($group->getCode(), 'NotEmpty')) {
- $exception->addError(__('%fieldName is a required field.', ['fieldName' => 'code']));
+ $exception->addError(__('"%fieldName" is required. Enter and try again.', ['fieldName' => 'code']));
}
if ($exception->wasErrorAdded()) {
diff --git a/app/code/Magento/Customer/Setup/CustomerSetup.php b/app/code/Magento/Customer/Setup/CustomerSetup.php
index b1f07e4872f..c074285765e 100644
--- a/app/code/Magento/Customer/Setup/CustomerSetup.php
+++ b/app/code/Magento/Customer/Setup/CustomerSetup.php
@@ -489,4 +489,23 @@ public function getEavConfig()
{
return $this->eavConfig;
}
+
+ /**
+ * Update attributes for customer.
+ *
+ * @param array $entityAttributes
+ * @return void
+ */
+ public function upgradeAttributes(array $entityAttributes)
+ {
+ foreach ($entityAttributes as $entityType => $attributes) {
+ foreach ($attributes as $attributeCode => $attributeData) {
+ $attribute = $this->getEavConfig()->getAttribute($entityType, $attributeCode);
+ foreach ($attributeData as $key => $value) {
+ $attribute->setData($key, $value);
+ }
+ $attribute->save();
+ }
+ }
+ }
}
diff --git a/app/code/Magento/Customer/Setup/Patch/Data/AddCustomerUpdatedAtAttribute.php b/app/code/Magento/Customer/Setup/Patch/Data/AddCustomerUpdatedAtAttribute.php
new file mode 100644
index 00000000000..bad5735bc3e
--- /dev/null
+++ b/app/code/Magento/Customer/Setup/Patch/Data/AddCustomerUpdatedAtAttribute.php
@@ -0,0 +1,91 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->customerSetupFactory = $customerSetupFactory;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ $customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);
+ $customerSetup->addAttribute(
+ Customer::ENTITY,
+ 'updated_at',
+ [
+ 'type' => 'static',
+ 'label' => 'Updated At',
+ 'input' => 'date',
+ 'required' => false,
+ 'sort_order' => 87,
+ 'visible' => false,
+ 'system' => false,
+ ]
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+ UpdateIdentifierCustomerAttributesVisibility::class,
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.4';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/Customer/Setup/Patch/Data/AddNonSpecifiedGenderAttributeOption.php b/app/code/Magento/Customer/Setup/Patch/Data/AddNonSpecifiedGenderAttributeOption.php
new file mode 100644
index 00000000000..ba50f6e17dd
--- /dev/null
+++ b/app/code/Magento/Customer/Setup/Patch/Data/AddNonSpecifiedGenderAttributeOption.php
@@ -0,0 +1,94 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->customerSetupFactory = $customerSetupFactory;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ $customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);
+ $entityTypeId = $customerSetup->getEntityTypeId(Customer::ENTITY);
+ $attributeId = $customerSetup->getAttributeId($entityTypeId, 'gender');
+
+ $option = ['attribute_id' => $attributeId, 'values' => [3 => 'Not Specified']];
+ $customerSetup->addAttributeOption($option);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+ UpdateCustomerAttributesMetadata::class,
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.2';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/Customer/Setup/Patch/Data/AddSecurityTrackingAttributes.php b/app/code/Magento/Customer/Setup/Patch/Data/AddSecurityTrackingAttributes.php
new file mode 100644
index 00000000000..b066d14a3c6
--- /dev/null
+++ b/app/code/Magento/Customer/Setup/Patch/Data/AddSecurityTrackingAttributes.php
@@ -0,0 +1,126 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->customerSetupFactory = $customerSetupFactory;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ $customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);
+ $customerSetup->addAttribute(
+ Customer::ENTITY,
+ 'failures_num',
+ [
+ 'type' => 'static',
+ 'label' => 'Failures Number',
+ 'input' => 'hidden',
+ 'required' => false,
+ 'sort_order' => 100,
+ 'visible' => false,
+ 'system' => true,
+ ]
+ );
+
+ $customerSetup->addAttribute(
+ Customer::ENTITY,
+ 'first_failure',
+ [
+ 'type' => 'static',
+ 'label' => 'First Failure Date',
+ 'input' => 'date',
+ 'required' => false,
+ 'sort_order' => 110,
+ 'visible' => false,
+ 'system' => true,
+ ]
+ );
+
+ $customerSetup->addAttribute(
+ Customer::ENTITY,
+ 'lock_expires',
+ [
+ 'type' => 'static',
+ 'label' => 'Failures Number',
+ 'input' => 'date',
+ 'required' => false,
+ 'sort_order' => 120,
+ 'visible' => false,
+ 'system' => true,
+ ]
+ );
+ $configTable = $this->moduleDataSetup->getTable('core_config_data');
+
+ $this->moduleDataSetup->getConnection()->update(
+ $configTable,
+ ['value' => new \Zend_Db_Expr('value*24')],
+ ['path = ?' => \Magento\Customer\Model\Customer::XML_PATH_CUSTOMER_RESET_PASSWORD_LINK_EXPIRATION_PERIOD]
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+ RemoveCheckoutRegisterAndUpdateAttributes::class,
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.7';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/Customer/Setup/Patch/Data/ConvertValidationRulesFromSerializedToJson.php b/app/code/Magento/Customer/Setup/Patch/Data/ConvertValidationRulesFromSerializedToJson.php
new file mode 100644
index 00000000000..83c5fe7ae6d
--- /dev/null
+++ b/app/code/Magento/Customer/Setup/Patch/Data/ConvertValidationRulesFromSerializedToJson.php
@@ -0,0 +1,84 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->fieldDataConverterFactory = $fieldDataConverterFactory;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ $fieldDataConverter = $this->fieldDataConverterFactory->create(SerializedToJson::class);
+ $fieldDataConverter->convert(
+ $this->moduleDataSetup->getConnection(),
+ $this->moduleDataSetup->getTable('customer_eav_attribute'),
+ 'attribute_id',
+ 'validate_rules'
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+ MigrateStoresAllowedCountriesToWebsite::class,
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.11';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/Customer/Setup/InstallData.php b/app/code/Magento/Customer/Setup/Patch/Data/DefaultCustomerGroupsAndAttributes.php
similarity index 67%
rename from app/code/Magento/Customer/Setup/InstallData.php
rename to app/code/Magento/Customer/Setup/Patch/Data/DefaultCustomerGroupsAndAttributes.php
index 0bc4b19db9d..6e61b66f3c9 100644
--- a/app/code/Magento/Customer/Setup/InstallData.php
+++ b/app/code/Magento/Customer/Setup/Patch/Data/DefaultCustomerGroupsAndAttributes.php
@@ -4,61 +4,69 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Customer\Setup;
+namespace Magento\Customer\Setup\Patch\Data;
+use Magento\Customer\Setup\CustomerSetup;
+use Magento\Customer\Setup\CustomerSetupFactory;
use Magento\Framework\Module\Setup\Migration;
-use Magento\Framework\Setup\InstallDataInterface;
-use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\Setup\Patch\DataPatchInterface;
+use Magento\Framework\Setup\Patch\PatchVersionInterface;
/**
- * @codeCoverageIgnore
+ * Class DefaultCustomerGroupsAndAttributes
+ * @package Magento\Customer\Setup\Patch
*/
-class InstallData implements InstallDataInterface
+class DefaultCustomerGroupsAndAttributes implements DataPatchInterface, PatchVersionInterface
{
/**
- * Customer setup factory
- *
* @var CustomerSetupFactory
*/
private $customerSetupFactory;
/**
- * Init
- *
+ * @var ModuleDataSetupInterface
+ */
+ private $moduleDataSetup;
+
+ /**
+ * DefaultCustomerGroupsAndAttributes constructor.
* @param CustomerSetupFactory $customerSetupFactory
+ * @param ModuleDataSetupInterface $moduleDataSetup
*/
- public function __construct(CustomerSetupFactory $customerSetupFactory)
- {
+ public function __construct(
+ CustomerSetupFactory $customerSetupFactory,
+ \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
+ ) {
$this->customerSetupFactory = $customerSetupFactory;
+ $this->moduleDataSetup = $moduleDataSetup;
}
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
+ public function apply()
{
/** @var CustomerSetup $customerSetup */
- $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
-
- $setup->startSetup();
+ $customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);
// insert default customer groups
- $setup->getConnection()->insertForce(
- $setup->getTable('customer_group'),
+ $this->moduleDataSetup->getConnection()->insertForce(
+ $this->moduleDataSetup->getTable('customer_group'),
['customer_group_id' => 0, 'customer_group_code' => 'NOT LOGGED IN', 'tax_class_id' => 3]
);
- $setup->getConnection()->insertForce(
- $setup->getTable('customer_group'),
+ $this->moduleDataSetup->getConnection()->insertForce(
+ $this->moduleDataSetup->getTable('customer_group'),
['customer_group_id' => 1, 'customer_group_code' => 'General', 'tax_class_id' => 3]
);
- $setup->getConnection()->insertForce(
- $setup->getTable('customer_group'),
+ $this->moduleDataSetup->getConnection()->insertForce(
+ $this->moduleDataSetup->getTable('customer_group'),
['customer_group_id' => 2, 'customer_group_code' => 'Wholesale', 'tax_class_id' => 3]
);
- $setup->getConnection()->insertForce(
- $setup->getTable('customer_group'),
+ $this->moduleDataSetup->getConnection()->insertForce(
+ $this->moduleDataSetup->getTable('customer_group'),
['customer_group_id' => 3, 'customer_group_code' => 'Retailer', 'tax_class_id' => 3]
);
@@ -128,7 +136,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
\Magento\Eav\Model\Entity\Attribute\Backend\DefaultBackend::class
);
- $migrationSetup = $setup->createMigrationSetup();
+ $migrationSetup = $this->moduleDataSetup->createMigrationSetup();
$migrationSetup->appendClassAliasReplace(
'customer_eav_attribute',
@@ -138,7 +146,29 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
['attribute_id']
);
$migrationSetup->doUpdateClassAliases();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [];
+ }
- $setup->endSetup();
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.0';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
}
}
diff --git a/app/code/Magento/Customer/Setup/Patch/Data/MigrateStoresAllowedCountriesToWebsite.php b/app/code/Magento/Customer/Setup/Patch/Data/MigrateStoresAllowedCountriesToWebsite.php
new file mode 100644
index 00000000000..7488f3fd4a9
--- /dev/null
+++ b/app/code/Magento/Customer/Setup/Patch/Data/MigrateStoresAllowedCountriesToWebsite.php
@@ -0,0 +1,176 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->storeManager = $storeManager;
+ $this->allowedCountries = $allowedCountries;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ $this->moduleDataSetup->getConnection()->beginTransaction();
+
+ try {
+ $this->migrateStoresAllowedCountriesToWebsite();
+ $this->moduleDataSetup->getConnection()->commit();
+ } catch (\Exception $e) {
+ $this->moduleDataSetup->getConnection()->rollBack();
+ throw $e;
+ }
+ }
+
+ /**
+ * Merge allowed countries from stores to websites
+ *
+ * @return void
+ */
+ private function migrateStoresAllowedCountriesToWebsite()
+ {
+ $allowedCountries = [];
+ //Process Websites
+ foreach ($this->storeManager->getStores() as $store) {
+ $allowedCountries = $this->mergeAllowedCountries(
+ $allowedCountries,
+ $this->getAllowedCountries(ScopeInterface::SCOPE_STORE, $store->getId()),
+ $store->getWebsiteId()
+ );
+ }
+ //Process stores
+ foreach ($this->storeManager->getWebsites() as $website) {
+ $allowedCountries = $this->mergeAllowedCountries(
+ $allowedCountries,
+ $this->getAllowedCountries(ScopeInterface::SCOPE_WEBSITE, $website->getId()),
+ $website->getId()
+ );
+ }
+
+ $connection = $this->moduleDataSetup->getConnection();
+
+ //Remove everything from stores scope
+ $connection->delete(
+ $this->moduleDataSetup->getTable('core_config_data'),
+ [
+ 'path = ?' => AllowedCountries::ALLOWED_COUNTRIES_PATH,
+ 'scope = ?' => ScopeInterface::SCOPE_STORES
+ ]
+ );
+
+ //Update websites
+ foreach ($allowedCountries as $scopeId => $countries) {
+ $connection->update(
+ $this->moduleDataSetup->getTable('core_config_data'),
+ [
+ 'value' => implode(',', $countries)
+ ],
+ [
+ 'path = ?' => AllowedCountries::ALLOWED_COUNTRIES_PATH,
+ 'scope_id = ?' => $scopeId,
+ 'scope = ?' => ScopeInterface::SCOPE_WEBSITES
+ ]
+ );
+ }
+ }
+
+ /**
+ * Retrieve countries not depending on global scope
+ *
+ * @param string $scope
+ * @param int $scopeCode
+ * @return array
+ */
+ private function getAllowedCountries($scope, $scopeCode)
+ {
+ return $this->allowedCountries->makeCountriesUnique(
+ $this->allowedCountries->getCountriesFromConfig($scope, $scopeCode)
+ );
+ }
+
+ /**
+ * Merge allowed countries between different scopes
+ *
+ * @param array $countries
+ * @param array $newCountries
+ * @param string $identifier
+ * @return array
+ */
+ private function mergeAllowedCountries(array $countries, array $newCountries, $identifier)
+ {
+ if (!isset($countries[$identifier])) {
+ $countries[$identifier] = $newCountries;
+ } else {
+ $countries[$identifier] = array_replace($countries[$identifier], $newCountries);
+ }
+
+ return $countries;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+ UpdateAutocompleteOnStorefrontConfigPath::class
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.9';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/Customer/Setup/Patch/Data/RemoveCheckoutRegisterAndUpdateAttributes.php b/app/code/Magento/Customer/Setup/Patch/Data/RemoveCheckoutRegisterAndUpdateAttributes.php
new file mode 100644
index 00000000000..51f54dc4a43
--- /dev/null
+++ b/app/code/Magento/Customer/Setup/Patch/Data/RemoveCheckoutRegisterAndUpdateAttributes.php
@@ -0,0 +1,136 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->customerSetupFactory = $customerSetupFactory;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ $this->moduleDataSetup->getConnection()->delete(
+ $this->moduleDataSetup->getTable('customer_form_attribute'),
+ ['form_code = ?' => 'checkout_register']
+ );
+ $customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);
+ $customerSetup->updateEntityType(
+ \Magento\Customer\Model\Customer::ENTITY,
+ 'entity_model',
+ \Magento\Customer\Model\ResourceModel\Customer::class
+ );
+ $customerSetup->updateEntityType(
+ \Magento\Customer\Model\Customer::ENTITY,
+ 'increment_model',
+ \Magento\Eav\Model\Entity\Increment\NumericValue::class
+ );
+ $customerSetup->updateEntityType(
+ \Magento\Customer\Model\Customer::ENTITY,
+ 'entity_attribute_collection',
+ \Magento\Customer\Model\ResourceModel\Attribute\Collection::class
+ );
+ $customerSetup->updateEntityType(
+ 'customer_address',
+ 'entity_model',
+ \Magento\Customer\Model\ResourceModel\Address::class
+ );
+ $customerSetup->updateEntityType(
+ 'customer_address',
+ 'entity_attribute_collection',
+ \Magento\Customer\Model\ResourceModel\Address\Attribute\Collection::class
+ );
+ $customerSetup->updateAttribute(
+ 'customer_address',
+ 'country_id',
+ 'source_model',
+ \Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Country::class
+ );
+ $customerSetup->updateAttribute(
+ 'customer_address',
+ 'region',
+ 'backend_model',
+ \Magento\Customer\Model\ResourceModel\Address\Attribute\Backend\Region::class
+ );
+ $customerSetup->updateAttribute(
+ 'customer_address',
+ 'region_id',
+ 'source_model',
+ \Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Region::class
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+ UpgradePasswordHashAndAddress::class,
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.6';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/Customer/Setup/Patch/Data/UpdateAutocompleteOnStorefrontConfigPath.php b/app/code/Magento/Customer/Setup/Patch/Data/UpdateAutocompleteOnStorefrontConfigPath.php
new file mode 100644
index 00000000000..30435ace54d
--- /dev/null
+++ b/app/code/Magento/Customer/Setup/Patch/Data/UpdateAutocompleteOnStorefrontConfigPath.php
@@ -0,0 +1,72 @@
+moduleDataSetup = $moduleDataSetup;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ $this->moduleDataSetup->getConnection()->update(
+ $this->moduleDataSetup->getTable('core_config_data'),
+ ['path' => \Magento\Customer\Model\Form::XML_PATH_ENABLE_AUTOCOMPLETE],
+ ['path = ?' => 'general/restriction/autocomplete_on_storefront']
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+ AddSecurityTrackingAttributes::class,
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.8';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/Customer/Setup/Patch/Data/UpdateCustomerAttributeInputFilters.php b/app/code/Magento/Customer/Setup/Patch/Data/UpdateCustomerAttributeInputFilters.php
new file mode 100644
index 00000000000..938cd3cd52e
--- /dev/null
+++ b/app/code/Magento/Customer/Setup/Patch/Data/UpdateCustomerAttributeInputFilters.php
@@ -0,0 +1,102 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->customerSetupFactory = $customerSetupFactory;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ $customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);
+ $entityAttributes = [
+ 'customer_address' => [
+ 'firstname' => [
+ 'input_filter' => 'trim'
+ ],
+ 'lastname' => [
+ 'input_filter' => 'trim'
+ ],
+ 'middlename' => [
+ 'input_filter' => 'trim'
+ ],
+ ],
+ 'customer' => [
+ 'firstname' => [
+ 'input_filter' => 'trim'
+ ],
+ 'lastname' => [
+ 'input_filter' => 'trim'
+ ],
+ 'middlename' => [
+ 'input_filter' => 'trim'
+ ],
+ ],
+ ];
+ $customerSetup->upgradeAttributes($entityAttributes);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+ UpdateVATNumber::class,
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.13';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/Customer/Setup/Patch/Data/UpdateCustomerAttributesMetadata.php b/app/code/Magento/Customer/Setup/Patch/Data/UpdateCustomerAttributesMetadata.php
new file mode 100644
index 00000000000..5f4d9952590
--- /dev/null
+++ b/app/code/Magento/Customer/Setup/Patch/Data/UpdateCustomerAttributesMetadata.php
@@ -0,0 +1,203 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->customerSetupFactory = $customerSetupFactory;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ /** @var CustomerSetup $customerSetup */
+ $customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);
+ $this->updateCustomerAttributesMetadata($customerSetup);
+ }
+
+ /**
+ * @param CustomerSetup $customerSetup
+ * @return void
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ */
+ private function updateCustomerAttributesMetadata($customerSetup)
+ {
+ $entityAttributes = [
+ 'customer' => [
+ 'website_id' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => true,
+ 'is_filterable_in_grid' => true,
+ 'is_searchable_in_grid' => false,
+ ],
+ 'created_in' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => true,
+ 'is_filterable_in_grid' => false,
+ 'is_searchable_in_grid' => true,
+ ],
+ 'email' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => true,
+ 'is_filterable_in_grid' => true,
+ 'is_searchable_in_grid' => true,
+ ],
+ 'group_id' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => true,
+ 'is_filterable_in_grid' => true,
+ 'is_searchable_in_grid' => false,
+ ],
+ 'dob' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => true,
+ 'is_filterable_in_grid' => true,
+ 'is_searchable_in_grid' => false,
+ ],
+ 'taxvat' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => true,
+ 'is_filterable_in_grid' => false,
+ 'is_searchable_in_grid' => true,
+ ],
+ 'confirmation' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => true,
+ 'is_filterable_in_grid' => true,
+ 'is_searchable_in_grid' => false,
+ ],
+ 'created_at' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => true,
+ 'is_filterable_in_grid' => true,
+ 'is_searchable_in_grid' => false,
+ ],
+ 'gender' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => true,
+ 'is_filterable_in_grid' => true,
+ 'is_searchable_in_grid' => false,
+ ],
+ ],
+ 'customer_address' => [
+ 'company' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => false,
+ 'is_filterable_in_grid' => false,
+ 'is_searchable_in_grid' => true,
+ ],
+ 'street' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => false,
+ 'is_filterable_in_grid' => false,
+ 'is_searchable_in_grid' => true,
+ ],
+ 'city' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => false,
+ 'is_filterable_in_grid' => false,
+ 'is_searchable_in_grid' => true,
+ ],
+ 'country_id' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => true,
+ 'is_filterable_in_grid' => true,
+ 'is_searchable_in_grid' => false,
+ ],
+ 'region' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => true,
+ 'is_filterable_in_grid' => false,
+ 'is_searchable_in_grid' => true,
+ ],
+ 'region_id' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => false,
+ 'is_filterable_in_grid' => true,
+ 'is_searchable_in_grid' => false,
+ ],
+ 'postcode' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => true,
+ 'is_filterable_in_grid' => true,
+ 'is_searchable_in_grid' => true,
+ ],
+ 'telephone' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => true,
+ 'is_filterable_in_grid' => true,
+ 'is_searchable_in_grid' => true,
+ ],
+ 'fax' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => false,
+ 'is_filterable_in_grid' => false,
+ 'is_searchable_in_grid' => true,
+ ],
+ ],
+ ];
+ $customerSetup->upgradeAttributes($entityAttributes);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+ DefaultCustomerGroupsAndAttributes::class,
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.1';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/Customer/Setup/Patch/Data/UpdateIdentifierCustomerAttributesVisibility.php b/app/code/Magento/Customer/Setup/Patch/Data/UpdateIdentifierCustomerAttributesVisibility.php
new file mode 100644
index 00000000000..7d0cad768d6
--- /dev/null
+++ b/app/code/Magento/Customer/Setup/Patch/Data/UpdateIdentifierCustomerAttributesVisibility.php
@@ -0,0 +1,100 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->customerSetupFactory = $customerSetupFactory;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ $customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);
+ $entityAttributes = [
+ 'customer_address' => [
+ 'region_id' => [
+ 'is_used_in_grid' => false,
+ 'is_visible_in_grid' => false,
+ 'is_filterable_in_grid' => false,
+ 'is_searchable_in_grid' => false,
+ ],
+ 'firstname' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => false,
+ 'is_filterable_in_grid' => false,
+ 'is_searchable_in_grid' => true,
+ ],
+ 'lastname' => [
+ 'is_used_in_grid' => true,
+ 'is_visible_in_grid' => false,
+ 'is_filterable_in_grid' => false,
+ 'is_searchable_in_grid' => true,
+ ],
+ ],
+ ];
+ $customerSetup->upgradeAttributes($entityAttributes);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+ AddNonSpecifiedGenderAttributeOption::class,
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.3';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/Customer/Setup/Patch/Data/UpdateVATNumber.php b/app/code/Magento/Customer/Setup/Patch/Data/UpdateVATNumber.php
new file mode 100644
index 00000000000..d31301eedf4
--- /dev/null
+++ b/app/code/Magento/Customer/Setup/Patch/Data/UpdateVATNumber.php
@@ -0,0 +1,86 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->customerSetupFactory = $customerSetupFactory;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ $customerSetup = $this->customerSetupFactory->create(['resourceConnection' => $this->moduleDataSetup]);
+ $customerSetup->updateAttribute('customer_address', 'vat_id', 'frontend_label', 'VAT Number');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+ ConvertValidationRulesFromSerializedToJson::class,
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.12';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/Customer/Setup/Patch/Data/UpgradePasswordHashAndAddress.php b/app/code/Magento/Customer/Setup/Patch/Data/UpgradePasswordHashAndAddress.php
new file mode 100644
index 00000000000..3b8f96a0373
--- /dev/null
+++ b/app/code/Magento/Customer/Setup/Patch/Data/UpgradePasswordHashAndAddress.php
@@ -0,0 +1,120 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->customerSetupFactory = $customerSetupFactory;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ $this->upgradeHash();
+ $entityAttributes = [
+ 'customer_address' => [
+ 'fax' => [
+ 'is_visible' => false,
+ 'is_system' => false,
+ ],
+ ],
+ ];
+ $customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);
+ $customerSetup->upgradeAttributes($entityAttributes);
+ }
+
+ /**
+ * @return void
+ */
+ private function upgradeHash()
+ {
+ $customerEntityTable = $this->moduleDataSetup->getTable('customer_entity');
+
+ $select = $this->moduleDataSetup->getConnection()->select()->from(
+ $customerEntityTable,
+ ['entity_id', 'password_hash']
+ );
+
+ $customers = $this->moduleDataSetup->getConnection()->fetchAll($select);
+ foreach ($customers as $customer) {
+ if ($customer['password_hash'] === null) {
+ continue;
+ }
+ list($hash, $salt) = explode(Encryptor::DELIMITER, $customer['password_hash']);
+
+ $newHash = $customer['password_hash'];
+ if (strlen($hash) === 32) {
+ $newHash = implode(Encryptor::DELIMITER, [$hash, $salt, Encryptor::HASH_VERSION_MD5]);
+ } elseif (strlen($hash) === 64) {
+ $newHash = implode(Encryptor::DELIMITER, [$hash, $salt, Encryptor::HASH_VERSION_SHA256]);
+ }
+
+ $bind = ['password_hash' => $newHash];
+ $where = ['entity_id = ?' => (int)$customer['entity_id']];
+ $this->moduleDataSetup->getConnection()->update($customerEntityTable, $bind, $where);
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+ AddCustomerUpdatedAtAttribute::class,
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.5';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/Customer/Setup/UpgradeData.php b/app/code/Magento/Customer/Setup/UpgradeData.php
deleted file mode 100644
index 5e087599588..00000000000
--- a/app/code/Magento/Customer/Setup/UpgradeData.php
+++ /dev/null
@@ -1,700 +0,0 @@
-customerSetupFactory = $customerSetupFactory;
- $this->indexerRegistry = $indexerRegistry;
- $this->eavConfig = $eavConfig;
-
- $this->fieldDataConverterFactory = $fieldDataConverterFactory ?: ObjectManager::getInstance()->get(
- FieldDataConverterFactory::class
- );
- }
-
- /**
- * {@inheritdoc}
- * @SuppressWarnings(PHPMD.NPathComplexity)
- * @SuppressWarnings(PHPMD.CyclomaticComplexity)
- */
- public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
- {
- $setup->startSetup();
- /** @var CustomerSetup $customerSetup */
- $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
-
- if (version_compare($context->getVersion(), '2.0.6', '<')) {
- $this->upgradeVersionTwoZeroSix($customerSetup);
- }
-
- if (version_compare($context->getVersion(), '2.0.1', '<')) {
- $this->upgradeVersionTwoZeroOne($customerSetup);
- }
-
- if (version_compare($context->getVersion(), '2.0.2') < 0) {
- $this->upgradeVersionTwoZeroTwo($customerSetup);
- }
-
- if (version_compare($context->getVersion(), '2.0.3', '<')) {
- $this->upgradeVersionTwoZeroThree($customerSetup);
- }
-
- if (version_compare($context->getVersion(), '2.0.4', '<')) {
- $this->upgradeVersionTwoZeroFour($customerSetup);
- }
-
- if (version_compare($context->getVersion(), '2.0.5', '<')) {
- $this->upgradeVersionTwoZeroFive($customerSetup, $setup);
- }
-
- if (version_compare($context->getVersion(), '2.0.6', '<')) {
- $setup->getConnection()->delete(
- $setup->getTable('customer_form_attribute'),
- ['form_code = ?' => 'checkout_register']
- );
- }
-
- if (version_compare($context->getVersion(), '2.0.8', '<')) {
- $setup->getConnection()->update(
- $setup->getTable('core_config_data'),
- ['path' => \Magento\Customer\Model\Form::XML_PATH_ENABLE_AUTOCOMPLETE],
- ['path = ?' => 'general/restriction/autocomplete_on_storefront']
- );
- }
-
- if (version_compare($context->getVersion(), '2.0.7', '<')) {
- $this->upgradeVersionTwoZeroSeven($customerSetup);
- $this->upgradeCustomerPasswordResetlinkExpirationPeriodConfig($setup);
- }
-
- if (version_compare($context->getVersion(), '2.0.9', '<')) {
- $setup->getConnection()->beginTransaction();
-
- try {
- $this->migrateStoresAllowedCountriesToWebsite($setup);
- $setup->getConnection()->commit();
- } catch (\Exception $e) {
- $setup->getConnection()->rollBack();
- throw $e;
- }
- }
- if (version_compare($context->getVersion(), '2.0.11', '<')) {
- $fieldDataConverter = $this->fieldDataConverterFactory->create(SerializedToJson::class);
- $fieldDataConverter->convert(
- $setup->getConnection(),
- $setup->getTable('customer_eav_attribute'),
- 'attribute_id',
- 'validate_rules'
- );
- }
-
- if (version_compare($context->getVersion(), '2.0.12', '<')) {
- $this->upgradeVersionTwoZeroTwelve($customerSetup);
- }
-
- if (version_compare($context->getVersion(), '2.0.13', '<')) {
- $this->upgradeVersionTwoZeroThirteen($customerSetup);
- }
-
- $this->eavConfig->clear();
- $setup->endSetup();
- }
-
- /**
- * Retrieve Store Manager
- *
- * @deprecated 100.1.3
- * @return StoreManagerInterface
- */
- private function getStoreManager()
- {
- if (!$this->storeManager) {
- $this->storeManager = ObjectManager::getInstance()->get(StoreManagerInterface::class);
- }
-
- return $this->storeManager;
- }
-
- /**
- * Retrieve Allowed Countries Reader
- *
- * @deprecated 100.1.3
- * @return AllowedCountries
- */
- private function getAllowedCountriesReader()
- {
- if (!$this->allowedCountriesReader) {
- $this->allowedCountriesReader = ObjectManager::getInstance()->get(AllowedCountries::class);
- }
-
- return $this->allowedCountriesReader;
- }
-
- /**
- * Merge allowed countries between different scopes
- *
- * @param array $countries
- * @param array $newCountries
- * @param string $identifier
- * @return array
- */
- private function mergeAllowedCountries(array $countries, array $newCountries, $identifier)
- {
- if (!isset($countries[$identifier])) {
- $countries[$identifier] = $newCountries;
- } else {
- $countries[$identifier] =
- array_replace($countries[$identifier], $newCountries);
- }
-
- return $countries;
- }
-
- /**
- * Retrieve countries not depending on global scope
- *
- * @param string $scope
- * @param int $scopeCode
- * @return array
- */
- private function getAllowedCountries($scope, $scopeCode)
- {
- $reader = $this->getAllowedCountriesReader();
- return $reader->makeCountriesUnique($reader->getCountriesFromConfig($scope, $scopeCode));
- }
-
- /**
- * Merge allowed countries from stores to websites
- *
- * @param SetupInterface $setup
- * @return void
- */
- private function migrateStoresAllowedCountriesToWebsite(SetupInterface $setup)
- {
- $allowedCountries = [];
- //Process Websites
- foreach ($this->getStoreManager()->getStores() as $store) {
- $allowedCountries = $this->mergeAllowedCountries(
- $allowedCountries,
- $this->getAllowedCountries(ScopeInterface::SCOPE_STORE, $store->getId()),
- $store->getWebsiteId()
- );
- }
- //Process stores
- foreach ($this->getStoreManager()->getWebsites() as $website) {
- $allowedCountries = $this->mergeAllowedCountries(
- $allowedCountries,
- $this->getAllowedCountries(ScopeInterface::SCOPE_WEBSITE, $website->getId()),
- $website->getId()
- );
- }
-
- $connection = $setup->getConnection();
-
- //Remove everything from stores scope
- $connection->delete(
- $setup->getTable('core_config_data'),
- [
- 'path = ?' => AllowedCountries::ALLOWED_COUNTRIES_PATH,
- 'scope = ?' => ScopeInterface::SCOPE_STORES
- ]
- );
-
- //Update websites
- foreach ($allowedCountries as $scopeId => $countries) {
- $connection->update(
- $setup->getTable('core_config_data'),
- [
- 'value' => implode(',', $countries)
- ],
- [
- 'path = ?' => AllowedCountries::ALLOWED_COUNTRIES_PATH,
- 'scope_id = ?' => $scopeId,
- 'scope = ?' => ScopeInterface::SCOPE_WEBSITES
- ]
- );
- }
- }
-
- /**
- * @param array $entityAttributes
- * @param CustomerSetup $customerSetup
- * @return void
- */
- protected function upgradeAttributes(array $entityAttributes, CustomerSetup $customerSetup)
- {
- foreach ($entityAttributes as $entityType => $attributes) {
- foreach ($attributes as $attributeCode => $attributeData) {
- $attribute = $customerSetup->getEavConfig()->getAttribute($entityType, $attributeCode);
- foreach ($attributeData as $key => $value) {
- $attribute->setData($key, $value);
- }
- $attribute->save();
- }
- }
- }
-
- /**
- * @param ModuleDataSetupInterface $setup
- * @return void
- */
- private function upgradeHash($setup)
- {
- $customerEntityTable = $setup->getTable('customer_entity');
-
- $select = $setup->getConnection()->select()->from(
- $customerEntityTable,
- ['entity_id', 'password_hash']
- );
-
- $customers = $setup->getConnection()->fetchAll($select);
- foreach ($customers as $customer) {
- if ($customer['password_hash'] === null) {
- continue;
- }
- list($hash, $salt) = explode(Encryptor::DELIMITER, $customer['password_hash']);
-
- $newHash = $customer['password_hash'];
- if (strlen($hash) === 32) {
- $newHash = implode(Encryptor::DELIMITER, [$hash, $salt, Encryptor::HASH_VERSION_MD5]);
- } elseif (strlen($hash) === 64) {
- $newHash = implode(Encryptor::DELIMITER, [$hash, $salt, Encryptor::HASH_VERSION_SHA256]);
- }
-
- $bind = ['password_hash' => $newHash];
- $where = ['entity_id = ?' => (int)$customer['entity_id']];
- $setup->getConnection()->update($customerEntityTable, $bind, $where);
- }
- }
-
- /**
- * @param CustomerSetup $customerSetup
- * @return void
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
- */
- private function upgradeVersionTwoZeroOne($customerSetup)
- {
- $entityAttributes = [
- 'customer' => [
- 'website_id' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => true,
- 'is_filterable_in_grid' => true,
- 'is_searchable_in_grid' => false,
- ],
- 'created_in' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => true,
- 'is_filterable_in_grid' => false,
- 'is_searchable_in_grid' => true,
- ],
- 'email' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => true,
- 'is_filterable_in_grid' => true,
- 'is_searchable_in_grid' => true,
- ],
- 'group_id' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => true,
- 'is_filterable_in_grid' => true,
- 'is_searchable_in_grid' => false,
- ],
- 'dob' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => true,
- 'is_filterable_in_grid' => true,
- 'is_searchable_in_grid' => false,
- ],
- 'taxvat' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => true,
- 'is_filterable_in_grid' => false,
- 'is_searchable_in_grid' => true,
- ],
- 'confirmation' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => true,
- 'is_filterable_in_grid' => true,
- 'is_searchable_in_grid' => false,
- ],
- 'created_at' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => true,
- 'is_filterable_in_grid' => true,
- 'is_searchable_in_grid' => false,
- ],
- 'gender' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => true,
- 'is_filterable_in_grid' => true,
- 'is_searchable_in_grid' => false,
- ],
- ],
- 'customer_address' => [
- 'company' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => false,
- 'is_filterable_in_grid' => false,
- 'is_searchable_in_grid' => true,
- ],
- 'street' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => false,
- 'is_filterable_in_grid' => false,
- 'is_searchable_in_grid' => true,
- ],
- 'city' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => false,
- 'is_filterable_in_grid' => false,
- 'is_searchable_in_grid' => true,
- ],
- 'country_id' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => true,
- 'is_filterable_in_grid' => true,
- 'is_searchable_in_grid' => false,
- ],
- 'region' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => true,
- 'is_filterable_in_grid' => false,
- 'is_searchable_in_grid' => true,
- ],
- 'region_id' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => false,
- 'is_filterable_in_grid' => true,
- 'is_searchable_in_grid' => false,
- ],
- 'postcode' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => true,
- 'is_filterable_in_grid' => true,
- 'is_searchable_in_grid' => true,
- ],
- 'telephone' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => true,
- 'is_filterable_in_grid' => true,
- 'is_searchable_in_grid' => true,
- ],
- 'fax' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => false,
- 'is_filterable_in_grid' => false,
- 'is_searchable_in_grid' => true,
- ],
- ],
- ];
- $this->upgradeAttributes($entityAttributes, $customerSetup);
- }
-
- /**
- * @param CustomerSetup $customerSetup
- * @return void
- */
- private function upgradeVersionTwoZeroTwo($customerSetup)
- {
- $entityTypeId = $customerSetup->getEntityTypeId(Customer::ENTITY);
- $attributeId = $customerSetup->getAttributeId($entityTypeId, 'gender');
-
- $option = ['attribute_id' => $attributeId, 'values' => [3 => 'Not Specified']];
- $customerSetup->addAttributeOption($option);
- }
-
- /**
- * @param CustomerSetup $customerSetup
- * @return void
- */
- private function upgradeVersionTwoZeroThree($customerSetup)
- {
- $entityAttributes = [
- 'customer_address' => [
- 'region_id' => [
- 'is_used_in_grid' => false,
- 'is_visible_in_grid' => false,
- 'is_filterable_in_grid' => false,
- 'is_searchable_in_grid' => false,
- ],
- 'firstname' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => false,
- 'is_filterable_in_grid' => false,
- 'is_searchable_in_grid' => true,
- ],
- 'lastname' => [
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => false,
- 'is_filterable_in_grid' => false,
- 'is_searchable_in_grid' => true,
- ],
- ],
- ];
- $this->upgradeAttributes($entityAttributes, $customerSetup);
- }
-
- /**
- * @param CustomerSetup $customerSetup
- * @return void
- */
- private function upgradeVersionTwoZeroFour($customerSetup)
- {
- $customerSetup->addAttribute(
- Customer::ENTITY,
- 'updated_at',
- [
- 'type' => 'static',
- 'label' => 'Updated At',
- 'input' => 'date',
- 'required' => false,
- 'sort_order' => 87,
- 'visible' => false,
- 'system' => false,
- ]
- );
- }
-
- /**
- * @param CustomerSetup $customerSetup
- * @param ModuleDataSetupInterface $setup
- * @return void
- */
- private function upgradeVersionTwoZeroFive($customerSetup, $setup)
- {
- $this->upgradeHash($setup);
- $entityAttributes = [
- 'customer_address' => [
- 'fax' => [
- 'is_visible' => false,
- 'is_system' => false,
- ],
- ],
- ];
- $this->upgradeAttributes($entityAttributes, $customerSetup);
- }
-
- /**
- * @param CustomerSetup $customerSetup
- * @return void
- */
- private function upgradeVersionTwoZeroSix($customerSetup)
- {
- $customerSetup->updateEntityType(
- \Magento\Customer\Model\Customer::ENTITY,
- 'entity_model',
- \Magento\Customer\Model\ResourceModel\Customer::class
- );
- $customerSetup->updateEntityType(
- \Magento\Customer\Model\Customer::ENTITY,
- 'increment_model',
- \Magento\Eav\Model\Entity\Increment\NumericValue::class
- );
- $customerSetup->updateEntityType(
- \Magento\Customer\Model\Customer::ENTITY,
- 'entity_attribute_collection',
- \Magento\Customer\Model\ResourceModel\Attribute\Collection::class
- );
- $customerSetup->updateEntityType(
- 'customer_address',
- 'entity_model',
- \Magento\Customer\Model\ResourceModel\Address::class
- );
- $customerSetup->updateEntityType(
- 'customer_address',
- 'entity_attribute_collection',
- \Magento\Customer\Model\ResourceModel\Address\Attribute\Collection::class
- );
- $customerSetup->updateAttribute(
- 'customer_address',
- 'country_id',
- 'source_model',
- \Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Country::class
- );
- $customerSetup->updateAttribute(
- 'customer_address',
- 'region',
- 'backend_model',
- \Magento\Customer\Model\ResourceModel\Address\Attribute\Backend\Region::class
- );
- $customerSetup->updateAttribute(
- 'customer_address',
- 'region_id',
- 'source_model',
- \Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Region::class
- );
- }
-
- /**
- * @param CustomerSetup $customerSetup
- * @return void
- */
- private function upgradeVersionTwoZeroSeven($customerSetup)
- {
- $customerSetup->addAttribute(
- Customer::ENTITY,
- 'failures_num',
- [
- 'type' => 'static',
- 'label' => 'Failures Number',
- 'input' => 'hidden',
- 'required' => false,
- 'sort_order' => 100,
- 'visible' => false,
- 'system' => true,
- ]
- );
-
- $customerSetup->addAttribute(
- Customer::ENTITY,
- 'first_failure',
- [
- 'type' => 'static',
- 'label' => 'First Failure Date',
- 'input' => 'date',
- 'required' => false,
- 'sort_order' => 110,
- 'visible' => false,
- 'system' => true,
- ]
- );
-
- $customerSetup->addAttribute(
- Customer::ENTITY,
- 'lock_expires',
- [
- 'type' => 'static',
- 'label' => 'Failures Number',
- 'input' => 'date',
- 'required' => false,
- 'sort_order' => 120,
- 'visible' => false,
- 'system' => true,
- ]
- );
- }
-
- /**
- * @param CustomerSetup $customerSetup
- * @return void
- */
- private function upgradeVersionTwoZeroTwelve(CustomerSetup $customerSetup)
- {
- $customerSetup->updateAttribute('customer_address', 'vat_id', 'frontend_label', 'VAT Number');
- }
-
- /**
- * @param ModuleDataSetupInterface $setup
- * @return void
- */
- private function upgradeCustomerPasswordResetlinkExpirationPeriodConfig($setup)
- {
- $configTable = $setup->getTable('core_config_data');
-
- $setup->getConnection()->update(
- $configTable,
- ['value' => new \Zend_Db_Expr('value*24')],
- ['path = ?' => \Magento\Customer\Model\Customer::XML_PATH_CUSTOMER_RESET_PASSWORD_LINK_EXPIRATION_PERIOD]
- );
- }
-
- /**
- * @param CustomerSetup $customerSetup
- */
- private function upgradeVersionTwoZeroThirteen(CustomerSetup $customerSetup)
- {
- $entityAttributes = [
- 'customer_address' => [
- 'firstname' => [
- 'input_filter' => 'trim'
- ],
- 'lastname' => [
- 'input_filter' => 'trim'
- ],
- 'middlename' => [
- 'input_filter' => 'trim'
- ],
- ],
- 'customer' => [
- 'firstname' => [
- 'input_filter' => 'trim'
- ],
- 'lastname' => [
- 'input_filter' => 'trim'
- ],
- 'middlename' => [
- 'input_filter' => 'trim'
- ],
- ],
- ];
- $this->upgradeAttributes($entityAttributes, $customerSetup);
- }
-}
diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php
index f2860725dbb..aaa1c170279 100644
--- a/app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Customer\Test\Unit\Controller\Account;
use Magento\Customer\Api\CustomerRepositoryInterface;
@@ -394,12 +395,13 @@ public function changeEmailExceptionDataProvider()
[
'testNumber' => 1,
'exceptionClass' => \Magento\Framework\Exception\InvalidEmailOrPasswordException::class,
- 'errorMessage' => __('The password doesn\'t match this account.')
+ 'errorMessage' => __("The password doesn't match this account. Verify the password and try again.")
],
[
'testNumber' => 2,
'exceptionClass' => \Magento\Framework\Exception\State\UserLockedException::class,
- 'errorMessage' => __('You did not sign in correctly or your account is temporarily disabled.')
+ 'errorMessage' => __('The account sign-in was incorrect or your account is disabled temporarily. '
+ . 'Please wait and try again later.')
]
];
}
diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php
index 8e07f41cff5..762c76b695d 100644
--- a/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Customer\Test\Unit\Controller\Account;
use Magento\Customer\Api\AccountManagementInterface;
@@ -563,7 +564,12 @@ protected function mockExceptions($exception, $username)
case \Magento\Framework\Exception\AuthenticationException::class:
$this->messageManager->expects($this->once())
->method('addError')
- ->with(__('You did not sign in correctly or your account is temporarily disabled.'))
+ ->with(
+ __(
+ 'The account sign-in was incorrect or your account is disabled temporarily. '
+ . 'Please wait and try again later.'
+ )
+ )
->willReturnSelf();
$this->session->expects($this->once())
@@ -581,7 +587,8 @@ protected function mockExceptions($exception, $username)
case \Magento\Framework\Exception\State\UserLockedException::class:
$message = __(
- 'You did not sign in correctly or your account is temporarily disabled.'
+ 'The account sign-in was incorrect or your account is disabled temporarily. '
+ . 'Please wait and try again later.'
);
$this->messageManager->expects($this->once())
->method('addError')
diff --git a/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php b/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php
index fed2005ade8..0ca79833e8a 100644
--- a/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Customer\Test\Unit\Model;
use Magento\Customer\Model\AccountManagement;
@@ -723,7 +724,8 @@ public function testCreateAccountWithPasswordInputException(
if ($testNumber == 1) {
$this->expectException(
\Magento\Framework\Exception\InputException::class,
- 'Please enter a password with at least ' . $minPasswordLength . ' characters.'
+ 'The password needs at least ' . $minPasswordLength . ' characters. '
+ . 'Create a new password and try again.'
);
}
@@ -1214,7 +1216,7 @@ public function testValidateResetPasswordTokenBadCustomerId()
/**
* @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage resetPasswordLinkToken is a required field
+ * @expectedExceptionMessage "resetPasswordLinkToken" is required. Enter and try again.
*/
public function testValidateResetPasswordTokenBadResetPasswordLinkToken()
{
@@ -1223,7 +1225,7 @@ public function testValidateResetPasswordTokenBadResetPasswordLinkToken()
/**
* @expectedException \Magento\Framework\Exception\State\InputMismatchException
- * @expectedExceptionMessage Reset password token mismatch
+ * @expectedExceptionMessage The password token is mismatched. Reset and try again.
*/
public function testValidateResetPasswordTokenTokenMismatch()
{
@@ -1236,7 +1238,7 @@ public function testValidateResetPasswordTokenTokenMismatch()
/**
* @expectedException \Magento\Framework\Exception\State\ExpiredException
- * @expectedExceptionMessage Reset password token expired
+ * @expectedExceptionMessage The password token is expired. Reset and try again.
*/
public function testValidateResetPasswordTokenTokenExpired()
{
diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php
index 2eef9a44cab..a94b7e39bc0 100644
--- a/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php
@@ -327,31 +327,31 @@ public function validateDataProvider()
return [
'firstname' => [
array_merge(array_diff_key($data, ['firstname' => '']), ['country_id' => $countryId++]),
- ['firstname is a required field.'],
+ ['"firstname" is required. Enter and try again.'],
],
'lastname' => [
array_merge(array_diff_key($data, ['lastname' => '']), ['country_id' => $countryId++]),
- ['lastname is a required field.'],
+ ['"lastname" is required. Enter and try again.'],
],
'street' => [
array_merge(array_diff_key($data, ['street' => '']), ['country_id' => $countryId++]),
- ['street is a required field.'],
+ ['"street" is required. Enter and try again.'],
],
'city' => [
array_merge(array_diff_key($data, ['city' => '']), ['country_id' => $countryId++]),
- ['city is a required field.'],
+ ['"city" is required. Enter and try again.'],
],
'telephone' => [
array_merge(array_diff_key($data, ['telephone' => '']), ['country_id' => $countryId++]),
- ['telephone is a required field.'],
+ ['"telephone" is required. Enter and try again.'],
],
'postcode' => [
array_merge(array_diff_key($data, ['postcode' => '']), ['country_id' => $countryId++]),
- ['postcode is a required field.'],
+ ['"postcode" is required. Enter and try again.'],
],
'country_id' => [
array_diff_key($data, ['country_id' => '']),
- ['countryId is a required field.'],
+ ['"countryId" is required. Enter and try again.'],
],
'validated' => [array_merge($data, ['country_id' => $countryId++]), true],
];
diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/CredentialsValidatorTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/CredentialsValidatorTest.php
index 07aef85e92d..36667e0ccf6 100644
--- a/app/code/Magento/Customer/Test/Unit/Model/Customer/CredentialsValidatorTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/CredentialsValidatorTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Customer\Test\Unit\Model\Customer;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
@@ -29,7 +30,6 @@ protected function setUp()
/**
* @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Password cannot be the same as email address.
*/
public function testCheckPasswordDifferentFromEmail()
{
@@ -37,5 +37,9 @@ public function testCheckPasswordDifferentFromEmail()
$password = strtoupper($email); // for case-insensitive check
$this->object->checkPasswordDifferentFromEmail($email, $password);
+
+ $this->expectExceptionMessage(
+ "The password can't be the same as the email address. Create a new password and try again."
+ );
}
}
diff --git a/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php b/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php
index f5b7f08d290..9848a09540c 100644
--- a/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php
@@ -134,7 +134,7 @@ public function testHashPassword()
/**
* @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage Please correct the transactional account email type.
+ * @expectedExceptionMessage The transactional account email type is incorrect. Verify and try again.
*/
public function testSendNewAccountEmailException()
{
diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressRepositoryTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressRepositoryTest.php
index f2ccc50dc68..070e5e59e3f 100644
--- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressRepositoryTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressRepositoryTest.php
@@ -275,13 +275,13 @@ public function testSaveWithInvalidRegion()
/**
* @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage regionId is a required field.
+ * @expectedExceptionMessage "regionId" is required. Enter and try again.
*/
public function testSaveWithInvalidRegionId()
{
$customerId = 34;
$addressId = 53;
- $errors[] = __('regionId is a required field.');
+ $errors[] = __('"regionId" is required. Enter and try again.');
$customerAddress = $this->getMockForAbstractClass(
\Magento\Customer\Api\Data\AddressInterface::class,
[],
diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Group/Grid/ServiceCollectionTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Group/Grid/ServiceCollectionTest.php
index 61081e1aaf2..524ae9065f6 100644
--- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Group/Grid/ServiceCollectionTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Group/Grid/ServiceCollectionTest.php
@@ -219,7 +219,7 @@ public function testGetSearchCriteriaAnd()
* @param array $conditions
*
* @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage When passing in a field array there must be a matching condition array
+ * @expectedExceptionMessage The field array failed to pass. The array must have a matching condition array.
* @dataProvider addFieldToFilterInconsistentArraysDataProvider
*/
public function testAddFieldToFilterInconsistentArrays($fields, $conditions)
@@ -243,7 +243,7 @@ public function addFieldToFilterInconsistentArraysDataProvider()
/**
* @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage When passing an array of fields there must be at least one field in the array.
+ * @expectedExceptionMessage The array of fields failed to pass. The array must include at one field.
* @dataProvider addFieldToFilterInconsistentArraysDataProvider
*/
public function testAddFieldToFilterEmptyArrays()
diff --git a/app/code/Magento/Customer/etc/db_schema.xml b/app/code/Magento/Customer/etc/db_schema.xml
index 490211e4307..368ca417432 100644
--- a/app/code/Magento/Customer/etc/db_schema.xml
+++ b/app/code/Magento/Customer/etc/db_schema.xml
@@ -6,7 +6,7 @@
*/
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
diff --git a/app/code/Magento/Customer/etc/events.xml b/app/code/Magento/Customer/etc/events.xml
index 66c9a381389..d841d8faa9c 100644
--- a/app/code/Magento/Customer/etc/events.xml
+++ b/app/code/Magento/Customer/etc/events.xml
@@ -10,7 +10,7 @@
-
+
diff --git a/app/code/Magento/Customer/etc/module.xml b/app/code/Magento/Customer/etc/module.xml
index 2dfe561d0da..853157fed1f 100644
--- a/app/code/Magento/Customer/etc/module.xml
+++ b/app/code/Magento/Customer/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js b/app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js
index 71ca63f6750..be2e0aedfe4 100644
--- a/app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js
+++ b/app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js
@@ -31,6 +31,8 @@ define([
this.options.cache.label = $(this.options.passwordStrengthMeterLabelSelector, this.element);
// We need to look outside the module for backward compatibility, since someone can already use the module.
+ // @todo Narrow this selector in 2.3 so it doesn't accidentally finds the the email field from the
+ // newsletter email field or any other "email" field.
this.options.cache.email = $(this.options.formSelector).find(this.options.emailSelector);
this._bind();
},
@@ -74,7 +76,9 @@ define([
'password-not-equal-to-user-name': this.options.cache.email.val()
});
- if (password.toLowerCase() === this.options.cache.email.val().toLowerCase()) {
+ // We should only perform this check in case there is an email field on screen
+ if (this.options.cache.email.length &&
+ password.toLowerCase() === this.options.cache.email.val().toLowerCase()) {
displayScore = 1;
} else {
isValid = $.validator.validateSingleElement(this.options.cache.input);
diff --git a/app/code/Magento/CustomerAnalytics/etc/module.xml b/app/code/Magento/CustomerAnalytics/etc/module.xml
index adc4f8dd849..a6a3380b346 100644
--- a/app/code/Magento/CustomerAnalytics/etc/module.xml
+++ b/app/code/Magento/CustomerAnalytics/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/CustomerGraphQl/etc/module.xml b/app/code/Magento/CustomerGraphQl/etc/module.xml
index 88f08623c71..c3149965b0f 100644
--- a/app/code/Magento/CustomerGraphQl/etc/module.xml
+++ b/app/code/Magento/CustomerGraphQl/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/CustomerImportExport/Model/Import/AbstractCustomer.php b/app/code/Magento/CustomerImportExport/Model/Import/AbstractCustomer.php
index 1d78c4e5bc2..cc6eebed57b 100644
--- a/app/code/Magento/CustomerImportExport/Model/Import/AbstractCustomer.php
+++ b/app/code/Magento/CustomerImportExport/Model/Import/AbstractCustomer.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\CustomerImportExport\Model\Import;
use Magento\ImportExport\Model\Import;
@@ -122,7 +123,10 @@ public function __construct(
);
$this->addMessageTemplate(self::ERROR_WEBSITE_IS_EMPTY, __('Please specify a website.'));
- $this->addMessageTemplate(self::ERROR_EMAIL_IS_EMPTY, __('Please specify an email.'));
+ $this->addMessageTemplate(
+ self::ERROR_EMAIL_IS_EMPTY,
+ __("An email wasn't specified. Enter the email and try again.")
+ );
$this->addMessageTemplate(self::ERROR_INVALID_WEBSITE, __('We found an invalid value in a website column.'));
$this->addMessageTemplate(self::ERROR_INVALID_EMAIL, __('Please enter a valid email.'));
$this->addMessageTemplate(self::ERROR_VALUE_IS_REQUIRED, __('Please make sure attribute "%s" is not empty.'));
diff --git a/app/code/Magento/CustomerImportExport/etc/module.xml b/app/code/Magento/CustomerImportExport/etc/module.xml
index 865b2e99141..2b351d06a5f 100644
--- a/app/code/Magento/CustomerImportExport/etc/module.xml
+++ b/app/code/Magento/CustomerImportExport/etc/module.xml
@@ -6,6 +6,6 @@
*/
-->
-
+
diff --git a/app/code/Magento/Deploy/Console/Command/App/SensitiveConfigSet/CollectorFactory.php b/app/code/Magento/Deploy/Console/Command/App/SensitiveConfigSet/CollectorFactory.php
index f7c38f7c6f6..c66388ed470 100644
--- a/app/code/Magento/Deploy/Console/Command/App/SensitiveConfigSet/CollectorFactory.php
+++ b/app/code/Magento/Deploy/Console/Command/App/SensitiveConfigSet/CollectorFactory.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Deploy\Console\Command\App\SensitiveConfigSet;
use Magento\Framework\Exception\LocalizedException;
@@ -64,7 +65,9 @@ public function __construct(
public function create($type)
{
if (!isset($this->types[$type])) {
- throw new LocalizedException(__('Class for type "%1" was not declared', $type));
+ throw new LocalizedException(
+ __('The class for "%1" type wasn\'t declared. Enter the class and try again.', $type)
+ );
}
$object = $this->objectManager->create($this->types[$type]);
diff --git a/app/code/Magento/Deploy/Console/Command/App/SensitiveConfigSet/SimpleCollector.php b/app/code/Magento/Deploy/Console/Command/App/SensitiveConfigSet/SimpleCollector.php
index 0dd59307941..53cd6166040 100644
--- a/app/code/Magento/Deploy/Console/Command/App/SensitiveConfigSet/SimpleCollector.php
+++ b/app/code/Magento/Deploy/Console/Command/App/SensitiveConfigSet/SimpleCollector.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Deploy\Console\Command\App\SensitiveConfigSet;
use Magento\Deploy\Console\Command\App\SensitiveConfigSetCommand;
@@ -103,7 +104,7 @@ private function getConfigValueQuestion()
]);
$configValueQuestion->setValidator(function ($interviewer) {
if (empty($interviewer)) {
- throw new LocalizedException(new Phrase('Value can\'t be empty'));
+ throw new LocalizedException(new Phrase("The value can't be empty. Enter the value and try again."));
}
return $interviewer;
});
diff --git a/app/code/Magento/Deploy/Console/Command/SetModeCommand.php b/app/code/Magento/Deploy/Console/Command/SetModeCommand.php
index 55b4a4f4f9b..2e223f5a0dc 100644
--- a/app/code/Magento/Deploy/Console/Command/SetModeCommand.php
+++ b/app/code/Magento/Deploy/Console/Command/SetModeCommand.php
@@ -105,7 +105,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$modeController->enableDefaultMode();
break;
default:
- throw new LocalizedException(__('Cannot switch into given mode "%1"', $toMode));
+ throw new LocalizedException(__('The mode can\'t be switched to "%1".', $toMode));
}
$output->writeln('Enabled ' . $toMode . ' mode.');
diff --git a/app/code/Magento/Deploy/Model/DeploymentConfig/Hash.php b/app/code/Magento/Deploy/Model/DeploymentConfig/Hash.php
index 780d36ddb27..17f418d9457 100644
--- a/app/code/Magento/Deploy/Model/DeploymentConfig/Hash.php
+++ b/app/code/Magento/Deploy/Model/DeploymentConfig/Hash.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Deploy\Model\DeploymentConfig;
use Magento\Framework\Exception\LocalizedException;
@@ -97,7 +98,7 @@ public function regenerate($sectionName = null)
$flag->setFlagData($hashes);
$this->flagResource->save($flag);
} catch (\Exception $exception) {
- throw new LocalizedException(__('Hash has not been saved.'), $exception);
+ throw new LocalizedException(__("The hash isn't saved."), $exception);
}
}
diff --git a/app/code/Magento/Deploy/Model/DeploymentConfig/ImporterPool.php b/app/code/Magento/Deploy/Model/DeploymentConfig/ImporterPool.php
index 9a987c704de..a4a9ef00c4a 100644
--- a/app/code/Magento/Deploy/Model/DeploymentConfig/ImporterPool.php
+++ b/app/code/Magento/Deploy/Model/DeploymentConfig/ImporterPool.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Deploy\Model\DeploymentConfig;
use Magento\Framework\App\DeploymentConfig\ValidatorInterface;
@@ -148,7 +149,9 @@ public function getImporters()
foreach ($this->sort($this->importers) as $section => $importer) {
if (empty($importer['importer_class'])) {
- throw new ConfigurationMismatchException(__('Parameter "importer_class" must be present.'));
+ throw new ConfigurationMismatchException(
+ __('The parameter "importer_class" is missing. Set the "importer_class" and try again.')
+ );
}
$sortedImporters[$section] = $importer['importer_class'];
diff --git a/app/code/Magento/Deploy/Model/Mode.php b/app/code/Magento/Deploy/Model/Mode.php
index c7ee9b68496..d4ae72d63bc 100644
--- a/app/code/Magento/Deploy/Model/Mode.php
+++ b/app/code/Magento/Deploy/Model/Mode.php
@@ -236,7 +236,7 @@ private function saveAppConfigs($mode)
$configs = $this->configProvider->getConfigs($this->getMode(), $mode);
foreach ($configs as $path => $item) {
$this->emulatedAreaProcessor->process(function () use ($path, $item) {
- $this->processorFacadeFactory->create()->process(
+ $this->processorFacadeFactory->create()->processWithLockTarget(
$path,
$item['value'],
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
diff --git a/app/code/Magento/Deploy/Model/Plugin/ConfigChangeDetector.php b/app/code/Magento/Deploy/Model/Plugin/ConfigChangeDetector.php
index 6ebc208ca6a..0642593ac55 100644
--- a/app/code/Magento/Deploy/Model/Plugin/ConfigChangeDetector.php
+++ b/app/code/Magento/Deploy/Model/Plugin/ConfigChangeDetector.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Deploy\Model\Plugin;
use Magento\Deploy\Model\DeploymentConfig\ChangeDetector;
@@ -49,7 +50,7 @@ public function beforeDispatch(FrontControllerInterface $subject, RequestInterfa
throw new LocalizedException(
__(
'The configuration file has changed.'
- . ' Run app:config:import or setup:upgrade command to synchronize configuration.'
+ . ' Run the "app:config:import" or the "setup:upgrade" command to synchronize the configuration.'
)
);
}
diff --git a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/CollectorFactoryTest.php b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/CollectorFactoryTest.php
index 155acd4c785..6ac84b1c834 100644
--- a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/CollectorFactoryTest.php
+++ b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/CollectorFactoryTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Deploy\Test\Unit\Console\Command\App\SensitiveConfigSet;
use Magento\Deploy\Console\Command\App\SensitiveConfigSet\CollectorFactory;
@@ -60,7 +61,7 @@ public function testCreate()
/**
* @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage Class for type "dummyType" was not declared
+ * @expectedExceptionMessage The class for "dummyType" type wasn't declared. Enter the class and try again.
*/
public function testCreateNonExisted()
{
diff --git a/app/code/Magento/Deploy/Test/Unit/Console/Command/SetModeCommandTest.php b/app/code/Magento/Deploy/Test/Unit/Console/Command/SetModeCommandTest.php
index 33ffbf20c5b..588dd40ad6c 100644
--- a/app/code/Magento/Deploy/Test/Unit/Console/Command/SetModeCommandTest.php
+++ b/app/code/Magento/Deploy/Test/Unit/Console/Command/SetModeCommandTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Deploy\Test\Unit\Console\Command;
use Magento\Deploy\Console\Command\SetModeCommand;
@@ -95,7 +96,7 @@ public function testSetInvalidMode()
$tester = new CommandTester($this->command);
$tester->execute(['mode' => 'invalid-mode']);
$this->assertContains(
- "Cannot switch into given mode",
+ 'The mode can\'t be switched to "invalid-mode".',
$tester->getDisplay()
);
}
diff --git a/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/HashTest.php b/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/HashTest.php
index 4afe9aa267d..a67f32eb364 100644
--- a/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/HashTest.php
+++ b/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/HashTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Deploy\Test\Unit\Model\DeploymentConfig;
use Magento\Deploy\Model\DeploymentConfig\DataCollector;
@@ -137,7 +138,7 @@ public function testRegenerate()
/**
* @return void
* @expectedException \Magento\Framework\Exception\LocalizedException
- * @expectedExceptionMessage Hash has not been saved
+ * @expectedExceptionMessage The hash isn't saved.
*/
public function testRegenerateWithException()
{
diff --git a/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ImporterPoolTest.php b/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ImporterPoolTest.php
index 73d90b4795d..36c5dd9e734 100644
--- a/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ImporterPoolTest.php
+++ b/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ImporterPoolTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Deploy\Test\Unit\Model\DeploymentConfig;
use Magento\Deploy\Model\DeploymentConfig\ImporterPool;
@@ -68,7 +69,7 @@ public function testGetImporters()
/**
* @return void
* @expectedException \Magento\Framework\Exception\ConfigurationMismatchException
- * @expectedExceptionMessage Parameter "importer_class" must be present.
+ * @expectedExceptionMessage The parameter "importer_class" is missing. Set the "importer_class" and try again.
*/
public function testGetImportersEmptyParameterClass()
{
diff --git a/app/code/Magento/Deploy/Test/Unit/Model/ModeTest.php b/app/code/Magento/Deploy/Test/Unit/Model/ModeTest.php
index 25625eaa5e2..50725a33820 100644
--- a/app/code/Magento/Deploy/Test/Unit/Model/ModeTest.php
+++ b/app/code/Magento/Deploy/Test/Unit/Model/ModeTest.php
@@ -241,7 +241,7 @@ public function testEnableProductionModeMinimal()
->willReturn($this->processorFacade);
$this->processorFacade
->expects($this->once())
- ->method('process')
+ ->method('processWithLockTarget')
->with(
'dev/debug/debug_logging',
0,
diff --git a/app/code/Magento/Deploy/Test/Unit/Model/Plugin/ConfigChangeDetectorTest.php b/app/code/Magento/Deploy/Test/Unit/Model/Plugin/ConfigChangeDetectorTest.php
index 62cb1bab3b3..a3b6cf241b7 100644
--- a/app/code/Magento/Deploy/Test/Unit/Model/Plugin/ConfigChangeDetectorTest.php
+++ b/app/code/Magento/Deploy/Test/Unit/Model/Plugin/ConfigChangeDetectorTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Deploy\Test\Unit\Model\Plugin;
use Magento\Deploy\Model\Plugin\ConfigChangeDetector;
@@ -63,7 +64,7 @@ public function testBeforeDispatchWithoutException()
* @return void
* @expectedException \Magento\Framework\Exception\LocalizedException
* @codingStandardsIgnoreStart
- * @expectedExceptionMessage The configuration file has changed. Run app:config:import or setup:upgrade command to synchronize configuration.
+ * @expectedExceptionMessage The configuration file has changed. Run the "app:config:import" or the "setup:upgrade" command to synchronize the configuration.
* @codingStandardsIgnoreEnd
*/
public function testBeforeDispatchWithException()
diff --git a/app/code/Magento/Deploy/etc/module.xml b/app/code/Magento/Deploy/etc/module.xml
index a61f9e1546e..d4785cd7a31 100644
--- a/app/code/Magento/Deploy/etc/module.xml
+++ b/app/code/Magento/Deploy/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/Developer/Console/Command/GeneratePatchCommand.php b/app/code/Magento/Developer/Console/Command/GeneratePatchCommand.php
new file mode 100644
index 00000000000..7a7deba98ea
--- /dev/null
+++ b/app/code/Magento/Developer/Console/Command/GeneratePatchCommand.php
@@ -0,0 +1,124 @@
+componentRegistrar = $componentRegistrar;
+ parent::__construct();
+ }
+
+ /**
+ * {@inheritdoc}
+ * @throws InvalidArgumentException
+ */
+ protected function configure()
+ {
+ $this->setName(self::COMMAND_NAME)
+ ->setDescription('Generate patch and put it in specific folder.')
+ ->setDefinition([
+ new InputArgument(
+ self::MODULE_NAME,
+ InputArgument::REQUIRED,
+ 'Module name'
+ ),
+ new InputArgument(
+ self::INPUT_KEY_PATCH_NAME,
+ InputArgument::REQUIRED,
+ 'Patch name'
+ ),
+ new InputOption(
+ self::INPUT_KEY_IS_REVERTABLE,
+ null,
+ InputOption::VALUE_OPTIONAL,
+ 'Check whether patch is revertable or not.',
+ false
+ ),
+ new InputOption(
+ self::INPUT_KEY_PATCH_TYPE,
+ null,
+ InputOption::VALUE_OPTIONAL,
+ 'Find out what type of patch should be generated.',
+ 'data'
+ ),
+ ]);
+
+ parent::configure();
+ }
+
+ /**
+ * Patch template
+ *
+ * @return string
+ */
+ private function getPatchTemplate()
+ {
+ return file_get_contents(__DIR__ . '/patch_template.php.dist');
+ }
+
+ /**
+ * {@inheritdoc}
+ * @throws \InvalidArgumentException
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $moduleName = $input->getArgument(self::MODULE_NAME);
+ $patchName = $input->getArgument(self::INPUT_KEY_PATCH_NAME);
+ $type = $input->getOption(self::INPUT_KEY_PATCH_TYPE);
+ $modulePath = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName);
+ $preparedModuleName = str_replace('_', '\\', $moduleName);
+ $preparedType = ucfirst($type);
+ $patchInterface = sprintf('%sPatchInterface', $preparedType);
+ $patchTemplateData = $this->getPatchTemplate();
+ $patchTemplateData = str_replace('%moduleName%', $preparedModuleName, $patchTemplateData);
+ $patchTemplateData = str_replace('%patchType%', $preparedType, $patchTemplateData);
+ $patchTemplateData = str_replace('%patchInterface%', $patchInterface, $patchTemplateData);
+ $patchTemplateData = str_replace('%class%', $patchName, $patchTemplateData);
+ $patchDir = $patchToFile = $modulePath . '/Setup/Patch/' . $preparedType;
+
+ if (!is_dir($patchDir)) {
+ mkdir($patchDir, 0777, true);
+ }
+ $patchToFile = $patchDir . '/' . $patchName . '.php';
+ file_put_contents($patchToFile, $patchTemplateData);
+ return Cli::RETURN_SUCCESS;
+ }
+}
diff --git a/app/code/Magento/Developer/Console/Command/TablesWhitelistGenerateCommand.php b/app/code/Magento/Developer/Console/Command/TablesWhitelistGenerateCommand.php
index 3313b7ef68a..6715ecd681e 100644
--- a/app/code/Magento/Developer/Console/Command/TablesWhitelistGenerateCommand.php
+++ b/app/code/Magento/Developer/Console/Command/TablesWhitelistGenerateCommand.php
@@ -8,8 +8,9 @@
use Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\Config\FileResolverByModule;
use Magento\Framework\Module\Dir;
+use Magento\Framework\Setup\Declaration\Schema\Diff\Diff;
use Magento\Framework\Setup\JsonPersistor;
-use Magento\Setup\Model\Declaration\Schema\Declaration\ReaderComposite;
+use Magento\Framework\Setup\Declaration\Schema\Declaration\ReaderComposite;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -103,7 +104,7 @@ private function persistModule($moduleName)
. DIRECTORY_SEPARATOR
. Dir::MODULE_ETC_DIR
. DIRECTORY_SEPARATOR
- . self::GENERATED_FILE_NAME;
+ . Diff::GENERATED_WHITELIST_FILE_NAME;
//We need to load whitelist file and update it with new revision of code.
if (file_exists($whiteListFileName)) {
$content = json_decode(file_get_contents($whiteListFileName), true);
diff --git a/app/code/Magento/Developer/Console/Command/patch_template.php.dist b/app/code/Magento/Developer/Console/Command/patch_template.php.dist
new file mode 100644
index 00000000000..c1b07246e64
--- /dev/null
+++ b/app/code/Magento/Developer/Console/Command/patch_template.php.dist
@@ -0,0 +1,59 @@
+moduleDataSetup = $moduleDataSetup;
+ }
+
+ /**
+ * Do Upgrade
+ *
+ * @return void
+ */
+ public function apply()
+ {
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+
+ ];
+ }
+}
diff --git a/app/code/Magento/Developer/Test/Unit/Console/Command/TablesWhitelistGenerateCommandTest.php b/app/code/Magento/Developer/Test/Unit/Console/Command/TablesWhitelistGenerateCommandTest.php
index 49235e19cc0..66fd7e3eec6 100644
--- a/app/code/Magento/Developer/Test/Unit/Console/Command/TablesWhitelistGenerateCommandTest.php
+++ b/app/code/Magento/Developer/Test/Unit/Console/Command/TablesWhitelistGenerateCommandTest.php
@@ -10,7 +10,7 @@
use Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\Setup\JsonPersistor;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
-use Magento\Setup\Model\Declaration\Schema\Declaration\ReaderComposite;
+use Magento\Framework\Setup\Declaration\Schema\Declaration\ReaderComposite;
use Symfony\Component\Console\Tester\CommandTester;
/**
diff --git a/app/code/Magento/Developer/Test/Unit/Console/Command/_files/test.xml b/app/code/Magento/Developer/Test/Unit/Console/Command/_files/test.xml
index ce31b046500..8112b9e8c46 100644
--- a/app/code/Magento/Developer/Test/Unit/Console/Command/_files/test.xml
+++ b/app/code/Magento/Developer/Test/Unit/Console/Command/_files/test.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/Developer/etc/di.xml b/app/code/Magento/Developer/etc/di.xml
index f68d01b8339..2254c94a8a9 100644
--- a/app/code/Magento/Developer/etc/di.xml
+++ b/app/code/Magento/Developer/etc/di.xml
@@ -105,6 +105,7 @@
- Magento\Developer\Console\Command\TemplateHintsEnableCommand
- Magento\Developer\Console\Command\ProfilerDisableCommand
- Magento\Developer\Console\Command\ProfilerEnableCommand
+ - Magento\Developer\Console\Command\GeneratePatchCommand
diff --git a/app/code/Magento/Developer/etc/module.xml b/app/code/Magento/Developer/etc/module.xml
index 96a8828b00c..e3cf8132e3e 100644
--- a/app/code/Magento/Developer/etc/module.xml
+++ b/app/code/Magento/Developer/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/Dhl/Model/Validator/XmlValidator.php b/app/code/Magento/Dhl/Model/Validator/XmlValidator.php
index a489832b47b..762dcbe5939 100644
--- a/app/code/Magento/Dhl/Model/Validator/XmlValidator.php
+++ b/app/code/Magento/Dhl/Model/Validator/XmlValidator.php
@@ -49,7 +49,7 @@ public function validate($xmlResponse, $isShippingLabel = false)
{
if (strlen(trim($xmlResponse)) > 0 && strpos(trim($xmlResponse), 'xmlSecurity->scan($xmlResponse)) {
- throw new DocumentValidationException(__('Security validation of XML document has been failed.'));
+ throw new DocumentValidationException(__('The security validation of the XML document has failed.'));
}
$xml = simplexml_load_string($xmlResponse, \Magento\Shipping\Model\Simplexml\Element::class);
diff --git a/app/code/Magento/Dhl/Setup/InstallData.php b/app/code/Magento/Dhl/Setup/InstallData.php
deleted file mode 100644
index 48f359aa636..00000000000
--- a/app/code/Magento/Dhl/Setup/InstallData.php
+++ /dev/null
@@ -1,68 +0,0 @@
-localeResolver = $localeResolver;
- }
-
- /**
- * {@inheritdoc}
- */
- public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
- {
- $days = (new DataBundle())->get(
- $this->localeResolver->getLocale()
- )['calendar']['gregorian']['dayNames']['format']['abbreviated'];
-
- $select = $setup->getConnection()->select()->from(
- $setup->getTable('core_config_data'),
- ['config_id', 'value']
- )->where(
- 'path = ?',
- 'carriers/dhl/shipment_days'
- );
-
- foreach ($setup->getConnection()->fetchAll($select) as $configRow) {
- $row = [
- 'value' => implode(
- ',',
- array_intersect_key(iterator_to_array($days), array_flip(explode(',', $configRow['value'])))
- )
- ];
- $setup->getConnection()->update(
- $setup->getTable('core_config_data'),
- $row,
- ['config_id = ?' => $configRow['config_id']]
- );
- }
- }
-}
diff --git a/app/code/Magento/Dhl/Setup/Patch/Data/PrepareShipmentDays.php b/app/code/Magento/Dhl/Setup/Patch/Data/PrepareShipmentDays.php
new file mode 100644
index 00000000000..8b91b842c36
--- /dev/null
+++ b/app/code/Magento/Dhl/Setup/Patch/Data/PrepareShipmentDays.php
@@ -0,0 +1,99 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->localeResolver = $localeResolver;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ $days = (new DataBundle())->get(
+ $this->localeResolver->getLocale()
+ )['calendar']['gregorian']['dayNames']['format']['abbreviated'];
+
+ $select = $this->moduleDataSetup->getConnection()->select()->from(
+ $this->moduleDataSetup->getTable('core_config_data'),
+ ['config_id', 'value']
+ )->where(
+ 'path = ?',
+ 'carriers/dhl/shipment_days'
+ );
+ foreach ($this->moduleDataSetup->getConnection()->fetchAll($select) as $configRow) {
+ $row = [
+ 'value' => implode(
+ ',',
+ array_intersect_key(iterator_to_array($days), array_flip(explode(',', $configRow['value'])))
+ )
+ ];
+ $this->moduleDataSetup->getConnection()->update(
+ $this->moduleDataSetup->getTable('core_config_data'),
+ $row,
+ ['config_id = ?' => $configRow['config_id']]
+ );
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.0';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/Dhl/Test/Unit/Model/Validator/XmlValidatorTest.php b/app/code/Magento/Dhl/Test/Unit/Model/Validator/XmlValidatorTest.php
index 3d7893fea11..26d87942238 100644
--- a/app/code/Magento/Dhl/Test/Unit/Model/Validator/XmlValidatorTest.php
+++ b/app/code/Magento/Dhl/Test/Unit/Model/Validator/XmlValidatorTest.php
@@ -123,7 +123,7 @@ public function invalidXmlResponseProvider()
[
[
'file' => 'invalidDHLResponse.xml',
- 'errorMessage' => 'Security validation of XML document has been failed.',
+ 'errorMessage' => 'The security validation of the XML document has failed.',
'isGenerateXml' => false,
],
],
diff --git a/app/code/Magento/Dhl/etc/module.xml b/app/code/Magento/Dhl/etc/module.xml
index 4723b14763a..b1af1baf97f 100644
--- a/app/code/Magento/Dhl/etc/module.xml
+++ b/app/code/Magento/Dhl/etc/module.xml
@@ -6,6 +6,6 @@
*/
-->
-
+
diff --git a/app/code/Magento/Directory/Model/CountryInformationAcquirer.php b/app/code/Magento/Directory/Model/CountryInformationAcquirer.php
index 4eaa18d9672..69c8f21f5a2 100644
--- a/app/code/Magento/Directory/Model/CountryInformationAcquirer.php
+++ b/app/code/Magento/Directory/Model/CountryInformationAcquirer.php
@@ -103,7 +103,7 @@ public function getCountryInfo($countryId)
if (!$country) {
throw new NoSuchEntityException(
__(
- 'Requested country is not available.'
+ "The country isn't available."
)
);
}
diff --git a/app/code/Magento/Directory/Model/Observer.php b/app/code/Magento/Directory/Model/Observer.php
index 8ad67ad1910..e35c2de5cee 100644
--- a/app/code/Magento/Directory/Model/Observer.php
+++ b/app/code/Magento/Directory/Model/Observer.php
@@ -9,6 +9,7 @@
*
* @author Magento Core Team
*/
+
namespace Magento\Directory\Model;
class Observer
@@ -113,7 +114,8 @@ public function scheduledUpdateCurrencyRates($schedule)
$rates = $importModel->fetchRates();
$errors = $importModel->getMessages();
} catch (\Exception $e) {
- $importWarnings[] = __('FATAL ERROR:') . ' ' . __('We can\'t initialize the import model.');
+ $importWarnings[] = __('FATAL ERROR:') . ' '
+ . __("The import model can't be initialized. Verify the model and try again.");
throw $e;
}
} else {
diff --git a/app/code/Magento/Directory/Setup/DataInstaller.php b/app/code/Magento/Directory/Setup/DataInstaller.php
new file mode 100644
index 00000000000..9fccc16e1d4
--- /dev/null
+++ b/app/code/Magento/Directory/Setup/DataInstaller.php
@@ -0,0 +1,76 @@
+data = $data;
+ $this->resourceConnection = $resourceConnection;
+ }
+
+ /**
+ * Add country-region data.
+ *
+ * @param AdapterInterface $adapter
+ * @param array $data
+ */
+ public function addCountryRegions(AdapterInterface $adapter, array $data)
+ {
+ /**
+ * Fill table directory/country_region
+ * Fill table directory/country_region_name for en_US locale
+ */
+ foreach ($data as $row) {
+ $bind = ['country_id' => $row[0], 'code' => $row[1], 'default_name' => $row[2]];
+ $adapter->insert($this->resourceConnection->getTableName('directory_country_region'), $bind);
+ $regionId = $adapter->lastInsertId($this->resourceConnection->getTableName('directory_country_region'));
+ $bind = ['locale' => 'en_US', 'region_id' => $regionId, 'name' => $row[2]];
+ $adapter->insert($this->resourceConnection->getTableName('directory_country_region_name'), $bind);
+ }
+ /**
+ * Upgrade core_config_data general/region/state_required field.
+ */
+ $countries = $this->data->getCountryCollection()->getCountriesWithRequiredStates();
+ $adapter->update(
+ $this->resourceConnection->getTableName('core_config_data'),
+ [
+ 'value' => implode(',', array_keys($countries))
+ ],
+ [
+ 'scope="default"',
+ 'scope_id=0',
+ 'path=?' => \Magento\Directory\Helper\Data::XML_PATH_STATES_REQUIRED
+ ]
+ );
+ }
+}
diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForCroatia.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForCroatia.php
new file mode 100644
index 00000000000..eb9d4f4018b
--- /dev/null
+++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForCroatia.php
@@ -0,0 +1,115 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->dataInstallerFactory = $dataInstallerFactory;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ /** @var DataInstaller $dataInstaller */
+ $dataInstaller = $this->dataInstallerFactory->create();
+ $dataInstaller->addCountryRegions(
+ $this->moduleDataSetup->getConnection(),
+ $this->getDataForCroatia()
+ );
+ }
+
+ /**
+ * Croatian states data.
+ *
+ * @return array
+ */
+ private function getDataForCroatia()
+ {
+ return [
+ ['HR', 'HR-01', 'Zagrebačka županija'],
+ ['HR', 'HR-02', 'Krapinsko-zagorska županija'],
+ ['HR', 'HR-03', 'Sisačko-moslavačka županija'],
+ ['HR', 'HR-04', 'Karlovačka županija'],
+ ['HR', 'HR-05', 'Varaždinska županija'],
+ ['HR', 'HR-06', 'Koprivničko-križevačka županija'],
+ ['HR', 'HR-07', 'Bjelovarsko-bilogorska županija'],
+ ['HR', 'HR-08', 'Primorsko-goranska županija'],
+ ['HR', 'HR-09', 'Ličko-senjska županija'],
+ ['HR', 'HR-10', 'Virovitičko-podravska županija'],
+ ['HR', 'HR-11', 'Požeško-slavonska županija'],
+ ['HR', 'HR-12', 'Brodsko-posavska županija'],
+ ['HR', 'HR-13', 'Zadarska županija'],
+ ['HR', 'HR-14', 'Osječko-baranjska županija'],
+ ['HR', 'HR-15', 'Šibensko-kninska županija'],
+ ['HR', 'HR-16', 'Vukovarsko-srijemska županija'],
+ ['HR', 'HR-17', 'Splitsko-dalmatinska županija'],
+ ['HR', 'HR-18', 'Istarska županija'],
+ ['HR', 'HR-19', 'Dubrovačko-neretvanska županija'],
+ ['HR', 'HR-20', 'Međimurska županija'],
+ ['HR', 'HR-21', 'Grad Zagreb']
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+ InitializeDirectoryData::class,
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.1';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForIndia.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForIndia.php
new file mode 100644
index 00000000000..69d500960d3
--- /dev/null
+++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForIndia.php
@@ -0,0 +1,130 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->dataInstallerFactory = $dataInstallerFactory;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ /** @var DataInstaller $dataInstaller */
+ $dataInstaller = $this->dataInstallerFactory->create();
+ $dataInstaller->addCountryRegions(
+ $this->moduleDataSetup->getConnection(),
+ $this->getDataForIndia()
+ );
+ }
+
+ /**
+ * Indian states data.
+ *
+ * @return array
+ */
+ private function getDataForIndia()
+ {
+ return [
+ ['IN', 'AN', 'Andaman and Nicobar Islands'],
+ ['IN', 'AP', 'Andhra Pradesh'],
+ ['IN', 'AR', 'Arunachal Pradesh'],
+ ['IN', 'AS', 'Assam'],
+ ['IN', 'BR', 'Bihar'],
+ ['IN', 'CH', 'Chandigarh'],
+ ['IN', 'CT', 'Chhattisgarh'],
+ ['IN', 'DN', 'Dadra and Nagar Haveli'],
+ ['IN', 'DD', 'Daman and Diu'],
+ ['IN', 'DL', 'Delhi'],
+ ['IN', 'GA', 'Goa'],
+ ['IN', 'GJ', 'Gujarat'],
+ ['IN', 'HR', 'Haryana'],
+ ['IN', 'HP', 'Himachal Pradesh'],
+ ['IN', 'JK', 'Jammu and Kashmir'],
+ ['IN', 'JH', 'Jharkhand'],
+ ['IN', 'KA', 'Karnataka'],
+ ['IN', 'KL', 'Kerala'],
+ ['IN', 'LD', 'Lakshadweep'],
+ ['IN', 'MP', 'Madhya Pradesh'],
+ ['IN', 'MH', 'Maharashtra'],
+ ['IN', 'MN', 'Manipur'],
+ ['IN', 'ML', 'Meghalaya'],
+ ['IN', 'MZ', 'Mizoram'],
+ ['IN', 'NL', 'Nagaland'],
+ ['IN', 'OR', 'Odisha'],
+ ['IN', 'PY', 'Puducherry'],
+ ['IN', 'PB', 'Punjab'],
+ ['IN', 'RJ', 'Rajasthan'],
+ ['IN', 'SK', 'Sikkim'],
+ ['IN', 'TN', 'Tamil Nadu'],
+ ['IN', 'TG', 'Telangana'],
+ ['IN', 'TR', 'Tripura'],
+ ['IN', 'UP', 'Uttar Pradesh'],
+ ['IN', 'UT', 'Uttarakhand'],
+ ['IN', 'WB', 'West Bengal']
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+ InitializeDirectoryData::class,
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.2';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/Directory/Setup/InstallData.php b/app/code/Magento/Directory/Setup/Patch/Data/InitializeDirectoryData.php
similarity index 92%
rename from app/code/Magento/Directory/Setup/InstallData.php
rename to app/code/Magento/Directory/Setup/Patch/Data/InitializeDirectoryData.php
index 33c3ae4558e..79ac53d3a44 100644
--- a/app/code/Magento/Directory/Setup/InstallData.php
+++ b/app/code/Magento/Directory/Setup/Patch/Data/InitializeDirectoryData.php
@@ -4,40 +4,47 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Directory\Setup;
+namespace Magento\Directory\Setup\Patch\Data;
use Magento\Directory\Helper\Data;
-use Magento\Framework\Setup\InstallDataInterface;
-use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
+use Magento\Framework\Setup\Patch\DataPatchInterface;
+use Magento\Framework\Setup\Patch\PatchVersionInterface;
/**
- * @codeCoverageIgnore
+ * Class InitializeDirectoryData
+ * @package Magento\Directory\Setup\Patch
*/
-class InstallData implements InstallDataInterface
+class InitializeDirectoryData implements DataPatchInterface, PatchVersionInterface
{
/**
- * Directory data
- *
- * @var Data
+ * @var ModuleDataSetupInterface
*/
- private $directoryData;
+ private $moduleDataSetup;
/**
- * Init
- *
- * @param Data $directoryData
+ * @var \Magento\Directory\Helper\DataFactory
*/
- public function __construct(Data $directoryData)
- {
- $this->directoryData = $directoryData;
+ private $directoryDataFactory;
+
+ /**
+ * InitializeDirectoryData constructor.
+ * @param ModuleDataSetupInterface $moduleDataSetup
+ * @param \Magento\Directory\Helper\DataFactory $directoryDataFactory
+ */
+ public function __construct(
+ ModuleDataSetupInterface $moduleDataSetup,
+ \Magento\Directory\Helper\DataFactory $directoryDataFactory
+ ) {
+ $this->moduleDataSetup = $moduleDataSetup;
+ $this->directoryDataFactory = $directoryDataFactory;
}
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
+ public function apply()
{
/**
* Fill table directory/country
@@ -291,8 +298,11 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
];
$columns = ['country_id', 'iso2_code', 'iso3_code'];
- $setup->getConnection()->insertArray($setup->getTable('directory_country'), $columns, $data);
-
+ $this->moduleDataSetup->getConnection()->insertArray(
+ $this->moduleDataSetup->getTable('directory_country'),
+ $columns,
+ $data
+ );
/**
* Fill table directory/country_region
* Fill table directory/country_region_name for en_US locale
@@ -810,16 +820,21 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
['BR', 'TO', 'Tocantins'],
['BR', 'DF', 'Distrito Federal'],
];
-
foreach ($data as $row) {
$bind = ['country_id' => $row[0], 'code' => $row[1], 'default_name' => $row[2]];
- $setup->getConnection()->insert($setup->getTable('directory_country_region'), $bind);
- $regionId = $setup->getConnection()->lastInsertId($setup->getTable('directory_country_region'));
-
+ $this->moduleDataSetup->getConnection()->insert(
+ $this->moduleDataSetup->getTable('directory_country_region'),
+ $bind
+ );
+ $regionId = $this->moduleDataSetup->getConnection()->lastInsertId(
+ $this->moduleDataSetup->getTable('directory_country_region')
+ );
$bind = ['locale' => 'en_US', 'region_id' => $regionId, 'name' => $row[2]];
- $setup->getConnection()->insert($setup->getTable('directory_country_region_name'), $bind);
+ $this->moduleDataSetup->getConnection()->insert(
+ $this->moduleDataSetup->getTable('directory_country_region_name'),
+ $bind
+ );
}
-
/**
* Fill table directory/currency_rate
*/
@@ -829,12 +844,14 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
['USD', 'EUR', 0.706700000000],
['USD', 'USD', 1],
];
-
$columns = ['currency_from', 'currency_to', 'rate'];
- $setup->getConnection()->insertArray($setup->getTable('directory_currency_rate'), $columns, $data);
-
- $setup->getConnection()->insert(
- $setup->getTable('core_config_data'),
+ $this->moduleDataSetup->getConnection()->insertArray(
+ $this->moduleDataSetup->getTable('directory_currency_rate'),
+ $columns,
+ $data
+ );
+ $this->moduleDataSetup->getConnection()->insert(
+ $this->moduleDataSetup->getTable('core_config_data'),
[
'scope' => 'default',
'scope_id' => 0,
@@ -842,10 +859,11 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
'value' => 1
]
);
-
- $countries = $this->directoryData->getCountryCollection()->getCountriesWithRequiredStates();
- $setup->getConnection()->insert(
- $setup->getTable('core_config_data'),
+ /** @var \Magento\Directory\Helper\Data $helper */
+ $helper = $this->directoryDataFactory->create();
+ $countries = $helper->getCountryCollection()->getCountriesWithRequiredStates();
+ $this->moduleDataSetup->getConnection()->insert(
+ $this->moduleDataSetup->getTable('core_config_data'),
[
'scope' => 'default',
'scope_id' => 0,
@@ -854,4 +872,28 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
]
);
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.0';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
}
diff --git a/app/code/Magento/Directory/Setup/UpgradeData.php b/app/code/Magento/Directory/Setup/UpgradeData.php
deleted file mode 100644
index 4ee9ea33673..00000000000
--- a/app/code/Magento/Directory/Setup/UpgradeData.php
+++ /dev/null
@@ -1,166 +0,0 @@
-directoryData = $directoryData;
- }
-
- /**
- * Upgrades data for Directry module.
- *
- * @param ModuleDataSetupInterface $setup
- * @param ModuleContextInterface $context
- * @return void
- */
- public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
- {
- if (version_compare($context->getVersion(), '2.0.1', '<')) {
- $this->addCountryRegions($setup, $this->getDataForCroatia());
- }
- if (version_compare($context->getVersion(), '2.0.2', '<')) {
- $this->addCountryRegions($setup, $this->getDataForIndia());
- }
- }
-
- /**
- * Croatian states data.
- *
- * @return array
- */
- private function getDataForCroatia()
- {
- return [
- ['HR', 'HR-01', 'Zagrebačka županija'],
- ['HR', 'HR-02', 'Krapinsko-zagorska županija'],
- ['HR', 'HR-03', 'Sisačko-moslavačka županija'],
- ['HR', 'HR-04', 'Karlovačka županija'],
- ['HR', 'HR-05', 'Varaždinska županija'],
- ['HR', 'HR-06', 'Koprivničko-križevačka županija'],
- ['HR', 'HR-07', 'Bjelovarsko-bilogorska županija'],
- ['HR', 'HR-08', 'Primorsko-goranska županija'],
- ['HR', 'HR-09', 'Ličko-senjska županija'],
- ['HR', 'HR-10', 'Virovitičko-podravska županija'],
- ['HR', 'HR-11', 'Požeško-slavonska županija'],
- ['HR', 'HR-12', 'Brodsko-posavska županija'],
- ['HR', 'HR-13', 'Zadarska županija'],
- ['HR', 'HR-14', 'Osječko-baranjska županija'],
- ['HR', 'HR-15', 'Šibensko-kninska županija'],
- ['HR', 'HR-16', 'Vukovarsko-srijemska županija'],
- ['HR', 'HR-17', 'Splitsko-dalmatinska županija'],
- ['HR', 'HR-18', 'Istarska županija'],
- ['HR', 'HR-19', 'Dubrovačko-neretvanska županija'],
- ['HR', 'HR-20', 'Međimurska županija'],
- ['HR', 'HR-21', 'Grad Zagreb']
- ];
- }
-
- /**
- * Indian states data.
- *
- * @return array
- */
- private function getDataForIndia()
- {
- return [
- ['IN', 'AN', 'Andaman and Nicobar Islands'],
- ['IN', 'AP', 'Andhra Pradesh'],
- ['IN', 'AR', 'Arunachal Pradesh'],
- ['IN', 'AS', 'Assam'],
- ['IN', 'BR', 'Bihar'],
- ['IN', 'CH', 'Chandigarh'],
- ['IN', 'CT', 'Chhattisgarh'],
- ['IN', 'DN', 'Dadra and Nagar Haveli'],
- ['IN', 'DD', 'Daman and Diu'],
- ['IN', 'DL', 'Delhi'],
- ['IN', 'GA', 'Goa'],
- ['IN', 'GJ', 'Gujarat'],
- ['IN', 'HR', 'Haryana'],
- ['IN', 'HP', 'Himachal Pradesh'],
- ['IN', 'JK', 'Jammu and Kashmir'],
- ['IN', 'JH', 'Jharkhand'],
- ['IN', 'KA', 'Karnataka'],
- ['IN', 'KL', 'Kerala'],
- ['IN', 'LD', 'Lakshadweep'],
- ['IN', 'MP', 'Madhya Pradesh'],
- ['IN', 'MH', 'Maharashtra'],
- ['IN', 'MN', 'Manipur'],
- ['IN', 'ML', 'Meghalaya'],
- ['IN', 'MZ', 'Mizoram'],
- ['IN', 'NL', 'Nagaland'],
- ['IN', 'OR', 'Odisha'],
- ['IN', 'PY', 'Puducherry'],
- ['IN', 'PB', 'Punjab'],
- ['IN', 'RJ', 'Rajasthan'],
- ['IN', 'SK', 'Sikkim'],
- ['IN', 'TN', 'Tamil Nadu'],
- ['IN', 'TG', 'Telangana'],
- ['IN', 'TR', 'Tripura'],
- ['IN', 'UP', 'Uttar Pradesh'],
- ['IN', 'UT', 'Uttarakhand'],
- ['IN', 'WB', 'West Bengal']
- ];
- }
-
- /**
- * Add country regions data to appropriate tables.
- *
- * @param ModuleDataSetupInterface $setup
- * @param array $data
- * @return void
- */
- private function addCountryRegions(ModuleDataSetupInterface $setup, array $data)
- {
- /**
- * Fill table directory/country_region
- * Fill table directory/country_region_name for en_US locale
- */
- foreach ($data as $row) {
- $bind = ['country_id' => $row[0], 'code' => $row[1], 'default_name' => $row[2]];
- $setup->getConnection()->insert($setup->getTable('directory_country_region'), $bind);
- $regionId = $setup->getConnection()->lastInsertId($setup->getTable('directory_country_region'));
- $bind = ['locale' => 'en_US', 'region_id' => $regionId, 'name' => $row[2]];
- $setup->getConnection()->insert($setup->getTable('directory_country_region_name'), $bind);
- }
- /**
- * Upgrade core_config_data general/region/state_required field.
- */
- $countries = $this->directoryData->getCountryCollection()->getCountriesWithRequiredStates();
- $setup->getConnection()->update(
- $setup->getTable('core_config_data'),
- [
- 'value' => implode(',', array_keys($countries))
- ],
- [
- 'scope="default"',
- 'scope_id=0',
- 'path=?' => Data::XML_PATH_STATES_REQUIRED
- ]
- );
- }
-}
diff --git a/app/code/Magento/Directory/Test/Unit/Model/CountryInformationAcquirerTest.php b/app/code/Magento/Directory/Test/Unit/Model/CountryInformationAcquirerTest.php
index 3f963cb2b82..a3037d64819 100644
--- a/app/code/Magento/Directory/Test/Unit/Model/CountryInformationAcquirerTest.php
+++ b/app/code/Magento/Directory/Test/Unit/Model/CountryInformationAcquirerTest.php
@@ -143,8 +143,8 @@ public function testGetCountryInfo()
/**
* test GetGetCountryInfoNotFound
*
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage Requested country is not available.
+ * @expectedException \Magento\Framework\Exception\NoSuchEntityException
+ * @expectedExceptionMessage The country isn't available.
*/
public function testGetCountryInfoNotFound()
{
diff --git a/app/code/Magento/Directory/etc/db_schema.xml b/app/code/Magento/Directory/etc/db_schema.xml
index 769c253d45f..72fd929b98a 100644
--- a/app/code/Magento/Directory/etc/db_schema.xml
+++ b/app/code/Magento/Directory/etc/db_schema.xml
@@ -6,7 +6,7 @@
*/
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
diff --git a/app/code/Magento/Directory/etc/module.xml b/app/code/Magento/Directory/etc/module.xml
index a3735ca6ddd..3a750db5e7c 100644
--- a/app/code/Magento/Directory/etc/module.xml
+++ b/app/code/Magento/Directory/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/Downloadable/Model/LinkRepository.php b/app/code/Magento/Downloadable/Model/LinkRepository.php
index b84a8284c90..0898f1924e5 100644
--- a/app/code/Magento/Downloadable/Model/LinkRepository.php
+++ b/app/code/Magento/Downloadable/Model/LinkRepository.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Downloadable\Model;
use Magento\Catalog\Api\Data\ProductInterface;
@@ -176,20 +177,22 @@ public function save($sku, LinkInterface $link, $isGlobalScopeContent = true)
return $this->updateLink($product, $link, $isGlobalScopeContent);
} else {
if ($product->getTypeId() !== \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) {
- throw new InputException(__('Provided product must be type \'downloadable\'.'));
+ throw new InputException(
+ __('The product needs to be the downloadable type. Verify the product and try again.')
+ );
}
$validateLinkContent = !($link->getLinkType() === 'file' && $link->getLinkFile());
$validateSampleContent = !($link->getSampleType() === 'file' && $link->getSampleFile());
if (!$this->contentValidator->isValid($link, $validateLinkContent, $validateSampleContent)) {
- throw new InputException(__('Provided link information is invalid.'));
+ throw new InputException(__('The link information is invalid. Verify the link and try again.'));
}
if (!in_array($link->getLinkType(), ['url', 'file'], true)) {
- throw new InputException(__('Invalid link type.'));
+ throw new InputException(__('The link type is invalid. Verify and try again.'));
}
$title = $link->getTitle();
if (empty($title)) {
- throw new InputException(__('Link title cannot be empty.'));
+ throw new InputException(__('The link title is empty. Enter the link title and try again.'));
}
return $this->saveLink($product, $link, $isGlobalScopeContent);
}
@@ -283,18 +286,22 @@ protected function updateLink(
/** @var $existingLink \Magento\Downloadable\Model\Link */
$existingLink = $this->linkFactory->create()->load($link->getId());
if (!$existingLink->getId()) {
- throw new NoSuchEntityException(__('There is no downloadable link with provided ID.'));
+ throw new NoSuchEntityException(
+ __('No downloadable link with the provided ID was found. Verify the ID and try again.')
+ );
}
$linkFieldValue = $product->getData(
$this->getMetadataPool()->getMetadata(ProductInterface::class)->getLinkField()
);
if ($existingLink->getProductId() != $linkFieldValue) {
- throw new InputException(__('Provided downloadable link is not related to given product.'));
+ throw new InputException(
+ __("The downloadable link isn't related to the product. Verify the link and try again.")
+ );
}
$validateLinkContent = !($link->getLinkFileContent() === null);
$validateSampleContent = !($link->getSampleFileContent() === null);
if (!$this->contentValidator->isValid($link, $validateLinkContent, $validateSampleContent)) {
- throw new InputException(__('Provided link information is invalid.'));
+ throw new InputException(__('The link information is invalid. Verify the link and try again.'));
}
if ($isGlobalScopeContent) {
$product->setStoreId(0);
@@ -302,7 +309,7 @@ protected function updateLink(
$title = $link->getTitle();
if (empty($title)) {
if ($isGlobalScopeContent) {
- throw new InputException(__('Link title cannot be empty.'));
+ throw new InputException(__('The link title is empty. Enter the link title and try again.'));
}
}
@@ -325,12 +332,14 @@ public function delete($id)
/** @var $link \Magento\Downloadable\Model\Link */
$link = $this->linkFactory->create()->load($id);
if (!$link->getId()) {
- throw new NoSuchEntityException(__('There is no downloadable link with provided ID.'));
+ throw new NoSuchEntityException(
+ __('No downloadable link with the provided ID was found. Verify the ID and try again.')
+ );
}
try {
$link->delete();
} catch (\Exception $exception) {
- throw new StateException(__('Cannot delete link with id %1', $link->getId()), $exception);
+ throw new StateException(__('The link with "%1" ID can\'t be deleted.', $link->getId()), $exception);
}
return true;
}
diff --git a/app/code/Magento/Downloadable/Model/SampleRepository.php b/app/code/Magento/Downloadable/Model/SampleRepository.php
index 5b9e8e784b9..0c7d2b96f1b 100644
--- a/app/code/Magento/Downloadable/Model/SampleRepository.php
+++ b/app/code/Magento/Downloadable/Model/SampleRepository.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Downloadable\Model;
use Magento\Catalog\Api\Data\ProductInterface;
@@ -183,20 +184,24 @@ public function save(
return $this->updateSample($product, $sample, $isGlobalScopeContent);
} else {
if ($product->getTypeId() !== Type::TYPE_DOWNLOADABLE) {
- throw new InputException(__('Provided product must be type \'downloadable\'.'));
+ throw new InputException(
+ __('The product needs to be the downloadable type. Verify the product and try again.')
+ );
}
$validateSampleContent = !($sample->getSampleType() === 'file' && $sample->getSampleFile());
if (!$this->contentValidator->isValid($sample, $validateSampleContent)) {
- throw new InputException(__('Provided sample information is invalid.'));
+ throw new InputException(
+ __('The sample information is invalid. Verify the information and try again.')
+ );
}
if (!in_array($sample->getSampleType(), ['url', 'file'], true)) {
- throw new InputException(__('Invalid sample type.'));
+ throw new InputException(__('The sample type is invalid. Verify the sample type and try again.'));
}
$title = $sample->getTitle();
if (empty($title)) {
- throw new InputException(__('Sample title cannot be empty.'));
+ throw new InputException(__('The sample title is empty. Enter the title and try again.'));
}
return $this->saveSample($product, $sample, $isGlobalScopeContent);
@@ -271,18 +276,22 @@ protected function updateSample(
$existingSample = $this->sampleFactory->create()->load($sampleId);
if (!$existingSample->getId()) {
- throw new NoSuchEntityException(__('There is no downloadable sample with provided ID.'));
+ throw new NoSuchEntityException(
+ __('No downloadable sample with the provided ID was found. Verify the ID and try again.')
+ );
}
$linkFieldValue = $product->getData(
$this->getMetadataPool()->getMetadata(ProductInterface::class)->getLinkField()
);
if ($existingSample->getProductId() != $linkFieldValue) {
- throw new InputException(__('Provided downloadable sample is not related to given product.'));
+ throw new InputException(
+ __("The downloadable sample isn't related to the product. Verify the link and try again.")
+ );
}
$validateFileContent = $sample->getSampleFileContent() === null ? false : true;
if (!$this->contentValidator->isValid($sample, $validateFileContent)) {
- throw new InputException(__('Provided sample information is invalid.'));
+ throw new InputException(__('The sample information is invalid. Verify the information and try again.'));
}
if ($isGlobalScopeContent) {
$product->setStoreId(0);
@@ -291,7 +300,7 @@ protected function updateSample(
$title = $sample->getTitle();
if (empty($title)) {
if ($isGlobalScopeContent) {
- throw new InputException(__('Sample title cannot be empty.'));
+ throw new InputException(__('The sample title is empty. Enter the title and try again.'));
}
// use title from GLOBAL scope
$existingSample->setTitle(null);
@@ -314,12 +323,14 @@ public function delete($id)
/** @var $sample \Magento\Downloadable\Model\Sample */
$sample = $this->sampleFactory->create()->load($id);
if (!$sample->getId()) {
- throw new NoSuchEntityException(__('There is no downloadable sample with provided ID.'));
+ throw new NoSuchEntityException(
+ __('No downloadable sample with the provided ID was found. Verify the ID and try again.')
+ );
}
try {
$sample->delete();
} catch (\Exception $exception) {
- throw new StateException(__('Cannot delete sample with id %1', $sample->getId()), $exception);
+ throw new StateException(__('The sample with "%1" ID can\'t be deleted.', $sample->getId()), $exception);
}
return true;
}
diff --git a/app/code/Magento/Downloadable/Setup/InstallData.php b/app/code/Magento/Downloadable/Setup/Patch/Data/InstallDownloadableAttributes.php
similarity index 81%
rename from app/code/Magento/Downloadable/Setup/InstallData.php
rename to app/code/Magento/Downloadable/Setup/Patch/Data/InstallDownloadableAttributes.php
index e015f3a23c1..9c101425e49 100644
--- a/app/code/Magento/Downloadable/Setup/InstallData.php
+++ b/app/code/Magento/Downloadable/Setup/Patch/Data/InstallDownloadableAttributes.php
@@ -4,33 +4,41 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Downloadable\Setup;
+namespace Magento\Downloadable\Setup\Patch\Data;
use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
-use Magento\Framework\Setup\InstallDataInterface;
-use Magento\Framework\Setup\ModuleContextInterface;
+use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Setup\ModuleDataSetupInterface;
+use Magento\Framework\Setup\Patch\DataPatchInterface;
+use Magento\Framework\Setup\Patch\PatchVersionInterface;
/**
- * @codeCoverageIgnore
+ * Class InstallDownloadableAttributes
+ * @package Magento\Downloadable\Setup\Patch
*/
-class InstallData implements InstallDataInterface
+class InstallDownloadableAttributes implements DataPatchInterface, PatchVersionInterface
{
/**
- * EAV setup factory
- *
+ * @var \Magento\Framework\Setup\ModuleDataSetupInterface
+ */
+ private $moduleDataSetup;
+
+ /**
* @var EavSetupFactory
*/
private $eavSetupFactory;
/**
- * Init
- *
+ * InstallDownloadableAttributes constructor.
+ * @param ModuleDataSetupInterface $moduleDataSetup
* @param EavSetupFactory $eavSetupFactory
*/
- public function __construct(EavSetupFactory $eavSetupFactory)
- {
+ public function __construct(
+ ModuleDataSetupInterface $moduleDataSetup,
+ EavSetupFactory $eavSetupFactory
+ ) {
+ $this->moduleDataSetup = $moduleDataSetup;
$this->eavSetupFactory = $eavSetupFactory;
}
@@ -38,10 +46,10 @@ public function __construct(EavSetupFactory $eavSetupFactory)
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
+ public function apply()
{
/** @var EavSetup $eavSetup */
- $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
+ $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
/**
* Add attributes to the eav/attribute table
*/
@@ -95,7 +103,6 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
'apply_to' => 'downloadable'
]
);
-
$eavSetup->addAttribute(
\Magento\Catalog\Model\Product::ENTITY,
'links_title',
@@ -120,7 +127,6 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
'apply_to' => 'downloadable'
]
);
-
$eavSetup->addAttribute(
\Magento\Catalog\Model\Product::ENTITY,
'links_exist',
@@ -146,7 +152,6 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
'used_in_product_listing' => 1
]
);
-
$fieldList = [
'price',
'special_price',
@@ -157,7 +162,6 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
'tier_price',
'weight',
];
-
// make these attributes applicable to downloadable products
foreach ($fieldList as $field) {
$applyTo = explode(
@@ -175,4 +179,28 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
}
}
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.0';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
}
diff --git a/app/code/Magento/Downloadable/Test/Unit/Helper/DownloadTest.php b/app/code/Magento/Downloadable/Test/Unit/Helper/DownloadTest.php
index 31429006132..226660b8652 100644
--- a/app/code/Magento/Downloadable/Test/Unit/Helper/DownloadTest.php
+++ b/app/code/Magento/Downloadable/Test/Unit/Helper/DownloadTest.php
@@ -102,7 +102,7 @@ public function testGetFileSizeNoResource()
*/
public function testGetFileSizeInvalidLinkType()
{
- $this->_helper->setResource(self::FILE_PATH, 'invalid link type');
+ $this->_helper->setResource(self::FILE_PATH, 'The link type is invalid. Verify and try again.');
$this->_helper->getFileSize();
}
diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php
index d835f255233..f771233fad7 100644
--- a/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php
+++ b/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Downloadable\Test\Unit\Model;
use Magento\Downloadable\Model\LinkRepository;
@@ -259,7 +260,7 @@ public function testCreate()
/**
* @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Link title cannot be empty.
+ * @expectedExceptionMessage The link title is empty. Enter the link title and try again.
*/
public function testCreateThrowsExceptionIfTitleIsEmpty()
{
@@ -421,7 +422,7 @@ public function testUpdateWithExistingFile()
/**
* @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Link title cannot be empty.
+ * @expectedExceptionMessage The link title is empty. Enter the link title and try again.
*/
public function testUpdateThrowsExceptionIfTitleIsEmptyAndScopeIsGlobal()
{
@@ -469,7 +470,7 @@ public function testDelete()
/**
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage There is no downloadable link with provided ID.
+ * @expectedExceptionMessage No downloadable link with the provided ID was found. Verify the ID and try again.
*/
public function testDeleteThrowsExceptionIfLinkIdIsNotValid()
{
diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/SampleRepositoryTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/SampleRepositoryTest.php
index 79a314cee54..8e13bd83b03 100644
--- a/app/code/Magento/Downloadable/Test/Unit/Model/SampleRepositoryTest.php
+++ b/app/code/Magento/Downloadable/Test/Unit/Model/SampleRepositoryTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Downloadable\Test\Unit\Model;
use Magento\Downloadable\Model\SampleRepository;
@@ -206,7 +207,7 @@ public function testCreate()
/**
* @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Sample title cannot be empty.
+ * @expectedExceptionMessage The sample title is empty. Enter the title and try again.
*/
public function testCreateThrowsExceptionIfTitleIsEmpty()
{
@@ -341,7 +342,7 @@ public function testUpdateWithExistingFile()
/**
* @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Sample title cannot be empty.
+ * @expectedExceptionMessage The sample title is empty. Enter the title and try again.
*/
public function testUpdateThrowsExceptionIfTitleIsEmptyAndScopeIsGlobal()
{
@@ -388,7 +389,7 @@ public function testDelete()
/**
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage There is no downloadable sample with provided ID.
+ * @expectedExceptionMessage No downloadable sample with the provided ID was found. Verify the ID and try again.
*/
public function testDeleteThrowsExceptionIfSampleIdIsNotValid()
{
diff --git a/app/code/Magento/Downloadable/etc/db_schema.xml b/app/code/Magento/Downloadable/etc/db_schema.xml
index 675c9a5c856..ed25628bcff 100644
--- a/app/code/Magento/Downloadable/etc/db_schema.xml
+++ b/app/code/Magento/Downloadable/etc/db_schema.xml
@@ -6,7 +6,7 @@
*/
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
diff --git a/app/code/Magento/Downloadable/etc/module.xml b/app/code/Magento/Downloadable/etc/module.xml
index 4c4e165feb0..72aadff621e 100644
--- a/app/code/Magento/Downloadable/etc/module.xml
+++ b/app/code/Magento/Downloadable/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/DownloadableGraphQl/etc/module.xml b/app/code/Magento/DownloadableGraphQl/etc/module.xml
index 0b89ef36c53..3f97f6f0acc 100644
--- a/app/code/Magento/DownloadableGraphQl/etc/module.xml
+++ b/app/code/Magento/DownloadableGraphQl/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/DownloadableImportExport/etc/module.xml b/app/code/Magento/DownloadableImportExport/etc/module.xml
index c59a8a2f6f1..9cba501ba5d 100644
--- a/app/code/Magento/DownloadableImportExport/etc/module.xml
+++ b/app/code/Magento/DownloadableImportExport/etc/module.xml
@@ -7,7 +7,7 @@
-->
-
+
diff --git a/app/code/Magento/Eav/Api/Data/AttributeInterface.php b/app/code/Magento/Eav/Api/Data/AttributeInterface.php
index 9664cabc79b..e8970d2b421 100644
--- a/app/code/Magento/Eav/Api/Data/AttributeInterface.php
+++ b/app/code/Magento/Eav/Api/Data/AttributeInterface.php
@@ -307,4 +307,14 @@ public function setValidationRules(array $validationRules = null);
* @return \Magento\Eav\Api\Data\AttributeExtensionInterface|null
*/
public function getExtensionAttributes();
+
+ /**
+ * Set an extension attributes object
+ *
+ * @param \Magento\Eav\Api\Data\AttributeExtensionInterface $extensionAttributes
+ * @return $this
+ */
+ public function setExtensionAttributes(
+ \Magento\Eav\Api\Data\AttributeExtensionInterface $extensionAttributes
+ );
}
diff --git a/app/code/Magento/Eav/Model/Adminhtml/System/Config/Source/Inputtype.php b/app/code/Magento/Eav/Model/Adminhtml/System/Config/Source/Inputtype.php
index 5faebdfd5da..aa3b00126ee 100644
--- a/app/code/Magento/Eav/Model/Adminhtml/System/Config/Source/Inputtype.php
+++ b/app/code/Magento/Eav/Model/Adminhtml/System/Config/Source/Inputtype.php
@@ -7,6 +7,20 @@
class Inputtype implements \Magento\Framework\Option\ArrayInterface
{
+ /**
+ * @var array
+ */
+ private $optionsArray;
+
+ /**
+ * Inputtype constructor.
+ * @param array $optionsArray
+ */
+ public function __construct(array $optionsArray = [])
+ {
+ $this->optionsArray = $optionsArray;
+ }
+
/**
* Return array of options
*
@@ -14,15 +28,9 @@ class Inputtype implements \Magento\Framework\Option\ArrayInterface
*/
public function toOptionArray()
{
- return [
- ['value' => 'text', 'label' => __('Text Field')],
- ['value' => 'textarea', 'label' => __('Text Area')],
- ['value' => 'texteditor', 'label' => __('Text Editor')],
- ['value' => 'date', 'label' => __('Date')],
- ['value' => 'boolean', 'label' => __('Yes/No')],
- ['value' => 'multiselect', 'label' => __('Multiple Select')],
- ['value' => 'select', 'label' => __('Dropdown')]
- ];
+ //sort array elements using key value
+ ksort($this->optionsArray);
+ return $this->optionsArray;
}
/**
diff --git a/app/code/Magento/Eav/Model/Attribute/GroupRepository.php b/app/code/Magento/Eav/Model/Attribute/GroupRepository.php
index 0714f8efac8..07ca71d95eb 100644
--- a/app/code/Magento/Eav/Model/Attribute/GroupRepository.php
+++ b/app/code/Magento/Eav/Model/Attribute/GroupRepository.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Eav\Model\Attribute;
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
@@ -99,7 +100,7 @@ public function save(\Magento\Eav\Api\Data\AttributeGroupInterface $group)
}
if ($existingGroup->getAttributeSetId() != $group->getAttributeSetId()) {
throw new StateException(
- __('Attribute group does not belong to provided attribute set')
+ __("The attribute group doesn't belong to the provided attribute set.")
);
}
}
@@ -107,7 +108,7 @@ public function save(\Magento\Eav\Api\Data\AttributeGroupInterface $group)
try {
$this->groupResource->save($group);
} catch (\Exception $e) {
- throw new StateException(__('Cannot save attributeGroup'));
+ throw new StateException(__("The attributeGroup can't be saved."));
}
return $group;
}
@@ -140,7 +141,9 @@ public function get($groupId)
$group = $this->groupFactory->create();
$this->groupResource->load($group, $groupId);
if (!$group->getId()) {
- throw new NoSuchEntityException(__('Group with id "%1" does not exist.', $groupId));
+ throw new NoSuchEntityException(
+ __('The group with the "%1" ID doesn\'t exist. Verify the ID and try again.', $groupId)
+ );
}
return $group;
}
@@ -155,7 +158,7 @@ public function delete(\Magento\Eav\Api\Data\AttributeGroupInterface $group)
} catch (\Exception $e) {
throw new StateException(
__(
- 'Cannot delete attributeGroup with id %1',
+ 'The attribute group with id "%1" can\'t be deleted.',
$group->getId()
),
$e
diff --git a/app/code/Magento/Eav/Model/AttributeManagement.php b/app/code/Magento/Eav/Model/AttributeManagement.php
index b76116c6f96..31f962db3ee 100644
--- a/app/code/Magento/Eav/Model/AttributeManagement.php
+++ b/app/code/Magento/Eav/Model/AttributeManagement.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Eav\Model;
use Magento\Framework\App\ObjectManager;
@@ -98,19 +99,24 @@ public function assign($entityTypeCode, $attributeSetId, $attributeGroupId, $att
try {
$attributeSet = $this->setRepository->get($attributeSetId);
} catch (NoSuchEntityException $ex) {
- throw new NoSuchEntityException(__('AttributeSet with id "%1" does not exist.', $attributeSetId));
+ throw new NoSuchEntityException(
+ __(
+ 'The AttributeSet with a "%1" ID doesn\'t exist. Verify the attributeSet and try again.',
+ $attributeSetId
+ )
+ );
}
$setEntityType = $this->entityTypeFactory->create()->getEntityType($attributeSet->getEntityTypeId());
if ($setEntityType->getEntityTypeCode() != $entityTypeCode) {
- throw new InputException(__('Wrong attribute set id provided'));
+ throw new InputException(__('The attribute set ID is incorrect. Verify the ID and try again.'));
}
//Check if group exists. If not - expected exception
$attributeGroup = $this->groupRepository->get($attributeGroupId);
if ($attributeGroup->getAttributeSetId() != $attributeSetId) {
- throw new InputException(__('Attribute group does not belong to attribute set'));
+ throw new InputException(__('The attribute group doesn\'t belong to the attribute set.'));
}
/** @var \Magento\Eav\Api\Data\AttributeInterface $attribute */
@@ -135,7 +141,9 @@ public function unassign($attributeSetId, $attributeCode)
try {
$attributeSet = $this->setRepository->get($attributeSetId);
} catch (NoSuchEntityException $e) {
- throw new NoSuchEntityException(__('Attribute set not found: %1', $attributeSetId));
+ throw new NoSuchEntityException(
+ __('The "%1" attribute set wasn\'t found. Verify and try again.', $attributeSetId)
+ );
}
$setEntityType = $this->entityTypeFactory->create()->getEntityType($attributeSet->getEntityTypeId());
@@ -148,11 +156,15 @@ public function unassign($attributeSetId, $attributeCode)
if (!$attribute->getEntityAttributeId()) {
throw new InputException(
- __('Attribute "%1" not found in attribute set %2.', $attributeCode, $attributeSetId)
+ __(
+ 'The "%1" attribute wasn\'t found in the "%2" attribute set. Enter the attribute and try again.',
+ $attributeCode,
+ $attributeSetId
+ )
);
}
if (!$attribute->getIsUserDefined()) {
- throw new StateException(__('System attribute can not be deleted'));
+ throw new StateException(__("The system attribute can't be deleted."));
}
$attribute->deleteEntity();
return true;
diff --git a/app/code/Magento/Eav/Model/AttributeRepository.php b/app/code/Magento/Eav/Model/AttributeRepository.php
index 3f20558d03d..120c868a9d4 100644
--- a/app/code/Magento/Eav/Model/AttributeRepository.php
+++ b/app/code/Magento/Eav/Model/AttributeRepository.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Eav\Model;
use Magento\Framework\Api\SearchCriteria\CollectionProcessor;
@@ -87,7 +88,7 @@ public function save(\Magento\Eav\Api\Data\AttributeInterface $attribute)
try {
$this->eavResource->save($attribute);
} catch (\Exception $e) {
- throw new StateException(__('Cannot save attribute'));
+ throw new StateException(__("The attribute can't be saved."));
}
return $attribute;
}
@@ -154,7 +155,10 @@ public function get($entityTypeCode, $attributeCode)
$attribute = $this->eavConfig->getAttribute($entityTypeCode, $attributeCode);
if (!$attribute || !$attribute->getAttributeId()) {
throw new NoSuchEntityException(
- __('Attribute with attributeCode "%1" does not exist.', $attributeCode)
+ __(
+ 'The attribute with a "%1" attributeCode doesn\'t exist. Verify the attribute and try again.',
+ $attributeCode
+ )
);
}
return $attribute;
@@ -168,7 +172,7 @@ public function delete(\Magento\Eav\Api\Data\AttributeInterface $attribute)
try {
$this->eavResource->delete($attribute);
} catch (\Exception $e) {
- throw new StateException(__('Cannot delete attribute.'));
+ throw new StateException(__("The attribute can't be deleted."));
}
return true;
}
@@ -183,7 +187,9 @@ public function deleteById($attributeId)
$this->eavResource->load($attribute, $attributeId);
if (!$attribute->getAttributeId()) {
- throw new NoSuchEntityException(__('Attribute with id "%1" does not exist.', $attributeId));
+ throw new NoSuchEntityException(
+ __('The attribute with a "%1" ID doesn\'t exist. Verify the attribute and try again.', $attributeId)
+ );
}
$this->delete($attribute);
diff --git a/app/code/Magento/Eav/Model/AttributeSetRepository.php b/app/code/Magento/Eav/Model/AttributeSetRepository.php
index d0b7ed3ccaa..caab82da391 100644
--- a/app/code/Magento/Eav/Model/AttributeSetRepository.php
+++ b/app/code/Magento/Eav/Model/AttributeSetRepository.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Eav\Model;
use Magento\Eav\Api\AttributeSetRepositoryInterface;
@@ -93,7 +94,12 @@ public function save(AttributeSetInterface $attributeSet)
try {
$this->attributeSetResource->save($attributeSet);
} catch (\Exception $exception) {
- throw new CouldNotSaveException(__('There was an error saving attribute set.'));
+ throw new CouldNotSaveException(
+ __(
+ 'The attribute set couldn\'t be saved due to an error. '
+ . 'Verify your information and try again. If the error persists, please try again later.'
+ )
+ );
}
return $attributeSet;
}
@@ -159,9 +165,14 @@ public function delete(AttributeSetInterface $attributeSet)
try {
$this->attributeSetResource->delete($attributeSet);
} catch (\Magento\Framework\Exception\StateException $exception) {
- throw new CouldNotDeleteException(__('Default attribute set can not be deleted'));
+ throw new CouldNotDeleteException(__('The default attribute set can\'t be deleted.'));
} catch (\Exception $exception) {
- throw new CouldNotDeleteException(__('There was an error deleting attribute set.'));
+ throw new CouldNotDeleteException(
+ __(
+ 'The attribute set couldn\'t be deleted due to an error. '
+ . 'Try again — if the error persists, please try again later.'
+ )
+ );
}
return true;
}
diff --git a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
index ef80f12b267..7159cedb61c 100644
--- a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
+++ b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
@@ -365,7 +365,7 @@ public function unsetAttributes($attributes = null)
}
if (!is_array($attributes)) {
- throw new LocalizedException(__('Unknown parameter'));
+ throw new LocalizedException(__('This parameter is unknown. Verify and try again.'));
}
foreach ($attributes as $attrCode) {
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute.php b/app/code/Magento/Eav/Model/Entity/Attribute.php
index a2c2cdcb5ae..1b20858a0c4 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Eav\Model\Entity;
use Magento\Framework\Api\AttributeValueFactory;
@@ -14,7 +15,6 @@
*
* @api
* @method \Magento\Eav\Model\Entity\Attribute setOption($value)
- * @method \Magento\Eav\Api\Data\AttributeExtensionInterface getExtensionAttributes()
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @since 100.0.2
*/
@@ -252,7 +252,10 @@ public function beforeSave()
)
) {
throw new LocalizedException(
- __('An attribute code must not be more than %1 characters.', self::ATTRIBUTE_CODE_MAX_LENGTH)
+ __(
+ 'The attribute code needs to be %1 characters or fewer. Re-enter the code and try again.',
+ self::ATTRIBUTE_CODE_MAX_LENGTH
+ )
);
}
@@ -263,7 +266,9 @@ public function beforeSave()
$numberFormatter = new \NumberFormatter($this->_localeResolver->getLocale(), \NumberFormatter::DECIMAL);
$defaultValue = $numberFormatter->parse($defaultValue);
if ($defaultValue === false) {
- throw new LocalizedException(__('Invalid default decimal value'));
+ throw new LocalizedException(
+ __('The default decimal value is invalid. Verify the value and try again.')
+ );
}
$this->setDefaultValue($defaultValue);
}
@@ -286,7 +291,7 @@ public function beforeSave()
$defaultValue = $this->dateTimeFormatter->formatObject(new \DateTime($defaultValue), $format);
$this->setDefaultValue($defaultValue);
} catch (\Exception $e) {
- throw new LocalizedException(__('Invalid default date'));
+ throw new LocalizedException(__('The default date is invalid. Verify the date and try again.'));
}
}
}
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php
index 19877a51c48..4d3c79db2df 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php
@@ -243,7 +243,7 @@ public function loadByCode($entityType, $code)
$entityTypeId = $entityType->getId();
}
if (empty($entityTypeId)) {
- throw new LocalizedException(__('Invalid entity supplied'));
+ throw new LocalizedException(__('The entity supplied is invalid. Verify the entity and try again.'));
}
$this->_getResource()->loadByCode($this, $entityTypeId, $code);
$this->_afterLoad();
@@ -550,7 +550,12 @@ public function getBackend()
}
$backend = $this->_universalFactory->create($this->getBackendModel());
if (!$backend) {
- throw new LocalizedException(__('Invalid backend model specified: %1', $this->getBackendModel()));
+ throw new LocalizedException(
+ __(
+ 'The "%1" backend model is invalid. Verify the backend model and try again.',
+ $this->getBackendModel()
+ )
+ );
}
$this->_backend = $backend->setAttribute($this);
}
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php
index 38e7b883f4e..53c32e1cbfb 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Eav\Model\Entity\Attribute\Backend;
use Magento\Framework\Exception\LocalizedException;
@@ -238,7 +239,9 @@ public function validate($object)
&& $attribute->isValueEmpty($attribute->getDefaultValue())
) {
$label = $attribute->getFrontend()->getLabel();
- throw new LocalizedException(__('The value of attribute "%1" must be set', $label));
+ throw new LocalizedException(
+ __('The "%1" attribute value is empty. Set the attribute and try again.', $label)
+ );
}
if ($attribute->getIsUnique()
@@ -251,7 +254,9 @@ public function validate($object)
if ($attribute->getIsUnique()) {
if (!$attribute->getEntity()->checkAttributeUniqueValue($attribute, $object)) {
$label = $attribute->getFrontend()->getLabel();
- throw new LocalizedException(__('The value of attribute "%1" must be unique', $label));
+ throw new LocalizedException(
+ __('The value of the "%1" attribute isn\'t unique. Set a unique value and try again.', $label)
+ );
}
}
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php b/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php
index b0508fd8cc6..938abdf3005 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php
@@ -41,12 +41,12 @@ public function __construct(
public function add($entityType, $attributeCode, $option)
{
if (empty($attributeCode)) {
- throw new InputException(__('Empty attribute code'));
+ throw new InputException(__('The attribute code is empty. Enter the code and try again.'));
}
$attribute = $this->attributeRepository->get($entityType, $attributeCode);
if (!$attribute->usesSource()) {
- throw new StateException(__('Attribute %1 doesn\'t work with options', $attributeCode));
+ throw new StateException(__('The "%1" attribute doesn\'t work with options.', $attributeCode));
}
$optionId = $this->getOptionId($option);
@@ -68,7 +68,7 @@ public function add($entityType, $attributeCode, $option)
try {
$this->resourceModel->save($attribute);
} catch (\Exception $e) {
- throw new StateException(__('Cannot save attribute %1', $attributeCode));
+ throw new StateException(__('The "%1" attribute can\'t be saved.', $attributeCode));
}
return true;
@@ -80,12 +80,12 @@ public function add($entityType, $attributeCode, $option)
public function delete($entityType, $attributeCode, $optionId)
{
if (empty($attributeCode)) {
- throw new InputException(__('Empty attribute code'));
+ throw new InputException(__('The attribute code is empty. Enter the code and try again.'));
}
$attribute = $this->attributeRepository->get($entityType, $attributeCode);
if (!$attribute->usesSource()) {
- throw new StateException(__('Attribute %1 doesn\'t have any option', $attributeCode));
+ throw new StateException(__('The "%1" attribute has no option.', $attributeCode));
}
$this->validateOption($attribute, $optionId);
@@ -99,7 +99,7 @@ public function delete($entityType, $attributeCode, $optionId)
try {
$this->resourceModel->save($attribute);
} catch (\Exception $e) {
- throw new StateException(__('Cannot save attribute %1', $attributeCode));
+ throw new StateException(__('The "%1" attribute can\'t be saved.', $attributeCode));
}
return true;
@@ -111,14 +111,14 @@ public function delete($entityType, $attributeCode, $optionId)
public function getItems($entityType, $attributeCode)
{
if (empty($attributeCode)) {
- throw new InputException(__('Empty attribute code'));
+ throw new InputException(__('The attribute code is empty. Enter the code and try again.'));
}
$attribute = $this->attributeRepository->get($entityType, $attributeCode);
try {
$options = $attribute->getOptions();
} catch (\Exception $e) {
- throw new StateException(__('Cannot load options for attribute %1', $attributeCode));
+ throw new StateException(__('The options for "%1" attribute can\'t be loaded.', $attributeCode));
}
return $options;
@@ -134,7 +134,11 @@ protected function validateOption($attribute, $optionId)
{
if (!$attribute->getSource()->getOptionText($optionId)) {
throw new NoSuchEntityException(
- __('Attribute %1 does not contain option with Id %2', $attribute->getAttributeCode(), $optionId)
+ __(
+ 'The "%1" attribute doesn\'t include an option with "%2" ID.',
+ $attribute->getAttributeCode(),
+ $optionId
+ )
);
}
}
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Set.php b/app/code/Magento/Eav/Model/Entity/Attribute/Set.php
index 5434f056104..da7d5fac089 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Set.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Set.php
@@ -220,7 +220,12 @@ public function organizeData($data)
foreach ($data['not_attributes'] as $entityAttributeId) {
$entityAttribute = $this->_resourceAttribute->getEntityAttribute($entityAttributeId);
if (!$entityAttribute) {
- throw new LocalizedException(__('Entity attribute with id "%1" not found', $entityAttributeId));
+ throw new LocalizedException(
+ __(
+ 'The entity attribute with the "%1" ID isn\'t found. Reset the attribute and try again.',
+ $entityAttributeId
+ )
+ );
}
$modelAttribute = $this->_eavConfig->getAttribute(
$this->getEntityTypeId(),
@@ -282,11 +287,13 @@ public function validate()
{
$attributeSetName = $this->getAttributeSetName();
if ($attributeSetName == '') {
- throw new LocalizedException(__('Attribute set name is empty.'));
+ throw new LocalizedException(__('The attribute set name is empty. Enter the name and try again.'));
}
if (!$this->_getResource()->validate($this, $attributeSetName)) {
- throw new LocalizedException(__('An attribute set named "%1" already exists.', $attributeSetName));
+ throw new LocalizedException(
+ __('A "%1" attribute set name already exists. Create a new name and try again.', $attributeSetName)
+ );
}
return true;
diff --git a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php
index 48dbb80fe6d..76e7c7655ba 100644
--- a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php
+++ b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Eav\Model\Entity\Collection;
use Magento\Framework\App\ResourceConnection\SourceProviderInterface;
@@ -246,7 +247,9 @@ public function setEntity($entity)
} elseif (is_string($entity) || $entity instanceof \Magento\Framework\App\Config\Element) {
$this->_entity = $this->_eavEntityFactory->create()->setType($entity);
} else {
- throw new LocalizedException(__('Invalid entity supplied: %1', print_r($entity, 1)));
+ throw new LocalizedException(
+ __('The "%1" entity supplied is invalid. Verify the entity and try again.', print_r($entity, 1))
+ );
}
return $this;
}
@@ -302,7 +305,9 @@ public function setObject($object = null)
public function addItem(\Magento\Framework\DataObject $object)
{
if (!$object instanceof $this->_itemObjectClass) {
- throw new LocalizedException(__('Attempt to add an invalid object'));
+ throw new LocalizedException(
+ __("The object wasn't added because it's invalid. To continue, enter a valid object and try again.")
+ );
}
return parent::addItem($object);
}
@@ -495,7 +500,12 @@ public function addAttributeToSelect($attribute, $joinType = false)
$attrInstance = $this->_eavConfig->getAttribute($this->getEntity()->getType(), $attribute);
}
if (empty($attrInstance)) {
- throw new LocalizedException(__('Invalid attribute requested: %1', (string)$attribute));
+ throw new LocalizedException(
+ __(
+ 'The "%1" attribute requested is invalid. Verify the attribute and try again.',
+ (string)$attribute
+ )
+ );
}
$this->_selectAttributes[$attrInstance->getAttributeCode()] = $attrInstance->getId();
}
@@ -662,7 +672,7 @@ public function joinAttribute($alias, $attribute, $bind, $filter = null, $joinTy
}
if (!$bindAttribute || !$bindAttribute->isStatic() && !$bindAttribute->getId()) {
- throw new LocalizedException(__('Invalid foreign key'));
+ throw new LocalizedException(__('The foreign key is invalid. Verify the foreign key and try again.'));
}
// try to explode combined entity/attribute if supplied
@@ -686,7 +696,7 @@ public function joinAttribute($alias, $attribute, $bind, $filter = null, $joinTy
}
}
if (!$entity || !$entity->getTypeId()) {
- throw new LocalizedException(__('Invalid entity type'));
+ throw new LocalizedException(__('The entity type is invalid. Verify the entity type and try again.'));
}
// cache entity
@@ -699,7 +709,7 @@ public function joinAttribute($alias, $attribute, $bind, $filter = null, $joinTy
$attribute = $entity->getAttribute($attribute);
}
if (!$attribute) {
- throw new LocalizedException(__('Invalid attribute type'));
+ throw new LocalizedException(__('The attribute type is invalid. Verify the attribute type and try again.'));
}
if (empty($filter)) {
@@ -819,7 +829,7 @@ public function joinTable($table, $bind, $fields = null, $cond = null, $joinType
}
foreach ($fields as $alias => $field) {
if (isset($this->_joinFields[$alias])) {
- throw new LocalizedException(__('A joint field with this alias (%1) is already declared.', $alias));
+ throw new LocalizedException(__('A joint field with a "%1" alias is already declared.', $alias));
}
$this->_joinFields[$alias] = ['table' => $tableAlias, 'field' => $field];
}
@@ -1269,7 +1279,9 @@ protected function _setItemAttributeValue($valueInfo)
$entityIdField = $this->getEntity()->getEntityIdField();
$entityId = $valueInfo[$entityIdField];
if (!isset($this->_itemsById[$entityId])) {
- throw new LocalizedException(__('Data integrity: No header row found for attribute'));
+ throw new LocalizedException(
+ __('A header row is missing for an attribute. Verify the header row and try again.')
+ );
}
$attributeCode = array_search($valueInfo['attribute_id'], $this->_selectAttributes);
if (!$attributeCode) {
@@ -1321,7 +1333,9 @@ protected function _getAttributeFieldName($attributeCode)
$attribute = $this->getAttribute($attributeCode);
if (!$attribute) {
- throw new LocalizedException(__('Invalid attribute name: %1', $attributeCode));
+ throw new LocalizedException(
+ __('The "%1" attribute name is invalid. Reset the name and try again.', $attributeCode)
+ );
}
if ($attribute->isStatic()) {
@@ -1380,7 +1394,9 @@ protected function _addAttributeJoin($attributeCode, $joinType = 'inner')
}
if (!$attribute) {
- throw new LocalizedException(__('Invalid attribute name: %1', $attributeCode));
+ throw new LocalizedException(
+ __('The "%1" attribute name is invalid. Reset the name and try again.', $attributeCode)
+ );
}
if ($attribute->getBackend()->isStatic()) {
diff --git a/app/code/Magento/Eav/Model/Entity/GetCustomAttributeCodes.php b/app/code/Magento/Eav/Model/Entity/GetCustomAttributeCodes.php
new file mode 100644
index 00000000000..a77b298f5d2
--- /dev/null
+++ b/app/code/Magento/Eav/Model/Entity/GetCustomAttributeCodes.php
@@ -0,0 +1,52 @@
+customAttributesCodes[$cacheKey])) {
+ $this->customAttributesCodes[$cacheKey] = $this->getEavAttributesCodes($metadataService);
+ }
+ return $this->customAttributesCodes[$cacheKey];
+ }
+
+ /**
+ * Receive a list of EAV attributes using provided metadata service.
+ *
+ * @param MetadataServiceInterface $metadataService
+ * @param string|null $entityType
+ * @return string[]
+ */
+ private function getEavAttributesCodes(MetadataServiceInterface $metadataService, string $entityType = null)
+ {
+ $attributeCodes = [];
+ $customAttributesMetadata = $metadataService->getCustomAttributesMetadata($entityType);
+ if (is_array($customAttributesMetadata)) {
+ /** @var $attribute \Magento\Framework\Api\MetadataObjectInterface */
+ foreach ($customAttributesMetadata as $attribute) {
+ $attributeCodes[] = $attribute->getAttributeCode();
+ }
+ }
+ return $attributeCodes;
+ }
+}
diff --git a/app/code/Magento/Eav/Model/Entity/GetCustomAttributeCodesInterface.php b/app/code/Magento/Eav/Model/Entity/GetCustomAttributeCodesInterface.php
new file mode 100644
index 00000000000..c73d626e736
--- /dev/null
+++ b/app/code/Magento/Eav/Model/Entity/GetCustomAttributeCodesInterface.php
@@ -0,0 +1,20 @@
+getTypeId()) {
- throw new LocalizedException(__('Invalid form type.'));
+ throw new LocalizedException(__('The form type is invalid. Reset the type and try again.'));
}
if (!$this->getAttributeId()) {
- throw new LocalizedException(__('Invalid EAV attribute'));
+ throw new LocalizedException(__('The EAV attribute is invalid. Verify the attribute and try again.'));
}
return parent::beforeSave();
diff --git a/app/code/Magento/Eav/Model/Form/Fieldset.php b/app/code/Magento/Eav/Model/Form/Fieldset.php
index a0c706c3d03..f43a10f074a 100644
--- a/app/code/Magento/Eav/Model/Form/Fieldset.php
+++ b/app/code/Magento/Eav/Model/Form/Fieldset.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Eav\Model\Form;
/**
@@ -72,7 +73,9 @@ protected function _construct()
public function beforeSave()
{
if (!$this->getTypeId()) {
- throw new \Magento\Framework\Exception\LocalizedException(__('Invalid form type.'));
+ throw new \Magento\Framework\Exception\LocalizedException(
+ __('The form type is invalid. Reset the type and try again.')
+ );
}
if (!$this->getStoreId() && $this->getLabel()) {
$this->setStoreLabel($this->getStoreId(), $this->getLabel());
diff --git a/app/code/Magento/Eav/Model/ResourceModel/AttributePersistor.php b/app/code/Magento/Eav/Model/ResourceModel/AttributePersistor.php
index f3b2e0ba3e6..9c6adc0354f 100644
--- a/app/code/Magento/Eav/Model/ResourceModel/AttributePersistor.php
+++ b/app/code/Magento/Eav/Model/ResourceModel/AttributePersistor.php
@@ -144,6 +144,31 @@ public function processInserts($entityType, $context)
return;
}
$metadata = $this->metadataPool->getMetadata($entityType);
+ $insertData = $this->prepareInsertDataForMultipleSave($entityType, $context);
+
+ foreach ($insertData as $table => $tableData) {
+ foreach ($tableData as $data) {
+ $metadata->getEntityConnection()->insertArray(
+ $table,
+ $data['columns'],
+ $data['data'],
+ \Magento\Framework\DB\Adapter\AdapterInterface::INSERT_IGNORE
+ );
+ }
+ }
+ }
+
+ /**
+ * Prepare data for insert multiple rows
+ *
+ * @param string $entityType
+ * @param \Magento\Framework\Model\Entity\ScopeInterface[] $context
+ * @return array
+ */
+ private function prepareInsertDataForMultipleSave($entityType, $context)
+ {
+ $metadata = $this->metadataPool->getMetadata($entityType);
+ $insertData = [];
foreach ($this->insert[$entityType] as $link => $data) {
foreach ($data as $attributeCode => $attributeValue) {
/** @var AbstractAttribute $attribute */
@@ -151,19 +176,21 @@ public function processInserts($entityType, $context)
$metadata->getEavEntityType(),
$attributeCode
);
-
+ $attributeTable = $attribute->getBackend()->getTable();
$conditions = $this->buildInsertConditions($attribute, $metadata, $context, $link);
$value = $this->prepareValue($entityType, $attributeValue, $attribute);
foreach ($conditions as $condition) {
$condition['value'] = $value;
- $metadata->getEntityConnection()->insertOnDuplicate(
- $attribute->getBackend()->getTable(),
- $condition
- );
+ $columns = array_keys($condition);
+ $columnsHash = implode('', $columns);
+ $insertData[$attributeTable][$columnsHash]['columns'] = $columns;
+ $insertData[$attributeTable][$columnsHash]['data'][] = array_values($condition);
}
}
}
+
+ return $insertData;
}
/**
diff --git a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php
index d64d5774fef..25858f6a345 100644
--- a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php
+++ b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Eav\Model\ResourceModel\Entity;
use Magento\Eav\Model\Config;
@@ -393,7 +394,9 @@ protected function _processAttributeOptions($object, $option)
protected function _checkDefaultOptionValue($values)
{
if (!isset($values[0])) {
- throw new \Magento\Framework\Exception\LocalizedException(__('Default option value is not defined'));
+ throw new \Magento\Framework\Exception\LocalizedException(
+ __("The default option isn't defined. Set the option and try again.")
+ );
}
}
diff --git a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Collection.php b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Collection.php
index f55c4db31ef..492da0b72c1 100644
--- a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Collection.php
+++ b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Collection.php
@@ -210,17 +210,19 @@ public function setAttributeSetsFilter(array $setIds)
*/
public function setInAllAttributeSetsFilter(array $setIds)
{
- foreach ($setIds as $setId) {
- $setId = (int)$setId;
- if (!$setId) {
- continue;
- }
- $alias = sprintf('entity_attribute_%d', $setId);
- $joinCondition = $this->getConnection()->quoteInto(
- "{$alias}.attribute_id = main_table.attribute_id AND {$alias}.attribute_set_id =?",
- $setId
- );
- $this->join([$alias => 'eav_entity_attribute'], $joinCondition, 'attribute_id');
+ if (!empty($setIds)) {
+ $this->getSelect()
+ ->join(
+ ['entity_attribute' => $this->getTable('eav_entity_attribute')],
+ 'entity_attribute.attribute_id = main_table.attribute_id',
+ ['count' => new \Zend_Db_Expr('COUNT(*)')]
+ )
+ ->where(
+ 'entity_attribute.attribute_set_id IN (?)',
+ $setIds
+ )
+ ->group('entity_attribute.attribute_id')
+ ->having('count = ' . count($setIds));
}
//$this->getSelect()->distinct(true);
diff --git a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Set.php b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Set.php
index 77ceb192cfd..4e1762730a8 100644
--- a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Set.php
+++ b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Set.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Eav\Model\ResourceModel\Entity\Attribute;
class Set extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
@@ -103,7 +104,7 @@ protected function _beforeDelete(\Magento\Framework\Model\AbstractModel $object)
->getDefaultAttributeSetId();
if ($object->getAttributeSetId() == $defaultAttributeSetId) {
throw new \Magento\Framework\Exception\StateException(
- __('Default attribute set can not be deleted')
+ __('The default attribute set can\'t be deleted.')
);
}
return parent::_beforeDelete($object);
diff --git a/app/code/Magento/Eav/Setup/EavSetup.php b/app/code/Magento/Eav/Setup/EavSetup.php
index 13f55308e6f..6e81ddc36e9 100644
--- a/app/code/Magento/Eav/Setup/EavSetup.php
+++ b/app/code/Magento/Eav/Setup/EavSetup.php
@@ -3,12 +3,15 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Eav\Setup;
use Magento\Eav\Model\Entity\Setup\Context;
use Magento\Eav\Model\Entity\Setup\PropertyMapperInterface;
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory;
use Magento\Framework\App\CacheInterface;
+use Magento\Framework\App\ObjectManager;
+use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Setup\ModuleDataSetupInterface;
@@ -99,7 +102,7 @@ public function __construct(
/**
* Gets setup model
- *
+ * @deprecated
* @return ModuleDataSetupInterface
*/
public function getSetup()
@@ -201,7 +204,10 @@ public function addEntityType($code, array $params)
if ($this->getEntityType($code, 'entity_type_id')) {
$this->updateEntityType($code, $data);
} else {
- $this->setup->getConnection()->insert($this->setup->getTable('eav_entity_type'), $data);
+ $this->setup->getConnection()->insert(
+ $this->setup->getTable('eav_entity_type'),
+ $data
+ );
}
if (isset($params['entity_type_id'])) {
@@ -264,7 +270,7 @@ public function getEntityTypeId($entityTypeId)
$entityTypeId = $this->getEntityType($entityTypeId, 'entity_type_id');
}
if (!is_numeric($entityTypeId)) {
- throw new LocalizedException(__('Wrong entity ID'));
+ throw new LocalizedException(__('The entity ID is incorrect. Verify the ID and try again.'));
}
return $entityTypeId;
@@ -338,7 +344,10 @@ public function addAttributeSet($entityTypeId, $name, $sortOrder = null, $setId
if ($setId) {
$this->updateAttributeSet($entityTypeId, $setId, $data);
} else {
- $this->setup->getConnection()->insert($this->setup->getTable('eav_attribute_set'), $data);
+ $this->setup->getConnection()->insert(
+ $this->setup->getTable('eav_attribute_set'),
+ $data
+ );
$this->addAttributeGroup($entityTypeId, $name, $this->_generalGroupName);
}
@@ -403,7 +412,7 @@ public function getAttributeSetId($entityTypeId, $setId)
$setId = $this->getAttributeSet($entityTypeId, $setId, 'attribute_set_id');
}
if (!is_numeric($setId)) {
- throw new LocalizedException(__('Wrong attribute set ID'));
+ throw new LocalizedException(__('The attribute set ID is incorrect. Verify the ID and try again.'));
}
return $setId;
@@ -549,7 +558,10 @@ public function addAttributeGroup($entityTypeId, $setId, $name, $sortOrder = nul
}
$data['attribute_group_code'] = $attributeGroupCode;
}
- $this->setup->getConnection()->insert($this->setup->getTable('eav_attribute_group'), $data);
+ $this->setup->getConnection()->insert(
+ $this->setup->getTable('eav_attribute_group'),
+ $data
+ );
}
return $this;
@@ -665,7 +677,7 @@ public function getAttributeGroupId($entityTypeId, $setId, $groupId)
}
if (!is_numeric($groupId)) {
- throw new LocalizedException(__('Wrong attribute group ID'));
+ throw new LocalizedException(__('The attribute group ID is incorrect. Verify the ID and try again.'));
}
return $groupId;
}
@@ -896,13 +908,17 @@ public function addAttributeOption($option)
$data = [
'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0,
];
- $this->setup->getConnection()->update($optionTable, $data, ['option_id=?' => $intOptionId]);
+ $this->setup->getConnection()->update(
+ $optionTable,
+ $data,
+ ['option_id=?' => $intOptionId]
+ );
}
// Default value
if (!isset($values[0])) {
throw new \Magento\Framework\Exception\LocalizedException(
- __('Default option value is not defined')
+ __("The default option isn't defined. Set the option and try again.")
);
}
$condition = ['option_id =?' => $intOptionId];
@@ -970,7 +986,10 @@ private function _updateAttribute($entityTypeId, $id, $field, $value = null, $so
$bind = [];
foreach ($field as $k => $v) {
if (isset($attributeFields[$k])) {
- $bind[$k] = $this->setup->getConnection()->prepareColumnValue($attributeFields[$k], $v);
+ $bind[$k] = $this->setup->getConnection()->prepareColumnValue(
+ $attributeFields[$k],
+ $v
+ );
}
}
if (!$bind) {
@@ -1016,16 +1035,23 @@ private function _updateAttributeAdditionalData($entityTypeId, $id, $field, $val
if (!$additionalTable) {
return $this;
}
- $additionalTableExists = $this->setup->getConnection()->isTableExists($this->setup->getTable($additionalTable));
+ $additionalTableExists = $this->setup->getConnection()->isTableExists(
+ $this->setup->getTable($additionalTable)
+ );
if (!$additionalTableExists) {
return $this;
}
- $attributeFields = $this->setup->getConnection()->describeTable($this->setup->getTable($additionalTable));
+ $attributeFields = $this->setup->getConnection()->describeTable(
+ $this->setup->getTable($additionalTable)
+ );
if (is_array($field)) {
$bind = [];
foreach ($field as $k => $v) {
if (isset($attributeFields[$k])) {
- $bind[$k] = $this->setup->getConnection()->prepareColumnValue($attributeFields[$k], $v);
+ $bind[$k] = $this->setup->getConnection()->prepareColumnValue(
+ $attributeFields[$k],
+ $v
+ );
}
}
if (!$bind) {
@@ -1358,7 +1384,10 @@ public function addAttributeToGroup($entityType, $setId, $groupId, $attributeId,
}
$sortOrder = is_numeric($sortOrder) ? $sortOrder : 1;
$data['sort_order'] = $sortOrder;
- $this->setup->getConnection()->insert($this->setup->getTable('eav_entity_attribute'), $data);
+ $this->setup->getConnection()->insert(
+ $this->setup->getTable('eav_entity_attribute'),
+ $data
+ );
}
return $this;
@@ -1439,7 +1468,9 @@ public function installEntities($entities = null)
*/
private function _getAttributeTableFields()
{
- return $this->setup->getConnection()->describeTable($this->setup->getTable('eav_attribute'));
+ return $this->setup->getConnection()->describeTable(
+ $this->setup->getTable('eav_attribute')
+ );
}
/**
@@ -1463,8 +1494,13 @@ private function _insertAttribute(array $data)
return $this;
}
- $this->setup->getConnection()->insert($this->setup->getTable('eav_attribute'), $bind);
- $attributeId = $this->setup->getConnection()->lastInsertId($this->setup->getTable('eav_attribute'));
+ $this->setup->getConnection()->insert(
+ $this->setup->getTable('eav_attribute'),
+ $bind
+ );
+ $attributeId = $this->setup->getConnection()->lastInsertId(
+ $this->setup->getTable('eav_attribute')
+ );
$this->_insertAttributeAdditionalData(
$data['entity_type_id'],
array_merge(['attribute_id' => $attributeId], $data)
@@ -1486,10 +1522,14 @@ private function _insertAttributeAdditionalData($entityTypeId, array $data)
if (!$additionalTable) {
return $this;
}
- $additionalTableExists = $this->setup->getConnection()->isTableExists($this->setup->getTable($additionalTable));
+ $additionalTableExists = $this->setup->getConnection()->isTableExists(
+ $this->setup->getTable($additionalTable)
+ );
if ($additionalTable && $additionalTableExists) {
$bind = [];
- $fields = $this->setup->getConnection()->describeTable($this->setup->getTable($additionalTable));
+ $fields = $this->setup->getConnection()->describeTable(
+ $this->setup->getTable($additionalTable)
+ );
foreach ($data as $k => $v) {
if (isset($fields[$k])) {
$bind[$k] = $this->setup->getConnection()->prepareColumnValue($fields[$k], $v);
@@ -1498,7 +1538,10 @@ private function _insertAttributeAdditionalData($entityTypeId, array $data)
if (!$bind) {
return $this;
}
- $this->setup->getConnection()->insert($this->setup->getTable($additionalTable), $bind);
+ $this->setup->getConnection()->insert(
+ $this->setup->getTable($additionalTable),
+ $bind
+ );
}
return $this;
diff --git a/app/code/Magento/Eav/Setup/InstallData.php b/app/code/Magento/Eav/Setup/Patch/Data/InitializeAttributeModels.php
similarity index 69%
rename from app/code/Magento/Eav/Setup/InstallData.php
rename to app/code/Magento/Eav/Setup/Patch/Data/InitializeAttributeModels.php
index ca2156d62ee..5cae23f8fd1 100644
--- a/app/code/Magento/Eav/Setup/InstallData.php
+++ b/app/code/Magento/Eav/Setup/Patch/Data/InitializeAttributeModels.php
@@ -4,43 +4,51 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Eav\Setup;
+namespace Magento\Eav\Setup\Patch\Data;
use Magento\Eav\Setup\EavSetupFactory;
-use Magento\Framework\Setup\InstallDataInterface;
-use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\Setup\Patch\DataPatchInterface;
+use Magento\Framework\Setup\Patch\PatchVersionInterface;
/**
- * @codeCoverageIgnore
+ * Class InitializeAttributeModels
+ * @package Magento\Eav\Setup\Patch
*/
-class InstallData implements InstallDataInterface
+class InitializeAttributeModels implements DataPatchInterface, PatchVersionInterface
{
/**
- * EAV setup factory
- *
+ * @var \Magento\Framework\Setup\ModuleDataSetupInterface
+ */
+ private $moduleDataSetup;
+ /**
* @var EavSetupFactory
*/
private $eavSetupFactory;
/**
- * Init
- *
+ * InitializeAttributeModels constructor.
+ * @param \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
+ * @param ModuleDataSetupInterface $moduleDataSetup
* @param EavSetupFactory $eavSetupFactory
*/
- public function __construct(EavSetupFactory $eavSetupFactory)
- {
+ public function __construct(
+ \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup,
+ EavSetupFactory $eavSetupFactory
+ ) {
$this->eavSetupFactory = $eavSetupFactory;
+ $this->moduleDataSetup = $moduleDataSetup;
}
/**
* {@inheritdoc}
*/
- public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
+ public function apply()
{
- $setup->startSetup();
+ $this->moduleDataSetup->startSetup();
/** @var \Magento\Framework\Module\Setup\Migration $migrationSetup */
- $migrationSetup = $setup->createMigrationSetup();
+ $migrationSetup = $this->moduleDataSetup->createMigrationSetup();
$migrationSetup->appendClassAliasReplace(
'eav_attribute',
@@ -70,7 +78,6 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
\Magento\Framework\Module\Setup\Migration::FIELD_CONTENT_TYPE_PLAIN,
['attribute_id']
);
-
$migrationSetup->appendClassAliasReplace(
'eav_entity_type',
'entity_model',
@@ -99,17 +106,40 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
\Magento\Framework\Module\Setup\Migration::FIELD_CONTENT_TYPE_PLAIN,
['entity_type_id']
);
-
$migrationSetup->doUpdateClassAliases();
-
/** @var \Magento\Eav\Setup\EavSetup $eavSetup */
- $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
+ $eavSetup = $this->eavSetupFactory->create([
+ 'setup' => $this->moduleDataSetup
+ ]);
$groups = $eavSetup->getAttributeGroupCollectionFactory();
foreach ($groups as $group) {
/** @var $group \Magento\Eav\Model\Entity\Attribute\Group*/
$group->save();
}
+ $this->moduleDataSetup->endSetup();
+ }
- $setup->endSetup();
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.0';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
}
}
diff --git a/app/code/Magento/Eav/Test/Unit/Model/Adminhtml/System/Config/Source/InputtypeTest.php b/app/code/Magento/Eav/Test/Unit/Model/Adminhtml/System/Config/Source/InputtypeTest.php
index 0fd50988b81..a851ab41610 100644
--- a/app/code/Magento/Eav/Test/Unit/Model/Adminhtml/System/Config/Source/InputtypeTest.php
+++ b/app/code/Magento/Eav/Test/Unit/Model/Adminhtml/System/Config/Source/InputtypeTest.php
@@ -14,12 +14,20 @@ class InputtypeTest extends \PHPUnit\Framework\TestCase
protected function setUp()
{
- $this->model = new \Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype();
+ $this->model = new \Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype(
+ $this->getOptionsArray()
+ );
}
public function testToOptionArray()
{
- $expectedResult = [
+ $expectedResult = $this->getOptionsArray();
+ $this->assertEquals($expectedResult, $this->model->toOptionArray());
+ }
+
+ private function getOptionsArray()
+ {
+ return [
['value' => 'text', 'label' => 'Text Field'],
['value' => 'textarea', 'label' => 'Text Area'],
['value' => 'texteditor', 'label' => 'Text Editor'],
@@ -28,6 +36,5 @@ public function testToOptionArray()
['value' => 'multiselect', 'label' => 'Multiple Select'],
['value' => 'select', 'label' => 'Dropdown']
];
- $this->assertEquals($expectedResult, $this->model->toOptionArray());
}
}
diff --git a/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php b/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php
index 9b0f9704887..6f9dab002aa 100644
--- a/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php
+++ b/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Eav\Test\Unit\Model\Attribute;
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
@@ -176,7 +177,7 @@ public function testSaveThrowExceptionIfAttributeSetDoesNotExist()
* Test saving throws exception if cannot save group
*
* @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage Cannot save attributeGroup
+ * @expectedExceptionMessage The attributeGroup can't be saved.
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @throws \Magento\Framework\Exception\StateException
* @return void
@@ -207,7 +208,7 @@ public function testSaveThrowExceptionIfCannotSaveGroup()
* Test saving throws exception if group does not belong to provided set
*
* @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage Attribute group does not belong to provided attribute set
+ * @expectedExceptionMessage The attribute group doesn't belong to the provided attribute set.
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @throws \Magento\Framework\Exception\StateException
* @return void
@@ -336,7 +337,7 @@ public function testGet()
* Test get throws exception if provided group does not exist
*
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage Group with id "42" does not exist.
+ * @expectedExceptionMessage The group with the "42" ID doesn't exist. Verify the ID and try again.
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @return void
*/
@@ -367,7 +368,7 @@ public function testDelete()
* Test deletion throws exception if provided group does not exist
*
* @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage Cannot delete attributeGroup with id
+ * @expectedExceptionMessage The attribute group with id "42" can't be deleted.
* @throws \Magento\Framework\Exception\StateException
* @return void
*/
diff --git a/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php b/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php
index 21697bf1e22..5b781545558 100644
--- a/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php
+++ b/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Eav\Test\Unit\Model;
use Magento\Eav\Model\AttributeManagement;
@@ -101,7 +102,7 @@ protected function setUp()
/**
*
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage AttributeSet with id "2" does not exist.
+ * @expectedExceptionMessage The AttributeSet with a "2" ID doesn't exist. Verify the attributeSet and try again.
*/
public function testAssignNoSuchEntityException()
{
@@ -128,7 +129,7 @@ public function testAssignNoSuchEntityException()
/**
*
* @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Wrong attribute set id provided
+ * @expectedExceptionMessage The attribute set ID is incorrect. Verify the ID and try again.
*/
public function testAssignInputException()
{
@@ -160,7 +161,7 @@ public function testAssignInputException()
/**
*
* @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Attribute group does not belong to attribute set
+ * @expectedExceptionMessage The attribute group doesn't belong to the attribute set.
*/
public function testAssignInputExceptionGroupInSet()
{
@@ -295,7 +296,6 @@ public function testUnassign()
/**
* @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Attribute "code" not found in attribute set 1.
*/
public function testUnassignInputException()
{
@@ -335,11 +335,15 @@ public function testUnassignInputException()
$attributeMock->expects($this->never())->method('deleteEntity');
$this->attributeManagement->unassign($attributeSetId, $attributeCode);
+
+ $this->expectExceptionMessage(
+ 'The "code" attribute wasn\'t found in the "1" attribute set. Enter the attribute and try again.'
+ );
}
/**
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage Attribute set not found: 1
+ * @expectedExceptionMessage The "1234567" attribute set wasn't found. Verify and try again.
*/
public function testUnassignWithWrongAttributeSet()
{
@@ -356,7 +360,7 @@ public function testUnassignWithWrongAttributeSet()
/**
* @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage System attribute can not be deleted
+ * @expectedExceptionMessage The system attribute can't be deleted.
*/
public function testUnassignStateException()
{
diff --git a/app/code/Magento/Eav/Test/Unit/Model/AttributeRepositoryTest.php b/app/code/Magento/Eav/Test/Unit/Model/AttributeRepositoryTest.php
index c225941c9eb..548a70e07bf 100644
--- a/app/code/Magento/Eav/Test/Unit/Model/AttributeRepositoryTest.php
+++ b/app/code/Magento/Eav/Test/Unit/Model/AttributeRepositoryTest.php
@@ -100,7 +100,7 @@ protected function setUp()
/**
* @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage entity_type_code is a required field.
+ * @expectedExceptionMessage "entity_type_code" is required. Enter and try again.
*/
public function testGetListInputException()
{
diff --git a/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php b/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php
index b7724c9cf34..04cd905d4ff 100644
--- a/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php
+++ b/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Eav\Test\Unit\Model;
use Magento\Eav\Model\AttributeSetRepository;
@@ -132,7 +133,6 @@ public function testSave()
/**
* @return void
* @expectedException \Magento\Framework\Exception\CouldNotSaveException
- * @expectedExceptionMessage There was an error saving attribute set.
*/
public function testSaveThrowsExceptionIfGivenEntityCannotBeSaved()
{
@@ -141,6 +141,11 @@ public function testSaveThrowsExceptionIfGivenEntityCannotBeSaved()
new \Exception('Some internal exception message.')
);
$this->model->save($attributeSetMock);
+
+ $this->expectExceptionMessage(
+ "The attribute set couldn't be saved due to an error. Verify your information and try again. "
+ . "If the error persists, please try again later."
+ );
}
/**
@@ -156,7 +161,6 @@ public function testDelete()
/**
* @return void
* @expectedException \Magento\Framework\Exception\CouldNotDeleteException
- * @expectedExceptionMessage There was an error deleting attribute set.
*/
public function testDeleteThrowsExceptionIfGivenEntityCannotBeDeleted()
{
@@ -165,12 +169,17 @@ public function testDeleteThrowsExceptionIfGivenEntityCannotBeDeleted()
new \Magento\Framework\Exception\CouldNotDeleteException(__('Some internal exception message.'))
);
$this->model->delete($attributeSetMock);
+
+ $this->expectExceptionMessage(
+ "The attribute set couldn't be deleted due to an error. "
+ . "Try again — if the error persists, please try again later."
+ );
}
/**
* @return void
* @expectedException \Magento\Framework\Exception\CouldNotDeleteException
- * @expectedExceptionMessage Default attribute set can not be deleted
+ * @expectedExceptionMessage The default attribute set can't be deleted.
*/
public function testDeleteThrowsExceptionIfGivenAttributeSetIsDefault()
{
diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/OptionManagementTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/OptionManagementTest.php
index 36eb78fd435..8900a22f6ab 100644
--- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/OptionManagementTest.php
+++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/OptionManagementTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Eav\Test\Unit\Model\Entity\Attribute;
class OptionManagementTest extends \PHPUnit\Framework\TestCase
@@ -85,7 +86,7 @@ public function testAdd()
/**
* @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Empty attribute code
+ * @expectedExceptionMessage The attribute code is empty. Enter the code and try again.
*/
public function testAddWithEmptyAttributeCode()
{
@@ -106,7 +107,7 @@ public function testAddWithEmptyAttributeCode()
/**
* @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage Attribute testAttribute doesn't work with options
+ * @expectedExceptionMessage The "testAttribute" attribute doesn't work with options.
*/
public function testAddWithWrongOptions()
{
@@ -139,7 +140,7 @@ public function testAddWithWrongOptions()
/**
* @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage Cannot save attribute atrCde
+ * @expectedExceptionMessage The "atrCde" attribute can't be saved.
*/
public function testAddWithCannotSaveException()
{
@@ -225,7 +226,7 @@ public function testDelete()
/**
* @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage Cannot save attribute atrCode
+ * @expectedExceptionMessage The "atrCode" attribute can't be saved.
*/
public function testDeleteWithCannotSaveException()
{
@@ -261,7 +262,7 @@ public function testDeleteWithCannotSaveException()
/**
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage Attribute atrCode does not contain option with Id option
+ * @expectedExceptionMessage The "atrCode" attribute doesn't include an option with "option" ID.
*/
public function testDeleteWithWrongOption()
{
@@ -290,7 +291,7 @@ public function testDeleteWithWrongOption()
/**
* @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage Attribute atrCode doesn't have any option
+ * @expectedExceptionMessage The "atrCode" attribute has no option.
*/
public function testDeleteWithAbsentOption()
{
@@ -315,7 +316,7 @@ public function testDeleteWithAbsentOption()
/**
* @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Empty attribute code
+ * @expectedExceptionMessage The attribute code is empty. Enter the code and try again.
*/
public function testDeleteWithEmptyAttributeCode()
{
@@ -348,7 +349,7 @@ public function testGetItems()
/**
* @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage Cannot load options for attribute atrCode
+ * @expectedExceptionMessage The options for "atrCode" attribute can't be loaded.
*/
public function testGetItemsWithCannotLoadException()
{
@@ -371,7 +372,7 @@ public function testGetItemsWithCannotLoadException()
/**
* @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Empty attribute code
+ * @expectedExceptionMessage The attribute code is empty. Enter the code and try again.
*/
public function testGetItemsWithEmptyAttributeCode()
{
diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/SetTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/SetTest.php
index 78465e57c62..79f601b154b 100644
--- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/SetTest.php
+++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/SetTest.php
@@ -65,8 +65,8 @@ public function testValidateWithNonexistentValidName()
public function invalidAttributeSetDataProvider()
{
return [
- ['', 'Attribute set name is empty.'],
- ['existing_name', 'An attribute set named "existing_name" already exists.']
+ ['', 'The attribute set name is empty. Enter the name and try again.'],
+ ['existing_name', 'A "existing_name" attribute set name already exists. Create a new name and try again.']
];
}
}
diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/GetCustomAttributeCodesTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/GetCustomAttributeCodesTest.php
new file mode 100644
index 00000000000..0ba247e1fbb
--- /dev/null
+++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/GetCustomAttributeCodesTest.php
@@ -0,0 +1,59 @@
+getCustomAttributeCodes = new GetCustomAttributeCodes();
+ }
+
+ /**
+ * Test GetCustomAttributeCodes::execute() will return attribute codes from attributes metadata.
+ *
+ * @return void
+ */
+ public function testExecute()
+ {
+ $attributeCode = 'testCode';
+ $attributeMetadata = $this->getMockBuilder(MetadataObjectInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getAttributeCode'])
+ ->getMockForAbstractClass();
+ $attributeMetadata->expects($this->once())
+ ->method('getAttributeCode')
+ ->willReturn($attributeCode);
+ /** @var MetadataServiceInterface|\PHPUnit_Framework_MockObject_MockObject $metadataService */
+ $metadataService = $this->getMockBuilder(MetadataServiceInterface::class)
+ ->setMethods(['getCustomAttributesMetadata'])
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
+ $metadataService->expects($this->once())
+ ->method('getCustomAttributesMetadata')
+ ->willReturn([$attributeMetadata]);
+ $this->assertEquals([$attributeCode], $this->getCustomAttributeCodes->execute($metadataService));
+ }
+}
diff --git a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/CollectionTest.php b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/CollectionTest.php
new file mode 100644
index 00000000000..138e1363bb6
--- /dev/null
+++ b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/CollectionTest.php
@@ -0,0 +1,158 @@
+entityFactoryMock = $this->getMockBuilder(\Magento\Framework\Data\Collection\EntityFactory::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->fetchStrategyMock = $this->getMockBuilder(FetchStrategyInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->eventManagerMock = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->eavConfigMock = $this->getMockBuilder(\Magento\Eav\Model\Config::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\Pdo\Mysql::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->resourceMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class)
+ ->setMethods(['__wakeup', 'getConnection', 'getMainTable', 'getTable'])
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
+
+ $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock);
+ $this->resourceMock->expects($this->any())->method('getMainTable')->willReturn('eav_entity_attribute');
+
+ $this->selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->connectionMock->expects($this->any())->method('select')->willReturn($this->selectMock);
+
+ $objectManager = new ObjectManager($this);
+ $this->model = $objectManager->getObject(
+ \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection::class,
+ [
+ 'entityFactory' => $this->entityFactoryMock,
+ 'logger' => $this->loggerMock,
+ 'fetchStrategy' => $this->fetchStrategyMock,
+ 'eventManager' => $this->eventManagerMock,
+ 'eavConfig' => $this->eavConfigMock,
+ 'connection' => $this->connectionMock,
+ 'resource' => $this->resourceMock,
+ ]
+ );
+ }
+
+ /**
+ * Test method \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection::setInAllAttributeSetsFilter
+ *
+ * @return void
+ */
+ public function testSetInAllAttributeSetsFilter()
+ {
+ $setIds = [1, 2, 3];
+
+ $this->selectMock->expects($this->atLeastOnce())
+ ->method('where')
+ ->with('entity_attribute.attribute_set_id IN (?)', $setIds)
+ ->willReturnSelf();
+ $this->selectMock->expects($this->atLeastOnce())->method('join')->with(
+ ['entity_attribute' => $this->model->getTable('eav_entity_attribute')],
+ 'entity_attribute.attribute_id = main_table.attribute_id',
+ ['count' => new \Zend_Db_Expr('COUNT(*)')]
+ )->willReturnSelf();
+
+ $this->selectMock->expects($this->atLeastOnce())->method('group')->with('entity_attribute.attribute_id')
+ ->willReturnSelf();
+
+ $this->selectMock->expects($this->atLeastOnce())->method('having')->with('count = ' . count($setIds))
+ ->willReturnSelf();
+
+ $this->model->setInAllAttributeSetsFilter($setIds);
+ }
+}
diff --git a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/SetTest.php b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/SetTest.php
index 1c66788f858..4c2ede60c87 100644
--- a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/SetTest.php
+++ b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/SetTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Eav\Test\Unit\Model\ResourceModel\Entity\Attribute;
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set;
@@ -116,7 +117,7 @@ protected function setUp()
/**
* @expectedException \Magento\Framework\Exception\StateException
- * @expectedExceptionMessage Default attribute set can not be deleted
+ * @expectedExceptionMessage The default attribute set can't be deleted.
* @return void
*/
public function testBeforeDeleteStateException()
diff --git a/app/code/Magento/Eav/etc/adminhtml/di.xml b/app/code/Magento/Eav/etc/adminhtml/di.xml
new file mode 100644
index 00000000000..7e8e13465b1
--- /dev/null
+++ b/app/code/Magento/Eav/etc/adminhtml/di.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+ -
+
- text
+ - Text Field
+
+ -
+
- textarea
+ - Text Area
+
+ -
+
- texteditor
+ - Text Editor
+
+ -
+
- date
+ - Date
+
+ -
+
- boolean
+ - Yes/No
+
+ -
+
- multiselect
+ - Multiple Select
+
+ -
+
- select
+ - Dropdown
+
+
+
+
+
diff --git a/app/code/Magento/Eav/etc/db_schema.xml b/app/code/Magento/Eav/etc/db_schema.xml
index 3acd1c28f08..24a9d405dd7 100644
--- a/app/code/Magento/Eav/etc/db_schema.xml
+++ b/app/code/Magento/Eav/etc/db_schema.xml
@@ -6,7 +6,7 @@
*/
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
diff --git a/app/code/Magento/Eav/etc/di.xml b/app/code/Magento/Eav/etc/di.xml
index 8e897b979d2..ae4663cfc23 100644
--- a/app/code/Magento/Eav/etc/di.xml
+++ b/app/code/Magento/Eav/etc/di.xml
@@ -8,6 +8,7 @@
+
diff --git a/app/code/Magento/Eav/etc/module.xml b/app/code/Magento/Eav/etc/module.xml
index acd5807a29f..7b2b651b2d2 100644
--- a/app/code/Magento/Eav/etc/module.xml
+++ b/app/code/Magento/Eav/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/EavGraphQl/etc/module.xml b/app/code/Magento/EavGraphQl/etc/module.xml
index b61215e8368..795acfaf647 100644
--- a/app/code/Magento/EavGraphQl/etc/module.xml
+++ b/app/code/Magento/EavGraphQl/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/Email/Model/AbstractTemplate.php b/app/code/Magento/Email/Model/AbstractTemplate.php
index e6a2f74a0d1..4830ecfbb74 100644
--- a/app/code/Magento/Email/Model/AbstractTemplate.php
+++ b/app/code/Magento/Email/Model/AbstractTemplate.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Email\Model;
use Magento\Framework\App\Filesystem\DirectoryList;
@@ -535,7 +536,7 @@ protected function cancelDesignConfig()
public function setForcedArea($templateId)
{
if ($this->area) {
- throw new \LogicException(__('Area is already set'));
+ throw new \LogicException(__('The area is already set.'));
}
$this->area = $this->emailConfig->getTemplateArea($templateId);
return $this;
@@ -605,7 +606,9 @@ public function getDesignConfig()
public function setDesignConfig(array $config)
{
if (!isset($config['area']) || !isset($config['store'])) {
- throw new LocalizedException(__('Design config must have area and store.'));
+ throw new LocalizedException(
+ __('The design config needs an area and a store. Verify that both are set and try again.')
+ );
}
$this->getDesignConfig()->setData($config);
return $this;
diff --git a/app/code/Magento/Email/etc/db_schema.xml b/app/code/Magento/Email/etc/db_schema.xml
index 937cdefa5d7..53ef349a383 100644
--- a/app/code/Magento/Email/etc/db_schema.xml
+++ b/app/code/Magento/Email/etc/db_schema.xml
@@ -6,7 +6,7 @@
*/
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
diff --git a/app/code/Magento/Email/etc/module.xml b/app/code/Magento/Email/etc/module.xml
index e3e0632c641..60c11ad2f0d 100644
--- a/app/code/Magento/Email/etc/module.xml
+++ b/app/code/Magento/Email/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/Email/view/adminhtml/ui_component/design_config_form.xml b/app/code/Magento/Email/view/adminhtml/ui_component/design_config_form.xml
index b63f7923338..91c38c92dc7 100644
--- a/app/code/Magento/Email/view/adminhtml/ui_component/design_config_form.xml
+++ b/app/code/Magento/Email/view/adminhtml/ui_component/design_config_form.xml
@@ -15,12 +15,12 @@
- Allowed file types: jpg, jpeg, gif, png. To optimize logo for high-resolution displays, upload an image that is 3x normal size and then specify 1x dimensions in the width/height fields below.
+ To optimize logo for high-resolution displays, upload an image that is 3x normal size and then specify 1x dimensions in the width/height fields below.
- fileUploader
+ imageUploader
-
+
jpg jpeg gif png
2097152
@@ -28,7 +28,7 @@
theme/design_config_fileUploader/save
-
+
diff --git a/app/code/Magento/EncryptionKey/etc/module.xml b/app/code/Magento/EncryptionKey/etc/module.xml
index 48ab3e51ba0..1a70ce0ddfb 100644
--- a/app/code/Magento/EncryptionKey/etc/module.xml
+++ b/app/code/Magento/EncryptionKey/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/Fedex/Setup/InstallData.php b/app/code/Magento/Fedex/Setup/Patch/Data/ConfigureFedexDefaults.php
similarity index 76%
rename from app/code/Magento/Fedex/Setup/InstallData.php
rename to app/code/Magento/Fedex/Setup/Patch/Data/ConfigureFedexDefaults.php
index 1591aaa3abf..c4e41ad7229 100644
--- a/app/code/Magento/Fedex/Setup/InstallData.php
+++ b/app/code/Magento/Fedex/Setup/Patch/Data/ConfigureFedexDefaults.php
@@ -4,24 +4,34 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Fedex\Setup;
+namespace Magento\Fedex\Setup\Patch\Data;
-use Magento\Framework\Setup\InstallDataInterface;
-use Magento\Framework\Setup\ModuleContextInterface;
-use Magento\Framework\Setup\ModuleDataSetupInterface;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\Setup\Patch\DataPatchInterface;
+use Magento\Framework\Setup\Patch\PatchVersionInterface;
-/**
- * Class InstallData
- * @SuppressWarnings(PHPMD.CyclomaticComplexity)
- * @codeCoverageIgnore
- */
-class InstallData implements InstallDataInterface
+class ConfigureFedexDefaults implements DataPatchInterface, PatchVersionInterface
{
+ /**
+ * @var \Magento\Framework\Setup\ModuleDataSetupInterface
+ */
+ private $moduleDataSetup;
+
+ /**
+ * ConfigureFedexDefaults constructor.
+ * @param \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
+ */
+ public function __construct(
+ \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
+ ) {
+ $this->moduleDataSetup = $moduleDataSetup;
+ }
+
/**
* {@inheritdoc}
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
- public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
+ public function apply()
{
$codes = [
'method' => [
@@ -64,10 +74,8 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
],
];
- $installer = $setup;
- $configDataTable = $installer->getTable('core_config_data');
- $conn = $installer->getConnection();
-
+ $conn = $this->moduleDataSetup->getConnection();
+ $configDataTable = $this->moduleDataSetup->getTable('core_config_data');
$select = $conn->select()->from(
$configDataTable
)->where(
@@ -100,11 +108,34 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
} else {
continue;
}
-
if (!empty($mapNew) && $mapNew != $mapOld['value']) {
$whereConfigId = $conn->quoteInto('config_id = ?', $mapOld['config_id']);
$conn->update($configDataTable, ['value' => $mapNew], $whereConfigId);
}
}
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.0';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
}
diff --git a/app/code/Magento/Fedex/etc/module.xml b/app/code/Magento/Fedex/etc/module.xml
index 8e7afc1c507..7eec2b39bb2 100644
--- a/app/code/Magento/Fedex/etc/module.xml
+++ b/app/code/Magento/Fedex/etc/module.xml
@@ -6,6 +6,6 @@
*/
-->
-
+
diff --git a/app/code/Magento/Framework/Test/Unit/Setup/SchemaPersistorTest.php b/app/code/Magento/Framework/Test/Unit/Setup/SchemaPersistorTest.php
index 94dfc50036c..56f04f4c7ba 100644
--- a/app/code/Magento/Framework/Test/Unit/Setup/SchemaPersistorTest.php
+++ b/app/code/Magento/Framework/Test/Unit/Setup/SchemaPersistorTest.php
@@ -145,7 +145,7 @@ public function schemaListenerTablesDataProvider()
],
'XMLResult' => '
+ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
diff --git a/app/code/Magento/GiftMessage/Model/CartRepository.php b/app/code/Magento/GiftMessage/Model/CartRepository.php
index eeab05f01d0..f6577d1e123 100644
--- a/app/code/Magento/GiftMessage/Model/CartRepository.php
+++ b/app/code/Magento/GiftMessage/Model/CartRepository.php
@@ -101,15 +101,15 @@ public function save($cartId, \Magento\GiftMessage\Api\Data\MessageInterface $gi
$quote = $this->quoteRepository->getActive($cartId);
if (0 == $quote->getItemsCount()) {
- throw new InputException(__('Gift Messages are not applicable for empty cart'));
+ throw new InputException(__("Gift messages can't be used for an empty cart. Add an item and try again."));
}
if ($quote->isVirtual()) {
- throw new InvalidTransitionException(__('Gift Messages are not applicable for virtual products'));
+ throw new InvalidTransitionException(__("Gift messages can't be used for virtual products."));
}
$messageText = $giftMessage->getMessage();
if ($messageText && !$this->helper->isMessagesAllowed('quote', $quote, $this->storeManager->getStore())) {
- throw new CouldNotSaveException(__('Gift Message is not available'));
+ throw new CouldNotSaveException(__("The gift message isn't available."));
}
$this->giftMessageManager->setMessage($quote, 'quote', $giftMessage);
return true;
diff --git a/app/code/Magento/GiftMessage/Model/GiftMessageManager.php b/app/code/Magento/GiftMessage/Model/GiftMessageManager.php
index e01da4c5262..605fd221462 100644
--- a/app/code/Magento/GiftMessage/Model/GiftMessageManager.php
+++ b/app/code/Magento/GiftMessage/Model/GiftMessageManager.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\GiftMessage\Model;
use Magento\Framework\Exception\CouldNotSaveException;
@@ -98,7 +99,7 @@ public function add($giftMessages, $quote)
* @param \Magento\GiftMessage\Api\Data\MessageInterface $giftMessage The gift message.
* @param null|int $entityId The entity ID.
* @return void
- * @throws \Magento\Framework\Exception\CouldNotSaveException The specified gift message is not available.
+ * @throws \Magento\Framework\Exception\CouldNotSaveException The gift message isn't available.
*/
public function setMessage(\Magento\Quote\Model\Quote $quote, $type, $giftMessage, $entityId = null)
{
@@ -111,7 +112,7 @@ public function setMessage(\Magento\Quote\Model\Quote $quote, $type, $giftMessag
try {
$this->add($message, $quote);
} catch (\Exception $e) {
- throw new CouldNotSaveException(__('Could not add gift message to shopping cart'));
+ throw new CouldNotSaveException(__("The gift message couldn't be added to Cart."));
}
}
}
diff --git a/app/code/Magento/GiftMessage/Model/ItemRepository.php b/app/code/Magento/GiftMessage/Model/ItemRepository.php
index 6d369e083b1..3c62a489af4 100644
--- a/app/code/Magento/GiftMessage/Model/ItemRepository.php
+++ b/app/code/Magento/GiftMessage/Model/ItemRepository.php
@@ -85,7 +85,9 @@ public function get($cartId, $itemId)
*/
$quote = $this->quoteRepository->getActive($cartId);
if (!$item = $quote->getItemById($itemId)) {
- throw new NoSuchEntityException(__('There is no item with provided id in the cart'));
+ throw new NoSuchEntityException(
+ __('No item with the provided ID was found in the Cart. Verify the ID and try again.')
+ );
};
$messageId = $item->getGiftMessageId();
if (!$messageId) {
@@ -114,16 +116,19 @@ public function save($cartId, \Magento\GiftMessage\Api\Data\MessageInterface $gi
if (!$item = $quote->getItemById($itemId)) {
throw new NoSuchEntityException(
- __('There is no product with provided itemId: %1 in the cart', $itemId)
+ __(
+ 'No product with the "%1" itemId exists in the Cart. Verify your information and try again.',
+ $itemId
+ )
);
};
if ($item->getIsVirtual()) {
- throw new InvalidTransitionException(__('Gift Messages are not applicable for virtual products'));
+ throw new InvalidTransitionException(__('Gift messages can\'t be used for virtual products.'));
}
$messageText = $giftMessage->getMessage();
if ($messageText && !$this->helper->isMessagesAllowed('items', $quote, $this->storeManager->getStore())) {
- throw new CouldNotSaveException(__('Gift Message is not available'));
+ throw new CouldNotSaveException(__("The gift message isn't available."));
}
$this->giftMessageManager->setMessage($quote, 'quote_item', $giftMessage, $itemId);
return true;
diff --git a/app/code/Magento/GiftMessage/Model/OrderItemRepository.php b/app/code/Magento/GiftMessage/Model/OrderItemRepository.php
index 4be7483dfe6..943552e2b75 100644
--- a/app/code/Magento/GiftMessage/Model/OrderItemRepository.php
+++ b/app/code/Magento/GiftMessage/Model/OrderItemRepository.php
@@ -86,18 +86,25 @@ public function get($orderId, $orderItemId)
{
/** @var \Magento\Sales\Api\Data\OrderItemInterface $orderItem */
if (!$orderItem = $this->getItemById($orderId, $orderItemId)) {
- throw new NoSuchEntityException(__('There is no item with provided id in the order'));
+ throw new NoSuchEntityException(
+ __('No item with the provided ID was found in the Order. Verify the ID and try again.')
+ );
};
if (!$this->helper->isMessagesAllowed('order_item', $orderItem, $this->storeManager->getStore())) {
throw new NoSuchEntityException(
- __('There is no item with provided id in the order or gift message isn\'t allowed')
+ __(
+ "No item with the provided ID was found in the Order, or a gift message isn't allowed. "
+ . "Verify and try again."
+ )
);
}
$messageId = $orderItem->getGiftMessageId();
if (!$messageId) {
- throw new NoSuchEntityException(__('There is no item with provided id in the order'));
+ throw new NoSuchEntityException(
+ __('No item with the provided ID was found in the Order. Verify the ID and try again.')
+ );
}
return $this->messageFactory->create()->load($messageId);
@@ -113,14 +120,16 @@ public function save($orderId, $orderItemId, \Magento\GiftMessage\Api\Data\Messa
/** @var \Magento\Sales\Api\Data\OrderItemInterface $orderItem */
if (!$orderItem = $this->getItemById($orderId, $orderItemId)) {
- throw new NoSuchEntityException(__('There is no item with provided id in the order'));
+ throw new NoSuchEntityException(
+ __('No item with the provided ID was found in the Order. Verify the ID and try again.')
+ );
};
if ($order->getIsVirtual()) {
- throw new InvalidTransitionException(__('Gift Messages are not applicable for virtual products'));
+ throw new InvalidTransitionException(__("Gift messages can't be used for virtual products."));
}
if (!$this->helper->isMessagesAllowed('order_item', $orderItem, $this->storeManager->getStore())) {
- throw new CouldNotSaveException(__('Gift Message is not available'));
+ throw new CouldNotSaveException(__("The gift message isn't available."));
}
$message = [];
@@ -136,7 +145,10 @@ public function save($orderId, $orderItemId, \Magento\GiftMessage\Api\Data\Messa
$this->giftMessageSaveModel->saveAllInOrder();
unset($this->orders[$orderId]);
} catch (\Exception $e) {
- throw new CouldNotSaveException(__('Could not add gift message to order: "%1"', $e->getMessage()), $e);
+ throw new CouldNotSaveException(
+ __('The gift message couldn\'t be added to the "%1" order.', $e->getMessage()),
+ $e
+ );
}
return true;
}
diff --git a/app/code/Magento/GiftMessage/Model/OrderRepository.php b/app/code/Magento/GiftMessage/Model/OrderRepository.php
index 1960281367e..abf38f1287b 100644
--- a/app/code/Magento/GiftMessage/Model/OrderRepository.php
+++ b/app/code/Magento/GiftMessage/Model/OrderRepository.php
@@ -83,13 +83,15 @@ public function get($orderId)
if (!$this->helper->isMessagesAllowed('order', $order, $this->storeManager->getStore())) {
throw new NoSuchEntityException(
- __('There is no order with provided id or gift message isn\'t allowed')
+ __("Either no order exists with this ID or gift message isn't allowed.")
);
}
$messageId = $order->getGiftMessageId();
if (!$messageId) {
- throw new NoSuchEntityException(__('There is no item with provided id in the order'));
+ throw new NoSuchEntityException(
+ __('No item with the provided ID was found in the Order. Verify the ID and try again.')
+ );
}
return $this->messageFactory->create()->load($messageId);
@@ -103,18 +105,20 @@ public function save($orderId, \Magento\GiftMessage\Api\Data\MessageInterface $g
/** @var \Magento\Sales\Api\Data\OrderInterface $order */
$order = $this->orderFactory->create()->load($orderId);
if (!$order->getEntityId()) {
- throw new NoSuchEntityException(__('There is no order with provided id'));
+ throw new NoSuchEntityException(__('No order exists with this ID. Verify your information and try again.'));
};
if (0 == $order->getTotalItemCount()) {
- throw new InputException(__('Gift Messages are not applicable for empty order'));
+ throw new InputException(
+ __("Gift messages can't be used for an empty order. Create an order, add an item, and try again.")
+ );
}
if ($order->getIsVirtual()) {
- throw new InvalidTransitionException(__('Gift Messages are not applicable for virtual products'));
+ throw new InvalidTransitionException(__("Gift messages can't be used for virtual products."));
}
if (!$this->helper->isMessagesAllowed('order', $order, $this->storeManager->getStore())) {
- throw new CouldNotSaveException(__('Gift Message is not available'));
+ throw new CouldNotSaveException(__("The gift message isn't available."));
}
$message = [];
@@ -130,7 +134,10 @@ public function save($orderId, \Magento\GiftMessage\Api\Data\MessageInterface $g
try {
$this->giftMessageSaveModel->saveAllInOrder();
} catch (\Exception $e) {
- throw new CouldNotSaveException(__('Could not add gift message to order: "%1"', $e->getMessage()), $e);
+ throw new CouldNotSaveException(
+ __('The gift message couldn\'t be added to the "%1" order.', $e->getMessage()),
+ $e
+ );
}
return true;
}
diff --git a/app/code/Magento/GiftMessage/Model/Plugin/OrderSave.php b/app/code/Magento/GiftMessage/Model/Plugin/OrderSave.php
index 260780828fa..8cddc0582f1 100644
--- a/app/code/Magento/GiftMessage/Model/Plugin/OrderSave.php
+++ b/app/code/Magento/GiftMessage/Model/Plugin/OrderSave.php
@@ -74,7 +74,7 @@ protected function saveOrderGiftMessage(\Magento\Sales\Api\Data\OrderInterface $
$this->giftMessageOrderRepository->save($order->getEntityId(), $giftMessage);
} catch (\Exception $e) {
throw new CouldNotSaveException(
- __('Could not add gift message to order: "%1"', $e->getMessage()),
+ __('The gift message couldn\'t be added to the "%1" order.', $e->getMessage()),
$e
);
}
@@ -109,7 +109,7 @@ protected function saveOrderItemGiftMessage(\Magento\Sales\Api\Data\OrderInterfa
);
} catch (\Exception $e) {
throw new CouldNotSaveException(
- __('Could not add gift message to order\'s item: "%1"', $e->getMessage()),
+ __('The gift message couldn\'t be added to the "%1" order item.', $e->getMessage()),
$e
);
}
diff --git a/app/code/Magento/GiftMessage/Setup/InstallData.php b/app/code/Magento/GiftMessage/Setup/Patch/Data/AddGiftMessageAttributes.php
similarity index 75%
rename from app/code/Magento/GiftMessage/Setup/InstallData.php
rename to app/code/Magento/GiftMessage/Setup/Patch/Data/AddGiftMessageAttributes.php
index cc181bce56d..bbaa9a883d8 100644
--- a/app/code/Magento/GiftMessage/Setup/InstallData.php
+++ b/app/code/Magento/GiftMessage/Setup/Patch/Data/AddGiftMessageAttributes.php
@@ -4,54 +4,51 @@
* See COPYING.txt for license details.
*/
-namespace Magento\GiftMessage\Setup;
+namespace Magento\GiftMessage\Setup\Patch\Data;
use Magento\Catalog\Setup\CategorySetupFactory;
-use Magento\Framework\Setup\InstallDataInterface;
-use Magento\Framework\Setup\ModuleContextInterface;
-use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Quote\Setup\QuoteSetupFactory;
use Magento\Sales\Setup\SalesSetupFactory;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\Setup\Patch\DataPatchInterface;
+use Magento\Framework\Setup\Patch\PatchVersionInterface;
-/**
- * @codeCoverageIgnore
- * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
- */
-class InstallData implements InstallDataInterface
+class AddGiftMessageAttributes implements DataPatchInterface, PatchVersionInterface
{
/**
- * Category setup factory
- *
+ * @var \Magento\Framework\Setup\ModuleDataSetupInterface
+ */
+ private $moduleDataSetup;
+
+ /**
* @var CategorySetupFactory
*/
- protected $categorySetupFactory;
+ private $categorySetupFactory;
/**
- * Quote setup factory
- *
* @var QuoteSetupFactory
*/
- protected $quoteSetupFactory;
+ private $quoteSetupFactory;
/**
- * Sales setup factory
- *
* @var SalesSetupFactory
*/
- protected $salesSetupFactory;
+ private $salesSetupFactory;
/**
- * Init
- *
+ * AddGiftMessageAttributes constructor.
+ * @param \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
* @param CategorySetupFactory $categorySetupFactory
* @param QuoteSetupFactory $quoteSetupFactory
* @param SalesSetupFactory $salesSetupFactory
*/
public function __construct(
+ \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup,
CategorySetupFactory $categorySetupFactory,
QuoteSetupFactory $quoteSetupFactory,
SalesSetupFactory $salesSetupFactory
) {
+ $this->moduleDataSetup = $moduleDataSetup;
$this->categorySetupFactory = $categorySetupFactory;
$this->quoteSetupFactory = $quoteSetupFactory;
$this->salesSetupFactory = $salesSetupFactory;
@@ -60,7 +57,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
- public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
+ public function apply()
{
/**
* Add 'gift_message_id' attributes for entities
@@ -68,22 +65,21 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
$options = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, 'visible' => false, 'required' => false];
$entities = ['quote', 'quote_address', 'quote_item', 'quote_address_item'];
/** @var \Magento\Quote\Setup\QuoteSetup $quoteSetup */
- $quoteSetup = $this->quoteSetupFactory->create(['setup' => $setup]);
+ $quoteSetup = $this->quoteSetupFactory->create(['setup' => $this->moduleDataSetup]);
foreach ($entities as $entity) {
$quoteSetup->addAttribute($entity, 'gift_message_id', $options);
}
/** @var \Magento\Sales\Setup\SalesSetup $salesSetup */
- $salesSetup = $this->salesSetupFactory->create(['setup' => $setup]);
+ $salesSetup = $this->salesSetupFactory->create(['setup' => $this->moduleDataSetup]);
$salesSetup->addAttribute('order', 'gift_message_id', $options);
$salesSetup->addAttribute('order_item', 'gift_message_id', $options);
/**
* Add 'gift_message_available' attributes for entities
*/
$salesSetup->addAttribute('order_item', 'gift_message_available', $options);
-
/** @var \Magento\Catalog\Setup\CategorySetup $catalogSetup */
- $catalogSetup = $this->categorySetupFactory->create(['setup' => $setup]);
+ $catalogSetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
$catalogSetup->addAttribute(
\Magento\Catalog\Model\Product::ENTITY,
'gift_message_available',
@@ -108,11 +104,9 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
'is_filterable_in_grid' => false,
]
);
-
$groupName = 'Autosettings';
$entityTypeId = $catalogSetup->getEntityTypeId(\Magento\Catalog\Model\Product::ENTITY);
$attributeSetId = $catalogSetup->getAttributeSetId($entityTypeId, 'Default');
-
$attribute = $catalogSetup->getAttribute($entityTypeId, 'gift_message_available');
if ($attribute) {
$catalogSetup->addAttributeToGroup(
@@ -124,4 +118,28 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
);
}
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.0';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
}
diff --git a/app/code/Magento/GiftMessage/Setup/Patch/Data/MoveGiftMessageToGiftOptionsGroup.php b/app/code/Magento/GiftMessage/Setup/Patch/Data/MoveGiftMessageToGiftOptionsGroup.php
new file mode 100644
index 00000000000..1f2c533a978
--- /dev/null
+++ b/app/code/Magento/GiftMessage/Setup/Patch/Data/MoveGiftMessageToGiftOptionsGroup.php
@@ -0,0 +1,96 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->categorySetupFactory = $categorySetupFactory;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ $this->moduleDataSetup->getConnection()->startSetup();
+
+ /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
+ $categorySetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
+ $entityTypeId = $categorySetup->getEntityTypeId(Product::ENTITY);
+ $attributeSetId = $categorySetup->getDefaultAttributeSetId(Product::ENTITY);
+ $attribute = $categorySetup->getAttribute($entityTypeId, 'gift_message_available');
+
+ $groupName = 'Gift Options';
+
+ if (!$categorySetup->getAttributeGroup(Product::ENTITY, $attributeSetId, $groupName)) {
+ $categorySetup->addAttributeGroup(Product::ENTITY, $attributeSetId, $groupName, 60);
+ }
+ $categorySetup->addAttributeToGroup(
+ $entityTypeId,
+ $attributeSetId,
+ $groupName,
+ $attribute['attribute_id'],
+ 10
+ );
+ $this->moduleDataSetup->getConnection()->endSetup();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+ AddGiftMessageAttributes::class,
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.1';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/GiftMessage/Setup/Patch/Data/UpdateGiftMessageAttribute.php b/app/code/Magento/GiftMessage/Setup/Patch/Data/UpdateGiftMessageAttribute.php
new file mode 100644
index 00000000000..dacd86a05c6
--- /dev/null
+++ b/app/code/Magento/GiftMessage/Setup/Patch/Data/UpdateGiftMessageAttribute.php
@@ -0,0 +1,89 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->categorySetupFactory = $categorySetupFactory;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ $this->moduleDataSetup->getConnection()->startSetup();
+
+ /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
+ $categorySetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
+ $entityTypeId = $categorySetup->getEntityTypeId(Product::ENTITY);
+ $attribute = $categorySetup->getAttribute($entityTypeId, 'gift_message_available');
+ $categorySetup->updateAttribute(
+ $entityTypeId,
+ $attribute['attribute_id'],
+ 'source_model',
+ \Magento\Catalog\Model\Product\Attribute\Source\Boolean::class
+ );
+ $this->moduleDataSetup->getConnection()->endSetup();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+ MoveGiftMessageToGiftOptionsGroup::class
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.1.0';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/GiftMessage/Setup/UpgradeData.php b/app/code/Magento/GiftMessage/Setup/UpgradeData.php
deleted file mode 100644
index 36ceb949616..00000000000
--- a/app/code/Magento/GiftMessage/Setup/UpgradeData.php
+++ /dev/null
@@ -1,71 +0,0 @@
-categorySetupFactory = $categorySetupFactory;
- }
-
- /**
- * {@inheritdoc}
- */
- public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
- {
- $setup->startSetup();
-
- /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
- $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
- $entityTypeId = $categorySetup->getEntityTypeId(Product::ENTITY);
- $attributeSetId = $categorySetup->getDefaultAttributeSetId(Product::ENTITY);
- $attribute = $categorySetup->getAttribute($entityTypeId, 'gift_message_available');
-
- if (version_compare($context->getVersion(), '2.0.1', '<')) {
- $groupName = 'Gift Options';
-
- if (!$categorySetup->getAttributeGroup(Product::ENTITY, $attributeSetId, $groupName)) {
- $categorySetup->addAttributeGroup(Product::ENTITY, $attributeSetId, $groupName, 60);
- }
-
- $categorySetup->addAttributeToGroup(
- $entityTypeId,
- $attributeSetId,
- $groupName,
- $attribute['attribute_id'],
- 10
- );
- }
-
- if (version_compare($context->getVersion(), '2.1.0', '<')) {
- $categorySetup->updateAttribute(
- $entityTypeId,
- $attribute['attribute_id'],
- 'source_model',
- \Magento\Catalog\Model\Product\Attribute\Source\Boolean::class
- );
- }
-
- $setup->endSetup();
- }
-}
diff --git a/app/code/Magento/GiftMessage/Test/Unit/Model/CartRepositoryTest.php b/app/code/Magento/GiftMessage/Test/Unit/Model/CartRepositoryTest.php
index b013b4a6de7..e41cb485501 100644
--- a/app/code/Magento/GiftMessage/Test/Unit/Model/CartRepositoryTest.php
+++ b/app/code/Magento/GiftMessage/Test/Unit/Model/CartRepositoryTest.php
@@ -4,6 +4,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\GiftMessage\Test\Unit\Model;
use Magento\GiftMessage\Model\CartRepository;
@@ -134,7 +135,7 @@ public function testGet()
/**
* @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Gift Messages are not applicable for empty cart
+ * @expectedExceptionMessage Gift messages can't be used for an empty cart. Add an item and try again.
*/
public function testSaveWithInputException()
{
@@ -144,7 +145,7 @@ public function testSaveWithInputException()
/**
* @expectedException \Magento\Framework\Exception\State\InvalidTransitionException
- * @expectedExceptionMessage Gift Messages are not applicable for virtual products
+ * @expectedExceptionMessage Gift messages can't be used for virtual products.
*/
public function testSaveWithInvalidTransitionException()
{
diff --git a/app/code/Magento/GiftMessage/Test/Unit/Model/GiftMessageManagerTest.php b/app/code/Magento/GiftMessage/Test/Unit/Model/GiftMessageManagerTest.php
index a70a946e77f..5956a4f5a1f 100644
--- a/app/code/Magento/GiftMessage/Test/Unit/Model/GiftMessageManagerTest.php
+++ b/app/code/Magento/GiftMessage/Test/Unit/Model/GiftMessageManagerTest.php
@@ -312,7 +312,7 @@ public function testAddWithQuoteAddressItem()
/**
* @expectedException \Magento\Framework\Exception\CouldNotSaveException
- * @expectedExceptionMessage Could not add gift message to shopping cart
+ * @expectedExceptionMessage The gift message couldn't be added to Cart.
*/
public function testSetMessageCouldNotAddGiftMessageException()
{
diff --git a/app/code/Magento/GiftMessage/Test/Unit/Model/GuestItemRepositoryTest.php b/app/code/Magento/GiftMessage/Test/Unit/Model/GuestItemRepositoryTest.php
index f9985a1f92d..fab9f961f1e 100644
--- a/app/code/Magento/GiftMessage/Test/Unit/Model/GuestItemRepositoryTest.php
+++ b/app/code/Magento/GiftMessage/Test/Unit/Model/GuestItemRepositoryTest.php
@@ -4,6 +4,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\GiftMessage\Test\Unit\Model;
use Magento\GiftMessage\Model\ItemRepository;
@@ -115,7 +116,7 @@ protected function setUp()
/**
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage There is no item with provided id in the cart
+ * @expectedExceptionMessage No item with the provided ID was found in the Cart. Verify the ID and try again.
*/
public function testGetWithNoSuchEntityException()
{
@@ -163,20 +164,22 @@ public function testGet()
/**
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage There is no product with provided itemId: 1 in the cart
*/
public function testSaveWithNoSuchEntityException()
{
$itemId = 1;
$this->quoteMock->expects($this->once())->method('getItemById')->with($itemId)->will($this->returnValue(null));
-
$this->itemRepository->save($this->cartId, $this->messageMock, $itemId);
+
+ $this->expectExceptionMessage(
+ 'No product with the "1" itemId exists in the Cart. Verify your information and try again.'
+ );
}
/**
* @expectedException \Magento\Framework\Exception\State\InvalidTransitionException
- * @expectedExceptionMessage Gift Messages are not applicable for virtual products
+ * @expectedExceptionMessage Gift messages can't be used for virtual products.
*/
public function testSaveWithInvalidTransitionException()
{
diff --git a/app/code/Magento/GiftMessage/Test/Unit/Model/ItemRepositoryTest.php b/app/code/Magento/GiftMessage/Test/Unit/Model/ItemRepositoryTest.php
index 9b0970a3ae2..589dcaf2154 100644
--- a/app/code/Magento/GiftMessage/Test/Unit/Model/ItemRepositoryTest.php
+++ b/app/code/Magento/GiftMessage/Test/Unit/Model/ItemRepositoryTest.php
@@ -4,6 +4,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\GiftMessage\Test\Unit\Model;
use Magento\GiftMessage\Model\ItemRepository;
@@ -115,7 +116,7 @@ protected function setUp()
/**
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage There is no item with provided id in the cart
+ * @expectedExceptionMessage No item with the provided ID was found in the Cart. Verify the ID and try again.
*/
public function testGetWithNoSuchEntityException()
{
@@ -163,20 +164,22 @@ public function testGet()
/**
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
- * @expectedExceptionMessage There is no product with provided itemId: 1 in the cart
*/
public function testSaveWithNoSuchEntityException()
{
$itemId = 1;
$this->quoteMock->expects($this->once())->method('getItemById')->with($itemId)->will($this->returnValue(null));
-
$this->itemRepository->save($this->cartId, $this->messageMock, $itemId);
+
+ $this->expectExceptionMessage(
+ 'No product with the "1" itemId exists in the Cart. Verify your information and try again.'
+ );
}
/**
* @expectedException \Magento\Framework\Exception\State\InvalidTransitionException
- * @expectedExceptionMessage Gift Messages are not applicable for virtual products
+ * @expectedExceptionMessage Gift messages can't be used for virtual products.
*/
public function testSaveWithInvalidTransitionException()
{
diff --git a/app/code/Magento/GiftMessage/Test/Unit/Model/OrderItemRepositoryTest.php b/app/code/Magento/GiftMessage/Test/Unit/Model/OrderItemRepositoryTest.php
index d6847259dbe..ae85e32ecee 100644
--- a/app/code/Magento/GiftMessage/Test/Unit/Model/OrderItemRepositoryTest.php
+++ b/app/code/Magento/GiftMessage/Test/Unit/Model/OrderItemRepositoryTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\GiftMessage\Test\Unit\Model;
use Magento\Framework\Exception\NoSuchEntityException;
@@ -169,7 +170,10 @@ public function testGetNoSuchEntityExceptionOnGetItemById()
$this->orderItemRepository->get($orderId, $orderItemId);
$this->fail('Expected NoSuchEntityException not caught');
} catch (NoSuchEntityException $exception) {
- $this->assertEquals('There is no item with provided id in the order', $exception->getMessage());
+ $this->assertEquals(
+ 'No item with the provided ID was found in the Order. Verify the ID and try again.',
+ $exception->getMessage()
+ );
}
}
@@ -206,7 +210,8 @@ public function testGetNoSuchEntityExceptionOnIsMessageAllowed()
$this->fail('Expected NoSuchEntityException not caught');
} catch (NoSuchEntityException $exception) {
$this->assertEquals(
- 'There is no item with provided id in the order or gift message isn\'t allowed',
+ "No item with the provided ID was found in the Order, or a gift message isn't allowed. "
+ . "Verify and try again.",
$exception->getMessage()
);
}
@@ -248,7 +253,10 @@ public function testGetNoSuchEntityExceptionOnGetGiftMessageId()
$this->orderItemRepository->get($orderId, $orderItemId);
$this->fail('Expected NoSuchEntityException not caught');
} catch (NoSuchEntityException $exception) {
- $this->assertEquals('There is no item with provided id in the order', $exception->getMessage());
+ $this->assertEquals(
+ 'No item with the provided ID was found in the Order. Verify the ID and try again.',
+ $exception->getMessage()
+ );
}
}
@@ -336,7 +344,10 @@ public function testSaveNoSuchEntityException()
$this->orderItemRepository->save($orderId, $orderItemId, $messageMock);
$this->fail('Expected NoSuchEntityException not caught');
} catch (NoSuchEntityException $exception) {
- $this->assertEquals('There is no item with provided id in the order', $exception->getMessage());
+ $this->assertEquals(
+ 'No item with the provided ID was found in the Order. Verify the ID and try again.',
+ $exception->getMessage()
+ );
}
}
@@ -375,7 +386,7 @@ public function testSaveInvalidTransitionException()
$this->orderItemRepository->save($orderId, $orderItemId, $messageMock);
$this->fail('Expected InvalidTransitionException not caught');
} catch (InvalidTransitionException $exception) {
- $this->assertEquals('Gift Messages are not applicable for virtual products', $exception->getMessage());
+ $this->assertEquals("Gift messages can't be used for virtual products.", $exception->getMessage());
}
}
@@ -418,7 +429,7 @@ public function testSaveCouldNotSaveException()
$this->orderItemRepository->save($orderId, $orderItemId, $messageMock);
$this->fail('Expected CouldNotSaveException not caught');
} catch (CouldNotSaveException $exception) {
- $this->assertEquals('Gift Message is not available', $exception->getMessage());
+ $this->assertEquals("The gift message isn't available.", $exception->getMessage());
}
}
@@ -482,7 +493,7 @@ public function testSaveCouldNotSaveExceptionOnSaveAllInOrder()
$this->fail('Expected CouldNotSaveException not caught');
} catch (CouldNotSaveException $exception) {
$this->assertEquals(
- 'Could not add gift message to order: "' . $excep->getMessage() . '"',
+ 'The gift message couldn\'t be added to the "' . $excep->getMessage() . '" order.',
$exception->getMessage()
);
}
diff --git a/app/code/Magento/GiftMessage/Test/Unit/Model/Plugin/OrderSaveTest.php b/app/code/Magento/GiftMessage/Test/Unit/Model/Plugin/OrderSaveTest.php
index ec8a8841f64..2170864407e 100644
--- a/app/code/Magento/GiftMessage/Test/Unit/Model/Plugin/OrderSaveTest.php
+++ b/app/code/Magento/GiftMessage/Test/Unit/Model/Plugin/OrderSaveTest.php
@@ -128,7 +128,7 @@ public function testAfterSaveGiftMessages()
/**
* @expectedException \Magento\Framework\Exception\CouldNotSaveException
- * @expectedMessage Could not add gift message to order:Test message
+ * @expectedMessage The gift message couldn't be added to the "Test message" order.
*/
public function testAfterSaveIfGiftMessagesNotExist()
{
@@ -155,7 +155,7 @@ public function testAfterSaveIfGiftMessagesNotExist()
/**
* @expectedException \Magento\Framework\Exception\CouldNotSaveException
- * @expectedMessage Could not add gift message to order:Test message
+ * @expectedMessage The gift message couldn't be added to the "Test message" order.
*/
public function testAfterSaveIfItemGiftMessagesNotExist()
{
diff --git a/app/code/Magento/GiftMessage/etc/db_schema.xml b/app/code/Magento/GiftMessage/etc/db_schema.xml
index 62bb290b55e..ecd73bd8708 100644
--- a/app/code/Magento/GiftMessage/etc/db_schema.xml
+++ b/app/code/Magento/GiftMessage/etc/db_schema.xml
@@ -6,7 +6,7 @@
*/
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
diff --git a/app/code/Magento/GiftMessage/etc/module.xml b/app/code/Magento/GiftMessage/etc/module.xml
index bb4ea1dbc2e..893045cb0c6 100644
--- a/app/code/Magento/GiftMessage/etc/module.xml
+++ b/app/code/Magento/GiftMessage/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/GoogleAdwords/etc/module.xml b/app/code/Magento/GoogleAdwords/etc/module.xml
index ee582ec6304..90399bd1c3c 100644
--- a/app/code/Magento/GoogleAdwords/etc/module.xml
+++ b/app/code/Magento/GoogleAdwords/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/GoogleAnalytics/etc/module.xml b/app/code/Magento/GoogleAnalytics/etc/module.xml
index bd401c26f39..494ec7a2342 100644
--- a/app/code/Magento/GoogleAnalytics/etc/module.xml
+++ b/app/code/Magento/GoogleAnalytics/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/GoogleOptimizer/etc/db_schema.xml b/app/code/Magento/GoogleOptimizer/etc/db_schema.xml
index 82eff9219f5..ad3e03e490b 100644
--- a/app/code/Magento/GoogleOptimizer/etc/db_schema.xml
+++ b/app/code/Magento/GoogleOptimizer/etc/db_schema.xml
@@ -6,7 +6,7 @@
*/
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
diff --git a/app/code/Magento/GoogleOptimizer/etc/module.xml b/app/code/Magento/GoogleOptimizer/etc/module.xml
index 25d7462587c..2ceff61f59d 100644
--- a/app/code/Magento/GoogleOptimizer/etc/module.xml
+++ b/app/code/Magento/GoogleOptimizer/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/GraphQl/etc/module.xml b/app/code/Magento/GraphQl/etc/module.xml
index b8cd9138da4..4d8b2090a85 100644
--- a/app/code/Magento/GraphQl/etc/module.xml
+++ b/app/code/Magento/GraphQl/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/GroupedImportExport/etc/module.xml b/app/code/Magento/GroupedImportExport/etc/module.xml
index a0518abc466..4274acded9f 100644
--- a/app/code/Magento/GroupedImportExport/etc/module.xml
+++ b/app/code/Magento/GroupedImportExport/etc/module.xml
@@ -6,6 +6,6 @@
*/
-->
-
+
diff --git a/app/code/Magento/GroupedProduct/Setup/InstallData.php b/app/code/Magento/GroupedProduct/Setup/Patch/Data/InitializeGroupedProductLinks.php
similarity index 53%
rename from app/code/Magento/GroupedProduct/Setup/InstallData.php
rename to app/code/Magento/GroupedProduct/Setup/Patch/Data/InitializeGroupedProductLinks.php
index f58cd657854..9f3e1a58267 100644
--- a/app/code/Magento/GroupedProduct/Setup/InstallData.php
+++ b/app/code/Magento/GroupedProduct/Setup/Patch/Data/InitializeGroupedProductLinks.php
@@ -4,37 +4,48 @@
* See COPYING.txt for license details.
*/
-namespace Magento\GroupedProduct\Setup;
+namespace Magento\GroupedProduct\Setup\Patch\Data;
use Magento\Catalog\Model\Product;
use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
-use Magento\Framework\Setup\InstallDataInterface;
-use Magento\Framework\Setup\ModuleContextInterface;
-use Magento\Framework\Setup\ModuleDataSetupInterface;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\Setup\Patch\DataPatchInterface;
+use Magento\Framework\Setup\Patch\PatchVersionInterface;
/**
- * @codeCoverageIgnore
+ * Class InitializeGroupedProductLinks
+ * @package Magento\GroupedProduct\Setup\Patch
*/
-class InstallData implements InstallDataInterface
+class InitializeGroupedProductLinks implements DataPatchInterface, PatchVersionInterface
{
+ /**
+ * @var \Magento\Framework\Setup\ModuleDataSetupInterface
+ */
+ private $moduleDataSetup;
+
/**
* @var EavSetupFactory
*/
private $eavSetupFactory;
/**
+ * InitializeGroupedProductLinks constructor.
+ * @param \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
* @param EavSetupFactory $eavSetupFactory
*/
- public function __construct(EavSetupFactory $eavSetupFactory)
- {
+ public function __construct(
+ \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup,
+ EavSetupFactory $eavSetupFactory
+ ) {
+ $this->moduleDataSetup = $moduleDataSetup;
$this->eavSetupFactory = $eavSetupFactory;
}
/**
* {@inheritdoc}
*/
- public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
+ public function apply()
{
/**
* Install grouped product link type
@@ -43,23 +54,24 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
'link_type_id' => \Magento\GroupedProduct\Model\ResourceModel\Product\Link::LINK_TYPE_GROUPED,
'code' => 'super',
];
- $setup->getConnection()
- ->insertOnDuplicate($setup->getTable('catalog_product_link_type'), $data);
+ $this->moduleDataSetup->getConnection()->insertOnDuplicate(
+ $this->moduleDataSetup->getTable('catalog_product_link_type'),
+ $data
+ );
/**
* Install grouped product link attributes
*/
- $select = $setup->getConnection()
+ $select = $this->moduleDataSetup->getConnection()
->select()
->from(
- ['c' => $setup->getTable('catalog_product_link_attribute')]
+ ['c' => $this->moduleDataSetup->getTable('catalog_product_link_attribute')]
)
->where(
"c.link_type_id=?",
\Magento\GroupedProduct\Model\ResourceModel\Product\Link::LINK_TYPE_GROUPED
);
- $result = $setup->getConnection()->fetchAll($select);
-
+ $result = $this->moduleDataSetup->getConnection()->fetchAll($select);
if (!$result) {
$data = [
[
@@ -73,12 +85,13 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
'data_type' => 'decimal'
],
];
-
- $setup->getConnection()->insertMultiple($setup->getTable('catalog_product_link_attribute'), $data);
+ $this->moduleDataSetup->getConnection()->insertMultiple(
+ $this->moduleDataSetup->getTable('catalog_product_link_attribute'),
+ $data
+ );
}
-
/** @var EavSetup $eavSetup */
- $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
+ $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
$field = 'country_of_manufacture';
$applyTo = explode(',', $eavSetup->getAttribute(Product::ENTITY, $field, 'apply_to'));
if (!in_array('grouped', $applyTo)) {
@@ -86,4 +99,28 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
$eavSetup->updateAttribute(Product::ENTITY, $field, 'apply_to', implode(',', $applyTo));
}
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.0';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
}
diff --git a/app/code/Magento/GroupedProduct/Setup/Patch/Data/UpdateProductRelations.php b/app/code/Magento/GroupedProduct/Setup/Patch/Data/UpdateProductRelations.php
new file mode 100644
index 00000000000..65a75099fff
--- /dev/null
+++ b/app/code/Magento/GroupedProduct/Setup/Patch/Data/UpdateProductRelations.php
@@ -0,0 +1,96 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->relationProcessor = $relationProcessor;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function apply()
+ {
+ $this->moduleDataSetup->getConnection()->startSetup();
+
+ $connection = $this->moduleDataSetup->getConnection();
+ $select = $connection->select()
+ ->from(
+ $this->relationProcessor->getTable('catalog_product_link'),
+ ['product_id', 'linked_product_id']
+ )
+ ->where('link_type_id = ?', Link::LINK_TYPE_GROUPED);
+
+ $connection->query(
+ $connection->insertFromSelect(
+ $select,
+ $this->relationProcessor->getMainTable(),
+ ['parent_id', 'child_id'],
+ AdapterInterface::INSERT_IGNORE
+ )
+ );
+
+ $this->moduleDataSetup->getConnection()->endSetup();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getDependencies()
+ {
+ return [
+ InitializeGroupedProductLinks::class
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function getVersion()
+ {
+ return '2.0.1';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+}
diff --git a/app/code/Magento/GroupedProduct/Setup/UpgradeData.php b/app/code/Magento/GroupedProduct/Setup/UpgradeData.php
deleted file mode 100644
index 85abe8c414e..00000000000
--- a/app/code/Magento/GroupedProduct/Setup/UpgradeData.php
+++ /dev/null
@@ -1,59 +0,0 @@
-relationProcessor = $relationProcessor;
- }
-
- /**
- * {@inheritdoc}
- */
- public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
- {
- $setup->startSetup();
-
- if (version_compare($context->getVersion(), '2.0.1', '<')) {
- $connection = $setup->getConnection();
- $select = $connection->select()
- ->from(
- $this->relationProcessor->getTable('catalog_product_link'),
- ['product_id', 'linked_product_id']
- )
- ->where('link_type_id = ?', Link::LINK_TYPE_GROUPED);
-
- $connection->query(
- $connection->insertFromSelect(
- $select,
- $this->relationProcessor->getMainTable(),
- ['parent_id', 'child_id'],
- AdapterInterface::INSERT_IGNORE
- )
- );
- }
-
- $setup->endSetup();
- }
-}
diff --git a/app/code/Magento/GroupedProduct/etc/module.xml b/app/code/Magento/GroupedProduct/etc/module.xml
index b5aa60db102..c1c1e902faa 100644
--- a/app/code/Magento/GroupedProduct/etc/module.xml
+++ b/app/code/Magento/GroupedProduct/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/GroupedProductGraphQl/etc/module.xml b/app/code/Magento/GroupedProductGraphQl/etc/module.xml
index f21eb8577db..5482cf54ba0 100644
--- a/app/code/Magento/GroupedProductGraphQl/etc/module.xml
+++ b/app/code/Magento/GroupedProductGraphQl/etc/module.xml
@@ -6,7 +6,7 @@
*/
-->
-
+