diff --git a/README.md b/README.md index c292f1100f336..979e60a167748 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,11 @@ Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a cutting-edge, feature-rich eCommerce solution that gets results. ## Magento system requirements -[Magento system requirements](http://devdocs.magento.com/guides/v2.3/install-gde/system-requirements2.html). +[Magento system requirements](https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements2.html). ## Install Magento -* [Installation guide](http://devdocs.magento.com/guides/v2.3/install-gde/bk-install-guide.html). +* [Installation guide](https://devdocs.magento.com/guides/v2.3/install-gde/bk-install-guide.html).

Contributing to the Magento 2 code base

Contributions can take the form of new components or features, changes to existing features, tests, documentation (such as developer guides, user guides, examples, or specifications), bug fixes, optimizations, or just good suggestions. @@ -21,10 +21,10 @@ To learn about issues, click [here][2]. To open an issue, click [here][3]. To suggest documentation improvements, click [here][4]. -[1]: -[2]: +[1]: +[2]: [3]: -[4]: +[4]:

Community Maintainers

The members of this team have been recognized for their outstanding commitment to maintaining and improving Magento. Magento has granted them permission to accept, merge, and reject pull requests, as well as review issues, and thanks these Community Maintainers for their valuable contributions. @@ -53,9 +53,9 @@ Stay up-to-date on the latest security news and patches for Magento by signing u Each Magento source file included in this distribution is licensed under OSL 3.0 or the Magento Enterprise Edition (MEE) license. -http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -Please see LICENSE.txt for the full text of the OSL 3.0 license or contact license@magentocommerce.com for a copy. +[Open Software License (OSL 3.0)](https://opensource.org/licenses/osl-3.0.php). +Please see [LICENSE.txt](https://github.com/magento/magento2/blob/2.3-develop/LICENSE.txt) for the full text of the OSL 3.0 license or contact license@magentocommerce.com for a copy. Subject to Licensee's payment of fees and compliance with the terms and conditions of the MEE License, the MEE License supersedes the OSL 3.0 license for each source file. -Please see LICENSE_EE.txt for the full text of the MEE License or visit http://magento.com/legal/terms/enterprise. +Please see LICENSE_EE.txt for the full text of the MEE License or visit https://magento.com/legal/terms/enterprise. diff --git a/app/code/Magento/AdminNotification/Block/Window.php b/app/code/Magento/AdminNotification/Block/Window.php index 9563626ee2577..e9b4bfa44893d 100644 --- a/app/code/Magento/AdminNotification/Block/Window.php +++ b/app/code/Magento/AdminNotification/Block/Window.php @@ -8,6 +8,8 @@ namespace Magento\AdminNotification\Block; /** + * Admin notification window block + * * @api * @since 100.0.2 */ @@ -40,7 +42,7 @@ class Window extends \Magento\Backend\Block\Template protected $_criticalCollection; /** - * @var \Magento\Adminnotification\Model\Inbox + * @var \Magento\AdminNotification\Model\Inbox */ protected $_latestItem; @@ -92,7 +94,7 @@ protected function _toHtml() /** * Retrieve latest critical item * - * @return bool|\Magento\Adminnotification\Model\Inbox + * @return bool|\Magento\AdminNotification\Model\Inbox */ protected function _getLatestItem() { diff --git a/app/code/Magento/AdminNotification/etc/db_schema.xml b/app/code/Magento/AdminNotification/etc/db_schema.xml index 35e6045b607d1..29d928ced2084 100644 --- a/app/code/Magento/AdminNotification/etc/db_schema.xml +++ b/app/code/Magento/AdminNotification/etc/db_schema.xml @@ -21,16 +21,16 @@ default="0" comment="Flag if notification read"/> - + - + - + - + @@ -40,7 +40,7 @@ default="0" comment="Problem type"/> - + diff --git a/app/code/Magento/AdvancedSearch/etc/db_schema.xml b/app/code/Magento/AdvancedSearch/etc/db_schema.xml index 9fae40411098c..2dd8c68e2d5fd 100644 --- a/app/code/Magento/AdvancedSearch/etc/db_schema.xml +++ b/app/code/Magento/AdvancedSearch/etc/db_schema.xml @@ -14,13 +14,13 @@ default="0" comment="Query Id"/> - + - - diff --git a/app/code/Magento/AsynchronousOperations/etc/db_schema.xml b/app/code/Magento/AsynchronousOperations/etc/db_schema.xml index 342326e6666f1..5cd55408838fe 100644 --- a/app/code/Magento/AsynchronousOperations/etc/db_schema.xml +++ b/app/code/Magento/AsynchronousOperations/etc/db_schema.xml @@ -21,13 +21,13 @@ comment="Total number of operations scheduled within this bulk"/> - + - + - + @@ -47,12 +47,12 @@ comment="Code of the error that appeared during operation execution (used to aggregate related failed operations)"/> - + - - + @@ -62,13 +62,13 @@ - + - - + diff --git a/app/code/Magento/AsynchronousOperations/etc/db_schema_whitelist.json b/app/code/Magento/AsynchronousOperations/etc/db_schema_whitelist.json index 423b7553ced2a..9b6c0709e1916 100644 --- a/app/code/Magento/AsynchronousOperations/etc/db_schema_whitelist.json +++ b/app/code/Magento/AsynchronousOperations/etc/db_schema_whitelist.json @@ -15,7 +15,8 @@ }, "constraint": { "PRIMARY": true, - "MAGENTO_BULK_UUID": true + "MAGENTO_BULK_UUID": true, + "MAGENTO_BULK_USER_ID_ADMIN_USER_USER_ID": true } }, "magento_operation": { diff --git a/app/code/Magento/Authorization/etc/db_schema.xml b/app/code/Magento/Authorization/etc/db_schema.xml index 45c02128bfc99..a38828eb6efca 100644 --- a/app/code/Magento/Authorization/etc/db_schema.xml +++ b/app/code/Magento/Authorization/etc/db_schema.xml @@ -21,14 +21,14 @@ comment="User ID"/> - + - + - + @@ -40,17 +40,17 @@ - + - - + - + diff --git a/app/code/Magento/Backend/view/adminhtml/web/js/validate-store.js b/app/code/Magento/Backend/view/adminhtml/web/js/validate-store.js index 0a692a9b868cc..c2a0d4dab1fb3 100644 --- a/app/code/Magento/Backend/view/adminhtml/web/js/validate-store.js +++ b/app/code/Magento/Backend/view/adminhtml/web/js/validate-store.js @@ -67,6 +67,7 @@ define([ * 'Confirm' action handler. */ confirm: function () { + $('body').trigger('processStart'); dataPost().postData(requestData); } } diff --git a/app/code/Magento/Braintree/Controller/Paypal/Review.php b/app/code/Magento/Braintree/Controller/Paypal/Review.php index ca252aabe54a9..14ec829d98024 100644 --- a/app/code/Magento/Braintree/Controller/Paypal/Review.php +++ b/app/code/Magento/Braintree/Controller/Paypal/Review.php @@ -12,11 +12,12 @@ use Magento\Braintree\Gateway\Config\PayPal\Config; use Magento\Braintree\Model\Paypal\Helper\QuoteUpdater; use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\App\Action\HttpPostActionInterface; /** * Class Review */ -class Review extends AbstractAction +class Review extends AbstractAction implements HttpPostActionInterface { /** * @var QuoteUpdater @@ -60,7 +61,7 @@ public function execute() try { $this->validateQuote($quote); - if ($this->validateRequestData($requestData)) { + if ($requestData && $this->validateRequestData($requestData)) { $this->quoteUpdater->execute( $requestData['nonce'], $requestData['details'], @@ -91,6 +92,8 @@ public function execute() } /** + * Validate request data + * * @param array $requestData * @return boolean */ diff --git a/app/code/Magento/Bundle/etc/db_schema.xml b/app/code/Magento/Bundle/etc/db_schema.xml index f1c1e7ae782dc..33738cd252d61 100644 --- a/app/code/Magento/Bundle/etc/db_schema.xml +++ b/app/code/Magento/Bundle/etc/db_schema.xml @@ -18,13 +18,13 @@ - + - - + @@ -39,13 +39,13 @@ - + - - + @@ -73,19 +73,19 @@ comment="Selection Qty"/> - + - - - + - + @@ -101,19 +101,19 @@ nullable="false" default="0" comment="Selection Price Value"/> - + - - - + @@ -129,24 +129,24 @@ comment="Min Price"/> - + - - - - + - + @@ -162,7 +162,7 @@ default="0" comment="Option Id"/> - + @@ -197,7 +197,7 @@ comment="Tier Price"/> - + @@ -231,7 +231,7 @@ comment="Tier Price"/> - + @@ -257,7 +257,7 @@ comment="Price"/> - + @@ -285,7 +285,7 @@ comment="Price"/> - + @@ -313,7 +313,7 @@ comment="Tier Price"/> - + @@ -340,7 +340,7 @@ comment="Tier Price"/> - + diff --git a/app/code/Magento/Captcha/etc/db_schema.xml b/app/code/Magento/Captcha/etc/db_schema.xml index fa9a14abb8963..b8987363569ca 100644 --- a/app/code/Magento/Captcha/etc/db_schema.xml +++ b/app/code/Magento/Captcha/etc/db_schema.xml @@ -13,7 +13,7 @@ - + diff --git a/app/code/Magento/Catalog/Model/FilterProductCustomAttribute.php b/app/code/Magento/Catalog/Model/FilterProductCustomAttribute.php index b83bb97301b9c..497ed2fd49953 100644 --- a/app/code/Magento/Catalog/Model/FilterProductCustomAttribute.php +++ b/app/code/Magento/Catalog/Model/FilterProductCustomAttribute.php @@ -27,11 +27,12 @@ public function __construct(array $blackList = []) /** * Delete custom attribute - * @param array $attributes + * + * @param array $attributes set objects attributes @example ['attribute_code'=>'attribute_object'] * @return array */ public function execute(array $attributes): array { - return array_diff($attributes, $this->blackList); + return array_diff_key($attributes, array_flip($this->blackList)); } } diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index cf6b509822ad3..44c5c891f4d6a 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -512,13 +512,17 @@ protected function _getResource() protected function getCustomAttributesCodes() { if ($this->customAttributesCodes === null) { - $this->customAttributesCodes = array_keys($this->eavConfig->getEntityAttributes( - self::ENTITY, - $this - )); - - $this->customAttributesCodes = $this->filterCustomAttribute->execute($this->customAttributesCodes); - $this->customAttributesCodes = array_diff($this->customAttributesCodes, ProductInterface::ATTRIBUTES); + $this->customAttributesCodes = array_diff( + array_keys( + $this->filterCustomAttribute->execute( + $this->eavConfig->getEntityAttributes( + self::ENTITY, + $this + ) + ) + ), + ProductInterface::ATTRIBUTES + ); } return $this->customAttributesCodes; @@ -596,7 +600,6 @@ public function getPrice() * @see \Magento\Catalog\Model\Product\Visibility * * @return int - * @codeCoverageIgnoreStart */ public function getVisibility() { @@ -1053,7 +1056,7 @@ public function reindex() * * Register indexing event before delete product * - * @return $this + * @return \Magento\Catalog\Model\Product * @throws \Magento\Framework\Exception\LocalizedException */ public function beforeDelete() @@ -1567,6 +1570,7 @@ public function hasGalleryAttribute() * @param bool $move if true, it will move source file * @param bool $exclude mark image as disabled in product page view * @return \Magento\Catalog\Model\Product + * @throws \Magento\Framework\Exception\LocalizedException */ public function addImageToMediaGallery($file, $mediaAttribute = null, $move = false, $exclude = true) { @@ -1818,7 +1822,7 @@ public function formatUrlKey($str) /** * Save current attribute with code $code and assign new value * - * @param string $code Attribute code + * @param string $code Attribute code * @param mixed $value New attribute value * @param int $store Store ID * @return void @@ -2230,9 +2234,9 @@ public function getPreconfiguredValues() } /** - * Prepare product custom options + * Prepare product custom options. * - * To be sure that all product custom options does not has ID and has product instance. + * To be sure that all product custom options does not has ID and has product instance * * @return \Magento\Catalog\Model\Product */ @@ -2568,7 +2572,7 @@ public function setTypeId($typeId) /** * @inheritdoc * - * @return \Magento\Catalog\Api\Data\ProductExtensionInterface + * @return \Magento\Framework\Api\ExtensionAttributesInterface */ public function getExtensionAttributes() { @@ -2609,7 +2613,7 @@ protected function convertToMediaGalleryInterface(array $mediaGallery) } /** - * Returns media gallery entries + * Get media gallery entries * * @return \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface[]|null * @throws \Magento\Framework\Exception\LocalizedException @@ -2671,7 +2675,7 @@ public function setId($value) } /** - * Returns link repository instance + * Get link repository * * @return ProductLinkRepositoryInterface */ @@ -2685,7 +2689,7 @@ private function getLinkRepository() } /** - * Returns media gallery processor instance + * Get media gallery processor * * @return Product\Gallery\Processor */ diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/File/ExistingValidate.php b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ExistingValidate.php new file mode 100644 index 0000000000000..c9afdf023b307 --- /dev/null +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ExistingValidate.php @@ -0,0 +1,52 @@ +_messages = []; + $this->_errors = []; + + if (!is_string($value)) { + $this->_messages[] = __('Full file path is expected.')->render(); + return false; + } + + $result = true; + $fileInfo = null; + if ($originalName) { + $fileInfo = ['name' => $originalName]; + } + foreach ($this->_validators as $element) { + $validator = $element['instance']; + if ($validator->isValid($value, $fileInfo)) { + continue; + } + $result = false; + $messages = $validator->getMessages(); + $this->_messages = array_merge($this->_messages, $messages); + $this->_errors = array_merge($this->_errors, array_keys($messages)); + if ($element['breakChainOnFailure']) { + break; + } + } + return $result; + } +} diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidateFactory.php b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidateFactory.php index 32c901afe8e74..a7add0ad87b89 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidateFactory.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidateFactory.php @@ -6,13 +6,18 @@ namespace Magento\Catalog\Model\Product\Option\Type\File; +/** + * Class ValidateFactory. Creates Validator with type "ExistingValidate" + */ class ValidateFactory { /** + * Main factory method + * * @return \Zend_Validate */ public function create() { - return new \Zend_Validate(); + return new ExistingValidate(); } } diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php index d6a5cb1cbc29d..fef4999a1174a 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php @@ -10,8 +10,12 @@ use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Catalog\Model\Product\Exception as ProductException; use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Math\Random; +use Magento\Framework\App\ObjectManager; /** + * Validator class. Represents logic for validation file given from product option + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ValidatorFile extends Validator @@ -63,11 +67,19 @@ class ValidatorFile extends Validator protected $isImageValidator; /** + * @var Random + */ + private $random; + + /** + * Constructor method + * * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Filesystem $filesystem * @param \Magento\Framework\File\Size $fileSize * @param \Magento\Framework\HTTP\Adapter\FileTransferFactory $httpFactory * @param \Magento\Framework\Validator\File\IsImage $isImageValidator + * @param Random|null $random * @throws \Magento\Framework\Exception\FileSystemException */ public function __construct( @@ -75,16 +87,21 @@ public function __construct( \Magento\Framework\Filesystem $filesystem, \Magento\Framework\File\Size $fileSize, \Magento\Framework\HTTP\Adapter\FileTransferFactory $httpFactory, - \Magento\Framework\Validator\File\IsImage $isImageValidator + \Magento\Framework\Validator\File\IsImage $isImageValidator, + Random $random = null ) { $this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA); $this->filesystem = $filesystem; $this->httpFactory = $httpFactory; $this->isImageValidator = $isImageValidator; + $this->random = $random + ?? ObjectManager::getInstance()->get(Random::class); parent::__construct($scopeConfig, $filesystem, $fileSize); } /** + * Setter method for the product + * * @param Product $product * @return $this */ @@ -95,6 +112,8 @@ public function setProduct(Product $product) } /** + * Validation method + * * @param \Magento\Framework\DataObject $processingParams * @param \Magento\Catalog\Model\Product\Option $option * @return array @@ -154,8 +173,6 @@ public function validate($processingParams, $option) $userValue = []; if ($upload->isUploaded($file) && $upload->isValid($file)) { - $extension = pathinfo(strtolower($fileInfo['name']), PATHINFO_EXTENSION); - $fileName = \Magento\MediaStorage\Model\File\Uploader::getCorrectFileName($fileInfo['name']); $dispersion = \Magento\MediaStorage\Model\File\Uploader::getDispersionPath($fileName); @@ -163,7 +180,8 @@ public function validate($processingParams, $option) $tmpDirectory = $this->filesystem->getDirectoryRead(DirectoryList::SYS_TMP); $fileHash = md5($tmpDirectory->readFile($tmpDirectory->getRelativePath($fileInfo['tmp_name']))); - $filePath .= '/' . $fileHash . '.' . $extension; + $fileRandomName = $this->random->getRandomString(32); + $filePath .= '/' .$fileRandomName; $fileFullPath = $this->mediaDirectory->getAbsolutePath($this->quotePath . $filePath); $upload->addFilter(new \Zend_Filter_File_Rename(['target' => $fileFullPath, 'overwrite' => true])); @@ -243,6 +261,8 @@ protected function initFilesystem() } /** + * Validate contents length method + * * @return bool * @todo need correctly name */ diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfo.php b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfo.php index 37e4c7b310a81..100ad37273cff 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfo.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfo.php @@ -6,6 +6,9 @@ namespace Magento\Catalog\Model\Product\Option\Type\File; +/** + * Validator for existing files. + */ class ValidatorInfo extends Validator { /** @@ -34,6 +37,8 @@ class ValidatorInfo extends Validator protected $fileRelativePath; /** + * Construct method + * * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Filesystem $filesystem * @param \Magento\Framework\File\Size $fileSize @@ -53,6 +58,8 @@ public function __construct( } /** + * Setter method for property "useQuotePath" + * * @param mixed $useQuotePath * @return $this */ @@ -63,6 +70,8 @@ public function setUseQuotePath($useQuotePath) } /** + * Validate method for the option value depends on an option + * * @param array $optionValue * @param \Magento\Catalog\Model\Product\Option $option * @return bool @@ -90,7 +99,7 @@ public function validate($optionValue, $option) } $result = false; - if ($validatorChain->isValid($this->fileFullPath)) { + if ($validatorChain->isValid($this->fileFullPath, $optionValue['title'])) { $result = $this->rootDirectory->isReadable($this->fileRelativePath) && isset($optionValue['secret_key']) && $this->buildSecretKey($this->fileRelativePath) == $optionValue['secret_key']; @@ -109,6 +118,8 @@ public function validate($optionValue, $option) } /** + * Method for creation secret key for the given file + * * @param string $fileRelativePath * @return string */ @@ -118,6 +129,8 @@ protected function buildSecretKey($fileRelativePath) } /** + * Calculates path for the file + * * @param array $optionValue * @return void */ diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml index 73025023c23c8..903526a862225 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml @@ -42,4 +42,11 @@ + + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ImageData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ImageData.xml new file mode 100644 index 0000000000000..a2391dda54809 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Data/ImageData.xml @@ -0,0 +1,28 @@ + + + + + + adobe-base.jpg + adobe-base + jpg + + + + adobe-small.jpg + adobe-small + jpg + + + + adobe-thumb.jpg + adobe-thumb + jpg + + diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryBasicFieldSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryBasicFieldSection.xml index 8b69a44993f17..9a0dd8f5b387d 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryBasicFieldSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryBasicFieldSection.xml @@ -32,6 +32,13 @@ +
+ + + + + +
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml index 17778c76da9b9..78d06afa7f003 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml @@ -23,6 +23,9 @@
+
+ +
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeOptionsSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeOptionsSection.xml new file mode 100644 index 0000000000000..0f438540603d0 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeOptionsSection.xml @@ -0,0 +1,14 @@ + + + +
+ +
+
\ No newline at end of file diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductImagePlaceholderConfigSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductImagePlaceholderConfigSection.xml new file mode 100644 index 0000000000000..7558b13d624bb --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductImagePlaceholderConfigSection.xml @@ -0,0 +1,37 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontMiniCartSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontMiniCartSection.xml new file mode 100644 index 0000000000000..ff2e5f2f36015 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontMiniCartSection.xml @@ -0,0 +1,16 @@ + + + + +
+ + + +
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddImageToWYSIWYGProductTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddImageToWYSIWYGProductTest.xml index d8f6bc3e4a749..d38a8e4190c82 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddImageToWYSIWYGProductTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddImageToWYSIWYGProductTest.xml @@ -50,9 +50,9 @@ - + - + @@ -63,7 +63,7 @@ - + @@ -75,10 +75,12 @@ + + - + @@ -87,7 +89,7 @@ - + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminConfigureProductImagePlaceholderTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminConfigureProductImagePlaceholderTest.xml new file mode 100644 index 0000000000000..4d97dee56f059 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminConfigureProductImagePlaceholderTest.xml @@ -0,0 +1,145 @@ + + + + + + + + + + + <description value="Admin should be able to configure the images used for product image placeholders. The configured placeholders should be seen on the frontend when an image has no image."/> + <severity value="MAJOR"/> + <testCaseId value="MC-5005"/> + <group value="configuration"/> + </annotations> + + <before> + <createData entity="ApiCategory" stepKey="category"/> + <!--Create product with no images--> + <createData entity="ApiSimpleProduct" stepKey="productNoImages"> + <requiredEntity createDataKey="category"/> + </createData> + <!--Create product with small, base, and thumbnail image--> + <createData entity="ApiSimpleProduct" stepKey="productWithImages"> + <requiredEntity createDataKey="category"/> + </createData> + <createData entity="ApiProductAttributeMediaGalleryEntryTestImage" stepKey="productImage"> + <requiredEntity createDataKey="productWithImages"/> + </createData> + </before> + + <after> + <!--Unset product image placeholders--> + <amOnPage url="{{CatalogConfigPage.url}}" stepKey="goToCatalogConfigurationPageAfter"/> + <waitForPageLoad stepKey="waitForConfigurationPageLoadAfter"/> + <conditionalClick selector="{{AdminProductImagePlaceholderConfigSection.sectionHeader}}" dependentSelector="{{AdminProductImagePlaceholderConfigSection.baseImageInput}}" visible="false" stepKey="openPlaceholderSectionAfter"/> + <waitForElementVisible selector="{{AdminProductImagePlaceholderConfigSection.baseImageInput}}" stepKey="waitForPlaceholderSectionOpenAfter"/> + <!--Delete base placeholder--> + <checkOption selector="{{AdminProductImagePlaceholderConfigSection.baseImageDelete}}" stepKey="checkDeleteBasePlaceholder"/> + <!--Delete small placeholder--> + <checkOption selector="{{AdminProductImagePlaceholderConfigSection.smallImageDelete}}" stepKey="checkDeleteSmallPlaceholder"/> + <!--Delete thumbnail placeholder--> + <checkOption selector="{{AdminProductImagePlaceholderConfigSection.thumbnailImageDelete}}" stepKey="checkDeleteThumbnailPlaceholder"/> + <!--Save config to delete placeholders--> + <click selector="{{AdminMainActionsSection.save}}" stepKey="saveConfigWithPlaceholders"/> + <!--See placeholders are empty--> + <conditionalClick selector="{{AdminProductImagePlaceholderConfigSection.sectionHeader}}" dependentSelector="{{AdminProductImagePlaceholderConfigSection.baseImageInput}}" visible="false" stepKey="openPlaceholderSection2"/> + <waitForElementVisible selector="{{AdminProductImagePlaceholderConfigSection.baseImageInput}}" stepKey="waitForPlaceholderSectionOpen2"/> + <dontSeeElement selector="{{AdminProductImagePlaceholderConfigSection.baseImage}}" stepKey="dontSeeBaseImageSet"/> + <dontSeeElement selector="{{AdminProductImagePlaceholderConfigSection.smallImage}}" stepKey="dontSeeSmallImageSet"/> + <dontSeeElement selector="{{AdminProductImagePlaceholderConfigSection.thumbnailImage}}" stepKey="dontSeeThumbnailImageSet"/> + <dontSeeElement selector="{{AdminProductImagePlaceholderConfigSection.swatchImage}}" stepKey="dontSeeSwatchImageSet"/> + + <!--Delete prerequisite entities--> + <deleteData createDataKey="category" stepKey="deleteCategory"/> + <deleteData createDataKey="productNoImages" stepKey="deleteProductNoImages"/> + <deleteData createDataKey="productWithImages" stepKey="deleteProductWithImages"/> + </after> + + <actionGroup ref="LoginAsAdmin" stepKey="loginToAdminArea"/> + + <!--Admin area: configure Product Image Placeholders--> + <comment userInput="Configure product image placeholders in store config" stepKey="configurePlaceholderComment"/> + <amOnPage url="{{CatalogConfigPage.url}}" stepKey="goToCatalogConfigurationPage"/> + <waitForPageLoad stepKey="waitForConfigurationPageLoad1"/> + <conditionalClick selector="{{AdminProductImagePlaceholderConfigSection.sectionHeader}}" dependentSelector="{{AdminProductImagePlaceholderConfigSection.baseImageInput}}" visible="false" stepKey="openPlaceholderSection1"/> + <waitForElementVisible selector="{{AdminProductImagePlaceholderConfigSection.baseImageInput}}" stepKey="waitForPlaceholderSectionOpen1"/> + <!--Set base placeholder--> + <attachFile selector="{{AdminProductImagePlaceholderConfigSection.baseImageInput}}" userInput="{{placeholderBaseImage.file}}" stepKey="uploadBasePlaceholder"/> + <!--Set small placeholder--> + <attachFile selector="{{AdminProductImagePlaceholderConfigSection.smallImageInput}}" userInput="{{placeholderSmallImage.file}}" stepKey="uploadSmallPlaceholder"/> + <!--Set thumbnail placeholder--> + <attachFile selector="{{AdminProductImagePlaceholderConfigSection.thumbnailImageInput}}" userInput="{{placeholderThumbnailImage.file}}" stepKey="uploadThumbnailPlaceholder"/> + <!--Save config with placeholders--> + <click selector="{{AdminMainActionsSection.save}}" stepKey="saveConfigWithPlaceholders"/> + <!--See images are saved--> + <conditionalClick selector="{{AdminProductImagePlaceholderConfigSection.sectionHeader}}" dependentSelector="{{AdminProductImagePlaceholderConfigSection.baseImageInput}}" visible="false" stepKey="openPlaceholderSection2"/> + <waitForElementVisible selector="{{AdminProductImagePlaceholderConfigSection.baseImageInput}}" stepKey="waitForPlaceholderSectionOpen2"/> + <seeElement selector="{{AdminProductImagePlaceholderConfigSection.baseImageBySrc(placeholderBaseImage.name)}}" stepKey="seeBasePlaceholderSet"/> + <seeElement selector="{{AdminProductImagePlaceholderConfigSection.smallImageBySrc(placeholderSmallImage.name)}}" stepKey="seeSmallPlaceholderSet"/> + <seeElement selector="{{AdminProductImagePlaceholderConfigSection.thumbnailImageBySrc(placeholderThumbnailImage.name)}}" stepKey="seeThumbnailPlaceholderSet"/> + <dontSeeElement selector="{{AdminProductImagePlaceholderConfigSection.swatchImage}}" stepKey="dontSeeSwatchImageSet"/> + + <!--See correct placeholder images on category page--> + <comment userInput="Check placeholder images on the storefront" stepKey="checkStorefrontComment"/> + <amOnPage url="$$category.name$$.html" stepKey="goToCategoryStorefront1"/> + <waitForPageLoad stepKey="waitForStorefrontCategory1"/> + <!--Product with no images uses placeholder--> + <seeElement selector="{{StorefrontCategoryProductSection.ProductImageByName($$productNoImages.name$$)}}" stepKey="seeProductNoImagesInCategory"/> + <grabAttributeFrom selector="{{StorefrontCategoryProductSection.ProductImageByName($$productNoImages.name$$)}}" userInput="src" stepKey="getSmallPlaceholderImageSrc"/> + <assertContains stepKey="checkSmallPlaceholderImage"> + <actualResult type="variable">$getSmallPlaceholderImageSrc</actualResult> + <expectedResult type="string">{{placeholderSmallImage.name}}</expectedResult> + </assertContains> + <!--Product with images does not use placeholder--> + <seeElement selector="{{StorefrontCategoryProductSection.ProductTitleByName($$productWithImages.name$$)}}" stepKey="seeProductWithImagesInCategory"/> + <grabAttributeFrom selector="{{StorefrontCategoryProductSection.ProductImageByName($$productWithImages.name$$)}}" userInput="src" stepKey="getSmallNonPlaceholderImageSrc"/> + <assertNotContains stepKey="checkSmallPlaceholderImageNotUsed"> + <actualResult type="variable">$getSmallNonPlaceholderImageSrc</actualResult> + <expectedResult type="string">{{placeholderSmallImage.name}}</expectedResult> + </assertNotContains> + + <!--Check base image on product page--> + <!--Product which is using placeholder--> + <click selector="{{StorefrontCategoryProductSection.ProductImageByName($$productNoImages.name$$)}}" stepKey="goToProductNoImages"/> + <waitForPageLoad stepKey="waitForProductPageLoad1"/> + <seeInCurrentUrl url="$$productNoImages.sku$$" stepKey="seeCorrectProductPage1"/> + <seeElement selector="{{StorefrontProductMediaSection.imageFile(placeholderBaseImage.name)}}" stepKey="seeBasePlaceholderImage"/> + <click selector="{{StorefrontProductPageSection.addToCartBtn}}" stepKey="addProductToCart1"/> + <waitForElementVisible selector="{{StorefrontProductPageSection.successMsg}}" stepKey="waitForProductAdded1"/> + <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="openMiniCart1"/> + <grabAttributeFrom selector="{{StorefrontMinicartSection.productImageByName($$productNoImages.name$$)}}" userInput="src" stepKey="getThumbnailPlaceholderImageSrc"/> + <assertContains stepKey="checkThumbnailPlaceholderImage"> + <actualResult type="variable">$getThumbnailPlaceholderImageSrc</actualResult> + <expectedResult type="string">{{placeholderThumbnailImage.name}}</expectedResult> + </assertContains> + <actionGroup ref="removeProductFromMiniCart" stepKey="removeProductFromCart1"> + <argument name="productName" value="$$productNoImages.name$$"/> + </actionGroup> + <!--Product which is NOT using placeholder--> + <amOnPage url="$$category.name$$.html" stepKey="goToCategoryStorefront2"/> + <waitForPageLoad stepKey="waitForStorefrontCategory2"/> + <click selector="{{StorefrontCategoryProductSection.ProductImageByName($$productWithImages.name$$)}}" stepKey="goToProductWithImages"/> + <waitForPageLoad stepKey="waitForProductPageLoad2"/> + <seeInCurrentUrl url="$$productWithImages.sku$$" stepKey="seeCorrectProductPage2"/> + <dontSeeElement selector="{{StorefrontProductMediaSection.imageFile(placeholderBaseImage.name)}}" stepKey="dontSeeBasePlaceholderImage"/> + <click selector="{{StorefrontProductPageSection.addToCartBtn}}" stepKey="addProductToCart2"/> + <waitForElementVisible selector="{{StorefrontProductPageSection.successMsg}}" stepKey="waitForProductAdded2"/> + <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="openMiniCart2"/> + <grabAttributeFrom selector="{{StorefrontMinicartSection.productImageByName($$productWithImages.name$$)}}" userInput="src" stepKey="getThumbnailImageSrc"/> + <assertNotContains stepKey="checkThumbnailImage"> + <actualResult type="variable">$getThumbnailImageSrc</actualResult> + <expectedResult type="string">{{placeholderThumbnailImage.name}}</expectedResult> + </assertNotContains> + <actionGroup ref="removeProductFromMiniCart" stepKey="removeProductFromCart2"> + <argument name="productName" value="$$productWithImages.name$$"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest.xml index bfb9557910642..8806612c0f5de 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest.xml @@ -69,4 +69,35 @@ <waitForElementVisible selector="{{CategoryDesignSection.LayoutDropdown}}" stepKey="waitForLayoutDropDown" /> <seeOptionIsSelected selector="{{CategoryDesignSection.LayoutDropdown}}" userInput="2 columns with right bar" stepKey="see2ColumnsSelected" /> </test> + <test name="AdminCategoryFormDisplaySettingsUIValidationTest"> + <annotations> + <features value="Catalog"/> + <stories value="Default layout configuration MAGETWO-88793"/> + <title value="Category should not be saved once layered navigation price step field is left empty"/> + <description value="Once the Config setting is unchecked Category should not be saved with layered navigation price field left empty"/> + <severity value="AVERAGE"/> + <testCaseId value="MAGETWO-95797"/> + <group value="category"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + <after> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPage"/> + <waitForPageLoad time="30" stepKey="waitForPageLoad1"/> + <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategory"/> + <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{SimpleSubCategory.name}}" stepKey="enterCategoryName"/> + <click selector="{{CategoryDisplaySettingsSection.DisplaySettingTab}}" stepKey="clickOnDisplaySettingsTab"/> + <waitForElementVisible selector="{{CategoryDisplaySettingsSection.filterPriceRangeUseConfig}}" stepKey="wait"/> + <scrollTo selector="{{CategoryDisplaySettingsSection.layeredNavigationPriceInput}}" stepKey="scrollToLayeredNavigationField"/> + <uncheckOption selector="{{CategoryDisplaySettingsSection.filterPriceRangeUseConfig}}" stepKey="uncheckConfigSetting"/> + <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveCategory"/> + <see selector="{{AdminCategoryBasicFieldSection.FieldError('uid')}}" userInput="This is a required field." stepKey="seeErrorMessage"/> + <!-- Verify that the Layered navigation price step field has the required indicator --> + <comment userInput="Check if Layered navigation price field has required indictor icon" stepKey="comment" /> + <executeJS function="{{CategoryDisplaySettingsSection.RequiredFieldIndicator('filter_price_range')}}" stepKey="getRequiredFieldIndicator"/> + <assertEquals expected='"*"' expectedType="string" actualType="variable" actual="getRequiredFieldIndicator" message="pass" stepKey="assertRequiredFieldIndicator1"/> + </test> </tests> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDropdownProductAttributeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDropdownProductAttributeTest.xml new file mode 100644 index 0000000000000..525f81de6c48c --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDropdownProductAttributeTest.xml @@ -0,0 +1,72 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminCreateDropdownProductAttributeTest"> + <annotations> + <features value="Catalog"/> + <stories value="Create/configure Dropdown product attribute"/> + <title value="Admin should be able to create dropdown product attribute"/> + <description value="Admin should be able to create dropdown product attribute"/> + <severity value="CRITICAL"/> + <testCaseId value="MC-4982"/> + <group value="Catalog"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="login"/> + </before> + <after> + <!-- Remove attribute --> + <actionGroup ref="deleteProductAttribute" stepKey="deleteAttribute"> + <argument name="ProductAttribute" value="productDropDownAttribute"/> + </actionGroup> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <amOnPage url="{{ProductAttributePage.url}}" stepKey="navigateToNewProductAttributePage"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + + <!-- Set attribute properties --> + <fillField selector="{{AttributePropertiesSection.DefaultLabel}}" + userInput="{{ProductAttributeFrontendLabel.label}}" stepKey="fillDefaultLabel"/> + <selectOption selector="{{AttributePropertiesSection.InputType}}" + userInput="{{productDropDownAttribute.frontend_input}}" stepKey="fillInputType"/> + + <!-- Set advanced attribute properties --> + <click selector="{{AdvancedAttributePropertiesSection.AdvancedAttributePropertiesSectionToggle}}" + stepKey="showAdvancedAttributePropertiesSection"/> + <waitForElementVisible selector="{{AdvancedAttributePropertiesSection.AttributeCode}}" + stepKey="waitForSlideOut"/> + <fillField selector="{{AdvancedAttributePropertiesSection.AttributeCode}}" + userInput="{{productDropDownAttribute.attribute_code}}" + stepKey="fillAttributeCode"/> + + <!-- Add new attribute options --> + <click selector="{{AttributeOptionsSection.AddOption}}" stepKey="clickAddOption1"/> + <fillField selector="{{DropdownAttributeOptionsSection.nthOptionAdminLabel('1')}}" + userInput="Fish and Chips" stepKey="fillAdminValue1"/> + + <click selector="{{AttributeOptionsSection.AddOption}}" stepKey="clickAddOption2"/> + <fillField selector="{{DropdownAttributeOptionsSection.nthOptionAdminLabel('2')}}" + userInput="Fish & Chips" stepKey="fillAdminValue2"/> + + <!-- Save the new product attribute --> + <click selector="{{AttributePropertiesSection.Save}}" stepKey="clickSave1"/> + <waitForPageLoad stepKey="waitForGridPageLoad1"/> + <seeElement selector="{{AdminProductMessagesSection.successMessage}}" + stepKey="waitForSuccessMessage"/> + + <actionGroup ref="navigateToCreatedProductAttribute" stepKey="navigateToAttribute"> + <argument name="ProductAttribute" value="productDropDownAttribute"/> + </actionGroup> + <!-- Check attribute data --> + <grabValueFrom selector="{{DropdownAttributeOptionsSection.nthOptionAdminLabel('2')}}" + stepKey="secondOptionAdminLabel"/> + <assertEquals actual="$secondOptionAdminLabel" expected="'Fish & Chips'" + stepKey="assertSecondOption"/> + </test> +</tests> \ No newline at end of file diff --git a/app/code/Magento/Catalog/etc/db_schema.xml b/app/code/Magento/Catalog/etc/db_schema.xml index 860e5fee9f157..a366065c89e76 100644 --- a/app/code/Magento/Catalog/etc/db_schema.xml +++ b/app/code/Magento/Catalog/etc/db_schema.xml @@ -22,13 +22,13 @@ comment="Creation Time"/> <column xsi:type="timestamp" name="updated_at" on_update="true" nullable="false" default="CURRENT_TIMESTAMP" comment="Update Time"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <index name="CATALOG_PRODUCT_ENTITY_ATTRIBUTE_SET_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_ATTRIBUTE_SET_ID" indexType="btree"> <column name="attribute_set_id"/> </index> - <index name="CATALOG_PRODUCT_ENTITY_SKU" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_SKU" indexType="btree"> <column name="sku"/> </index> </table> @@ -43,27 +43,27 @@ <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Entity ID"/> <column xsi:type="datetime" name="value" on_update="false" nullable="true" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_DTIME_ATTR_ID_EAV_ATTR_ATTR_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_DTIME_ATTR_ID_EAV_ATTR_ATTR_ID" table="catalog_product_entity_datetime" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_DTIME_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_DTIME_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_entity_datetime" column="entity_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOG_PRODUCT_ENTITY_DATETIME_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_STORE_ID_STORE_STORE_ID" table="catalog_product_entity_datetime" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOG_PRODUCT_ENTITY_DATETIME_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> </constraint> - <index name="CATALOG_PRODUCT_ENTITY_DATETIME_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CATALOG_PRODUCT_ENTITY_DATETIME_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_DATETIME_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -79,27 +79,27 @@ default="0" comment="Entity ID"/> <column xsi:type="decimal" name="value" scale="4" precision="12" unsigned="false" nullable="true" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_DEC_ATTR_ID_EAV_ATTR_ATTR_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_DEC_ATTR_ID_EAV_ATTR_ATTR_ID" table="catalog_product_entity_decimal" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_DEC_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_DEC_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_entity_decimal" column="entity_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOG_PRODUCT_ENTITY_DECIMAL_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_PRODUCT_ENTITY_DECIMAL_STORE_ID_STORE_STORE_ID" table="catalog_product_entity_decimal" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOG_PRODUCT_ENTITY_DECIMAL_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_ENTITY_DECIMAL_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> </constraint> - <index name="CATALOG_PRODUCT_ENTITY_DECIMAL_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_DECIMAL_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="CATALOG_PRODUCT_ENTITY_DECIMAL_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_DECIMAL_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> </table> @@ -115,27 +115,27 @@ default="0" comment="Entity ID"/> <column xsi:type="int" name="value" padding="11" unsigned="false" nullable="true" identity="false" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_INT_ATTR_ID_EAV_ATTR_ATTR_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_INT_ATTR_ID_EAV_ATTR_ATTR_ID" table="catalog_product_entity_int" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_INT_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_INT_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_entity_int" column="entity_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOG_PRODUCT_ENTITY_INT_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_PRODUCT_ENTITY_INT_STORE_ID_STORE_STORE_ID" table="catalog_product_entity_int" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOG_PRODUCT_ENTITY_INT_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_ENTITY_INT_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> </constraint> - <index name="CATALOG_PRODUCT_ENTITY_INT_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_INT_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CATALOG_PRODUCT_ENTITY_INT_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_INT_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -150,27 +150,27 @@ <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Entity ID"/> <column xsi:type="text" name="value" nullable="true" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_TEXT_ATTR_ID_EAV_ATTR_ATTR_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_TEXT_ATTR_ID_EAV_ATTR_ATTR_ID" table="catalog_product_entity_text" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_TEXT_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_TEXT_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_entity_text" column="entity_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOG_PRODUCT_ENTITY_TEXT_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_PRODUCT_ENTITY_TEXT_STORE_ID_STORE_STORE_ID" table="catalog_product_entity_text" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOG_PRODUCT_ENTITY_TEXT_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_ENTITY_TEXT_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> </constraint> - <index name="CATALOG_PRODUCT_ENTITY_TEXT_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_TEXT_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CATALOG_PRODUCT_ENTITY_TEXT_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_TEXT_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -185,27 +185,27 @@ <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Entity ID"/> <column xsi:type="varchar" name="value" nullable="true" length="255" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_VCHR_ATTR_ID_EAV_ATTR_ATTR_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_VCHR_ATTR_ID_EAV_ATTR_ATTR_ID" table="catalog_product_entity_varchar" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_VCHR_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_VCHR_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_entity_varchar" column="entity_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOG_PRODUCT_ENTITY_VARCHAR_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_PRODUCT_ENTITY_VARCHAR_STORE_ID_STORE_STORE_ID" table="catalog_product_entity_varchar" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOG_PRODUCT_ENTITY_VARCHAR_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_ENTITY_VARCHAR_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> </constraint> - <index name="CATALOG_PRODUCT_ENTITY_VARCHAR_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_VARCHAR_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CATALOG_PRODUCT_ENTITY_VARCHAR_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_VARCHAR_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -222,30 +222,30 @@ <column xsi:type="int" name="position" padding="11" unsigned="false" nullable="false" identity="false" default="0" comment="Position"/> <column xsi:type="varchar" name="value" nullable="true" length="255" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_GLR_ATTR_ID_EAV_ATTR_ATTR_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_GLR_ATTR_ID_EAV_ATTR_ATTR_ID" table="catalog_product_entity_gallery" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_GLR_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_GLR_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_entity_gallery" column="entity_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOG_PRODUCT_ENTITY_GALLERY_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_PRODUCT_ENTITY_GALLERY_STORE_ID_STORE_STORE_ID" table="catalog_product_entity_gallery" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOG_PRODUCT_ENTITY_GALLERY_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_ENTITY_GALLERY_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> </constraint> - <index name="CATALOG_PRODUCT_ENTITY_GALLERY_ENTITY_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_GALLERY_ENTITY_ID" indexType="btree"> <column name="entity_id"/> </index> - <index name="CATALOG_PRODUCT_ENTITY_GALLERY_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_GALLERY_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CATALOG_PRODUCT_ENTITY_GALLERY_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_GALLERY_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -267,13 +267,13 @@ comment="Tree Level"/> <column xsi:type="int" name="children_count" padding="11" unsigned="false" nullable="false" identity="false" comment="Child Count"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <index name="CATALOG_CATEGORY_ENTITY_LEVEL" indexType="btree"> + <index referenceId="CATALOG_CATEGORY_ENTITY_LEVEL" indexType="btree"> <column name="level"/> </index> - <index name="CATALOG_CATEGORY_ENTITY_PATH" indexType="btree"> + <index referenceId="CATALOG_CATEGORY_ENTITY_PATH" indexType="btree"> <column name="path"/> </index> </table> @@ -288,30 +288,30 @@ <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Entity ID"/> <column xsi:type="datetime" name="value" on_update="false" nullable="true" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_CTGR_ENTT_DTIME_ATTR_ID_EAV_ATTR_ATTR_ID" + <constraint xsi:type="foreign" referenceId="CAT_CTGR_ENTT_DTIME_ATTR_ID_EAV_ATTR_ATTR_ID" table="catalog_category_entity_datetime" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_CTGR_ENTT_DTIME_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_CTGR_ENTT_DTIME_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID" table="catalog_category_entity_datetime" column="entity_id" referenceTable="catalog_category_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOG_CATEGORY_ENTITY_DATETIME_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_CATEGORY_ENTITY_DATETIME_STORE_ID_STORE_STORE_ID" table="catalog_category_entity_datetime" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOG_CATEGORY_ENTITY_DATETIME_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_CATEGORY_ENTITY_DATETIME_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> </constraint> - <index name="CATALOG_CATEGORY_ENTITY_DATETIME_ENTITY_ID" indexType="btree"> + <index referenceId="CATALOG_CATEGORY_ENTITY_DATETIME_ENTITY_ID" indexType="btree"> <column name="entity_id"/> </index> - <index name="CATALOG_CATEGORY_ENTITY_DATETIME_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CATALOG_CATEGORY_ENTITY_DATETIME_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CATALOG_CATEGORY_ENTITY_DATETIME_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_CATEGORY_ENTITY_DATETIME_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -327,30 +327,30 @@ default="0" comment="Entity ID"/> <column xsi:type="decimal" name="value" scale="4" precision="12" unsigned="false" nullable="true" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_CTGR_ENTT_DEC_ATTR_ID_EAV_ATTR_ATTR_ID" + <constraint xsi:type="foreign" referenceId="CAT_CTGR_ENTT_DEC_ATTR_ID_EAV_ATTR_ATTR_ID" table="catalog_category_entity_decimal" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_CTGR_ENTT_DEC_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_CTGR_ENTT_DEC_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID" table="catalog_category_entity_decimal" column="entity_id" referenceTable="catalog_category_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOG_CATEGORY_ENTITY_DECIMAL_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_CATEGORY_ENTITY_DECIMAL_STORE_ID_STORE_STORE_ID" table="catalog_category_entity_decimal" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOG_CATEGORY_ENTITY_DECIMAL_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_CATEGORY_ENTITY_DECIMAL_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> </constraint> - <index name="CATALOG_CATEGORY_ENTITY_DECIMAL_ENTITY_ID" indexType="btree"> + <index referenceId="CATALOG_CATEGORY_ENTITY_DECIMAL_ENTITY_ID" indexType="btree"> <column name="entity_id"/> </index> - <index name="CATALOG_CATEGORY_ENTITY_DECIMAL_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CATALOG_CATEGORY_ENTITY_DECIMAL_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CATALOG_CATEGORY_ENTITY_DECIMAL_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_CATEGORY_ENTITY_DECIMAL_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -366,30 +366,30 @@ default="0" comment="Entity ID"/> <column xsi:type="int" name="value" padding="11" unsigned="false" nullable="true" identity="false" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_CTGR_ENTT_INT_ATTR_ID_EAV_ATTR_ATTR_ID" + <constraint xsi:type="foreign" referenceId="CAT_CTGR_ENTT_INT_ATTR_ID_EAV_ATTR_ATTR_ID" table="catalog_category_entity_int" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_CTGR_ENTT_INT_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_CTGR_ENTT_INT_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID" table="catalog_category_entity_int" column="entity_id" referenceTable="catalog_category_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOG_CATEGORY_ENTITY_INT_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_CATEGORY_ENTITY_INT_STORE_ID_STORE_STORE_ID" table="catalog_category_entity_int" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOG_CATEGORY_ENTITY_INT_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_CATEGORY_ENTITY_INT_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> </constraint> - <index name="CATALOG_CATEGORY_ENTITY_INT_ENTITY_ID" indexType="btree"> + <index referenceId="CATALOG_CATEGORY_ENTITY_INT_ENTITY_ID" indexType="btree"> <column name="entity_id"/> </index> - <index name="CATALOG_CATEGORY_ENTITY_INT_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CATALOG_CATEGORY_ENTITY_INT_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CATALOG_CATEGORY_ENTITY_INT_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_CATEGORY_ENTITY_INT_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -404,30 +404,30 @@ <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Entity ID"/> <column xsi:type="text" name="value" nullable="true" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_CTGR_ENTT_TEXT_ATTR_ID_EAV_ATTR_ATTR_ID" + <constraint xsi:type="foreign" referenceId="CAT_CTGR_ENTT_TEXT_ATTR_ID_EAV_ATTR_ATTR_ID" table="catalog_category_entity_text" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_CTGR_ENTT_TEXT_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_CTGR_ENTT_TEXT_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID" table="catalog_category_entity_text" column="entity_id" referenceTable="catalog_category_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOG_CATEGORY_ENTITY_TEXT_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_CATEGORY_ENTITY_TEXT_STORE_ID_STORE_STORE_ID" table="catalog_category_entity_text" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOG_CATEGORY_ENTITY_TEXT_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_CATEGORY_ENTITY_TEXT_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> </constraint> - <index name="CATALOG_CATEGORY_ENTITY_TEXT_ENTITY_ID" indexType="btree"> + <index referenceId="CATALOG_CATEGORY_ENTITY_TEXT_ENTITY_ID" indexType="btree"> <column name="entity_id"/> </index> - <index name="CATALOG_CATEGORY_ENTITY_TEXT_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CATALOG_CATEGORY_ENTITY_TEXT_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CATALOG_CATEGORY_ENTITY_TEXT_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_CATEGORY_ENTITY_TEXT_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -442,30 +442,30 @@ <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Entity ID"/> <column xsi:type="varchar" name="value" nullable="true" length="255" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_CTGR_ENTT_VCHR_ATTR_ID_EAV_ATTR_ATTR_ID" + <constraint xsi:type="foreign" referenceId="CAT_CTGR_ENTT_VCHR_ATTR_ID_EAV_ATTR_ATTR_ID" table="catalog_category_entity_varchar" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_CTGR_ENTT_VCHR_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_CTGR_ENTT_VCHR_ENTT_ID_CAT_CTGR_ENTT_ENTT_ID" table="catalog_category_entity_varchar" column="entity_id" referenceTable="catalog_category_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOG_CATEGORY_ENTITY_VARCHAR_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_CATEGORY_ENTITY_VARCHAR_STORE_ID_STORE_STORE_ID" table="catalog_category_entity_varchar" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOG_CATEGORY_ENTITY_VARCHAR_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_CATEGORY_ENTITY_VARCHAR_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> </constraint> - <index name="CATALOG_CATEGORY_ENTITY_VARCHAR_ENTITY_ID" indexType="btree"> + <index referenceId="CATALOG_CATEGORY_ENTITY_VARCHAR_ENTITY_ID" indexType="btree"> <column name="entity_id"/> </index> - <index name="CATALOG_CATEGORY_ENTITY_VARCHAR_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CATALOG_CATEGORY_ENTITY_VARCHAR_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CATALOG_CATEGORY_ENTITY_VARCHAR_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_CATEGORY_ENTITY_VARCHAR_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -479,22 +479,22 @@ default="0" comment="Product ID"/> <column xsi:type="int" name="position" padding="11" unsigned="false" nullable="false" identity="false" default="0" comment="Position"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> <column name="category_id"/> <column name="product_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_CTGR_PRD_PRD_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_category_product" + <constraint xsi:type="foreign" referenceId="CAT_CTGR_PRD_PRD_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_category_product" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_CTGR_PRD_CTGR_ID_CAT_CTGR_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_CTGR_PRD_CTGR_ID_CAT_CTGR_ENTT_ENTT_ID" table="catalog_category_product" column="category_id" referenceTable="catalog_category_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOG_CATEGORY_PRODUCT_CATEGORY_ID_PRODUCT_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_CATEGORY_PRODUCT_CATEGORY_ID_PRODUCT_ID"> <column name="category_id"/> <column name="product_id"/> </constraint> - <index name="CATALOG_CATEGORY_PRODUCT_PRODUCT_ID" indexType="btree"> + <index referenceId="CATALOG_CATEGORY_PRODUCT_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> </table> @@ -512,18 +512,18 @@ default="0" comment="Store ID"/> <column xsi:type="smallint" name="visibility" padding="5" unsigned="true" nullable="false" identity="false" comment="Visibility"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="category_id"/> <column name="product_id"/> <column name="store_id"/> </constraint> - <index name="CAT_CTGR_PRD_IDX_PRD_ID_STORE_ID_CTGR_ID_VISIBILITY" indexType="btree"> + <index referenceId="CAT_CTGR_PRD_IDX_PRD_ID_STORE_ID_CTGR_ID_VISIBILITY" indexType="btree"> <column name="product_id"/> <column name="store_id"/> <column name="category_id"/> <column name="visibility"/> </index> - <index name="CAT_CTGR_PRD_IDX_STORE_ID_CTGR_ID_VISIBILITY_IS_PARENT_POSITION" indexType="btree"> + <index referenceId="CAT_CTGR_PRD_IDX_STORE_ID_CTGR_ID_VISIBILITY_IS_PARENT_POSITION" indexType="btree"> <column name="store_id"/> <column name="category_id"/> <column name="visibility"/> @@ -542,29 +542,29 @@ default="0" comment="Product ID"/> <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="true" identity="false" comment="Store ID"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="catalog_compare_item_id"/> </constraint> - <constraint xsi:type="foreign" name="CATALOG_COMPARE_ITEM_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_COMPARE_ITEM_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="catalog_compare_item" column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOG_COMPARE_ITEM_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_COMPARE_ITEM_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID" table="catalog_compare_item" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOG_COMPARE_ITEM_STORE_ID_STORE_STORE_ID" table="catalog_compare_item" + <constraint xsi:type="foreign" referenceId="CATALOG_COMPARE_ITEM_STORE_ID_STORE_STORE_ID" table="catalog_compare_item" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <index name="CATALOG_COMPARE_ITEM_PRODUCT_ID" indexType="btree"> + <index referenceId="CATALOG_COMPARE_ITEM_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> - <index name="CATALOG_COMPARE_ITEM_VISITOR_ID_PRODUCT_ID" indexType="btree"> + <index referenceId="CATALOG_COMPARE_ITEM_VISITOR_ID_PRODUCT_ID" indexType="btree"> <column name="visitor_id"/> <column name="product_id"/> </index> - <index name="CATALOG_COMPARE_ITEM_CUSTOMER_ID_PRODUCT_ID" indexType="btree"> + <index referenceId="CATALOG_COMPARE_ITEM_CUSTOMER_ID_PRODUCT_ID" indexType="btree"> <column name="customer_id"/> <column name="product_id"/> </index> - <index name="CATALOG_COMPARE_ITEM_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_COMPARE_ITEM_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -574,17 +574,17 @@ comment="Product ID"/> <column xsi:type="smallint" name="website_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Website ID"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="product_id"/> <column name="website_id"/> </constraint> - <constraint xsi:type="foreign" name="CATALOG_PRODUCT_WEBSITE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_PRODUCT_WEBSITE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" table="catalog_product_website" column="website_id" referenceTable="store_website" referenceColumn="website_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_PRD_WS_PRD_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_website" + <constraint xsi:type="foreign" referenceId="CAT_PRD_WS_PRD_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_website" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="CATALOG_PRODUCT_WEBSITE_WEBSITE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_WEBSITE_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> </table> @@ -593,7 +593,7 @@ <column xsi:type="smallint" name="link_type_id" padding="5" unsigned="true" nullable="false" identity="true" comment="Link Type ID"/> <column xsi:type="varchar" name="code" nullable="true" length="32" comment="Code"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="link_type_id"/> </constraint> </table> @@ -607,27 +607,27 @@ default="0" comment="Linked Product ID"/> <column xsi:type="smallint" name="link_type_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Link Type ID"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="link_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_LNK_LNKED_PRD_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_link" + <constraint xsi:type="foreign" referenceId="CAT_PRD_LNK_LNKED_PRD_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_link" column="linked_product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOG_PRODUCT_LINK_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_PRODUCT_LINK_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID" table="catalog_product_link" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_PRD_LNK_LNK_TYPE_ID_CAT_PRD_LNK_TYPE_LNK_TYPE_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_LNK_LNK_TYPE_ID_CAT_PRD_LNK_TYPE_LNK_TYPE_ID" table="catalog_product_link" column="link_type_id" referenceTable="catalog_product_link_type" referenceColumn="link_type_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOG_PRODUCT_LINK_LINK_TYPE_ID_PRODUCT_ID_LINKED_PRODUCT_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_LINK_LINK_TYPE_ID_PRODUCT_ID_LINKED_PRODUCT_ID"> <column name="link_type_id"/> <column name="product_id"/> <column name="linked_product_id"/> </constraint> - <index name="CATALOG_PRODUCT_LINK_PRODUCT_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_LINK_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> - <index name="CATALOG_PRODUCT_LINK_LINKED_PRODUCT_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_LINK_LINKED_PRODUCT_ID" indexType="btree"> <column name="linked_product_id"/> </index> </table> @@ -640,13 +640,13 @@ <column xsi:type="varchar" name="product_link_attribute_code" nullable="true" length="32" comment="Product Link Attribute Code"/> <column xsi:type="varchar" name="data_type" nullable="true" length="32" comment="Data Type"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="product_link_attribute_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_LNK_ATTR_LNK_TYPE_ID_CAT_PRD_LNK_TYPE_LNK_TYPE_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_LNK_ATTR_LNK_TYPE_ID_CAT_PRD_LNK_TYPE_LNK_TYPE_ID" table="catalog_product_link_attribute" column="link_type_id" referenceTable="catalog_product_link_type" referenceColumn="link_type_id" onDelete="CASCADE"/> - <index name="CATALOG_PRODUCT_LINK_ATTRIBUTE_LINK_TYPE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_LINK_ATTRIBUTE_LINK_TYPE_ID" indexType="btree"> <column name="link_type_id"/> </index> </table> @@ -660,21 +660,21 @@ comment="Link ID"/> <column xsi:type="decimal" name="value" scale="4" precision="12" unsigned="false" nullable="false" default="0" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_LNK_ATTR_DEC_LNK_ID_CAT_PRD_LNK_LNK_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_LNK_ATTR_DEC_LNK_ID_CAT_PRD_LNK_LNK_ID" table="catalog_product_link_attribute_decimal" column="link_id" referenceTable="catalog_product_link" referenceColumn="link_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="FK_AB2EFA9A14F7BCF1D5400056203D14B6" + <constraint xsi:type="foreign" referenceId="FK_AB2EFA9A14F7BCF1D5400056203D14B6" table="catalog_product_link_attribute_decimal" column="product_link_attribute_id" referenceTable="catalog_product_link_attribute" referenceColumn="product_link_attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CAT_PRD_LNK_ATTR_DEC_PRD_LNK_ATTR_ID_LNK_ID"> + <constraint xsi:type="unique" referenceId="CAT_PRD_LNK_ATTR_DEC_PRD_LNK_ATTR_ID_LNK_ID"> <column name="product_link_attribute_id"/> <column name="link_id"/> </constraint> - <index name="CATALOG_PRODUCT_LINK_ATTRIBUTE_DECIMAL_LINK_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_LINK_ATTRIBUTE_DECIMAL_LINK_ID" indexType="btree"> <column name="link_id"/> </index> </table> @@ -688,21 +688,21 @@ comment="Link ID"/> <column xsi:type="int" name="value" padding="11" unsigned="false" nullable="false" identity="false" default="0" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_LNK_ATTR_INT_LNK_ID_CAT_PRD_LNK_LNK_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_LNK_ATTR_INT_LNK_ID_CAT_PRD_LNK_LNK_ID" table="catalog_product_link_attribute_int" column="link_id" referenceTable="catalog_product_link" referenceColumn="link_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="FK_D6D878F8BA2A4282F8DDED7E6E3DE35C" + <constraint xsi:type="foreign" referenceId="FK_D6D878F8BA2A4282F8DDED7E6E3DE35C" table="catalog_product_link_attribute_int" column="product_link_attribute_id" referenceTable="catalog_product_link_attribute" referenceColumn="product_link_attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CAT_PRD_LNK_ATTR_INT_PRD_LNK_ATTR_ID_LNK_ID"> + <constraint xsi:type="unique" referenceId="CAT_PRD_LNK_ATTR_INT_PRD_LNK_ATTR_ID_LNK_ID"> <column name="product_link_attribute_id"/> <column name="link_id"/> </constraint> - <index name="CATALOG_PRODUCT_LINK_ATTRIBUTE_INT_LINK_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_LINK_ATTRIBUTE_INT_LINK_ID" indexType="btree"> <column name="link_id"/> </index> </table> @@ -715,21 +715,21 @@ <column xsi:type="int" name="link_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Link ID"/> <column xsi:type="varchar" name="value" nullable="true" length="255" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_LNK_ATTR_VCHR_LNK_ID_CAT_PRD_LNK_LNK_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_LNK_ATTR_VCHR_LNK_ID_CAT_PRD_LNK_LNK_ID" table="catalog_product_link_attribute_varchar" column="link_id" referenceTable="catalog_product_link" referenceColumn="link_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="FK_DEE9C4DA61CFCC01DFCF50F0D79CEA51" + <constraint xsi:type="foreign" referenceId="FK_DEE9C4DA61CFCC01DFCF50F0D79CEA51" table="catalog_product_link_attribute_varchar" column="product_link_attribute_id" referenceTable="catalog_product_link_attribute" referenceColumn="product_link_attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CAT_PRD_LNK_ATTR_VCHR_PRD_LNK_ATTR_ID_LNK_ID"> + <constraint xsi:type="unique" referenceId="CAT_PRD_LNK_ATTR_VCHR_PRD_LNK_ATTR_ID_LNK_ID"> <column name="product_link_attribute_id"/> <column name="link_id"/> </constraint> - <index name="CATALOG_PRODUCT_LINK_ATTRIBUTE_VARCHAR_LINK_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_LINK_ATTRIBUTE_VARCHAR_LINK_ID" indexType="btree"> <column name="link_id"/> </index> </table> @@ -751,29 +751,29 @@ comment="Website ID"/> <column xsi:type="decimal" name="percentage_value" scale="2" precision="5" unsigned="false" nullable="true" comment="Percentage value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_TIER_PRICE_CSTR_GROUP_ID_CSTR_GROUP_CSTR_GROUP_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_TIER_PRICE_CSTR_GROUP_ID_CSTR_GROUP_CSTR_GROUP_ID" table="catalog_product_entity_tier_price" column="customer_group_id" referenceTable="customer_group" referenceColumn="customer_group_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_TIER_PRICE_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_TIER_PRICE_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_entity_tier_price" column="entity_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_TIER_PRICE_WS_ID_STORE_WS_WS_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_TIER_PRICE_WS_ID_STORE_WS_WS_ID" table="catalog_product_entity_tier_price" column="website_id" referenceTable="store_website" referenceColumn="website_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="UNQ_E8AB433B9ACB00343ABB312AD2FAB087"> + <constraint xsi:type="unique" referenceId="UNQ_E8AB433B9ACB00343ABB312AD2FAB087"> <column name="entity_id"/> <column name="all_groups"/> <column name="customer_group_id"/> <column name="qty"/> <column name="website_id"/> </constraint> - <index name="CATALOG_PRODUCT_ENTITY_TIER_PRICE_CUSTOMER_GROUP_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_TIER_PRICE_CUSTOMER_GROUP_ID" indexType="btree"> <column name="customer_group_id"/> </index> - <index name="CATALOG_PRODUCT_ENTITY_TIER_PRICE_WEBSITE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_TIER_PRICE_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> </table> @@ -788,13 +788,13 @@ comment="Media entry type"/> <column xsi:type="smallint" name="disabled" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Visibility status"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_MDA_GLR_ATTR_ID_EAV_ATTR_ATTR_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_MDA_GLR_ATTR_ID_EAV_ATTR_ATTR_ID" table="catalog_product_entity_media_gallery" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <index name="CATALOG_PRODUCT_ENTITY_MEDIA_GALLERY_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_MEDIA_GALLERY_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> </table> @@ -813,26 +813,26 @@ default="0" comment="Is Disabled"/> <column xsi:type="int" name="record_id" padding="10" unsigned="true" nullable="false" identity="true" comment="Record Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="record_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_MDA_GLR_VAL_VAL_ID_CAT_PRD_ENTT_MDA_GLR_VAL_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_MDA_GLR_VAL_VAL_ID_CAT_PRD_ENTT_MDA_GLR_VAL_ID" table="catalog_product_entity_media_gallery_value" column="value_id" referenceTable="catalog_product_entity_media_gallery" referenceColumn="value_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_MDA_GLR_VAL_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_MDA_GLR_VAL_STORE_ID_STORE_STORE_ID" table="catalog_product_entity_media_gallery_value" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_MDA_GLR_VAL_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_MDA_GLR_VAL_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_entity_media_gallery_value" column="entity_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="CATALOG_PRODUCT_ENTITY_MEDIA_GALLERY_VALUE_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_MEDIA_GALLERY_VALUE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="CATALOG_PRODUCT_ENTITY_MEDIA_GALLERY_VALUE_ENTITY_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_MEDIA_GALLERY_VALUE_ENTITY_ID" indexType="btree"> <column name="entity_id"/> </index> - <index name="CATALOG_PRODUCT_ENTITY_MEDIA_GALLERY_VALUE_VALUE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_ENTITY_MEDIA_GALLERY_VALUE_VALUE_ID" indexType="btree"> <column name="value_id"/> </index> </table> @@ -854,13 +854,13 @@ comment="Image Size Y"/> <column xsi:type="int" name="sort_order" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Sort Order"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="option_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_OPT_PRD_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_option" + <constraint xsi:type="foreign" referenceId="CAT_PRD_OPT_PRD_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_option" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="CATALOG_PRODUCT_OPTION_PRODUCT_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_OPTION_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> </table> @@ -875,20 +875,20 @@ <column xsi:type="decimal" name="price" scale="4" precision="12" unsigned="false" nullable="false" default="0" comment="Price"/> <column xsi:type="varchar" name="price_type" nullable="false" length="7" default="fixed" comment="Price Type"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="option_price_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_OPT_PRICE_OPT_ID_CAT_PRD_OPT_OPT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_OPT_PRICE_OPT_ID_CAT_PRD_OPT_OPT_ID" table="catalog_product_option_price" column="option_id" referenceTable="catalog_product_option" referenceColumn="option_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOG_PRODUCT_OPTION_PRICE_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_PRODUCT_OPTION_PRICE_STORE_ID_STORE_STORE_ID" table="catalog_product_option_price" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOG_PRODUCT_OPTION_PRICE_OPTION_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_OPTION_PRICE_OPTION_ID_STORE_ID"> <column name="option_id"/> <column name="store_id"/> </constraint> - <index name="CATALOG_PRODUCT_OPTION_PRICE_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_OPTION_PRICE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -901,20 +901,20 @@ <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Store ID"/> <column xsi:type="varchar" name="title" nullable="true" length="255" comment="Title"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="option_title_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_OPT_TTL_OPT_ID_CAT_PRD_OPT_OPT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_OPT_TTL_OPT_ID_CAT_PRD_OPT_OPT_ID" table="catalog_product_option_title" column="option_id" referenceTable="catalog_product_option" referenceColumn="option_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOG_PRODUCT_OPTION_TITLE_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_PRODUCT_OPTION_TITLE_STORE_ID_STORE_STORE_ID" table="catalog_product_option_title" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOG_PRODUCT_OPTION_TITLE_OPTION_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_OPTION_TITLE_OPTION_ID_STORE_ID"> <column name="option_id"/> <column name="store_id"/> </constraint> - <index name="CATALOG_PRODUCT_OPTION_TITLE_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_OPTION_TITLE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -927,13 +927,13 @@ <column xsi:type="varchar" name="sku" nullable="true" length="64" comment="SKU"/> <column xsi:type="int" name="sort_order" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Sort Order"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="option_type_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_OPT_TYPE_VAL_OPT_ID_CAT_PRD_OPT_OPT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_OPT_TYPE_VAL_OPT_ID_CAT_PRD_OPT_OPT_ID" table="catalog_product_option_type_value" column="option_id" referenceTable="catalog_product_option" referenceColumn="option_id" onDelete="CASCADE"/> - <index name="CATALOG_PRODUCT_OPTION_TYPE_VALUE_OPTION_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_OPTION_TYPE_VALUE_OPTION_ID" indexType="btree"> <column name="option_id"/> </index> </table> @@ -948,21 +948,21 @@ <column xsi:type="decimal" name="price" scale="4" precision="12" unsigned="false" nullable="false" default="0" comment="Price"/> <column xsi:type="varchar" name="price_type" nullable="false" length="7" default="fixed" comment="Price Type"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="option_type_price_id"/> </constraint> - <constraint xsi:type="foreign" name="FK_B523E3378E8602F376CC415825576B7F" + <constraint xsi:type="foreign" referenceId="FK_B523E3378E8602F376CC415825576B7F" table="catalog_product_option_type_price" column="option_type_id" referenceTable="catalog_product_option_type_value" referenceColumn="option_type_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOG_PRODUCT_OPTION_TYPE_PRICE_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_PRODUCT_OPTION_TYPE_PRICE_STORE_ID_STORE_STORE_ID" table="catalog_product_option_type_price" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOG_PRODUCT_OPTION_TYPE_PRICE_OPTION_TYPE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_OPTION_TYPE_PRICE_OPTION_TYPE_ID_STORE_ID"> <column name="option_type_id"/> <column name="store_id"/> </constraint> - <index name="CATALOG_PRODUCT_OPTION_TYPE_PRICE_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_OPTION_TYPE_PRICE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -975,21 +975,21 @@ <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Store ID"/> <column xsi:type="varchar" name="title" nullable="true" length="255" comment="Title"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="option_type_title_id"/> </constraint> - <constraint xsi:type="foreign" name="FK_C085B9CF2C2A302E8043FDEA1937D6A2" + <constraint xsi:type="foreign" referenceId="FK_C085B9CF2C2A302E8043FDEA1937D6A2" table="catalog_product_option_type_title" column="option_type_id" referenceTable="catalog_product_option_type_value" referenceColumn="option_type_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOG_PRODUCT_OPTION_TYPE_TITLE_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_PRODUCT_OPTION_TYPE_TITLE_STORE_ID_STORE_STORE_ID" table="catalog_product_option_type_title" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOG_PRODUCT_OPTION_TYPE_TITLE_OPTION_TYPE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_OPTION_TYPE_TITLE_OPTION_TYPE_ID_STORE_ID"> <column name="option_type_id"/> <column name="store_id"/> </constraint> - <index name="CATALOG_PRODUCT_OPTION_TYPE_TITLE_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_OPTION_TYPE_TITLE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -1037,16 +1037,16 @@ identity="false" default="0" comment="Is Visible in Grid"/> <column xsi:type="smallint" name="is_filterable_in_grid" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Is Filterable in Grid"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="attribute_id"/> </constraint> - <constraint xsi:type="foreign" name="CATALOG_EAV_ATTRIBUTE_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_EAV_ATTRIBUTE_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" table="catalog_eav_attribute" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <index name="CATALOG_EAV_ATTRIBUTE_USED_FOR_SORT_BY" indexType="btree"> + <index referenceId="CATALOG_EAV_ATTRIBUTE_USED_FOR_SORT_BY" indexType="btree"> <column name="used_for_sort_by"/> </index> - <index name="CATALOG_EAV_ATTRIBUTE_USED_IN_PRODUCT_LISTING" indexType="btree"> + <index referenceId="CATALOG_EAV_ATTRIBUTE_USED_IN_PRODUCT_LISTING" indexType="btree"> <column name="used_in_product_listing"/> </index> </table> @@ -1055,17 +1055,17 @@ comment="Parent ID"/> <column xsi:type="int" name="child_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Child ID"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="parent_id"/> <column name="child_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_RELATION_CHILD_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_RELATION_CHILD_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_relation" column="child_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_PRD_RELATION_PARENT_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_RELATION_PARENT_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_relation" column="parent_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="CATALOG_PRODUCT_RELATION_CHILD_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_RELATION_CHILD_ID" indexType="btree"> <column name="child_id"/> </index> </table> @@ -1081,20 +1081,20 @@ comment="Value"/> <column xsi:type="int" name="source_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Original entity Id for attribute value"/> - <constraint xsi:type="primary" name="CAT_PRD_IDX_EAV_ENTT_ID_ATTR_ID_STORE_ID_VAL_SOURCE_ID"> + <constraint xsi:type="primary" referenceId="CAT_PRD_IDX_EAV_ENTT_ID_ATTR_ID_STORE_ID_VAL_SOURCE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> <column name="value"/> <column name="source_id"/> </constraint> - <index name="CATALOG_PRODUCT_INDEX_EAV_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_EAV_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_EAV_VALUE" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_VALUE" indexType="btree"> <column name="value"/> </index> </table> @@ -1110,20 +1110,20 @@ comment="Value"/> <column xsi:type="int" name="source_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Original entity Id for attribute value"/> - <constraint xsi:type="primary" name="CAT_PRD_IDX_EAV_DEC_ENTT_ID_ATTR_ID_STORE_ID_VAL_SOURCE_ID"> + <constraint xsi:type="primary" referenceId="CAT_PRD_IDX_EAV_DEC_ENTT_ID_ATTR_ID_STORE_ID_VAL_SOURCE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> <column name="value"/> <column name="source_id"/> </constraint> - <index name="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_VALUE" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_VALUE" indexType="btree"> <column name="value"/> </index> </table> @@ -1147,18 +1147,18 @@ comment="Max Price"/> <column xsi:type="decimal" name="tier_price" scale="4" precision="12" unsigned="false" nullable="true" comment="Tier Price"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> <column name="customer_group_id"/> <column name="website_id"/> </constraint> - <index name="CATALOG_PRODUCT_INDEX_PRICE_CUSTOMER_GROUP_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_PRICE_CUSTOMER_GROUP_ID" indexType="btree"> <column name="customer_group_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_PRICE_MIN_PRICE" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_PRICE_MIN_PRICE" indexType="btree"> <column name="min_price"/> </index> - <index name="CAT_PRD_IDX_PRICE_WS_ID_CSTR_GROUP_ID_MIN_PRICE" indexType="btree"> + <index referenceId="CAT_PRD_IDX_PRICE_WS_ID_CSTR_GROUP_ID_MIN_PRICE" indexType="btree"> <column name="website_id"/> <column name="customer_group_id"/> <column name="min_price"/> @@ -1174,24 +1174,24 @@ comment="Website ID"/> <column xsi:type="decimal" name="min_price" scale="4" precision="12" unsigned="false" nullable="true" comment="Min Price"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> <column name="customer_group_id"/> <column name="website_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_IDX_TIER_PRICE_CSTR_GROUP_ID_CSTR_GROUP_CSTR_GROUP_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_IDX_TIER_PRICE_CSTR_GROUP_ID_CSTR_GROUP_CSTR_GROUP_ID" table="catalog_product_index_tier_price" column="customer_group_id" referenceTable="customer_group" referenceColumn="customer_group_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_PRD_IDX_TIER_PRICE_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_IDX_TIER_PRICE_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_index_tier_price" column="entity_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_PRD_IDX_TIER_PRICE_WS_ID_STORE_WS_WS_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_IDX_TIER_PRICE_WS_ID_STORE_WS_WS_ID" table="catalog_product_index_tier_price" column="website_id" referenceTable="store_website" referenceColumn="website_id" onDelete="CASCADE"/> - <index name="CATALOG_PRODUCT_INDEX_TIER_PRICE_CUSTOMER_GROUP_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_TIER_PRICE_CUSTOMER_GROUP_ID" indexType="btree"> <column name="customer_group_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_TIER_PRICE_WEBSITE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_TIER_PRICE_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> </table> @@ -1203,12 +1203,12 @@ comment="Default store id for website"/> <column xsi:type="date" name="website_date" comment="Website Date"/> <column xsi:type="float" name="rate" unsigned="false" nullable="true" default="1" comment="Rate"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="website_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_IDX_WS_WS_ID_STORE_WS_WS_ID" table="catalog_product_index_website" + <constraint xsi:type="foreign" referenceId="CAT_PRD_IDX_WS_WS_ID_STORE_WS_WS_ID" table="catalog_product_index_website" column="website_id" referenceTable="store_website" referenceColumn="website_id" onDelete="CASCADE"/> - <index name="CATALOG_PRODUCT_INDEX_WEBSITE_WEBSITE_DATE" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_WEBSITE_WEBSITE_DATE" indexType="btree"> <column name="website_date"/> </index> </table> @@ -1226,7 +1226,7 @@ comment="Price"/> <column xsi:type="decimal" name="tier_price" scale="4" precision="12" unsigned="false" nullable="true" comment="Tier Price"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="parent_id"/> <column name="child_id"/> <column name="customer_group_id"/> @@ -1247,7 +1247,7 @@ comment="Price"/> <column xsi:type="decimal" name="tier_price" scale="4" precision="12" unsigned="false" nullable="true" comment="Tier Price"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="parent_id"/> <column name="child_id"/> <column name="customer_group_id"/> @@ -1268,7 +1268,7 @@ comment="Max Price"/> <column xsi:type="decimal" name="tier_price" scale="4" precision="12" unsigned="false" nullable="true" comment="Tier Price"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> <column name="customer_group_id"/> <column name="website_id"/> @@ -1288,7 +1288,7 @@ comment="Max Price"/> <column xsi:type="decimal" name="tier_price" scale="4" precision="12" unsigned="false" nullable="true" comment="Tier Price"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> <column name="customer_group_id"/> <column name="website_id"/> @@ -1316,7 +1316,7 @@ comment="Tier Price"/> <column xsi:type="decimal" name="base_tier" scale="4" precision="12" unsigned="false" nullable="true" comment="Base Tier"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> <column name="customer_group_id"/> <column name="website_id"/> @@ -1344,7 +1344,7 @@ comment="Tier Price"/> <column xsi:type="decimal" name="base_tier" scale="4" precision="12" unsigned="false" nullable="true" comment="Base Tier"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> <column name="customer_group_id"/> <column name="website_id"/> @@ -1364,7 +1364,7 @@ comment="Max Price"/> <column xsi:type="decimal" name="tier_price" scale="4" precision="12" unsigned="false" nullable="true" comment="Tier Price"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> <column name="customer_group_id"/> <column name="website_id"/> @@ -1384,7 +1384,7 @@ comment="Max Price"/> <column xsi:type="decimal" name="tier_price" scale="4" precision="12" unsigned="false" nullable="true" comment="Tier Price"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> <column name="customer_group_id"/> <column name="website_id"/> @@ -1406,7 +1406,7 @@ comment="Max Price"/> <column xsi:type="decimal" name="tier_price" scale="4" precision="12" unsigned="false" nullable="true" comment="Tier Price"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> <column name="customer_group_id"/> <column name="website_id"/> @@ -1429,7 +1429,7 @@ comment="Max Price"/> <column xsi:type="decimal" name="tier_price" scale="4" precision="12" unsigned="false" nullable="true" comment="Tier Price"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> <column name="customer_group_id"/> <column name="website_id"/> @@ -1448,20 +1448,20 @@ comment="Value"/> <column xsi:type="int" name="source_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Original entity Id for attribute value"/> - <constraint xsi:type="primary" name="CAT_PRD_IDX_EAV_IDX_ENTT_ID_ATTR_ID_STORE_ID_VAL_SOURCE_ID"> + <constraint xsi:type="primary" referenceId="CAT_PRD_IDX_EAV_IDX_ENTT_ID_ATTR_ID_STORE_ID_VAL_SOURCE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> <column name="value"/> <column name="source_id"/> </constraint> - <index name="CATALOG_PRODUCT_INDEX_EAV_IDX_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_IDX_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_EAV_IDX_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_IDX_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_EAV_IDX_VALUE" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_IDX_VALUE" indexType="btree"> <column name="value"/> </index> </table> @@ -1477,20 +1477,20 @@ comment="Value"/> <column xsi:type="int" name="source_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Original entity Id for attribute value"/> - <constraint xsi:type="primary" name="CAT_PRD_IDX_EAV_TMP_ENTT_ID_ATTR_ID_STORE_ID_VAL_SOURCE_ID"> + <constraint xsi:type="primary" referenceId="CAT_PRD_IDX_EAV_TMP_ENTT_ID_ATTR_ID_STORE_ID_VAL_SOURCE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> <column name="value"/> <column name="source_id"/> </constraint> - <index name="CATALOG_PRODUCT_INDEX_EAV_TMP_ATTRIBUTE_ID" indexType="hash"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_TMP_ATTRIBUTE_ID" indexType="hash"> <column name="attribute_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_EAV_TMP_STORE_ID" indexType="hash"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_TMP_STORE_ID" indexType="hash"> <column name="store_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_EAV_TMP_VALUE" indexType="hash"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_TMP_VALUE" indexType="hash"> <column name="value"/> </index> </table> @@ -1506,20 +1506,20 @@ comment="Value"/> <column xsi:type="int" name="source_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Original entity Id for attribute value"/> - <constraint xsi:type="primary" name="CAT_PRD_IDX_EAV_DEC_IDX_ENTT_ID_ATTR_ID_STORE_ID_VAL_SOURCE_ID"> + <constraint xsi:type="primary" referenceId="CAT_PRD_IDX_EAV_DEC_IDX_ENTT_ID_ATTR_ID_STORE_ID_VAL_SOURCE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> <column name="value"/> <column name="source_id"/> </constraint> - <index name="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_IDX_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_IDX_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_IDX_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_IDX_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_IDX_VALUE" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_IDX_VALUE" indexType="btree"> <column name="value"/> </index> </table> @@ -1535,20 +1535,20 @@ comment="Value"/> <column xsi:type="int" name="source_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Original entity Id for attribute value"/> - <constraint xsi:type="primary" name="CAT_PRD_IDX_EAV_DEC_TMP_ENTT_ID_ATTR_ID_STORE_ID_VAL_SOURCE_ID"> + <constraint xsi:type="primary" referenceId="CAT_PRD_IDX_EAV_DEC_TMP_ENTT_ID_ATTR_ID_STORE_ID_VAL_SOURCE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> <column name="value"/> <column name="source_id"/> </constraint> - <index name="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_TMP_ATTRIBUTE_ID" indexType="hash"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_TMP_ATTRIBUTE_ID" indexType="hash"> <column name="attribute_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_TMP_STORE_ID" indexType="hash"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_TMP_STORE_ID" indexType="hash"> <column name="store_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_TMP_VALUE" indexType="hash"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_TMP_VALUE" indexType="hash"> <column name="value"/> </index> </table> @@ -1572,18 +1572,18 @@ comment="Max Price"/> <column xsi:type="decimal" name="tier_price" scale="4" precision="12" unsigned="false" nullable="true" comment="Tier Price"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> <column name="customer_group_id"/> <column name="website_id"/> </constraint> - <index name="CATALOG_PRODUCT_INDEX_PRICE_IDX_CUSTOMER_GROUP_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_PRICE_IDX_CUSTOMER_GROUP_ID" indexType="btree"> <column name="customer_group_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_PRICE_IDX_WEBSITE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_PRICE_IDX_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_PRICE_IDX_MIN_PRICE" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_PRICE_IDX_MIN_PRICE" indexType="btree"> <column name="min_price"/> </index> </table> @@ -1607,18 +1607,18 @@ comment="Max Price"/> <column xsi:type="decimal" name="tier_price" scale="4" precision="12" unsigned="false" nullable="true" comment="Tier Price"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> <column name="customer_group_id"/> <column name="website_id"/> </constraint> - <index name="CATALOG_PRODUCT_INDEX_PRICE_TMP_CUSTOMER_GROUP_ID" indexType="hash"> + <index referenceId="CATALOG_PRODUCT_INDEX_PRICE_TMP_CUSTOMER_GROUP_ID" indexType="hash"> <column name="customer_group_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_PRICE_TMP_WEBSITE_ID" indexType="hash"> + <index referenceId="CATALOG_PRODUCT_INDEX_PRICE_TMP_WEBSITE_ID" indexType="hash"> <column name="website_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_PRICE_TMP_MIN_PRICE" indexType="hash"> + <index referenceId="CATALOG_PRODUCT_INDEX_PRICE_TMP_MIN_PRICE" indexType="hash"> <column name="min_price"/> </index> </table> @@ -1636,12 +1636,12 @@ default="0" comment="Store ID"/> <column xsi:type="smallint" name="visibility" padding="5" unsigned="true" nullable="false" identity="false" comment="Visibility"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="category_id"/> <column name="product_id"/> <column name="store_id"/> </constraint> - <index name="CAT_CTGR_PRD_IDX_TMP_PRD_ID_CTGR_ID_STORE_ID" indexType="hash"> + <index referenceId="CAT_CTGR_PRD_IDX_TMP_PRD_ID_CTGR_ID_STORE_ID" indexType="hash"> <column name="product_id"/> <column name="category_id"/> <column name="store_id"/> @@ -1653,14 +1653,14 @@ comment="Value media Entry ID"/> <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Product Entity ID"/> - <constraint xsi:type="foreign" name="FK_A6C6C8FAA386736921D3A7C4B50B1185" + <constraint xsi:type="foreign" referenceId="FK_A6C6C8FAA386736921D3A7C4B50B1185" table="catalog_product_entity_media_gallery_value_to_entity" column="value_id" referenceTable="catalog_product_entity_media_gallery" referenceColumn="value_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_MDA_GLR_VAL_TO_ENTT_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_MDA_GLR_VAL_TO_ENTT_ENTT_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_entity_media_gallery_value_to_entity" column="entity_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CAT_PRD_ENTT_MDA_GLR_VAL_TO_ENTT_VAL_ID_ENTT_ID"> + <constraint xsi:type="unique" referenceId="CAT_PRD_ENTT_MDA_GLR_VAL_TO_ENTT_VAL_ID_ENTT_ID"> <column name="value_id"/> <column name="entity_id"/> </constraint> @@ -1677,20 +1677,20 @@ comment="Value"/> <column xsi:type="int" name="source_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Original entity Id for attribute value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> <column name="value"/> <column name="source_id"/> </constraint> - <index name="CATALOG_PRODUCT_INDEX_EAV_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_EAV_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_EAV_VALUE" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_VALUE" indexType="btree"> <column name="value"/> </index> </table> @@ -1706,20 +1706,20 @@ comment="Value"/> <column xsi:type="int" name="source_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Original entity Id for attribute value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> <column name="value"/> <column name="source_id"/> </constraint> - <index name="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_VALUE" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_VALUE" indexType="btree"> <column name="value"/> </index> </table> @@ -1743,18 +1743,18 @@ comment="Max Price"/> <column xsi:type="decimal" name="tier_price" scale="4" precision="12" unsigned="false" nullable="true" comment="Tier Price"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> <column name="customer_group_id"/> <column name="website_id"/> </constraint> - <index name="CATALOG_PRODUCT_INDEX_PRICE_CUSTOMER_GROUP_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_PRICE_CUSTOMER_GROUP_ID" indexType="btree"> <column name="customer_group_id"/> </index> - <index name="CATALOG_PRODUCT_INDEX_PRICE_MIN_PRICE" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_INDEX_PRICE_MIN_PRICE" indexType="btree"> <column name="min_price"/> </index> - <index name="CAT_PRD_IDX_PRICE_WS_ID_CSTR_GROUP_ID_MIN_PRICE" indexType="btree"> + <index referenceId="CAT_PRD_IDX_PRICE_WS_ID_CSTR_GROUP_ID_MIN_PRICE" indexType="btree"> <column name="website_id"/> <column name="customer_group_id"/> <column name="min_price"/> @@ -1774,18 +1774,18 @@ default="0" comment="Store ID"/> <column xsi:type="smallint" name="visibility" padding="5" unsigned="true" nullable="false" identity="false" comment="Visibility"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="category_id"/> <column name="product_id"/> <column name="store_id"/> </constraint> - <index name="CAT_CTGR_PRD_IDX_PRD_ID_STORE_ID_CTGR_ID_VISIBILITY" indexType="btree"> + <index referenceId="CAT_CTGR_PRD_IDX_PRD_ID_STORE_ID_CTGR_ID_VISIBILITY" indexType="btree"> <column name="product_id"/> <column name="store_id"/> <column name="category_id"/> <column name="visibility"/> </index> - <index name="CAT_CTGR_PRD_IDX_STORE_ID_CTGR_ID_VISIBILITY_IS_PARENT_POSITION" indexType="btree"> + <index referenceId="CAT_CTGR_PRD_IDX_STORE_ID_CTGR_ID_VISIBILITY_IS_PARENT_POSITION" indexType="btree"> <column name="store_id"/> <column name="category_id"/> <column name="visibility"/> @@ -1806,21 +1806,21 @@ comment="Product Id"/> <column xsi:type="bigint" name="added_at" padding="20" unsigned="false" nullable="false" identity="false" comment="Added At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="action_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_FRONTEND_ACTION_CSTR_ID_CSTR_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_FRONTEND_ACTION_CSTR_ID_CSTR_ENTT_ENTT_ID" table="catalog_product_frontend_action" column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_PRD_FRONTEND_ACTION_PRD_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_FRONTEND_ACTION_PRD_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_frontend_action" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE" /> - <constraint xsi:type="unique" name="CATALOG_PRODUCT_FRONTEND_ACTION_VISITOR_ID_PRODUCT_ID_TYPE_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_FRONTEND_ACTION_VISITOR_ID_PRODUCT_ID_TYPE_ID"> <column name="visitor_id"/> <column name="product_id"/> <column name="type_id"/> </constraint> - <constraint xsi:type="unique" name="CATALOG_PRODUCT_FRONTEND_ACTION_CUSTOMER_ID_PRODUCT_ID_TYPE_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_FRONTEND_ACTION_CUSTOMER_ID_PRODUCT_ID_TYPE_ID"> <column name="customer_id"/> <column name="product_id"/> <column name="type_id"/> diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml index dafea71f872d0..1a54db0d59f0f 100644 --- a/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml +++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml @@ -331,7 +331,6 @@ <item name="type" xsi:type="string">group</item> <item name="config" xsi:type="array"> <item name="breakLine" xsi:type="boolean">true</item> - <item name="required" xsi:type="boolean">true</item> </item> </argument> <field name="filter_price_range" formElement="input"> @@ -341,6 +340,9 @@ </item> </argument> <settings> + <validation> + <rule name="required-entry" xsi:type="boolean">true</rule> + </validation> <additionalClasses> <class name="admin__field-small">true</class> </additionalClasses> diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/options.js b/app/code/Magento/Catalog/view/adminhtml/web/js/options.js index 1ec47f14fee88..7adc0dcfdf408 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/js/options.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/options.js @@ -182,24 +182,16 @@ define([ }); } editForm.on('beforeSubmit', function () { - var optionsValues = [], - optionContainer = optionPanel.find('table tbody'); + var optionContainer = optionPanel.find('table tbody'), + optionsValues; if (optionPanel.hasClass(activePanelClass)) { - optionContainer.find('input') - .each(function () { - if (this.disabled) { - return; - } - - if (this.type === 'checkbox' || this.type === 'radio') { - if (this.checked) { - optionsValues.push(this.name + '=' + jQuery(this).val()); - } - } else { - optionsValues.push(this.name + '=' + jQuery(this).val()); - } - }); + optionsValues = jQuery.map( + optionContainer.find('tr'), + function (row) { + return jQuery(row).find('input, select, textarea').serialize(); + } + ); jQuery('<input>') .attr({ type: 'hidden', diff --git a/app/code/Magento/Catalog/view/frontend/web/js/product/provider.js b/app/code/Magento/Catalog/view/frontend/web/js/product/provider.js index c53b2fa6e2a7a..b29ebe7d57d1c 100644 --- a/app/code/Magento/Catalog/view/frontend/web/js/product/provider.js +++ b/app/code/Magento/Catalog/view/frontend/web/js/product/provider.js @@ -5,11 +5,13 @@ define([ 'underscore', + 'jquery', 'mageUtils', 'uiElement', 'Magento_Catalog/js/product/storage/storage-service', - 'Magento_Customer/js/customer-data' -], function (_, utils, Element, storage, customerData) { + 'Magento_Customer/js/customer-data', + 'Magento_Catalog/js/product/view/product-ids-resolver' +], function (_, $, utils, Element, storage, customerData, productResolver) { 'use strict'; return Element.extend({ @@ -135,11 +137,16 @@ define([ */ filterIds: function (ids) { var _ids = {}, - currentTime = new Date().getTime() / 1000; + currentTime = new Date().getTime() / 1000, + currentProductIds = productResolver($('#product_addtocart_form')); _.each(ids, function (id) { - if (currentTime - id['added_at'] < ~~this.idsStorage.lifetime) { + if ( + currentTime - id['added_at'] < ~~this.idsStorage.lifetime && + !_.contains(currentProductIds, id['product_id']) + ) { _ids[id['product_id']] = id; + } }, this); diff --git a/app/code/Magento/CatalogGraphQl/Model/Resolver/Products/Query/Search.php b/app/code/Magento/CatalogGraphQl/Model/Resolver/Products/Query/Search.php index c4da59fd2cedf..f9b64f3a3c69b 100644 --- a/app/code/Magento/CatalogGraphQl/Model/Resolver/Products/Query/Search.php +++ b/app/code/Magento/CatalogGraphQl/Model/Resolver/Products/Query/Search.php @@ -12,7 +12,6 @@ use Magento\CatalogGraphQl\Model\Resolver\Products\SearchCriteria\Helper\Filter as FilterHelper; use Magento\CatalogGraphQl\Model\Resolver\Products\SearchResult; use Magento\CatalogGraphQl\Model\Resolver\Products\SearchResultFactory; -use Magento\Framework\EntityManager\EntityManager; use Magento\Search\Api\SearchInterface; /** @@ -45,31 +44,42 @@ class Search */ private $metadataPool; + /** + * @var \Magento\Search\Model\Search\PageSizeProvider + */ + private $pageSizeProvider; + /** * @param SearchInterface $search * @param FilterHelper $filterHelper * @param Filter $filterQuery * @param SearchResultFactory $searchResultFactory + * @param \Magento\Framework\EntityManager\MetadataPool $metadataPool + * @param \Magento\Search\Model\Search\PageSizeProvider $pageSize */ public function __construct( SearchInterface $search, FilterHelper $filterHelper, Filter $filterQuery, SearchResultFactory $searchResultFactory, - \Magento\Framework\EntityManager\MetadataPool $metadataPool + \Magento\Framework\EntityManager\MetadataPool $metadataPool, + \Magento\Search\Model\Search\PageSizeProvider $pageSize ) { $this->search = $search; $this->filterHelper = $filterHelper; $this->filterQuery = $filterQuery; $this->searchResultFactory = $searchResultFactory; $this->metadataPool = $metadataPool; + $this->pageSizeProvider = $pageSize; } /** * Return results of full text catalog search of given term, and will return filtered results if filter is specified * * @param SearchCriteriaInterface $searchCriteria + * @param ResolveInfo $info * @return SearchResult + * @throws \Exception */ public function getResult(SearchCriteriaInterface $searchCriteria, ResolveInfo $info) : SearchResult { @@ -79,7 +89,8 @@ public function getResult(SearchCriteriaInterface $searchCriteria, ResolveInfo $ $realPageSize = $searchCriteria->getPageSize(); $realCurrentPage = $searchCriteria->getCurrentPage(); // Current page must be set to 0 and page size to max for search to grab all ID's as temporary workaround - $searchCriteria->setPageSize(PHP_INT_MAX); + $pageSize = $this->pageSizeProvider->getMaxPageSize(); + $searchCriteria->setPageSize($pageSize); $searchCriteria->setCurrentPage(0); $itemsResults = $this->search->search($searchCriteria); diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index 7c56c266a64ef..6f8b2248d8d89 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -1640,7 +1640,16 @@ protected function _saveProducts() } $rowScope = $this->getRowScope($rowData); - $rowData[self::URL_KEY] = $this->getUrlKey($rowData); + $urlKey = $this->getUrlKey($rowData); + if (!empty($rowData[self::URL_KEY])) { + // If url_key column and its value were in the CSV file + $rowData[self::URL_KEY] = $urlKey; + } else if ($this->isNeedToChangeUrlKey($rowData)) { + // If url_key column was empty or even not declared in the CSV file but by the rules it is need to + // be setteed. In case when url_key is generating from name column we have to ensure that the bunch + // of products will pass for the event with url_key column. + $bunch[$rowNum][self::URL_KEY] = $rowData[self::URL_KEY] = $urlKey; + } $rowSku = $rowData[self::COL_SKU]; @@ -2889,6 +2898,26 @@ protected function getResource() return $this->_resource; } + /** + * Whether a url key is needed to be change. + * + * @param array $rowData + * @return bool + */ + private function isNeedToChangeUrlKey(array $rowData): bool + { + $urlKey = $this->getUrlKey($rowData); + $productExists = $this->isSkuExist($rowData[self::COL_SKU]); + $markedToEraseUrlKey = isset($rowData[self::URL_KEY]); + // The product isn't new and the url key index wasn't marked for change. + if (!$urlKey && $productExists && !$markedToEraseUrlKey) { + // Seems there is no need to change the url key + return false; + } + + return true; + } + /** * Get product entity link field * diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/CategoryProcessor.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/CategoryProcessor.php index ffa0d4aff874b..951989146e67e 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/CategoryProcessor.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/CategoryProcessor.php @@ -66,7 +66,7 @@ public function __construct( } /** - * Initialize categories to be processed + * Initialize categories * * @return $this */ @@ -106,7 +106,6 @@ protected function initCategories() * * @param string $name * @param int $parentId - * * @return int */ protected function createCategory($name, $parentId) @@ -116,22 +115,14 @@ protected function createCategory($name, $parentId) if (!($parentCategory = $this->getCategoryById($parentId))) { $parentCategory = $this->categoryFactory->create()->load($parentId); } - - // Set StoreId to 0 to generate URL Keys global and prevent generating url rewrites just for default website - $category->setStoreId(0); $category->setPath($parentCategory->getPath()); $category->setParentId($parentId); $category->setName($this->unquoteDelimiter($name)); $category->setIsActive(true); $category->setIncludeInMenu(true); $category->setAttributeSetId($category->getDefaultAttributeSetId()); - try { - $category->save(); - $this->categoriesCache[$category->getId()] = $category; - } catch (\Exception $e) { - $this->addFailedCategory($category, $e); - } - + $category->save(); + $this->categoriesCache[$category->getId()] = $category; return $category->getId(); } @@ -139,7 +130,6 @@ protected function createCategory($name, $parentId) * Returns ID of category by string path creating nonexistent ones. * * @param string $categoryPath - * * @return int */ protected function upsertCategory($categoryPath) @@ -170,7 +160,6 @@ protected function upsertCategory($categoryPath) * * @param string $categoriesString * @param string $categoriesSeparator - * * @return array */ public function upsertCategories($categoriesString, $categoriesSeparator) diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php index c7eb722050303..fa2853c738624 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php @@ -1794,7 +1794,8 @@ protected function _getSpecificTypeData(array $rowData, $optionTypeId, $defaultS ]; $priceData = false; - if (!empty($rowData[self::COLUMN_ROW_PRICE])) { + $customOptionRowPrice = $rowData[self::COLUMN_ROW_PRICE]; + if (!empty($customOptionRowPrice) || $customOptionRowPrice === '0') { $priceData = [ 'price' => (double)rtrim($rowData[self::COLUMN_ROW_PRICE], '%'), 'price_type' => 'fixed', diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/CategoryProcessorTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/CategoryProcessorTest.php index 69f4a465e3309..919f0cfda7cbe 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/CategoryProcessorTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/CategoryProcessorTest.php @@ -34,41 +34,49 @@ class CategoryProcessorTest extends \PHPUnit\Framework\TestCase */ protected $product; + /** + * @var \Magento\Catalog\Model\Category + */ + private $childCategory; + + /** + * \Magento\Catalog\Model\Category + */ + private $parentCategory; + protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->objectManagerHelper = new ObjectManagerHelper($this); - $childCategory = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) + $this->childCategory = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) ->disableOriginalConstructor() ->getMock(); - $childCategory->method('getId')->will($this->returnValue(self::CHILD_CATEGORY_ID)); - $childCategory->method('getName')->will($this->returnValue(self::CHILD_CATEGORY_NAME)); - $childCategory->method('getPath')->will($this->returnValue( + $this->childCategory->method('getId')->will($this->returnValue(self::CHILD_CATEGORY_ID)); + $this->childCategory->method('getName')->will($this->returnValue(self::CHILD_CATEGORY_NAME)); + $this->childCategory->method('getPath')->will($this->returnValue( self::PARENT_CATEGORY_ID . CategoryProcessor::DELIMITER_CATEGORY . self::CHILD_CATEGORY_ID )); - $childCategory->method('save')->willThrowException(new \Exception()); - - $parentCategory = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) + $this->parentCategory = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) ->disableOriginalConstructor() ->getMock(); - $parentCategory->method('getId')->will($this->returnValue(self::PARENT_CATEGORY_ID)); - $parentCategory->method('getName')->will($this->returnValue('Parent')); - $parentCategory->method('getPath')->will($this->returnValue(self::PARENT_CATEGORY_ID)); + $this->parentCategory->method('getId')->will($this->returnValue(self::PARENT_CATEGORY_ID)); + $this->parentCategory->method('getName')->will($this->returnValue('Parent')); + $this->parentCategory->method('getPath')->will($this->returnValue(self::PARENT_CATEGORY_ID)); $categoryCollection = $this->objectManagerHelper->getCollectionMock( \Magento\Catalog\Model\ResourceModel\Category\Collection::class, [ - self::PARENT_CATEGORY_ID => $parentCategory, - self::CHILD_CATEGORY_ID => $childCategory, + self::PARENT_CATEGORY_ID => $this->parentCategory, + self::CHILD_CATEGORY_ID => $this->childCategory, ] ); $map = [ - [self::PARENT_CATEGORY_ID, $parentCategory], - [self::CHILD_CATEGORY_ID, $childCategory], + [self::PARENT_CATEGORY_ID, $this->parentCategory], + [self::CHILD_CATEGORY_ID, $this->childCategory], ]; $categoryCollection->expects($this->any()) ->method('getItemById') @@ -91,7 +99,7 @@ protected function setUp() $categoryFactory = $this->createPartialMock(\Magento\Catalog\Model\CategoryFactory::class, ['create']); - $categoryFactory->method('create')->will($this->returnValue($childCategory)); + $categoryFactory->method('create')->will($this->returnValue($this->childCategory)); $this->categoryProcessor = new \Magento\CatalogImportExport\Model\Import\Product\CategoryProcessor( @@ -110,11 +118,13 @@ public function testUpsertCategories() /** * Tests case when newly created category save throws exception. */ - public function testCreateCategoryException() + public function testUpsertCategoriesWithAlreadyExistsException() { - $method = new \ReflectionMethod(CategoryProcessor::class, 'createCategory'); - $method->setAccessible(true); - $method->invoke($this->categoryProcessor, self::CHILD_CATEGORY_NAME, self::PARENT_CATEGORY_ID); + $exception = new \Magento\Framework\Exception\AlreadyExistsException(); + $categoriesSeparator = '/'; + $categoryName = 'Exception Category'; + $this->childCategory->method('save')->willThrowException($exception); + $this->categoryProcessor->upsertCategories($categoryName, $categoriesSeparator); $this->assertNotEmpty($this->categoryProcessor->getFailedCategories()); } diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockCollectionInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockCollectionInterface.php index c2521f77ca24a..9ae22e5e1a364 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockCollectionInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockCollectionInterface.php @@ -15,6 +15,10 @@ * Interface StockCollectionInterface * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockCollectionInterface extends SearchResultsInterface { diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockInterface.php index 53e95921ea955..087fae6e6568a 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockInterface.php @@ -11,6 +11,10 @@ * Interface Stock * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockInterface extends ExtensibleDataInterface { diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockItemCollectionInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockItemCollectionInterface.php index 038174c8e52be..59a1f58b74c2c 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockItemCollectionInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockItemCollectionInterface.php @@ -15,6 +15,10 @@ * Interface StockItemCollectionInterface * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockItemCollectionInterface extends SearchResultsInterface { diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockItemInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockItemInterface.php index b876615468ba9..e2e8a744c4bcd 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockItemInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockItemInterface.php @@ -11,6 +11,10 @@ * Interface StockItem * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockItemInterface extends ExtensibleDataInterface { diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockStatusCollectionInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockStatusCollectionInterface.php index 70a2c29ff9a6e..1cc045745a0c1 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockStatusCollectionInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockStatusCollectionInterface.php @@ -11,6 +11,10 @@ * Stock Status collection interface * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockStatusCollectionInterface extends SearchResultsInterface { diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockStatusInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockStatusInterface.php index c9ae6a96a3671..66b639fb088d1 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockStatusInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockStatusInterface.php @@ -11,6 +11,10 @@ * Interface StockStatusInterface * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockStatusInterface extends ExtensibleDataInterface { diff --git a/app/code/Magento/CatalogInventory/Api/RegisterProductSaleInterface.php b/app/code/Magento/CatalogInventory/Api/RegisterProductSaleInterface.php index 9122fb0038646..6fd1e7466970d 100644 --- a/app/code/Magento/CatalogInventory/Api/RegisterProductSaleInterface.php +++ b/app/code/Magento/CatalogInventory/Api/RegisterProductSaleInterface.php @@ -12,6 +12,10 @@ /** * @api + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface RegisterProductSaleInterface { diff --git a/app/code/Magento/CatalogInventory/Api/RevertProductSaleInterface.php b/app/code/Magento/CatalogInventory/Api/RevertProductSaleInterface.php index ed496f3882fc2..552e30da89235 100644 --- a/app/code/Magento/CatalogInventory/Api/RevertProductSaleInterface.php +++ b/app/code/Magento/CatalogInventory/Api/RevertProductSaleInterface.php @@ -9,6 +9,10 @@ /** * @api + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface RevertProductSaleInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockConfigurationInterface.php b/app/code/Magento/CatalogInventory/Api/StockConfigurationInterface.php index a23d5030b8242..5019e86b7af40 100644 --- a/app/code/Magento/CatalogInventory/Api/StockConfigurationInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockConfigurationInterface.php @@ -9,6 +9,10 @@ * Interface StockConfigurationInterface * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockConfigurationInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockCriteriaInterface.php b/app/code/Magento/CatalogInventory/Api/StockCriteriaInterface.php index 969af6481cb4a..eb6fb2e812f2e 100644 --- a/app/code/Magento/CatalogInventory/Api/StockCriteriaInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockCriteriaInterface.php @@ -9,6 +9,10 @@ * Interface StockCriteriaInterface * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockCriteriaInterface extends \Magento\Framework\Api\CriteriaInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockIndexInterface.php b/app/code/Magento/CatalogInventory/Api/StockIndexInterface.php index 1521b34c715b0..18bab6571c209 100644 --- a/app/code/Magento/CatalogInventory/Api/StockIndexInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockIndexInterface.php @@ -9,6 +9,10 @@ * Interface StockIndexInterface * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockIndexInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockItemCriteriaInterface.php b/app/code/Magento/CatalogInventory/Api/StockItemCriteriaInterface.php index a2fc7801b1d13..1d2cabbb48a11 100644 --- a/app/code/Magento/CatalogInventory/Api/StockItemCriteriaInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockItemCriteriaInterface.php @@ -9,6 +9,10 @@ * Interface StockItemCriteriaInterface * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockItemCriteriaInterface extends \Magento\Framework\Api\CriteriaInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockItemRepositoryInterface.php b/app/code/Magento/CatalogInventory/Api/StockItemRepositoryInterface.php index 2732048d1445f..eecf6cbe07632 100644 --- a/app/code/Magento/CatalogInventory/Api/StockItemRepositoryInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockItemRepositoryInterface.php @@ -9,6 +9,10 @@ * Interface StockItemRepository * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockItemRepositoryInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockManagementInterface.php b/app/code/Magento/CatalogInventory/Api/StockManagementInterface.php index ddb84abf3d1a5..8796953e32fd0 100644 --- a/app/code/Magento/CatalogInventory/Api/StockManagementInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockManagementInterface.php @@ -9,6 +9,10 @@ * Interface StockManagementInterface * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockManagementInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockRegistryInterface.php b/app/code/Magento/CatalogInventory/Api/StockRegistryInterface.php index 2d011e24f4105..5478f90fb7d9f 100644 --- a/app/code/Magento/CatalogInventory/Api/StockRegistryInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockRegistryInterface.php @@ -9,6 +9,10 @@ * Interface StockRegistryInterface * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockRegistryInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockRepositoryInterface.php b/app/code/Magento/CatalogInventory/Api/StockRepositoryInterface.php index 80a7e79289cff..3cfdf45506340 100644 --- a/app/code/Magento/CatalogInventory/Api/StockRepositoryInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockRepositoryInterface.php @@ -9,6 +9,10 @@ * Interface StockRepositoryInterface * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockRepositoryInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockStateInterface.php b/app/code/Magento/CatalogInventory/Api/StockStateInterface.php index 8a1f7da5158ed..8be7f5be79f27 100644 --- a/app/code/Magento/CatalogInventory/Api/StockStateInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockStateInterface.php @@ -9,6 +9,10 @@ * Interface StockStateInterface * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockStateInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockStatusCriteriaInterface.php b/app/code/Magento/CatalogInventory/Api/StockStatusCriteriaInterface.php index e504e6355a15a..99ad7005d9da4 100644 --- a/app/code/Magento/CatalogInventory/Api/StockStatusCriteriaInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockStatusCriteriaInterface.php @@ -9,6 +9,10 @@ * Interface StockStatusCriteriaInterface * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockStatusCriteriaInterface extends \Magento\Framework\Api\CriteriaInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockStatusRepositoryInterface.php b/app/code/Magento/CatalogInventory/Api/StockStatusRepositoryInterface.php index 94d4998c1e318..d29171f557f05 100644 --- a/app/code/Magento/CatalogInventory/Api/StockStatusRepositoryInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockStatusRepositoryInterface.php @@ -9,6 +9,10 @@ * Interface StockStatusRepositoryInterface * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockStatusRepositoryInterface { diff --git a/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php b/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php index 15dfbd122e950..d3c165bbde1a8 100644 --- a/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php +++ b/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php @@ -10,6 +10,10 @@ * * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ class Minsaleqty extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray { diff --git a/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php b/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php index 2c41e1798921a..5378801b6c24b 100644 --- a/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php +++ b/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php @@ -14,6 +14,10 @@ /** * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ class Stock extends \Magento\Framework\Data\Form\Element\Select { diff --git a/app/code/Magento/CatalogInventory/Block/Qtyincrements.php b/app/code/Magento/CatalogInventory/Block/Qtyincrements.php index adaa762f3279b..a12b72cd0a971 100644 --- a/app/code/Magento/CatalogInventory/Block/Qtyincrements.php +++ b/app/code/Magento/CatalogInventory/Block/Qtyincrements.php @@ -14,6 +14,10 @@ * * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ class Qtyincrements extends Template implements IdentityInterface { diff --git a/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php b/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php index c315338be0de0..5a3a3ca6ee983 100644 --- a/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php +++ b/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php @@ -11,6 +11,10 @@ * * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ class DefaultStockqty extends AbstractStockqty implements \Magento\Framework\DataObject\IdentityInterface { diff --git a/app/code/Magento/CatalogInventory/Helper/Stock.php b/app/code/Magento/CatalogInventory/Helper/Stock.php index 494d440eeed89..798ac4074c188 100644 --- a/app/code/Magento/CatalogInventory/Helper/Stock.php +++ b/app/code/Magento/CatalogInventory/Helper/Stock.php @@ -18,6 +18,10 @@ * Class Stock * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ class Stock { diff --git a/app/code/Magento/CatalogInventory/Model/Adminhtml/Stock/Item.php b/app/code/Magento/CatalogInventory/Model/Adminhtml/Stock/Item.php index 36721db874887..145b0d1454ae2 100644 --- a/app/code/Magento/CatalogInventory/Model/Adminhtml/Stock/Item.php +++ b/app/code/Magento/CatalogInventory/Model/Adminhtml/Stock/Item.php @@ -20,6 +20,10 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ class Item extends \Magento\CatalogInventory\Model\Stock\Item implements IdentityInterface { diff --git a/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator.php b/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator.php index b86c3cf13f31b..502d9532e8a05 100644 --- a/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator.php +++ b/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator.php @@ -25,6 +25,10 @@ * @api * @since 100.0.2 * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ class QuantityValidator { diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php index 366cb1c3902a3..ba3b62f554767 100644 --- a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php @@ -18,6 +18,10 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ class DefaultStock extends AbstractIndexer implements StockInterface { diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/QueryProcessorInterface.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/QueryProcessorInterface.php index abe473bd9682b..115002b237645 100644 --- a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/QueryProcessorInterface.php +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/QueryProcessorInterface.php @@ -11,6 +11,10 @@ /** * @api * @since 100.1.0 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface QueryProcessorInterface { diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/StockInterface.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/StockInterface.php index 5ced55edf208b..24ed496372817 100644 --- a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/StockInterface.php +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/StockInterface.php @@ -9,6 +9,10 @@ * CatalogInventory Stock Indexer Interface * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockInterface { diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/StockFactory.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/StockFactory.php index f9738484766b9..0ee162e429f40 100644 --- a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/StockFactory.php +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/StockFactory.php @@ -12,6 +12,10 @@ /** * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ class StockFactory { diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock/Status.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock/Status.php index bc5fda4939adc..402ce5f2f611e 100644 --- a/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock/Status.php +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock/Status.php @@ -13,6 +13,10 @@ * CatalogInventory Stock Status per website Resource Model * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ class Status extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { diff --git a/app/code/Magento/CatalogInventory/Model/Source/Backorders.php b/app/code/Magento/CatalogInventory/Model/Source/Backorders.php index 1d200d27a4445..0bffb9a9888cd 100644 --- a/app/code/Magento/CatalogInventory/Model/Source/Backorders.php +++ b/app/code/Magento/CatalogInventory/Model/Source/Backorders.php @@ -9,6 +9,10 @@ * Back orders source class * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ class Backorders implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/CatalogInventory/Model/Source/Stock.php b/app/code/Magento/CatalogInventory/Model/Source/Stock.php index 9ed891d1dcc0f..7d44ab782de61 100644 --- a/app/code/Magento/CatalogInventory/Model/Source/Stock.php +++ b/app/code/Magento/CatalogInventory/Model/Source/Stock.php @@ -11,6 +11,10 @@ * CatalogInventory Stock source model * @api * @since 100.0.2 + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ class Stock extends AbstractSource { diff --git a/app/code/Magento/CatalogInventory/composer.json b/app/code/Magento/CatalogInventory/composer.json index 8b55b6f327988..007d744b2296f 100644 --- a/app/code/Magento/CatalogInventory/composer.json +++ b/app/code/Magento/CatalogInventory/composer.json @@ -27,5 +27,6 @@ "psr-4": { "Magento\\CatalogInventory\\": "" } - } + }, + "abandoned": "magento/inventory-composer-metapackage" } diff --git a/app/code/Magento/CatalogInventory/etc/db_schema.xml b/app/code/Magento/CatalogInventory/etc/db_schema.xml index 8a6ae8d2d93c6..5ac7fedc5aa18 100644 --- a/app/code/Magento/CatalogInventory/etc/db_schema.xml +++ b/app/code/Magento/CatalogInventory/etc/db_schema.xml @@ -13,10 +13,10 @@ <column xsi:type="smallint" name="website_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Website Id"/> <column xsi:type="varchar" name="stock_name" nullable="true" length="255" comment="Stock Name"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="stock_id"/> </constraint> - <index name="CATALOGINVENTORY_STOCK_WEBSITE_ID" indexType="btree"> + <index referenceId="CATALOGINVENTORY_STOCK_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> </table> @@ -71,23 +71,23 @@ identity="false" default="0" comment="Is Divided into Multiple Boxes for Shipping"/> <column xsi:type="smallint" name="website_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Website ID"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="item_id"/> </constraint> - <constraint xsi:type="foreign" name="CATINV_STOCK_ITEM_PRD_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CATINV_STOCK_ITEM_PRD_ID_CAT_PRD_ENTT_ENTT_ID" table="cataloginventory_stock_item" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATINV_STOCK_ITEM_STOCK_ID_CATINV_STOCK_STOCK_ID" + <constraint xsi:type="foreign" referenceId="CATINV_STOCK_ITEM_STOCK_ID_CATINV_STOCK_STOCK_ID" table="cataloginventory_stock_item" column="stock_id" referenceTable="cataloginventory_stock" referenceColumn="stock_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOGINVENTORY_STOCK_ITEM_PRODUCT_ID_STOCK_ID"> + <constraint xsi:type="unique" referenceId="CATALOGINVENTORY_STOCK_ITEM_PRODUCT_ID_STOCK_ID"> <column name="product_id"/> <column name="stock_id"/> </constraint> - <index name="CATALOGINVENTORY_STOCK_ITEM_WEBSITE_ID" indexType="btree"> + <index referenceId="CATALOGINVENTORY_STOCK_ITEM_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> - <index name="CATALOGINVENTORY_STOCK_ITEM_STOCK_ID" indexType="btree"> + <index referenceId="CATALOGINVENTORY_STOCK_ITEM_STOCK_ID" indexType="btree"> <column name="stock_id"/> </index> </table> @@ -103,18 +103,18 @@ comment="Qty"/> <column xsi:type="smallint" name="stock_status" padding="5" unsigned="true" nullable="false" identity="false" comment="Stock Status"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="product_id"/> <column name="website_id"/> <column name="stock_id"/> </constraint> - <index name="CATALOGINVENTORY_STOCK_STATUS_STOCK_ID" indexType="btree"> + <index referenceId="CATALOGINVENTORY_STOCK_STATUS_STOCK_ID" indexType="btree"> <column name="stock_id"/> </index> - <index name="CATALOGINVENTORY_STOCK_STATUS_WEBSITE_ID" indexType="btree"> + <index referenceId="CATALOGINVENTORY_STOCK_STATUS_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> - <index name="CATALOGINVENTORY_STOCK_STATUS_STOCK_STATUS" indexType="btree"> + <index referenceId="CATALOGINVENTORY_STOCK_STATUS_STOCK_STATUS" indexType="btree"> <column name="stock_status"/> </index> </table> @@ -130,15 +130,15 @@ comment="Qty"/> <column xsi:type="smallint" name="stock_status" padding="5" unsigned="true" nullable="false" identity="false" comment="Stock Status"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="product_id"/> <column name="website_id"/> <column name="stock_id"/> </constraint> - <index name="CATALOGINVENTORY_STOCK_STATUS_IDX_STOCK_ID" indexType="btree"> + <index referenceId="CATALOGINVENTORY_STOCK_STATUS_IDX_STOCK_ID" indexType="btree"> <column name="stock_id"/> </index> - <index name="CATALOGINVENTORY_STOCK_STATUS_IDX_WEBSITE_ID" indexType="btree"> + <index referenceId="CATALOGINVENTORY_STOCK_STATUS_IDX_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> </table> @@ -154,15 +154,15 @@ comment="Qty"/> <column xsi:type="smallint" name="stock_status" padding="5" unsigned="true" nullable="false" identity="false" comment="Stock Status"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="product_id"/> <column name="website_id"/> <column name="stock_id"/> </constraint> - <index name="CATALOGINVENTORY_STOCK_STATUS_TMP_STOCK_ID" indexType="hash"> + <index referenceId="CATALOGINVENTORY_STOCK_STATUS_TMP_STOCK_ID" indexType="hash"> <column name="stock_id"/> </index> - <index name="CATALOGINVENTORY_STOCK_STATUS_TMP_WEBSITE_ID" indexType="hash"> + <index referenceId="CATALOGINVENTORY_STOCK_STATUS_TMP_WEBSITE_ID" indexType="hash"> <column name="website_id"/> </index> </table> @@ -178,18 +178,18 @@ comment="Qty"/> <column xsi:type="smallint" name="stock_status" padding="5" unsigned="true" nullable="false" identity="false" comment="Stock Status"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="product_id"/> <column name="website_id"/> <column name="stock_id"/> </constraint> - <index name="CATALOGINVENTORY_STOCK_STATUS_STOCK_ID" indexType="btree"> + <index referenceId="CATALOGINVENTORY_STOCK_STATUS_STOCK_ID" indexType="btree"> <column name="stock_id"/> </index> - <index name="CATALOGINVENTORY_STOCK_STATUS_WEBSITE_ID" indexType="btree"> + <index referenceId="CATALOGINVENTORY_STOCK_STATUS_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> - <index name="CATALOGINVENTORY_STOCK_STATUS_STOCK_STATUS" indexType="btree"> + <index referenceId="CATALOGINVENTORY_STOCK_STATUS_STOCK_STATUS" indexType="btree"> <column name="stock_status"/> </index> </table> diff --git a/app/code/Magento/CatalogRule/etc/db_schema.xml b/app/code/Magento/CatalogRule/etc/db_schema.xml index 25c9d866167ce..6f7d713e49fe3 100644 --- a/app/code/Magento/CatalogRule/etc/db_schema.xml +++ b/app/code/Magento/CatalogRule/etc/db_schema.xml @@ -25,10 +25,10 @@ <column xsi:type="varchar" name="simple_action" nullable="true" length="32" comment="Simple Action"/> <column xsi:type="decimal" name="discount_amount" scale="4" precision="12" unsigned="false" nullable="false" default="0" comment="Discount Amount"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="rule_id"/> </constraint> - <index name="CATALOGRULE_IS_ACTIVE_SORT_ORDER_TO_DATE_FROM_DATE" indexType="btree"> + <index referenceId="CATALOGRULE_IS_ACTIVE_SORT_ORDER_TO_DATE_FROM_DATE" indexType="btree"> <column name="is_active"/> <column name="sort_order"/> <column name="to_date"/> @@ -57,10 +57,10 @@ default="0" comment="Sort Order"/> <column xsi:type="smallint" name="website_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Website Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="rule_product_id"/> </constraint> - <constraint xsi:type="unique" name="UNQ_EAA51B56FF092A0DCB795D1CEF812B7B"> + <constraint xsi:type="unique" referenceId="UNQ_EAA51B56FF092A0DCB795D1CEF812B7B"> <column name="rule_id"/> <column name="from_time"/> <column name="to_time"/> @@ -69,19 +69,19 @@ <column name="product_id"/> <column name="sort_order"/> </constraint> - <index name="CATALOGRULE_PRODUCT_CUSTOMER_GROUP_ID" indexType="btree"> + <index referenceId="CATALOGRULE_PRODUCT_CUSTOMER_GROUP_ID" indexType="btree"> <column name="customer_group_id"/> </index> - <index name="CATALOGRULE_PRODUCT_WEBSITE_ID" indexType="btree"> + <index referenceId="CATALOGRULE_PRODUCT_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> - <index name="CATALOGRULE_PRODUCT_FROM_TIME" indexType="btree"> + <index referenceId="CATALOGRULE_PRODUCT_FROM_TIME" indexType="btree"> <column name="from_time"/> </index> - <index name="CATALOGRULE_PRODUCT_TO_TIME" indexType="btree"> + <index referenceId="CATALOGRULE_PRODUCT_TO_TIME" indexType="btree"> <column name="to_time"/> </index> - <index name="CATALOGRULE_PRODUCT_PRODUCT_ID" indexType="btree"> + <index referenceId="CATALOGRULE_PRODUCT_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> </table> @@ -98,22 +98,22 @@ comment="Website Id"/> <column xsi:type="date" name="latest_start_date" comment="Latest StartDate"/> <column xsi:type="date" name="earliest_end_date" comment="Earliest EndDate"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="rule_product_price_id"/> </constraint> - <constraint xsi:type="unique" name="CATRULE_PRD_PRICE_RULE_DATE_WS_ID_CSTR_GROUP_ID_PRD_ID"> + <constraint xsi:type="unique" referenceId="CATRULE_PRD_PRICE_RULE_DATE_WS_ID_CSTR_GROUP_ID_PRD_ID"> <column name="rule_date"/> <column name="website_id"/> <column name="customer_group_id"/> <column name="product_id"/> </constraint> - <index name="CATALOGRULE_PRODUCT_PRICE_CUSTOMER_GROUP_ID" indexType="btree"> + <index referenceId="CATALOGRULE_PRODUCT_PRICE_CUSTOMER_GROUP_ID" indexType="btree"> <column name="customer_group_id"/> </index> - <index name="CATALOGRULE_PRODUCT_PRICE_WEBSITE_ID" indexType="btree"> + <index referenceId="CATALOGRULE_PRODUCT_PRICE_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> - <index name="CATALOGRULE_PRODUCT_PRICE_PRODUCT_ID" indexType="btree"> + <index referenceId="CATALOGRULE_PRODUCT_PRICE_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> </table> @@ -124,15 +124,15 @@ default="0" comment="Customer Group Id"/> <column xsi:type="smallint" name="website_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Website Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="rule_id"/> <column name="customer_group_id"/> <column name="website_id"/> </constraint> - <index name="CATALOGRULE_GROUP_WEBSITE_CUSTOMER_GROUP_ID" indexType="btree"> + <index referenceId="CATALOGRULE_GROUP_WEBSITE_CUSTOMER_GROUP_ID" indexType="btree"> <column name="customer_group_id"/> </index> - <index name="CATALOGRULE_GROUP_WEBSITE_WEBSITE_ID" indexType="btree"> + <index referenceId="CATALOGRULE_GROUP_WEBSITE_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> </table> @@ -141,17 +141,17 @@ comment="Rule ID"/> <column xsi:type="smallint" name="website_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Website Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="rule_id"/> <column name="website_id"/> </constraint> - <constraint xsi:type="foreign" name="CATALOGRULE_WEBSITE_RULE_ID_CATALOGRULE_RULE_ID" + <constraint xsi:type="foreign" referenceId="CATALOGRULE_WEBSITE_RULE_ID_CATALOGRULE_RULE_ID" table="catalogrule_website" column="rule_id" referenceTable="catalogrule" referenceColumn="rule_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOGRULE_WEBSITE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" + <constraint xsi:type="foreign" referenceId="CATALOGRULE_WEBSITE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" table="catalogrule_website" column="website_id" referenceTable="store_website" referenceColumn="website_id" onDelete="CASCADE"/> - <index name="CATALOGRULE_WEBSITE_WEBSITE_ID" indexType="btree"> + <index referenceId="CATALOGRULE_WEBSITE_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> </table> @@ -161,17 +161,17 @@ comment="Rule ID"/> <column xsi:type="int" name="customer_group_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Customer Group Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="rule_id"/> <column name="customer_group_id"/> </constraint> - <constraint xsi:type="foreign" name="CATALOGRULE_CUSTOMER_GROUP_RULE_ID_CATALOGRULE_RULE_ID" + <constraint xsi:type="foreign" referenceId="CATALOGRULE_CUSTOMER_GROUP_RULE_ID_CATALOGRULE_RULE_ID" table="catalogrule_customer_group" column="rule_id" referenceTable="catalogrule" referenceColumn="rule_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATRULE_CSTR_GROUP_CSTR_GROUP_ID_CSTR_GROUP_CSTR_GROUP_ID" + <constraint xsi:type="foreign" referenceId="CATRULE_CSTR_GROUP_CSTR_GROUP_ID_CSTR_GROUP_CSTR_GROUP_ID" table="catalogrule_customer_group" column="customer_group_id" referenceTable="customer_group" referenceColumn="customer_group_id" onDelete="CASCADE"/> - <index name="CATALOGRULE_CUSTOMER_GROUP_CUSTOMER_GROUP_ID" indexType="btree"> + <index referenceId="CATALOGRULE_CUSTOMER_GROUP_CUSTOMER_GROUP_ID" indexType="btree"> <column name="customer_group_id"/> </index> </table> @@ -197,10 +197,10 @@ default="0" comment="Sort Order"/> <column xsi:type="smallint" name="website_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Website Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="rule_product_id"/> </constraint> - <constraint xsi:type="unique" name="UNQ_EAA51B56FF092A0DCB795D1CEF812B7B"> + <constraint xsi:type="unique" referenceId="UNQ_EAA51B56FF092A0DCB795D1CEF812B7B"> <column name="rule_id"/> <column name="from_time"/> <column name="to_time"/> @@ -209,19 +209,19 @@ <column name="product_id"/> <column name="sort_order"/> </constraint> - <index name="CATALOGRULE_PRODUCT_CUSTOMER_GROUP_ID" indexType="btree"> + <index referenceId="CATALOGRULE_PRODUCT_CUSTOMER_GROUP_ID" indexType="btree"> <column name="customer_group_id"/> </index> - <index name="CATALOGRULE_PRODUCT_WEBSITE_ID" indexType="btree"> + <index referenceId="CATALOGRULE_PRODUCT_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> - <index name="CATALOGRULE_PRODUCT_FROM_TIME" indexType="btree"> + <index referenceId="CATALOGRULE_PRODUCT_FROM_TIME" indexType="btree"> <column name="from_time"/> </index> - <index name="CATALOGRULE_PRODUCT_TO_TIME" indexType="btree"> + <index referenceId="CATALOGRULE_PRODUCT_TO_TIME" indexType="btree"> <column name="to_time"/> </index> - <index name="CATALOGRULE_PRODUCT_PRODUCT_ID" indexType="btree"> + <index referenceId="CATALOGRULE_PRODUCT_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> </table> @@ -239,22 +239,22 @@ comment="Website Id"/> <column xsi:type="date" name="latest_start_date" comment="Latest StartDate"/> <column xsi:type="date" name="earliest_end_date" comment="Earliest EndDate"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="rule_product_price_id"/> </constraint> - <constraint xsi:type="unique" name="CATRULE_PRD_PRICE_RULE_DATE_WS_ID_CSTR_GROUP_ID_PRD_ID"> + <constraint xsi:type="unique" referenceId="CATRULE_PRD_PRICE_RULE_DATE_WS_ID_CSTR_GROUP_ID_PRD_ID"> <column name="rule_date"/> <column name="website_id"/> <column name="customer_group_id"/> <column name="product_id"/> </constraint> - <index name="CATALOGRULE_PRODUCT_PRICE_CUSTOMER_GROUP_ID" indexType="btree"> + <index referenceId="CATALOGRULE_PRODUCT_PRICE_CUSTOMER_GROUP_ID" indexType="btree"> <column name="customer_group_id"/> </index> - <index name="CATALOGRULE_PRODUCT_PRICE_WEBSITE_ID" indexType="btree"> + <index referenceId="CATALOGRULE_PRODUCT_PRICE_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> - <index name="CATALOGRULE_PRODUCT_PRICE_PRODUCT_ID" indexType="btree"> + <index referenceId="CATALOGRULE_PRODUCT_PRICE_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> </table> @@ -266,15 +266,15 @@ default="0" comment="Customer Group Id"/> <column xsi:type="smallint" name="website_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Website Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="rule_id"/> <column name="customer_group_id"/> <column name="website_id"/> </constraint> - <index name="CATALOGRULE_GROUP_WEBSITE_CUSTOMER_GROUP_ID" indexType="btree"> + <index referenceId="CATALOGRULE_GROUP_WEBSITE_CUSTOMER_GROUP_ID" indexType="btree"> <column name="customer_group_id"/> </index> - <index name="CATALOGRULE_GROUP_WEBSITE_WEBSITE_ID" indexType="btree"> + <index referenceId="CATALOGRULE_GROUP_WEBSITE_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> </table> diff --git a/app/code/Magento/CatalogSearch/Block/Advanced/Form.php b/app/code/Magento/CatalogSearch/Block/Advanced/Form.php index 863165ecf720d..681b7ecfb02dc 100644 --- a/app/code/Magento/CatalogSearch/Block/Advanced/Form.php +++ b/app/code/Magento/CatalogSearch/Block/Advanced/Form.php @@ -4,11 +4,6 @@ * See COPYING.txt for license details. */ -/** - * Advanced search form - * - * @author Magento Core Team <core@magentocommerce.com> - */ namespace Magento\CatalogSearch\Block\Advanced; use Magento\CatalogSearch\Model\Advanced; @@ -21,10 +16,10 @@ use Magento\Framework\View\Element\Template\Context; /** + * Advanced search form + * * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Form extends Template { @@ -60,7 +55,7 @@ public function __construct( } /** - * @return AbstractBlock + * @inheritdoc */ public function _prepareLayout() { @@ -288,6 +283,8 @@ public function getAttributeYesNoElement($attribute) } /** + * Get select block. + * * @return BlockInterface */ protected function _getSelectBlock() @@ -301,6 +298,8 @@ protected function _getSelectBlock() } /** + * Get date block. + * * @return BlockInterface|mixed */ protected function _getDateBlock() diff --git a/app/code/Magento/CatalogSearch/Block/Advanced/Result.php b/app/code/Magento/CatalogSearch/Block/Advanced/Result.php index 65bc7b5fb0c20..9f25990594a49 100644 --- a/app/code/Magento/CatalogSearch/Block/Advanced/Result.php +++ b/app/code/Magento/CatalogSearch/Block/Advanced/Result.php @@ -18,8 +18,6 @@ * * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Result extends Template { @@ -65,7 +63,7 @@ public function __construct( } /** - * @return AbstractBlock + * @inheritdoc */ protected function _prepareLayout() { @@ -127,6 +125,8 @@ public function setListModes() } /** + * Initialize list collection. + * * @return void */ public function setListCollection() @@ -135,6 +135,8 @@ public function setListCollection() } /** + * Get product collection. + * * @return Collection */ protected function _getProductCollection() @@ -143,6 +145,8 @@ protected function _getProductCollection() } /** + * Set search model. + * * @return Advanced */ public function getSearchModel() @@ -151,6 +155,8 @@ public function getSearchModel() } /** + * Get result count. + * * @return mixed */ public function getResultCount() @@ -163,6 +169,8 @@ public function getResultCount() } /** + * Get product list HTML. + * * @return string */ public function getProductListHtml() @@ -171,6 +179,8 @@ public function getProductListHtml() } /** + * Get form URL. + * * @return string */ public function getFormUrl() @@ -184,6 +194,8 @@ public function getFormUrl() } /** + * Get search criteria. + * * @return array */ public function getSearchCriterias() diff --git a/app/code/Magento/CatalogSearch/Block/Plugin/FrontTabPlugin.php b/app/code/Magento/CatalogSearch/Block/Plugin/FrontTabPlugin.php index be65372725ceb..85ad66013cf32 100644 --- a/app/code/Magento/CatalogSearch/Block/Plugin/FrontTabPlugin.php +++ b/app/code/Magento/CatalogSearch/Block/Plugin/FrontTabPlugin.php @@ -11,9 +11,7 @@ use Magento\Framework\Data\Form\Element\Fieldset; /** - * Plugin for Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Front - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Add Search Weight field to the product attribute add/edit tab */ class FrontTabPlugin { diff --git a/app/code/Magento/CatalogSearch/Block/Result.php b/app/code/Magento/CatalogSearch/Block/Result.php index ccc8950450dad..f0d899b678c78 100644 --- a/app/code/Magento/CatalogSearch/Block/Result.php +++ b/app/code/Magento/CatalogSearch/Block/Result.php @@ -18,8 +18,6 @@ * * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Result extends Template { diff --git a/app/code/Magento/CatalogSearch/Block/SearchTermsLog.php b/app/code/Magento/CatalogSearch/Block/SearchTermsLog.php index 3679803c04d02..005c7860cfe5f 100644 --- a/app/code/Magento/CatalogSearch/Block/SearchTermsLog.php +++ b/app/code/Magento/CatalogSearch/Block/SearchTermsLog.php @@ -9,9 +9,7 @@ use Magento\Framework\View\Element\Block\ArgumentInterface; /** - * Class for logging search terms on cached pages - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Provider of the information on whether the page is cacheable, so that AJAX-based logging of terms can be triggered */ class SearchTermsLog implements ArgumentInterface { diff --git a/app/code/Magento/CatalogSearch/Controller/Advanced/Index.php b/app/code/Magento/CatalogSearch/Controller/Advanced/Index.php index a669016eb6b1b..4942b36743c12 100644 --- a/app/code/Magento/CatalogSearch/Controller/Advanced/Index.php +++ b/app/code/Magento/CatalogSearch/Controller/Advanced/Index.php @@ -11,13 +11,12 @@ use Magento\Framework\Controller\ResultFactory; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Advanced search controller. */ class Index extends \Magento\Framework\App\Action\Action implements HttpGetActionInterface, HttpPostActionInterface { /** - * @return \Magento\Framework\Controller\ResultInterface + * @inheritdoc */ public function execute() { diff --git a/app/code/Magento/CatalogSearch/Controller/Advanced/Result.php b/app/code/Magento/CatalogSearch/Controller/Advanced/Result.php index 937175511b1fb..17d70e38d3b61 100644 --- a/app/code/Magento/CatalogSearch/Controller/Advanced/Result.php +++ b/app/code/Magento/CatalogSearch/Controller/Advanced/Result.php @@ -13,8 +13,7 @@ use Magento\Framework\UrlFactory; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Advanced search result. */ class Result extends \Magento\Framework\App\Action\Action implements HttpGetActionInterface, HttpPostActionInterface { @@ -50,7 +49,7 @@ public function __construct( } /** - * @return \Magento\Framework\Controller\Result\Redirect + * @inheritdoc */ public function execute() { diff --git a/app/code/Magento/CatalogSearch/Controller/Result/Index.php b/app/code/Magento/CatalogSearch/Controller/Result/Index.php index 7c3577df452e4..fba4572cf2c10 100644 --- a/app/code/Magento/CatalogSearch/Controller/Result/Index.php +++ b/app/code/Magento/CatalogSearch/Controller/Result/Index.php @@ -16,8 +16,7 @@ use Magento\Search\Model\PopularSearchTerms; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Search result. */ class Index extends \Magento\Framework\App\Action\Action implements HttpGetActionInterface, HttpPostActionInterface { diff --git a/app/code/Magento/CatalogSearch/Controller/SearchTermsLog/Save.php b/app/code/Magento/CatalogSearch/Controller/SearchTermsLog/Save.php index f4018ed5b5d0d..a4a843c636cd0 100644 --- a/app/code/Magento/CatalogSearch/Controller/SearchTermsLog/Save.php +++ b/app/code/Magento/CatalogSearch/Controller/SearchTermsLog/Save.php @@ -15,8 +15,6 @@ /** * Controller for save search terms - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Save extends \Magento\Framework\App\Action\Action { diff --git a/app/code/Magento/CatalogSearch/Helper/Data.php b/app/code/Magento/CatalogSearch/Helper/Data.php index 7ba438ff36a58..6898e33d49f1d 100644 --- a/app/code/Magento/CatalogSearch/Helper/Data.php +++ b/app/code/Magento/CatalogSearch/Helper/Data.php @@ -10,8 +10,6 @@ * * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Data extends \Magento\Search\Helper\Data { diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/AggregationResolver.php b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/AggregationResolver.php index 2e41183940052..8a484d4cc7903 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/AggregationResolver.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/AggregationResolver.php @@ -15,8 +15,7 @@ use Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection as AttributeCollection; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Aggregation resolver. */ class AggregationResolver implements AggregationResolverInterface { @@ -79,7 +78,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function resolve(RequestInterface $request, array $documentIds) { diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/AdvancedSearch.php b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/AdvancedSearch.php index bb0de00816337..cea42347dc3f9 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/AdvancedSearch.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/AdvancedSearch.php @@ -12,8 +12,6 @@ * Request checker for advanced search. * * Checks advanced search query whether required to collect all attributes for entity. - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class AdvancedSearch implements RequestCheckerInterface { @@ -31,7 +29,7 @@ public function __construct($name) } /** - * {@inheritdoc} + * @inheritdoc */ public function isApplicable(RequestInterface $request) { diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/CatalogView.php b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/CatalogView.php index 3990587fa8c75..42da02f8ca4ff 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/CatalogView.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/Checker/Query/CatalogView.php @@ -17,8 +17,6 @@ * Request checker for catalog view. * * Checks catalog view query whether required to collect all attributes for entity. - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class CatalogView implements RequestCheckerInterface { @@ -53,7 +51,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function isApplicable(RequestInterface $request) { diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerComposite.php b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerComposite.php index 70c076fc21639..75910e1720734 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerComposite.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerComposite.php @@ -10,8 +10,7 @@ use Magento\Store\Model\StoreManagerInterface; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Composite request checker. */ class RequestCheckerComposite implements RequestCheckerInterface { @@ -57,7 +56,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function isApplicable(RequestInterface $request) { diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerInterface.php b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerInterface.php index 5c28db9a3b07a..7efe708a5755f 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerInterface.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Aggregation/RequestCheckerInterface.php @@ -9,9 +9,6 @@ /** * RequestCheckerInterface provides the interface to work with query checkers. - * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ interface RequestCheckerInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider.php index 48a78204774f7..15856bbee7461 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider.php @@ -18,8 +18,8 @@ use Magento\Framework\Search\Request\BucketInterface; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class DataProvider implements DataProviderInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php index 29238022811c5..26837448f2df2 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilder.php @@ -22,8 +22,8 @@ /** * Attribute query builder * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/SelectBuilderForAttribute.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/SelectBuilderForAttribute.php index 155dea824cde2..ddb4085fa13d9 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/SelectBuilderForAttribute.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/SelectBuilderForAttribute.php @@ -22,8 +22,8 @@ /** * Build select for attribute. * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class SelectBuilderForAttribute { diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/SelectBuilderForAttribute/ApplyStockConditionToSelect.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/SelectBuilderForAttribute/ApplyStockConditionToSelect.php index aa3d82954cfe7..be572793f1ec3 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/SelectBuilderForAttribute/ApplyStockConditionToSelect.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider/SelectBuilderForAttribute/ApplyStockConditionToSelect.php @@ -14,8 +14,8 @@ /** * Join stock table with stock condition to select. * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class ApplyStockConditionToSelect { diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/BaseSelectStrategy/BaseSelectAttributesSearchStrategy.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/BaseSelectStrategy/BaseSelectAttributesSearchStrategy.php index 8ee404e9df2ba..27a784f8609bb 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/BaseSelectStrategy/BaseSelectAttributesSearchStrategy.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/BaseSelectStrategy/BaseSelectAttributesSearchStrategy.php @@ -19,8 +19,8 @@ * The main idea of this strategy is using eav index table as main table for query * in case when search request requires search by attributes * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class BaseSelectAttributesSearchStrategy implements BaseSelectStrategyInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/BaseSelectStrategy/BaseSelectFullTextSearchStrategy.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/BaseSelectStrategy/BaseSelectFullTextSearchStrategy.php index b0bf91013af35..bff878122c8c4 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/BaseSelectStrategy/BaseSelectFullTextSearchStrategy.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/BaseSelectStrategy/BaseSelectFullTextSearchStrategy.php @@ -18,8 +18,8 @@ * The main idea of this strategy is using fulltext search index table as main table for query * in case when search request does not requires any search by attributes * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class BaseSelectFullTextSearchStrategy implements BaseSelectStrategyInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php index bed27c16f3ab8..eb4761adf830c 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Dynamic/DataProvider.php @@ -24,8 +24,8 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class DataProvider implements DataProviderInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Field/Resolver.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Field/Resolver.php index 30be62826fc9a..c24acf4610e07 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Field/Resolver.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Field/Resolver.php @@ -11,8 +11,8 @@ use Magento\Framework\Search\Adapter\Mysql\Field\ResolverInterface; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class Resolver implements ResolverInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/AliasResolver.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/AliasResolver.php index 82bd3d139f35d..bf431396cc0c7 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/AliasResolver.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/AliasResolver.php @@ -12,8 +12,8 @@ * Purpose of class is to resolve table alias for Search Request filter * @api * @since 100.1.6 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class AliasResolver { diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/Preprocessor.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/Preprocessor.php index c51de6e28b26d..2ffa63098cdee 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/Preprocessor.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/Preprocessor.php @@ -25,8 +25,8 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class Preprocessor implements PreprocessorInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Plugin/Aggregation/Category/DataProvider.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Plugin/Aggregation/Category/DataProvider.php index 6bf5bb632f02b..a5650cac73395 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Plugin/Aggregation/Category/DataProvider.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Plugin/Aggregation/Category/DataProvider.php @@ -18,8 +18,8 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class DataProvider { diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Options.php b/app/code/Magento/CatalogSearch/Model/Adapter/Options.php index efc955486708c..f2e1c3c4c42d2 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Options.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Options.php @@ -10,10 +10,10 @@ use Magento\Store\Model\ScopeInterface; /** + * Catalog search config. + * * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Options implements OptionsInterface { @@ -35,7 +35,7 @@ public function __construct(ScopeConfigInterface $scopeConfig) } /** - * {@inheritdoc} + * @inheritdoc */ public function get() { diff --git a/app/code/Magento/CatalogSearch/Model/Adminhtml/System/Config/Backend/Engine.php b/app/code/Magento/CatalogSearch/Model/Adminhtml/System/Config/Backend/Engine.php index 5262316e2ca38..1f11d2650334d 100644 --- a/app/code/Magento/CatalogSearch/Model/Adminhtml/System/Config/Backend/Engine.php +++ b/app/code/Magento/CatalogSearch/Model/Adminhtml/System/Config/Backend/Engine.php @@ -6,10 +6,10 @@ namespace Magento\CatalogSearch\Model\Adminhtml\System\Config\Backend; /** + * Backend model for catalog search engine system config + * * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Engine extends \Magento\Framework\App\Config\Value { @@ -44,6 +44,7 @@ public function __construct( /** * After save call + * * Invalidate catalog search index if engine was changed * * @return $this diff --git a/app/code/Magento/CatalogSearch/Model/Advanced.php b/app/code/Magento/CatalogSearch/Model/Advanced.php index 81c0ecdb32128..af0e9ff5528cf 100644 --- a/app/code/Magento/CatalogSearch/Model/Advanced.php +++ b/app/code/Magento/CatalogSearch/Model/Advanced.php @@ -22,6 +22,7 @@ /** * Catalog advanced search model + * * @method int getEntityTypeId() * @method \Magento\CatalogSearch\Model\Advanced setEntityTypeId(int $value) * @method int getAttributeSetId() @@ -43,8 +44,6 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Advanced extends \Magento\Framework\Model\AbstractModel { @@ -298,6 +297,8 @@ public function prepareProductCollection($collection) } /** + * Add search criteria. + * * @param EntityAttribute $attribute * @param mixed $value * @return void diff --git a/app/code/Magento/CatalogSearch/Model/Advanced/Request/Builder.php b/app/code/Magento/CatalogSearch/Model/Advanced/Request/Builder.php index 4584838782a98..9e7737123b2ec 100644 --- a/app/code/Magento/CatalogSearch/Model/Advanced/Request/Builder.php +++ b/app/code/Magento/CatalogSearch/Model/Advanced/Request/Builder.php @@ -8,14 +8,16 @@ use Magento\Framework\Search\Request\Builder as RequestBuilder; /** + * Catalog search advanced request builder. + * * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Builder extends RequestBuilder { /** + * Bind value to query. + * * @param string $attributeCode * @param array|string $attributeValue * @return void diff --git a/app/code/Magento/CatalogSearch/Model/Attribute/SearchWeight.php b/app/code/Magento/CatalogSearch/Model/Attribute/SearchWeight.php index 139154be9df3a..fa42cadb8a2fa 100644 --- a/app/code/Magento/CatalogSearch/Model/Attribute/SearchWeight.php +++ b/app/code/Magento/CatalogSearch/Model/Attribute/SearchWeight.php @@ -7,13 +7,11 @@ namespace Magento\CatalogSearch\Model\Attribute; /** - * This plugin is responsible for processing of search_weight property of a product attribute, - * which is used to boost matches by specific attributes. + * This plugin is responsible for processing of search_weight property of a product attribute. * - * This is part of search accuracy customization functionality. + * 'search_weight' is used to boost matches by specific attributes. * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * This is part of search accuracy customization functionality. */ class SearchWeight { diff --git a/app/code/Magento/CatalogSearch/Model/Autocomplete/DataProvider.php b/app/code/Magento/CatalogSearch/Model/Autocomplete/DataProvider.php index 82a64923ef702..f014c6d133187 100644 --- a/app/code/Magento/CatalogSearch/Model/Autocomplete/DataProvider.php +++ b/app/code/Magento/CatalogSearch/Model/Autocomplete/DataProvider.php @@ -14,8 +14,7 @@ use Magento\Store\Model\ScopeInterface; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Catalog search auto-complete data provider. */ class DataProvider implements DataProviderInterface { @@ -48,6 +47,7 @@ class DataProvider implements DataProviderInterface /** * @param QueryFactory $queryFactory * @param ItemFactory $itemFactory + * @param ScopeConfig $scopeConfig */ public function __construct( QueryFactory $queryFactory, @@ -64,7 +64,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function getItems() { diff --git a/app/code/Magento/CatalogSearch/Model/Fulltext.php b/app/code/Magento/CatalogSearch/Model/Fulltext.php index 2e7eb097af5cf..398d6e9dd18dd 100644 --- a/app/code/Magento/CatalogSearch/Model/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/Fulltext.php @@ -22,8 +22,8 @@ * @method string getDataIndex() * @method \Magento\CatalogSearch\Model\Fulltext setDataIndex(string $value) * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class Fulltext extends \Magento\Framework\Model\AbstractModel { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php index ee66a91f395b9..21d8b7297da7d 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php @@ -19,8 +19,6 @@ * * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Fulltext implements \Magento\Framework\Indexer\ActionInterface, diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php index 83058b6f0ad55..03c3a50d1714b 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php @@ -12,12 +12,12 @@ use Magento\Store\Model\Store; /** + * Catalog search full test search data provider. + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) * @api * @since 100.0.3 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class DataProvider { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php index 2b4be8369de59..8a18c1bfcc576 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php @@ -22,9 +22,6 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api * @since 100.0.2 - * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Full { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/IndexIterator.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/IndexIterator.php index 1a18b4c05e396..a2c39deff1892 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/IndexIterator.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/IndexIterator.php @@ -15,8 +15,8 @@ * @api * @since 100.0.3 * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class IndexIterator implements \Iterator { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/Category.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/Category.php index eee6ac37767ee..ed841996ea07b 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/Category.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Model/Plugin/Category.php @@ -12,9 +12,6 @@ /** * Perform indexer invalidation after a category delete. - * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Category { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/AbstractPlugin.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/AbstractPlugin.php index 61b7075043d29..5d4096a3afab0 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/AbstractPlugin.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/AbstractPlugin.php @@ -10,9 +10,6 @@ /** * Abstract plugin for indexers - * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ abstract class AbstractPlugin { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Attribute.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Attribute.php index ae218f65087d4..86dccf8cfe559 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Attribute.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Attribute.php @@ -8,8 +8,7 @@ use Magento\CatalogSearch\Model\Indexer\Fulltext; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Catalog search indexer plugin for catalog attribute. */ class Attribute extends AbstractPlugin { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Category.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Category.php index 0cf9f04f97613..1218e3da9a783 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Category.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Category.php @@ -10,8 +10,7 @@ use Magento\Framework\Model\AbstractModel; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Catalog search indexer plugin for catalog category. */ class Category extends AbstractPlugin { @@ -30,6 +29,8 @@ public function aroundSave(ResourceCategory $resourceCategory, \Closure $proceed } /** + * Reindex catalog search. + * * @param ResourceCategory $resourceCategory * @param \Closure $proceed * @param AbstractModel $category diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product.php index 120a22f60d048..e250d1123937a 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product.php @@ -10,12 +10,13 @@ use Magento\Framework\Model\AbstractModel; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Catalog search indexer plugin for catalog product. */ class Product extends AbstractPlugin { /** + * Reindex on product save. + * * @param ResourceProduct $productResource * @param \Closure $proceed * @param AbstractModel $product @@ -42,6 +43,8 @@ public function aroundDelete(ResourceProduct $productResource, \Closure $proceed } /** + * Reindex catalog search. + * * @param ResourceProduct $productResource * @param \Closure $proceed * @param AbstractModel $product diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product/Action.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product/Action.php index 2ead0ac0ac612..75bf4cbd0f3f6 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product/Action.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product/Action.php @@ -24,8 +24,6 @@ class Action extends AbstractIndexerPlugin * @return ProductAction * * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * @deprecated - * @see ElasticSearch module is default search engine starting from 2.3. CatalogSearch would be removed in 2.4 */ public function afterUpdateAttributes( ProductAction $subject, diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/Group.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/Group.php index 27a2bd82a5d7e..73a79f7c87239 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/Group.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/Group.php @@ -12,9 +12,6 @@ /** * Plugin for Magento\Store\Model\ResourceModel\Group - * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Group extends AbstractIndexerPlugin { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/View.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/View.php index 51695fd261d7b..7f0c5fdae6d42 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/View.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Store/View.php @@ -12,9 +12,6 @@ /** * Plugin for Magento\Store\Model\ResourceModel\Store - * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class View extends AbstractIndexerPlugin { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Processor.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Processor.php index 33881061eb88d..cd3ff62d53682 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Processor.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Processor.php @@ -12,8 +12,6 @@ * Class Processor * @api * @since 100.1.0 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Processor extends AbstractProcessor { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Store.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Store.php index 8b0a18105ec84..23ab52012f2e5 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Store.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Store.php @@ -12,8 +12,7 @@ use Magento\Framework\Event\ObserverInterface; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Catalog search indexer plugin for store. */ class Store implements ObserverInterface { @@ -48,6 +47,8 @@ public function __construct( } /** + * Reindex catalog search. + * * @param \Magento\Store\Model\Store $store * @return void */ @@ -63,6 +64,8 @@ private function clearIndex(\Magento\Store\Model\Store $store) } /** + * Reindex catalog search on store modification. + * * @param \Magento\Framework\Event\Observer $observer * @return void */ diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructure.php b/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructure.php index 31916c456f000..0d226acdc3d7b 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructure.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructure.php @@ -15,10 +15,10 @@ use Magento\Framework\Search\Request\IndexScopeResolverInterface; /** + * Catalog search index structure. + * * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class IndexStructure implements IndexStructureInterface { @@ -45,9 +45,7 @@ public function __construct( } /** - * @param string $index - * @param Dimension[] $dimensions - * @return void + * @inheritdoc */ public function delete($index, array $dimensions = []) { @@ -58,11 +56,7 @@ public function delete($index, array $dimensions = []) } /** - * @param string $index - * @param array $fields - * @param array $dimensions - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * @return void + * @inheritdoc */ public function create($index, array $fields, array $dimensions = []) { @@ -70,6 +64,8 @@ public function create($index, array $fields, array $dimensions = []) } /** + * Create fulltext index table. + * * @param string $tableName * @throws \Zend_Db_Exception * @return void diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructureFactory.php b/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructureFactory.php index 4bdd4336c5257..d54d6c939cccc 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructureFactory.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructureFactory.php @@ -10,10 +10,10 @@ use Magento\Framework\Search\EngineResolverInterface; /** + * Index structure factory + * * @api * @since 100.1.0 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class IndexStructureFactory { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructureProxy.php b/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructureProxy.php index cee6bb9f6488e..c62d2a033565f 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructureProxy.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructureProxy.php @@ -8,8 +8,7 @@ use Magento\Framework\Indexer\IndexStructureInterface; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Catalog search index structure proxy. */ class IndexStructureProxy implements IndexStructureInterface { @@ -33,7 +32,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function delete( $index, @@ -43,7 +42,7 @@ public function delete( } /** - * {@inheritdoc} + * @inheritdoc */ public function create( $index, diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/IndexSwitcherInterface.php b/app/code/Magento/CatalogSearch/Model/Indexer/IndexSwitcherInterface.php index 798801187b4e4..f45ef11a86389 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/IndexSwitcherInterface.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/IndexSwitcherInterface.php @@ -6,11 +6,10 @@ namespace Magento\CatalogSearch\Model\Indexer; /** - * Provides a functionality to replace main index with its temporary representation + * Provides a functionality to replace main index with its temporary representation. + * * @api * @since 100.2.0 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ interface IndexSwitcherInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/IndexSwitcherProxy.php b/app/code/Magento/CatalogSearch/Model/Indexer/IndexSwitcherProxy.php index f3b6399c4d7e2..e4a20cc188fbd 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/IndexSwitcherProxy.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/IndexSwitcherProxy.php @@ -11,9 +11,6 @@ /** * Proxy for adapter-specific index switcher - * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class IndexSwitcherProxy implements IndexSwitcherInterface { @@ -54,7 +51,7 @@ public function __construct( } /** - * {@inheritDoc} + * @inheritDoc * * As index switcher is an optional part of the search SPI, it may be not defined by a search engine. * It is especially reasonable for search engines with pre-defined indexes declaration (like Sphinx) diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandler.php b/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandler.php index bbdb1dd7b6502..9f105bd3ea462 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandler.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandler.php @@ -18,8 +18,8 @@ * * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class IndexerHandler implements IndexerInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandlerFactory.php b/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandlerFactory.php index af1839f04ab38..841ee8708f264 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandlerFactory.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandlerFactory.php @@ -10,10 +10,10 @@ use Magento\Framework\Search\EngineResolverInterface; /** + * Indexer handler factory. + * * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class IndexerHandlerFactory { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Mview/Action.php b/app/code/Magento/CatalogSearch/Model/Indexer/Mview/Action.php index ba5a16978c59b..b6639f760457b 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Mview/Action.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Mview/Action.php @@ -10,8 +10,7 @@ use Magento\Framework\Indexer\IndexerInterfaceFactory; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Catalog search materialized view index action. */ class Action implements ActionInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/ProductFieldset.php b/app/code/Magento/CatalogSearch/Model/Indexer/ProductFieldset.php index 426fa69a5fd09..6db063bde7d1e 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/ProductFieldset.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/ProductFieldset.php @@ -13,8 +13,8 @@ /** * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class ProductFieldset implements \Magento\Framework\Indexer\FieldsetInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Scope/IndexSwitcher.php b/app/code/Magento/CatalogSearch/Model/Indexer/Scope/IndexSwitcher.php index 168446e960689..ed2b1be5c7035 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Scope/IndexSwitcher.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Scope/IndexSwitcher.php @@ -12,8 +12,8 @@ /** * Provides a functionality to replace main index with its temporary representation * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class IndexSwitcher implements IndexSwitcherInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Scope/IndexTableNotExistException.php b/app/code/Magento/CatalogSearch/Model/Indexer/Scope/IndexTableNotExistException.php index fa7bcce8f2274..b01f3c50d5002 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Scope/IndexTableNotExistException.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Scope/IndexTableNotExistException.php @@ -14,8 +14,8 @@ * * @api * @since 100.2.0 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class IndexTableNotExistException extends LocalizedException { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Scope/ScopeProxy.php b/app/code/Magento/CatalogSearch/Model/Indexer/Scope/ScopeProxy.php index c96ccf3663b48..fcecb36e7d508 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Scope/ScopeProxy.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Scope/ScopeProxy.php @@ -9,11 +9,7 @@ use Magento\Framework\Search\Request\Dimension; /** - * Implementation of IndexScopeResolverInterface which resolves index scope dynamically - * depending on current scope state - * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Implementation of IndexScopeResolverInterface which resolves index scope dynamically depending on current scope state */ class ScopeProxy implements \Magento\Framework\Search\Request\IndexScopeResolverInterface { @@ -67,9 +63,7 @@ private function create($state) } /** - * @param string $index - * @param Dimension[] $dimensions - * @return string + * @inheritdoc */ public function resolve($index, array $dimensions) { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Scope/State.php b/app/code/Magento/CatalogSearch/Model/Indexer/Scope/State.php index f11d8709ba4a3..a12ae8e69c310 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Scope/State.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Scope/State.php @@ -18,9 +18,6 @@ * The 'use_temporary_table' state is an opposite for 'use_main_table' * which means that default indexer table should be left unchanged during indexation * and temporary table should be used instead. - * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class State { @@ -34,6 +31,7 @@ class State /** * Set the state to use temporary Index + * * @return void */ public function useTemporaryIndex() @@ -43,6 +41,7 @@ public function useTemporaryIndex() /** * Set the state to use regular Index + * * @return void */ public function useRegularIndex() @@ -51,6 +50,8 @@ public function useRegularIndex() } /** + * Get state. + * * @return string */ public function getState() diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Scope/TemporaryResolver.php b/app/code/Magento/CatalogSearch/Model/Indexer/Scope/TemporaryResolver.php index 70af9cafd749e..796559d1f7034 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Scope/TemporaryResolver.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Scope/TemporaryResolver.php @@ -12,8 +12,8 @@ /** * Resolves name of a temporary table for indexation * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class TemporaryResolver implements \Magento\Framework\Search\Request\IndexScopeResolverInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Scope/UnknownStateException.php b/app/code/Magento/CatalogSearch/Model/Indexer/Scope/UnknownStateException.php index cce195c953ebd..8722cd52b618a 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Scope/UnknownStateException.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Scope/UnknownStateException.php @@ -13,8 +13,8 @@ * * @api * @since 100.2.0 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class UnknownStateException extends LocalizedException { diff --git a/app/code/Magento/CatalogSearch/Model/Layer/Category/ItemCollectionProvider.php b/app/code/Magento/CatalogSearch/Model/Layer/Category/ItemCollectionProvider.php index 02beeae0f1579..c24665f4808d2 100644 --- a/app/code/Magento/CatalogSearch/Model/Layer/Category/ItemCollectionProvider.php +++ b/app/code/Magento/CatalogSearch/Model/Layer/Category/ItemCollectionProvider.php @@ -10,8 +10,7 @@ use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Catalog search category layer collection provider. */ class ItemCollectionProvider implements ItemCollectionProviderInterface { @@ -29,8 +28,7 @@ public function __construct(CollectionFactory $collectionFactory) } /** - * @param \Magento\Catalog\Model\Category $category - * @return \Magento\Catalog\Model\ResourceModel\Product\Collection + * @inheritdoc */ public function getCollection(\Magento\Catalog\Model\Category $category) { diff --git a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Attribute.php b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Attribute.php index 8119d7c5869c5..7aac6e98fc044 100644 --- a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Attribute.php +++ b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Attribute.php @@ -9,8 +9,6 @@ /** * Layer attribute filter - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Attribute extends AbstractFilter { diff --git a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Category.php b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Category.php index 63d9656fea25a..0998cf7a9b3ac 100644 --- a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Category.php +++ b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Category.php @@ -10,9 +10,6 @@ /** * Layer category filter - * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Category extends AbstractFilter { @@ -27,14 +24,16 @@ class Category extends AbstractFilter private $dataProvider; /** + * Category constructor. + * * @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\Layer $layer * @param \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder - * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param \Magento\Framework\Escaper $escaper - * @param CategoryManagerFactory $categoryManager + * @param \Magento\Catalog\Model\Layer\Filter\DataProvider\CategoryFactory $categoryDataProviderFactory * @param array $data + * @throws \Magento\Framework\Exception\LocalizedException */ public function __construct( \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory, diff --git a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Decimal.php b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Decimal.php index a3b1d76fef151..e61a886a41d6f 100644 --- a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Decimal.php +++ b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Decimal.php @@ -9,9 +9,6 @@ /** * Layer decimal filter - * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Decimal extends AbstractFilter { diff --git a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Price.php b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Price.php index 126a0a7ea3212..a19f53469ae01 100644 --- a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Price.php +++ b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Price.php @@ -10,8 +10,6 @@ /** * Layer price filter based on Search API * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Price extends AbstractFilter @@ -88,6 +86,8 @@ public function __construct( } /** + * Get resource model. + * * @return \Magento\Catalog\Model\ResourceModel\Layer\Filter\Price */ public function getResource() @@ -225,6 +225,8 @@ protected function _getItemsData() } /** + * Get 'to' part of the filter. + * * @param float $from * @return float */ @@ -239,6 +241,8 @@ protected function getTo($from) } /** + * Get 'from' part of the filter. + * * @param float $from * @return float */ @@ -253,6 +257,8 @@ protected function getFrom($from) } /** + * Prepare filter data. + * * @param string $key * @param int $count * @return array diff --git a/app/code/Magento/CatalogSearch/Model/Layer/Search/Plugin/CollectionFilter.php b/app/code/Magento/CatalogSearch/Model/Layer/Search/Plugin/CollectionFilter.php index 5fbd08c134334..eb901498c4ea5 100644 --- a/app/code/Magento/CatalogSearch/Model/Layer/Search/Plugin/CollectionFilter.php +++ b/app/code/Magento/CatalogSearch/Model/Layer/Search/Plugin/CollectionFilter.php @@ -10,8 +10,7 @@ use Magento\Search\Model\QueryFactory; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Catalog search plugin for search collection filter in layered navigation. */ class CollectionFilter { diff --git a/app/code/Magento/CatalogSearch/Model/Layer/Search/StateKey.php b/app/code/Magento/CatalogSearch/Model/Layer/Search/StateKey.php index 16a22aba8db35..98caccea2ae49 100644 --- a/app/code/Magento/CatalogSearch/Model/Layer/Search/StateKey.php +++ b/app/code/Magento/CatalogSearch/Model/Layer/Search/StateKey.php @@ -10,8 +10,7 @@ use Magento\Catalog\Model\Layer\StateKeyInterface; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Catalog search state key for layered navigation. */ class StateKey extends \Magento\Catalog\Model\Layer\Category\StateKey implements StateKeyInterface { @@ -35,8 +34,7 @@ public function __construct( } /** - * @param \Magento\Catalog\Model\Category $category - * @return string|void + * @inheritdoc */ public function toString($category) { diff --git a/app/code/Magento/CatalogSearch/Model/Price/Interval.php b/app/code/Magento/CatalogSearch/Model/Price/Interval.php index 69e4b90baf04d..ea2d24aeadfd1 100644 --- a/app/code/Magento/CatalogSearch/Model/Price/Interval.php +++ b/app/code/Magento/CatalogSearch/Model/Price/Interval.php @@ -8,8 +8,7 @@ use Magento\Framework\Search\Dynamic\IntervalInterface; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Catalog search price interval. */ class Interval implements IntervalInterface { @@ -27,7 +26,7 @@ public function __construct(\Magento\Catalog\Model\ResourceModel\Layer\Filter\Pr } /** - * {@inheritdoc} + * @inheritdoc */ public function load($limit, $offset = null, $lower = null, $upper = null) { @@ -36,7 +35,7 @@ public function load($limit, $offset = null, $lower = null, $upper = null) } /** - * {@inheritdoc} + * @inheritdoc */ public function loadPrevious($data, $index, $lower = null) { @@ -45,7 +44,7 @@ public function loadPrevious($data, $index, $lower = null) } /** - * {@inheritdoc} + * @inheritdoc */ public function loadNext($data, $rightIndex, $upper = null) { @@ -54,6 +53,8 @@ public function loadNext($data, $rightIndex, $upper = null) } /** + * Convert to float values. + * * @param array $prices * @return array */ diff --git a/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced.php b/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced.php index 2aab76cb9536f..05254a50aadc6 100644 --- a/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced.php +++ b/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced.php @@ -8,11 +8,8 @@ /** * Advanced Catalog Search resource model * - * @author Magento Core Team <core@magentocommerce.com> * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Advanced extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { diff --git a/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced/Collection.php b/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced/Collection.php index 8d097487b1bfe..b4b15554f6029 100644 --- a/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced/Collection.php @@ -17,14 +17,13 @@ use Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitationFactory; /** - * Collection Advanced + * Advanced search collection + * + * This collection should be refactored to not have dependencies on MySQL-specific implementation. * - * @author Magento Core Team <core@magentocommerce.com> * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection { @@ -41,6 +40,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection /** * @var \Magento\Framework\Search\Adapter\Mysql\TemporaryStorageFactory + * @deprecated There must be no dependencies on specific adapter in generic search implementation */ private $temporaryStorageFactory; @@ -207,6 +207,8 @@ protected function _renderFiltersBefore() } /** + * Get attribute code. + * * @param string $attributeCode * @return string */ @@ -266,6 +268,8 @@ private function addRangeAttributeToSearch($attributeCode, $attributeValue) } /** + * Get search. + * * @return \Magento\Search\Api\SearchInterface */ private function getSearch() @@ -278,6 +282,8 @@ private function getSearch() } /** + * Get search criteria builder. + * * @return SearchCriteriaBuilder */ private function getSearchCriteriaBuilder() @@ -290,6 +296,8 @@ private function getSearchCriteriaBuilder() } /** + * Get fielter builder. + * * @return FilterBuilder */ private function getFilterBuilder() diff --git a/app/code/Magento/CatalogSearch/Model/ResourceModel/Engine.php b/app/code/Magento/CatalogSearch/Model/ResourceModel/Engine.php index a6a97a89882a2..49caede8c4ac2 100644 --- a/app/code/Magento/CatalogSearch/Model/ResourceModel/Engine.php +++ b/app/code/Magento/CatalogSearch/Model/ResourceModel/Engine.php @@ -8,8 +8,8 @@ /** * CatalogSearch Fulltext Index Engine resource model * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class Engine implements EngineInterface { diff --git a/app/code/Magento/CatalogSearch/Model/ResourceModel/EngineInterface.php b/app/code/Magento/CatalogSearch/Model/ResourceModel/EngineInterface.php index 99d34de1830b7..4b9db55105ea9 100644 --- a/app/code/Magento/CatalogSearch/Model/ResourceModel/EngineInterface.php +++ b/app/code/Magento/CatalogSearch/Model/ResourceModel/EngineInterface.php @@ -3,16 +3,11 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +namespace Magento\CatalogSearch\Model\ResourceModel; /** * CatalogSearch Index Engine Interface * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. - */ -namespace Magento\CatalogSearch\Model\ResourceModel; - -/** * @api * @since 100.0.2 */ diff --git a/app/code/Magento/CatalogSearch/Model/ResourceModel/EngineProvider.php b/app/code/Magento/CatalogSearch/Model/ResourceModel/EngineProvider.php index 6faffefde6095..d1259159606d3 100644 --- a/app/code/Magento/CatalogSearch/Model/ResourceModel/EngineProvider.php +++ b/app/code/Magento/CatalogSearch/Model/ResourceModel/EngineProvider.php @@ -4,18 +4,13 @@ * See COPYING.txt for license details. */ -/** - * Catalog Search engine provider - * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. - */ namespace Magento\CatalogSearch\Model\ResourceModel; -use Magento\CatalogSearch\Model\ResourceModel\EngineInterface; use Magento\Framework\Search\EngineResolverInterface; /** + * Catalog Search engine provider + * * @api * @since 100.0.2 */ diff --git a/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext.php b/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext.php index 49d1fe82d8e28..0835fb66f876a 100644 --- a/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext.php @@ -14,8 +14,6 @@ * * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Fulltext extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { diff --git a/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php b/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php index 7e0cb306d483b..e6cfe8ca112f7 100644 --- a/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php @@ -20,12 +20,12 @@ /** * Fulltext Collection - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * + * This collection should be refactored to not have dependencies on MySQL-specific implementation. * * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection { @@ -72,6 +72,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection /** * @var \Magento\Framework\Search\Adapter\Mysql\TemporaryStorageFactory + * @deprecated There must be no dependencies on specific adapter in generic search implementation */ private $temporaryStorageFactory; @@ -200,6 +201,8 @@ public function __construct( } /** + * Get search. + * * @deprecated 100.1.0 * @return \Magento\Search\Api\SearchInterface */ @@ -212,6 +215,8 @@ private function getSearch() } /** + * Test search. + * * @deprecated 100.1.0 * @param \Magento\Search\Api\SearchInterface $object * @return void @@ -223,6 +228,8 @@ public function setSearch(\Magento\Search\Api\SearchInterface $object) } /** + * Set search criteria builder. + * * @deprecated 100.1.0 * @return \Magento\Framework\Api\Search\SearchCriteriaBuilder */ @@ -236,6 +243,8 @@ private function getSearchCriteriaBuilder() } /** + * Set search criteria builder. + * * @deprecated 100.1.0 * @param \Magento\Framework\Api\Search\SearchCriteriaBuilder $object * @return void @@ -247,6 +256,8 @@ public function setSearchCriteriaBuilder(\Magento\Framework\Api\Search\SearchCri } /** + * Get filter builder. + * * @deprecated 100.1.0 * @return \Magento\Framework\Api\FilterBuilder */ @@ -259,6 +270,8 @@ private function getFilterBuilder() } /** + * Set filter builder. + * * @deprecated 100.1.0 * @param \Magento\Framework\Api\FilterBuilder $object * @return void @@ -273,7 +286,7 @@ public function setFilterBuilder(\Magento\Framework\Api\FilterBuilder $object) * Apply attribute filter to facet collection * * @param string $field - * @param null $condition + * @param mixed|null $condition * @return $this */ public function addFieldToFilter($field, $condition = null) @@ -386,6 +399,8 @@ protected function _beforeLoad() } /** + * Render filters. + * * @return $this */ protected function _renderFilters() diff --git a/app/code/Magento/CatalogSearch/Model/ResourceModel/Search/Collection.php b/app/code/Magento/CatalogSearch/Model/ResourceModel/Search/Collection.php index e706756515a14..b958de91314f4 100644 --- a/app/code/Magento/CatalogSearch/Model/ResourceModel/Search/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/ResourceModel/Search/Collection.php @@ -12,8 +12,6 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection implements \Magento\Search\Model\SearchCollectionInterface diff --git a/app/code/Magento/CatalogSearch/Model/Search/BaseSelectStrategy/BaseSelectStrategyInterface.php b/app/code/Magento/CatalogSearch/Model/Search/BaseSelectStrategy/BaseSelectStrategyInterface.php index 32ecb49714246..2d8dfb9222497 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/BaseSelectStrategy/BaseSelectStrategyInterface.php +++ b/app/code/Magento/CatalogSearch/Model/Search/BaseSelectStrategy/BaseSelectStrategyInterface.php @@ -8,11 +8,10 @@ use Magento\CatalogSearch\Model\Search\SelectContainer\SelectContainer; /** - * Interface BaseSelectStrategyInterface * This interface represents strategy that will be used to create base select for search request * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ interface BaseSelectStrategyInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Search/BaseSelectStrategy/StrategyMapper.php b/app/code/Magento/CatalogSearch/Model/Search/BaseSelectStrategy/StrategyMapper.php index 9e954b57f649f..e554d3c774a31 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/BaseSelectStrategy/StrategyMapper.php +++ b/app/code/Magento/CatalogSearch/Model/Search/BaseSelectStrategy/StrategyMapper.php @@ -10,11 +10,10 @@ use Magento\CatalogSearch\Model\Adapter\Mysql\BaseSelectStrategy\BaseSelectAttributesSearchStrategy; /** - * Class StrategyMapper * This class is responsible for deciding which BaseSelectStrategyInterface should be used for passed SelectContainer * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class StrategyMapper { diff --git a/app/code/Magento/CatalogSearch/Model/Search/Catalog.php b/app/code/Magento/CatalogSearch/Model/Search/Catalog.php index 7a39a7bf47824..31ac889b19e69 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/Catalog.php +++ b/app/code/Magento/CatalogSearch/Model/Search/Catalog.php @@ -9,9 +9,6 @@ /** * Search model for backend search - * - * @deprecated 100.2.0 - * @see ElasticSearch module is default search engine starting from 2.3. CatalogSearch would be removed in 2.4 */ class Catalog extends \Magento\Framework\DataObject { diff --git a/app/code/Magento/CatalogSearch/Model/Search/CustomAttributeFilterCheck.php b/app/code/Magento/CatalogSearch/Model/Search/CustomAttributeFilterCheck.php index ce8ce6829a008..bcd4080b30b14 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/CustomAttributeFilterCheck.php +++ b/app/code/Magento/CatalogSearch/Model/Search/CustomAttributeFilterCheck.php @@ -10,11 +10,10 @@ use Magento\Catalog\Model\Product; /** - * Class CustomAttributeFilterSelector * Checks if FilterInterface is by custom attribute * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class CustomAttributeFilterCheck { diff --git a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/CustomAttributeFilter.php b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/CustomAttributeFilter.php index e182255b93ae8..8c796f8770657 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/CustomAttributeFilter.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/CustomAttributeFilter.php @@ -18,8 +18,8 @@ /** * Applies filters by custom attributes to base select. * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class CustomAttributeFilter { diff --git a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/DimensionsProcessor.php b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/DimensionsProcessor.php index df314377b5afc..3d2b9eed03761 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/DimensionsProcessor.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/DimensionsProcessor.php @@ -17,8 +17,8 @@ * Class DimensionsProcessor * Adds dimension conditions to select query * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class DimensionsProcessor { diff --git a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php index e7cf5da09351d..c382569338e29 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/ExclusionStrategy.php @@ -21,8 +21,8 @@ /** * Strategy which processes exclusions from general rules * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ diff --git a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/FilterContext.php b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/FilterContext.php index 692e199fffa01..67ed66da2a036 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/FilterContext.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/FilterContext.php @@ -15,8 +15,8 @@ * Its responsibility is to choose appropriate strategy to apply passed filter to the Select * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class FilterContext implements FilterStrategyInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/FilterMapper.php b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/FilterMapper.php index 49a55ddf26e4b..7136fad5b19a9 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/FilterMapper.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/FilterMapper.php @@ -14,8 +14,8 @@ * Class FilterMapper * This class applies filters to Select based on SelectContainer configuration * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class FilterMapper { diff --git a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/FilterStrategyInterface.php b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/FilterStrategyInterface.php index 7925a619c8095..a61c691c0d5cd 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/FilterStrategyInterface.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/FilterStrategyInterface.php @@ -10,8 +10,8 @@ * FilterStrategyInterface provides the interface to work with strategies * @api * @since 100.1.6 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ interface FilterStrategyInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/StaticAttributeStrategy.php b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/StaticAttributeStrategy.php index 1e35a3c0352b1..3986cc617f06d 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/StaticAttributeStrategy.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/StaticAttributeStrategy.php @@ -13,8 +13,8 @@ /** * This strategy handles static attributes * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class StaticAttributeStrategy implements FilterStrategyInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/StockStatusFilter.php b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/StockStatusFilter.php index f15e313ce06a6..0e3ba0d4e669f 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/StockStatusFilter.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/StockStatusFilter.php @@ -16,8 +16,8 @@ * Class StockStatusFilter * Adds filter by stock status to base select * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class StockStatusFilter { diff --git a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/TermDropdownStrategy.php b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/TermDropdownStrategy.php index bbec04eed0621..9d7e31ee3b6d1 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/TermDropdownStrategy.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/TermDropdownStrategy.php @@ -16,8 +16,8 @@ * - The filter for dropdown or multi-select attribute * - The filter is Term filter * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class TermDropdownStrategy implements FilterStrategyInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/TermDropdownStrategy/ApplyStockConditionToSelect.php b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/TermDropdownStrategy/ApplyStockConditionToSelect.php index 64a2fdc25bb02..c28bc3485cf49 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/TermDropdownStrategy/ApplyStockConditionToSelect.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/TermDropdownStrategy/ApplyStockConditionToSelect.php @@ -14,8 +14,8 @@ /** * Apply stock condition to select. * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class ApplyStockConditionToSelect { diff --git a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/TermDropdownStrategy/SelectBuilder.php b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/TermDropdownStrategy/SelectBuilder.php index 85281ce556889..007647db39b32 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/TermDropdownStrategy/SelectBuilder.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/TermDropdownStrategy/SelectBuilder.php @@ -17,8 +17,8 @@ /** * Add joins to select. * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class SelectBuilder { diff --git a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/VisibilityFilter.php b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/VisibilityFilter.php index c73651ad8007d..690ef9115edfe 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/VisibilityFilter.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/VisibilityFilter.php @@ -17,8 +17,8 @@ * Class VisibilityFilter * Applies filter by visibility to base select * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class VisibilityFilter { diff --git a/app/code/Magento/CatalogSearch/Model/Search/FiltersExtractor.php b/app/code/Magento/CatalogSearch/Model/Search/FiltersExtractor.php index 4a654acc920c5..55c8582979912 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FiltersExtractor.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FiltersExtractor.php @@ -13,8 +13,8 @@ * Class FiltersExtractor * Extracts filters from QueryInterface * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class FiltersExtractor { diff --git a/app/code/Magento/CatalogSearch/Model/Search/IndexBuilder.php b/app/code/Magento/CatalogSearch/Model/Search/IndexBuilder.php index 8c4e5c432d5bc..906220db28dc1 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/IndexBuilder.php +++ b/app/code/Magento/CatalogSearch/Model/Search/IndexBuilder.php @@ -26,8 +26,8 @@ /** * Build base Query for Index * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class IndexBuilder implements IndexBuilderInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Search/QueryChecker/FullTextSearchCheck.php b/app/code/Magento/CatalogSearch/Model/Search/QueryChecker/FullTextSearchCheck.php index a70f83d7ac91b..c122bae15cb0c 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/QueryChecker/FullTextSearchCheck.php +++ b/app/code/Magento/CatalogSearch/Model/Search/QueryChecker/FullTextSearchCheck.php @@ -13,8 +13,8 @@ /** * Class is responsible for checking if fulltext search is required for search query * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class FullTextSearchCheck { diff --git a/app/code/Magento/CatalogSearch/Model/Search/ReaderPlugin.php b/app/code/Magento/CatalogSearch/Model/Search/ReaderPlugin.php index 7256e11b8edbd..916e03f471493 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/ReaderPlugin.php +++ b/app/code/Magento/CatalogSearch/Model/Search/ReaderPlugin.php @@ -6,8 +6,8 @@ namespace Magento\CatalogSearch\Model\Search; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class ReaderPlugin { diff --git a/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator.php b/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator.php index 8e47a0674e2da..0adc2fcecbfa7 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator.php +++ b/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator.php @@ -14,10 +14,10 @@ use Magento\Framework\Search\Request\QueryInterface; /** + * Catalog search request generator. + * * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class RequestGenerator { diff --git a/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/Decimal.php b/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/Decimal.php index 5729b2544b3f4..b3d39a48fe9fc 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/Decimal.php +++ b/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/Decimal.php @@ -11,13 +11,12 @@ use Magento\Framework\Search\Request\FilterInterface; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Catalog search range request generator. */ class Decimal implements GeneratorInterface { /** - * {@inheritdoc} + * @inheritdoc */ public function getFilterData(Attribute $attribute, $filterName) { @@ -31,7 +30,7 @@ public function getFilterData(Attribute $attribute, $filterName) } /** - * {@inheritdoc} + * @inheritdoc */ public function getAggregationData(Attribute $attribute, $bucketName) { diff --git a/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/General.php b/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/General.php index 8db96ad04b20f..63b09de7f08d8 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/General.php +++ b/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/General.php @@ -11,13 +11,12 @@ use Magento\Framework\Search\Request\FilterInterface; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * Catalog search request generator. */ class General implements GeneratorInterface { /** - * {@inheritdoc} + * @inheritdoc */ public function getFilterData(Attribute $attribute, $filterName) { @@ -30,7 +29,7 @@ public function getFilterData(Attribute $attribute, $filterName) } /** - * {@inheritdoc} + * @inheritdoc */ public function getAggregationData(Attribute $attribute, $bucketName) { diff --git a/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/GeneratorInterface.php b/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/GeneratorInterface.php index 2eb7d06d31a5c..22f829063fbe7 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/GeneratorInterface.php +++ b/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/GeneratorInterface.php @@ -9,15 +9,16 @@ use Magento\Catalog\Model\ResourceModel\Eav\Attribute; /** + * Catalog search reguest generator interface. + * * @api * @since 100.1.6 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ interface GeneratorInterface { /** - * Get filter data for specific attribute + * Get filter data for specific attribute. + * * @param Attribute $attribute * @param string $filterName * @return array @@ -26,7 +27,8 @@ interface GeneratorInterface public function getFilterData(Attribute $attribute, $filterName); /** - * Get aggregation data for specific attribute + * Get aggregation data for specific attribute. + * * @param Attribute $attribute * @param string $bucketName * @return array diff --git a/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/GeneratorResolver.php b/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/GeneratorResolver.php index 5e4c2e0ff8ad6..68ca546b81919 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/GeneratorResolver.php +++ b/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/GeneratorResolver.php @@ -9,8 +9,8 @@ /** * @api * @since 100.1.6 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class GeneratorResolver { diff --git a/app/code/Magento/CatalogSearch/Model/Search/SelectContainer/SelectContainer.php b/app/code/Magento/CatalogSearch/Model/Search/SelectContainer/SelectContainer.php index ffd434251f9f5..f0eade4bfbcf5 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/SelectContainer/SelectContainer.php +++ b/app/code/Magento/CatalogSearch/Model/Search/SelectContainer/SelectContainer.php @@ -10,11 +10,10 @@ use Magento\Framework\Search\Request\FilterInterface; /** - * Class SelectContainer * This class is a container for all data that is required for creating select query by search request * - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class SelectContainer { diff --git a/app/code/Magento/CatalogSearch/Model/Search/SelectContainer/SelectContainerBuilder.php b/app/code/Magento/CatalogSearch/Model/Search/SelectContainer/SelectContainerBuilder.php index b6e60aabf484a..d5b7be8bf0106 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/SelectContainer/SelectContainerBuilder.php +++ b/app/code/Magento/CatalogSearch/Model/Search/SelectContainer/SelectContainerBuilder.php @@ -18,8 +18,8 @@ * Class SelectContainerBuilder * Class is responsible for SelectContainer creation and filling it with all required data * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class SelectContainerBuilder { diff --git a/app/code/Magento/CatalogSearch/Model/Search/TableMapper.php b/app/code/Magento/CatalogSearch/Model/Search/TableMapper.php index 001f9936c9586..6b18c4307f515 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/TableMapper.php +++ b/app/code/Magento/CatalogSearch/Model/Search/TableMapper.php @@ -25,8 +25,8 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class TableMapper { diff --git a/app/code/Magento/CatalogSearch/Model/Source/Weight.php b/app/code/Magento/CatalogSearch/Model/Source/Weight.php index c02d861fda8dd..495e1a4567d63 100644 --- a/app/code/Magento/CatalogSearch/Model/Source/Weight.php +++ b/app/code/Magento/CatalogSearch/Model/Source/Weight.php @@ -9,8 +9,6 @@ * Attribute weight options * @api * @since 100.0.2 - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. */ class Weight implements \Magento\Framework\Data\OptionSourceInterface { diff --git a/app/code/Magento/CatalogSearch/Plugin/EnableEavIndexer.php b/app/code/Magento/CatalogSearch/Plugin/EnableEavIndexer.php index c624f9d1c2e52..956a1b2360f89 100644 --- a/app/code/Magento/CatalogSearch/Plugin/EnableEavIndexer.php +++ b/app/code/Magento/CatalogSearch/Plugin/EnableEavIndexer.php @@ -9,6 +9,9 @@ /** * Enable Product EAV indexer in configuration for MySQL search engine + * + * @deprecated + * @see \Magento\ElasticSearch */ class EnableEavIndexer { diff --git a/app/code/Magento/CatalogSearch/Setup/Patch/Data/MySQLSearchDeprecationNotification.php b/app/code/Magento/CatalogSearch/Setup/Patch/Data/MySQLSearchDeprecationNotification.php index a58ee2bcb184d..d3c5aa5aaa6f5 100644 --- a/app/code/Magento/CatalogSearch/Setup/Patch/Data/MySQLSearchDeprecationNotification.php +++ b/app/code/Magento/CatalogSearch/Setup/Patch/Data/MySQLSearchDeprecationNotification.php @@ -7,6 +7,12 @@ namespace Magento\CatalogSearch\Setup\Patch\Data; +/** + * Implementation of the notification about MySQL search being deprecated. + * + * @deprecated + * @see \Magento\ElasticSearch + */ class MySQLSearchDeprecationNotification implements \Magento\Framework\Setup\Patch\DataPatchInterface { /** diff --git a/app/code/Magento/CatalogSearch/Setup/Patch/Data/SetInitialSearchWeightForAttributes.php b/app/code/Magento/CatalogSearch/Setup/Patch/Data/SetInitialSearchWeightForAttributes.php index 23429dd43e3fe..7f6dbe033e3a5 100644 --- a/app/code/Magento/CatalogSearch/Setup/Patch/Data/SetInitialSearchWeightForAttributes.php +++ b/app/code/Magento/CatalogSearch/Setup/Patch/Data/SetInitialSearchWeightForAttributes.php @@ -13,8 +13,8 @@ use Magento\Catalog\Api\ProductAttributeRepositoryInterface; /** - * @deprecated CatalogSearch will be removed in 2.4, and {@see \Magento\ElasticSearch} - * will replace it as the default search engine. + * @deprecated + * @see \Magento\ElasticSearch */ class SetInitialSearchWeightForAttributes implements DataPatchInterface, PatchVersionInterface { diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilderTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilderTest.php index 72379c3819dea..949554506d5b0 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilderTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProvider/QueryBuilderTest.php @@ -20,6 +20,8 @@ * Test for Magento\CatalogSearch\Model\Adapter\Mysql\Aggregation\DataProvider\QueryBuilder. * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @deprecated + * @see \Magento\ElasticSearch */ class QueryBuilderTest extends \PHPUnit\Framework\TestCase { diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProviderTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProviderTest.php index 8eeceba8209bf..85b1b136e78d2 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProviderTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProviderTest.php @@ -23,6 +23,9 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * + * @deprecated + * @see \Magento\ElasticSearch */ class DataProviderTest extends \PHPUnit\Framework\TestCase { diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Dynamic/DataProviderTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Dynamic/DataProviderTest.php index 1186dd6936cc6..b064eec3338e9 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Dynamic/DataProviderTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Dynamic/DataProviderTest.php @@ -19,8 +19,9 @@ use Magento\Store\Model\StoreManager; /** - * Class DataProviderTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @deprecated + * @see \Magento\ElasticSearch */ class DataProviderTest extends \PHPUnit\Framework\TestCase { diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Field/ResolverTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Field/ResolverTest.php index ca19e5e995c81..1e609cdeac28f 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Field/ResolverTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Field/ResolverTest.php @@ -9,6 +9,9 @@ /** * Unit tests for Magento\CatalogSearch\Model\Adapter\Mysql\Field\Resolver class. + * + * @deprecated + * @see \Magento\ElasticSearch */ class ResolverTest extends \PHPUnit\Framework\TestCase { diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Filter/AliasResolverTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Filter/AliasResolverTest.php index 697fab6507934..1690d9f39360f 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Filter/AliasResolverTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Filter/AliasResolverTest.php @@ -9,6 +9,10 @@ use Magento\CatalogSearch\Model\Search\RequestGenerator; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +/** + * @deprecated + * @see \Magento\ElasticSearch + */ class AliasResolverTest extends \PHPUnit\Framework\TestCase { /** diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Filter/PreprocessorTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Filter/PreprocessorTest.php index 01108358da2e0..7e3de7534e8c4 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Filter/PreprocessorTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Filter/PreprocessorTest.php @@ -15,6 +15,8 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @deprecated + * @see \Magento\ElasticSearch */ class PreprocessorTest extends \PHPUnit\Framework\TestCase { diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/ResourceModel/Advanced/CollectionTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/ResourceModel/Advanced/CollectionTest.php index 21d67bdf53c56..b65a0d6ca47a0 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/ResourceModel/Advanced/CollectionTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/ResourceModel/Advanced/CollectionTest.php @@ -13,6 +13,8 @@ * Tests Magento\CatalogSearch\Model\ResourceModel\Advanced\Collection * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @deprecated + * @see \Magento\ElasticSearch */ class CollectionTest extends BaseCollection { diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/ResourceModel/BaseCollection.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/ResourceModel/BaseCollection.php index e99d75c25f5cd..9ea103e23d2a7 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/ResourceModel/BaseCollection.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/ResourceModel/BaseCollection.php @@ -9,6 +9,9 @@ * Base class for Collection tests. * * Contains helper methods to get commonly used mocks used for collection tests. + * + * @deprecated + * @see \Magento\ElasticSearch **/ class BaseCollection extends \PHPUnit\Framework\TestCase { diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/BaseSelectStrategy/StrategyMapperTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/BaseSelectStrategy/StrategyMapperTest.php index 5fa5b0333c6ba..b168e72811760 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/BaseSelectStrategy/StrategyMapperTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/BaseSelectStrategy/StrategyMapperTest.php @@ -11,6 +11,10 @@ use \Magento\CatalogSearch\Model\Search\BaseSelectStrategy\StrategyMapper; use \Magento\CatalogSearch\Model\Search\SelectContainer\SelectContainer; +/** + * @deprecated + * @see \Magento\ElasticSearch + */ class StrategyMapperTest extends \PHPUnit\Framework\TestCase { /** @var BaseSelectAttributesSearchStrategy|\PHPUnit_Framework_MockObject_MockObject */ diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/ExclusionStrategyTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/ExclusionStrategyTest.php index 09591532f9f06..e693807760ea5 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/ExclusionStrategyTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/ExclusionStrategyTest.php @@ -17,6 +17,8 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @deprecated + * @see \Magento\ElasticSearch */ class ExclusionStrategyTest extends \PHPUnit\Framework\TestCase { diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/FilterContextTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/FilterContextTest.php index e16f23ca09d2c..12ce0d63ac685 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/FilterContextTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/FilterContextTest.php @@ -16,6 +16,10 @@ use Magento\Framework\Search\Request\FilterInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * @deprecated + * @see \Magento\ElasticSearch + */ class FilterContextTest extends \PHPUnit\Framework\TestCase { /** diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/TermDropdownStrategyTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/TermDropdownStrategyTest.php index 8771c92039f4d..e064f46655d91 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/TermDropdownStrategyTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/FilterMapper/TermDropdownStrategyTest.php @@ -18,6 +18,9 @@ /** * Class TermDropdownStrategyTest. * Unit test for \Magento\CatalogSearch\Model\Search\FilterMapper\TermDropdownStrategy. + * + * @deprecated + * @see \Magento\ElasticSearch */ class TermDropdownStrategyTest extends \PHPUnit\Framework\TestCase { diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php index da7cfa1ea9821..b066c118ef783 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/IndexBuilderTest.php @@ -27,6 +27,8 @@ * Test for \Magento\CatalogSearch\Model\Search\IndexBuilder * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @deprecated + * @see \Magento\ElasticSearch */ class IndexBuilderTest extends \PHPUnit\Framework\TestCase { diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/TableMapperTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/TableMapperTest.php index cfddc07bceecc..db46755261534 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/TableMapperTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Search/TableMapperTest.php @@ -18,7 +18,10 @@ /** * Test for \Magento\CatalogSearch\Model\Search\TableMapper + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @deprecated + * @see \Magento\ElasticSearch */ class TableMapperTest extends \PHPUnit\Framework\TestCase { diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Plugin/EnableEavIndexerTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Plugin/EnableEavIndexerTest.php index 0eac2e3309aec..b20fdde7c5216 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Plugin/EnableEavIndexerTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Plugin/EnableEavIndexerTest.php @@ -9,6 +9,10 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +/** + * @deprecated + * @see \Magento\ElasticSearch + */ class EnableEavIndexerTest extends \PHPUnit\Framework\TestCase { /** diff --git a/app/code/Magento/CatalogSearch/composer.json b/app/code/Magento/CatalogSearch/composer.json index a823867296ffd..7bcb91e945417 100644 --- a/app/code/Magento/CatalogSearch/composer.json +++ b/app/code/Magento/CatalogSearch/composer.json @@ -1,6 +1,6 @@ { "name": "magento/module-catalog-search", - "description": "[Deprecated] CatalogSearch will be removed in 2.4, and ElasticSearch will replace it as the default search engine.", + "description": "Catalog search", "config": { "sort-packages": true }, diff --git a/app/code/Magento/CatalogUrlRewrite/etc/db_schema.xml b/app/code/Magento/CatalogUrlRewrite/etc/db_schema.xml index 174173fa2019f..c8da5b59cf5f5 100644 --- a/app/code/Magento/CatalogUrlRewrite/etc/db_schema.xml +++ b/app/code/Magento/CatalogUrlRewrite/etc/db_schema.xml @@ -15,16 +15,16 @@ comment="category_id"/> <column xsi:type="int" name="product_id" padding="10" unsigned="true" nullable="false" identity="false" comment="product_id"/> - <constraint xsi:type="foreign" name="CAT_URL_REWRITE_PRD_CTGR_PRD_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_URL_REWRITE_PRD_CTGR_PRD_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_url_rewrite_product_category" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="FK_BB79E64705D7F17FE181F23144528FC8" + <constraint xsi:type="foreign" referenceId="FK_BB79E64705D7F17FE181F23144528FC8" table="catalog_url_rewrite_product_category" column="url_rewrite_id" referenceTable="url_rewrite" referenceColumn="url_rewrite_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_URL_REWRITE_PRD_CTGR_CTGR_ID_CAT_CTGR_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_URL_REWRITE_PRD_CTGR_CTGR_ID_CAT_CTGR_ENTT_ENTT_ID" table="catalog_url_rewrite_product_category" column="category_id" referenceTable="catalog_category_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="CATALOG_URL_REWRITE_PRODUCT_CATEGORY_CATEGORY_ID_PRODUCT_ID" indexType="btree"> + <index referenceId="CATALOG_URL_REWRITE_PRODUCT_CATEGORY_CATEGORY_ID_PRODUCT_ID" indexType="btree"> <column name="category_id"/> <column name="product_id"/> </index> diff --git a/app/code/Magento/Checkout/Controller/Cart/Delete.php b/app/code/Magento/Checkout/Controller/Cart/Delete.php index 7e88a484f9f6c..e9c15bd7f8cc1 100644 --- a/app/code/Magento/Checkout/Controller/Cart/Delete.php +++ b/app/code/Magento/Checkout/Controller/Cart/Delete.php @@ -1,6 +1,5 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ @@ -8,6 +7,11 @@ use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; +/** + * Action Delete. + * + * Deletes item from cart. + */ class Delete extends \Magento\Checkout\Controller\Cart implements HttpPostActionInterface { /** @@ -24,7 +28,12 @@ public function execute() $id = (int)$this->getRequest()->getParam('id'); if ($id) { try { - $this->cart->removeItem($id)->save(); + $this->cart->removeItem($id); + // We should set Totals to be recollected once more because of Cart model as usually is loading + // before action executing and in case when triggerRecollect setted as true recollecting will + // executed and the flag will be true already. + $this->cart->getQuote()->setTotalsCollectedFlag(false); + $this->cart->save(); } catch (\Exception $e) { $this->messageManager->addErrorMessage(__('We can\'t remove the item.')); $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); diff --git a/app/code/Magento/Checkout/Model/Cart.php b/app/code/Magento/Checkout/Model/Cart.php index a18cba3f67c84..eff07af0e6a3e 100644 --- a/app/code/Magento/Checkout/Model/Cart.php +++ b/app/code/Magento/Checkout/Model/Cart.php @@ -380,6 +380,10 @@ public function addProduct($productInfo, $requestInfo = null) } try { + $this->_eventManager->dispatch( + 'checkout_cart_product_add_before', + ['info' => $requestInfo, 'product' => $product] + ); $result = $this->getQuote()->addProduct($product, $request); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->_checkoutSession->setUseNotice(false); @@ -615,6 +619,8 @@ public function truncate() } /** + * Get product ids. + * * @return int[] */ public function getProductIds() diff --git a/app/code/Magento/Checkout/Model/ShippingInformationManagement.php b/app/code/Magento/Checkout/Model/ShippingInformationManagement.php index 381ee2b9015c9..cd3bd2c5a7deb 100644 --- a/app/code/Magento/Checkout/Model/ShippingInformationManagement.php +++ b/app/code/Magento/Checkout/Model/ShippingInformationManagement.php @@ -19,6 +19,9 @@ use Magento\Framework\App\ObjectManager; /** + * Class ShippingInformationManagement + * + * @package Magento\Checkout\Model * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ShippingInformationManagement implements \Magento\Checkout\Api\ShippingInformationManagementInterface @@ -99,8 +102,8 @@ class ShippingInformationManagement implements \Magento\Checkout\Api\ShippingInf * @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Quote\Model\Quote\TotalsCollector $totalsCollector - * @param CartExtensionFactory|null $cartExtensionFactory, - * @param ShippingAssignmentFactory|null $shippingAssignmentFactory, + * @param CartExtensionFactory|null $cartExtensionFactory + * @param ShippingAssignmentFactory|null $shippingAssignmentFactory * @param ShippingFactory|null $shippingFactory * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -136,7 +139,14 @@ public function __construct( } /** - * {@inheritDoc} + * Save address information. + * + * @param int $cartId + * @param \Magento\Checkout\Api\Data\ShippingInformationInterface $addressInformation + * @return \Magento\Checkout\Api\Data\PaymentDetailsInterface + * @throws InputException + * @throws NoSuchEntityException + * @throws StateException */ public function saveAddressInformation( $cartId, @@ -151,6 +161,10 @@ public function saveAddressInformation( $address->setCustomerAddressId(null); } + if ($billingAddress && !$billingAddress->getCustomerAddressId()) { + $billingAddress->setCustomerAddressId(null); + } + if (!$address->getCountryId()) { throw new StateException(__('The shipping address is missing. Set the address and try again.')); } @@ -208,6 +222,8 @@ protected function validateQuote(\Magento\Quote\Model\Quote $quote) } /** + * Prepare shipping assignment. + * * @param CartInterface $quote * @param AddressInterface $address * @param string $method diff --git a/app/code/Magento/Checkout/Plugin/Model/Quote/ResetQuoteAddresses.php b/app/code/Magento/Checkout/Plugin/Model/Quote/ResetQuoteAddresses.php index 3791b28917e97..e7776b3dcbedc 100644 --- a/app/code/Magento/Checkout/Plugin/Model/Quote/ResetQuoteAddresses.php +++ b/app/code/Magento/Checkout/Plugin/Model/Quote/ResetQuoteAddresses.php @@ -15,10 +15,11 @@ class ResetQuoteAddresses { /** + * Clears the quote addresses when all the items are removed from the cart + * * @param Quote $quote * @param Quote $result * @param mixed $itemId - * * @return Quote * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -28,6 +29,10 @@ public function afterRemoveItem(Quote $quote, Quote $result, $itemId): Quote foreach ($result->getAllAddresses() as $address) { $result->removeAddress($address->getId()); } + $extensionAttributes = $result->getExtensionAttributes(); + if (!$result->isVirtual() && $extensionAttributes && $extensionAttributes->getShippingAssignments()) { + $extensionAttributes->setShippingAssignments([]); + } } return $result; diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml index 32d6ad8667029..41b1e0d811851 100644 --- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml @@ -38,6 +38,51 @@ <seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/> </actionGroup> + <!-- Guest checkout filling shipping section without region --> + <actionGroup name="GuestCheckoutFillingShippingSectionWithoutRegionActionGroup"> + <arguments> + <argument name="customerVar"/> + <argument name="customerAddressVar"/> + </arguments> + <fillField selector="{{CheckoutShippingSection.email}}" userInput="{{customerVar.email}}" stepKey="enterEmail"/> + <fillField selector="{{CheckoutShippingSection.firstName}}" userInput="{{customerVar.firstname}}" stepKey="enterFirstName"/> + <fillField selector="{{CheckoutShippingSection.lastName}}" userInput="{{customerVar.lastname}}" stepKey="enterLastName"/> + <fillField selector="{{CheckoutShippingSection.street}}" userInput="{{customerAddressVar.street[0]}}" stepKey="enterStreet"/> + <fillField selector="{{CheckoutShippingSection.city}}" userInput="{{customerAddressVar.city}}" stepKey="enterCity"/> + <fillField selector="{{CheckoutShippingSection.postcode}}" userInput="{{customerAddressVar.postcode}}" stepKey="enterPostcode"/> + <selectOption selector="{{CheckoutShippingSection.country}}" userInput="{{customerAddressVar.country_id}}" stepKey="enterCountry"/> + <fillField selector="{{CheckoutShippingSection.telephone}}" userInput="{{customerAddressVar.telephone}}" stepKey="enterTelephone"/> + <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/> + <click selector="{{CheckoutShippingSection.firstShippingMethod}}" stepKey="selectFirstShippingMethod"/> + <waitForElement selector="{{CheckoutShippingSection.next}}" time="30" stepKey="waitForNextButton"/> + <click selector="{{CheckoutShippingSection.next}}" stepKey="clickNext"/> + <waitForElement selector="{{CheckoutPaymentSection.paymentSectionTitle}}" time="30" stepKey="waitForPaymentSectionLoaded"/> + <seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/> + </actionGroup> + + <!-- Guest checkout filling shipping section with unavailable payments--> + <actionGroup name="GuestCheckoutFillingShippingSectionUnavailablePaymentActionGroup"> + <arguments> + <argument name="customerVar"/> + <argument name="customerAddressVar"/> + </arguments> + <fillField selector="{{CheckoutShippingSection.email}}" userInput="{{customerVar.email}}" stepKey="enterEmail"/> + <fillField selector="{{CheckoutShippingSection.firstName}}" userInput="{{customerVar.firstname}}" stepKey="enterFirstName"/> + <fillField selector="{{CheckoutShippingSection.lastName}}" userInput="{{customerVar.lastname}}" stepKey="enterLastName"/> + <fillField selector="{{CheckoutShippingSection.street}}" userInput="{{customerAddressVar.street[0]}}" stepKey="enterStreet"/> + <fillField selector="{{CheckoutShippingSection.city}}" userInput="{{customerAddressVar.city}}" stepKey="enterCity"/> + <selectOption selector="{{CheckoutShippingSection.region}}" userInput="{{customerAddressVar.state}}" stepKey="selectRegion"/> + <fillField selector="{{CheckoutShippingSection.postcode}}" userInput="{{customerAddressVar.postcode}}" stepKey="enterPostcode"/> + <fillField selector="{{CheckoutShippingSection.telephone}}" userInput="{{customerAddressVar.telephone}}" stepKey="enterTelephone"/> + <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/> + <click selector="{{CheckoutShippingSection.firstShippingMethod}}" stepKey="selectFirstShippingMethod"/> + <waitForElement selector="{{CheckoutShippingSection.next}}" time="30" stepKey="waitForNextButton"/> + <click selector="{{CheckoutShippingSection.next}}" stepKey="clickNext"/> + <seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/> + <waitForElementVisible selector="{{CheckoutPaymentSection.noQuotes}}" stepKey="waitMessage"/> + <see userInput="No Payment method available." stepKey="checkMessage"/> + </actionGroup> + <!-- Logged in user checkout filling shipping section --> <actionGroup name="LoggedInUserCheckoutFillingShippingSectionActionGroup"> <arguments> @@ -59,6 +104,28 @@ <seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/> </actionGroup> + <!-- Logged in user checkout filling shipping section --> + <actionGroup name="LoggedInUserCheckoutAddNewShippingSectionWithoutRegionActionGroup"> + <arguments> + <argument name="customerVar"/> + <argument name="customerAddressVar"/> + </arguments> + <fillField selector="{{CheckoutShippingSection.firstName}}" userInput="{{customerVar.firstname}}" stepKey="enterFirstName"/> + <fillField selector="{{CheckoutShippingSection.lastName}}" userInput="{{customerVar.lastname}}" stepKey="enterLastName"/> + <fillField selector="{{CheckoutShippingSection.street}}" userInput="{{customerAddressVar.street[0]}}" stepKey="enterStreet"/> + <fillField selector="{{CheckoutShippingSection.city}}" userInput="{{customerAddressVar.city}}" stepKey="enterCity"/> + <fillField selector="{{CheckoutShippingSection.postcode}}" userInput="{{customerAddressVar.postcode}}" stepKey="enterPostcode"/> + <selectOption selector="{{CheckoutShippingSection.country}}" userInput="{{customerAddressVar.country_id}}" stepKey="enterCountry"/> + <fillField selector="{{CheckoutShippingSection.telephone}}" userInput="{{customerAddressVar.telephone}}" stepKey="enterTelephone"/> + <click selector="{{CheckoutShippingSection.saveAddress}}" stepKey="clickSaveAddress"/> + <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/> + <click selector="{{CheckoutShippingSection.firstShippingMethod}}" stepKey="selectFirstShippingMethod"/> + <waitForElement selector="{{CheckoutShippingSection.next}}" time="30" stepKey="waitForNextButton"/> + <click selector="{{CheckoutShippingSection.next}}" stepKey="clickNext"/> + <waitForElement selector="{{CheckoutPaymentSection.paymentSectionTitle}}" time="30" stepKey="waitForPaymentSectionLoaded"/> + <seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/> + </actionGroup> + <!-- Check product in checkout cart items --> <actionGroup name="CheckProductInCheckoutCartItemsActionGroup"> <arguments> diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontMiniCartActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontMiniCartActionGroup.xml index cb53a2a4f381f..7a5c5e1d15872 100644 --- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontMiniCartActionGroup.xml +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontMiniCartActionGroup.xml @@ -21,4 +21,18 @@ <waitForElementVisible selector="{{StorefrontMinicartSection.viewAndEditCart}}" stepKey="waitForViewAndEditCartVisible"/> <see selector="{{StorefrontMinicartSection.miniCartItemsText}}" userInput="{{productName}}" stepKey="seeInMiniCart"/> </actionGroup> + + <!--Remove an item from the cart using minicart--> + <actionGroup name="removeProductFromMiniCart"> + <arguments> + <argument name="productName" type="string"/> + </arguments> + <conditionalClick selector="{{StorefrontMinicartSection.showCart}}" dependentSelector="{{StorefrontMinicartSection.miniCartOpened}}" visible="false" stepKey="openMiniCart"/> + <waitForElementVisible selector="{{StorefrontMinicartSection.viewAndEditCart}}" stepKey="waitForMiniCartOpen"/> + <click selector="{{StorefrontMinicartSection.deleteMiniCartItemByName(productName)}}" stepKey="clickDelete"/> + <waitForElementVisible selector="{{StoreFrontRemoveItemModalSection.message}}" stepKey="waitForConfirmationModal"/> + <see selector="{{StoreFrontRemoveItemModalSection.message}}" userInput="Are you sure you would like to remove this item from the shopping cart?" stepKey="seeDeleteConfirmationMessage"/> + <click selector="{{StoreFrontRemoveItemModalSection.ok}}" stepKey="confirmDelete"/> + <waitForPageLoad stepKey="waitForDeleteToFinish"/> + </actionGroup> </actionGroups> diff --git a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutPaymentSection.xml b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutPaymentSection.xml index 7dda1110fd145..846b20ed225dd 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutPaymentSection.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutPaymentSection.xml @@ -50,5 +50,6 @@ <element name="shippingAndBillingAddressSame" type="input" selector="#billing-address-same-as-shipping-braintree_cc_vault"/> <element name="addressAction" type="button" selector="//span[text()='{{action}}']" parameterized="true"/> <element name="addressBook" type="button" selector="//a[text()='Address Book']"/> + <element name="noQuotes" type="text" selector=".no-quotes-block"/> </section> </sections> diff --git a/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontMiniCartSection.xml b/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontMiniCartSection.xml index c8ff851ae54ab..231713075881e 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontMiniCartSection.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontMiniCartSection.xml @@ -22,6 +22,7 @@ <element name="viewAndEditCart" type="button" selector=".action.viewcart" timeout="30"/> <element name="miniCartItemsText" type="text" selector=".minicart-items"/> <element name="deleteMiniCartItem" type="button" selector=".action.delete" timeout="30"/> + <element name="deleteMiniCartItemByName" type="button" selector="//ol[@id='mini-cart']//div[contains(., '{{var}}')]//a[contains(@class, 'delete')]" parameterized="true"/> <element name="miniCartSubtotalField" type="text" selector=".block-minicart .amount span.price"/> <element name="itemQuantity" type="input" selector="//a[text()='{{productName}}']/../..//input[contains(@class,'cart-item-qty')]" parameterized="true"/> <element name="itemQuantityUpdate" type="button" selector="//a[text()='{{productName}}']/../..//span[text()='Update']" parameterized="true"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest.xml index 13e4e286311b2..1ef7403e94ce1 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest.xml @@ -193,4 +193,69 @@ <waitForPageLoad stepKey="waitForOrderSuccessPage2"/> <see stepKey="seeSuccessMessage2" selector="{{CheckoutSuccessMainSection.success}}" userInput="Your order number is:" /> </test> + <test name="StorefrontCustomerCheckoutTestWithRestrictedCountriesForPayment"> + <annotations> + <features value="Checkout"/> + <stories value="Checkout flow if payment solutions are not available"/> + <title value="Checkout via Customer Checkout with restricted countries for payment"/> + <description value="Should be able to place an order as a Customer with restricted countries for payment."/> + <severity value="MAJOR"/> + <testCaseId value="MAGETWO-42653"/> + <group value="checkout"/> + </annotations> + <before> + <createData entity="_defaultCategory" stepKey="createCategory"/> + <createData entity="ApiSimpleProduct" stepKey="createProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <magentoCLI stepKey="allowSpecificValue" command="config:set payment/checkmo/allowspecific 1" /> + <magentoCLI stepKey="specificCountryValue" command="config:set payment/checkmo/specificcountry GB" /> + <createData entity="Simple_US_Customer" stepKey="simpleuscustomer"/> + </before> + <after> + <amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> + <magentoCLI stepKey="allowSpecificValue" command="config:set payment/checkmo/allowspecific 0" /> + <magentoCLI stepKey="specificCountryValue" command="config:set payment/checkmo/specificcountry ''" /> + </after> + <!-- Login as Customer --> + <actionGroup ref="LoginToStorefrontActionGroup" stepKey="customerLogin"> + <argument name="Customer" value="$$simpleuscustomer$$" /> + </actionGroup> + + <!-- Add product to cart --> + <amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="onCategoryPage"/> + <waitForPageLoad stepKey="waitForPageLoad1"/> + <moveMouseOver selector="{{StorefrontCategoryMainSection.ProductItemInfo}}" stepKey="hoverProduct"/> + <click selector="{{StorefrontCategoryMainSection.AddToCartBtn}}" stepKey="addToCart"/> + <waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" time="30" stepKey="waitForProductAdded"/> + <see selector="{{StorefrontCategoryMainSection.SuccessMsg}}" userInput="You added $$createProduct.name$$ to your shopping cart." stepKey="seeAddedToCartMessage"/> + <see selector="{{StorefrontMinicartSection.quantity}}" userInput="1" stepKey="seeCartQuantity"/> + + <!-- Go to checkout page --> + <actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="customerGoToCheckoutFromMinicart" /> + + <!-- Select address --> + <click stepKey="selectAddress" selector="{{CheckoutShippingMethodsSection.firstShippingMethod}}"/> + <waitForElement stepKey="waitNextButton" selector="{{CheckoutShippingMethodsSection.next}}" time="30"/> + <click stepKey="clickNextButton" selector="{{CheckoutShippingMethodsSection.next}}" /> + <waitForPageLoad stepKey="waitBillingForm"/> + <seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/> + <waitForElementVisible selector="{{CheckoutPaymentSection.noQuotes}}" stepKey="waitMessage"/> + <see userInput="No Payment method available." stepKey="checkMessage"/> + + <!-- Fill UK Address and verify that payment available and checkout successful --> + <click selector="{{CheckoutHeaderSection.shippingMethodStep}}" stepKey="goToShipping" /> + <click selector="{{CheckoutShippingSection.newAddressButton}}" stepKey="fillNewAddress" /> + <actionGroup ref="LoggedInUserCheckoutAddNewShippingSectionWithoutRegionActionGroup" stepKey="customerCheckoutFillingShippingSectionUK"> + <argument name="customerVar" value="CustomerEntityOne" /> + <argument name="customerAddressVar" value="UK_Not_Default_Address" /> + </actionGroup> + <actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="customerSelectCheckMoneyOrderPayment" /> + <actionGroup ref="CheckoutPlaceOrderActionGroup" stepKey="customerPlaceorder"> + <argument name="orderNumberMessage" value="CONST.successCheckoutOrderNumberMessage" /> + <argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage" /> + </actionGroup> + </test> </tests> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml index a7b82d54afb30..02cc233acc7bc 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml @@ -68,4 +68,61 @@ <see selector="{{AdminOrderDetailsInformationSection.shippingAddress}}" userInput="{{CustomerAddressSimple.street[0]}}" stepKey="seeAdminOrderShippingAddress"/> <see selector="{{AdminOrderDetailsInformationSection.itemsOrdered}}" userInput="$$createProduct.name$$" stepKey="seeAdminOrderProduct"/> </test> + <test name="StorefrontGuestCheckoutTestWithRestrictedCountriesForPayment"> + <annotations> + <features value="Checkout"/> + <stories value="Checkout flow if payment solutions are not available"/> + <title value="Checkout via Guest Checkout with restricted countries for payment"/> + <description value="Should be able to place an order as a Guest with restricted countries for payment."/> + <severity value="CRITICAL"/> + <testCaseId value="MAGETWO-42653"/> + <group value="checkout"/> + </annotations> + <before> + <createData entity="_defaultCategory" stepKey="createCategory"/> + <createData entity="ApiSimpleProduct" stepKey="createProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <magentoCLI stepKey="allowSpecificValue" command="config:set payment/checkmo/allowspecific 1" /> + <magentoCLI stepKey="specificCountryValue" command="config:set payment/checkmo/specificcountry GB" /> + + </before> + <after> + <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> + <magentoCLI stepKey="allowSpecificValue" command="config:set payment/checkmo/allowspecific 0" /> + <magentoCLI stepKey="specificCountryValue" command="config:set payment/checkmo/specificcountry ''" /> + </after> + + <!-- Add product to cart --> + <amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="onCategoryPage"/> + <waitForPageLoad stepKey="waitForPageLoad1"/> + <moveMouseOver selector="{{StorefrontCategoryMainSection.ProductItemInfo}}" stepKey="hoverProduct"/> + <click selector="{{StorefrontCategoryMainSection.AddToCartBtn}}" stepKey="addToCart"/> + <waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" time="30" stepKey="waitForProductAdded"/> + <see selector="{{StorefrontCategoryMainSection.SuccessMsg}}" userInput="You added $$createProduct.name$$ to your shopping cart." stepKey="seeAddedToCartMessage"/> + <see selector="{{StorefrontMinicartSection.quantity}}" userInput="1" stepKey="seeCartQuantity"/> + + <!-- Go to checkout page --> + <actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="guestGoToCheckoutFromMinicart" /> + + <!-- Fill US Address and verify that no payment available --> + <actionGroup ref="GuestCheckoutFillingShippingSectionUnavailablePaymentActionGroup" stepKey="guestCheckoutFillingShippingSection"> + <argument name="customerVar" value="CustomerEntityOne" /> + <argument name="customerAddressVar" value="CustomerAddressSimple" /> + </actionGroup> + + <!-- Fill UK Address and verify that payment available and checkout successful --> + <click selector="{{CheckoutHeaderSection.shippingMethodStep}}" stepKey="goToShipping" /> + <actionGroup ref="GuestCheckoutFillingShippingSectionWithoutRegionActionGroup" stepKey="guestCheckoutFillingShippingSectionUK"> + <argument name="customerVar" value="CustomerEntityOne" /> + <argument name="customerAddressVar" value="UK_Not_Default_Address" /> + </actionGroup> + <actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="guestSelectCheckMoneyOrderPayment" /> + <actionGroup ref="CheckoutPlaceOrderActionGroup" stepKey="guestPlaceorder"> + <argument name="orderNumberMessage" value="CONST.successGuestCheckoutOrderNumberMessage" /> + <argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage" /> + </actionGroup> + </test> </tests> diff --git a/app/code/Magento/Checkout/Test/Unit/Model/CartTest.php b/app/code/Magento/Checkout/Test/Unit/Model/CartTest.php index 6bd0bdf258a0a..bc66324c2986d 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/CartTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/CartTest.php @@ -318,6 +318,12 @@ public function testAddProduct($productInfo, $requestInfo) $this->productRepository->expects($this->any()) ->method('getById') ->will($this->returnValue($product)); + + $this->eventManagerMock->expects($this->at(0))->method('dispatch')->with( + 'checkout_cart_product_add_before', + ['info' => $requestInfo, 'product' => $product] + ); + $this->quoteMock->expects($this->once()) ->method('addProduct') ->will($this->returnValue(1)); @@ -325,7 +331,7 @@ public function testAddProduct($productInfo, $requestInfo) ->method('getQuote') ->will($this->returnValue($this->quoteMock)); - $this->eventManagerMock->expects($this->at(0))->method('dispatch')->with( + $this->eventManagerMock->expects($this->at(1))->method('dispatch')->with( 'checkout_cart_product_add_after', ['quote_item' => 1, 'product' => $product] ); @@ -363,6 +369,12 @@ public function testAddProductException() $this->productRepository->expects($this->any()) ->method('getById') ->will($this->returnValue($product)); + + $this->eventManagerMock->expects($this->once())->method('dispatch')->with( + 'checkout_cart_product_add_before', + ['info' => 4, 'product' => $product] + ); + $this->quoteMock->expects($this->once()) ->method('addProduct') ->will($this->returnValue('error')); @@ -370,10 +382,6 @@ public function testAddProductException() ->method('getQuote') ->will($this->returnValue($this->quoteMock)); - $this->eventManagerMock->expects($this->never())->method('dispatch')->with( - 'checkout_cart_product_add_after', - ['quote_item' => 1, 'product' => $product] - ); $this->expectException(\Magento\Framework\Exception\LocalizedException::class); $this->cart->addProduct(4, 4); } @@ -399,6 +407,11 @@ public function testAddProductExceptionBadParams() ->method('getById') ->will($this->returnValue($product)); + $this->eventManagerMock->expects($this->never())->method('dispatch')->with( + 'checkout_cart_product_add_before', + ['info' => 'bad', 'product' => $product] + ); + $this->eventManagerMock->expects($this->never())->method('dispatch')->with( 'checkout_cart_product_add_after', ['quote_item' => 1, 'product' => $product] diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js b/app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js index a1aacf6e80320..9b20a782c38d9 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js @@ -58,6 +58,16 @@ define([ } delete addressData['region_id']; + if (addressData['custom_attributes']) { + addressData['custom_attributes'] = Object.entries(addressData['custom_attributes']) + .map(function (customAttribute) { + return { + 'attribute_code': customAttribute[0], + 'value': customAttribute[1] + }; + }); + } + return address(addressData); }, diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/error-processor.js b/app/code/Magento/Checkout/view/frontend/web/js/model/error-processor.js index 16fc459729bbc..42b692ff9dd8d 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/error-processor.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/error-processor.js @@ -9,8 +9,8 @@ define([ 'mage/url', 'Magento_Ui/js/model/messageList', - 'consoleLogger' -], function (url, globalMessageList, consoleLogger) { + 'mage/translate' +], function (url, globalMessageList, $t) { 'use strict'; return { @@ -28,10 +28,10 @@ define([ } else { try { error = JSON.parse(response.responseText); - messageContainer.addErrorMessage(error); - } catch (e) { - consoleLogger.error(e); + } catch (exception) { + error = $t('Something went wrong with your request. Please try again later.'); } + messageContainer.addErrorMessage(error); } } }; diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js index c0f8b5a45fec9..395d15bc02f36 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js @@ -247,6 +247,7 @@ define([ */ setShippingInformation: function () { if (this.validateShippingInformation()) { + quote.billingAddress(null); checkoutDataResolver.resolveBillingAddress(); setShippingInformationAction().done( function () { diff --git a/app/code/Magento/CheckoutAgreements/etc/db_schema.xml b/app/code/Magento/CheckoutAgreements/etc/db_schema.xml index 31b3111df98eb..09cd1c5b63965 100644 --- a/app/code/Magento/CheckoutAgreements/etc/db_schema.xml +++ b/app/code/Magento/CheckoutAgreements/etc/db_schema.xml @@ -20,7 +20,7 @@ default="0" comment="Is Html"/> <column xsi:type="smallint" name="mode" padding="6" unsigned="false" nullable="false" identity="false" default="0" comment="Applied mode"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="agreement_id"/> </constraint> </table> @@ -29,14 +29,14 @@ comment="Agreement Id"/> <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Store Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="agreement_id"/> <column name="store_id"/> </constraint> - <constraint xsi:type="foreign" name="CHKT_AGRT_STORE_AGRT_ID_CHKT_AGRT_AGRT_ID" table="checkout_agreement_store" + <constraint xsi:type="foreign" referenceId="CHKT_AGRT_STORE_AGRT_ID_CHKT_AGRT_AGRT_ID" table="checkout_agreement_store" column="agreement_id" referenceTable="checkout_agreement" referenceColumn="agreement_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CHECKOUT_AGREEMENT_STORE_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="CHECKOUT_AGREEMENT_STORE_STORE_ID_STORE_STORE_ID" table="checkout_agreement_store" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> </table> diff --git a/app/code/Magento/Cms/Model/Wysiwyg/Config.php b/app/code/Magento/Cms/Model/Wysiwyg/Config.php index 5db3933dd1169..1da7b99c6d886 100644 --- a/app/code/Magento/Cms/Model/Wysiwyg/Config.php +++ b/app/code/Magento/Cms/Model/Wysiwyg/Config.php @@ -89,8 +89,6 @@ class Config extends \Magento\Framework\DataObject implements ConfigInterface /** * @var array - * @deprecated - * @see \Magento\Cms\Model\Wysiwyg\Gallery\DefaultConfigProvider */ protected $_windowSize; @@ -207,6 +205,12 @@ public function getConfig($data = []) if ($this->_authorization->isAllowed('Magento_Cms::media_gallery')) { $this->configProvider->processGalleryConfig($config); + $config->addData( + [ + 'files_browser_window_width' => $this->_windowSize['width'], + 'files_browser_window_height' => $this->_windowSize['height'], + ] + ); } if ($config->getData('add_widgets')) { $this->configProvider->processWidgetConfig($config); diff --git a/app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml b/app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml index 75a399720cd6a..92112661846c0 100644 --- a/app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml +++ b/app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml @@ -34,15 +34,18 @@ </section> <section name="MediaGallerySection"> <element name="Browse" type="button" selector=".mce-i-browse"/> + <element name="browseForImage" type="button" selector="//*[@id='srcbrowser']"/> <element name="BrowseUploadImage" type="file" selector=".fileupload" /> <element name="image" type="text" selector="//small[text()='{{var1}}']" parameterized="true"/> <element name="imageOrImageCopy" type="text" selector="//div[contains(@class,'media-gallery-modal')]//img[contains(@alt, '{{arg1}}.{{arg2}}')]|//img[contains(@alt,'{{arg1}}_') and contains(@alt,'.{{arg2}}')]" parameterized="true"/> <element name="imageSelected" type="text" selector="//small[text()='{{var1}}']/parent::*[@class='filecnt selected']" parameterized="true"/> <element name="ImageSource" type="input" selector=".mce-combobox.mce-abs-layout-item.mce-last.mce-has-open" /> <element name="ImageDescription" type="input" selector=".mce-textbox.mce-abs-layout-item.mce-last" /> + <element name="ImageDescriptionTinyMCE3" type="input" selector="#alt" /> <element name="Height" type="input" selector=".mce-textbox.mce-abs-layout-item.mce-first" /> <element name="UploadImage" type="file" selector=".fileupload" /> <element name="OkBtn" type="button" selector="//span[text()='Ok']"/> + <element name="insertBtn" type="button" selector="#insert"/> <element name="InsertFile" type="text" selector="#insert_files"/> <element name="CreateFolder" type="button" selector="#new_folder" /> <element name="DeleteSelectedBtn" type="text" selector="#delete_files"/> diff --git a/app/code/Magento/Cms/Test/Mftf/Test/AdminAddImageToCMSPageTinyMCE3Test.xml b/app/code/Magento/Cms/Test/Mftf/Test/AdminAddImageToCMSPageTinyMCE3Test.xml new file mode 100644 index 0000000000000..11bf03c1d5ee9 --- /dev/null +++ b/app/code/Magento/Cms/Test/Mftf/Test/AdminAddImageToCMSPageTinyMCE3Test.xml @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminAddImageToCMSPageTinyMCE3Test"> + <annotations> + <features value="Cms"/> + <stories value="Admin should be able to upload images with TinyMCE3 WYSIWYG"/> + <group value="Cms"/> + <title value="Verify that admin is able to upload image to a CMS Page with TinyMCE3 enabled"/> + <description value="Verify that admin is able to upload image to CMS Page with TinyMCE3 enabled"/> + <severity value="MAJOR"/> + <testCaseId value="MAGETWO-95725"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + <magentoCLI command="config:set cms/wysiwyg/enabled enabled" stepKey="enableWYSIWYG"/> + <!-- Choose TinyMCE3 as the default WYSIWYG editor--> + <magentoCLI command="config:set cms/wysiwyg/editor Magento_Tinymce3/tinymce3Adapter" stepKey="enableTinyMCE3"/> + </before> + <after> + <!-- Switch WYSIWYG editor to TinyMCE4--> + <comment userInput="Reset editor as TinyMCE4" stepKey="chooseTinyMCE4AsEditor"/> + <magentoCLI command="config:set cms/wysiwyg/editor mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter" stepKey="enableTinyMCE4"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <amOnPage url="{{CmsNewPagePage.url}}" stepKey="navigateToPage2"/> + <waitForPageLoad stepKey="wait5"/> + <fillField selector="{{CmsNewPagePageBasicFieldsSection.pageTitle}}" userInput="{{_defaultCmsPage.title}}" stepKey="fillFieldTitle2"/> + <click selector="{{CmsNewPagePageContentSection.header}}" stepKey="clickContentTab2" /> + <waitForElementVisible selector="{{TinyMCESection.TinyMCE3}}" stepKey="waitForTinyMCE3"/> + <seeElement selector="{{TinyMCESection.TinyMCE3}}" stepKey="seeTinyMCE3" /> + <wait time="3" stepKey="waiting"/> + <comment userInput="Click Insert image button" stepKey="clickImageButton"/> + <click selector="{{TinyMCESection.InsertImageBtnTinyMCE3}}" stepKey="clickInsertImage" /> + <waitForPageLoad stepKey="waitForiFrameToLoad" /> + <!-- Switch to the Edit/Insert Image iFrame --> + <comment userInput="Switching to iFrame" stepKey="insertImageiFrame"/> + <executeJS function="document.querySelector('.clearlooks2 iframe').setAttribute('name', 'insert-image');" stepKey="makeIFrameInteractable"/> + <switchToIFrame selector="insert-image" stepKey="switchToIFrame"/> + <click selector="{{MediaGallerySection.browseForImage}}" stepKey="clickBrowse"/> + <switchToIFrame stepKey="switchOutOfIFrame"/> + <waitForPageLoad stepKey="waitForPageToLoad" /> + <actionGroup ref="CreateImageFolder" stepKey="CreateImageFolder"> + <argument name="ImageFolder" value="ImageFolder"/> + </actionGroup> + <actionGroup ref="attachImage" stepKey="attachImage1"> + <argument name="Image" value="ImageUpload"/> + </actionGroup> + <actionGroup ref="saveImage" stepKey="insertImage"/> + <!-- Switching back to the Edit/Insert Image iFrame--> + <comment userInput="switching back to iFrame" stepKey="switchBackToIFrame"/> + <executeJS function="document.querySelector('.clearlooks2 iframe').setAttribute('name', 'insert-image');" stepKey="makeIFrameInteractable2"/> + <switchToIFrame selector="insert-image" stepKey="switchToIFrame2"/> + <waitForElementVisible selector="{{MediaGallerySection.insertBtn}}" stepKey="waitForInsertBtnOnIFrame" /> + <fillField selector="{{MediaGallerySection.ImageDescriptionTinyMCE3}}" userInput="{{ImageUpload.content}}" stepKey="fillImageDescription" /> + <click selector="{{MediaGallerySection.insertBtn}}" stepKey="clickInsertBtn" /> + <waitForPageLoad stepKey="wait3"/> + <click selector="{{CmsNewPagePageActionsSection.expandSplitButton}}" stepKey="expandButtonMenu"/> + <waitForElementVisible selector="{{CmsNewPagePageActionsSection.splitButtonMenu}}" stepKey="waitForSplitButtonMenuVisible"/> + <click selector="{{CmsNewPagePageActionsSection.savePage}}" stepKey="clickSavePage"/> + <see userInput="You saved the page." stepKey="seeSuccessMessage"/> + </test> +</tests> \ No newline at end of file diff --git a/app/code/Magento/Cms/etc/db_schema.xml b/app/code/Magento/Cms/etc/db_schema.xml index 3f97a94d54943..1e64c905badd8 100644 --- a/app/code/Magento/Cms/etc/db_schema.xml +++ b/app/code/Magento/Cms/etc/db_schema.xml @@ -19,10 +19,10 @@ comment="Block Modification Time"/> <column xsi:type="smallint" name="is_active" padding="6" unsigned="false" nullable="false" identity="false" default="1" comment="Is Block Active"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="block_id"/> </constraint> - <index name="CMS_BLOCK_TITLE_IDENTIFIER_CONTENT" indexType="fulltext"> + <index referenceId="CMS_BLOCK_TITLE_IDENTIFIER_CONTENT" indexType="fulltext"> <column name="title"/> <column name="identifier"/> <column name="content"/> @@ -32,15 +32,15 @@ <column xsi:type="smallint" name="block_id" padding="6" unsigned="false" nullable="false" identity="false"/> <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Store ID"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="block_id"/> <column name="store_id"/> </constraint> - <constraint xsi:type="foreign" name="CMS_BLOCK_STORE_BLOCK_ID_CMS_BLOCK_BLOCK_ID" table="cms_block_store" + <constraint xsi:type="foreign" referenceId="CMS_BLOCK_STORE_BLOCK_ID_CMS_BLOCK_BLOCK_ID" table="cms_block_store" column="block_id" referenceTable="cms_block" referenceColumn="block_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CMS_BLOCK_STORE_STORE_ID_STORE_STORE_ID" table="cms_block_store" + <constraint xsi:type="foreign" referenceId="CMS_BLOCK_STORE_STORE_ID_STORE_STORE_ID" table="cms_block_store" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <index name="CMS_BLOCK_STORE_STORE_ID" indexType="btree"> + <index referenceId="CMS_BLOCK_STORE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -71,13 +71,13 @@ <column xsi:type="date" name="custom_theme_from" comment="Page Custom Theme Active From Date"/> <column xsi:type="date" name="custom_theme_to" comment="Page Custom Theme Active To Date"/> <column xsi:type="varchar" name="meta_title" nullable="true" length="255" comment="Page Meta Title"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="page_id"/> </constraint> - <index name="CMS_PAGE_IDENTIFIER" indexType="btree"> + <index referenceId="CMS_PAGE_IDENTIFIER" indexType="btree"> <column name="identifier"/> </index> - <index name="CMS_PAGE_TITLE_META_KEYWORDS_META_DESCRIPTION_IDENTIFIER_CONTENT" indexType="fulltext"> + <index referenceId="CMS_PAGE_TITLE_META_KEYWORDS_META_DESCRIPTION_IDENTIFIER_CONTENT" indexType="fulltext"> <column name="title"/> <column name="meta_keywords"/> <column name="meta_description"/> @@ -90,15 +90,15 @@ comment="Entity ID"/> <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Store ID"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="page_id"/> <column name="store_id"/> </constraint> - <constraint xsi:type="foreign" name="CMS_PAGE_STORE_PAGE_ID_CMS_PAGE_PAGE_ID" table="cms_page_store" + <constraint xsi:type="foreign" referenceId="CMS_PAGE_STORE_PAGE_ID_CMS_PAGE_PAGE_ID" table="cms_page_store" column="page_id" referenceTable="cms_page" referenceColumn="page_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CMS_PAGE_STORE_STORE_ID_STORE_STORE_ID" table="cms_page_store" + <constraint xsi:type="foreign" referenceId="CMS_PAGE_STORE_STORE_ID_STORE_STORE_ID" table="cms_page_store" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <index name="CMS_PAGE_STORE_STORE_ID" indexType="btree"> + <index referenceId="CMS_PAGE_STORE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> diff --git a/app/code/Magento/Config/App/Config/Type/System.php b/app/code/Magento/Config/App/Config/Type/System.php index f5d109b198d5a..2b65c2791365a 100644 --- a/app/code/Magento/Config/App/Config/Type/System.php +++ b/app/code/Magento/Config/App/Config/Type/System.php @@ -101,6 +101,8 @@ public function __construct( } /** + * Get config value by path. + * * System configuration is separated by scopes (default, websites, stores). Configuration of a scope is inherited * from its parent scope (store inherits website). * @@ -121,7 +123,7 @@ public function __construct( public function get($path = '') { if ($path === '') { - $this->data = array_replace_recursive($this->loadAllData(), $this->data); + $this->data = array_replace_recursive($this->data, $this->loadAllData()); return $this->data; } @@ -142,7 +144,7 @@ private function getWithParts($path) if (count($pathParts) === 1 && $pathParts[0] !== ScopeInterface::SCOPE_DEFAULT) { if (!isset($this->data[$pathParts[0]])) { $data = $this->readData(); - $this->data = array_replace_recursive($data, $this->data); + $this->data = array_replace_recursive($this->data, $this->postProcessor->process($data)); } return $this->data[$pathParts[0]]; @@ -152,7 +154,12 @@ private function getWithParts($path) if ($scopeType === ScopeInterface::SCOPE_DEFAULT) { if (!isset($this->data[$scopeType])) { - $this->data = array_replace_recursive($this->loadDefaultScopeData($scopeType), $this->data); + $this->data = array_replace_recursive( + $this->data, + $scopeData = $this->loadDefaultScopeData($scopeType) + ); + $scopeData = $this->postProcessor->process($scopeData); + $this->data = array_replace_recursive($this->data, $scopeData); } return $this->getDataByPathParts($this->data[$scopeType], $pathParts); @@ -162,10 +169,9 @@ private function getWithParts($path) if (!isset($this->data[$scopeType][$scopeId])) { $scopeData = $this->loadScopeData($scopeType, $scopeId); - - if (!isset($this->data[$scopeType][$scopeId])) { - $this->data = array_replace_recursive($scopeData, $this->data); - } + $this->data = array_replace_recursive($this->data, $scopeData); + $scopeData = $this->postProcessor->process($scopeData); + $this->data = array_replace_recursive($this->data, $scopeData); } return isset($this->data[$scopeType][$scopeId]) @@ -186,9 +192,10 @@ private function loadAllData() $data = $this->readData(); } else { $data = $this->serializer->unserialize($cachedData); + $this->data = $data; } - return $data; + return $this->postProcessor->process($data); } /** @@ -243,6 +250,7 @@ private function loadScopeData($scopeType, $scopeId) /** * Cache configuration data. + * * Caches data per scope to avoid reading data for all scopes on every request * * @param array $data @@ -308,9 +316,6 @@ private function getDataByPathParts($data, $pathParts) private function readData(): array { $this->data = $this->reader->read(); - $this->data = $this->postProcessor->process( - $this->data - ); return $this->data; } diff --git a/app/code/Magento/Config/Model/Config.php b/app/code/Magento/Config/Model/Config.php index 535e0bba3885f..a9c400c46643d 100644 --- a/app/code/Magento/Config/Model/Config.php +++ b/app/code/Magento/Config/Model/Config.php @@ -14,7 +14,6 @@ * Backend config model * * Used to save configuration - * * @author Magento Core Team <core@magentocommerce.com> * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api diff --git a/app/code/Magento/Config/Test/Mftf/ActionGroup/ConfigWYSIWYGActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/ConfigWYSIWYGActionGroup.xml index 3c043b28801e2..307999ce48e4d 100644 --- a/app/code/Magento/Config/Test/Mftf/ActionGroup/ConfigWYSIWYGActionGroup.xml +++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/ConfigWYSIWYGActionGroup.xml @@ -19,6 +19,17 @@ <click selector="{{ContentManagementSection.WYSIWYGOptions}}" stepKey="collapseWYSIWYGOptions" /> <click selector="{{ContentManagementSection.Save}}" stepKey="saveConfig" /> </actionGroup> + <actionGroup name="SwitchToTinyMCE3"> + <comment userInput="Choose TinyMCE3 as the default editor" stepKey="chooseTinyMCE3AsEditor"/> + <conditionalClick stepKey="expandWYSIWYGOptions1" selector="{{ContentManagementSection.WYSIWYGOptions}}" dependentSelector="{{ContentManagementSection.CheckIfTabExpand}}" visible="true" /> + <waitForElementVisible selector="{{ContentManagementSection.SwitcherSystemValue}}" stepKey="waitForCheckbox2" /> + <uncheckOption selector="{{ContentManagementSection.SwitcherSystemValue}}" stepKey="uncheckUseSystemValue2"/> + <waitForElementVisible selector="{{ContentManagementSection.Switcher}}" stepKey="waitForSwitcherDropdown2" /> + <selectOption selector="{{ContentManagementSection.Switcher}}" userInput="TinyMCE 3" stepKey="switchToVersion3" /> + <click selector="{{ContentManagementSection.WYSIWYGOptions}}" stepKey="collapseWYSIWYGOptions" /> + <click selector="{{ContentManagementSection.Save}}" stepKey="saveConfig" /> + <see selector="{{AdminMessagesSection.success}}" userInput="You saved the configuration." stepKey="seeConfigurationSuccessMessage"/> + </actionGroup> <actionGroup name="DisabledWYSIWYG"> <amOnPage url="{{ConfigurationStoresPage.url}}" stepKey="navigateToConfigurationPage" /> <waitForPageLoad stepKey="wait3"/> diff --git a/app/code/Magento/Config/Test/Unit/App/Config/Type/SystemTest.php b/app/code/Magento/Config/Test/Unit/App/Config/Type/SystemTest.php deleted file mode 100644 index 40aa110382ede..0000000000000 --- a/app/code/Magento/Config/Test/Unit/App/Config/Type/SystemTest.php +++ /dev/null @@ -1,181 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Config\Test\Unit\App\Config\Type; - -use Magento\Config\App\Config\Type\System; -use Magento\Framework\App\Config\ConfigSourceInterface; -use Magento\Framework\App\Config\Spi\PostProcessorInterface; -use Magento\Framework\App\Config\Spi\PreProcessorInterface; -use Magento\Framework\Cache\FrontendInterface; -use Magento\Framework\Serialize\SerializerInterface; -use Magento\Store\Model\Config\Processor\Fallback; -use Magento\Config\App\Config\Type\System\Reader; - -/** - * Test how Class process source, cache them and retrieve value by path - * @package Magento\Config\Test\Unit\App\Config\Type - */ -class SystemTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var ConfigSourceInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $source; - - /** - * @var PostProcessorInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $postProcessor; - - /** - * @var PreProcessorInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $preProcessor; - - /** - * @var Fallback|\PHPUnit_Framework_MockObject_MockObject - */ - private $fallback; - - /** - * @var FrontendInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $cache; - - /** - * @var System - */ - private $configType; - - /** - * @var SerializerInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $serializer; - - /** - * @var Reader|\PHPUnit_Framework_MockObject_MockObject - */ - private $reader; - - public function setUp() - { - $this->source = $this->getMockBuilder(ConfigSourceInterface::class) - ->getMockForAbstractClass(); - $this->postProcessor = $this->getMockBuilder(PostProcessorInterface::class) - ->getMockForAbstractClass(); - $this->fallback = $this->getMockBuilder(Fallback::class) - ->disableOriginalConstructor() - ->getMock(); - $this->cache = $this->getMockBuilder(FrontendInterface::class) - ->getMockForAbstractClass(); - $this->preProcessor = $this->getMockBuilder(PreProcessorInterface::class) - ->getMockForAbstractClass(); - $this->serializer = $this->getMockBuilder(SerializerInterface::class) - ->getMock(); - $this->reader = $this->getMockBuilder(Reader::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->configType = new System( - $this->source, - $this->postProcessor, - $this->fallback, - $this->cache, - $this->serializer, - $this->preProcessor, - 1, - 'system', - $this->reader - ); - } - - public function testGetCachedWithLoadDefaultScopeData() - { - $path = 'default/dev/unsecure/url'; - $url = 'http://magento.test/'; - $data = [ - 'dev' => [ - 'unsecure' => [ - 'url' => $url - ] - ] - ]; - - $this->cache->expects($this->any()) - ->method('load') - ->willReturnOnConsecutiveCalls('1', serialize($data)); - $this->serializer->expects($this->once()) - ->method('unserialize') - ->willReturn($data); - $this->assertEquals($url, $this->configType->get($path)); - } - - public function testGetCachedWithLoadAllData() - { - $url = 'http://magento.test/'; - $data = [ - 'dev' => [ - 'unsecure' => [ - 'url' => $url - ] - ] - ]; - - $this->cache->expects($this->any()) - ->method('load') - ->willReturnOnConsecutiveCalls('1', serialize($data)); - $this->serializer->expects($this->once()) - ->method('unserialize') - ->willReturn($data); - $this->assertEquals($data, $this->configType->get('')); - } - - public function testGetNotCached() - { - $path = 'stores/default/dev/unsecure/url'; - $url = 'http://magento.test/'; - - $dataToCache = [ - 'unsecure' => [ - 'url' => $url - ] - ]; - $data = [ - 'default' => [], - 'websites' => [], - 'stores' => [ - 'default' => [ - 'dev' => [ - 'unsecure' => [ - 'url' => $url - ] - ] - ] - ] - ]; - $this->cache->expects($this->any()) - ->method('load') - ->willReturnOnConsecutiveCalls(false, false); - - $this->serializer->expects($this->atLeastOnce()) - ->method('serialize') - ->willReturn(serialize($dataToCache)); - $this->cache->expects($this->atLeastOnce()) - ->method('save') - ->willReturnSelf(); - $this->reader->expects($this->once()) - ->method('read') - ->willReturn($data); - $this->postProcessor->expects($this->once()) - ->method('process') - ->with($data) - ->willReturn($data); - - $this->assertEquals($url, $this->configType->get($path)); - $this->assertEquals($url, $this->configType->get($path)); - } -} diff --git a/app/code/Magento/Config/etc/db_schema.xml b/app/code/Magento/Config/etc/db_schema.xml index 3f55d582776ce..8aeac802fbd91 100644 --- a/app/code/Magento/Config/etc/db_schema.xml +++ b/app/code/Magento/Config/etc/db_schema.xml @@ -15,10 +15,10 @@ default="0" comment="Config Scope Id"/> <column xsi:type="varchar" name="path" nullable="false" length="255" default="general" comment="Config Path"/> <column xsi:type="text" name="value" nullable="true" comment="Config Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="config_id"/> </constraint> - <constraint xsi:type="unique" name="CORE_CONFIG_DATA_SCOPE_SCOPE_ID_PATH"> + <constraint xsi:type="unique" referenceId="CORE_CONFIG_DATA_SCOPE_SCOPE_ID_PATH"> <column name="scope"/> <column name="scope_id"/> <column name="path"/> diff --git a/app/code/Magento/ConfigurableProduct/etc/db_schema.xml b/app/code/Magento/ConfigurableProduct/etc/db_schema.xml index 7c6661a5f399a..d6917e8c1845a 100644 --- a/app/code/Magento/ConfigurableProduct/etc/db_schema.xml +++ b/app/code/Magento/ConfigurableProduct/etc/db_schema.xml @@ -17,13 +17,13 @@ default="0" comment="Attribute ID"/> <column xsi:type="smallint" name="position" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Position"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="product_super_attribute_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_SPR_ATTR_PRD_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_SPR_ATTR_PRD_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_super_attribute" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOG_PRODUCT_SUPER_ATTRIBUTE_PRODUCT_ID_ATTRIBUTE_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_SUPER_ATTRIBUTE_PRODUCT_ID_ATTRIBUTE_ID"> <column name="product_id"/> <column name="attribute_id"/> </constraint> @@ -39,21 +39,21 @@ <column xsi:type="smallint" name="use_default" padding="5" unsigned="true" nullable="true" identity="false" default="0" comment="Use Default Value"/> <column xsi:type="varchar" name="value" nullable="true" length="255" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="FK_309442281DF7784210ED82B2CC51E5D5" + <constraint xsi:type="foreign" referenceId="FK_309442281DF7784210ED82B2CC51E5D5" table="catalog_product_super_attribute_label" column="product_super_attribute_id" referenceTable="catalog_product_super_attribute" referenceColumn="product_super_attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CATALOG_PRODUCT_SUPER_ATTRIBUTE_LABEL_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="CATALOG_PRODUCT_SUPER_ATTRIBUTE_LABEL_STORE_ID_STORE_STORE_ID" table="catalog_product_super_attribute_label" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CAT_PRD_SPR_ATTR_LBL_PRD_SPR_ATTR_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="CAT_PRD_SPR_ATTR_LBL_PRD_SPR_ATTR_ID_STORE_ID"> <column name="product_super_attribute_id"/> <column name="store_id"/> </constraint> - <index name="CATALOG_PRODUCT_SUPER_ATTRIBUTE_LABEL_STORE_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_SUPER_ATTRIBUTE_LABEL_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -65,20 +65,20 @@ default="0" comment="Product ID"/> <column xsi:type="int" name="parent_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Parent ID"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="link_id"/> </constraint> - <constraint xsi:type="foreign" name="CAT_PRD_SPR_LNK_PRD_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_SPR_LNK_PRD_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_super_link" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_PRD_SPR_LNK_PARENT_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_SPR_LNK_PARENT_ID_CAT_PRD_ENTT_ENTT_ID" table="catalog_product_super_link" column="parent_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CATALOG_PRODUCT_SUPER_LINK_PRODUCT_ID_PARENT_ID"> + <constraint xsi:type="unique" referenceId="CATALOG_PRODUCT_SUPER_LINK_PRODUCT_ID_PARENT_ID"> <column name="product_id"/> <column name="parent_id"/> </constraint> - <index name="CATALOG_PRODUCT_SUPER_LINK_PARENT_ID" indexType="btree"> + <index referenceId="CATALOG_PRODUCT_SUPER_LINK_PARENT_ID" indexType="btree"> <column name="parent_id"/> </index> </table> diff --git a/app/code/Magento/Cron/etc/db_schema.xml b/app/code/Magento/Cron/etc/db_schema.xml index deff05d3eec96..b3061eefa6313 100644 --- a/app/code/Magento/Cron/etc/db_schema.xml +++ b/app/code/Magento/Cron/etc/db_schema.xml @@ -18,13 +18,13 @@ <column xsi:type="timestamp" name="scheduled_at" on_update="false" nullable="true" comment="Scheduled At"/> <column xsi:type="timestamp" name="executed_at" on_update="false" nullable="true" comment="Executed At"/> <column xsi:type="timestamp" name="finished_at" on_update="false" nullable="true" comment="Finished At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="schedule_id"/> </constraint> - <index name="CRON_SCHEDULE_JOB_CODE" indexType="btree"> + <index referenceId="CRON_SCHEDULE_JOB_CODE" indexType="btree"> <column name="job_code"/> </index> - <index name="CRON_SCHEDULE_SCHEDULED_AT_STATUS" indexType="btree"> + <index referenceId="CRON_SCHEDULE_SCHEDULED_AT_STATUS" indexType="btree"> <column name="scheduled_at"/> <column name="status"/> </index> diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/ResetPasswordButton.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/ResetPasswordButton.php index c38f182f275f2..aa93785116851 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/ResetPasswordButton.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/ResetPasswordButton.php @@ -25,10 +25,7 @@ public function getButtonData() $data = [ 'label' => __('Reset Password'), 'class' => 'reset reset-password', - 'data_attribute' => [ - 'url' => $this->getResetPasswordUrl() - ], - 'on_click' => '', + 'on_click' => sprintf("location.href = '%s';", $this->getResetPasswordUrl()), 'sort_order' => 60, ]; } diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/ResetPassword.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/ResetPassword.php index 6ef6ddd0e732b..3e6046b0d117f 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/ResetPassword.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/ResetPassword.php @@ -5,11 +5,16 @@ */ namespace Magento\Customer\Controller\Adminhtml\Index; -use Magento\Framework\App\Action\HttpPostActionInterface; +use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Exception\SecurityViolationException; -class ResetPassword extends \Magento\Customer\Controller\Adminhtml\Index implements HttpPostActionInterface +/** + * Reset password controller + * + * @package Magento\Customer\Controller\Adminhtml\Index + */ +class ResetPassword extends \Magento\Customer\Controller\Adminhtml\Index implements HttpGetActionInterface { /** * Reset password handler diff --git a/app/code/Magento/Customer/Model/GroupManagement.php b/app/code/Magento/Customer/Model/GroupManagement.php index eb5d90f2fd7ea..48cb5d55061c5 100644 --- a/app/code/Magento/Customer/Model/GroupManagement.php +++ b/app/code/Magento/Customer/Model/GroupManagement.php @@ -15,7 +15,6 @@ use Magento\Framework\Api\SortOrderBuilder; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\ObjectManager; -use Magento\Framework\Data\Collection; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Store\Model\StoreManagerInterface; @@ -170,7 +169,7 @@ public function getLoggedInGroups() ->create(); $groupNameSortOrder = $this->sortOrderBuilder ->setField('customer_group_code') - ->setDirection(Collection::SORT_ORDER_ASC) + ->setAscendingDirection() ->create(); $searchCriteria = $this->searchCriteriaBuilder ->addFilters($notLoggedInFilter) diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerMainActionsSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerMainActionsSection.xml index 37ea99d652fb9..3ff880c64e6d6 100644 --- a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerMainActionsSection.xml +++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerMainActionsSection.xml @@ -10,5 +10,6 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminCustomerMainActionsSection"> <element name="saveButton" type="button" selector="#save" timeout="30"/> + <element name="resetPassword" type="button" selector="#resetPassword" timeout="30"/> </section> </sections> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminResetCustomerPasswordTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminResetCustomerPasswordTest.xml new file mode 100644 index 0000000000000..0ca1d72a3ae1d --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminResetCustomerPasswordTest.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminResetCustomerPasswordTest"> + <annotations> + <features value="Customer"/> + <stories value="Admin should be able to reset an existing customer's password"/> + <description value="Admin should be able to reset customer password"/> + <severity value="CRITICAL"/> + <testCaseId value="MAGETWO-30875"/> + <group value="customer"/> + </annotations> + <before> + <createData entity="Simple_US_Customer" stepKey="customer"/> + <actionGroup ref="LoginAsAdmin" stepKey="login"/> + </before> + <after> + <deleteData createDataKey="customer" stepKey="deleteCustomer"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <!--Edit customer info--> + <actionGroup ref="OpenEditCustomerFromAdminActionGroup" stepKey="OpenEditCustomerFrom"> + <argument name="customer" value="$$customer$$"/> + </actionGroup> + <click selector="{{AdminCustomerMainActionsSection.resetPassword}}" stepKey="resetPassword"/> + <see userInput="The customer will receive an email with a link to reset password." stepKey="messageThatLinkToPasswordResetIsSent"/> + </test> +</tests> + + diff --git a/app/code/Magento/Customer/etc/db_schema.xml b/app/code/Magento/Customer/etc/db_schema.xml index 657083b58e1b1..7971627521740 100644 --- a/app/code/Magento/Customer/etc/db_schema.xml +++ b/app/code/Magento/Customer/etc/db_schema.xml @@ -50,28 +50,28 @@ <column xsi:type="timestamp" name="first_failure" on_update="false" nullable="true" comment="First Failure"/> <column xsi:type="timestamp" name="lock_expires" on_update="false" nullable="true" comment="Lock Expiration Date"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="CUSTOMER_ENTITY_STORE_ID_STORE_STORE_ID" table="customer_entity" + <constraint xsi:type="foreign" referenceId="CUSTOMER_ENTITY_STORE_ID_STORE_STORE_ID" table="customer_entity" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <constraint xsi:type="foreign" name="CUSTOMER_ENTITY_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" + <constraint xsi:type="foreign" referenceId="CUSTOMER_ENTITY_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" table="customer_entity" column="website_id" referenceTable="store_website" referenceColumn="website_id" onDelete="SET NULL"/> - <constraint xsi:type="unique" name="CUSTOMER_ENTITY_EMAIL_WEBSITE_ID"> + <constraint xsi:type="unique" referenceId="CUSTOMER_ENTITY_EMAIL_WEBSITE_ID"> <column name="email"/> <column name="website_id"/> </constraint> - <index name="CUSTOMER_ENTITY_STORE_ID" indexType="btree"> + <index referenceId="CUSTOMER_ENTITY_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="CUSTOMER_ENTITY_WEBSITE_ID" indexType="btree"> + <index referenceId="CUSTOMER_ENTITY_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> - <index name="CUSTOMER_ENTITY_FIRSTNAME" indexType="btree"> + <index referenceId="CUSTOMER_ENTITY_FIRSTNAME" indexType="btree"> <column name="firstname"/> </index> - <index name="CUSTOMER_ENTITY_LASTNAME" indexType="btree"> + <index referenceId="CUSTOMER_ENTITY_LASTNAME" indexType="btree"> <column name="lastname"/> </index> </table> @@ -111,13 +111,13 @@ comment="VAT number validation request ID"/> <column xsi:type="int" name="vat_request_success" padding="10" unsigned="true" nullable="true" identity="false" comment="VAT number validation request success"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="CUSTOMER_ADDRESS_ENTITY_PARENT_ID_CUSTOMER_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="CUSTOMER_ADDRESS_ENTITY_PARENT_ID_CUSTOMER_ENTITY_ENTITY_ID" table="customer_address_entity" column="parent_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="CUSTOMER_ADDRESS_ENTITY_PARENT_ID" indexType="btree"> + <index referenceId="CUSTOMER_ADDRESS_ENTITY_PARENT_ID" indexType="btree"> <column name="parent_id"/> </index> </table> @@ -130,23 +130,23 @@ <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Entity ID"/> <column xsi:type="datetime" name="value" on_update="false" nullable="true" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CSTR_ADDR_ENTT_DTIME_ATTR_ID_EAV_ATTR_ATTR_ID" + <constraint xsi:type="foreign" referenceId="CSTR_ADDR_ENTT_DTIME_ATTR_ID_EAV_ATTR_ATTR_ID" table="customer_address_entity_datetime" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CSTR_ADDR_ENTT_DTIME_ENTT_ID_CSTR_ADDR_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CSTR_ADDR_ENTT_DTIME_ENTT_ID_CSTR_ADDR_ENTT_ENTT_ID" table="customer_address_entity_datetime" column="entity_id" referenceTable="customer_address_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CUSTOMER_ADDRESS_ENTITY_DATETIME_ENTITY_ID_ATTRIBUTE_ID"> + <constraint xsi:type="unique" referenceId="CUSTOMER_ADDRESS_ENTITY_DATETIME_ENTITY_ID_ATTRIBUTE_ID"> <column name="entity_id"/> <column name="attribute_id"/> </constraint> - <index name="CUSTOMER_ADDRESS_ENTITY_DATETIME_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CUSTOMER_ADDRESS_ENTITY_DATETIME_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CUSTOMER_ADDRESS_ENTITY_DATETIME_ENTITY_ID_ATTRIBUTE_ID_VALUE" indexType="btree"> + <index referenceId="CUSTOMER_ADDRESS_ENTITY_DATETIME_ENTITY_ID_ATTRIBUTE_ID_VALUE" indexType="btree"> <column name="entity_id"/> <column name="attribute_id"/> <column name="value"/> @@ -162,23 +162,23 @@ default="0" comment="Entity ID"/> <column xsi:type="decimal" name="value" scale="4" precision="12" unsigned="false" nullable="false" default="0" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CSTR_ADDR_ENTT_DEC_ATTR_ID_EAV_ATTR_ATTR_ID" + <constraint xsi:type="foreign" referenceId="CSTR_ADDR_ENTT_DEC_ATTR_ID_EAV_ATTR_ATTR_ID" table="customer_address_entity_decimal" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CSTR_ADDR_ENTT_DEC_ENTT_ID_CSTR_ADDR_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CSTR_ADDR_ENTT_DEC_ENTT_ID_CSTR_ADDR_ENTT_ENTT_ID" table="customer_address_entity_decimal" column="entity_id" referenceTable="customer_address_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CUSTOMER_ADDRESS_ENTITY_DECIMAL_ENTITY_ID_ATTRIBUTE_ID"> + <constraint xsi:type="unique" referenceId="CUSTOMER_ADDRESS_ENTITY_DECIMAL_ENTITY_ID_ATTRIBUTE_ID"> <column name="entity_id"/> <column name="attribute_id"/> </constraint> - <index name="CUSTOMER_ADDRESS_ENTITY_DECIMAL_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CUSTOMER_ADDRESS_ENTITY_DECIMAL_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CUSTOMER_ADDRESS_ENTITY_DECIMAL_ENTITY_ID_ATTRIBUTE_ID_VALUE" indexType="btree"> + <index referenceId="CUSTOMER_ADDRESS_ENTITY_DECIMAL_ENTITY_ID_ATTRIBUTE_ID_VALUE" indexType="btree"> <column name="entity_id"/> <column name="attribute_id"/> <column name="value"/> @@ -193,23 +193,23 @@ default="0" comment="Entity ID"/> <column xsi:type="int" name="value" padding="11" unsigned="false" nullable="false" identity="false" default="0" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CSTR_ADDR_ENTT_INT_ATTR_ID_EAV_ATTR_ATTR_ID" + <constraint xsi:type="foreign" referenceId="CSTR_ADDR_ENTT_INT_ATTR_ID_EAV_ATTR_ATTR_ID" table="customer_address_entity_int" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CSTR_ADDR_ENTT_INT_ENTT_ID_CSTR_ADDR_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CSTR_ADDR_ENTT_INT_ENTT_ID_CSTR_ADDR_ENTT_ENTT_ID" table="customer_address_entity_int" column="entity_id" referenceTable="customer_address_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CUSTOMER_ADDRESS_ENTITY_INT_ENTITY_ID_ATTRIBUTE_ID"> + <constraint xsi:type="unique" referenceId="CUSTOMER_ADDRESS_ENTITY_INT_ENTITY_ID_ATTRIBUTE_ID"> <column name="entity_id"/> <column name="attribute_id"/> </constraint> - <index name="CUSTOMER_ADDRESS_ENTITY_INT_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CUSTOMER_ADDRESS_ENTITY_INT_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CUSTOMER_ADDRESS_ENTITY_INT_ENTITY_ID_ATTRIBUTE_ID_VALUE" indexType="btree"> + <index referenceId="CUSTOMER_ADDRESS_ENTITY_INT_ENTITY_ID_ATTRIBUTE_ID_VALUE" indexType="btree"> <column name="entity_id"/> <column name="attribute_id"/> <column name="value"/> @@ -224,20 +224,20 @@ <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Entity ID"/> <column xsi:type="text" name="value" nullable="false" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CSTR_ADDR_ENTT_TEXT_ATTR_ID_EAV_ATTR_ATTR_ID" + <constraint xsi:type="foreign" referenceId="CSTR_ADDR_ENTT_TEXT_ATTR_ID_EAV_ATTR_ATTR_ID" table="customer_address_entity_text" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CSTR_ADDR_ENTT_TEXT_ENTT_ID_CSTR_ADDR_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CSTR_ADDR_ENTT_TEXT_ENTT_ID_CSTR_ADDR_ENTT_ENTT_ID" table="customer_address_entity_text" column="entity_id" referenceTable="customer_address_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CUSTOMER_ADDRESS_ENTITY_TEXT_ENTITY_ID_ATTRIBUTE_ID"> + <constraint xsi:type="unique" referenceId="CUSTOMER_ADDRESS_ENTITY_TEXT_ENTITY_ID_ATTRIBUTE_ID"> <column name="entity_id"/> <column name="attribute_id"/> </constraint> - <index name="CUSTOMER_ADDRESS_ENTITY_TEXT_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CUSTOMER_ADDRESS_ENTITY_TEXT_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> </table> @@ -250,23 +250,23 @@ <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Entity ID"/> <column xsi:type="varchar" name="value" nullable="true" length="255" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CSTR_ADDR_ENTT_VCHR_ATTR_ID_EAV_ATTR_ATTR_ID" + <constraint xsi:type="foreign" referenceId="CSTR_ADDR_ENTT_VCHR_ATTR_ID_EAV_ATTR_ATTR_ID" table="customer_address_entity_varchar" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CSTR_ADDR_ENTT_VCHR_ENTT_ID_CSTR_ADDR_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CSTR_ADDR_ENTT_VCHR_ENTT_ID_CSTR_ADDR_ENTT_ENTT_ID" table="customer_address_entity_varchar" column="entity_id" referenceTable="customer_address_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CUSTOMER_ADDRESS_ENTITY_VARCHAR_ENTITY_ID_ATTRIBUTE_ID"> + <constraint xsi:type="unique" referenceId="CUSTOMER_ADDRESS_ENTITY_VARCHAR_ENTITY_ID_ATTRIBUTE_ID"> <column name="entity_id"/> <column name="attribute_id"/> </constraint> - <index name="CUSTOMER_ADDRESS_ENTITY_VARCHAR_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CUSTOMER_ADDRESS_ENTITY_VARCHAR_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CUSTOMER_ADDRESS_ENTITY_VARCHAR_ENTITY_ID_ATTRIBUTE_ID_VALUE" indexType="btree"> + <index referenceId="CUSTOMER_ADDRESS_ENTITY_VARCHAR_ENTITY_ID_ATTRIBUTE_ID_VALUE" indexType="btree"> <column name="entity_id"/> <column name="attribute_id"/> <column name="value"/> @@ -280,23 +280,23 @@ <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Entity ID"/> <column xsi:type="datetime" name="value" on_update="false" nullable="true" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CUSTOMER_ENTITY_DATETIME_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" + <constraint xsi:type="foreign" referenceId="CUSTOMER_ENTITY_DATETIME_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" table="customer_entity_datetime" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CUSTOMER_ENTITY_DATETIME_ENTITY_ID_CUSTOMER_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="CUSTOMER_ENTITY_DATETIME_ENTITY_ID_CUSTOMER_ENTITY_ENTITY_ID" table="customer_entity_datetime" column="entity_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CUSTOMER_ENTITY_DATETIME_ENTITY_ID_ATTRIBUTE_ID"> + <constraint xsi:type="unique" referenceId="CUSTOMER_ENTITY_DATETIME_ENTITY_ID_ATTRIBUTE_ID"> <column name="entity_id"/> <column name="attribute_id"/> </constraint> - <index name="CUSTOMER_ENTITY_DATETIME_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CUSTOMER_ENTITY_DATETIME_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CUSTOMER_ENTITY_DATETIME_ENTITY_ID_ATTRIBUTE_ID_VALUE" indexType="btree"> + <index referenceId="CUSTOMER_ENTITY_DATETIME_ENTITY_ID_ATTRIBUTE_ID_VALUE" indexType="btree"> <column name="entity_id"/> <column name="attribute_id"/> <column name="value"/> @@ -311,23 +311,23 @@ default="0" comment="Entity ID"/> <column xsi:type="decimal" name="value" scale="4" precision="12" unsigned="false" nullable="false" default="0" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CUSTOMER_ENTITY_DECIMAL_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" + <constraint xsi:type="foreign" referenceId="CUSTOMER_ENTITY_DECIMAL_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" table="customer_entity_decimal" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CUSTOMER_ENTITY_DECIMAL_ENTITY_ID_CUSTOMER_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="CUSTOMER_ENTITY_DECIMAL_ENTITY_ID_CUSTOMER_ENTITY_ENTITY_ID" table="customer_entity_decimal" column="entity_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CUSTOMER_ENTITY_DECIMAL_ENTITY_ID_ATTRIBUTE_ID"> + <constraint xsi:type="unique" referenceId="CUSTOMER_ENTITY_DECIMAL_ENTITY_ID_ATTRIBUTE_ID"> <column name="entity_id"/> <column name="attribute_id"/> </constraint> - <index name="CUSTOMER_ENTITY_DECIMAL_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CUSTOMER_ENTITY_DECIMAL_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CUSTOMER_ENTITY_DECIMAL_ENTITY_ID_ATTRIBUTE_ID_VALUE" indexType="btree"> + <index referenceId="CUSTOMER_ENTITY_DECIMAL_ENTITY_ID_ATTRIBUTE_ID_VALUE" indexType="btree"> <column name="entity_id"/> <column name="attribute_id"/> <column name="value"/> @@ -342,23 +342,23 @@ default="0" comment="Entity ID"/> <column xsi:type="int" name="value" padding="11" unsigned="false" nullable="false" identity="false" default="0" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CUSTOMER_ENTITY_INT_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" + <constraint xsi:type="foreign" referenceId="CUSTOMER_ENTITY_INT_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" table="customer_entity_int" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CUSTOMER_ENTITY_INT_ENTITY_ID_CUSTOMER_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="CUSTOMER_ENTITY_INT_ENTITY_ID_CUSTOMER_ENTITY_ENTITY_ID" table="customer_entity_int" column="entity_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CUSTOMER_ENTITY_INT_ENTITY_ID_ATTRIBUTE_ID"> + <constraint xsi:type="unique" referenceId="CUSTOMER_ENTITY_INT_ENTITY_ID_ATTRIBUTE_ID"> <column name="entity_id"/> <column name="attribute_id"/> </constraint> - <index name="CUSTOMER_ENTITY_INT_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CUSTOMER_ENTITY_INT_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CUSTOMER_ENTITY_INT_ENTITY_ID_ATTRIBUTE_ID_VALUE" indexType="btree"> + <index referenceId="CUSTOMER_ENTITY_INT_ENTITY_ID_ATTRIBUTE_ID_VALUE" indexType="btree"> <column name="entity_id"/> <column name="attribute_id"/> <column name="value"/> @@ -372,20 +372,20 @@ <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Entity ID"/> <column xsi:type="text" name="value" nullable="false" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CUSTOMER_ENTITY_TEXT_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" + <constraint xsi:type="foreign" referenceId="CUSTOMER_ENTITY_TEXT_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" table="customer_entity_text" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CUSTOMER_ENTITY_TEXT_ENTITY_ID_CUSTOMER_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="CUSTOMER_ENTITY_TEXT_ENTITY_ID_CUSTOMER_ENTITY_ENTITY_ID" table="customer_entity_text" column="entity_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CUSTOMER_ENTITY_TEXT_ENTITY_ID_ATTRIBUTE_ID"> + <constraint xsi:type="unique" referenceId="CUSTOMER_ENTITY_TEXT_ENTITY_ID_ATTRIBUTE_ID"> <column name="entity_id"/> <column name="attribute_id"/> </constraint> - <index name="CUSTOMER_ENTITY_TEXT_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CUSTOMER_ENTITY_TEXT_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> </table> @@ -397,23 +397,23 @@ <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Entity ID"/> <column xsi:type="varchar" name="value" nullable="true" length="255" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="CUSTOMER_ENTITY_VARCHAR_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" + <constraint xsi:type="foreign" referenceId="CUSTOMER_ENTITY_VARCHAR_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" table="customer_entity_varchar" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CUSTOMER_ENTITY_VARCHAR_ENTITY_ID_CUSTOMER_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="CUSTOMER_ENTITY_VARCHAR_ENTITY_ID_CUSTOMER_ENTITY_ENTITY_ID" table="customer_entity_varchar" column="entity_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CUSTOMER_ENTITY_VARCHAR_ENTITY_ID_ATTRIBUTE_ID"> + <constraint xsi:type="unique" referenceId="CUSTOMER_ENTITY_VARCHAR_ENTITY_ID_ATTRIBUTE_ID"> <column name="entity_id"/> <column name="attribute_id"/> </constraint> - <index name="CUSTOMER_ENTITY_VARCHAR_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CUSTOMER_ENTITY_VARCHAR_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="CUSTOMER_ENTITY_VARCHAR_ENTITY_ID_ATTRIBUTE_ID_VALUE" indexType="btree"> + <index referenceId="CUSTOMER_ENTITY_VARCHAR_ENTITY_ID_ATTRIBUTE_ID_VALUE" indexType="btree"> <column name="entity_id"/> <column name="attribute_id"/> <column name="value"/> @@ -425,7 +425,7 @@ comment="Customer Group Code"/> <column xsi:type="int" name="tax_class_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Tax Class Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="customer_group_id"/> </constraint> </table> @@ -451,10 +451,10 @@ identity="false" default="0" comment="Is Filterable in Grid"/> <column xsi:type="smallint" name="is_searchable_in_grid" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Is Searchable in Grid"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="attribute_id"/> </constraint> - <constraint xsi:type="foreign" name="CUSTOMER_EAV_ATTRIBUTE_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" + <constraint xsi:type="foreign" referenceId="CUSTOMER_EAV_ATTRIBUTE_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" table="customer_eav_attribute" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> </table> @@ -462,14 +462,14 @@ <column xsi:type="varchar" name="form_code" nullable="false" length="32" comment="Form Code"/> <column xsi:type="smallint" name="attribute_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Attribute Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="form_code"/> <column name="attribute_id"/> </constraint> - <constraint xsi:type="foreign" name="CUSTOMER_FORM_ATTRIBUTE_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" + <constraint xsi:type="foreign" referenceId="CUSTOMER_FORM_ATTRIBUTE_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" table="customer_form_attribute" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <index name="CUSTOMER_FORM_ATTRIBUTE_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="CUSTOMER_FORM_ATTRIBUTE_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> </table> @@ -486,17 +486,17 @@ <column xsi:type="text" name="default_value" nullable="true" comment="Default Value"/> <column xsi:type="smallint" name="multiline_count" padding="5" unsigned="true" nullable="true" identity="false" comment="Multiline Count"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="attribute_id"/> <column name="website_id"/> </constraint> - <constraint xsi:type="foreign" name="CSTR_EAV_ATTR_WS_ATTR_ID_EAV_ATTR_ATTR_ID" + <constraint xsi:type="foreign" referenceId="CSTR_EAV_ATTR_WS_ATTR_ID_EAV_ATTR_ATTR_ID" table="customer_eav_attribute_website" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CSTR_EAV_ATTR_WS_WS_ID_STORE_WS_WS_ID" + <constraint xsi:type="foreign" referenceId="CSTR_EAV_ATTR_WS_WS_ID_STORE_WS_WS_ID" table="customer_eav_attribute_website" column="website_id" referenceTable="store_website" referenceColumn="website_id" onDelete="CASCADE"/> - <index name="CUSTOMER_EAV_ATTRIBUTE_WEBSITE_WEBSITE_ID" indexType="btree"> + <index referenceId="CUSTOMER_EAV_ATTRIBUTE_WEBSITE_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> </table> @@ -508,13 +508,13 @@ <column xsi:type="varchar" name="session_id" nullable="true" length="64" comment="Session ID"/> <column xsi:type="timestamp" name="last_visit_at" on_update="true" nullable="true" default="CURRENT_TIMESTAMP" comment="Last Visit Time"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="visitor_id"/> </constraint> - <index name="CUSTOMER_VISITOR_CUSTOMER_ID" indexType="btree"> + <index referenceId="CUSTOMER_VISITOR_CUSTOMER_ID" indexType="btree"> <column name="customer_id"/> </index> - <index name="CUSTOMER_VISITOR_LAST_VISIT_AT" indexType="btree"> + <index referenceId="CUSTOMER_VISITOR_LAST_VISIT_AT" indexType="btree"> <column name="last_visit_at"/> </index> </table> @@ -526,10 +526,10 @@ <column xsi:type="timestamp" name="last_login_at" on_update="false" nullable="true" comment="Last Login Time"/> <column xsi:type="timestamp" name="last_logout_at" on_update="false" nullable="true" comment="Last Logout Time"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="log_id"/> </constraint> - <constraint xsi:type="unique" name="CUSTOMER_LOG_CUSTOMER_ID"> + <constraint xsi:type="unique" referenceId="CUSTOMER_LOG_CUSTOMER_ID"> <column name="customer_id"/> </constraint> </table> diff --git a/app/code/Magento/Customer/view/adminhtml/web/edit/post-wrapper.js b/app/code/Magento/Customer/view/adminhtml/web/edit/post-wrapper.js index 27fa5eb783bba..76b060015c5ff 100644 --- a/app/code/Magento/Customer/view/adminhtml/web/edit/post-wrapper.js +++ b/app/code/Magento/Customer/view/adminhtml/web/edit/post-wrapper.js @@ -44,12 +44,4 @@ define([ return false; }); - - $('#resetPassword').click(function () { - var url = $('#resetPassword').data('url'); - - getForm(url).appendTo('body').submit(); - - return false; - }); }); diff --git a/app/code/Magento/Deploy/Console/DeployStaticOptions.php b/app/code/Magento/Deploy/Console/DeployStaticOptions.php index 9a73dd5d65fc7..89cb3e4b30345 100644 --- a/app/code/Magento/Deploy/Console/DeployStaticOptions.php +++ b/app/code/Magento/Deploy/Console/DeployStaticOptions.php @@ -240,7 +240,7 @@ private function getBasicOptions() new InputArgument( self::LANGUAGES_ARGUMENT, InputArgument::IS_ARRAY, - 'Space-separated list of ISO-636 language codes for which to output static view files.' + 'Space-separated list of ISO-639 language codes for which to output static view files.' ), ]; } diff --git a/app/code/Magento/Developer/Console/Command/TablesWhitelistGenerateCommand.php b/app/code/Magento/Developer/Console/Command/TablesWhitelistGenerateCommand.php index b30edc0c7976f..2155efa017093 100644 --- a/app/code/Magento/Developer/Console/Command/TablesWhitelistGenerateCommand.php +++ b/app/code/Magento/Developer/Console/Command/TablesWhitelistGenerateCommand.php @@ -7,12 +7,9 @@ namespace Magento\Developer\Console\Command; -use Magento\Framework\Component\ComponentRegistrar; +use Magento\Developer\Model\Setup\Declaration\Schema\WhitelistGenerator; 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\Framework\Setup\Declaration\Schema\Declaration\ReaderComposite; +use Magento\Framework\Exception\ConfigurationMismatchException; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -31,41 +28,20 @@ class TablesWhitelistGenerateCommand extends Command const MODULE_NAME_KEY = 'module-name'; /** - * @var ComponentRegistrar + * @var WhitelistGenerator */ - private $componentRegistrar; + private $whitelistGenerator; /** - * @var ReaderComposite - */ - private $readerComposite; - - /** - * @var JsonPersistor - */ - private $jsonPersistor; - - /** - * @var array - */ - private $primaryDbSchema; - - /** - * @param ComponentRegistrar $componentRegistrar - * @param ReaderComposite $readerComposite - * @param JsonPersistor $jsonPersistor + * @param WhitelistGenerator $whitelistGenerator * @param string|null $name */ public function __construct( - ComponentRegistrar $componentRegistrar, - ReaderComposite $readerComposite, - JsonPersistor $jsonPersistor, + WhitelistGenerator $whitelistGenerator, $name = null ) { + $this->whitelistGenerator = $whitelistGenerator; parent::__construct($name); - $this->componentRegistrar = $componentRegistrar; - $this->readerComposite = $readerComposite; - $this->jsonPersistor = $jsonPersistor; } /** @@ -93,38 +69,6 @@ protected function configure() parent::configure(); } - /** - * Update whitelist tables for all modules that are enabled on the moment. - * - * @param string $moduleName - * @return void - */ - private function persistModule($moduleName) - { - $content = []; - $modulePath = $this->componentRegistrar->getPath('module', $moduleName); - $whiteListFileName = $modulePath - . DIRECTORY_SEPARATOR - . Dir::MODULE_ETC_DIR - . DIRECTORY_SEPARATOR - . 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); - } - - $newContent = $this->filterPrimaryTables($this->readerComposite->read($moduleName)); - - //Do merge between what we have before, and what we have now and filter to only certain attributes. - $content = array_replace_recursive( - $content, - $this->filterAttributeNames($newContent) - ); - if (!empty($content)) { - $this->jsonPersistor->persist($content, $whiteListFileName); - } - } - /** * @inheritdoc */ @@ -133,77 +77,14 @@ protected function execute(InputInterface $input, OutputInterface $output) : int $moduleName = $input->getOption(self::MODULE_NAME_KEY); try { - if ($moduleName === FileResolverByModule::ALL_MODULES) { - foreach (array_keys($this->componentRegistrar->getPaths('module')) as $moduleName) { - $this->persistModule($moduleName); - } - } else { - $this->persistModule($moduleName); - } + $this->whitelistGenerator->generate($moduleName); + } catch (ConfigurationMismatchException $e) { + $output->writeln($e->getMessage()); + return \Magento\Framework\Console\Cli::RETURN_FAILURE; } catch (\Exception $e) { return \Magento\Framework\Console\Cli::RETURN_FAILURE; } - //If script comes here, that we sucessfully write whitelist configuration return \Magento\Framework\Console\Cli::RETURN_SUCCESS; } - - /** - * Filter attribute names - * - * As for whitelist we do not need any specific attributes like nullable or indexType, we need to choose only names. - * - * @param array $content - * @return array - */ - private function filterAttributeNames(array $content) : array - { - $names = []; - $types = ['column', 'index', 'constraint']; - - foreach ($content['table'] as $tableName => $tableContent) { - foreach ($types as $type) { - if (isset($tableContent[$type])) { - //Add elements to whitelist - foreach (array_keys($tableContent[$type]) as $elementName) { - //Depends on flag column will be whitelisted or not - $names[$tableName][$type][$elementName] = true; - } - } - } - } - - return $names; - } - - /** - * Load db_schema content from the primary scope app/etc/db_schema.xml. - * - * @return array - */ - private function getPrimaryDbSchema() - { - if (!$this->primaryDbSchema) { - $this->primaryDbSchema = $this->readerComposite->read('primary'); - } - return $this->primaryDbSchema; - } - - /** - * Filter tables from module db_schema.xml as they should not contain the primary system tables. - * - * @param array $moduleDbSchema - * @return array - * @SuppressWarnings(PHPMD.UnusedLocalVariable) - */ - private function filterPrimaryTables(array $moduleDbSchema) - { - $primaryDbSchema = $this->getPrimaryDbSchema(); - if (isset($moduleDbSchema['table']) && isset($primaryDbSchema['table'])) { - foreach ($primaryDbSchema['table'] as $tableNameKey => $tableContents) { - unset($moduleDbSchema['table'][$tableNameKey]); - } - } - return $moduleDbSchema; - } } diff --git a/app/code/Magento/Developer/Model/Setup/Declaration/Schema/WhitelistGenerator.php b/app/code/Magento/Developer/Model/Setup/Declaration/Schema/WhitelistGenerator.php new file mode 100644 index 0000000000000..5cdcc6eb99af5 --- /dev/null +++ b/app/code/Magento/Developer/Model/Setup/Declaration/Schema/WhitelistGenerator.php @@ -0,0 +1,258 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Developer\Model\Setup\Declaration\Schema; + +use Magento\Framework\App\DeploymentConfig; +use Magento\Framework\Component\ComponentRegistrar; +use Magento\Framework\Config\ConfigOptionsListConstants; +use Magento\Framework\Config\FileResolverByModule; +use Magento\Framework\Exception\ConfigurationMismatchException; +use Magento\Framework\Module\Dir; +use Magento\Framework\Setup\Declaration\Schema\Declaration\ReaderComposite; +use Magento\Framework\Setup\Declaration\Schema\Declaration\TableElement\ElementNameResolver; +use Magento\Framework\Setup\Declaration\Schema\Diff\Diff; +use Magento\Framework\Setup\Declaration\Schema\Dto\Schema; +use Magento\Framework\Setup\Declaration\Schema\SchemaConfig; +use Magento\Framework\Setup\JsonPersistor; + +/** + * Generate whitelist declaration declarative schema. + */ +class WhitelistGenerator +{ + /** + * @var SchemaConfig + */ + private $schemaConfig; + + /** + * @var ComponentRegistrar + */ + private $componentRegistrar; + + /** + * @var JsonPersistor + */ + private $jsonPersistor; + + /** + * @var ReaderComposite + */ + private $readerComposite; + + /** + * @var array + */ + private $primaryDbSchema; + + /** + * @var ElementNameResolver + */ + private $elementNameResolver; + + /** + * @var DeploymentConfig + */ + private $deploymentConfig; + + /** + * @param ComponentRegistrar $componentRegistrar + * @param JsonPersistor $jsonPersistor + * @param SchemaConfig $schemaConfig + * @param ReaderComposite $readerComposite + * @param ElementNameResolver $elementNameResolver + * @param DeploymentConfig $deploymentConfig + */ + public function __construct( + ComponentRegistrar $componentRegistrar, + JsonPersistor $jsonPersistor, + SchemaConfig $schemaConfig, + ReaderComposite $readerComposite, + ElementNameResolver $elementNameResolver, + DeploymentConfig $deploymentConfig + ) { + $this->componentRegistrar = $componentRegistrar; + $this->jsonPersistor = $jsonPersistor; + $this->schemaConfig = $schemaConfig; + $this->readerComposite = $readerComposite; + $this->elementNameResolver = $elementNameResolver; + $this->deploymentConfig = $deploymentConfig; + } + + /** + * Generate whitelist declaration. + * + * @param string $moduleName + * @throws ConfigurationMismatchException + */ + public function generate(string $moduleName) + { + $this->checkMagentoInstallation(); + $schema = $this->schemaConfig->getDeclarationConfig(); + if ($moduleName === FileResolverByModule::ALL_MODULES) { + foreach (array_keys($this->componentRegistrar->getPaths('module')) as $moduleName) { + $this->persistModule($schema, $moduleName); + } + } else { + $this->persistModule($schema, $moduleName); + } + } + + /** + * Check the configuration of the installed instance. + * + * @throws ConfigurationMismatchException + */ + private function checkMagentoInstallation() + { + $tablePrefixLength = $this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_PREFIX); + if ($tablePrefixLength) { + throw new ConfigurationMismatchException( + __('Magento was installed with a table prefix. Please re-install without prefix.') + ); + } + } + + /** + * Update whitelist tables for all modules that are enabled on the moment. + * + * @param Schema $schema + * @param string $moduleName + * @return void + */ + private function persistModule(Schema $schema, string $moduleName) + { + $content = []; + $modulePath = $this->componentRegistrar->getPath('module', $moduleName); + $whiteListFileName = $modulePath + . DIRECTORY_SEPARATOR + . Dir::MODULE_ETC_DIR + . DIRECTORY_SEPARATOR + . 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); + } + + $data = $this->filterPrimaryTables($this->readerComposite->read($moduleName)); + if (!empty($data['table'])) { + foreach ($data['table'] as $tableName => $tabledata) { + //Do merge between what we have before, and what we have now and filter to only certain attributes. + $content = array_replace_recursive( + $content, + [$tableName => $this->getElementsWithFixedName($tabledata)], + [$tableName => $this->getElementsWithAutogeneratedName( + $schema, + $tableName, + $tabledata + )] + ); + } + if (!empty($content)) { + $this->jsonPersistor->persist($content, $whiteListFileName); + } + } + } + + /** + * Provide immutable names of the table elements. + * + * @param array $tableData + * @return array + */ + private function getElementsWithFixedName(array $tableData): array + { + $declaredStructure = []; + if (!empty($tableData['column'])) { + $declaredColumns = array_keys($tableData['column']); + $declaredStructure['column'] = array_fill_keys($declaredColumns, true); + } + return $declaredStructure; + } + + /** + * Provide autogenerated names of the table elements. + * + * @param Schema $schema + * @param string $tableName + * @param array $tableData + * @return array + */ + private function getElementsWithAutogeneratedName(Schema $schema, string $tableName, array $tableData) : array + { + $declaredStructure = []; + $table = $schema->getTableByName($tableName); + + $elementType = 'index'; + if (!empty($tableData[$elementType])) { + foreach ($tableData[$elementType] as $tableElementData) { + $indexName = $this->elementNameResolver->getFullIndexName( + $table, + $tableElementData['column'], + $tableElementData['indexType'] ?? null + ); + $declaredStructure[$elementType][$indexName] = true; + } + } + + $elementType = 'constraint'; + if (!empty($tableData[$elementType])) { + foreach ($tableData[$elementType] as $tableElementData) { + if ($tableElementData['type'] === 'foreign') { + $referenceTable = $schema->getTableByName($tableElementData['referenceTable']); + $constraintName = $this->elementNameResolver->getFullFKName( + $table, + $table->getColumnByName($tableElementData['column']), + $referenceTable, + $referenceTable->getColumnByName($tableElementData['referenceColumn']) + ); + } else { + $constraintName = $this->elementNameResolver->getFullIndexName( + $table, + $tableElementData['column'], + $tableElementData['type'] + ); + } + $declaredStructure[$elementType][$constraintName] = true; + } + } + + return $declaredStructure; + } + + /** + * Load db_schema content from the primary scope app/etc/db_schema.xml. + * + * @return array + */ + private function getPrimaryDbSchema(): array + { + if (!$this->primaryDbSchema) { + $this->primaryDbSchema = $this->readerComposite->read('primary'); + } + return $this->primaryDbSchema; + } + + /** + * Filter tables from module database schema as they should not contain the primary system tables. + * + * @param array $moduleDbSchema + * @return array + */ + private function filterPrimaryTables(array $moduleDbSchema): array + { + $primaryDbSchema = $this->getPrimaryDbSchema(); + if (isset($moduleDbSchema['table']) && isset($primaryDbSchema['table'])) { + foreach (array_keys($primaryDbSchema['table']) as $tableNameKey) { + unset($moduleDbSchema['table'][$tableNameKey]); + } + } + return $moduleDbSchema; + } +} diff --git a/app/code/Magento/Developer/Test/Unit/Console/Command/TablesWhitelistGenerateCommandTest.php b/app/code/Magento/Developer/Test/Unit/Console/Command/TablesWhitelistGenerateCommandTest.php deleted file mode 100644 index 5bfc5686b05fb..0000000000000 --- a/app/code/Magento/Developer/Test/Unit/Console/Command/TablesWhitelistGenerateCommandTest.php +++ /dev/null @@ -1,425 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Developer\Test\Unit\Console\Command; - -use Magento\Developer\Console\Command\TablesWhitelistGenerateCommand; -use Magento\Framework\Component\ComponentRegistrar; -use Magento\Framework\Setup\JsonPersistor; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -use Magento\Framework\Setup\Declaration\Schema\Declaration\ReaderComposite; -use Symfony\Component\Console\Tester\CommandTester; - -/** - * Unit test for whitelist generation command. - * - * @package Magento\Developer\Test\Unit\Console\Command - */ -class TablesWhitelistGenerateCommandTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var TablesWhitelistGenerateCommand - */ - private $model; - - /** - * @var ObjectManagerHelper - */ - private $objectManagerHelper; - - /** - * @var ComponentRegistrar|\PHPUnit_Framework_MockObject_MockObject - */ - private $componentRegistrarMock; - - /** - * @var ReaderComposite|\PHPUnit_Framework_MockObject_MockObject - */ - private $readerCompositeMock; - - /** - * @var JsonPersistor|\PHPUnit_Framework_MockObject_MockObject - */ - private $jsonPersistorMock; - - /** - * {@inheritdoc} - */ - protected function setUp() - { - $this->componentRegistrarMock = $this->getMockBuilder(ComponentRegistrar::class) - ->disableOriginalConstructor() - ->getMock(); - $this->readerCompositeMock = $this->getMockBuilder(ReaderComposite::class) - ->disableOriginalConstructor() - ->getMock(); - $this->jsonPersistorMock = $this->getMockBuilder(JsonPersistor::class) - ->getMock(); - $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->model = $this->objectManagerHelper->getObject( - TablesWhitelistGenerateCommand::class, - [ - 'componentRegistrar' => $this->componentRegistrarMock, - 'readerComposite' => $this->readerCompositeMock, - 'jsonPersistor' => $this->jsonPersistorMock - ] - ); - } - - /** - * @return array - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function whitelistTableProvider() - { - return [ - [ - 'moduleName' => 'SomeModule', - 'whitelist' => [ - 'primary' => [ - 'table' => - [ - 'patch_list' => - [ - 'column' => - [ - 'patch_id' => - [ - 'type' => 'int', - 'name' => 'patch_id', - 'identity' => 'true', - 'comment' => 'Patch Auto Increment', - ], - 'patch_name' => - [ - 'type' => 'varchar', - 'name' => 'patch_name', - 'length' => '1024', - 'nullable' => 'false', - 'comment' => 'Patch Class Name', - ], - ], - 'constraint' => - [ - 'PRIMARY' => - [ - 'column' => - [ - 'patch_id' => 'patch_id', - ], - 'type' => 'primary', - 'name' => 'PRIMARY', - ], - ], - 'name' => 'patch_list', - 'resource' => 'default', - 'comment' => 'List of data/schema patches', - ], - ], - ], - 'SomeModule' => [ - 'table' => [ - 'first_table' => [ - 'disabled' => false, - 'name' => 'first_table', - 'resource' => 'default', - 'engine' => 'innodb', - 'column' => [ - 'first_column' => [ - 'name' => 'first_column', - 'xsi:type' => 'integer', - 'nullable' => 1, - 'unsigned' => '0', - ], - 'second_column' => [ - 'name' => 'second_column', - 'xsi:type' => 'date', - 'nullable' => 0, - ] - ], - 'index' => [ - 'TEST_INDEX' => [ - 'name' => 'TEST_INDEX', - 'indexType' => 'btree', - 'columns' => [ - 'first_column' - ] - ] - ], - 'constraint' => [ - 'foreign' => [ - 'some_foreign_constraint' => [ - 'referenceTable' => 'table', - 'referenceColumn' => 'column', - 'table' => 'first_table', - 'column' => 'first_column' - ] - ], - 'primary' => [ - 'PRIMARY' => [ - 'xsi:type' => 'primary', - 'name' => 'PRIMARY', - 'columns' => [ - 'second_column' - ] - ] - ] - ] - ] - ] - ], - ], - 'expected' => [ - 'SomeModule' => [ - 'first_table' => [ - 'column' => [ - 'first_column' => true, - 'second_column' => true, - ], - 'index' => [ - 'TEST_INDEX' => true, - ], - 'constraint' => [ - 'foreign' => true, - 'primary' => true, - ] - ] - ] - ] - ], - [ - 'moduleName' => false, - 'whitelist' => [ - 'primary' => [ - 'table' => - [ - 'patch_list' => - [ - 'column' => - [ - 'patch_id' => - [ - 'type' => 'int', - 'name' => 'patch_id', - 'identity' => 'true', - 'comment' => 'Patch Auto Increment', - ], - 'patch_name' => - [ - 'type' => 'varchar', - 'name' => 'patch_name', - 'length' => '1024', - 'nullable' => 'false', - 'comment' => 'Patch Class Name', - ], - ], - 'constraint' => - [ - 'PRIMARY' => - [ - 'column' => - [ - 'patch_id' => 'patch_id', - ], - 'type' => 'primary', - 'name' => 'PRIMARY', - ], - ], - 'name' => 'patch_list', - 'resource' => 'default', - 'comment' => 'List of data/schema patches', - ], - ], - ], - 'SomeModule' => [ - 'table' => [ - 'first_table' => [ - 'disabled' => false, - 'name' => 'first_table', - 'resource' => 'default', - 'engine' => 'innodb', - 'column' => [ - 'first_column' => [ - 'name' => 'first_column', - 'xsi:type' => 'integer', - 'nullable' => 1, - 'unsigned' => '0', - ], - 'second_column' => [ - 'name' => 'second_column', - 'xsi:type' => 'date', - 'nullable' => 0, - ] - ], - 'index' => [ - 'TEST_INDEX' => [ - 'name' => 'TEST_INDEX', - 'indexType' => 'btree', - 'columns' => [ - 'first_column' - ] - ] - ], - 'constraint' => [ - 'foreign' => [ - 'some_foreign_constraint' => [ - 'referenceTable' => 'table', - 'referenceColumn' => 'column', - 'table' => 'first_table', - 'column' => 'first_column' - ] - ], - 'primary' => [ - 'PRIMARY' => [ - 'xsi:type' => 'primary', - 'name' => 'PRIMARY', - 'columns' => [ - 'second_column' - ] - ] - ] - ] - ] - ] - ], - 'Module2' => [ - 'table' => [ - 'second_table' => [ - 'disabled' => false, - 'name' => 'second_table', - 'resource' => 'default', - 'engine' => 'innodb', - 'column' => [ - 'first_column' => [ - 'name' => 'first_column', - 'xsi:type' => 'integer', - 'nullable' => 1, - 'unsigned' => '0', - ], - 'second_column' => [ - 'name' => 'second_column', - 'xsi:type' => 'date', - 'nullable' => 0, - ] - ], - 'index' => [ - 'TEST_INDEX' => [ - 'name' => 'TEST_INDEX', - 'indexType' => 'btree', - 'columns' => [ - 'first_column' - ] - ] - ], - 'constraint' => [ - 'foreign' => [ - 'some_foreign_constraint' => [ - 'referenceTable' => 'table', - 'referenceColumn' => 'column', - 'table' => 'second_table', - 'column' => 'first_column' - ] - ], - 'primary' => [ - 'PRIMARY' => [ - 'xsi:type' => 'primary', - 'name' => 'PRIMARY', - 'columns' => [ - 'second_column' - ] - ] - ] - ] - ] - ] - ] - ], - 'expected' => [ - 'SomeModule' => [ - 'first_table' => [ - 'column' => [ - 'first_column' => true, - 'second_column' => true, - ], - 'index' => [ - 'TEST_INDEX' => true, - ], - 'constraint' => [ - 'foreign' => true, - 'primary' => true, - ] - ] - ], - 'Module2' => [ - 'second_table' => [ - 'column' => [ - 'first_column' => true, - 'second_column' => true, - ], - 'index' => [ - 'TEST_INDEX' => true, - ], - 'constraint' => [ - 'foreign' => true, - 'primary' => true, - ] - ] - ] - ] - ] - ]; - } - - /** - * @dataProvider whitelistTableProvider - * @param string $moduleName - * @param array $whiteListTables - * @param array $expected - */ - public function testCommand($moduleName, array $whiteListTables, array $expected) - { - $commandTester = new CommandTester($this->model); - $options = !$moduleName ? [] : ['--module-name' => $moduleName]; - - if (!$moduleName) { - $this->componentRegistrarMock->expects(self::once()) - ->method('getPaths') - ->willReturn(['SomeModule' => 1, 'Module2' => 2]); - $this->readerCompositeMock->expects(self::exactly(3)) - ->method('read') - ->withConsecutive(['SomeModule'], ['primary'], ['Module2']) - ->willReturnOnConsecutiveCalls( - $whiteListTables['SomeModule'], - $whiteListTables['primary'], - $whiteListTables['Module2'] - ); - $this->jsonPersistorMock->expects(self::exactly(2)) - ->method('persist') - ->withConsecutive( - [ - $expected['SomeModule'], - '/etc/db_schema_whitelist.json' - ], - [ - $expected['Module2'], - '/etc/db_schema_whitelist.json' - ] - ); - } else { - $this->readerCompositeMock->expects(self::exactly(2)) - ->method('read') - ->withConsecutive([$moduleName], ['primary']) - ->willReturnOnConsecutiveCalls($whiteListTables['SomeModule'], $whiteListTables['primary']); - $this->jsonPersistorMock->expects(self::once()) - ->method('persist') - ->with( - $expected['SomeModule'], - '/etc/db_schema_whitelist.json' - ); - } - $commandTester->execute($options); - } -} diff --git a/app/code/Magento/Directory/etc/db_schema.xml b/app/code/Magento/Directory/etc/db_schema.xml index 72fd929b98a07..c11e0ee525e37 100644 --- a/app/code/Magento/Directory/etc/db_schema.xml +++ b/app/code/Magento/Directory/etc/db_schema.xml @@ -11,7 +11,7 @@ <column xsi:type="varchar" name="country_id" nullable="false" length="2" comment="Country Id in ISO-2"/> <column xsi:type="varchar" name="iso2_code" nullable="true" length="2" comment="Country ISO-2 format"/> <column xsi:type="varchar" name="iso3_code" nullable="true" length="3" comment="Country ISO-3"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="country_id"/> </constraint> </table> @@ -21,10 +21,10 @@ <column xsi:type="varchar" name="country_id" nullable="true" length="2" comment="Country Id in ISO-2"/> <column xsi:type="varchar" name="type" nullable="true" length="30" comment="Country Format Type"/> <column xsi:type="text" name="format" nullable="false" comment="Country Format"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="country_format_id"/> </constraint> - <constraint xsi:type="unique" name="DIRECTORY_COUNTRY_FORMAT_COUNTRY_ID_TYPE"> + <constraint xsi:type="unique" referenceId="DIRECTORY_COUNTRY_FORMAT_COUNTRY_ID_TYPE"> <column name="country_id"/> <column name="type"/> </constraint> @@ -36,10 +36,10 @@ comment="Country Id in ISO-2"/> <column xsi:type="varchar" name="code" nullable="true" length="32" comment="Region code"/> <column xsi:type="varchar" name="default_name" nullable="true" length="255" comment="Region Name"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="region_id"/> </constraint> - <index name="DIRECTORY_COUNTRY_REGION_COUNTRY_ID" indexType="btree"> + <index referenceId="DIRECTORY_COUNTRY_REGION_COUNTRY_ID" indexType="btree"> <column name="country_id"/> </index> </table> @@ -49,14 +49,14 @@ <column xsi:type="int" name="region_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Region Id"/> <column xsi:type="varchar" name="name" nullable="true" length="255" comment="Region Name"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="locale"/> <column name="region_id"/> </constraint> - <constraint xsi:type="foreign" name="DIR_COUNTRY_REGION_NAME_REGION_ID_DIR_COUNTRY_REGION_REGION_ID" + <constraint xsi:type="foreign" referenceId="DIR_COUNTRY_REGION_NAME_REGION_ID_DIR_COUNTRY_REGION_REGION_ID" table="directory_country_region_name" column="region_id" referenceTable="directory_country_region" referenceColumn="region_id" onDelete="CASCADE"/> - <index name="DIRECTORY_COUNTRY_REGION_NAME_REGION_ID" indexType="btree"> + <index referenceId="DIRECTORY_COUNTRY_REGION_NAME_REGION_ID" indexType="btree"> <column name="region_id"/> </index> </table> @@ -66,11 +66,11 @@ <column xsi:type="varchar" name="currency_to" nullable="false" length="3" comment="Currency Code Convert To"/> <column xsi:type="decimal" name="rate" scale="12" precision="24" unsigned="false" nullable="false" default="0" comment="Currency Conversion Rate"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="currency_from"/> <column name="currency_to"/> </constraint> - <index name="DIRECTORY_CURRENCY_RATE_CURRENCY_TO" indexType="btree"> + <index referenceId="DIRECTORY_CURRENCY_RATE_CURRENCY_TO" indexType="btree"> <column name="currency_to"/> </index> </table> diff --git a/app/code/Magento/Downloadable/etc/db_schema.xml b/app/code/Magento/Downloadable/etc/db_schema.xml index ed25628bcffd9..89d47644661a5 100644 --- a/app/code/Magento/Downloadable/etc/db_schema.xml +++ b/app/code/Magento/Downloadable/etc/db_schema.xml @@ -24,13 +24,13 @@ <column xsi:type="varchar" name="sample_url" nullable="true" length="255" comment="Sample Url"/> <column xsi:type="varchar" name="sample_file" nullable="true" length="255" comment="Sample File"/> <column xsi:type="varchar" name="sample_type" nullable="true" length="20" comment="Sample Type"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="link_id"/> </constraint> - <constraint xsi:type="foreign" name="DOWNLOADABLE_LINK_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="DOWNLOADABLE_LINK_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID" table="downloadable_link" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="DOWNLOADABLE_LINK_PRODUCT_ID_SORT_ORDER" indexType="btree"> + <index referenceId="DOWNLOADABLE_LINK_PRODUCT_ID_SORT_ORDER" indexType="btree"> <column name="product_id"/> <column name="sort_order"/> </index> @@ -44,19 +44,19 @@ default="0" comment="Website ID"/> <column xsi:type="decimal" name="price" scale="4" precision="12" unsigned="false" nullable="false" default="0" comment="Price"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="price_id"/> </constraint> - <constraint xsi:type="foreign" name="DOWNLOADABLE_LINK_PRICE_LINK_ID_DOWNLOADABLE_LINK_LINK_ID" + <constraint xsi:type="foreign" referenceId="DOWNLOADABLE_LINK_PRICE_LINK_ID_DOWNLOADABLE_LINK_LINK_ID" table="downloadable_link_price" column="link_id" referenceTable="downloadable_link" referenceColumn="link_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="DOWNLOADABLE_LINK_PRICE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" + <constraint xsi:type="foreign" referenceId="DOWNLOADABLE_LINK_PRICE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" table="downloadable_link_price" column="website_id" referenceTable="store_website" referenceColumn="website_id" onDelete="CASCADE"/> - <index name="DOWNLOADABLE_LINK_PRICE_LINK_ID" indexType="btree"> + <index referenceId="DOWNLOADABLE_LINK_PRICE_LINK_ID" indexType="btree"> <column name="link_id"/> </index> - <index name="DOWNLOADABLE_LINK_PRICE_WEBSITE_ID" indexType="btree"> + <index referenceId="DOWNLOADABLE_LINK_PRICE_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> </table> @@ -78,22 +78,22 @@ <column xsi:type="varchar" name="product_name" nullable="true" length="255" comment="Product name"/> <column xsi:type="varchar" name="product_sku" nullable="true" length="255" comment="Product sku"/> <column xsi:type="varchar" name="link_section_title" nullable="true" length="255" comment="Link_section_title"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="purchased_id"/> </constraint> - <constraint xsi:type="foreign" name="DL_LNK_PURCHASED_CSTR_ID_CSTR_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="DL_LNK_PURCHASED_CSTR_ID_CSTR_ENTT_ENTT_ID" table="downloadable_link_purchased" column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="SET NULL"/> - <constraint xsi:type="foreign" name="DOWNLOADABLE_LINK_PURCHASED_ORDER_ID_SALES_ORDER_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="DOWNLOADABLE_LINK_PURCHASED_ORDER_ID_SALES_ORDER_ENTITY_ID" table="downloadable_link_purchased" column="order_id" referenceTable="sales_order" referenceColumn="entity_id" onDelete="SET NULL"/> - <index name="DOWNLOADABLE_LINK_PURCHASED_ORDER_ID" indexType="btree"> + <index referenceId="DOWNLOADABLE_LINK_PURCHASED_ORDER_ID" indexType="btree"> <column name="order_id"/> </index> - <index name="DOWNLOADABLE_LINK_PURCHASED_ORDER_ITEM_ID" indexType="btree"> + <index referenceId="DOWNLOADABLE_LINK_PURCHASED_ORDER_ITEM_ID" indexType="btree"> <column name="order_item_id"/> </index> - <index name="DOWNLOADABLE_LINK_PURCHASED_CUSTOMER_ID" indexType="btree"> + <index referenceId="DOWNLOADABLE_LINK_PURCHASED_CUSTOMER_ID" indexType="btree"> <column name="customer_id"/> </index> </table> @@ -125,22 +125,22 @@ comment="Creation Time"/> <column xsi:type="timestamp" name="updated_at" on_update="true" nullable="false" default="CURRENT_TIMESTAMP" comment="Update Time"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="item_id"/> </constraint> - <constraint xsi:type="foreign" name="DL_LNK_PURCHASED_ITEM_PURCHASED_ID_DL_LNK_PURCHASED_PURCHASED_ID" + <constraint xsi:type="foreign" referenceId="DL_LNK_PURCHASED_ITEM_PURCHASED_ID_DL_LNK_PURCHASED_PURCHASED_ID" table="downloadable_link_purchased_item" column="purchased_id" referenceTable="downloadable_link_purchased" referenceColumn="purchased_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="DL_LNK_PURCHASED_ITEM_ORDER_ITEM_ID_SALES_ORDER_ITEM_ITEM_ID" + <constraint xsi:type="foreign" referenceId="DL_LNK_PURCHASED_ITEM_ORDER_ITEM_ID_SALES_ORDER_ITEM_ITEM_ID" table="downloadable_link_purchased_item" column="order_item_id" referenceTable="sales_order_item" referenceColumn="item_id" onDelete="SET NULL"/> - <index name="DOWNLOADABLE_LINK_PURCHASED_ITEM_LINK_HASH" indexType="btree"> + <index referenceId="DOWNLOADABLE_LINK_PURCHASED_ITEM_LINK_HASH" indexType="btree"> <column name="link_hash"/> </index> - <index name="DOWNLOADABLE_LINK_PURCHASED_ITEM_ORDER_ITEM_ID" indexType="btree"> + <index referenceId="DOWNLOADABLE_LINK_PURCHASED_ITEM_ORDER_ITEM_ID" indexType="btree"> <column name="order_item_id"/> </index> - <index name="DOWNLOADABLE_LINK_PURCHASED_ITEM_PURCHASED_ID" indexType="btree"> + <index referenceId="DOWNLOADABLE_LINK_PURCHASED_ITEM_PURCHASED_ID" indexType="btree"> <column name="purchased_id"/> </index> </table> @@ -152,20 +152,20 @@ <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Store ID"/> <column xsi:type="varchar" name="title" nullable="true" length="255" comment="Title"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="title_id"/> </constraint> - <constraint xsi:type="foreign" name="DOWNLOADABLE_LINK_TITLE_LINK_ID_DOWNLOADABLE_LINK_LINK_ID" + <constraint xsi:type="foreign" referenceId="DOWNLOADABLE_LINK_TITLE_LINK_ID_DOWNLOADABLE_LINK_LINK_ID" table="downloadable_link_title" column="link_id" referenceTable="downloadable_link" referenceColumn="link_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="DOWNLOADABLE_LINK_TITLE_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="DOWNLOADABLE_LINK_TITLE_STORE_ID_STORE_STORE_ID" table="downloadable_link_title" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="DOWNLOADABLE_LINK_TITLE_LINK_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="DOWNLOADABLE_LINK_TITLE_LINK_ID_STORE_ID"> <column name="link_id"/> <column name="store_id"/> </constraint> - <index name="DOWNLOADABLE_LINK_TITLE_STORE_ID" indexType="btree"> + <index referenceId="DOWNLOADABLE_LINK_TITLE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -179,13 +179,13 @@ <column xsi:type="varchar" name="sample_type" nullable="true" length="20" comment="Sample Type"/> <column xsi:type="int" name="sort_order" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Sort Order"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="sample_id"/> </constraint> - <constraint xsi:type="foreign" name="DOWNLOADABLE_SAMPLE_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="DOWNLOADABLE_SAMPLE_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID" table="downloadable_sample" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="DOWNLOADABLE_SAMPLE_PRODUCT_ID" indexType="btree"> + <index referenceId="DOWNLOADABLE_SAMPLE_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> </table> @@ -198,20 +198,20 @@ <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Store ID"/> <column xsi:type="varchar" name="title" nullable="true" length="255" comment="Title"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="title_id"/> </constraint> - <constraint xsi:type="foreign" name="DL_SAMPLE_TTL_SAMPLE_ID_DL_SAMPLE_SAMPLE_ID" + <constraint xsi:type="foreign" referenceId="DL_SAMPLE_TTL_SAMPLE_ID_DL_SAMPLE_SAMPLE_ID" table="downloadable_sample_title" column="sample_id" referenceTable="downloadable_sample" referenceColumn="sample_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="DOWNLOADABLE_SAMPLE_TITLE_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="DOWNLOADABLE_SAMPLE_TITLE_STORE_ID_STORE_STORE_ID" table="downloadable_sample_title" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="DOWNLOADABLE_SAMPLE_TITLE_SAMPLE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="DOWNLOADABLE_SAMPLE_TITLE_SAMPLE_ID_STORE_ID"> <column name="sample_id"/> <column name="store_id"/> </constraint> - <index name="DOWNLOADABLE_SAMPLE_TITLE_STORE_ID" indexType="btree"> + <index referenceId="DOWNLOADABLE_SAMPLE_TITLE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -227,7 +227,7 @@ default="0" comment="Minimum price"/> <column xsi:type="decimal" name="max_price" scale="4" precision="12" unsigned="false" nullable="false" default="0" comment="Maximum price"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> <column name="customer_group_id"/> <column name="website_id"/> @@ -245,7 +245,7 @@ default="0" comment="Minimum price"/> <column xsi:type="decimal" name="max_price" scale="4" precision="12" unsigned="false" nullable="false" default="0" comment="Maximum price"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> <column name="customer_group_id"/> <column name="website_id"/> diff --git a/app/code/Magento/Eav/etc/db_schema.xml b/app/code/Magento/Eav/etc/db_schema.xml index e81fad5ebded8..b6c42d725e5e9 100644 --- a/app/code/Magento/Eav/etc/db_schema.xml +++ b/app/code/Magento/Eav/etc/db_schema.xml @@ -33,10 +33,10 @@ comment="Additional Attribute Table"/> <column xsi:type="varchar" name="entity_attribute_collection" nullable="true" length="255" comment="Entity Attribute Collection"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_type_id"/> </constraint> - <index name="EAV_ENTITY_TYPE_ENTITY_TYPE_CODE" indexType="btree"> + <index referenceId="EAV_ENTITY_TYPE_ENTITY_TYPE_CODE" indexType="btree"> <column name="entity_type_code"/> </index> </table> @@ -58,18 +58,18 @@ comment="Updated At"/> <column xsi:type="smallint" name="is_active" padding="5" unsigned="true" nullable="false" identity="false" default="1" comment="Defines Is Entity Active"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_ENTITY_ENTITY_TYPE_ID_EAV_ENTITY_TYPE_ENTITY_TYPE_ID" + <constraint xsi:type="foreign" referenceId="EAV_ENTITY_ENTITY_TYPE_ID_EAV_ENTITY_TYPE_ENTITY_TYPE_ID" table="eav_entity" column="entity_type_id" referenceTable="eav_entity_type" referenceColumn="entity_type_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="EAV_ENTITY_STORE_ID_STORE_STORE_ID" table="eav_entity" column="store_id" + <constraint xsi:type="foreign" referenceId="EAV_ENTITY_STORE_ID_STORE_STORE_ID" table="eav_entity" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <index name="EAV_ENTITY_ENTITY_TYPE_ID" indexType="btree"> + <index referenceId="EAV_ENTITY_ENTITY_TYPE_ID" indexType="btree"> <column name="entity_type_id"/> </index> - <index name="EAV_ENTITY_STORE_ID" indexType="btree"> + <index referenceId="EAV_ENTITY_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -85,30 +85,30 @@ <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Entity ID"/> <column xsi:type="datetime" name="value" on_update="false" nullable="true" comment="Attribute Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_ENTITY_DATETIME_ENTITY_ID_EAV_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="EAV_ENTITY_DATETIME_ENTITY_ID_EAV_ENTITY_ENTITY_ID" table="eav_entity_datetime" column="entity_id" referenceTable="eav_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="EAV_ENTT_DTIME_ENTT_TYPE_ID_EAV_ENTT_TYPE_ENTT_TYPE_ID" + <constraint xsi:type="foreign" referenceId="EAV_ENTT_DTIME_ENTT_TYPE_ID_EAV_ENTT_TYPE_ENTT_TYPE_ID" table="eav_entity_datetime" column="entity_type_id" referenceTable="eav_entity_type" referenceColumn="entity_type_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="EAV_ENTITY_DATETIME_STORE_ID_STORE_STORE_ID" table="eav_entity_datetime" + <constraint xsi:type="foreign" referenceId="EAV_ENTITY_DATETIME_STORE_ID_STORE_STORE_ID" table="eav_entity_datetime" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="EAV_ENTITY_DATETIME_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="EAV_ENTITY_DATETIME_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> </constraint> - <index name="EAV_ENTITY_DATETIME_STORE_ID" indexType="btree"> + <index referenceId="EAV_ENTITY_DATETIME_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="EAV_ENTITY_DATETIME_ATTRIBUTE_ID_VALUE" indexType="btree"> + <index referenceId="EAV_ENTITY_DATETIME_ATTRIBUTE_ID_VALUE" indexType="btree"> <column name="attribute_id"/> <column name="value"/> </index> - <index name="EAV_ENTITY_DATETIME_ENTITY_TYPE_ID_VALUE" indexType="btree"> + <index referenceId="EAV_ENTITY_DATETIME_ENTITY_TYPE_ID_VALUE" indexType="btree"> <column name="entity_type_id"/> <column name="value"/> </index> @@ -126,30 +126,30 @@ default="0" comment="Entity ID"/> <column xsi:type="decimal" name="value" scale="4" precision="12" unsigned="false" nullable="false" default="0" comment="Attribute Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_ENTITY_DECIMAL_ENTITY_ID_EAV_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="EAV_ENTITY_DECIMAL_ENTITY_ID_EAV_ENTITY_ENTITY_ID" table="eav_entity_decimal" column="entity_id" referenceTable="eav_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="EAV_ENTITY_DECIMAL_ENTITY_TYPE_ID_EAV_ENTITY_TYPE_ENTITY_TYPE_ID" + <constraint xsi:type="foreign" referenceId="EAV_ENTITY_DECIMAL_ENTITY_TYPE_ID_EAV_ENTITY_TYPE_ENTITY_TYPE_ID" table="eav_entity_decimal" column="entity_type_id" referenceTable="eav_entity_type" referenceColumn="entity_type_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="EAV_ENTITY_DECIMAL_STORE_ID_STORE_STORE_ID" table="eav_entity_decimal" + <constraint xsi:type="foreign" referenceId="EAV_ENTITY_DECIMAL_STORE_ID_STORE_STORE_ID" table="eav_entity_decimal" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="EAV_ENTITY_DECIMAL_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="EAV_ENTITY_DECIMAL_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> </constraint> - <index name="EAV_ENTITY_DECIMAL_STORE_ID" indexType="btree"> + <index referenceId="EAV_ENTITY_DECIMAL_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="EAV_ENTITY_DECIMAL_ATTRIBUTE_ID_VALUE" indexType="btree"> + <index referenceId="EAV_ENTITY_DECIMAL_ATTRIBUTE_ID_VALUE" indexType="btree"> <column name="attribute_id"/> <column name="value"/> </index> - <index name="EAV_ENTITY_DECIMAL_ENTITY_TYPE_ID_VALUE" indexType="btree"> + <index referenceId="EAV_ENTITY_DECIMAL_ENTITY_TYPE_ID_VALUE" indexType="btree"> <column name="entity_type_id"/> <column name="value"/> </index> @@ -167,29 +167,29 @@ default="0" comment="Entity ID"/> <column xsi:type="int" name="value" padding="11" unsigned="false" nullable="false" identity="false" default="0" comment="Attribute Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_ENTITY_INT_ENTITY_ID_EAV_ENTITY_ENTITY_ID" table="eav_entity_int" + <constraint xsi:type="foreign" referenceId="EAV_ENTITY_INT_ENTITY_ID_EAV_ENTITY_ENTITY_ID" table="eav_entity_int" column="entity_id" referenceTable="eav_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="EAV_ENTITY_INT_ENTITY_TYPE_ID_EAV_ENTITY_TYPE_ENTITY_TYPE_ID" + <constraint xsi:type="foreign" referenceId="EAV_ENTITY_INT_ENTITY_TYPE_ID_EAV_ENTITY_TYPE_ENTITY_TYPE_ID" table="eav_entity_int" column="entity_type_id" referenceTable="eav_entity_type" referenceColumn="entity_type_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="EAV_ENTITY_INT_STORE_ID_STORE_STORE_ID" table="eav_entity_int" + <constraint xsi:type="foreign" referenceId="EAV_ENTITY_INT_STORE_ID_STORE_STORE_ID" table="eav_entity_int" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="EAV_ENTITY_INT_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="EAV_ENTITY_INT_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> </constraint> - <index name="EAV_ENTITY_INT_STORE_ID" indexType="btree"> + <index referenceId="EAV_ENTITY_INT_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="EAV_ENTITY_INT_ATTRIBUTE_ID_VALUE" indexType="btree"> + <index referenceId="EAV_ENTITY_INT_ATTRIBUTE_ID_VALUE" indexType="btree"> <column name="attribute_id"/> <column name="value"/> </index> - <index name="EAV_ENTITY_INT_ENTITY_TYPE_ID_VALUE" indexType="btree"> + <index referenceId="EAV_ENTITY_INT_ENTITY_TYPE_ID_VALUE" indexType="btree"> <column name="entity_type_id"/> <column name="value"/> </index> @@ -206,28 +206,28 @@ <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Entity ID"/> <column xsi:type="text" name="value" nullable="false" comment="Attribute Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_ENTITY_TEXT_ENTITY_ID_EAV_ENTITY_ENTITY_ID" table="eav_entity_text" + <constraint xsi:type="foreign" referenceId="EAV_ENTITY_TEXT_ENTITY_ID_EAV_ENTITY_ENTITY_ID" table="eav_entity_text" column="entity_id" referenceTable="eav_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="EAV_ENTITY_TEXT_ENTITY_TYPE_ID_EAV_ENTITY_TYPE_ENTITY_TYPE_ID" + <constraint xsi:type="foreign" referenceId="EAV_ENTITY_TEXT_ENTITY_TYPE_ID_EAV_ENTITY_TYPE_ENTITY_TYPE_ID" table="eav_entity_text" column="entity_type_id" referenceTable="eav_entity_type" referenceColumn="entity_type_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="EAV_ENTITY_TEXT_STORE_ID_STORE_STORE_ID" table="eav_entity_text" + <constraint xsi:type="foreign" referenceId="EAV_ENTITY_TEXT_STORE_ID_STORE_STORE_ID" table="eav_entity_text" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="EAV_ENTITY_TEXT_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="EAV_ENTITY_TEXT_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> </constraint> - <index name="EAV_ENTITY_TEXT_ENTITY_TYPE_ID" indexType="btree"> + <index referenceId="EAV_ENTITY_TEXT_ENTITY_TYPE_ID" indexType="btree"> <column name="entity_type_id"/> </index> - <index name="EAV_ENTITY_TEXT_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="EAV_ENTITY_TEXT_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index name="EAV_ENTITY_TEXT_STORE_ID" indexType="btree"> + <index referenceId="EAV_ENTITY_TEXT_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -243,30 +243,30 @@ <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Entity ID"/> <column xsi:type="varchar" name="value" nullable="true" length="255" comment="Attribute Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_ENTITY_VARCHAR_ENTITY_ID_EAV_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="EAV_ENTITY_VARCHAR_ENTITY_ID_EAV_ENTITY_ENTITY_ID" table="eav_entity_varchar" column="entity_id" referenceTable="eav_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="EAV_ENTITY_VARCHAR_ENTITY_TYPE_ID_EAV_ENTITY_TYPE_ENTITY_TYPE_ID" + <constraint xsi:type="foreign" referenceId="EAV_ENTITY_VARCHAR_ENTITY_TYPE_ID_EAV_ENTITY_TYPE_ENTITY_TYPE_ID" table="eav_entity_varchar" column="entity_type_id" referenceTable="eav_entity_type" referenceColumn="entity_type_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="EAV_ENTITY_VARCHAR_STORE_ID_STORE_STORE_ID" table="eav_entity_varchar" + <constraint xsi:type="foreign" referenceId="EAV_ENTITY_VARCHAR_STORE_ID_STORE_STORE_ID" table="eav_entity_varchar" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="EAV_ENTITY_VARCHAR_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="EAV_ENTITY_VARCHAR_ENTITY_ID_ATTRIBUTE_ID_STORE_ID"> <column name="entity_id"/> <column name="attribute_id"/> <column name="store_id"/> </constraint> - <index name="EAV_ENTITY_VARCHAR_STORE_ID" indexType="btree"> + <index referenceId="EAV_ENTITY_VARCHAR_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="EAV_ENTITY_VARCHAR_ATTRIBUTE_ID_VALUE" indexType="btree"> + <index referenceId="EAV_ENTITY_VARCHAR_ATTRIBUTE_ID_VALUE" indexType="btree"> <column name="attribute_id"/> <column name="value"/> </index> - <index name="EAV_ENTITY_VARCHAR_ENTITY_TYPE_ID_VALUE" indexType="btree"> + <index referenceId="EAV_ENTITY_VARCHAR_ENTITY_TYPE_ID_VALUE" indexType="btree"> <column name="entity_type_id"/> <column name="value"/> </index> @@ -295,13 +295,13 @@ <column xsi:type="smallint" name="is_unique" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Defines Is Unique"/> <column xsi:type="varchar" name="note" nullable="true" length="255" comment="Note"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="attribute_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_ATTRIBUTE_ENTITY_TYPE_ID_EAV_ENTITY_TYPE_ENTITY_TYPE_ID" + <constraint xsi:type="foreign" referenceId="EAV_ATTRIBUTE_ENTITY_TYPE_ID_EAV_ENTITY_TYPE_ENTITY_TYPE_ID" table="eav_attribute" column="entity_type_id" referenceTable="eav_entity_type" referenceColumn="entity_type_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="EAV_ATTRIBUTE_ENTITY_TYPE_ID_ATTRIBUTE_CODE"> + <constraint xsi:type="unique" referenceId="EAV_ATTRIBUTE_ENTITY_TYPE_ID_ATTRIBUTE_CODE"> <column name="entity_type_id"/> <column name="attribute_code"/> </constraint> @@ -315,18 +315,18 @@ default="0" comment="Store Id"/> <column xsi:type="varchar" name="increment_prefix" nullable="true" length="20" comment="Increment Prefix"/> <column xsi:type="varchar" name="increment_last_id" nullable="true" length="50" comment="Last Incremented Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_store_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_ENTITY_STORE_ENTITY_TYPE_ID_EAV_ENTITY_TYPE_ENTITY_TYPE_ID" + <constraint xsi:type="foreign" referenceId="EAV_ENTITY_STORE_ENTITY_TYPE_ID_EAV_ENTITY_TYPE_ENTITY_TYPE_ID" table="eav_entity_store" column="entity_type_id" referenceTable="eav_entity_type" referenceColumn="entity_type_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="EAV_ENTITY_STORE_STORE_ID_STORE_STORE_ID" table="eav_entity_store" + <constraint xsi:type="foreign" referenceId="EAV_ENTITY_STORE_STORE_ID_STORE_STORE_ID" table="eav_entity_store" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <index name="EAV_ENTITY_STORE_ENTITY_TYPE_ID" indexType="btree"> + <index referenceId="EAV_ENTITY_STORE_ENTITY_TYPE_ID" indexType="btree"> <column name="entity_type_id"/> </index> - <index name="EAV_ENTITY_STORE_STORE_ID" indexType="btree"> + <index referenceId="EAV_ENTITY_STORE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -338,17 +338,17 @@ <column xsi:type="varchar" name="attribute_set_name" nullable="true" length="255" comment="Attribute Set Name"/> <column xsi:type="smallint" name="sort_order" padding="6" unsigned="false" nullable="false" identity="false" default="0" comment="Sort Order"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="attribute_set_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_ATTRIBUTE_SET_ENTITY_TYPE_ID_EAV_ENTITY_TYPE_ENTITY_TYPE_ID" + <constraint xsi:type="foreign" referenceId="EAV_ATTRIBUTE_SET_ENTITY_TYPE_ID_EAV_ENTITY_TYPE_ENTITY_TYPE_ID" table="eav_attribute_set" column="entity_type_id" referenceTable="eav_entity_type" referenceColumn="entity_type_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="EAV_ATTRIBUTE_SET_ENTITY_TYPE_ID_ATTRIBUTE_SET_NAME"> + <constraint xsi:type="unique" referenceId="EAV_ATTRIBUTE_SET_ENTITY_TYPE_ID_ATTRIBUTE_SET_NAME"> <column name="entity_type_id"/> <column name="attribute_set_name"/> </constraint> - <index name="EAV_ATTRIBUTE_SET_ENTITY_TYPE_ID_SORT_ORDER" indexType="btree"> + <index referenceId="EAV_ATTRIBUTE_SET_ENTITY_TYPE_ID_SORT_ORDER" indexType="btree"> <column name="entity_type_id"/> <column name="sort_order"/> </index> @@ -367,21 +367,21 @@ <column xsi:type="varchar" name="attribute_group_code" nullable="false" length="255" comment="Attribute Group Code"/> <column xsi:type="varchar" name="tab_group_code" nullable="true" length="255" comment="Tab Group Code"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="attribute_group_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_ATTR_GROUP_ATTR_SET_ID_EAV_ATTR_SET_ATTR_SET_ID" + <constraint xsi:type="foreign" referenceId="EAV_ATTR_GROUP_ATTR_SET_ID_EAV_ATTR_SET_ATTR_SET_ID" table="eav_attribute_group" column="attribute_set_id" referenceTable="eav_attribute_set" referenceColumn="attribute_set_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="EAV_ATTRIBUTE_GROUP_ATTRIBUTE_SET_ID_ATTRIBUTE_GROUP_NAME"> + <constraint xsi:type="unique" referenceId="EAV_ATTRIBUTE_GROUP_ATTRIBUTE_SET_ID_ATTRIBUTE_GROUP_NAME"> <column name="attribute_set_id"/> <column name="attribute_group_name"/> </constraint> - <constraint xsi:type="unique" name="EAV_ATTRIBUTE_GROUP_ATTRIBUTE_SET_ID_ATTRIBUTE_GROUP_CODE"> + <constraint xsi:type="unique" referenceId="EAV_ATTRIBUTE_GROUP_ATTRIBUTE_SET_ID_ATTRIBUTE_GROUP_CODE"> <column name="attribute_set_id"/> <column name="attribute_group_code"/> </constraint> - <index name="EAV_ATTRIBUTE_GROUP_ATTRIBUTE_SET_ID_SORT_ORDER" indexType="btree"> + <index referenceId="EAV_ATTRIBUTE_GROUP_ATTRIBUTE_SET_ID_SORT_ORDER" indexType="btree"> <column name="attribute_set_id"/> <column name="sort_order"/> </index> @@ -399,28 +399,28 @@ default="0" comment="Attribute Id"/> <column xsi:type="smallint" name="sort_order" padding="6" unsigned="false" nullable="false" identity="false" default="0" comment="Sort Order"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_attribute_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_ENTITY_ATTRIBUTE_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" + <constraint xsi:type="foreign" referenceId="EAV_ENTITY_ATTRIBUTE_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" table="eav_entity_attribute" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="EAV_ENTT_ATTR_ATTR_GROUP_ID_EAV_ATTR_GROUP_ATTR_GROUP_ID" + <constraint xsi:type="foreign" referenceId="EAV_ENTT_ATTR_ATTR_GROUP_ID_EAV_ATTR_GROUP_ATTR_GROUP_ID" table="eav_entity_attribute" column="attribute_group_id" referenceTable="eav_attribute_group" referenceColumn="attribute_group_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="EAV_ENTITY_ATTRIBUTE_ATTRIBUTE_SET_ID_ATTRIBUTE_ID"> + <constraint xsi:type="unique" referenceId="EAV_ENTITY_ATTRIBUTE_ATTRIBUTE_SET_ID_ATTRIBUTE_ID"> <column name="attribute_set_id"/> <column name="attribute_id"/> </constraint> - <constraint xsi:type="unique" name="EAV_ENTITY_ATTRIBUTE_ATTRIBUTE_GROUP_ID_ATTRIBUTE_ID"> + <constraint xsi:type="unique" referenceId="EAV_ENTITY_ATTRIBUTE_ATTRIBUTE_GROUP_ID_ATTRIBUTE_ID"> <column name="attribute_group_id"/> <column name="attribute_id"/> </constraint> - <index name="EAV_ENTITY_ATTRIBUTE_ATTRIBUTE_SET_ID_SORT_ORDER" indexType="btree"> + <index referenceId="EAV_ENTITY_ATTRIBUTE_ATTRIBUTE_SET_ID_SORT_ORDER" indexType="btree"> <column name="attribute_set_id"/> <column name="sort_order"/> </index> - <index name="EAV_ENTITY_ATTRIBUTE_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="EAV_ENTITY_ATTRIBUTE_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> </table> @@ -431,13 +431,13 @@ default="0" comment="Attribute Id"/> <column xsi:type="smallint" name="sort_order" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Sort Order"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="option_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_ATTRIBUTE_OPTION_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" + <constraint xsi:type="foreign" referenceId="EAV_ATTRIBUTE_OPTION_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" table="eav_attribute_option" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <index name="EAV_ATTRIBUTE_OPTION_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="EAV_ATTRIBUTE_OPTION_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> </table> @@ -449,19 +449,19 @@ <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Store Id"/> <column xsi:type="varchar" name="value" nullable="true" length="255" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_ATTR_OPT_VAL_OPT_ID_EAV_ATTR_OPT_OPT_ID" + <constraint xsi:type="foreign" referenceId="EAV_ATTR_OPT_VAL_OPT_ID_EAV_ATTR_OPT_OPT_ID" table="eav_attribute_option_value" column="option_id" referenceTable="eav_attribute_option" referenceColumn="option_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="EAV_ATTRIBUTE_OPTION_VALUE_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="EAV_ATTRIBUTE_OPTION_VALUE_STORE_ID_STORE_STORE_ID" table="eav_attribute_option_value" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <index name="EAV_ATTRIBUTE_OPTION_VALUE_OPTION_ID" indexType="btree"> + <index referenceId="EAV_ATTRIBUTE_OPTION_VALUE_OPTION_ID" indexType="btree"> <column name="option_id"/> </index> - <index name="EAV_ATTRIBUTE_OPTION_VALUE_STORE_ID" indexType="btree"> + <index referenceId="EAV_ATTRIBUTE_OPTION_VALUE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -473,18 +473,18 @@ <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Store Id"/> <column xsi:type="varchar" name="value" nullable="true" length="255" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="attribute_label_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_ATTRIBUTE_LABEL_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" + <constraint xsi:type="foreign" referenceId="EAV_ATTRIBUTE_LABEL_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" table="eav_attribute_label" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="EAV_ATTRIBUTE_LABEL_STORE_ID_STORE_STORE_ID" table="eav_attribute_label" + <constraint xsi:type="foreign" referenceId="EAV_ATTRIBUTE_LABEL_STORE_ID_STORE_STORE_ID" table="eav_attribute_label" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <index name="EAV_ATTRIBUTE_LABEL_STORE_ID" indexType="btree"> + <index referenceId="EAV_ATTRIBUTE_LABEL_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="EAV_ATTRIBUTE_LABEL_ATTRIBUTE_ID_STORE_ID" indexType="btree"> + <index referenceId="EAV_ATTRIBUTE_LABEL_ATTRIBUTE_ID_STORE_ID" indexType="btree"> <column name="attribute_id"/> <column name="store_id"/> </index> @@ -499,17 +499,17 @@ <column xsi:type="varchar" name="theme" nullable="true" length="64" comment="Theme"/> <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Store Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="type_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_FORM_TYPE_STORE_ID_STORE_STORE_ID" table="eav_form_type" + <constraint xsi:type="foreign" referenceId="EAV_FORM_TYPE_STORE_ID_STORE_STORE_ID" table="eav_form_type" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="EAV_FORM_TYPE_CODE_THEME_STORE_ID"> + <constraint xsi:type="unique" referenceId="EAV_FORM_TYPE_CODE_THEME_STORE_ID"> <column name="code"/> <column name="theme"/> <column name="store_id"/> </constraint> - <index name="EAV_FORM_TYPE_STORE_ID" indexType="btree"> + <index referenceId="EAV_FORM_TYPE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -518,17 +518,17 @@ comment="Type Id"/> <column xsi:type="smallint" name="entity_type_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Entity Type Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="type_id"/> <column name="entity_type_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_FORM_TYPE_ENTT_ENTT_TYPE_ID_EAV_ENTT_TYPE_ENTT_TYPE_ID" + <constraint xsi:type="foreign" referenceId="EAV_FORM_TYPE_ENTT_ENTT_TYPE_ID_EAV_ENTT_TYPE_ENTT_TYPE_ID" table="eav_form_type_entity" column="entity_type_id" referenceTable="eav_entity_type" referenceColumn="entity_type_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="EAV_FORM_TYPE_ENTITY_TYPE_ID_EAV_FORM_TYPE_TYPE_ID" + <constraint xsi:type="foreign" referenceId="EAV_FORM_TYPE_ENTITY_TYPE_ID_EAV_FORM_TYPE_TYPE_ID" table="eav_form_type_entity" column="type_id" referenceTable="eav_form_type" referenceColumn="type_id" onDelete="CASCADE"/> - <index name="EAV_FORM_TYPE_ENTITY_ENTITY_TYPE_ID" indexType="btree"> + <index referenceId="EAV_FORM_TYPE_ENTITY_ENTITY_TYPE_ID" indexType="btree"> <column name="entity_type_id"/> </index> </table> @@ -540,12 +540,12 @@ <column xsi:type="varchar" name="code" nullable="false" length="64" comment="Code"/> <column xsi:type="int" name="sort_order" padding="11" unsigned="false" nullable="false" identity="false" default="0" comment="Sort Order"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="fieldset_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_FORM_FIELDSET_TYPE_ID_EAV_FORM_TYPE_TYPE_ID" table="eav_form_fieldset" + <constraint xsi:type="foreign" referenceId="EAV_FORM_FIELDSET_TYPE_ID_EAV_FORM_TYPE_TYPE_ID" table="eav_form_fieldset" column="type_id" referenceTable="eav_form_type" referenceColumn="type_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="EAV_FORM_FIELDSET_TYPE_ID_CODE"> + <constraint xsi:type="unique" referenceId="EAV_FORM_FIELDSET_TYPE_ID_CODE"> <column name="type_id"/> <column name="code"/> </constraint> @@ -556,17 +556,17 @@ <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Store Id"/> <column xsi:type="varchar" name="label" nullable="false" length="255" comment="Label"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="fieldset_id"/> <column name="store_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_FORM_FSET_LBL_FSET_ID_EAV_FORM_FSET_FSET_ID" + <constraint xsi:type="foreign" referenceId="EAV_FORM_FSET_LBL_FSET_ID_EAV_FORM_FSET_FSET_ID" table="eav_form_fieldset_label" column="fieldset_id" referenceTable="eav_form_fieldset" referenceColumn="fieldset_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="EAV_FORM_FIELDSET_LABEL_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="EAV_FORM_FIELDSET_LABEL_STORE_ID_STORE_STORE_ID" table="eav_form_fieldset_label" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <index name="EAV_FORM_FIELDSET_LABEL_STORE_ID" indexType="btree"> + <index referenceId="EAV_FORM_FIELDSET_LABEL_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -581,25 +581,25 @@ comment="Attribute Id"/> <column xsi:type="int" name="sort_order" padding="11" unsigned="false" nullable="false" identity="false" default="0" comment="Sort Order"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="element_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_FORM_ELEMENT_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" + <constraint xsi:type="foreign" referenceId="EAV_FORM_ELEMENT_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" table="eav_form_element" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="EAV_FORM_ELEMENT_FIELDSET_ID_EAV_FORM_FIELDSET_FIELDSET_ID" + <constraint xsi:type="foreign" referenceId="EAV_FORM_ELEMENT_FIELDSET_ID_EAV_FORM_FIELDSET_FIELDSET_ID" table="eav_form_element" column="fieldset_id" referenceTable="eav_form_fieldset" referenceColumn="fieldset_id" onDelete="SET NULL"/> - <constraint xsi:type="foreign" name="EAV_FORM_ELEMENT_TYPE_ID_EAV_FORM_TYPE_TYPE_ID" table="eav_form_element" + <constraint xsi:type="foreign" referenceId="EAV_FORM_ELEMENT_TYPE_ID_EAV_FORM_TYPE_TYPE_ID" table="eav_form_element" column="type_id" referenceTable="eav_form_type" referenceColumn="type_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="EAV_FORM_ELEMENT_TYPE_ID_ATTRIBUTE_ID"> + <constraint xsi:type="unique" referenceId="EAV_FORM_ELEMENT_TYPE_ID_ATTRIBUTE_ID"> <column name="type_id"/> <column name="attribute_id"/> </constraint> - <index name="EAV_FORM_ELEMENT_FIELDSET_ID" indexType="btree"> + <index referenceId="EAV_FORM_ELEMENT_FIELDSET_ID" indexType="btree"> <column name="fieldset_id"/> </index> - <index name="EAV_FORM_ELEMENT_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="EAV_FORM_ELEMENT_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> </table> diff --git a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/BatchDataMapper/CategoryFieldsProvider.php b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/BatchDataMapper/CategoryFieldsProvider.php index 009c07602fc2a..eb7874a936140 100644 --- a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/BatchDataMapper/CategoryFieldsProvider.php +++ b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/BatchDataMapper/CategoryFieldsProvider.php @@ -3,10 +3,14 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Elasticsearch\Elasticsearch5\Model\Adapter\BatchDataMapper; use Magento\Elasticsearch\Model\ResourceModel\Index; use Magento\AdvancedSearch\Model\Adapter\DataMapper\AdditionalFieldsProviderInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeProvider; +use Magento\Framework\App\ObjectManager; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\ResolverInterface; /** * Provide data mapping for categories fields @@ -18,16 +22,35 @@ class CategoryFieldsProvider implements AdditionalFieldsProviderInterface */ private $resourceIndex; + /** + * @var AttributeProvider + */ + private $attributeAdapterProvider; + + /** + * @var ResolverInterface + */ + private $fieldNameResolver; + /** * @param Index $resourceIndex + * @param AttributeProvider|null $attributeAdapterProvider + * @param ResolverInterface|null $fieldNameResolver */ - public function __construct(Index $resourceIndex) - { + public function __construct( + Index $resourceIndex, + AttributeProvider $attributeAdapterProvider = null, + ResolverInterface $fieldNameResolver = null + ) { $this->resourceIndex = $resourceIndex; + $this->attributeAdapterProvider = $attributeAdapterProvider ?: ObjectManager::getInstance() + ->get(AttributeProvider::class); + $this->fieldNameResolver = $fieldNameResolver ?: ObjectManager::getInstance() + ->get(ResolverInterface::class); } /** - * {@inheritdoc} + * @inheritdoc */ public function getFields(array $productIds, $storeId) { @@ -58,9 +81,19 @@ private function getProductCategoryData($productId, array $categoryIndexData) if (count($categoryIds)) { $result = ['category_ids' => $categoryIds]; + $positionAttribute = $this->attributeAdapterProvider->getByAttributeCode('position'); + $categoryNameAttribute = $this->attributeAdapterProvider->getByAttributeCode('category_name'); foreach ($indexData as $data) { - $result['position_category_' . $data['id']] = $data['position']; - $result['name_category_' . $data['id']] = $data['name']; + $categoryPositionKey = $this->fieldNameResolver->getFieldName( + $positionAttribute, + ['categoryId' => $data['id']] + ); + $categoryNameKey = $this->fieldNameResolver->getFieldName( + $categoryNameAttribute, + ['categoryId' => $data['id']] + ); + $result[$categoryPositionKey] = $data['position']; + $result[$categoryNameKey] = $data['name']; } } } diff --git a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/DataMapper/ProductDataMapper.php b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/DataMapper/ProductDataMapper.php index 659df0f8447f9..f0b7380397235 100644 --- a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/DataMapper/ProductDataMapper.php +++ b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/DataMapper/ProductDataMapper.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Elasticsearch\Elasticsearch5\Model\Adapter\DataMapper; use Magento\Catalog\Model\ResourceModel\Eav\Attribute; @@ -14,8 +15,13 @@ use Magento\Elasticsearch\Model\Adapter\FieldMapperInterface; use Magento\Elasticsearch\Model\Adapter\DataMapperInterface; use Magento\Elasticsearch\Model\Adapter\FieldType\Date as DateFieldType; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeProvider; +use Magento\Framework\App\ObjectManager; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\ResolverInterface; /** + * Don't use this product data mapper class. + * * @deprecated 100.2.0 * @see \Magento\Elasticsearch\Model\Adapter\BatchDataMapperInterface */ @@ -78,6 +84,16 @@ class ProductDataMapper implements DataMapperInterface */ protected $mediaGalleryRoles; + /** + * @var AttributeProvider + */ + private $attributeAdapterProvider; + + /** + * @var ResolverInterface + */ + private $fieldNameResolver; + /** * Construction for DocumentDataMapper * @@ -87,6 +103,8 @@ class ProductDataMapper implements DataMapperInterface * @param FieldMapperInterface $fieldMapper * @param StoreManagerInterface $storeManager * @param DateFieldType $dateFieldType + * @param AttributeProvider|null $attributeAdapterProvider + * @param ResolverInterface|null $fieldNameResolver */ public function __construct( Builder $builder, @@ -94,7 +112,9 @@ public function __construct( Index $resourceIndex, FieldMapperInterface $fieldMapper, StoreManagerInterface $storeManager, - DateFieldType $dateFieldType + DateFieldType $dateFieldType, + AttributeProvider $attributeAdapterProvider = null, + ResolverInterface $fieldNameResolver = null ) { $this->builder = $builder; $this->attributeContainer = $attributeContainer; @@ -102,6 +122,10 @@ public function __construct( $this->fieldMapper = $fieldMapper; $this->storeManager = $storeManager; $this->dateFieldType = $dateFieldType; + $this->attributeAdapterProvider = $attributeAdapterProvider ?: ObjectManager::getInstance() + ->get(AttributeProvider::class); + $this->fieldNameResolver = $fieldNameResolver ?: ObjectManager::getInstance() + ->get(ResolverInterface::class); $this->mediaGalleryRoles = [ self::MEDIA_ROLE_IMAGE, @@ -203,6 +227,8 @@ protected function processAdvancedAttributes($productId, array $productIndexData } /** + * Check value. + * * @param mixed $value * @param Attribute $attribute * @param string $storeId @@ -232,14 +258,14 @@ protected function getProductTierPriceData($data) if (!empty($data)) { $i = 0; foreach ($data as $tierPrice) { - $result['tier_price_id_'.$i] = $tierPrice['price_id']; - $result['tier_website_id_'.$i] = $tierPrice['website_id']; - $result['tier_all_groups_'.$i] = $tierPrice['all_groups']; - $result['tier_cust_group_'.$i] = $tierPrice['cust_group'] == GroupInterface::CUST_GROUP_ALL + $result['tier_price_id_' . $i] = $tierPrice['price_id']; + $result['tier_website_id_' . $i] = $tierPrice['website_id']; + $result['tier_all_groups_' . $i] = $tierPrice['all_groups']; + $result['tier_cust_group_' . $i] = $tierPrice['cust_group'] == GroupInterface::CUST_GROUP_ALL ? '' : $tierPrice['cust_group']; - $result['tier_price_qty_'.$i] = $tierPrice['price_qty']; - $result['tier_website_price_'.$i] = $tierPrice['website_price']; - $result['tier_price_'.$i] = $tierPrice['price']; + $result['tier_price_qty_' . $i] = $tierPrice['price_qty']; + $result['tier_website_price_' . $i] = $tierPrice['website_price']; + $result['tier_price_' . $i] = $tierPrice['price']; $i++; } } @@ -293,6 +319,8 @@ protected function getProductMediaGalleryData($media, $roles) } /** + * Get media role image. + * * @param string $file * @param array $roles * @return string @@ -303,6 +331,8 @@ protected function getMediaRoleImage($file, $roles) } /** + * Get media role small image. + * * @param string $file * @param array $roles * @return string @@ -313,6 +343,8 @@ protected function getMediaRoleSmallImage($file, $roles) } /** + * Get media role thumbnail. + * * @param string $file * @param array $roles * @return string @@ -323,6 +355,8 @@ protected function getMediaRoleThumbnail($file, $roles) } /** + * Get media role swatch image. + * * @param string $file * @param array $roles * @return string @@ -364,9 +398,11 @@ protected function getProductPriceData($productId, $storeId, array $priceIndexDa $result = []; if (array_key_exists($productId, $priceIndexData)) { $productPriceIndexData = $priceIndexData[$productId]; - $websiteId = $this->storeManager->getStore($storeId)->getWebsiteId(); foreach ($productPriceIndexData as $customerGroupId => $price) { - $fieldName = 'price_' . $customerGroupId . '_' . $websiteId; + $fieldName = $this->fieldMapper->getFieldName( + 'price', + ['customerGroupId' => $customerGroupId, 'websiteId' => $storeId] + ); $result[$fieldName] = sprintf('%F', $price); } } @@ -393,13 +429,23 @@ protected function getProductCategoryData($productId, array $categoryIndexData) if (array_key_exists($productId, $categoryIndexData)) { $indexData = $categoryIndexData[$productId]; foreach ($indexData as $categoryData) { - $categoryIds[] = (int) $categoryData['id']; + $categoryIds[] = (int)$categoryData['id']; } if (count($categoryIds)) { $result = ['category_ids' => implode(' ', $categoryIds)]; + $positionAttribute = $this->attributeAdapterProvider->getByAttributeCode('position'); + $categoryNameAttribute = $this->attributeAdapterProvider->getByAttributeCode('category_name'); foreach ($indexData as $data) { - $result['position_category_' . $data['id']] = $data['position']; - $result['name_category_' . $data['id']] = $data['name']; + $categoryPositionKey = $this->fieldNameResolver->getFieldName( + $positionAttribute, + ['categoryId' => $data['id']] + ); + $categoryNameKey = $this->fieldNameResolver->getFieldName( + $categoryNameAttribute, + ['categoryId' => $data['id']] + ); + $result[$categoryPositionKey] = $data['position']; + $result[$categoryNameKey] = $data['name']; } } } diff --git a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/Converter.php b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/Converter.php new file mode 100644 index 0000000000000..b7f21696162dd --- /dev/null +++ b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/Converter.php @@ -0,0 +1,45 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\ConverterInterface; + +/** + * Field type converter from internal index type to elastic service. + */ +class Converter implements ConverterInterface +{ + /** + * Text flags for Elasticsearch index value + */ + private const ES_NO_INDEX = false; + + /** + * Mapping between internal data types and elastic service. + * + * @var array + */ + private $mapping = [ + 'no_index' => self::ES_NO_INDEX, + ]; + + /** + * Get service field index type for elasticsearch 5. + * + * @param string $internalType + * @return string|boolean + * @throws \DomainException + */ + public function convert(string $internalType) + { + if (!isset($this->mapping[$internalType])) { + throw new \DomainException(sprintf('Unsupported internal field index type: %s', $internalType)); + } + return $this->mapping[$internalType]; + } +} diff --git a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/IndexResolver.php b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/IndexResolver.php new file mode 100644 index 0000000000000..954deaec639ef --- /dev/null +++ b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/IndexResolver.php @@ -0,0 +1,87 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\ResolverInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\ConverterInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface + as FieldTypeConverterInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ResolverInterface + as FieldTypeResolver; + +/** + * Field index resolver that provides index type for the attribute in mapping. + * For example, we need to set ‘no’/false in the case when attribute must be present in index data, + * but stay as not indexable. + */ +class IndexResolver implements ResolverInterface +{ + /** + * @var ConverterInterface + */ + private $converter; + + /** + * @var FieldTypeConverterInterface + */ + private $fieldTypeConverter; + + /** + * @var FieldTypeResolver + */ + private $fieldTypeResolver; + + /** + * @param ConverterInterface $converter + * @param FieldTypeConverterInterface $fieldTypeConverter + * @param FieldTypeResolver $fieldTypeResolver + */ + public function __construct( + ConverterInterface $converter, + FieldTypeConverterInterface $fieldTypeConverter, + FieldTypeResolver $fieldTypeResolver + ) { + $this->converter = $converter; + $this->fieldTypeConverter = $fieldTypeConverter; + $this->fieldTypeResolver = $fieldTypeResolver; + } + + /** + * @inheritdoc + */ + public function getFieldIndex(AttributeAdapter $attribute) + { + $index = null; + if (!$attribute->isSearchable() + && !$attribute->isAlwaysIndexable() + && ($this->isStringServiceFieldType($attribute) || $attribute->isComplexType()) + && !(($attribute->isIntegerType() || $attribute->isBooleanType()) + && !$attribute->isUserDefined()) + && !$attribute->isFloatType() + ) { + $index = $this->converter->convert(ConverterInterface::INTERNAL_NO_INDEX_VALUE); + } + + return $index; + } + + /** + * Check if service field type for field set as 'string' + * + * @param AttributeAdapter $attribute + * @return bool + */ + private function isStringServiceFieldType(AttributeAdapter $attribute): bool + { + $serviceFieldType = $this->fieldTypeResolver->getFieldType($attribute); + $stringTypeKey = $this->fieldTypeConverter->convert(FieldTypeConverterInterface::INTERNAL_DATA_TYPE_STRING); + + return $serviceFieldType === $stringTypeKey; + } +} diff --git a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Converter.php b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Converter.php new file mode 100644 index 0000000000000..1f6e05c9e02fc --- /dev/null +++ b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Converter.php @@ -0,0 +1,54 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface; + +/** + * Field type converter from internal data types to elastic service. + */ +class Converter implements ConverterInterface +{ + /**#@+ + * Text flags for Elasticsearch field types + */ + private const ES_DATA_TYPE_TEXT = 'text'; + private const ES_DATA_TYPE_KEYWORD = 'keyword'; + private const ES_DATA_TYPE_FLOAT = 'float'; + private const ES_DATA_TYPE_INT = 'integer'; + private const ES_DATA_TYPE_DATE = 'date'; + /**#@-*/ + + /** + * Mapping between internal data types and elastic service. + * + * @var array + */ + private $mapping = [ + self::INTERNAL_DATA_TYPE_STRING => self::ES_DATA_TYPE_TEXT, + self::INTERNAL_DATA_TYPE_KEYWORD => self::ES_DATA_TYPE_KEYWORD, + self::INTERNAL_DATA_TYPE_FLOAT => self::ES_DATA_TYPE_FLOAT, + self::INTERNAL_DATA_TYPE_INT => self::ES_DATA_TYPE_INT, + self::INTERNAL_DATA_TYPE_DATE => self::ES_DATA_TYPE_DATE, + ]; + + /** + * Get service field type for elasticsearch 5. + * + * @param string $internalType + * @return string + * @throws \DomainException + */ + public function convert(string $internalType): string + { + if (!isset($this->mapping[$internalType])) { + throw new \DomainException(sprintf('Unsupported internal field type: %s', $internalType)); + } + return $this->mapping[$internalType]; + } +} diff --git a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/CompositeResolver.php b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/CompositeResolver.php new file mode 100644 index 0000000000000..fed36ff6b1c8f --- /dev/null +++ b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/CompositeResolver.php @@ -0,0 +1,56 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ResolverInterface; + +/** + * Composite resolver for resolving field type. + */ +class CompositeResolver implements ResolverInterface +{ + /** + * @var ResolverInterface[] + */ + private $items; + + /** + * @param ResolverInterface[] $items + */ + public function __construct(array $items) + { + foreach ($items as $item) { + if (!$item instanceof ResolverInterface) { + throw new \InvalidArgumentException( + sprintf('Instance of the field type resolver is expected, got %s instead.', get_class($item)) + ); + } + } + $this->items = $items; + } + + /** + * Get field type. + * + * @param AttributeAdapter $attribute + * @return string + */ + public function getFieldType(AttributeAdapter $attribute): ?string + { + $result = null; + foreach ($this->items as $item) { + $result = $item->getFieldType($attribute); + if (null !== $result) { + break; + } + } + + return $result; + } +} diff --git a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerType.php b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerType.php new file mode 100644 index 0000000000000..e5c8dd48c7af3 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerType.php @@ -0,0 +1,56 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ResolverInterface; + +/** + * Integer type resolver. + */ +class IntegerType implements ResolverInterface +{ + /** + * @var ConverterInterface + */ + private $fieldTypeConverter; + + /** + * @var array + */ + private $integerTypeAttributes; + + /** + * @param ConverterInterface $fieldTypeConverter + * @param array $integerTypeAttributes + */ + public function __construct(ConverterInterface $fieldTypeConverter, $integerTypeAttributes = ['category_ids']) + { + $this->fieldTypeConverter = $fieldTypeConverter; + $this->integerTypeAttributes = $integerTypeAttributes; + } + + /** + * Get integer field type. + * + * @param AttributeAdapter $attribute + * @return string + */ + public function getFieldType(AttributeAdapter $attribute): ?string + { + if (in_array($attribute->getAttributeCode(), $this->integerTypeAttributes, true) + || (($attribute->isIntegerType() || $attribute->isBooleanType()) + && !$attribute->isUserDefined()) + ) { + return $this->fieldTypeConverter->convert(ConverterInterface::INTERNAL_DATA_TYPE_INT); + } + + return null; + } +} diff --git a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/KeywordType.php b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/KeywordType.php new file mode 100644 index 0000000000000..e522d4ae5e070 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/KeywordType.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ResolverInterface; + +/** + * Keyword type resolver. + */ +class KeywordType implements ResolverInterface +{ + /** + * @var ConverterInterface + */ + private $fieldTypeConverter; + + /** + * @param ConverterInterface $fieldTypeConverter + */ + public function __construct(ConverterInterface $fieldTypeConverter) + { + $this->fieldTypeConverter = $fieldTypeConverter; + } + + /** + * Get field type. + * + * @param AttributeAdapter $attribute + * @return string + */ + public function getFieldType(AttributeAdapter $attribute): ?string + { + if ($attribute->isComplexType() + || (!$attribute->isSearchable() && !$attribute->isAlwaysIndexable() && $attribute->isFilterable()) + ) { + return $this->fieldTypeConverter->convert(ConverterInterface::INTERNAL_DATA_TYPE_KEYWORD); + } + + return null; + } +} diff --git a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/ProductFieldMapper.php b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/ProductFieldMapper.php index be198e7190ec9..5aea87e5e6ae1 100644 --- a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/ProductFieldMapper.php +++ b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/ProductFieldMapper.php @@ -3,11 +3,15 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper; -use Magento\Catalog\Api\Data\ProductAttributeInterface; use Magento\Eav\Model\Config; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeProvider; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProviderInterface; use Magento\Elasticsearch\Model\Adapter\FieldMapperInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\ResolverInterface; +use Magento\Framework\App\ObjectManager; use Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldType; use Magento\Framework\Registry; use Magento\Store\Model\StoreManagerInterface as StoreManager; @@ -19,53 +23,81 @@ class ProductFieldMapper implements FieldMapperInterface { /** + * @deprecated * @var Config */ protected $eavConfig; /** + * @deprecated * @var FieldType */ protected $fieldType; /** + * @deprecated * @var CustomerSession */ protected $customerSession; /** - * Store manager - * + * @deprecated * @var StoreManager */ protected $storeManager; /** - * Core registry - * + * @deprecated * @var Registry */ protected $coreRegistry; + /** + * @var AttributeProvider + */ + private $attributeAdapterProvider; + + /** + * @var ResolverInterface + */ + private $fieldNameResolver; + + /** + * @var FieldProviderInterface + */ + private $fieldProvider; + /** * @param Config $eavConfig * @param FieldType $fieldType * @param CustomerSession $customerSession * @param StoreManager $storeManager * @param Registry $coreRegistry + * @param ResolverInterface|null $fieldNameResolver + * @param AttributeProvider|null $attributeAdapterProvider + * @param FieldProviderInterface|null $fieldProvider */ public function __construct( Config $eavConfig, FieldType $fieldType, CustomerSession $customerSession, StoreManager $storeManager, - Registry $coreRegistry + Registry $coreRegistry, + ResolverInterface $fieldNameResolver = null, + AttributeProvider $attributeAdapterProvider = null, + FieldProviderInterface $fieldProvider = null ) { $this->eavConfig = $eavConfig; $this->fieldType = $fieldType; $this->customerSession = $customerSession; $this->storeManager = $storeManager; $this->coreRegistry = $coreRegistry; + $this->fieldNameResolver = $fieldNameResolver ?: ObjectManager::getInstance() + ->get(ResolverInterface::class); + $this->attributeAdapterProvider = $attributeAdapterProvider ?: ObjectManager::getInstance() + ->get(AttributeProvider::class); + $this->fieldProvider = $fieldProvider ?: ObjectManager::getInstance() + ->get(FieldProviderInterface::class); } /** @@ -77,35 +109,8 @@ public function __construct( */ public function getFieldName($attributeCode, $context = []) { - $attribute = $this->eavConfig->getAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, $attributeCode); - if (!$attribute || in_array($attributeCode, ['id', 'sku', 'store_id', 'visibility'], true)) { - return $attributeCode; - } - if ($attributeCode === 'price') { - return $this->getPriceFieldName($context); - } - if ($attributeCode === 'position') { - return $this->getPositionFiledName($context); - } - $fieldType = $this->fieldType->getFieldType($attribute); - $frontendInput = $attribute->getFrontendInput(); - if (empty($context['type'])) { - $fieldName = $attributeCode; - } elseif ($context['type'] === FieldMapperInterface::TYPE_FILTER) { - if ($fieldType === FieldType::ES_DATA_TYPE_TEXT) { - return $this->getFieldName( - $attributeCode, - array_merge($context, ['type' => FieldMapperInterface::TYPE_QUERY]) - ); - } - $fieldName = $attributeCode; - } elseif ($context['type'] === FieldMapperInterface::TYPE_QUERY) { - $fieldName = $this->getQueryTypeFieldName($frontendInput, $fieldType, $attributeCode); - } else { - $fieldName = 'sort_' . $attributeCode; - } - - return $fieldName; + $attributeAdapter = $this->attributeAdapterProvider->getByAttributeCode($attributeCode); + return $this->fieldNameResolver->getFieldName($attributeAdapter, $context); } /** @@ -113,139 +118,9 @@ public function getFieldName($attributeCode, $context = []) * * @param array $context * @return array - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function getAllAttributesTypes($context = []) { - $attributeCodes = $this->eavConfig->getEntityAttributeCodes(ProductAttributeInterface::ENTITY_TYPE_CODE); - $allAttributes = []; - // List of attributes which are required to be indexable - $alwaysIndexableAttributes = [ - 'category_ids', - 'visibility', - ]; - - foreach ($attributeCodes as $attributeCode) { - $attribute = $this->eavConfig->getAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, $attributeCode); - - $allAttributes[$attributeCode] = [ - 'type' => $this->fieldType->getFieldType($attribute), - ]; - - if (!$attribute->getIsSearchable() && !$this->isAttributeUsedInAdvancedSearch($attribute) - && !in_array($attributeCode, $alwaysIndexableAttributes, true) - ) { - if ($attribute->getIsFilterable() || $attribute->getIsFilterableInSearch()) { - $allAttributes[$attributeCode]['type'] = FieldType::ES_DATA_TYPE_KEYWORD; - } else if ($allAttributes[$attributeCode]['type'] === FieldType::ES_DATA_TYPE_TEXT) { - $allAttributes[$attributeCode]['index'] = false; - } - } else if ($attributeCode == "category_ids") { - $allAttributes[$attributeCode] = [ - 'type' => FieldType::ES_DATA_TYPE_INT, - ]; - } - - if ($attribute->usesSource() - || $attribute->getFrontendInput() === 'select' - || $attribute->getFrontendInput() === 'multiselect' - ) { - $allAttributes[$attributeCode]['type'] = FieldType::ES_DATA_TYPE_KEYWORD; - - $allAttributes[$attributeCode . '_value'] = [ - 'type' => FieldType::ES_DATA_TYPE_TEXT, - ]; - } - } - - return $allAttributes; - } - - /** - * Is attribute used in advanced search. - * - * @param Object $attribute - * @return bool - */ - protected function isAttributeUsedInAdvancedSearch($attribute) - { - return $attribute->getIsVisibleInAdvancedSearch() - || $attribute->getIsFilterable() - || $attribute->getIsFilterableInSearch(); - } - - /** - * Get refined field name. - * - * @param string $frontendInput - * @param string $fieldType - * @param string $attributeCode - * @return string - */ - protected function getRefinedFieldName($frontendInput, $fieldType, $attributeCode) - { - switch ($frontendInput) { - case 'select': - case 'multiselect': - return in_array($fieldType, ['text','integer'], true) ? $attributeCode . '_value' : $attributeCode; - case 'boolean': - return $fieldType === 'integer' ? $attributeCode . '_value' : $attributeCode; - default: - return $attributeCode; - } - } - - /** - * Get query type field name. - * - * @param string $frontendInput - * @param string $fieldType - * @param string $attributeCode - * @return string - */ - protected function getQueryTypeFieldName($frontendInput, $fieldType, $attributeCode) - { - if ($attributeCode === '*') { - $fieldName = '_all'; - } else { - $fieldName = $this->getRefinedFieldName($frontendInput, $fieldType, $attributeCode); - } - return $fieldName; - } - - /** - * Get "position" field name - * - * @param array $context - * @return string - */ - protected function getPositionFiledName($context) - { - if (isset($context['categoryId'])) { - $category = $context['categoryId']; - } else { - $category = $this->coreRegistry->registry('current_category') - ? $this->coreRegistry->registry('current_category')->getId() - : $this->storeManager->getStore()->getRootCategoryId(); - } - return 'position_category_' . $category; - } - - /** - * Prepare price field name for search engine - * - * @param array $context - * @return string - */ - protected function getPriceFieldName($context) - { - $customerGroupId = !empty($context['customerGroupId']) - ? $context['customerGroupId'] - : $this->customerSession->getCustomerGroupId(); - $websiteId = !empty($context['websiteId']) - ? $context['websiteId'] - : $this->storeManager->getStore()->getWebsiteId(); - return 'price_' . $customerGroupId . '_' . $websiteId; + return $this->fieldProvider->getFields($context); } } diff --git a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldType.php b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldType.php index 9bf67954cc28f..6891b8c693624 100644 --- a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldType.php +++ b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldType.php @@ -6,15 +6,23 @@ namespace Magento\Elasticsearch\Elasticsearch5\Model\Adapter; use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ResolverInterface; /** * Class FieldType + * * @api * @since 100.1.0 + * + * @deprecated This class provide not full data about field type. Only basic rules apply on this class. + * @see ResolverInterface */ class FieldType { /**#@+ + * @deprecated + * @see \Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface + * * Text flags for Elasticsearch field types */ const ES_DATA_TYPE_TEXT = 'text'; @@ -28,7 +36,10 @@ class FieldType /**#@-*/ /** - * Get field type by attribute + * Get field type. + * + * @deprecated + * @see ResolverInterface::getFieldType * * @param AbstractAttribute $attribute * @return string @@ -36,6 +47,7 @@ class FieldType */ public function getFieldType($attribute) { + trigger_error('Class is deprecated', E_USER_DEPRECATED); $backendType = $attribute->getBackendType(); $frontendInput = $attribute->getFrontendInput(); diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/BatchDataMapper/CategoryFieldsProvider.php b/app/code/Magento/Elasticsearch/Model/Adapter/BatchDataMapper/CategoryFieldsProvider.php index e2de4aec717a4..0e130c24e79d3 100644 --- a/app/code/Magento/Elasticsearch/Model/Adapter/BatchDataMapper/CategoryFieldsProvider.php +++ b/app/code/Magento/Elasticsearch/Model/Adapter/BatchDataMapper/CategoryFieldsProvider.php @@ -3,10 +3,14 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Elasticsearch\Model\Adapter\BatchDataMapper; use Magento\Elasticsearch\Model\ResourceModel\Index; use Magento\AdvancedSearch\Model\Adapter\DataMapper\AdditionalFieldsProviderInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeProvider; +use Magento\Framework\App\ObjectManager; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\ResolverInterface; /** * Provide data mapping for categories fields @@ -18,16 +22,35 @@ class CategoryFieldsProvider implements AdditionalFieldsProviderInterface */ private $resourceIndex; + /** + * @var AttributeProvider + */ + private $attributeAdapterProvider; + + /** + * @var ResolverInterface + */ + private $fieldNameResolver; + /** * @param Index $resourceIndex + * @param AttributeProvider|null $attributeAdapterProvider + * @param ResolverInterface|null $fieldNameResolver */ - public function __construct(Index $resourceIndex) - { + public function __construct( + Index $resourceIndex, + AttributeProvider $attributeAdapterProvider = null, + ResolverInterface $fieldNameResolver = null + ) { $this->resourceIndex = $resourceIndex; + $this->attributeAdapterProvider = $attributeAdapterProvider ?: ObjectManager::getInstance() + ->get(AttributeProvider::class); + $this->fieldNameResolver = $fieldNameResolver ?: ObjectManager::getInstance() + ->get(ResolverInterface::class); } /** - * {@inheritdoc} + * @inheritdoc */ public function getFields(array $productIds, $storeId) { @@ -58,9 +81,19 @@ private function getProductCategoryData($productId, array $categoryIndexData) if (count($categoryIds)) { $result = ['category_ids' => implode(' ', $categoryIds)]; + $positionAttribute = $this->attributeAdapterProvider->getByAttributeCode('position'); + $categoryNameAttribute = $this->attributeAdapterProvider->getByAttributeCode('category_name'); foreach ($indexData as $data) { - $result['position_category_' . $data['id']] = $data['position']; - $result['name_category_' . $data['id']] = $data['name']; + $categoryPositionKey = $this->fieldNameResolver->getFieldName( + $positionAttribute, + ['categoryId' => $data['id']] + ); + $categoryNameKey = $this->fieldNameResolver->getFieldName( + $categoryNameAttribute, + ['categoryId' => $data['id']] + ); + $result[$categoryPositionKey] = $data['position']; + $result[$categoryNameKey] = $data['name']; } } } diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/BatchDataMapper/PriceFieldsProvider.php b/app/code/Magento/Elasticsearch/Model/Adapter/BatchDataMapper/PriceFieldsProvider.php index f5e8a23525a07..875d384a20596 100644 --- a/app/code/Magento/Elasticsearch/Model/Adapter/BatchDataMapper/PriceFieldsProvider.php +++ b/app/code/Magento/Elasticsearch/Model/Adapter/BatchDataMapper/PriceFieldsProvider.php @@ -3,12 +3,16 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Elasticsearch\Model\Adapter\BatchDataMapper; use Magento\Elasticsearch\Model\ResourceModel\Index; use Magento\Store\Model\StoreManagerInterface; use Magento\AdvancedSearch\Model\Adapter\DataMapper\AdditionalFieldsProviderInterface; use Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeProvider; +use Magento\Framework\App\ObjectManager; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\ResolverInterface; /** * Provide data mapping for price fields @@ -30,23 +34,41 @@ class PriceFieldsProvider implements AdditionalFieldsProviderInterface */ private $storeManager; + /** + * @var AttributeProvider + */ + private $attributeAdapterProvider; + + /** + * @var ResolverInterface + */ + private $fieldNameResolver; + /** * @param Index $resourceIndex * @param DataProvider $dataProvider * @param StoreManagerInterface $storeManager + * @param AttributeProvider|null $attributeAdapterProvider + * @param ResolverInterface|null $fieldNameResolver */ public function __construct( Index $resourceIndex, DataProvider $dataProvider, - StoreManagerInterface $storeManager + StoreManagerInterface $storeManager, + AttributeProvider $attributeAdapterProvider = null, + ResolverInterface $fieldNameResolver = null ) { $this->resourceIndex = $resourceIndex; $this->dataProvider = $dataProvider; $this->storeManager = $storeManager; + $this->attributeAdapterProvider = $attributeAdapterProvider ?: ObjectManager::getInstance() + ->get(AttributeProvider::class); + $this->fieldNameResolver = $fieldNameResolver ?: ObjectManager::getInstance() + ->get(ResolverInterface::class); } /** - * {@inheritdoc} + * @inheritdoc */ public function getFields(array $productIds, $storeId) { @@ -75,8 +97,12 @@ private function getProductPriceData($productId, $websiteId, array $priceIndexDa $result = []; if (array_key_exists($productId, $priceIndexData)) { $productPriceIndexData = $priceIndexData[$productId]; + $priceAttribute = $this->attributeAdapterProvider->getByAttributeCode('price'); foreach ($productPriceIndexData as $customerGroupId => $price) { - $fieldName = 'price_' . $customerGroupId . '_' . $websiteId; + $fieldName = $this->fieldNameResolver->getFieldName( + $priceAttribute, + ['customerGroupId' => $customerGroupId, 'websiteId' => $websiteId] + ); $result[$fieldName] = sprintf('%F', $price); } } diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/DataMapper/ProductDataMapper.php b/app/code/Magento/Elasticsearch/Model/Adapter/DataMapper/ProductDataMapper.php index da37c8d7647d8..24b740b554fcb 100644 --- a/app/code/Magento/Elasticsearch/Model/Adapter/DataMapper/ProductDataMapper.php +++ b/app/code/Magento/Elasticsearch/Model/Adapter/DataMapper/ProductDataMapper.php @@ -5,48 +5,15 @@ */ namespace Magento\Elasticsearch\Model\Adapter\DataMapper; -use Magento\Catalog\Model\ResourceModel\Eav\Attribute; -use Magento\Store\Model\StoreManagerInterface; -use Magento\Customer\Api\Data\GroupInterface; use Magento\Elasticsearch\Model\Adapter\DataMapperInterface; use Magento\Elasticsearch\Elasticsearch5\Model\Adapter\DataMapper\ProductDataMapper as ElasticSearch5ProductDataMapper; /** + * Don't use this product data mapper class. + * * @deprecated 100.2.0 * @see \Magento\Elasticsearch\Model\Adapter\BatchDataMapperInterface */ class ProductDataMapper extends ElasticSearch5ProductDataMapper implements DataMapperInterface { - /** - * Prepare category index data for product - * - * @param int $productId - * @param array $categoryIndexData - * @return array - */ - protected function getProductCategoryData($productId, array $categoryIndexData) - { - $result = []; - $categoryIds = []; - - if (array_key_exists($productId, $categoryIndexData)) { - $indexData = $categoryIndexData[$productId]; - $result = $indexData; - } - - if (array_key_exists($productId, $categoryIndexData)) { - $indexData = $categoryIndexData[$productId]; - foreach ($indexData as $categoryData) { - $categoryIds[] = $categoryData['id']; - } - if (count($categoryIds)) { - $result = ['category_ids' => implode(' ', $categoryIds)]; - foreach ($indexData as $data) { - $result['position_category_' . $data['id']] = $data['position']; - $result['name_category_' . $data['id']] = $data['name']; - } - } - } - return $result; - } } diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/Elasticsearch.php b/app/code/Magento/Elasticsearch/Model/Adapter/Elasticsearch.php index 2f7065cbd63b7..97a76de4b995a 100644 --- a/app/code/Magento/Elasticsearch/Model/Adapter/Elasticsearch.php +++ b/app/code/Magento/Elasticsearch/Model/Adapter/Elasticsearch.php @@ -23,6 +23,11 @@ class Elasticsearch const BULK_ACTION_UPDATE = 'update'; /**#@-*/ + /** + * Buffer for total fields limit in mapping. + */ + private const MAPPING_TOTAL_FIELDS_BUFFER_LIMIT = 1000; + /**#@-*/ protected $connectionManager; @@ -348,13 +353,32 @@ public function updateAlias($storeId, $mappedIndexerId) protected function prepareIndex($storeId, $indexName, $mappedIndexerId) { $this->indexBuilder->setStoreId($storeId); - $this->client->createIndex($indexName, ['settings' => $this->indexBuilder->build()]); + $settings = $this->indexBuilder->build(); + $allAttributeTypes = $this->fieldMapper->getAllAttributesTypes([ + 'entityType' => $mappedIndexerId, + // Use store id instead of website id from context for save existing fields mapping. + // In future websiteId will be eliminated due to index stored per store + 'websiteId' => $storeId + ]); + $settings['index']['mapping']['total_fields']['limit'] = $this->getMappingTotalFieldsLimit($allAttributeTypes); + $this->client->createIndex($indexName, ['settings' => $settings]); $this->client->addFieldsMapping( - $this->fieldMapper->getAllAttributesTypes(['entityType' => $mappedIndexerId]), + $allAttributeTypes, $indexName, $this->clientConfig->getEntityType() ); $this->preparedIndex[$storeId] = $indexName; return $this; } + + /** + * Get total fields limit for mapping. + * + * @param array $allAttributeTypes + * @return int + */ + private function getMappingTotalFieldsLimit(array $allAttributeTypes): int + { + return count($allAttributeTypes) + self::MAPPING_TOTAL_FIELDS_BUFFER_LIMIT; + } } diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/AttributeAdapter.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/AttributeAdapter.php new file mode 100644 index 0000000000000..17ebf9c83903e --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/AttributeAdapter.php @@ -0,0 +1,178 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product; + +use Magento\Framework\Api\CustomAttributesDataInterface; + +/** + * Product attribute adapter for elasticsearch context. + */ +class AttributeAdapter +{ + /** + * @var CustomAttributesDataInterface + */ + private $attribute; + + /** + * @var string + */ + private $attributeCode; + + /** + * @param CustomAttributesDataInterface $attribute + * @param string $attributeCode + */ + public function __construct( + CustomAttributesDataInterface $attribute, + string $attributeCode + ) { + $this->attribute = $attribute; + $this->attributeCode = $attributeCode; + } + + /** + * Check if attribute is filterable. + * + * @return bool + */ + public function isFilterable(): bool + { + return $this->getAttribute()->getIsFilterable() || $this->getAttribute()->getIsFilterableInSearch(); + } + + /** + * Check if attribute is searchable. + * + * @return bool + */ + public function isSearchable(): bool + { + return $this->getAttribute()->getIsSearchable() + || ($this->getAttribute()->getIsVisibleInAdvancedSearch() + || $this->isFilterable()); + } + + /** + * Check if attribute is need to index always. + * + * @return bool + */ + public function isAlwaysIndexable(): bool + { + // List of attributes which are required to be indexable + $alwaysIndexableAttributes = [ + 'category_ids', + 'visibility', + ]; + + return in_array($this->getAttributeCode(), $alwaysIndexableAttributes, true); + } + + /** + * Check if attribute has date/time type. + * + * @return bool + */ + public function isDateTimeType(): bool + { + return in_array($this->getAttribute()->getBackendType(), ['timestamp', 'datetime'], true); + } + + /** + * Check if attribute has float type. + * + * @return bool + */ + public function isFloatType(): bool + { + return $this->getAttribute()->getBackendType() === 'decimal'; + } + + /** + * Check if attribute has integer type. + * + * @return bool + */ + public function isIntegerType(): bool + { + return in_array($this->getAttribute()->getBackendType(), ['int', 'smallint'], true); + } + + /** + * Check if attribute has boolean type. + * + * @return bool + */ + public function isBooleanType(): bool + { + return in_array($this->getAttribute()->getFrontendInput(), ['select', 'boolean'], true) + && $this->getAttribute()->getBackendType() !== 'varchar'; + } + + /** + * Check if attribute has boolean type. + * + * @return bool + */ + public function isComplexType(): bool + { + return in_array($this->getAttribute()->getFrontendInput(), ['select', 'multiselect'], true) + || $this->getAttribute()->usesSource(); + } + + /** + * Check if product attribute is EAV. + * + * @return bool + */ + public function isEavAttribute(): bool + { + return $this->getAttribute() instanceof \Magento\Eav\Api\Data\AttributeInterface; + } + + /** + * Get attribute code. + * + * @return string + */ + public function getAttributeCode(): string + { + return $this->attributeCode; + } + + /** + * Check if attribute is defined by user. + * + * @return string + */ + public function isUserDefined(): string + { + return $this->getAttribute()->getIsUserDefined(); + } + + /** + * Frontend HTML for input element. + * + * @return string + */ + public function getFrontendInput() + { + return $this->getAttribute()->getFrontendInput(); + } + + /** + * Get product attribute instance. + * + * @return CustomAttributesDataInterface|\Magento\Eav\Api\Data\AttributeInterface + */ + private function getAttribute(): CustomAttributesDataInterface + { + return $this->attribute; + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/AttributeAdapter/DummyAttribute.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/AttributeAdapter/DummyAttribute.php new file mode 100644 index 0000000000000..b8c0da53c53e0 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/AttributeAdapter/DummyAttribute.php @@ -0,0 +1,62 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; + +use Magento\Framework\Api\CustomAttributesDataInterface; + +/** + * Dummy class for Not EAV attribute. + * @SuppressWarnings(PHPMD) + */ +class DummyAttribute implements CustomAttributesDataInterface +{ + /** + * Get an attribute value. + * + * @param string $attributeCode + * @return \Magento\Framework\Api\AttributeInterface|null + */ + public function getCustomAttribute($attributeCode) + { + return null; + } + + /** + * Set an attribute value for a given attribute code + * + * @param string $attributeCode + * @param mixed $attributeValue + * @return $this + */ + public function setCustomAttribute($attributeCode, $attributeValue) + { + return $this; + } + + /** + * Retrieve custom attributes values. + * + * @return \Magento\Framework\Api\AttributeInterface[]|null + */ + public function getCustomAttributes() + { + return null; + } + + /** + * Set array of custom attributes + * + * @param \Magento\Framework\Api\AttributeInterface[] $attributes + * @return $this + * @throws \LogicException + */ + public function setCustomAttributes(array $attributes) + { + return $this; + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/AttributeProvider.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/AttributeProvider.php new file mode 100644 index 0000000000000..89c98d29ae03e --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/AttributeProvider.php @@ -0,0 +1,90 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product; + +use Magento\Eav\Model\Config; +use Magento\Catalog\Api\Data\ProductAttributeInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter\DummyAttribute; +use Psr\Log\LoggerInterface; + +/** + * Provide attribute adapter. + */ +class AttributeProvider +{ + /** + * Object Manager instance + * + * @var \Magento\Framework\ObjectManagerInterface + */ + private $objectManager; + + /** + * Instance name to create + * + * @var string + */ + private $instanceName; + + /** + * @var Config + */ + private $eavConfig; + + /** + * @var array + */ + private $cachedPool = []; + + /** + * @var LoggerInterface + */ + private $logger; + + /** + * Factory constructor + * + * @param \Magento\Framework\ObjectManagerInterface $objectManager + * @param Config $eavConfig + * @param LoggerInterface $logger + * @param string $instanceName + */ + public function __construct( + \Magento\Framework\ObjectManagerInterface $objectManager, + Config $eavConfig, + LoggerInterface $logger, + $instanceName = AttributeAdapter::class + ) { + $this->objectManager = $objectManager; + $this->instanceName = $instanceName; + $this->eavConfig = $eavConfig; + $this->logger = $logger; + } + + /** + * @inheritdoc + */ + public function getByAttributeCode(string $attributeCode): AttributeAdapter + { + if (!isset($this->cachedPool[$attributeCode])) { + $attribute = $this->eavConfig->getAttribute( + ProductAttributeInterface::ENTITY_TYPE_CODE, + $attributeCode + ); + if (null === $attribute) { + $attribute = $this->objectManager->create(DummyAttribute::class); + } + $this->cachedPool[$attributeCode] = $this->objectManager->create( + $this->instanceName, + ['attribute' => $attribute, 'attributeCode' => $attributeCode] + ); + } + + return $this->cachedPool[$attributeCode]; + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/CompositeFieldProvider.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/CompositeFieldProvider.php new file mode 100644 index 0000000000000..8038c8c05bc1c --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/CompositeFieldProvider.php @@ -0,0 +1,51 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product; + +/** + * Provide fields for product. + */ +class CompositeFieldProvider implements FieldProviderInterface +{ + /** + * @var FieldProviderInterface[] + */ + private $providers; + + /** + * @param FieldProviderInterface[] $providers + */ + public function __construct(array $providers) + { + foreach ($providers as $provider) { + if (!$provider instanceof FieldProviderInterface) { + throw new \InvalidArgumentException( + sprintf('Instance of the field provider is expected, got %s instead.', get_class($provider)) + ); + } + } + $this->providers = $providers; + } + + /** + * Get fields. + * + * @param array $context + * @return array + */ + public function getFields(array $context = []): array + { + $allAttributes = []; + + foreach ($this->providers as $provider) { + $allAttributes = array_merge($allAttributes, $provider->getFields($context)); + } + + return $allAttributes; + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/DynamicField.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/DynamicField.php new file mode 100644 index 0000000000000..c7e2a4beabb5c --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/DynamicField.php @@ -0,0 +1,139 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider; + +use Magento\Catalog\Api\CategoryListInterface; +use Magento\Customer\Api\GroupRepositoryInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeProvider; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProviderInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface + as FieldTypeConverterInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\ConverterInterface + as IndexTypeConverterInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\ResolverInterface + as FieldNameResolver; +use Magento\Framework\Api\SearchCriteriaBuilder; + +/** + * Provide dynamic fields for product. + */ +class DynamicField implements FieldProviderInterface +{ + /** + * Category list. + * + * @var CategoryListInterface + */ + private $categoryList; + + /** + * Customer group repository. + * + * @var GroupRepositoryInterface + */ + private $groupRepository; + + /** + * Search criteria builder. + * + * @var SearchCriteriaBuilder + */ + private $searchCriteriaBuilder; + + /** + * @var FieldTypeConverterInterface + */ + private $fieldTypeConverter; + + /** + * @var IndexTypeConverterInterface + */ + private $indexTypeConverter; + + /** + * @var AttributeProvider + */ + private $attributeAdapterProvider; + + /** + * @var FieldNameResolver + */ + private $fieldNameResolver; + + /** + * @param FieldTypeConverterInterface $fieldTypeConverter + * @param IndexTypeConverterInterface $indexTypeConverter + * @param GroupRepositoryInterface $groupRepository + * @param SearchCriteriaBuilder $searchCriteriaBuilder + * @param CategoryListInterface $categoryList + * @param FieldNameResolver $fieldNameResolver + * @param AttributeProvider $attributeAdapterProvider + */ + public function __construct( + FieldTypeConverterInterface $fieldTypeConverter, + IndexTypeConverterInterface $indexTypeConverter, + GroupRepositoryInterface $groupRepository, + SearchCriteriaBuilder $searchCriteriaBuilder, + CategoryListInterface $categoryList, + FieldNameResolver $fieldNameResolver, + AttributeProvider $attributeAdapterProvider + ) { + $this->groupRepository = $groupRepository; + $this->searchCriteriaBuilder = $searchCriteriaBuilder; + $this->fieldTypeConverter = $fieldTypeConverter; + $this->indexTypeConverter = $indexTypeConverter; + $this->categoryList = $categoryList; + $this->fieldNameResolver = $fieldNameResolver; + $this->attributeAdapterProvider = $attributeAdapterProvider; + } + + /** + * @inheritdoc + */ + public function getFields(array $context = []): array + { + $allAttributes = []; + $searchCriteria = $this->searchCriteriaBuilder->create(); + $categories = $this->categoryList->getList($searchCriteria)->getItems(); + $positionAttribute = $this->attributeAdapterProvider->getByAttributeCode('position'); + $categoryNameAttribute = $this->attributeAdapterProvider->getByAttributeCode('category_name'); + foreach ($categories as $category) { + $categoryPositionKey = $this->fieldNameResolver->getFieldName( + $positionAttribute, + ['categoryId' => $category->getId()] + ); + $categoryNameKey = $this->fieldNameResolver->getFieldName( + $categoryNameAttribute, + ['categoryId' => $category->getId()] + ); + $allAttributes[$categoryPositionKey] = [ + 'type' => $this->fieldTypeConverter->convert(FieldTypeConverterInterface::INTERNAL_DATA_TYPE_STRING), + 'index' => $this->indexTypeConverter->convert(IndexTypeConverterInterface::INTERNAL_NO_INDEX_VALUE) + ]; + $allAttributes[$categoryNameKey] = [ + 'type' => $this->fieldTypeConverter->convert(FieldTypeConverterInterface::INTERNAL_DATA_TYPE_STRING), + 'index' => $this->indexTypeConverter->convert(IndexTypeConverterInterface::INTERNAL_NO_INDEX_VALUE) + ]; + } + + $groups = $this->groupRepository->getList($searchCriteria)->getItems(); + $priceAttribute = $this->attributeAdapterProvider->getByAttributeCode('price'); + foreach ($groups as $group) { + $groupPriceKey = $this->fieldNameResolver->getFieldName( + $priceAttribute, + ['customerGroupId' => $group->getId(), 'websiteId' => $context['websiteId']] + ); + $allAttributes[$groupPriceKey] = [ + 'type' => $this->fieldTypeConverter->convert(FieldTypeConverterInterface::INTERNAL_DATA_TYPE_FLOAT), + 'store' => true + ]; + } + + return $allAttributes; + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/Converter.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/Converter.php new file mode 100644 index 0000000000000..5abe4972e34d0 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/Converter.php @@ -0,0 +1,43 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex; + +/** + * Field type converter from internal index type to elastic service. + */ +class Converter implements ConverterInterface +{ + /** + * Text flags for Elasticsearch index value + */ + private const ES_NO_INDEX = 'no'; + + /** + * Mapping between internal data types and elastic service. + * + * @var array + */ + private $mapping = [ + 'no_index' => self::ES_NO_INDEX, + ]; + + /** + * Get service field index type for elasticsearch 2. + * + * @param string $internalType + * @return string|boolean + * @throws \DomainException + */ + public function convert(string $internalType) + { + if (!isset($this->mapping[$internalType])) { + throw new \DomainException(sprintf('Unsupported internal field index type: %s', $internalType)); + } + return $this->mapping[$internalType]; + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/ConverterInterface.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/ConverterInterface.php new file mode 100644 index 0000000000000..02c4d29558dad --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/ConverterInterface.php @@ -0,0 +1,28 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex; + +/** + * Field type converter from internal index value to elastic service. + */ +interface ConverterInterface +{ + /**#@+ + * Text flags for internal no index value. + */ + public const INTERNAL_NO_INDEX_VALUE = 'no_index'; + public const INTERNAL_INDEX_VALUE = 'index'; + + /** + * Get service field index type. + * + * @param string $internalType + * @return string|boolean + */ + public function convert(string $internalType); +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/IndexResolver.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/IndexResolver.php new file mode 100644 index 0000000000000..590430a7e2431 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/IndexResolver.php @@ -0,0 +1,44 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; + +/** + * Field index resolver that provides index type for the attribute in mapping. + * For example, we need to set ‘no’/false in the case when attribute must be present in index data, + * but stay as not indexable. + */ +class IndexResolver implements ResolverInterface +{ + /** + * @var ConverterInterface + */ + private $converter; + + /** + * @param ConverterInterface $converter + */ + public function __construct(ConverterInterface $converter) + { + $this->converter = $converter; + } + + /** + * @inheritdoc + */ + public function getFieldIndex(AttributeAdapter $attribute) + { + $index = null; + if (!($attribute->isSearchable() || $attribute->isAlwaysIndexable())) { + $index = $this->converter->convert(ConverterInterface::INTERNAL_NO_INDEX_VALUE); + } + + return $index; + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/ResolverInterface.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/ResolverInterface.php new file mode 100644 index 0000000000000..663b1d865fb52 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/ResolverInterface.php @@ -0,0 +1,24 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; + +/** + * Field index type resolver interface. + */ +interface ResolverInterface +{ + /** + * Get field index. + * + * @param AttributeAdapter $attribute + * @return string|boolean + */ + public function getFieldIndex(AttributeAdapter $attribute); +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/CategoryName.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/CategoryName.php new file mode 100644 index 0000000000000..5824aca6cdd54 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/CategoryName.php @@ -0,0 +1,76 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Framework\Registry; +use Magento\Store\Model\StoreManagerInterface as StoreManager; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\ResolverInterface; +use Magento\Framework\App\ObjectManager; + +/** + * Resolver field name for Category name attribute. + */ +class CategoryName implements ResolverInterface +{ + /** + * @var StoreManager + */ + private $storeManager; + + /** + * @var Registry + */ + private $coreRegistry; + + /** + * @param StoreManager $storeManager + * @param Registry $coreRegistry + */ + public function __construct( + StoreManager $storeManager = null, + Registry $coreRegistry = null + ) { + $this->storeManager = $storeManager ?: ObjectManager::getInstance() + ->get(StoreManager::class); + $this->coreRegistry = $coreRegistry ?: ObjectManager::getInstance() + ->get(Registry::class); + } + + /** + * Get field name. + * + * @param AttributeAdapter $attribute + * @param array $context + * @return string + */ + public function getFieldName(AttributeAdapter $attribute, $context = []): ?string + { + if ($attribute->getAttributeCode() === 'category_name') { + return 'name_category_' . $this->resolveCategoryId($context); + } + + return null; + } + + /** + * @inheritdoc + */ + private function resolveCategoryId($context): int + { + if (isset($context['categoryId'])) { + $id = $context['categoryId']; + } else { + $id = $this->coreRegistry->registry('current_category') + ? $this->coreRegistry->registry('current_category')->getId() + : $this->storeManager->getStore()->getRootCategoryId(); + } + + return (int)$id; + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/CompositeResolver.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/CompositeResolver.php new file mode 100644 index 0000000000000..f1fed3f06fe35 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/CompositeResolver.php @@ -0,0 +1,57 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\ResolverInterface; + +/** + * Composite class for resolving field name. + */ +class CompositeResolver implements ResolverInterface +{ + /** + * @var ResolverInterface[] + */ + private $items; + + /** + * @param ResolverInterface[] $items + */ + public function __construct(array $items) + { + foreach ($items as $item) { + if (!$item instanceof ResolverInterface) { + throw new \InvalidArgumentException( + sprintf('Instance of the field name resolver is expected, got %s instead.', get_class($item)) + ); + } + } + $this->items = $items; + } + + /** + * Get field name. + * + * @param AttributeAdapter $attribute + * @param array $context + * @return string + */ + public function getFieldName(AttributeAdapter $attribute, $context = []): ?string + { + $result = null; + foreach ($this->items as $item) { + $result = $item->getFieldName($attribute, $context); + if (null !== $result) { + break; + } + } + + return $result; + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/DefaultResolver.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/DefaultResolver.php new file mode 100644 index 0000000000000..3208ca7fc6171 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/DefaultResolver.php @@ -0,0 +1,130 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapperInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\ResolverInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ResolverInterface + as FieldTypeResolver; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface + as FieldTypeConverterInterface; + +/** + * Default name resolver. + */ +class DefaultResolver implements ResolverInterface +{ + /** + * @var FieldTypeResolver + */ + private $fieldTypeResolver; + + /** + * @var FieldTypeConverterInterface + */ + private $fieldTypeConverter; + + /** + * @param FieldTypeResolver $fieldTypeResolver + * @param FieldTypeConverterInterface $fieldTypeConverter + */ + public function __construct( + FieldTypeResolver $fieldTypeResolver, + FieldTypeConverterInterface $fieldTypeConverter + ) { + $this->fieldTypeResolver = $fieldTypeResolver; + $this->fieldTypeConverter = $fieldTypeConverter; + } + + /** + * Get field name. + * + * @param AttributeAdapter $attribute + * @param array $context + * @return string + */ + public function getFieldName(AttributeAdapter $attribute, $context = []): ?string + { + $fieldType = $this->fieldTypeResolver->getFieldType($attribute); + $attributeCode = $attribute->getAttributeCode(); + $frontendInput = $attribute->getFrontendInput(); + if (empty($context['type'])) { + $fieldName = $attributeCode; + } elseif ($context['type'] === FieldMapperInterface::TYPE_FILTER) { + if ($this->isStringServiceFieldType($fieldType)) { + return $this->getFieldName( + $attribute, + array_merge($context, ['type' => FieldMapperInterface::TYPE_QUERY]) + ); + } + $fieldName = $attributeCode; + } elseif ($context['type'] === FieldMapperInterface::TYPE_QUERY) { + $fieldName = $this->getQueryTypeFieldName($frontendInput, $fieldType, $attributeCode); + } else { + $fieldName = 'sort_' . $attributeCode; + } + + return $fieldName; + } + + /** + * Check if service field type for field set as 'string' + * + * @param string $serviceFieldType + * @return bool + */ + private function isStringServiceFieldType(string $serviceFieldType): bool + { + $stringTypeKey = $this->fieldTypeConverter->convert(FieldTypeConverterInterface::INTERNAL_DATA_TYPE_STRING); + + return $serviceFieldType === $stringTypeKey; + } + + /** + * Get field name for query type fields. + * + * @param string $frontendInput + * @param string $fieldType + * @param string $attributeCode + * @return string + */ + private function getQueryTypeFieldName($frontendInput, $fieldType, $attributeCode) + { + if ($attributeCode === '*') { + $fieldName = '_all'; + } else { + $fieldName = $this->getRefinedFieldName($frontendInput, $fieldType, $attributeCode); + } + return $fieldName; + } + + /** + * Prepare field name for complex fields. + * + * @param string $frontendInput + * @param string $fieldType + * @param string $attributeCode + * @return string + */ + private function getRefinedFieldName($frontendInput, $fieldType, $attributeCode) + { + $stringTypeKey = $this->fieldTypeConverter->convert(FieldTypeConverterInterface::INTERNAL_DATA_TYPE_STRING); + switch ($frontendInput) { + case 'select': + case 'multiselect': + return in_array($fieldType, [$stringTypeKey, 'integer'], true) + ? $attributeCode . '_value' + : $attributeCode; + case 'boolean': + return $fieldType === 'integer' ? $attributeCode . '_value' : $attributeCode; + default: + return $attributeCode; + } + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/NotEavAttribute.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/NotEavAttribute.php new file mode 100644 index 0000000000000..cbbd15083ee60 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/NotEavAttribute.php @@ -0,0 +1,33 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\ResolverInterface; + +/** + * Resolver field name for not EAV attribute. + */ +class NotEavAttribute implements ResolverInterface +{ + /** + * Get field name for not EAV attributes. + * + * @param AttributeAdapter $attribute + * @param array $context + * @return string + */ + public function getFieldName(AttributeAdapter $attribute, $context = []): ?string + { + if (!$attribute->isEavAttribute()) { + return $attribute->getAttributeCode(); + } + + return null; + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/Position.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/Position.php new file mode 100644 index 0000000000000..044d5d8da9a6c --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/Position.php @@ -0,0 +1,72 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Framework\Registry; +use Magento\Store\Model\StoreManagerInterface as StoreManager; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\ResolverInterface; +use Magento\Framework\App\ObjectManager; + +/** + * Resolver field name for position attribute. + */ +class Position implements ResolverInterface +{ + /** + * @var StoreManager + */ + private $storeManager; + + /** + * @var Registry + */ + private $coreRegistry; + + /** + * @param StoreManager $storeManager + * @param Registry $coreRegistry + */ + public function __construct( + StoreManager $storeManager = null, + Registry $coreRegistry = null + ) { + $this->storeManager = $storeManager ?: ObjectManager::getInstance() + ->get(StoreManager::class); + $this->coreRegistry = $coreRegistry ?: ObjectManager::getInstance() + ->get(Registry::class); + } + + /** + * @inheritdoc + */ + public function getFieldName(AttributeAdapter $attribute, $context = []): ?string + { + if ($attribute->getAttributeCode() === 'position') { + return 'position_category_' . $this->resolveCategoryId($context); + } + + return null; + } + + /** + * @inheritdoc + */ + private function resolveCategoryId($context) + { + if (isset($context['categoryId'])) { + $id = $context['categoryId']; + } else { + $id = $this->coreRegistry->registry('current_category') + ? $this->coreRegistry->registry('current_category')->getId() + : $this->storeManager->getStore()->getRootCategoryId(); + } + + return $id; + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/Price.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/Price.php new file mode 100644 index 0000000000000..12e53ca2bd714 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/Price.php @@ -0,0 +1,63 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver; + +use Magento\Framework\App\ObjectManager; +use Magento\Customer\Model\Session as CustomerSession; +use Magento\Store\Model\StoreManagerInterface as StoreManager; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\ResolverInterface; + +/** + * Resolver field name for price attribute. + */ +class Price implements ResolverInterface +{ + /** + * @var CustomerSession + */ + private $customerSession; + + /** + * @var StoreManager + */ + private $storeManager; + + /** + * @param CustomerSession $customerSession + * @param StoreManager $storeManager + */ + public function __construct( + CustomerSession $customerSession = null, + StoreManager $storeManager = null + ) { + $this->storeManager = $storeManager ?: ObjectManager::getInstance() + ->get(StoreManager::class); + $this->customerSession = $customerSession ?: ObjectManager::getInstance() + ->get(CustomerSession::class); + } + + /** + * @inheritdoc + */ + public function getFieldName(AttributeAdapter $attribute, $context = []): ?string + { + if ($attribute->getAttributeCode() === 'price') { + $customerGroupId = !empty($context['customerGroupId']) + ? $context['customerGroupId'] + : $this->customerSession->getCustomerGroupId(); + $websiteId = !empty($context['websiteId']) + ? $context['websiteId'] + : $this->storeManager->getStore()->getWebsiteId(); + + return 'price_' . $customerGroupId . '_' . $websiteId; + } + + return null; + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/SpecialAttribute.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/SpecialAttribute.php new file mode 100644 index 0000000000000..4fa16db98639e --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/SpecialAttribute.php @@ -0,0 +1,33 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\ResolverInterface; + +/** + * Resolver field name for not special attribute. + */ +class SpecialAttribute implements ResolverInterface +{ + /** + * Get field name for special list of attributes. + * + * @param AttributeAdapter $attribute + * @param array $context + * @return string + */ + public function getFieldName(AttributeAdapter $attribute, $context = []): ?string + { + if (in_array($attribute->getAttributeCode(), ['id', 'sku', 'store_id', 'visibility'], true)) { + return $attribute->getAttributeCode(); + } + + return null; + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/ResolverInterface.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/ResolverInterface.php new file mode 100644 index 0000000000000..3d36e026f70db --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/ResolverInterface.php @@ -0,0 +1,25 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; + +/** + * Field name resolver for preparing field key for elasticsearch mapping by attribute. + */ +interface ResolverInterface +{ + /** + * Get field name. + * + * @param AttributeAdapter $attribute + * @param array $context + * @return string + */ + public function getFieldName(AttributeAdapter $attribute, $context = []): ?string; +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Converter.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Converter.php new file mode 100644 index 0000000000000..88dab83698794 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Converter.php @@ -0,0 +1,51 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType; + +/** + * Field type converter from internal data types to elastic service. + */ +class Converter implements ConverterInterface +{ + /**#@+ + * Text flags for Elasticsearch field types + */ + private const ES_DATA_TYPE_STRING = 'string'; + private const ES_DATA_TYPE_FLOAT = 'float'; + private const ES_DATA_TYPE_INT = 'integer'; + private const ES_DATA_TYPE_DATE = 'date'; + /**#@-*/ + + /** + * Mapping between internal data types and elastic service. + * + * @var array + */ + private $mapping = [ + self::INTERNAL_DATA_TYPE_STRING => self::ES_DATA_TYPE_STRING, + self::INTERNAL_DATA_TYPE_KEYWORD => self::ES_DATA_TYPE_STRING, + self::INTERNAL_DATA_TYPE_FLOAT => self::ES_DATA_TYPE_FLOAT, + self::INTERNAL_DATA_TYPE_INT => self::ES_DATA_TYPE_INT, + self::INTERNAL_DATA_TYPE_DATE => self::ES_DATA_TYPE_DATE, + ]; + + /** + * Get service field type for elasticsearch 2. + * + * @param string $internalType + * @return string + * @throws \DomainException + */ + public function convert(string $internalType): string + { + if (!isset($this->mapping[$internalType])) { + throw new \DomainException(sprintf('Unsupported internal field type: %s', $internalType)); + } + return $this->mapping[$internalType]; + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/ConverterInterface.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/ConverterInterface.php new file mode 100644 index 0000000000000..3e7c3e9b592bd --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/ConverterInterface.php @@ -0,0 +1,33 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType; + +/** + * @api + * Field type converter from internal data types to elastic service. + */ +interface ConverterInterface +{ + /**#@+ + * Text flags for internal field types + */ + public const INTERNAL_DATA_TYPE_STRING = 'string'; + public const INTERNAL_DATA_TYPE_FLOAT = 'float'; + public const INTERNAL_DATA_TYPE_INT = 'integer'; + public const INTERNAL_DATA_TYPE_DATE = 'date'; + public const INTERNAL_DATA_TYPE_KEYWORD = 'keyword'; + /**#@-*/ + + /** + * Get service field type. + * + * @param string $internalType + * @return string + */ + public function convert(string $internalType): string; +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/CompositeResolver.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/CompositeResolver.php new file mode 100644 index 0000000000000..e83502e4fe32e --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/CompositeResolver.php @@ -0,0 +1,56 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ResolverInterface; + +/** + * Composite resolver for resolving field type. + */ +class CompositeResolver implements ResolverInterface +{ + /** + * @var ResolverInterface[] + */ + private $items; + + /** + * @param ResolverInterface[] $items + */ + public function __construct(array $items) + { + foreach ($items as $item) { + if (!$item instanceof ResolverInterface) { + throw new \InvalidArgumentException( + sprintf('Instance of the field type resolver is expected, got %s instead.', get_class($item)) + ); + } + } + $this->items = $items; + } + + /** + * Get field type. + * + * @param AttributeAdapter $attribute + * @return string + */ + public function getFieldType(AttributeAdapter $attribute): ?string + { + $result = null; + foreach ($this->items as $item) { + $result = $item->getFieldType($attribute); + if (null !== $result) { + break; + } + } + + return $result; + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/DateTimeType.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/DateTimeType.php new file mode 100644 index 0000000000000..a4e3c634ce717 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/DateTimeType.php @@ -0,0 +1,46 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ResolverInterface; + +/** + * Date/Time type resolver. + */ +class DateTimeType implements ResolverInterface +{ + /** + * @var ConverterInterface + */ + private $fieldTypeConverter; + + /** + * @param ConverterInterface $fieldTypeConverter + */ + public function __construct(ConverterInterface $fieldTypeConverter) + { + $this->fieldTypeConverter = $fieldTypeConverter; + } + + /** + * Get datetime field type. + * + * @param AttributeAdapter $attribute + * @return string + */ + public function getFieldType(AttributeAdapter $attribute): ?string + { + if ($attribute->isDateTimeType()) { + return $this->fieldTypeConverter->convert(ConverterInterface::INTERNAL_DATA_TYPE_DATE); + } + + return null; + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/DefaultResolver.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/DefaultResolver.php new file mode 100644 index 0000000000000..be4a8cca28814 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/DefaultResolver.php @@ -0,0 +1,42 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ResolverInterface; + +/** + * Default field type resolver. + */ +class DefaultResolver implements ResolverInterface +{ + /** + * @var ConverterInterface + */ + private $fieldTypeConverter; + + /** + * @param ConverterInterface $fieldTypeConverter + */ + public function __construct(ConverterInterface $fieldTypeConverter) + { + $this->fieldTypeConverter = $fieldTypeConverter; + } + + /** + * Get default field type. + * + * @param AttributeAdapter $attribute + * @return string + */ + public function getFieldType(AttributeAdapter $attribute): ?string + { + return $this->fieldTypeConverter->convert(ConverterInterface::INTERNAL_DATA_TYPE_STRING); + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/FloatType.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/FloatType.php new file mode 100644 index 0000000000000..a6681a7f676ba --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/FloatType.php @@ -0,0 +1,46 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ResolverInterface; + +/** + * Float type resolver. + */ +class FloatType implements ResolverInterface +{ + /** + * @var ConverterInterface + */ + private $fieldTypeConverter; + + /** + * @param ConverterInterface $fieldTypeConverter + */ + public function __construct(ConverterInterface $fieldTypeConverter) + { + $this->fieldTypeConverter = $fieldTypeConverter; + } + + /** + * Get float field type. + * + * @param AttributeAdapter $attribute + * @return string + */ + public function getFieldType(AttributeAdapter $attribute): ?string + { + if ($attribute->isFloatType()) { + return $this->fieldTypeConverter->convert(ConverterInterface::INTERNAL_DATA_TYPE_FLOAT); + } + + return null; + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerType.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerType.php new file mode 100644 index 0000000000000..7793f60cd1efc --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerType.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ResolverInterface; + +/** + * Integer type resolver. + */ +class IntegerType implements ResolverInterface +{ + /** + * @var ConverterInterface + */ + private $fieldTypeConverter; + + /** + * @param ConverterInterface $fieldTypeConverter + */ + public function __construct(ConverterInterface $fieldTypeConverter) + { + $this->fieldTypeConverter = $fieldTypeConverter; + } + + /** + * Get integer field type. + * + * @param AttributeAdapter $attribute + * @return string + */ + public function getFieldType(AttributeAdapter $attribute): ?string + { + if (($attribute->isIntegerType() || $attribute->isBooleanType()) + && !$attribute->isUserDefined() + ) { + return $this->fieldTypeConverter->convert(ConverterInterface::INTERNAL_DATA_TYPE_INT); + } + + return null; + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/ResolverInterface.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/ResolverInterface.php new file mode 100644 index 0000000000000..43e512ecb025b --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/ResolverInterface.php @@ -0,0 +1,24 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; + +/** + * Field type resolver interface. + */ +interface ResolverInterface +{ + /** + * Get field type. + * + * @param AttributeAdapter $attribute + * @return string + */ + public function getFieldType(AttributeAdapter $attribute): ?string; +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/StaticField.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/StaticField.php new file mode 100644 index 0000000000000..b5c78cbc28f45 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/StaticField.php @@ -0,0 +1,120 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider; + +use Magento\Eav\Model\Config; +use Magento\Catalog\Api\Data\ProductAttributeInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeProvider; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProviderInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface + as FieldTypeConverterInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\ConverterInterface + as IndexTypeConverterInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ResolverInterface + as FieldTypeResolver; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\ResolverInterface + as FieldIndexResolver; + +/** + * Provide static fields for mapping of product. + */ +class StaticField implements FieldProviderInterface +{ + /** + * @var Config + */ + private $eavConfig; + + /** + * @var FieldTypeConverterInterface + */ + private $fieldTypeConverter; + + /** + * @var IndexTypeConverterInterface + */ + private $indexTypeConverter; + + /** + * @var AttributeProvider + */ + private $attributeAdapterProvider; + + /** + * @var FieldTypeResolver + */ + private $fieldTypeResolver; + + /** + * @var FieldIndexResolver + */ + private $fieldIndexResolver; + + /** + * @param Config $eavConfig + * @param FieldTypeConverterInterface $fieldTypeConverter + * @param IndexTypeConverterInterface $indexTypeConverter + * @param FieldTypeResolver $fieldTypeResolver + * @param FieldIndexResolver $fieldIndexResolver + * @param AttributeProvider $attributeAdapterProvider + */ + public function __construct( + Config $eavConfig, + FieldTypeConverterInterface $fieldTypeConverter, + IndexTypeConverterInterface $indexTypeConverter, + FieldTypeResolver $fieldTypeResolver, + FieldIndexResolver $fieldIndexResolver, + AttributeProvider $attributeAdapterProvider + ) { + $this->eavConfig = $eavConfig; + $this->fieldTypeConverter = $fieldTypeConverter; + $this->indexTypeConverter = $indexTypeConverter; + $this->fieldTypeResolver = $fieldTypeResolver; + $this->fieldIndexResolver = $fieldIndexResolver; + $this->attributeAdapterProvider = $attributeAdapterProvider; + } + + /** + * Get static fields. + * + * @param array $context + * @return array + */ + public function getFields(array $context = []): array + { + $attributes = $this->eavConfig->getEntityAttributes(ProductAttributeInterface::ENTITY_TYPE_CODE); + $allAttributes = []; + + foreach ($attributes as $attribute) { + $attributeAdapter = $this->attributeAdapterProvider->getByAttributeCode($attribute->getAttributeCode()); + $code = $attributeAdapter->getAttributeCode(); + + $allAttributes[$code] = [ + 'type' => $this->fieldTypeResolver->getFieldType($attributeAdapter), + ]; + + $index = $this->fieldIndexResolver->getFieldIndex($attributeAdapter); + if (null !== $index) { + $allAttributes[$code]['index'] = $index; + } + + if ($attributeAdapter->isComplexType()) { + $allAttributes[$code . '_value'] = [ + 'type' => $this->fieldTypeConverter->convert(FieldTypeConverterInterface::INTERNAL_DATA_TYPE_STRING) + ]; + } + } + + $allAttributes['store_id'] = [ + 'type' => $this->fieldTypeConverter->convert(FieldTypeConverterInterface::INTERNAL_DATA_TYPE_STRING), + 'index' => $this->indexTypeConverter->convert(IndexTypeConverterInterface::INTERNAL_NO_INDEX_VALUE), + ]; + + return $allAttributes; + } +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProviderInterface.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProviderInterface.php new file mode 100644 index 0000000000000..aaafb699b33bd --- /dev/null +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProviderInterface.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Model\Adapter\FieldMapper\Product; + +/** + * Product fields provider. + * Provide fields mapping configuration for elasticsearch service of internal product attributes. + */ +interface FieldProviderInterface +{ + /** + * Get fields. + * + * @param array $context + * @return array + */ + public function getFields(array $context = []): array; +} diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/ProductFieldMapper.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/ProductFieldMapper.php index 12645d0341417..657605bbd019b 100644 --- a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/ProductFieldMapper.php +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/ProductFieldMapper.php @@ -5,142 +5,13 @@ */ namespace Magento\Elasticsearch\Model\Adapter\FieldMapper; -use Magento\Catalog\Api\Data\ProductAttributeInterface; -use Magento\Eav\Model\Config; use Magento\Elasticsearch\Model\Adapter\FieldMapperInterface; -use Magento\Framework\Registry; -use Magento\Store\Model\StoreManagerInterface as StoreManager; -use \Magento\Customer\Model\Session as CustomerSession; use Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\ProductFieldMapper as Elasticsearch5ProductFieldMapper; -use Magento\Elasticsearch\Model\Adapter\FieldType; /** * Class ProductFieldMapper */ class ProductFieldMapper extends Elasticsearch5ProductFieldMapper implements FieldMapperInterface { - /** - * @param Config $eavConfig - * @param FieldType $fieldType - * @param CustomerSession $customerSession - * @param StoreManager $storeManager - * @param Registry $coreRegistry - */ - public function __construct( - Config $eavConfig, - FieldType $fieldType, - CustomerSession $customerSession, - StoreManager $storeManager, - Registry $coreRegistry - ) { - $this->eavConfig = $eavConfig; - $this->fieldType = $fieldType; - $this->customerSession = $customerSession; - $this->storeManager = $storeManager; - $this->coreRegistry = $coreRegistry; - } - - /** - * Get field name. - * - * @param string $attributeCode - * @param array $context - * @return string - */ - public function getFieldName($attributeCode, $context = []) - { - $attribute = $this->eavConfig->getAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, $attributeCode); - if (!$attribute || in_array($attributeCode, ['id', 'sku', 'store_id', 'visibility'], true)) { - return $attributeCode; - } - if ($attributeCode === 'price') { - return $this->getPriceFieldName($context); - } - if ($attributeCode === 'position') { - return $this->getPositionFiledName($context); - } - $fieldType = $this->fieldType->getFieldType($attribute); - $frontendInput = $attribute->getFrontendInput(); - if (empty($context['type'])) { - $fieldName = $attributeCode; - } elseif ($context['type'] === FieldMapperInterface::TYPE_FILTER) { - if ($fieldType === 'string') { - return $this->getFieldName( - $attributeCode, - array_merge($context, ['type' => FieldMapperInterface::TYPE_QUERY]) - ); - } - $fieldName = $attributeCode; - } elseif ($context['type'] === FieldMapperInterface::TYPE_QUERY) { - $fieldName = $this->getQueryTypeFieldName($frontendInput, $fieldType, $attributeCode); - } else { - $fieldName = 'sort_' . $attributeCode; - } - - return $fieldName; - } - - /** - * Get all attributes types. - * - * @param array $context - * @return array - */ - public function getAllAttributesTypes($context = []) - { - $attributeCodes = $this->eavConfig->getEntityAttributeCodes(ProductAttributeInterface::ENTITY_TYPE_CODE); - $allAttributes = []; - // List of attributes which are required to be indexable - $alwaysIndexableAttributes = [ - 'category_ids', - 'visibility', - ]; - - foreach ($attributeCodes as $attributeCode) { - $attribute = $this->eavConfig->getAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, $attributeCode); - - $allAttributes[$attributeCode] = [ - 'type' => $this->fieldType->getFieldType($attribute) - ]; - - if (!$attribute->getIsSearchable() && !$this->isAttributeUsedInAdvancedSearch($attribute) - && !in_array($attributeCode, $alwaysIndexableAttributes, true) - ) { - $allAttributes[$attributeCode] = array_merge( - $allAttributes[$attributeCode], - ['index' => 'no'] - ); - } - - if ($attribute->getFrontendInput() === 'select' || $attribute->getFrontendInput() === 'multiselect') { - $allAttributes[$attributeCode . '_value'] = [ - 'type' => FieldType::ES_DATA_TYPE_STRING, - ]; - } - } - - return $allAttributes; - } - - /** - * Get refined field name. - * - * @param string $frontendInput - * @param string $fieldType - * @param string $attributeCode - * @return string - */ - protected function getRefinedFieldName($frontendInput, $fieldType, $attributeCode) - { - switch ($frontendInput) { - case 'select': - case 'multiselect': - return in_array($fieldType, ['string','integer'], true) ? $attributeCode . '_value' : $attributeCode; - case 'boolean': - return $fieldType === 'integer' ? $attributeCode . '_value' : $attributeCode; - default: - return $attributeCode; - } - } } diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldType.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldType.php index 0ad4ad8ec7970..e7d8d0672aaf0 100644 --- a/app/code/Magento/Elasticsearch/Model/Adapter/FieldType.php +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldType.php @@ -6,15 +6,23 @@ namespace Magento\Elasticsearch\Model\Adapter; use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ResolverInterface; /** * Class FieldType + * * @api * @since 100.1.0 + * + * @deprecated This class provide not full data about field type. Only basic rules apply in this class. + * @see ResolverInterface */ class FieldType { /**#@+ + * @deprecated + * @see \Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface + * * Text flags for Elasticsearch field types */ const ES_DATA_TYPE_STRING = 'string'; @@ -27,14 +35,17 @@ class FieldType /**#@-*/ /** - * Get field type by attribute + * Get field type. + * + * @deprecated + * @see ResolverInterface::getFieldType * * @param AbstractAttribute $attribute * @return string - * @since 100.1.0 */ public function getFieldType($attribute) { + trigger_error('Class is deprecated', E_USER_DEPRECATED); $backendType = $attribute->getBackendType(); $frontendInput = $attribute->getFrontendInput(); diff --git a/app/code/Magento/Elasticsearch/SearchAdapter/Dynamic/DataProvider.php b/app/code/Magento/Elasticsearch/SearchAdapter/Dynamic/DataProvider.php index a995667954c7d..cfdab2463311e 100644 --- a/app/code/Magento/Elasticsearch/SearchAdapter/Dynamic/DataProvider.php +++ b/app/code/Magento/Elasticsearch/SearchAdapter/Dynamic/DataProvider.php @@ -211,7 +211,7 @@ public function getAggregation( 'prices' => [ 'histogram' => [ 'field' => $fieldName, - 'interval' => $range, + 'interval' => (float)$range, ], ], ]; diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/IndexResolverTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/IndexResolverTest.php new file mode 100644 index 0000000000000..98284e49ad85d --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/IndexResolverTest.php @@ -0,0 +1,165 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Test\Unit\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\ConverterInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface + as FieldTypeConverterInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ResolverInterface + as FieldTypeResolver; +use Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\IndexResolver; + +/** + * @SuppressWarnings(PHPMD) + */ +class IndexResolverTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var IndexResolver + */ + private $resolver; + + /** + * @var ConverterInterface + */ + private $converter; + + /** + * @var FieldTypeConverterInterface + */ + private $fieldTypeConverter; + + /** + * @var FieldTypeResolver + */ + private $fieldTypeResolver; + + /** + * Set up test environment + * + * @return void + */ + protected function setUp() + { + $this->converter = $this->getMockBuilder(ConverterInterface::class) + ->disableOriginalConstructor() + ->setMethods(['convert']) + ->getMockForAbstractClass(); + $this->fieldTypeConverter = $this->getMockBuilder(FieldTypeConverterInterface::class) + ->disableOriginalConstructor() + ->setMethods(['convert']) + ->getMockForAbstractClass(); + $this->fieldTypeResolver = $this->getMockBuilder(FieldTypeResolver::class) + ->disableOriginalConstructor() + ->setMethods(['getFieldType']) + ->getMockForAbstractClass(); + $objectManager = new ObjectManagerHelper($this); + + $this->resolver = $objectManager->getObject( + IndexResolver::class, + [ + 'converter' => $this->converter, + 'fieldTypeConverter' => $this->fieldTypeConverter, + 'fieldTypeResolver' => $this->fieldTypeResolver, + ] + ); + } + + /** + * @dataProvider getFieldIndexProvider + * @param $isSearchable + * @param $isAlwaysIndexable + * @param $isComplexType + * @param $isIntegerType + * @param $isBooleanType + * @param $isUserDefined + * @param $isFloatType + * @param $serviceFieldType + * @param $expected + * @return void + */ + public function testGetFieldName( + $isSearchable, + $isAlwaysIndexable, + $isComplexType, + $isIntegerType, + $isBooleanType, + $isUserDefined, + $isFloatType, + $serviceFieldType, + $expected + ) { + $this->converter->expects($this->any()) + ->method('convert') + ->willReturn('something'); + $this->fieldTypeResolver->expects($this->any()) + ->method('getFieldType') + ->willReturn($serviceFieldType); + $this->fieldTypeConverter->expects($this->any()) + ->method('convert') + ->willReturn('string'); + $attributeMock = $this->getMockBuilder(AttributeAdapter::class) + ->disableOriginalConstructor() + ->setMethods([ + 'isSearchable', + 'isAlwaysIndexable', + 'isComplexType', + 'isIntegerType', + 'isBooleanType', + 'isUserDefined', + 'isFloatType', + ]) + ->getMock(); + $attributeMock->expects($this->any()) + ->method('isSearchable') + ->willReturn($isSearchable); + $attributeMock->expects($this->any()) + ->method('isAlwaysIndexable') + ->willReturn($isAlwaysIndexable); + $attributeMock->expects($this->any()) + ->method('isComplexType') + ->willReturn($isComplexType); + $attributeMock->expects($this->any()) + ->method('isIntegerType') + ->willReturn($isIntegerType); + $attributeMock->expects($this->any()) + ->method('isBooleanType') + ->willReturn($isBooleanType); + $attributeMock->expects($this->any()) + ->method('isUserDefined') + ->willReturn($isUserDefined); + $attributeMock->expects($this->any()) + ->method('isFloatType') + ->willReturn($isFloatType); + + $this->assertEquals( + $expected, + $this->resolver->getFieldIndex($attributeMock) + ); + } + + /** + * @return array + */ + public function getFieldIndexProvider() + { + return [ + [true, true, true, true, true, true, true, 'string', null], + [false, false, true, false, false, false, false, 'string', 'something'], + [false, false, true, false, false, false, false, 'string', 'something'], + [false, false, false, false, false, false, false, 'string', 'something'], + [false, false, false, false, false, false, false, 'int', null], + [false, false, true, true, false, true, false, 'string', 'something'], + [false, false, true, false, true, true, false, 'string', 'something'], + [false, false, true, false, true, false, false, 'string', null], + [false, false, true, false, true, true, true, 'string', null], + ]; + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerTypeTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerTypeTest.php new file mode 100644 index 0000000000000..39155e4f4fe02 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerTypeTest.php @@ -0,0 +1,105 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace +Magento\Elasticsearch\Test\Unit\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface + as FieldTypeConverterInterface; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\IntegerType; + +/** + * @SuppressWarnings(PHPMD) + */ +class IntegerTypeTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var IntegerType + */ + private $resolver; + + /** + * @var FieldTypeConverterInterface + */ + private $fieldTypeConverter; + + /** + * Set up test environment + * + * @return void + */ + protected function setUp() + { + $this->fieldTypeConverter = $this->getMockBuilder(FieldTypeConverterInterface::class) + ->disableOriginalConstructor() + ->setMethods(['convert']) + ->getMockForAbstractClass(); + + $objectManager = new ObjectManagerHelper($this); + + $this->resolver = $objectManager->getObject( + IntegerType::class, + [ + 'fieldTypeConverter' => $this->fieldTypeConverter, + ] + ); + } + + /** + * @dataProvider getFieldTypeProvider + * @param $attributeCode + * @param $isIntegerType + * @param $isBooleanType + * @param $isUserDefined + * @param $expected + * @return void + */ + public function testGetFieldType($attributeCode, $isIntegerType, $isBooleanType, $isUserDefined, $expected) + { + $attributeMock = $this->getMockBuilder(AttributeAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['getAttributeCode', 'isIntegerType', 'isBooleanType', 'isUserDefined']) + ->getMock(); + $attributeMock->expects($this->any()) + ->method('getAttributeCode') + ->willReturn($attributeCode); + $attributeMock->expects($this->any()) + ->method('isIntegerType') + ->willReturn($isIntegerType); + $attributeMock->expects($this->any()) + ->method('isBooleanType') + ->willReturn($isBooleanType); + $attributeMock->expects($this->any()) + ->method('isUserDefined') + ->willReturn($isUserDefined); + $this->fieldTypeConverter->expects($this->any()) + ->method('convert') + ->willReturn('something'); + + $this->assertEquals( + $expected, + $this->resolver->getFieldType($attributeMock) + ); + } + + /** + * @return array + */ + public function getFieldTypeProvider() + { + return [ + ['category_ids', true, true, true, 'something'], + ['category_ids', false, false, false, 'something'], + ['type', true, false, false, 'something'], + ['type', false, true, false, 'something'], + ['type', true, true, true, ''], + ['type', false, false, true, ''], + ]; + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/KeywordTypeTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/KeywordTypeTest.php new file mode 100644 index 0000000000000..0e33498a16fba --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/KeywordTypeTest.php @@ -0,0 +1,106 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace +Magento\Elasticsearch\Test\Unit\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface + as FieldTypeConverterInterface; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\KeywordType; + +/** + * @SuppressWarnings(PHPMD) + */ +class KeywordTypeTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var KeywordType + */ + private $resolver; + + /** + * @var FieldTypeConverterInterface + */ + private $fieldTypeConverter; + + /** + * Set up test environment + * + * @return void + */ + protected function setUp() + { + $this->fieldTypeConverter = $this->getMockBuilder(FieldTypeConverterInterface::class) + ->disableOriginalConstructor() + ->setMethods(['convert']) + ->getMockForAbstractClass(); + + $objectManager = new ObjectManagerHelper($this); + + $this->resolver = $objectManager->getObject( + KeywordType::class, + [ + 'fieldTypeConverter' => $this->fieldTypeConverter, + ] + ); + } + + /** + * @dataProvider getFieldTypeProvider + * @param $isComplexType + * @param $isSearchable + * @param $isAlwaysIndexable + * @param $isFilterable + * @param $expected + * @return void + */ + public function testGetFieldType($isComplexType, $isSearchable, $isAlwaysIndexable, $isFilterable, $expected) + { + $attributeMock = $this->getMockBuilder(AttributeAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['isComplexType', 'isSearchable', 'isAlwaysIndexable', 'isFilterable']) + ->getMock(); + $attributeMock->expects($this->any()) + ->method('isComplexType') + ->willReturn($isComplexType); + $attributeMock->expects($this->any()) + ->method('isSearchable') + ->willReturn($isSearchable); + $attributeMock->expects($this->any()) + ->method('isAlwaysIndexable') + ->willReturn($isAlwaysIndexable); + $attributeMock->expects($this->any()) + ->method('isFilterable') + ->willReturn($isFilterable); + $this->fieldTypeConverter->expects($this->any()) + ->method('convert') + ->willReturn('something'); + + $this->assertEquals( + $expected, + $this->resolver->getFieldType($attributeMock) + ); + } + + /** + * @return array + */ + public function getFieldTypeProvider() + { + return [ + [true, true, true, true, 'something'], + [true, false, false, false, 'something'], + [true, false, false, true, 'something'], + [false, false, false, true, 'something'], + [false, false, false, false, ''], + [false, false, true, false, ''], + [false, true, false, false, ''], + ]; + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/ProductFieldMapperTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/ProductFieldMapperTest.php deleted file mode 100644 index 6ee32a58698c6..0000000000000 --- a/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/ProductFieldMapperTest.php +++ /dev/null @@ -1,296 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Elasticsearch\Test\Unit\Elasticsearch5\Model\Adapter\FieldMapper; - -use Magento\Catalog\Api\Data\ProductAttributeInterface; -use Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldType; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; - -class ProductFieldMapperTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var \Magento\Elasticsearch\Model\Adapter\FieldMapper\ProductFieldMapper - */ - protected $mapper; - - /** - * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject - */ - protected $eavConfig; - - /** - * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject - */ - protected $coreRegistry; - - /** - * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject - */ - protected $customerSession; - - /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $storeManager; - - /** - * @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute|\PHPUnit_Framework_MockObject_MockObject - */ - protected $eavAttributeResource; - - /** - * @var FieldType|\PHPUnit_Framework_MockObject_MockObject - */ - protected $fieldType; - - /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $store; - - /** - * Set up test environment - * - * @return void - */ - protected function setUp() - { - $this->eavConfig = $this->getMockBuilder(\Magento\Eav\Model\Config::class) - ->disableOriginalConstructor() - ->setMethods(['getEntityType', 'getAttribute', 'getEntityAttributeCodes']) - ->getMock(); - - $this->fieldType = $this->getMockBuilder(FieldType::class) - ->disableOriginalConstructor() - ->setMethods(['getFieldType']) - ->getMock(); - - $this->customerSession = $this->getMockBuilder(\Magento\Customer\Model\Session::class) - ->disableOriginalConstructor() - ->setMethods(['getCustomerGroupId']) - ->getMock(); - - $this->storeManager = $this->storeManager = $this->getMockForAbstractClass( - \Magento\Store\Model\StoreManagerInterface::class, - [], - '', - false - ); - - $this->store = $this->getMockForAbstractClass( - \Magento\Store\Api\Data\StoreInterface::class, - [], - '', - false, - false, - true, - ['getWebsiteId', 'getRootCategoryId'] - ); - - $this->coreRegistry = $this->createMock(\Magento\Framework\Registry::class); - - $objectManager = new ObjectManagerHelper($this); - - $this->eavAttributeResource = $this->createPartialMock( - \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, - [ - '__wakeup', - 'getBackendType', - 'getFrontendInput' - ] - ); - - $this->mapper = $objectManager->getObject( - \Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\ProductFieldMapper::class, - [ - 'eavConfig' => $this->eavConfig, - 'storeManager' => $this->storeManager, - 'fieldType' => $this->fieldType, - 'customerSession' => $this->customerSession, - 'coreRegistry' => $this->coreRegistry - ] - ); - } - - /** - * @dataProvider attributeCodeProvider - * @param string $attributeCode - * @param string $fieldName - * @param string $fieldType - * @param array $context - * - * @return void - */ - public function testGetFieldName($attributeCode, $fieldName, $fieldType, $context = []) - { - $attributeMock = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class) - ->setMethods(['getBackendType', 'getFrontendInput', 'getAttribute']) - ->disableOriginalConstructor() - ->getMock(); - - $this->customerSession->expects($this->any()) - ->method('getCustomerGroupId') - ->willReturn('0'); - - $this->storeManager->expects($this->any()) - ->method('getStore') - ->willReturn($this->store); - $this->store->expects($this->any()) - ->method('getWebsiteId') - ->willReturn('1'); - $this->store->expects($this->any()) - ->method('getRootCategoryId') - ->willReturn('1'); - - $this->eavConfig->expects($this->any())->method('getAttribute') - ->with(ProductAttributeInterface::ENTITY_TYPE_CODE, $attributeCode) - ->willReturn($attributeMock); - - $attributeMock->expects($this->any())->method('getFrontendInput') - ->will($this->returnValue('select')); - - $this->fieldType->expects($this->any())->method('getFieldType') - ->with($attributeMock) - ->willReturn($fieldType); - - $this->assertEquals( - $fieldName, - $this->mapper->getFieldName($attributeCode, $context) - ); - } - - /** - * @return void - */ - public function testGetFieldNameWithoutAttribute() - { - $this->eavConfig->expects($this->any())->method('getAttribute') - ->with(ProductAttributeInterface::ENTITY_TYPE_CODE, 'attr1') - ->willReturn(''); - - $this->assertEquals( - 'attr1', - $this->mapper->getFieldName('attr1', []) - ); - } - - /** - * @dataProvider attributeProvider - * @param string $attributeCode - * @param string $inputType - * @param array $searchAttributes - * @param array $expected - * @return void - */ - public function testGetAllAttributesTypes($attributeCode, $inputType, $searchAttributes, $expected) - { - $attributeMock = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->eavConfig->expects($this->any())->method('getEntityAttributeCodes') - ->with(ProductAttributeInterface::ENTITY_TYPE_CODE) - ->willReturn([$attributeCode]); - - $this->eavConfig->expects($this->any())->method('getAttribute') - ->with(ProductAttributeInterface::ENTITY_TYPE_CODE, $attributeCode) - ->willReturn($attributeMock); - - $this->fieldType->expects($this->once())->method('getFieldType')->willReturn(FieldType::ES_DATA_TYPE_INT); - - $attributeMock->expects($this->any()) - ->method('getIsSearchable') - ->willReturn($searchAttributes['searchable']); - $attributeMock->expects($this->any()) - ->method('getIsFilterable') - ->willReturn($searchAttributes['filterable']); - $attributeMock->expects($this->any()) - ->method('getIsFilterableInSearch') - ->willReturn($searchAttributes['filterableInSearch']); - $attributeMock->expects($this->any()) - ->method('getIsVisibleInAdvancedSearch') - ->willReturn($searchAttributes['advSearch']); - - $attributeMock->expects($this->any())->method('getFrontendInput') - ->will($this->returnValue($inputType)); - - $this->assertEquals( - $expected, - $this->mapper->getAllAttributesTypes() - ); - } - - /** - * @return array - */ - public function attributeCodeProvider() - { - return [ - ['id', 'id', 'text'], - ['status', 'status', 'text'], - ['status', 'status_value', 'text', ['type'=>'default']], - ['price', 'price_0_1', 'text', ['type'=>'default']], - ['position', 'position_category_1', 'text', ['type'=>'default']], - ['price', 'price_2_3', 'text', ['type'=>'default', 'customerGroupId'=>'2', 'websiteId'=>'3']], - ['position', 'position_category_3', 'text', ['type'=>'default', 'categoryId'=>'3']], - ['color', 'color_value', 'text', ['type'=>'text']], - ['description', 'sort_description', 'text', ['type'=>'some']], - ['*', '_all', 'text', ['type'=>'text']], - ['description', 'description_value', 'text', ['type'=>'text']], - ]; - } - - /** - * @return array - */ - public function attributeProvider() - { - return [ - [ - 'category_ids', - 'select', - ['searchable' => false, 'filterable' => false, 'filterableInSearch' => false, 'advSearch' => false], - ['category_ids' => ['type' => 'keyword'], 'category_ids_value' => ['type' => 'text']] - ], - [ - 'attr_code', - 'text', - ['searchable' => false, 'filterable' => false, 'filterableInSearch' => false, 'advSearch' => false], - ['attr_code' => ['type' => 'integer']] - ], - [ - 'attr_code', - 'text', - ['searchable' => '0', 'filterable' => '0', 'filterableInSearch' => '0', 'advSearch' => '0'], - ['attr_code' => ['type' => 'integer']] - ], - [ - 'attr_code', - 'text', - ['searchable' => true, 'filterable' => false, 'filterableInSearch' => false, 'advSearch' => false], - ['attr_code' => ['type' => 'integer']] - ], - [ - 'attr_code', - 'text', - ['searchable' => '1', 'filterable' => '0', 'filterableInSearch' => '0', 'advSearch' => '0'], - ['attr_code' => ['type' => 'integer']] - ], - [ - 'attr_code', - 'text', - ['searchable' => false, 'filterable' => false, 'filterableInSearch' => false, 'advSearch' => true], - ['attr_code' => ['type' => 'integer']] - ], - [ - 'attr_code', - 'text', - ['searchable' => '0', 'filterable' => '0', 'filterableInSearch' => '1', 'advSearch' => '0'], - ['attr_code' => ['type' => 'integer']] - ], - ]; - } -} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldTypeTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldTypeTest.php deleted file mode 100644 index e9ce18ef0d3ff..0000000000000 --- a/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldTypeTest.php +++ /dev/null @@ -1,107 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Elasticsearch\Test\Unit\Elasticsearch5\Model\Adapter; - -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -use PHPUnit_Framework_MockObject_MockObject as MockObject; - -class FieldTypeTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var \Magento\Elasticsearch\Model\Adapter\FieldType - */ - protected $type; - - /** - * @var \Magento\Eav\Model\Config|MockObject - */ - protected $eavConfig; - - /** - * @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute|\PHPUnit_Framework_MockObject_MockObject - */ - protected $eavAttributeResource; - - /** - * Set up test environment. - * - * @return void - */ - protected function setUp() - { - $this->eavConfig = $this->getMockBuilder(\Magento\Eav\Model\Config::class) - ->disableOriginalConstructor() - ->setMethods(['getEntityType', 'getAttribute', 'getEntityAttributeCodes']) - ->getMock(); - - $objectManager = new ObjectManagerHelper($this); - - $this->eavAttributeResource = $this->createPartialMock( - \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, - [ - '__wakeup', - 'getBackendType', - 'getFrontendInput' - ] - ); - - $this->type = $objectManager->getObject( - \Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldType::class, - [ - 'eavConfig' => $this->eavConfig, - ] - ); - } - - /** - * Test getFieldType() method. - * - * @dataProvider attributeTypesProvider - * @param string $attributeCode - * @param string $backendType - * @param string $frontendType - * @param string $expectedFieldType - * @return void - */ - public function testGetFieldType($attributeCode, $backendType, $frontendType, $expectedFieldType) - { - $attributeMock = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class) - ->setMethods(['getBackendType', 'getFrontendInput', 'getAttributeCode']) - ->disableOriginalConstructor() - ->getMock(); - - $attributeMock->expects($this->any())->method('getBackendType') - ->will($this->returnValue($backendType)); - - $attributeMock->expects($this->any())->method('getFrontendInput') - ->will($this->returnValue($frontendType)); - - $attributeMock->expects($this->any())->method('getAttributeCode') - ->will($this->returnValue($attributeCode)); - - $this->assertEquals($expectedFieldType, $this->type->getFieldType($attributeMock)); - } - - /** - * @return array - */ - public static function attributeTypesProvider() - { - return [ - ['attr1', 'static', 'select', 'integer'], - ['attr1', 'static', 'text', 'text'], - ['attr1', 'timestamp', 'select', 'date'], - ['attr1', 'datetime', 'text', 'text'], - ['attr1', 'int', 'select', 'integer'], - ['attr1', 'decimal', 'text', 'float'], - ['attr1', 'varchar', 'select', 'text'], - ['attr1', 'array', 'multiselect', 'text'], - ['price', 'int', 'text', 'integer'], - ['tier_price', 'int', 'text', 'integer'], - ['tier_price', 'smallint', 'text', 'integer'], - ]; - } -} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/AttributeAdapterTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/AttributeAdapterTest.php new file mode 100644 index 0000000000000..9ca65d8e675b9 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/AttributeAdapterTest.php @@ -0,0 +1,387 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Test\Unit\Model\Adapter\FieldMapper\Product; + +use Magento\Framework\Api\CustomAttributesDataInterface; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Framework\Model\AbstractExtensibleModel; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface + as FieldTypeConverterInterface; + +/** + * @SuppressWarnings(PHPMD) + */ +class AttributeAdapterTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var \Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter + */ + private $adapter; + + /** + * @var AbstractExtensibleModel + */ + private $attribute; + + /** + * Set up test environment + * + * @return void + */ + protected function setUp() + { + $this->attribute = $this->getMockBuilder(CustomAttributesDataInterface::class) + ->disableOriginalConstructor() + ->setMethods([ + 'getIsFilterable', + 'getIsFilterableInSearch', + 'getIsSearchable', + 'getIsVisibleInAdvancedSearch', + 'getBackendType', + 'getFrontendInput', + 'usesSource', + ]) + ->getMockForAbstractClass(); + + $objectManager = new ObjectManagerHelper($this); + + $this->adapter = $objectManager->getObject( + \Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter::class, + [ + 'attribute' => $this->attribute, + 'attributeCode' => 'code', + ] + ); + } + + /** + * @dataProvider isFilterableProvider + * @param $isFilterable + * @param $isFilterableInSearch + * @param $expected + * @return void + */ + public function testIsFilterable($isFilterable, $isFilterableInSearch, $expected) + { + $this->attribute + ->method('getIsFilterable') + ->willReturn($isFilterable); + $this->attribute + ->method('getIsFilterableInSearch') + ->willReturn($isFilterableInSearch); + $this->assertEquals( + $expected, + $this->adapter->isFilterable() + ); + } + + /** + * @dataProvider isSearchableProvider + * @param $isSearchable + * @param $isVisibleInAdvancedSearch + * @param $isFilterable + * @param $isFilterableInSearch + * @param $expected + * @return void + */ + public function testIsSearchable( + $isSearchable, + $isVisibleInAdvancedSearch, + $isFilterable, + $isFilterableInSearch, + $expected + ) { + $this->attribute + ->method('getIsSearchable') + ->willReturn($isSearchable); + $this->attribute + ->method('getIsVisibleInAdvancedSearch') + ->willReturn($isVisibleInAdvancedSearch); + $this->attribute + ->method('getIsFilterable') + ->willReturn($isFilterable); + $this->attribute + ->method('getIsFilterableInSearch') + ->willReturn($isFilterableInSearch); + $this->assertEquals( + $expected, + $this->adapter->isSearchable() + ); + } + + /** + * @dataProvider isAlwaysIndexableProvider + * @param $expected + * @return void + */ + public function testIsAlwaysIndexable($expected) + { + $this->assertEquals( + $expected, + $this->adapter->isAlwaysIndexable() + ); + } + + /** + * @dataProvider isDateTimeTypeProvider + * @param $backendType + * @param $expected + * @return void + */ + public function testIsDateTimeType($backendType, $expected) + { + $this->attribute + ->method('getBackendType') + ->willReturn($backendType); + $this->assertEquals( + $expected, + $this->adapter->isDateTimeType() + ); + } + + /** + * @dataProvider isFloatTypeProvider + * @param $backendType + * @param $expected + * @return void + */ + public function testIsFloatType($backendType, $expected) + { + $this->attribute + ->method('getBackendType') + ->willReturn($backendType); + $this->assertEquals( + $expected, + $this->adapter->isFloatType() + ); + } + + /** + * @dataProvider isIntegerTypeProvider + * @param $backendType + * @param $expected + * @return void + */ + public function testIsIntegerType($backendType, $expected) + { + $this->attribute + ->method('getBackendType') + ->willReturn($backendType); + $this->assertEquals( + $expected, + $this->adapter->isIntegerType() + ); + } + + /** + * @dataProvider isBooleanTypeProvider + * @param $frontendInput + * @param $backendType + * @param $expected + * @return void + */ + public function testIsBooleanType($frontendInput, $backendType, $expected) + { + $this->attribute + ->method('getBackendType') + ->willReturn($backendType); + $this->attribute + ->method('getFrontendInput') + ->willReturn($frontendInput); + $this->assertEquals( + $expected, + $this->adapter->isBooleanType() + ); + } + + /** + * @dataProvider isComplexTypeProvider + * @param $frontendInput + * @param $usesSource + * @param $expected + * @return void + */ + public function testIsComplexType($frontendInput, $usesSource, $expected) + { + $this->attribute + ->method('usesSource') + ->willReturn($usesSource); + $this->attribute + ->method('getFrontendInput') + ->willReturn($frontendInput); + $this->assertEquals( + $expected, + $this->adapter->isComplexType() + ); + } + + /** + * @dataProvider isEavAttributeProvider + * @param $expected + * @return void + */ + public function testIsEavAttribute($expected) + { + $this->assertEquals( + $expected, + $this->adapter->isEavAttribute() + ); + } + + /** + * @return array + */ + public function isEavAttributeProvider() + { + return [ + [false], + ]; + } + + /** + * @return array + */ + public function isComplexTypeProvider() + { + return [ + ['select', true, true], + ['multiselect', true, true], + ['multiselect', false, true], + ['int', false, false], + ['int', true, true], + ]; + } + + /** + * @return array + */ + public function isBooleanTypeProvider() + { + return [ + ['select', 'int', true], + ['boolean', 'int', true], + ['boolean', 'varchar', false], + ['select', 'varchar', false], + ['int', 'varchar', false], + ['int', 'int', false], + ]; + } + + /** + * @return array + */ + public function isIntegerTypeProvider() + { + return [ + ['smallint', true], + ['int', true], + ['string', false], + ]; + } + + /** + * @return array + */ + public function isFloatTypeProvider() + { + return [ + ['decimal', true], + ['int', false], + ]; + } + + /** + * @return array + */ + public function isDateTimeTypeProvider() + { + return [ + ['timestamp', true], + ['datetime', true], + ['int', false], + ]; + } + + /** + * @return array + */ + public function isAlwaysIndexableProvider() + { + return [ + [false] + ]; + } + + /** + * @return array + */ + public function isSearchableProvider() + { + return [ + [true, false, false, false, true], + [false, false, false, false, false], + [false, true, false, false, true], + [false, false, true, false, true], + [true, true, true, false, true], + [true, true, false, false, true], + ]; + } + + /** + * @return array + */ + public function isFilterableProvider() + { + return [ + [true, false, true,], + [true, false, true,], + [false, false, false,] + ]; + } + + /** + * @return array + */ + public function isStringServiceFieldTypeProvider() + { + return [ + ['string', 'text', false,], + ['text', 'text', true,] + ]; + } + + /** + * @return array + */ + public function getFieldNameProvider() + { + return [ + ['name', [], 'name'] + ]; + } + + /** + * @return array + */ + public function getFieldTypeProvider() + { + return [ + ['type', 'type'] + ]; + } + + /** + * @return array + */ + public function getFieldIndexProvider() + { + return [ + ['type', 'no', 'no'] + ]; + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/DynamicFieldTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/DynamicFieldTest.php new file mode 100644 index 0000000000000..ba5e97aa14b54 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/DynamicFieldTest.php @@ -0,0 +1,331 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Test\Unit\Model\Adapter\FieldMapper\Product\FieldProvider; + +use Magento\Framework\Api\SearchCriteria; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Catalog\Api\CategoryListInterface; +use Magento\Customer\Api\GroupRepositoryInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeProvider; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface + as FieldTypeConverterInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\ConverterInterface + as IndexTypeConverterInterface; +use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Catalog\Api\Data\CategorySearchResultsInterface; +use Magento\Catalog\Api\Data\CategoryInterface; +use Magento\Customer\Api\Data\GroupSearchResultsInterface; +use Magento\Customer\Api\Data\GroupInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\ResolverInterface + as FieldNameResolver; + +/** + * @SuppressWarnings(PHPMD) + */ +class DynamicFieldTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var \Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\DynamicField + */ + private $provider; + + /** + * @var GroupRepositoryInterface + */ + private $groupRepository; + + /** + * @var SearchCriteriaBuilder + */ + private $searchCriteriaBuilder; + + /** + * @var FieldTypeConverterInterface + */ + private $fieldTypeConverter; + + /** + * @var IndexTypeConverterInterface + */ + private $indexTypeConverter; + + /** + * @var AttributeProvider + */ + private $attributeAdapterProvider; + + /** + * @var CategoryListInterface + */ + private $categoryList; + + /** + * @var FieldNameResolver + */ + private $fieldNameResolver; + + /** + * Set up test environment + * + * @return void + */ + protected function setUp() + { + $this->groupRepository = $this->getMockBuilder(GroupRepositoryInterface::class) + ->disableOriginalConstructor() + ->getMock(); + $this->searchCriteriaBuilder = $this->getMockBuilder(SearchCriteriaBuilder::class) + ->disableOriginalConstructor() + ->getMock(); + $this->fieldTypeConverter = $this->getMockBuilder(FieldTypeConverterInterface::class) + ->disableOriginalConstructor() + ->getMock(); + $this->indexTypeConverter = $this->getMockBuilder(IndexTypeConverterInterface::class) + ->disableOriginalConstructor() + ->getMock(); + $this->attributeAdapterProvider = $this->getMockBuilder(AttributeProvider::class) + ->disableOriginalConstructor() + ->setMethods(['getByAttributeCode', 'getByAttribute']) + ->getMock(); + $this->fieldNameResolver = $this->getMockBuilder(FieldNameResolver::class) + ->disableOriginalConstructor() + ->setMethods(['getFieldName']) + ->getMock(); + $this->categoryList = $this->getMockBuilder(CategoryListInterface::class) + ->disableOriginalConstructor() + ->getMock(); + + $objectManager = new ObjectManagerHelper($this); + + $this->provider = $objectManager->getObject( + \Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\DynamicField::class, + [ + 'groupRepository' => $this->groupRepository, + 'searchCriteriaBuilder' => $this->searchCriteriaBuilder, + 'fieldTypeConverter' => $this->fieldTypeConverter, + 'indexTypeConverter' => $this->indexTypeConverter, + 'attributeAdapterProvider' => $this->attributeAdapterProvider, + 'categoryList' => $this->categoryList, + 'fieldNameResolver' => $this->fieldNameResolver, + ] + ); + } + + /** + * @dataProvider attributeProvider + * @param $complexType + * @param $categoryId + * @param $groupId + * @param array $expected + * @return void + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function testGetAllAttributesTypes( + $complexType, + $categoryId, + $groupId, + $expected + ) { + $searchCriteria = $this->getMockBuilder(SearchCriteria::class) + ->disableOriginalConstructor() + ->getMock(); + $this->searchCriteriaBuilder->expects($this->any()) + ->method('create') + ->willReturn($searchCriteria); + $categorySearchResults = $this->getMockBuilder(CategorySearchResultsInterface::class) + ->disableOriginalConstructor() + ->setMethods(['getItems']) + ->getMockForAbstractClass(); + $groupSearchResults = $this->getMockBuilder(GroupSearchResultsInterface::class) + ->disableOriginalConstructor() + ->setMethods(['getItems']) + ->getMockForAbstractClass(); + $group = $this->getMockBuilder(GroupInterface::class) + ->disableOriginalConstructor() + ->setMethods(['getId']) + ->getMockForAbstractClass(); + $group->expects($this->any()) + ->method('getId') + ->willReturn($groupId); + $groupSearchResults->expects($this->any()) + ->method('getItems') + ->willReturn([$group]); + $category = $this->getMockBuilder(CategoryInterface::class) + ->disableOriginalConstructor() + ->setMethods(['getId']) + ->getMockForAbstractClass(); + $category->expects($this->any()) + ->method('getId') + ->willReturn($categoryId); + $categorySearchResults->expects($this->any()) + ->method('getItems') + ->willReturn([$category]); + $this->categoryList->expects($this->any()) + ->method('getList') + ->willReturn($categorySearchResults); + + $categoryAttributeMock = $this->getMockBuilder(AttributeAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['getAttributeCode']) + ->getMock(); + $categoryAttributeMock->expects($this->any()) + ->method('getAttributeCode') + ->willReturn('category'); + $positionAttributeMock = $this->getMockBuilder(AttributeAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['getAttributeCode']) + ->getMock(); + $positionAttributeMock->expects($this->any()) + ->method('getAttributeCode') + ->willReturn('position'); + + $this->fieldNameResolver->expects($this->any()) + ->method('getFieldName') + ->will($this->returnCallback( + function ($attribute) use ($categoryId) { + static $callCount = []; + $attributeCode = $attribute->getAttributeCode(); + $callCount[$attributeCode] = !isset($callCount[$attributeCode]) ? 1 : ++$callCount[$attributeCode]; + + if ($attributeCode === 'category') { + return 'category_name_' . $categoryId; + } elseif ($attributeCode === 'position') { + return 'position_' . $categoryId; + } elseif ($attributeCode === 'price') { + return 'price_' . $categoryId . '_1'; + } + } + )); + $priceAttributeMock = $this->getMockBuilder(AttributeAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['getAttributeCode']) + ->getMock(); + $priceAttributeMock->expects($this->any()) + ->method('getAttributeCode') + ->willReturn('price'); + $this->indexTypeConverter->expects($this->any()) + ->method('convert') + ->willReturn('no_index'); + $this->groupRepository->expects($this->any()) + ->method('getList') + ->willReturn($groupSearchResults); + $this->attributeAdapterProvider->expects($this->any()) + ->method('getByAttributeCode') + ->with($this->anything()) + ->will($this->returnCallback( + function ($code) use ( + $categoryAttributeMock, + $positionAttributeMock, + $priceAttributeMock + ) { + static $callCount = []; + $callCount[$code] = !isset($callCount[$code]) ? 1 : ++$callCount[$code]; + + if ($code === 'position') { + return $positionAttributeMock; + } elseif ($code === 'category_name') { + return $categoryAttributeMock; + } elseif ($code === 'price') { + return $priceAttributeMock; + } + } + )); + $this->fieldTypeConverter->expects($this->any()) + ->method('convert') + ->with($this->anything()) + ->will($this->returnCallback( + function ($type) use ($complexType) { + static $callCount = []; + $callCount[$type] = !isset($callCount[$type]) ? 1 : ++$callCount[$type]; + + if ($type === 'string') { + return 'string'; + } + if ($type === 'string') { + return 'string'; + } elseif ($type === 'float') { + return 'float'; + } else { + return $complexType; + } + } + )); + + $this->assertEquals( + $expected, + $this->provider->getFields(['websiteId' => 1]) + ); + } + + /** + * @return array + */ + public function attributeProvider() + { + return [ + [ + 'text', + 1, + 1, + [ + 'category_name_1' => [ + 'type' => 'string', + 'index' => 'no_index' + ], + 'position_1' => [ + 'type' => 'string', + 'index' => 'no_index' + ], + 'price_1_1' => [ + 'type' => 'float', + 'store' => true + ] + ] + ], + [ + null, + 1, + 1, + [ + 'category_name_1' => [ + 'type' => 'string', + 'index' => 'no_index' + ], + 'position_1' => [ + 'type' => 'string', + 'index' => 'no_index' + ], + 'price_1_1' => [ + 'type' => 'float', + 'store' => true + ] + ], + ], + [ + null, + 1, + 1, + [ + 'category_name_1' => [ + 'type' => 'string', + 'index' => 'no_index' + ], + 'position_1' => [ + 'type' => 'string', + 'index' => 'no_index' + ], + 'price_1_1' => [ + 'type' => 'float', + 'store' => true + ] + ] + ] + ]; + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/IndexResolverTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/IndexResolverTest.php new file mode 100644 index 0000000000000..86bcfeb06480e --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldIndex/IndexResolverTest.php @@ -0,0 +1,99 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Test\Unit\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\ConverterInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; + +/** + * @SuppressWarnings(PHPMD) + */ +class IndexResolverTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var \Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\IndexResolver + */ + private $resolver; + + /** + * @var ConverterInterface + */ + private $converter; + + /** + * Set up test environment + * + * @return void + */ + protected function setUp() + { + $this->converter = $this->getMockBuilder(ConverterInterface::class) + ->disableOriginalConstructor() + ->setMethods(['convert']) + ->getMockForAbstractClass(); + $objectManager = new ObjectManagerHelper($this); + + $this->resolver = $objectManager->getObject( + \Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\IndexResolver::class, + [ + 'converter' => $this->converter + ] + ); + } + + /** + * @dataProvider getFieldIndexProvider + * @param $isSearchable + * @param $isAlwaysIndexable + * @param $serviceFieldType + * @param $expected + * @return void + */ + public function testGetFieldName( + $isSearchable, + $isAlwaysIndexable, + $serviceFieldType, + $expected + ) { + $this->converter->expects($this->any()) + ->method('convert') + ->willReturn('something'); + $attributeMock = $this->getMockBuilder(AttributeAdapter::class) + ->disableOriginalConstructor() + ->setMethods([ + 'isSearchable', + 'isAlwaysIndexable', + ]) + ->getMock(); + $attributeMock->expects($this->any()) + ->method('isSearchable') + ->willReturn($isSearchable); + $attributeMock->expects($this->any()) + ->method('isAlwaysIndexable') + ->willReturn($isAlwaysIndexable); + + $this->assertEquals( + $expected, + $this->resolver->getFieldIndex($attributeMock, $serviceFieldType) + ); + } + + /** + * @return array + */ + public function getFieldIndexProvider() + { + return [ + [true, true, 'string', null], + [false, false, 'string', 'something'], + [true, false, 'string', null], + [false, true, 'string', null], + ]; + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/CategoryNameTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/CategoryNameTest.php new file mode 100644 index 0000000000000..5ebeac2284435 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/CategoryNameTest.php @@ -0,0 +1,124 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Test\Unit\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver; + +use Magento\Catalog\Api\Data\CategoryInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Framework\Registry; +use Magento\Store\Model\StoreManagerInterface as StoreManager; +use Magento\Store\Api\Data\StoreInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\CategoryName; + +/** + * @SuppressWarnings(PHPMD) + */ +class CategoryNameTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var CategoryName + */ + private $resolver; + + /** + * @var StoreManager + */ + private $storeManager; + + /** + * @var Registry + */ + private $coreRegistry; + + /** + * Set up test environment + * + * @return void + */ + protected function setUp() + { + $this->storeManager = $this->getMockBuilder(StoreManager::class) + ->disableOriginalConstructor() + ->setMethods(['getStore']) + ->getMockForAbstractClass(); + $this->coreRegistry = $this->getMockBuilder(Registry::class) + ->disableOriginalConstructor() + ->setMethods(['registry']) + ->getMock(); + + $objectManager = new ObjectManagerHelper($this); + + $this->resolver = $objectManager->getObject( + CategoryName::class, + [ + 'storeManager' => $this->storeManager, + 'coreRegistry' => $this->coreRegistry, + ] + ); + } + + /** + * @dataProvider getFieldNameProvider + * @param $attributeCode + * @param $context + * @param $fromRegistry + * @param $expected + * @return void + */ + public function testGetFieldName($attributeCode, $context, $fromRegistry, $expected) + { + $attributeMock = $this->getMockBuilder(AttributeAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['getAttributeCode']) + ->getMock(); + $attributeMock->expects($this->any()) + ->method('getAttributeCode') + ->willReturn($attributeCode); + $store = $this->getMockBuilder(StoreInterface::class) + ->disableOriginalConstructor() + ->setMethods(['getRootCategoryId']) + ->getMockForAbstractClass(); + $store->expects($this->any()) + ->method('getRootCategoryId') + ->willReturn(2); + $this->storeManager->expects($this->any()) + ->method('getStore') + ->willReturn($store); + $category = null; + if ($fromRegistry) { + $category = $this->getMockBuilder(CategoryInterface::class) + ->disableOriginalConstructor() + ->setMethods(['getId']) + ->getMockForAbstractClass(); + $category->expects($this->any()) + ->method('getId') + ->willReturn(1); + } + $this->coreRegistry->expects($this->any()) + ->method('registry') + ->willReturn($category); + + $this->assertEquals( + $expected, + $this->resolver->getFieldName($attributeMock, $context) + ); + } + + /** + * @return array + */ + public function getFieldNameProvider() + { + return [ + ['category_name', [], true, 'name_category_1'], + ['category_name', [], false, 'name_category_2'], + ['category_name', ['categoryId' => 3], false, 'name_category_3'], + ['price', ['categoryId' => 3], false, ''], + ]; + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/DefaultResolverTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/DefaultResolverTest.php new file mode 100644 index 0000000000000..4fa99f3bf834d --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/DefaultResolverTest.php @@ -0,0 +1,118 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Test\Unit\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ResolverInterface + as FieldTypeResolver; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface + as FieldTypeConverterInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\DefaultResolver; + +/** + * @SuppressWarnings(PHPMD) + */ +class DefaultResolverTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var DefaultResolver + */ + private $resolver; + + /** + * @var FieldTypeResolver + */ + private $fieldTypeResolver; + + /** + * @var FieldTypeConverterInterface + */ + private $fieldTypeConverter; + + /** + * Set up test environment + * + * @return void + */ + protected function setUp() + { + $objectManager = new ObjectManagerHelper($this); + $this->fieldTypeResolver = $this->getMockBuilder(FieldTypeResolver::class) + ->disableOriginalConstructor() + ->setMethods(['getFieldType']) + ->getMockForAbstractClass(); + $this->fieldTypeConverter = $this->getMockBuilder(FieldTypeConverterInterface::class) + ->disableOriginalConstructor() + ->setMethods(['convert']) + ->getMockForAbstractClass(); + + $this->resolver = $objectManager->getObject( + DefaultResolver::class, + [ + 'fieldTypeResolver' => $this->fieldTypeResolver, + 'fieldTypeConverter' => $this->fieldTypeConverter + ] + ); + } + + /** + * @dataProvider getFieldNameProvider + * @param $fieldType + * @param $attributeCode + * @param $frontendInput + * @param $context + * @param $expected + * @return void + */ + public function testGetFieldName( + $fieldType, + $attributeCode, + $frontendInput, + $context, + $expected + ) { + $this->fieldTypeConverter->expects($this->any()) + ->method('convert') + ->willReturn('string'); + $attributeMock = $this->getMockBuilder(AttributeAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['getAttributeCode', 'getFrontendInput']) + ->getMock(); + $attributeMock->expects($this->any()) + ->method('getAttributeCode') + ->willReturn($attributeCode); + $attributeMock->expects($this->any()) + ->method('getFrontendInput') + ->willReturn($frontendInput); + $this->fieldTypeResolver->expects($this->any()) + ->method('getFieldType') + ->willReturn($fieldType); + + $this->assertEquals( + $expected, + $this->resolver->getFieldName($attributeMock, $context) + ); + } + + /** + * @return array + */ + public function getFieldNameProvider() + { + return [ + ['', 'code', '', [], 'code'], + ['', 'code', '', ['type' => 'default'], 'code'], + ['string', '*', '', ['type' => 'default'], '_all'], + ['', 'code', '', ['type' => 'default'], 'code'], + ['', 'code', 'select', ['type' => 'default'], 'code'], + ['', 'code', 'boolean', ['type' => 'default'], 'code'], + ['', 'code', '', ['type' => 'type'], 'sort_code'], + ]; + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/NotEavAttributeTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/NotEavAttributeTest.php new file mode 100644 index 0000000000000..cdd8dde585a5a --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/NotEavAttributeTest.php @@ -0,0 +1,75 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Test\Unit\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\NotEavAttribute; + +/** + * @SuppressWarnings(PHPMD) + */ +class NotEavAttributeTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var NotEavAttribute + */ + private $resolver; + + /** + * Set up test environment + * + * @return void + */ + protected function setUp() + { + $objectManager = new ObjectManagerHelper($this); + + $this->resolver = $objectManager->getObject( + NotEavAttribute::class + ); + } + + /** + * @dataProvider getFieldNameProvider + * @param $attributeCode + * @param $isEavAttribute + * @param $context + * @param $expected + * @return void + */ + public function testGetFieldName($attributeCode, $isEavAttribute, $context, $expected) + { + $attributeMock = $this->getMockBuilder(AttributeAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['isEavAttribute', 'getAttributeCode']) + ->getMock(); + $attributeMock->expects($this->any()) + ->method('isEavAttribute') + ->willReturn($isEavAttribute); + $attributeMock->expects($this->any()) + ->method('getAttributeCode') + ->willReturn($attributeCode); + + $this->assertEquals( + $expected, + $this->resolver->getFieldName($attributeMock, $context) + ); + } + + /** + * @return array + */ + public function getFieldNameProvider() + { + return [ + ['code', true, [], ''], + ['code', false, [], 'code'], + ]; + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/PositionTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/PositionTest.php new file mode 100644 index 0000000000000..dcfd4d02988da --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/PositionTest.php @@ -0,0 +1,123 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Test\Unit\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver; + +use Magento\Catalog\Api\Data\CategoryInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Framework\Registry; +use Magento\Store\Model\StoreManagerInterface as StoreManager; +use Magento\Store\Api\Data\StoreInterface; + +/** + * @SuppressWarnings(PHPMD) + */ +class PositionTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var \Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\Position + */ + private $resolver; + + /** + * @var StoreManager + */ + private $storeManager; + + /** + * @var Registry + */ + private $coreRegistry; + + /** + * Set up test environment + * + * @return void + */ + protected function setUp() + { + $this->storeManager = $this->getMockBuilder(StoreManager::class) + ->disableOriginalConstructor() + ->setMethods(['getStore']) + ->getMockForAbstractClass(); + $this->coreRegistry = $this->getMockBuilder(Registry::class) + ->disableOriginalConstructor() + ->setMethods(['registry']) + ->getMock(); + + $objectManager = new ObjectManagerHelper($this); + + $this->resolver = $objectManager->getObject( + \Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\Position::class, + [ + 'storeManager' => $this->storeManager, + 'coreRegistry' => $this->coreRegistry, + ] + ); + } + + /** + * @dataProvider getFieldNameProvider + * @param $attributeCode + * @param $context + * @param $fromRegistry + * @param $expected + * @return void + */ + public function testGetFieldName($attributeCode, $context, $fromRegistry, $expected) + { + $attributeMock = $this->getMockBuilder(AttributeAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['getAttributeCode']) + ->getMock(); + $attributeMock->expects($this->any()) + ->method('getAttributeCode') + ->willReturn($attributeCode); + $store = $this->getMockBuilder(StoreInterface::class) + ->disableOriginalConstructor() + ->setMethods(['getRootCategoryId']) + ->getMockForAbstractClass(); + $store->expects($this->any()) + ->method('getRootCategoryId') + ->willReturn(2); + $this->storeManager->expects($this->any()) + ->method('getStore') + ->willReturn($store); + $category = null; + if ($fromRegistry) { + $category = $this->getMockBuilder(CategoryInterface::class) + ->disableOriginalConstructor() + ->setMethods(['getId']) + ->getMockForAbstractClass(); + $category->expects($this->any()) + ->method('getId') + ->willReturn(1); + } + $this->coreRegistry->expects($this->any()) + ->method('registry') + ->willReturn($category); + + $this->assertEquals( + $expected, + $this->resolver->getFieldName($attributeMock, $context) + ); + } + + /** + * @return array + */ + public function getFieldNameProvider() + { + return [ + ['position', [], true, 'position_category_1'], + ['position', [], false, 'position_category_2'], + ['position', ['categoryId' => 2], false, 'position_category_2'], + ['price', ['categoryId' => 2], false, ''], + ]; + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/PriceTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/PriceTest.php new file mode 100644 index 0000000000000..244da5a42e00a --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/PriceTest.php @@ -0,0 +1,111 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Test\Unit\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Customer\Model\Session as CustomerSession; +use Magento\Store\Model\StoreManagerInterface as StoreManager; +use Magento\Store\Api\Data\StoreInterface; + +/** + * @SuppressWarnings(PHPMD) + */ +class PriceTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var \Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\Price + */ + private $resolver; + + /** + * @var CustomerSession + */ + private $customerSession; + + /** + * @var StoreManager + */ + private $storeManager; + + /** + * Set up test environment + * + * @return void + */ + protected function setUp() + { + $this->customerSession = $this->getMockBuilder(CustomerSession::class) + ->disableOriginalConstructor() + ->setMethods(['getCustomerGroupId']) + ->getMock(); + $this->storeManager = $this->getMockBuilder(StoreManager::class) + ->disableOriginalConstructor() + ->setMethods(['getStore']) + ->getMockForAbstractClass(); + + $objectManager = new ObjectManagerHelper($this); + + $this->resolver = $objectManager->getObject( + \Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\Price::class, + [ + 'customerSession' => $this->customerSession, + 'storeManager' => $this->storeManager, + ] + ); + } + + /** + * @dataProvider getFieldNameProvider + * @param $attributeCode + * @param $context + * @param $expected + * @return void + */ + public function testGetFieldName($attributeCode, $context, $expected) + { + $attributeMock = $this->getMockBuilder(AttributeAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['getAttributeCode']) + ->getMock(); + $attributeMock->expects($this->any()) + ->method('getAttributeCode') + ->willReturn($attributeCode); + $this->customerSession->expects($this->any()) + ->method('getCustomerGroupId') + ->willReturn(1); + $store = $this->getMockBuilder(StoreInterface::class) + ->disableOriginalConstructor() + ->setMethods(['getWebsiteId']) + ->getMockForAbstractClass(); + $store->expects($this->any()) + ->method('getWebsiteId') + ->willReturn(2); + $this->storeManager->expects($this->any()) + ->method('getStore') + ->willReturn($store); + + $this->assertEquals( + $expected, + $this->resolver->getFieldName($attributeMock, $context) + ); + } + + /** + * @return array + */ + public function getFieldNameProvider() + { + return [ + ['price', [], 'price_1_2'], + ['price', ['customerGroupId' => 2, 'websiteId' => 3], 'price_2_3'], + ['price', ['customerGroupId' => 2], 'price_2_2'], + ['sku', ['customerGroupId' => 2], ''], + ]; + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/SpecialAttributeTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/SpecialAttributeTest.php new file mode 100644 index 0000000000000..dcbf64bbb2005 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver/SpecialAttributeTest.php @@ -0,0 +1,73 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Test\Unit\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\SpecialAttribute; + +/** + * @SuppressWarnings(PHPMD) + */ +class SpecialAttributeTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var SpecialAttribute + */ + private $resolver; + + /** + * Set up test environment + * + * @return void + */ + protected function setUp() + { + $objectManager = new ObjectManagerHelper($this); + + $this->resolver = $objectManager->getObject( + SpecialAttribute::class + ); + } + + /** + * @dataProvider getFieldNameProvider + * @param $attributeCode + * @param $expected + * @return void + */ + public function testGetFieldName($attributeCode, $expected) + { + $attributeMock = $this->getMockBuilder(AttributeAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['getAttributeCode']) + ->getMock(); + $attributeMock->expects($this->any()) + ->method('getAttributeCode') + ->willReturn($attributeCode); + + $this->assertEquals( + $expected, + $this->resolver->getFieldName($attributeMock) + ); + } + + /** + * @return array + */ + public function getFieldNameProvider() + { + return [ + ['id', 'id'], + ['sku', 'sku'], + ['store_id', 'store_id'], + ['visibility', 'visibility'], + ['price', ''], + ]; + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/ConverterTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/ConverterTest.php new file mode 100644 index 0000000000000..842007aee294e --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/ConverterTest.php @@ -0,0 +1,61 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Test\Unit\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType; + +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; + +/** + * @SuppressWarnings(PHPMD) + */ +class ConverterTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var \Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Converter + */ + private $converter; + + /** + * Set up test environment + * + * @return void + */ + protected function setUp() + { + $objectManager = new ObjectManagerHelper($this); + + $this->converter = $objectManager->getObject( + \Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Converter::class + ); + } + + /** + * @dataProvider convertProvider + * @param $internalType + * @param $expected + * @return void + */ + public function testConvert($internalType, $expected) + { + $this->assertEquals( + $expected, + $this->converter->convert($internalType) + ); + } + + /** + * @return array + */ + public function convertProvider() + { + return [ + ['string', 'string'], + ['float', 'float'], + ['integer', 'integer'], + ]; + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/DateTimeTypeTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/DateTimeTypeTest.php new file mode 100644 index 0000000000000..ca474c4bee17d --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/DateTimeTypeTest.php @@ -0,0 +1,88 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Test\Unit\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface + as FieldTypeConverterInterface; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\DateTimeType; + +/** + * @SuppressWarnings(PHPMD) + */ +class DateTimeTypeTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var DateTimeType + */ + private $resolver; + + /** + * @var FieldTypeConverterInterface + */ + private $fieldTypeConverter; + + /** + * Set up test environment + * + * @return void + */ + protected function setUp() + { + $this->fieldTypeConverter = $this->getMockBuilder(FieldTypeConverterInterface::class) + ->disableOriginalConstructor() + ->setMethods(['convert']) + ->getMockForAbstractClass(); + + $objectManager = new ObjectManagerHelper($this); + + $this->resolver = $objectManager->getObject( + DateTimeType::class, + [ + 'fieldTypeConverter' => $this->fieldTypeConverter, + ] + ); + } + + /** + * @dataProvider getFieldTypeProvider + * @param $isDateTimeType + * @param $expected + * @return void + */ + public function testGetFieldType($isDateTimeType, $expected) + { + $attributeMock = $this->getMockBuilder(AttributeAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['isDateTimeType']) + ->getMock(); + $attributeMock->expects($this->any()) + ->method('isDateTimeType') + ->willReturn($isDateTimeType); + $this->fieldTypeConverter->expects($this->any()) + ->method('convert') + ->willReturn('something'); + + $this->assertEquals( + $expected, + $this->resolver->getFieldType($attributeMock) + ); + } + + /** + * @return array + */ + public function getFieldTypeProvider() + { + return [ + [true, 'something'], + [false, ''], + ]; + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/DefaultResolverTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/DefaultResolverTest.php new file mode 100644 index 0000000000000..72b5320a050bd --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/DefaultResolverTest.php @@ -0,0 +1,82 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Test\Unit\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface + as FieldTypeConverterInterface; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\DefaultResolver; + +/** + * @SuppressWarnings(PHPMD) + */ +class DefaultResolverTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var DefaultResolver + */ + private $resolver; + + /** + * @var FieldTypeConverterInterface + */ + private $fieldTypeConverter; + + /** + * Set up test environment + * + * @return void + */ + protected function setUp() + { + $this->fieldTypeConverter = $this->getMockBuilder(FieldTypeConverterInterface::class) + ->disableOriginalConstructor() + ->setMethods(['convert']) + ->getMockForAbstractClass(); + + $objectManager = new ObjectManagerHelper($this); + + $this->resolver = $objectManager->getObject( + DefaultResolver::class, + [ + 'fieldTypeConverter' => $this->fieldTypeConverter, + ] + ); + } + + /** + * @dataProvider getFieldTypeProvider + * @param $expected + * @return void + */ + public function testGetFieldType($expected) + { + $attributeMock = $this->getMockBuilder(AttributeAdapter::class) + ->disableOriginalConstructor() + ->getMock(); + $this->fieldTypeConverter->expects($this->any()) + ->method('convert') + ->willReturn('something'); + + $this->assertEquals( + $expected, + $this->resolver->getFieldType($attributeMock) + ); + } + + /** + * @return array + */ + public function getFieldTypeProvider() + { + return [ + ['something'], + ]; + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/FloatTypeTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/FloatTypeTest.php new file mode 100644 index 0000000000000..c69a6f35b1eb4 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/FloatTypeTest.php @@ -0,0 +1,87 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Test\Unit\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface + as FieldTypeConverterInterface; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; + +/** + * @SuppressWarnings(PHPMD) + */ +class FloatTypeTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var \Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\FloatType + */ + private $resolver; + + /** + * @var FieldTypeConverterInterface + */ + private $fieldTypeConverter; + + /** + * Set up test environment + * + * @return void + */ + protected function setUp() + { + $this->fieldTypeConverter = $this->getMockBuilder(FieldTypeConverterInterface::class) + ->disableOriginalConstructor() + ->setMethods(['convert']) + ->getMockForAbstractClass(); + + $objectManager = new ObjectManagerHelper($this); + + $this->resolver = $objectManager->getObject( + \Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\FloatType::class, + [ + 'fieldTypeConverter' => $this->fieldTypeConverter, + ] + ); + } + + /** + * @dataProvider getFieldTypeProvider + * @param $isFloatType + * @param $expected + * @return void + */ + public function testGetFieldType($isFloatType, $expected) + { + $attributeMock = $this->getMockBuilder(AttributeAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['isFloatType']) + ->getMock(); + $attributeMock->expects($this->any()) + ->method('isFloatType') + ->willReturn($isFloatType); + $this->fieldTypeConverter->expects($this->any()) + ->method('convert') + ->willReturn('something'); + + $this->assertEquals( + $expected, + $this->resolver->getFieldType($attributeMock) + ); + } + + /** + * @return array + */ + public function getFieldTypeProvider() + { + return [ + [true, 'something'], + [false, ''], + ]; + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerTypeTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerTypeTest.php new file mode 100644 index 0000000000000..7570c8971b27b --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerTypeTest.php @@ -0,0 +1,104 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Test\Unit\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver; + +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface + as FieldTypeConverterInterface; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\IntegerType; + +/** + * @SuppressWarnings(PHPMD) + */ +class IntegerTypeTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var IntegerType + */ + private $resolver; + + /** + * @var FieldTypeConverterInterface + */ + private $fieldTypeConverter; + + /** + * Set up test environment + * + * @return void + */ + protected function setUp() + { + $this->fieldTypeConverter = $this->getMockBuilder(FieldTypeConverterInterface::class) + ->disableOriginalConstructor() + ->setMethods(['convert']) + ->getMockForAbstractClass(); + + $objectManager = new ObjectManagerHelper($this); + + $this->resolver = $objectManager->getObject( + IntegerType::class, + [ + 'fieldTypeConverter' => $this->fieldTypeConverter, + ] + ); + } + + /** + * @dataProvider getFieldTypeProvider + * @param $attributeCode + * @param $isIntegerType + * @param $isBooleanType + * @param $isUserDefined + * @param $expected + * @return void + */ + public function testGetFieldType($attributeCode, $isIntegerType, $isBooleanType, $isUserDefined, $expected) + { + $attributeMock = $this->getMockBuilder(AttributeAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['getAttributeCode', 'isIntegerType', 'isBooleanType', 'isUserDefined']) + ->getMock(); + $attributeMock->expects($this->any()) + ->method('getAttributeCode') + ->willReturn($attributeCode); + $attributeMock->expects($this->any()) + ->method('isIntegerType') + ->willReturn($isIntegerType); + $attributeMock->expects($this->any()) + ->method('isBooleanType') + ->willReturn($isBooleanType); + $attributeMock->expects($this->any()) + ->method('isUserDefined') + ->willReturn($isUserDefined); + $this->fieldTypeConverter->expects($this->any()) + ->method('convert') + ->willReturn('something'); + + $this->assertEquals( + $expected, + $this->resolver->getFieldType($attributeMock) + ); + } + + /** + * @return array + */ + public function getFieldTypeProvider() + { + return [ + ['category_ids', true, true, true, null], + ['category_ids', false, false, false, null], + ['type', true, false, false, 'something'], + ['type', false, true, false, 'something'], + ['type', true, true, true, ''], + ['type', false, false, true, ''], + ]; + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/StaticFieldTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/StaticFieldTest.php new file mode 100644 index 0000000000000..bf8b601ed43ab --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/StaticFieldTest.php @@ -0,0 +1,249 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Test\Unit\Model\Adapter\FieldMapper\Product\FieldProvider; + +use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Eav\Model\Config; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeProvider; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeAdapter; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface + as FieldTypeConverterInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\ConverterInterface + as IndexTypeConverterInterface; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ResolverInterface + as FieldTypeResolver; +use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\ResolverInterface + as FieldIndexResolver; + +/** + * @SuppressWarnings(PHPMD) + */ +class StaticFieldTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var \Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\StaticField + */ + private $provider; + + /** + * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject + */ + private $eavConfig; + + /** + * @var FieldTypeConverterInterface + */ + private $fieldTypeConverter; + + /** + * @var IndexTypeConverterInterface + */ + private $indexTypeConverter; + + /** + * @var AttributeProvider + */ + private $attributeAdapterProvider; + + /** + * @var FieldIndexResolver + */ + private $fieldIndexResolver; + + /** + * @var FieldTypeResolver + */ + private $fieldTypeResolver; + + /** + * Set up test environment + * + * @return void + */ + protected function setUp() + { + $this->eavConfig = $this->getMockBuilder(Config::class) + ->disableOriginalConstructor() + ->setMethods(['getEntityAttributes']) + ->getMock(); + $this->fieldTypeConverter = $this->getMockBuilder(FieldTypeConverterInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->indexTypeConverter = $this->getMockBuilder(IndexTypeConverterInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->attributeAdapterProvider = $this->getMockBuilder(AttributeProvider::class) + ->disableOriginalConstructor() + ->setMethods(['getByAttributeCode']) + ->getMock(); + $this->fieldTypeResolver = $this->getMockBuilder(FieldTypeResolver::class) + ->disableOriginalConstructor() + ->setMethods(['getFieldType']) + ->getMock(); + $this->fieldIndexResolver = $this->getMockBuilder(FieldIndexResolver::class) + ->disableOriginalConstructor() + ->setMethods(['getFieldIndex']) + ->getMock(); + + $objectManager = new ObjectManagerHelper($this); + + $this->provider = $objectManager->getObject( + \Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\StaticField::class, + [ + 'eavConfig' => $this->eavConfig, + 'fieldTypeConverter' => $this->fieldTypeConverter, + 'indexTypeConverter' => $this->indexTypeConverter, + 'attributeAdapterProvider' => $this->attributeAdapterProvider, + 'fieldIndexResolver' => $this->fieldIndexResolver, + 'fieldTypeResolver' => $this->fieldTypeResolver, + ] + ); + } + + /** + * @dataProvider attributeProvider + * @param string $attributeCode + * @param string $inputType + * @param $indexType + * @param $isComplexType + * @param $complexType + * @param array $expected + * @return void + */ + public function testGetAllAttributesTypes( + $attributeCode, + $inputType, + $indexType, + $isComplexType, + $complexType, + $expected + ) { + $this->fieldTypeResolver->expects($this->any()) + ->method('getFieldType') + ->willReturn($inputType); + $this->fieldIndexResolver->expects($this->any()) + ->method('getFieldIndex') + ->willReturn($indexType); + $this->indexTypeConverter->expects($this->any()) + ->method('convert') + ->willReturn('no'); + + $productAttributeMock = $this->getMockBuilder(AbstractAttribute::class) + ->setMethods(['getAttributeCode']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $productAttributeMock->expects($this->any()) + ->method('getAttributeCode') + ->willReturn($attributeCode); + $this->eavConfig->expects($this->any())->method('getEntityAttributes') + ->willReturn([$productAttributeMock]); + + $attributeMock = $this->getMockBuilder(AttributeAdapter::class) + ->disableOriginalConstructor() + ->setMethods(['isComplexType', 'getAttributeCode']) + ->getMock(); + $attributeMock->expects($this->any()) + ->method('isComplexType') + ->willReturn($isComplexType); + $attributeMock->expects($this->any()) + ->method('getAttributeCode') + ->willReturn($attributeCode); + $this->attributeAdapterProvider->expects($this->any()) + ->method('getByAttributeCode') + ->with($this->anything()) + ->willReturn($attributeMock); + $this->fieldTypeConverter->expects($this->any()) + ->method('convert') + ->with($this->anything()) + ->will($this->returnCallback( + function ($type) use ($complexType) { + static $callCount = []; + $callCount[$type] = !isset($callCount[$type]) ? 1 : ++$callCount[$type]; + + if ($type === 'string') { + return 'string'; + } + if ($type === 'string') { + return 'string'; + } elseif ($type === 'float') { + return 'float'; + } else { + return $complexType; + } + } + )); + + $this->assertEquals( + $expected, + $this->provider->getFields(['storeId' => 1]) + ); + } + + /** + * @return array + */ + public function attributeProvider() + { + return [ + [ + 'category_ids', + 'select', + true, + true, + 'text', + [ + 'category_ids' => [ + 'type' => 'select', + 'index' => true + ], + 'category_ids_value' => [ + 'type' => 'string' + ], + 'store_id' => [ + 'type' => 'string', + 'index' => 'no' + ] + ] + ], + [ + 'attr_code', + 'text', + 'no', + false, + null, + [ + 'attr_code' => [ + 'type' => 'text', + 'index' => 'no' + ], + 'store_id' => [ + 'type' => 'string', + 'index' => 'no' + ] + ], + ], + [ + 'attr_code', + 'text', + null, + false, + null, + [ + 'attr_code' => [ + 'type' => 'text' + ], + 'store_id' => [ + 'type' => 'string', + 'index' => 'no' + ] + ] + ] + ]; + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/ProductFieldMapperTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/ProductFieldMapperTest.php deleted file mode 100644 index 8b7ac6abbb190..0000000000000 --- a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/ProductFieldMapperTest.php +++ /dev/null @@ -1,298 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\Elasticsearch\Test\Unit\Model\Adapter\FieldMapper; - -use Magento\Catalog\Api\Data\ProductAttributeInterface; -use Magento\Elasticsearch\Model\Adapter\FieldType; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; - -class ProductFieldMapperTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var \Magento\Elasticsearch\Model\Adapter\FieldMapper\ProductFieldMapper - */ - protected $mapper; - - /** - * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject - */ - protected $eavConfig; - - /** - * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject - */ - protected $coreRegistry; - - /** - * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject - */ - protected $customerSession; - - /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $storeManager; - - /** - * @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute|\PHPUnit_Framework_MockObject_MockObject - */ - protected $eavAttributeResource; - - /** - * @var FieldType|\PHPUnit_Framework_MockObject_MockObject - */ - protected $fieldType; - - /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $store; - - /** - * Set up test environment - * - * @return void - */ - protected function setUp() - { - $this->eavConfig = $this->getMockBuilder(\Magento\Eav\Model\Config::class) - ->disableOriginalConstructor() - ->setMethods(['getEntityType', 'getAttribute', 'getEntityAttributeCodes']) - ->getMock(); - - $this->fieldType = $this->getMockBuilder(FieldType::class) - ->disableOriginalConstructor() - ->setMethods(['getFieldType']) - ->getMock(); - - $this->customerSession = $this->getMockBuilder(\Magento\Customer\Model\Session::class) - ->disableOriginalConstructor() - ->setMethods(['getCustomerGroupId']) - ->getMock(); - - $this->storeManager = $this->storeManager = $this->getMockForAbstractClass( - \Magento\Store\Model\StoreManagerInterface::class, - [], - '', - false - ); - - $this->store = $this->getMockForAbstractClass( - \Magento\Store\Api\Data\StoreInterface::class, - [], - '', - false, - false, - true, - ['getWebsiteId', 'getRootCategoryId'] - ); - - $this->coreRegistry = $this->createMock(\Magento\Framework\Registry::class); - - $objectManager = new ObjectManagerHelper($this); - - $this->eavAttributeResource = $this->createPartialMock( - \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, - [ - '__wakeup', - 'getBackendType', - 'getFrontendInput' - ] - ); - - $this->mapper = $objectManager->getObject( - \Magento\Elasticsearch\Model\Adapter\FieldMapper\ProductFieldMapper::class, - [ - 'eavConfig' => $this->eavConfig, - 'storeManager' => $this->storeManager, - 'fieldType' => $this->fieldType, - 'customerSession' => $this->customerSession, - 'coreRegistry' => $this->coreRegistry - ] - ); - } - - /** - * @dataProvider attributeCodeProvider - * @param string $attributeCode - * @param string $fieldName - * @param string $fieldType - * @param array $context - * - * @return void - */ - public function testGetFieldName($attributeCode, $fieldName, $fieldType, $context = []) - { - $attributeMock = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class) - ->setMethods(['getBackendType', 'getFrontendInput', 'getAttribute']) - ->disableOriginalConstructor() - ->getMock(); - - $this->customerSession->expects($this->any()) - ->method('getCustomerGroupId') - ->willReturn('0'); - - $this->storeManager->expects($this->any()) - ->method('getStore') - ->willReturn($this->store); - $this->store->expects($this->any()) - ->method('getWebsiteId') - ->willReturn('1'); - $this->store->expects($this->any()) - ->method('getRootCategoryId') - ->willReturn('1'); - - $this->eavConfig->expects($this->any())->method('getAttribute') - ->with(ProductAttributeInterface::ENTITY_TYPE_CODE, $attributeCode) - ->willReturn($attributeMock); - - $attributeMock->expects($this->any())->method('getFrontendInput') - ->will($this->returnValue('select')); - - $this->fieldType->expects($this->any())->method('getFieldType') - ->with($attributeMock) - ->willReturn($fieldType); - - $this->assertEquals( - $fieldName, - $this->mapper->getFieldName($attributeCode, $context) - ); - } - - /** - * @return void - */ - public function testGetFieldNameWithoutAttribute() - { - $this->eavConfig->expects($this->any())->method('getAttribute') - ->with(ProductAttributeInterface::ENTITY_TYPE_CODE, 'attr1') - ->willReturn(''); - - $this->assertEquals( - 'attr1', - $this->mapper->getFieldName('attr1', []) - ); - } - - /** - * @dataProvider attributeProvider - * @param string $attributeCode - * @param string $inputType - * @param array $searchAttributes - * @param array $expected - * @return void - */ - public function testGetAllAttributesTypes($attributeCode, $inputType, $searchAttributes, $expected) - { - $attributeMock = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->eavConfig->expects($this->any())->method('getEntityAttributeCodes') - ->with(ProductAttributeInterface::ENTITY_TYPE_CODE) - ->willReturn([$attributeCode]); - - $this->eavConfig->expects($this->any())->method('getAttribute') - ->with(ProductAttributeInterface::ENTITY_TYPE_CODE, $attributeCode) - ->willReturn($attributeMock); - - $this->fieldType->expects($this->once())->method('getFieldType')->willReturn(FieldType::ES_DATA_TYPE_INT); - - $attributeMock->expects($this->any()) - ->method('getIsSearchable') - ->willReturn($searchAttributes['searchable']); - $attributeMock->expects($this->any()) - ->method('getIsFilterable') - ->willReturn($searchAttributes['filterable']); - $attributeMock->expects($this->any()) - ->method('getIsFilterableInSearch') - ->willReturn($searchAttributes['filterableInSearch']); - $attributeMock->expects($this->any()) - ->method('getIsVisibleInAdvancedSearch') - ->willReturn($searchAttributes['advSearch']); - - $attributeMock->expects($this->any())->method('getFrontendInput') - ->will($this->returnValue($inputType)); - - $this->assertEquals( - $expected, - $this->mapper->getAllAttributesTypes() - ); - } - - /** - * @return array - */ - public function attributeCodeProvider() - { - return [ - ['id', 'id', 'string'], - ['status', 'status', 'string'], - ['status', 'status_value', 'string', ['type'=>'default']], - ['price', 'price_0_1', 'string', ['type'=>'default']], - ['position', 'position_category_1', 'string', ['type'=>'default']], - ['price', 'price_2_3', 'string', ['type'=>'default', 'customerGroupId'=>'2', 'websiteId'=>'3']], - ['position', 'position_category_3', 'string', ['type'=>'default', 'categoryId'=>'3']], - ['color', 'color_value', 'string', ['type'=>'text']], - ['description', 'sort_description', 'string', ['type'=>'some']], - ['*', '_all', 'string', ['type'=>'text']], - ['description', 'description_value', 'string', ['type'=>'text']], - ]; - } - - /** - * @return array - */ - public function attributeProvider() - { - return [ - [ - 'category_ids', - 'text', - ['searchable' => false, 'filterable' => false, 'filterableInSearch' => false, 'advSearch' => false], - ['category_ids' => ['type' => 'integer']] - ], - [ - 'attr_code', - 'string', - ['searchable' => false, 'filterable' => false, 'filterableInSearch' => false, 'advSearch' => false], - ['attr_code' => ['type' => 'integer', 'index' => 'no']] - ], - [ - 'attr_code', - 'string', - ['searchable' => '0', 'filterable' => '0', 'filterableInSearch' => '0', 'advSearch' => '0'], - ['attr_code' => ['type' => 'integer', 'index' => 'no']] - ], - [ - 'attr_code', - 'string', - ['searchable' => true, 'filterable' => false, 'filterableInSearch' => false, 'advSearch' => false], - ['attr_code' => ['type' => 'integer']] - ], - [ - 'attr_code', - 'string', - ['searchable' => '1', 'filterable' => '0', 'filterableInSearch' => '0', 'advSearch' => '0'], - ['attr_code' => ['type' => 'integer']] - ], - [ - 'attr_code', - 'string', - ['searchable' => false, 'filterable' => false, 'filterableInSearch' => false, 'advSearch' => true], - ['attr_code' => ['type' => 'integer']] - ], - [ - 'attr_code', - 'string', - ['searchable' => '0', 'filterable' => '0', 'filterableInSearch' => '1', 'advSearch' => '0'], - ['attr_code' => ['type' => 'integer']] - ], - ]; - } -} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Observer/CategoryProductIndexerTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Observer/CategoryProductIndexerTest.php new file mode 100644 index 0000000000000..adebee0d591ab --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Observer/CategoryProductIndexerTest.php @@ -0,0 +1,136 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch\Test\Unit\Observer; + +use Magento\CatalogSearch\Model\Indexer\Fulltext\Processor; +use Magento\Elasticsearch\Model\Config; +use Magento\Elasticsearch\Observer\CategoryProductIndexer; +use Magento\Framework\Event; +use Magento\Framework\Event\Observer; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; + +/** + * Class CategoryProductIndexerTest + */ +class CategoryProductIndexerTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var CategoryProductIndexer + */ + private $observer; + + /** + * @var Config|\PHPUnit_Framework_MockObject_MockObject + */ + private $configMock; + + /** + * @var Processor|\PHPUnit_Framework_MockObject_MockObject + */ + private $processorMock; + + /** + * @var Observer|\PHPUnit_Framework_MockObject_MockObject + */ + private $observerMock; + + /** + * Set Up method + * + * @return void + */ + protected function setUp(): void + { + $this->configMock = $this->createMock(Config::class); + $this->processorMock = $this->createMock(Processor::class); + $this->observerMock = $this->createMock(Observer::class); + + $objectManager = new ObjectManagerHelper($this); + $this->observer = $objectManager->getObject( + CategoryProductIndexer::class, + [ + 'config' => $this->configMock, + 'processor' => $this->processorMock, + ] + ); + } + + /** + * Test if a category has changed products + * + * @return void + */ + public function testExecuteIfCategoryHasChangedProducts() + { + $this->getProductIdsWithEnabledElasticSearch(); + $this->processorMock->expects($this->once())->method('isIndexerScheduled')->willReturn(true); + $this->processorMock->expects($this->once())->method('markIndexerAsInvalid'); + $this->observer->execute($this->observerMock); + } + + /** + * Test if a category has changed products and not scheduled indexer + * + * @return void + */ + public function testExecuteIfCategoryHasChangedProductsAndNotScheduledIndexer(): void + { + $this->getProductIdsWithEnabledElasticSearch(); + $this->processorMock->expects($this->once())->method('isIndexerScheduled')->willReturn(false); + $this->processorMock->expects($this->never())->method('markIndexerAsInvalid'); + $this->observer->execute($this->observerMock); + } + + /** + * Test if a category has none changed products + * + * @return void + */ + public function testExecuteIfCategoryHasNoneChangedProducts(): void + { + /** @var Event|\PHPUnit_Framework_MockObject_MockObject $eventMock */ + $eventMock = $this->createPartialMock(Event::class, ['getProductIds']); + $this->configMock->expects($this->once())->method('isElasticsearchEnabled')->willReturn(true); + + $eventMock->expects($this->once())->method('getProductIds')->willReturn([]); + $this->observerMock->expects($this->once())->method('getEvent')->willReturn($eventMock); + + $this->processorMock->expects($this->never())->method('isIndexerScheduled'); + $this->processorMock->expects($this->never())->method('markIndexerAsInvalid'); + + $this->observer->execute($this->observerMock); + } + + /** + * Test if ElasticSearch is disabled + * + * @return void + */ + public function testExecuteIfElasticSearchIsDisabled(): void + { + /** @var Event|\PHPUnit_Framework_MockObject_MockObject $eventMock */ + $eventMock = $this->createPartialMock(Event::class, ['getProductIds']); + $this->configMock->expects($this->once())->method('isElasticsearchEnabled')->willReturn(false); + $eventMock->expects($this->never())->method('getProductIds')->willReturn([]); + $this->observer->execute($this->observerMock); + } + + /** + * Get product ids with enabled ElasticSearch + * + * @return void + */ + private function getProductIdsWithEnabledElasticSearch(): void + { + /** @var Event|\PHPUnit_Framework_MockObject_MockObject $eventMock */ + $eventMock = $this->createPartialMock(Event::class, ['getProductIds']); + $this->configMock->expects($this->once())->method('isElasticsearchEnabled')->willReturn(true); + $eventMock->expects($this->once())->method('getProductIds')->willReturn([1]); + $this->observerMock->expects($this->once())->method('getEvent')->willReturn($eventMock); + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/SearchAdapter/Dynamic/DataProviderTest.php b/app/code/Magento/Elasticsearch/Test/Unit/SearchAdapter/Dynamic/DataProviderTest.php index 41be237efe532..9c717ea240a5d 100644 --- a/app/code/Magento/Elasticsearch/Test/Unit/SearchAdapter/Dynamic/DataProviderTest.php +++ b/app/code/Magento/Elasticsearch/Test/Unit/SearchAdapter/Dynamic/DataProviderTest.php @@ -320,6 +320,10 @@ public function testGetAggregation() $this->clientMock->expects($this->once()) ->method('query') + ->with($this->callback(function ($query) { + // Assert the interval is queried as a float. See MAGETWO-95471 + return $query['body']['aggregations']['prices']['histogram']['interval'] === 10.0; + })) ->willReturn([ 'aggregations' => [ 'prices' => [ diff --git a/app/code/Magento/Elasticsearch/etc/di.xml b/app/code/Magento/Elasticsearch/etc/di.xml index 0cfaba845fd6a..b10d30e48064a 100644 --- a/app/code/Magento/Elasticsearch/etc/di.xml +++ b/app/code/Magento/Elasticsearch/etc/di.xml @@ -7,6 +7,12 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\Elasticsearch\Model\Adapter\FieldMapperInterface" type="Magento\Elasticsearch\Model\Adapter\FieldMapper\FieldMapperResolver" /> + <preference for="Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\ResolverInterface" type="Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\CompositeResolver" /> + <preference for="Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ResolverInterface" type="Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\CompositeResolver" /> + <preference for="Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\ResolverInterface" type="Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\IndexResolver" /> + <preference for="Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\ConverterInterface" type="Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\Converter" /> + <preference for="Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\ConverterInterface" type="Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Converter" /> + <preference for="Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProviderInterface" type="Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\CompositeFieldProvider" /> <type name="Magento\Elasticsearch\Model\Adapter\FieldMapper\FieldMapperResolver"> <arguments> <argument name="fieldMappers" xsi:type="array"> @@ -271,4 +277,148 @@ </argument> </arguments> </type> + <type name="Magento\Elasticsearch\Elasticsearch5\Model\Adapter\BatchDataMapper\CategoryFieldsProvider"> + <arguments> + <argument name="fieldNameResolver" xsi:type="object">elasticsearch5FieldNameResolver</argument> + </arguments> + </type> + <type name="Magento\Elasticsearch\Elasticsearch5\Model\Adapter\DataMapper\ProductDataMapper"> + <arguments> + <argument name="fieldNameResolver" xsi:type="object">elasticsearch5FieldNameResolver</argument> + </arguments> + </type> + <type name="\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\CompositeResolver"> + <arguments> + <argument name="items" xsi:type="array"> + <item name="notEav" xsi:type="object">\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\NotEavAttribute</item> + <item name="special" xsi:type="object">\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\SpecialAttribute</item> + <item name="price" xsi:type="object">\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\Price</item> + <item name="categoryName" xsi:type="object">\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\CategoryName</item> + <item name="position" xsi:type="object">\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\Position</item> + <item name="default" xsi:type="object">\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\DefaultResolver</item> + </argument> + </arguments> + </type> + <virtualType name="elasticsearch5FieldNameResolver" type="\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\CompositeResolver"> + <arguments> + <argument name="items" xsi:type="array"> + <item name="notEav" xsi:type="object">\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\NotEavAttribute</item> + <item name="special" xsi:type="object">\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\SpecialAttribute</item> + <item name="price" xsi:type="object">\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\Price</item> + <item name="categoryName" xsi:type="object">\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\CategoryName</item> + <item name="position" xsi:type="object">\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\Position</item> + <item name="default" xsi:type="object">elasticsearch5FieldNameDefaultResolver</item> + </argument> + </arguments> + </virtualType> + <virtualType name="elasticsearch5FieldNameDefaultResolver" type="Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\Resolver\DefaultResolver"> + <arguments> + <argument name="fieldTypeResolver" xsi:type="object">\Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\CompositeResolver</argument> + <argument name="fieldTypeConverter" xsi:type="object">Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Converter</argument> + </arguments> + </virtualType> + <type name="\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\CompositeResolver"> + <arguments> + <argument name="items" xsi:type="array"> + <item name="integer" xsi:type="object">\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\IntegerType</item> + <item name="datetime" xsi:type="object">\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\DateTimeType</item> + <item name="float" xsi:type="object">\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\FloatType</item> + <item name="default" xsi:type="object">\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\DefaultResolver</item> + </argument> + </arguments> + </type> + <type name="\Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\CompositeResolver"> + <arguments> + <argument name="items" xsi:type="array"> + <item name="keyword" xsi:type="object">\Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\KeywordType</item> + <item name="integer" xsi:type="object">\Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\IntegerType</item> + <item name="datetime" xsi:type="object">elasticsearch5FieldTypeDateTimeResolver</item> + <item name="float" xsi:type="object">elasticsearch5FieldTypeFloatResolver</item> + <item name="default" xsi:type="object">elasticsearch5FieldTypeDefaultResolver</item> + </argument> + </arguments> + </type> + <type name="Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\CompositeFieldProvider"> + <arguments> + <argument name="providers" xsi:type="array"> + <item name="static" xsi:type="object">\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\StaticField</item> + <item name="dynamic" xsi:type="object">\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\DynamicField</item> + </argument> + </arguments> + </type> + <virtualType name="elasticsearch5FieldProvider" type="Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\CompositeFieldProvider"> + <arguments> + <argument name="providers" xsi:type="array"> + <item name="static" xsi:type="object">elasticsearch5StaticFieldProvider</item> + <item name="dynamic" xsi:type="object">elasticsearch5DynamicFieldProvider</item> + </argument> + </arguments> + </virtualType> + <virtualType name="elasticsearch5StaticFieldProvider" type="\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\StaticField"> + <arguments> + <argument name="fieldTypeConverter" xsi:type="object">Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Converter</argument> + <argument name="indexTypeConverter" xsi:type="object">Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\Converter</argument> + <argument name="fieldIndexResolver" xsi:type="object">Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\IndexResolver</argument> + <argument name="fieldTypeResolver" xsi:type="object">\Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\CompositeResolver</argument> + </arguments> + </virtualType> + <virtualType name="elasticsearch5DynamicFieldProvider" type="\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\DynamicField"> + <arguments> + <argument name="fieldTypeConverter" xsi:type="object">Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Converter</argument> + <argument name="indexTypeConverter" xsi:type="object">Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\Converter</argument> + </arguments> + </virtualType> + <type name="\Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\KeywordType"> + <arguments> + <argument name="fieldTypeConverter" xsi:type="object">Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Converter</argument> + </arguments> + </type> + <type name="\Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\IntegerType"> + <arguments> + <argument name="fieldTypeConverter" xsi:type="object">Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Converter</argument> + </arguments> + </type> + <virtualType name="elasticsearch5FieldTypeDateTimeResolver" type="\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\DateTimeType"> + <arguments> + <argument name="fieldTypeConverter" xsi:type="object">Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Converter</argument> + </arguments> + </virtualType> + <virtualType name="elasticsearch5FieldTypeFloatResolver" type="\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\FloatType"> + <arguments> + <argument name="fieldTypeConverter" xsi:type="object">Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Converter</argument> + </arguments> + </virtualType> + <virtualType name="elasticsearch5FieldTypeDefaultResolver" type="\Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\DefaultResolver"> + <arguments> + <argument name="fieldTypeConverter" xsi:type="object">Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Converter</argument> + </arguments> + </virtualType> + <type name="\Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\ProductFieldMapper"> + <arguments> + <argument name="fieldProvider" xsi:type="object">elasticsearch5FieldProvider</argument> + <argument name="fieldNameResolver" xsi:type="object">elasticsearch5FieldNameResolver</argument> + </arguments> + </type> + <type name="\Magento\Elasticsearch\Model\Adapter\FieldMapper\ProductFieldMapper"> + <arguments> + <argument name="attributeAdapterProvider" xsi:type="object">Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeProvider</argument> + <argument name="fieldProvider" xsi:type="object">Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProviderInterface</argument> + <argument name="fieldNameResolver" xsi:type="object">Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\ResolverInterface</argument> + </arguments> + </type> + <type name="Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\IndexResolver"> + <arguments> + <argument name="converter" xsi:type="object">Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\Converter</argument> + <argument name="fieldTypeConverter" xsi:type="object">Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Converter</argument> + <argument name="fieldTypeResolver" xsi:type="object">\Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\CompositeResolver</argument> + </arguments> + </type> + <type name="Magento\Search\Model\Search\PageSizeProvider"> + <arguments> + <argument name="pageSizeBySearchEngine" xsi:type="array"> + <item name="elasticsearch" xsi:type="number">2147483647</item> + <item name="elasticsearch5" xsi:type="number">2147483647</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Email/Test/Unit/Model/Plugin/WindowsSmtpConfigTest.php b/app/code/Magento/Email/Test/Unit/Model/Plugin/WindowsSmtpConfigTest.php new file mode 100644 index 0000000000000..5f7c44b988c66 --- /dev/null +++ b/app/code/Magento/Email/Test/Unit/Model/Plugin/WindowsSmtpConfigTest.php @@ -0,0 +1,100 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Email\Test\Unit\Model\Plugin; + +use Magento\Email\Model\Plugin\WindowsSmtpConfig; +use Magento\Framework\App\Config\ReinitableConfigInterface; +use Magento\Framework\Mail\TransportInterface; +use Magento\Framework\OsInfo; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; + +/** + * WindowsSmtpConfigTest + */ +class WindowsSmtpConfigTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var WindowsSmtpConfig + */ + private $windowsSmtpConfig; + + /** + * @var OsInfo|\PHPUnit_Framework_MockObject_MockObject + */ + private $osInfoMock; + + /** + * @var ReinitableConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $configMock; + + /** + * @var TransportInterface + */ + private $transportMock; + + /** + * setUp + * + * @return void + */ + public function setUp(): void + { + $objectManager = new ObjectManager($this); + + $this->osInfoMock = $this->createMock(OsInfo::class); + $this->configMock = $this->createMock(ReinitableConfigInterface::class); + $this->transportMock = $this->createMock(TransportInterface::class); + + $this->windowsSmtpConfig = $objectManager->getObject( + WindowsSmtpConfig::class, + [ + 'config' => $this->configMock, + 'osInfo' => $this->osInfoMock + ] + ); + } + + /** + * Test if SMTP settings if windows server + * + * @return void + */ + public function testBeforeSendMessageOsWindows(): void + { + $this->osInfoMock->expects($this->once()) + ->method('isWindows') + ->willReturn(true); + + $this->configMock->expects($this->exactly(2)) + ->method('getValue') + ->willReturnMap([ + [WindowsSmtpConfig::XML_SMTP_HOST, '127.0.0.1'], + [WindowsSmtpConfig::XML_SMTP_PORT, '80'] + ]); + + $this->windowsSmtpConfig->beforeSendMessage($this->transportMock); + } + + /** + * Test if SMTP settings if not windows server + * + * @return void + */ + public function testBeforeSendMessageOsIsWindows(): void + { + $this->osInfoMock->expects($this->once()) + ->method('isWindows') + ->willReturn(false); + + $this->configMock->expects($this->never()) + ->method('getValue'); + + $this->windowsSmtpConfig->beforeSendMessage($this->transportMock); + } +} diff --git a/app/code/Magento/Email/Test/Unit/Model/Template/SenderResolverTest.php b/app/code/Magento/Email/Test/Unit/Model/Template/SenderResolverTest.php new file mode 100644 index 0000000000000..fb25290f9d27b --- /dev/null +++ b/app/code/Magento/Email/Test/Unit/Model/Template/SenderResolverTest.php @@ -0,0 +1,112 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Email\Test\Unit\Model\Template; + +use Magento\Email\Model\Template\SenderResolver; +use Magento\Framework\Exception\MailException; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Framework\App\Config\ScopeConfigInterface; + +/** + * SenderResolverTest + */ +class SenderResolverTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var SenderResolver + */ + private $senderResolver; + + /** + * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $scopeConfig; + + /** + * @return void + */ + public function setUp(): void + { + $objectManager = new ObjectManager($this); + + $this->scopeConfig = $this->createMock(ScopeConfigInterface::class); + + $this->senderResolver = $objectManager->getObject( + SenderResolver::class, + [ + 'scopeConfig' => $this->scopeConfig + ] + ); + } + + /** + * Test returned information for given sender's name and email + * + * @return void + */ + public function testResolve(): void + { + $sender = 'general'; + $scopeId = null; + + $this->scopeConfig->expects($this->exactly(2)) + ->method('getValue') + ->willReturnMap([ + [ + 'trans_email/ident_' . $sender . '/name', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $scopeId, + 'Test Name' + ], + [ + 'trans_email/ident_' . $sender . '/email', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $scopeId, + 'test@email.com' + ] + ]); + + $result = $this->senderResolver->resolve($sender); + + $this->assertTrue(isset($result['name'])); + $this->assertEquals('Test Name', $result['name']); + + $this->assertTrue(isset($result['email'])); + $this->assertEquals('test@email.com', $result['email']); + } + + /** + * Test if exception is thrown in case there is no name or email in result + * + * @dataProvider dataProvidedSenderArray + * @param array $sender + * + * @return void + */ + public function testResolveThrowException(array $sender): void + { + $this->expectExceptionMessage('Invalid sender data'); + $this->expectException(MailException::class); + $this->senderResolver->resolve($sender); + } + + /** + * @return array + */ + public function dataProvidedSenderArray() + { + return [ + [ + ['name' => 'Name'] + ], + [ + ['email' => 'test@email.com'] + ] + ]; + } +} diff --git a/app/code/Magento/Email/etc/db_schema.xml b/app/code/Magento/Email/etc/db_schema.xml index 53ef349a383ae..dbb8855e9e57e 100644 --- a/app/code/Magento/Email/etc/db_schema.xml +++ b/app/code/Magento/Email/etc/db_schema.xml @@ -27,16 +27,16 @@ <column xsi:type="varchar" name="orig_template_code" nullable="true" length="200" comment="Original Template Code"/> <column xsi:type="text" name="orig_template_variables" nullable="true" comment="Original Template Variables"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="template_id"/> </constraint> - <constraint xsi:type="unique" name="EMAIL_TEMPLATE_TEMPLATE_CODE"> + <constraint xsi:type="unique" referenceId="EMAIL_TEMPLATE_TEMPLATE_CODE"> <column name="template_code"/> </constraint> - <index name="EMAIL_TEMPLATE_ADDED_AT" indexType="btree"> + <index referenceId="EMAIL_TEMPLATE_ADDED_AT" indexType="btree"> <column name="added_at"/> </index> - <index name="EMAIL_TEMPLATE_MODIFIED_AT" indexType="btree"> + <index referenceId="EMAIL_TEMPLATE_MODIFIED_AT" indexType="btree"> <column name="modified_at"/> </index> </table> diff --git a/app/code/Magento/GiftMessage/Test/Unit/Observer/SalesEventQuoteMergeTest.php b/app/code/Magento/GiftMessage/Test/Unit/Observer/SalesEventQuoteMergeTest.php new file mode 100644 index 0000000000000..7a3000f7c0743 --- /dev/null +++ b/app/code/Magento/GiftMessage/Test/Unit/Observer/SalesEventQuoteMergeTest.php @@ -0,0 +1,81 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\GiftMessage\Test\Unit\Observer; + +use Magento\GiftMessage\Observer\SalesEventQuoteMerge; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Framework\Event\Observer; +use Magento\Quote\Model\Quote; + +/** + * SalesEventQuoteMergeTest + */ +class SalesEventQuoteMergeTest extends \PHPUnit\Framework\TestCase +{ + + /** + * @var SalesEventQuoteMerge + */ + private $salesEventQuoteMerge; + + /** + * @return void + */ + public function setUp(): void + { + $objectManger = new ObjectManager($this); + $this->salesEventQuoteMerge = $objectManger->getObject(SalesEventQuoteMerge::class); + } + + /** + * @dataProvider dataProviderGiftMessageId + * + * @param null|int $giftMessageId + * + * @return void + */ + public function testExecute($giftMessageId): void + { + $sourceQuoteMock = $this->createPartialMock(Quote::class, ['getGiftMessageId']); + $sourceQuoteMock->expects($this->once()) + ->method('getGiftMessageId') + ->willReturn($giftMessageId); + + $targetQuoteMock = $this->createPartialMock(Quote::class, ['setGiftMessageId']); + + if ($giftMessageId) { + $targetQuoteMock->expects($this->once()) + ->method('setGiftMessageId'); + } else { + $targetQuoteMock->expects($this->never()) + ->method('setGiftMessageId'); + } + + $observer = $this->createMock(Observer::class); + $observer->expects($this->exactly(2)) + ->method('getData') + ->willReturnMap([ + ['quote', null, $targetQuoteMock], + ['source', null, $sourceQuoteMock] + ]); + + $this->salesEventQuoteMerge->execute($observer); + } + + /** + * @return array + */ + public function dataProviderGiftMessageId(): array + { + return [ + [null], + [1] + ]; + } +} diff --git a/app/code/Magento/GiftMessage/etc/db_schema.xml b/app/code/Magento/GiftMessage/etc/db_schema.xml index 518c6398e4c8d..4ae98799df0c2 100644 --- a/app/code/Magento/GiftMessage/etc/db_schema.xml +++ b/app/code/Magento/GiftMessage/etc/db_schema.xml @@ -15,7 +15,7 @@ <column xsi:type="varchar" name="sender" nullable="true" length="255" comment="Sender"/> <column xsi:type="varchar" name="recipient" nullable="true" length="255" comment="Registrant"/> <column xsi:type="text" name="message" nullable="true" comment="Message"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="gift_message_id"/> </constraint> </table> diff --git a/app/code/Magento/GoogleOptimizer/etc/db_schema.xml b/app/code/Magento/GoogleOptimizer/etc/db_schema.xml index ad3e03e490b05..76c377544cfb3 100644 --- a/app/code/Magento/GoogleOptimizer/etc/db_schema.xml +++ b/app/code/Magento/GoogleOptimizer/etc/db_schema.xml @@ -16,12 +16,12 @@ <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Store id"/> <column xsi:type="text" name="experiment_script" nullable="true" comment="Google experiment script"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="code_id"/> </constraint> - <constraint xsi:type="foreign" name="GOOGLEOPTIMIZER_CODE_STORE_ID_STORE_STORE_ID" table="googleoptimizer_code" + <constraint xsi:type="foreign" referenceId="GOOGLEOPTIMIZER_CODE_STORE_ID_STORE_STORE_ID" table="googleoptimizer_code" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="GOOGLEOPTIMIZER_CODE_STORE_ID_ENTITY_ID_ENTITY_TYPE"> + <constraint xsi:type="unique" referenceId="GOOGLEOPTIMIZER_CODE_STORE_ID_ENTITY_ID_ENTITY_TYPE"> <column name="store_id"/> <column name="entity_id"/> <column name="entity_type"/> diff --git a/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Start.php b/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Start.php index 8896f84ce2471..8f64d023c19f9 100644 --- a/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Start.php +++ b/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Start.php @@ -8,7 +8,11 @@ use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; use Magento\ImportExport\Controller\Adminhtml\ImportResult as ImportResultController; use Magento\Framework\Controller\ResultFactory; +use Magento\ImportExport\Model\Import; +/** + * Controller responsible for initiating the import process + */ class Start extends ImportResultController implements HttpPostActionInterface { /** @@ -63,6 +67,11 @@ public function execute() $this->importModel->setData($data); $errorAggregator = $this->importModel->getErrorAggregator(); + $errorAggregator->initValidationStrategy( + $this->importModel->getData(Import::FIELD_NAME_VALIDATION_STRATEGY), + $this->importModel->getData(Import::FIELD_NAME_ALLOWED_ERROR_COUNT) + ); + try { $this->importModel->importSource(); } catch (\Exception $e) { diff --git a/app/code/Magento/ImportExport/etc/db_schema.xml b/app/code/Magento/ImportExport/etc/db_schema.xml index 01f20daabf0f9..df45131848519 100644 --- a/app/code/Magento/ImportExport/etc/db_schema.xml +++ b/app/code/Magento/ImportExport/etc/db_schema.xml @@ -12,7 +12,7 @@ <column xsi:type="varchar" name="entity" nullable="false" length="50" comment="Entity"/> <column xsi:type="varchar" name="behavior" nullable="false" length="10" default="append" comment="Behavior"/> <column xsi:type="longtext" name="data" nullable="true" comment="Data"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> </table> @@ -27,7 +27,7 @@ <column xsi:type="varchar" name="execution_time" nullable="true" length="255" comment="Execution time"/> <column xsi:type="varchar" name="summary" nullable="true" length="255" comment="Summary"/> <column xsi:type="varchar" name="error_file" nullable="false" length="255" comment="Imported file with errors"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="history_id"/> </constraint> </table> diff --git a/app/code/Magento/Indexer/etc/db_schema.xml b/app/code/Magento/Indexer/etc/db_schema.xml index 58c447f4d262e..d7cb006a2cf45 100644 --- a/app/code/Magento/Indexer/etc/db_schema.xml +++ b/app/code/Magento/Indexer/etc/db_schema.xml @@ -15,10 +15,10 @@ comment="Indexer Status"/> <column xsi:type="datetime" name="updated" on_update="false" nullable="true" comment="Indexer Status"/> <column xsi:type="varchar" name="hash_config" nullable="false" length="32" comment="Hash of indexer config"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="state_id"/> </constraint> - <index name="INDEXER_STATE_INDEXER_ID" indexType="btree"> + <index referenceId="INDEXER_STATE_INDEXER_ID" indexType="btree"> <column name="indexer_id"/> </index> </table> @@ -31,13 +31,13 @@ <column xsi:type="datetime" name="updated" on_update="false" nullable="true" comment="View updated time"/> <column xsi:type="int" name="version_id" padding="10" unsigned="true" nullable="true" identity="false" comment="View Version Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="state_id"/> </constraint> - <index name="MVIEW_STATE_VIEW_ID" indexType="btree"> + <index referenceId="MVIEW_STATE_VIEW_ID" indexType="btree"> <column name="view_id"/> </index> - <index name="MVIEW_STATE_MODE" indexType="btree"> + <index referenceId="MVIEW_STATE_MODE" indexType="btree"> <column name="mode"/> </index> </table> diff --git a/app/code/Magento/Integration/etc/db_schema.xml b/app/code/Magento/Integration/etc/db_schema.xml index 33173df4f6c0b..79fbf0b3db17b 100644 --- a/app/code/Magento/Integration/etc/db_schema.xml +++ b/app/code/Magento/Integration/etc/db_schema.xml @@ -19,19 +19,19 @@ <column xsi:type="varchar" name="secret" nullable="false" length="32" comment="Secret code"/> <column xsi:type="text" name="callback_url" nullable="true" comment="Callback URL"/> <column xsi:type="text" name="rejected_callback_url" nullable="false" comment="Rejected callback URL"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="unique" name="OAUTH_CONSUMER_KEY"> + <constraint xsi:type="unique" referenceId="OAUTH_CONSUMER_KEY"> <column name="key"/> </constraint> - <constraint xsi:type="unique" name="OAUTH_CONSUMER_SECRET"> + <constraint xsi:type="unique" referenceId="OAUTH_CONSUMER_SECRET"> <column name="secret"/> </constraint> - <index name="OAUTH_CONSUMER_CREATED_AT" indexType="btree"> + <index referenceId="OAUTH_CONSUMER_CREATED_AT" indexType="btree"> <column name="created_at"/> </index> - <index name="OAUTH_CONSUMER_UPDATED_AT" indexType="btree"> + <index referenceId="OAUTH_CONSUMER_UPDATED_AT" indexType="btree"> <column name="updated_at"/> </index> </table> @@ -57,21 +57,21 @@ comment="User type"/> <column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Token creation timestamp"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="OAUTH_TOKEN_ADMIN_ID_ADMIN_USER_USER_ID" table="oauth_token" + <constraint xsi:type="foreign" referenceId="OAUTH_TOKEN_ADMIN_ID_ADMIN_USER_USER_ID" table="oauth_token" column="admin_id" referenceTable="admin_user" referenceColumn="user_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="OAUTH_TOKEN_CONSUMER_ID_OAUTH_CONSUMER_ENTITY_ID" table="oauth_token" + <constraint xsi:type="foreign" referenceId="OAUTH_TOKEN_CONSUMER_ID_OAUTH_CONSUMER_ENTITY_ID" table="oauth_token" column="consumer_id" referenceTable="oauth_consumer" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="OAUTH_TOKEN_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="oauth_token" + <constraint xsi:type="foreign" referenceId="OAUTH_TOKEN_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="oauth_token" column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="OAUTH_TOKEN_TOKEN"> + <constraint xsi:type="unique" referenceId="OAUTH_TOKEN_TOKEN"> <column name="token"/> </constraint> - <index name="OAUTH_TOKEN_CONSUMER_ID" indexType="btree"> + <index referenceId="OAUTH_TOKEN_CONSUMER_ID" indexType="btree"> <column name="consumer_id"/> </index> </table> @@ -81,14 +81,14 @@ comment="Nonce Timestamp"/> <column xsi:type="int" name="consumer_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Consumer ID"/> - <constraint xsi:type="foreign" name="OAUTH_NONCE_CONSUMER_ID_OAUTH_CONSUMER_ENTITY_ID" table="oauth_nonce" + <constraint xsi:type="foreign" referenceId="OAUTH_NONCE_CONSUMER_ID_OAUTH_CONSUMER_ENTITY_ID" table="oauth_nonce" column="consumer_id" referenceTable="oauth_consumer" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="OAUTH_NONCE_NONCE_CONSUMER_ID"> + <constraint xsi:type="unique" referenceId="OAUTH_NONCE_NONCE_CONSUMER_ID"> <column name="nonce"/> <column name="consumer_id"/> </constraint> - <index name="OAUTH_NONCE_TIMESTAMP" indexType="btree"> + <index referenceId="OAUTH_NONCE_TIMESTAMP" indexType="btree"> <column name="timestamp"/> </index> </table> @@ -113,16 +113,16 @@ default="0" comment="Integration type - manual or config file"/> <column xsi:type="varchar" name="identity_link_url" nullable="true" length="255" comment="Identity linking Url"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="integration_id"/> </constraint> - <constraint xsi:type="foreign" name="INTEGRATION_CONSUMER_ID_OAUTH_CONSUMER_ENTITY_ID" table="integration" + <constraint xsi:type="foreign" referenceId="INTEGRATION_CONSUMER_ID_OAUTH_CONSUMER_ENTITY_ID" table="integration" column="consumer_id" referenceTable="oauth_consumer" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="INTEGRATION_NAME"> + <constraint xsi:type="unique" referenceId="INTEGRATION_NAME"> <column name="name"/> </constraint> - <constraint xsi:type="unique" name="INTEGRATION_CONSUMER_ID"> + <constraint xsi:type="unique" referenceId="INTEGRATION_CONSUMER_ID"> <column name="consumer_id"/> </constraint> </table> @@ -138,10 +138,10 @@ default="0" comment="Number of failed authentication attempts in a row"/> <column xsi:type="timestamp" name="lock_expires_at" on_update="true" nullable="true" default="CURRENT_TIMESTAMP" comment="Lock expiration time"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="log_id"/> </constraint> - <constraint xsi:type="unique" name="OAUTH_TOKEN_REQUEST_LOG_USER_NAME_USER_TYPE"> + <constraint xsi:type="unique" referenceId="OAUTH_TOKEN_REQUEST_LOG_USER_NAME_USER_TYPE"> <column name="user_name"/> <column name="user_type"/> </constraint> diff --git a/app/code/Magento/MessageQueue/etc/db_schema.xml b/app/code/Magento/MessageQueue/etc/db_schema.xml index 9cbad4d32a889..7a20d2bd4df5d 100644 --- a/app/code/Magento/MessageQueue/etc/db_schema.xml +++ b/app/code/Magento/MessageQueue/etc/db_schema.xml @@ -14,10 +14,10 @@ <column xsi:type="varchar" name="message_code" nullable="false" length="255" default="" comment="Message Code"/> <column xsi:type="timestamp" name="created_at" on_update="true" nullable="false" default="CURRENT_TIMESTAMP" comment="Created At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="unique" name="QUEUE_LOCK_MESSAGE_CODE"> + <constraint xsi:type="unique" referenceId="QUEUE_LOCK_MESSAGE_CODE"> <column name="message_code"/> </constraint> </table> diff --git a/app/code/Magento/MysqlMq/etc/db_schema.xml b/app/code/Magento/MysqlMq/etc/db_schema.xml index 02757afa53fcd..3850a6749a3d6 100644 --- a/app/code/Magento/MysqlMq/etc/db_schema.xml +++ b/app/code/Magento/MysqlMq/etc/db_schema.xml @@ -11,10 +11,10 @@ <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" comment="Queue ID"/> <column xsi:type="varchar" name="name" nullable="true" length="255" comment="Queue name"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="unique" name="QUEUE_NAME"> + <constraint xsi:type="unique" referenceId="QUEUE_NAME"> <column name="name"/> </constraint> </table> @@ -23,7 +23,7 @@ comment="Message ID"/> <column xsi:type="varchar" name="topic_name" nullable="true" length="255" comment="Message topic"/> <column xsi:type="longtext" name="body" nullable="true" comment="Message body"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> </table> @@ -41,19 +41,19 @@ comment="Message status in particular queue"/> <column xsi:type="smallint" name="number_of_trials" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Number of trials to processed failed message processing"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="QUEUE_MESSAGE_STATUS_MESSAGE_ID_QUEUE_MESSAGE_ID" + <constraint xsi:type="foreign" referenceId="QUEUE_MESSAGE_STATUS_MESSAGE_ID_QUEUE_MESSAGE_ID" table="queue_message_status" column="message_id" referenceTable="queue_message" referenceColumn="id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="QUEUE_MESSAGE_STATUS_QUEUE_ID_QUEUE_ID" table="queue_message_status" + <constraint xsi:type="foreign" referenceId="QUEUE_MESSAGE_STATUS_QUEUE_ID_QUEUE_ID" table="queue_message_status" column="queue_id" referenceTable="queue" referenceColumn="id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="QUEUE_MESSAGE_STATUS_QUEUE_ID_MESSAGE_ID"> + <constraint xsi:type="unique" referenceId="QUEUE_MESSAGE_STATUS_QUEUE_ID_MESSAGE_ID"> <column name="queue_id"/> <column name="message_id"/> </constraint> - <index name="QUEUE_MESSAGE_STATUS_STATUS_UPDATED_AT" indexType="btree"> + <index referenceId="QUEUE_MESSAGE_STATUS_STATUS_UPDATED_AT" indexType="btree"> <column name="status"/> <column name="updated_at"/> </index> diff --git a/app/code/Magento/NewRelicReporting/etc/db_schema.xml b/app/code/Magento/NewRelicReporting/etc/db_schema.xml index f6d463de0ce33..b5db533f90c75 100644 --- a/app/code/Magento/NewRelicReporting/etc/db_schema.xml +++ b/app/code/Magento/NewRelicReporting/etc/db_schema.xml @@ -16,7 +16,7 @@ comment="Count Value"/> <column xsi:type="timestamp" name="updated_at" on_update="true" nullable="false" default="CURRENT_TIMESTAMP" comment="Updated At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> </table> @@ -29,7 +29,7 @@ <column xsi:type="varchar" name="state" nullable="true" length="255" comment="Module State"/> <column xsi:type="timestamp" name="updated_at" on_update="true" nullable="false" default="CURRENT_TIMESTAMP" comment="Updated At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> </table> @@ -44,7 +44,7 @@ comment="Line Item Count"/> <column xsi:type="timestamp" name="updated_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Updated At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> </table> @@ -55,7 +55,7 @@ <column xsi:type="varchar" name="action" nullable="true" length="255" comment="Action Performed"/> <column xsi:type="timestamp" name="updated_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Updated At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> </table> @@ -66,7 +66,7 @@ <column xsi:type="varchar" name="action" nullable="true" length="255" comment="Action Performed"/> <column xsi:type="timestamp" name="updated_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Updated At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> </table> diff --git a/app/code/Magento/Newsletter/Model/ResourceModel/Subscriber.php b/app/code/Magento/Newsletter/Model/ResourceModel/Subscriber.php index b6e53b3695f78..57123d6842647 100644 --- a/app/code/Magento/Newsletter/Model/ResourceModel/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/ResourceModel/Subscriber.php @@ -5,6 +5,9 @@ */ namespace Magento\Newsletter\Model\ResourceModel; +use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\App\ObjectManager; + /** * Newsletter subscriber resource model * @@ -48,6 +51,13 @@ class Subscriber extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ protected $mathRandom; + /** + * Store manager + * + * @var StoreManagerInterface + */ + private $storeManager; + /** * Construct * @@ -55,15 +65,19 @@ class Subscriber extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb * @param \Magento\Framework\Stdlib\DateTime\DateTime $date * @param \Magento\Framework\Math\Random $mathRandom * @param string $connectionName + * @param StoreManagerInterface $storeManager */ public function __construct( \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Framework\Stdlib\DateTime\DateTime $date, \Magento\Framework\Math\Random $mathRandom, - $connectionName = null + $connectionName = null, + StoreManagerInterface $storeManager = null ) { $this->_date = $date; $this->mathRandom = $mathRandom; + $this->storeManager = $storeManager ?: ObjectManager::getInstance() + ->get(StoreManagerInterface::class); parent::__construct($context, $connectionName); } @@ -117,6 +131,9 @@ public function loadByEmail($subscriberEmail) */ public function loadByCustomerData(\Magento\Customer\Api\Data\CustomerInterface $customer) { + $storeId = (int)$customer->getStoreId() ?: $this->storeManager + ->getWebsite($customer->getWebsiteId())->getDefaultStore()->getId(); + $select = $this->connection ->select() ->from($this->getMainTable()) @@ -127,7 +144,7 @@ public function loadByCustomerData(\Magento\Customer\Api\Data\CustomerInterface $select, [ 'customer_id' => $customer->getId(), - 'store_id' => $customer->getStoreId() + 'store_id' => $storeId ] ); @@ -145,7 +162,7 @@ public function loadByCustomerData(\Magento\Customer\Api\Data\CustomerInterface $select, [ 'subscriber_email' => $customer->getEmail(), - 'store_id' => $customer->getStoreId() + 'store_id' => $storeId ] ); diff --git a/app/code/Magento/Newsletter/Model/Subscriber.php b/app/code/Magento/Newsletter/Model/Subscriber.php index 03976dfcdc197..5527060a6e2f1 100644 --- a/app/code/Magento/Newsletter/Model/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Subscriber.php @@ -613,16 +613,17 @@ protected function _updateCustomerSubscription($customerId, $subscribe) $this->setStatus($status); + $storeId = $customerData->getStoreId(); + if ((int)$customerData->getStoreId() === 0) { + $storeId = $this->_storeManager->getWebsite($customerData->getWebsiteId())->getDefaultStore()->getId(); + } + if (!$this->getId()) { - $storeId = $customerData->getStoreId(); - if ($customerData->getStoreId() == 0) { - $storeId = $this->_storeManager->getWebsite($customerData->getWebsiteId())->getDefaultStore()->getId(); - } $this->setStoreId($storeId) ->setCustomerId($customerData->getId()) ->setEmail($customerData->getEmail()); } else { - $this->setStoreId($customerData->getStoreId()) + $this->setStoreId($storeId) ->setEmail($customerData->getEmail()); } diff --git a/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php b/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php index 9809a9ee4e430..6ccbba9f8828b 100644 --- a/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php +++ b/app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php @@ -213,6 +213,7 @@ public function testSubscribeNotLoggedIn() public function testUpdateSubscription() { + $storeId = 2; $customerId = 1; $customerDataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMock(); @@ -234,7 +235,7 @@ public function testUpdateSubscription() ->method('getConfirmationStatus') ->with($customerId) ->willReturn('account_confirmation_required'); - $customerDataMock->expects($this->once())->method('getStoreId')->willReturn('store_id'); + $customerDataMock->expects($this->exactly(2))->method('getStoreId')->willReturn($storeId); $customerDataMock->expects($this->once())->method('getEmail')->willReturn('email'); $storeModel = $this->getMockBuilder(\Magento\Store\Model\Store::class) @@ -248,6 +249,7 @@ public function testUpdateSubscription() public function testUnsubscribeCustomerById() { + $storeId = 2; $customerId = 1; $customerDataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMock(); @@ -265,7 +267,7 @@ public function testUnsubscribeCustomerById() ); $customerDataMock->expects($this->atLeastOnce())->method('getId')->willReturn('id'); $this->resource->expects($this->atLeastOnce())->method('save')->willReturnSelf(); - $customerDataMock->expects($this->once())->method('getStoreId')->willReturn('store_id'); + $customerDataMock->expects($this->exactly(2))->method('getStoreId')->willReturn($storeId); $customerDataMock->expects($this->once())->method('getEmail')->willReturn('email'); $this->sendEmailCheck(); @@ -274,6 +276,7 @@ public function testUnsubscribeCustomerById() public function testSubscribeCustomerById() { + $storeId = 2; $customerId = 1; $customerDataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMock(); @@ -291,7 +294,7 @@ public function testSubscribeCustomerById() ); $customerDataMock->expects($this->atLeastOnce())->method('getId')->willReturn('id'); $this->resource->expects($this->atLeastOnce())->method('save')->willReturnSelf(); - $customerDataMock->expects($this->once())->method('getStoreId')->willReturn('store_id'); + $customerDataMock->expects($this->exactly(2))->method('getStoreId')->willReturn($storeId); $customerDataMock->expects($this->once())->method('getEmail')->willReturn('email'); $this->sendEmailCheck(); @@ -300,6 +303,7 @@ public function testSubscribeCustomerById() public function testSubscribeCustomerById1() { + $storeId = 2; $customerId = 1; $customerDataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMock(); @@ -317,7 +321,7 @@ public function testSubscribeCustomerById1() ); $customerDataMock->expects($this->atLeastOnce())->method('getId')->willReturn('id'); $this->resource->expects($this->atLeastOnce())->method('save')->willReturnSelf(); - $customerDataMock->expects($this->once())->method('getStoreId')->willReturn('store_id'); + $customerDataMock->expects($this->exactly(2))->method('getStoreId')->willReturn($storeId); $customerDataMock->expects($this->once())->method('getEmail')->willReturn('email'); $this->sendEmailCheck(); $this->customerAccountManagement->expects($this->once()) @@ -331,6 +335,7 @@ public function testSubscribeCustomerById1() public function testSubscribeCustomerByIdAfterConfirmation() { + $storeId = 2; $customerId = 1; $customerDataMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMock(); @@ -348,7 +353,7 @@ public function testSubscribeCustomerByIdAfterConfirmation() ); $customerDataMock->expects($this->atLeastOnce())->method('getId')->willReturn('id'); $this->resource->expects($this->atLeastOnce())->method('save')->willReturnSelf(); - $customerDataMock->expects($this->once())->method('getStoreId')->willReturn('store_id'); + $customerDataMock->expects($this->exactly(2))->method('getStoreId')->willReturn($storeId); $customerDataMock->expects($this->once())->method('getEmail')->willReturn('email'); $this->sendEmailCheck(); $this->customerAccountManagement->expects($this->never())->method('getConfirmationStatus'); diff --git a/app/code/Magento/Newsletter/etc/db_schema.xml b/app/code/Magento/Newsletter/etc/db_schema.xml index 5084b8b6d01e7..5cb572f41b6be 100644 --- a/app/code/Magento/Newsletter/etc/db_schema.xml +++ b/app/code/Magento/Newsletter/etc/db_schema.xml @@ -21,19 +21,19 @@ default="0" comment="Subscriber Status"/> <column xsi:type="varchar" name="subscriber_confirm_code" nullable="true" length="32" default="NULL" comment="Subscriber Confirm Code"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="subscriber_id"/> </constraint> - <constraint xsi:type="foreign" name="NEWSLETTER_SUBSCRIBER_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="NEWSLETTER_SUBSCRIBER_STORE_ID_STORE_STORE_ID" table="newsletter_subscriber" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <index name="NEWSLETTER_SUBSCRIBER_CUSTOMER_ID" indexType="btree"> + <index referenceId="NEWSLETTER_SUBSCRIBER_CUSTOMER_ID" indexType="btree"> <column name="customer_id"/> </index> - <index name="NEWSLETTER_SUBSCRIBER_STORE_ID" indexType="btree"> + <index referenceId="NEWSLETTER_SUBSCRIBER_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="NEWSLETTER_SUBSCRIBER_SUBSCRIBER_EMAIL" indexType="btree"> + <index referenceId="NEWSLETTER_SUBSCRIBER_SUBSCRIBER_EMAIL" indexType="btree"> <column name="subscriber_email"/> </index> </table> @@ -54,16 +54,16 @@ default="1" comment="Template Actual"/> <column xsi:type="timestamp" name="added_at" on_update="false" nullable="true" comment="Added At"/> <column xsi:type="timestamp" name="modified_at" on_update="false" nullable="true" comment="Modified At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="template_id"/> </constraint> - <index name="NEWSLETTER_TEMPLATE_TEMPLATE_ACTUAL" indexType="btree"> + <index referenceId="NEWSLETTER_TEMPLATE_TEMPLATE_ACTUAL" indexType="btree"> <column name="template_actual"/> </index> - <index name="NEWSLETTER_TEMPLATE_ADDED_AT" indexType="btree"> + <index referenceId="NEWSLETTER_TEMPLATE_ADDED_AT" indexType="btree"> <column name="added_at"/> </index> - <index name="NEWSLETTER_TEMPLATE_MODIFIED_AT" indexType="btree"> + <index referenceId="NEWSLETTER_TEMPLATE_MODIFIED_AT" indexType="btree"> <column name="modified_at"/> </index> </table> @@ -86,13 +86,13 @@ <column xsi:type="timestamp" name="queue_start_at" on_update="false" nullable="true" comment="Queue Start At"/> <column xsi:type="timestamp" name="queue_finish_at" on_update="false" nullable="true" comment="Queue Finish At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="queue_id"/> </constraint> - <constraint xsi:type="foreign" name="NEWSLETTER_QUEUE_TEMPLATE_ID_NEWSLETTER_TEMPLATE_TEMPLATE_ID" + <constraint xsi:type="foreign" referenceId="NEWSLETTER_QUEUE_TEMPLATE_ID_NEWSLETTER_TEMPLATE_TEMPLATE_ID" table="newsletter_queue" column="template_id" referenceTable="newsletter_template" referenceColumn="template_id" onDelete="CASCADE"/> - <index name="NEWSLETTER_QUEUE_TEMPLATE_ID" indexType="btree"> + <index referenceId="NEWSLETTER_QUEUE_TEMPLATE_ID" indexType="btree"> <column name="template_id"/> </index> </table> @@ -104,19 +104,19 @@ <column xsi:type="int" name="subscriber_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Subscriber Id"/> <column xsi:type="timestamp" name="letter_sent_at" on_update="false" nullable="true" comment="Letter Sent At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="queue_link_id"/> </constraint> - <constraint xsi:type="foreign" name="NEWSLETTER_QUEUE_LINK_QUEUE_ID_NEWSLETTER_QUEUE_QUEUE_ID" + <constraint xsi:type="foreign" referenceId="NEWSLETTER_QUEUE_LINK_QUEUE_ID_NEWSLETTER_QUEUE_QUEUE_ID" table="newsletter_queue_link" column="queue_id" referenceTable="newsletter_queue" referenceColumn="queue_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="NLTTR_QUEUE_LNK_SUBSCRIBER_ID_NLTTR_SUBSCRIBER_SUBSCRIBER_ID" + <constraint xsi:type="foreign" referenceId="NLTTR_QUEUE_LNK_SUBSCRIBER_ID_NLTTR_SUBSCRIBER_SUBSCRIBER_ID" table="newsletter_queue_link" column="subscriber_id" referenceTable="newsletter_subscriber" referenceColumn="subscriber_id" onDelete="CASCADE"/> - <index name="NEWSLETTER_QUEUE_LINK_SUBSCRIBER_ID" indexType="btree"> + <index referenceId="NEWSLETTER_QUEUE_LINK_SUBSCRIBER_ID" indexType="btree"> <column name="subscriber_id"/> </index> - <index name="NEWSLETTER_QUEUE_LINK_QUEUE_ID_LETTER_SENT_AT" indexType="btree"> + <index referenceId="NEWSLETTER_QUEUE_LINK_QUEUE_ID_LETTER_SENT_AT" indexType="btree"> <column name="queue_id"/> <column name="letter_sent_at"/> </index> @@ -126,17 +126,17 @@ default="0" comment="Queue Id"/> <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Store Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="queue_id"/> <column name="store_id"/> </constraint> - <constraint xsi:type="foreign" name="NEWSLETTER_QUEUE_STORE_LINK_QUEUE_ID_NEWSLETTER_QUEUE_QUEUE_ID" + <constraint xsi:type="foreign" referenceId="NEWSLETTER_QUEUE_STORE_LINK_QUEUE_ID_NEWSLETTER_QUEUE_QUEUE_ID" table="newsletter_queue_store_link" column="queue_id" referenceTable="newsletter_queue" referenceColumn="queue_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="NEWSLETTER_QUEUE_STORE_LINK_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="NEWSLETTER_QUEUE_STORE_LINK_STORE_ID_STORE_STORE_ID" table="newsletter_queue_store_link" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <index name="NEWSLETTER_QUEUE_STORE_LINK_STORE_ID" indexType="btree"> + <index referenceId="NEWSLETTER_QUEUE_STORE_LINK_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -150,19 +150,19 @@ <column xsi:type="int" name="problem_error_code" padding="10" unsigned="true" nullable="true" identity="false" default="0" comment="Problem Error Code"/> <column xsi:type="varchar" name="problem_error_text" nullable="true" length="200" comment="Problem Error Text"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="problem_id"/> </constraint> - <constraint xsi:type="foreign" name="NEWSLETTER_PROBLEM_QUEUE_ID_NEWSLETTER_QUEUE_QUEUE_ID" + <constraint xsi:type="foreign" referenceId="NEWSLETTER_PROBLEM_QUEUE_ID_NEWSLETTER_QUEUE_QUEUE_ID" table="newsletter_problem" column="queue_id" referenceTable="newsletter_queue" referenceColumn="queue_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="NLTTR_PROBLEM_SUBSCRIBER_ID_NLTTR_SUBSCRIBER_SUBSCRIBER_ID" + <constraint xsi:type="foreign" referenceId="NLTTR_PROBLEM_SUBSCRIBER_ID_NLTTR_SUBSCRIBER_SUBSCRIBER_ID" table="newsletter_problem" column="subscriber_id" referenceTable="newsletter_subscriber" referenceColumn="subscriber_id" onDelete="CASCADE"/> - <index name="NEWSLETTER_PROBLEM_SUBSCRIBER_ID" indexType="btree"> + <index referenceId="NEWSLETTER_PROBLEM_SUBSCRIBER_ID" indexType="btree"> <column name="subscriber_id"/> </index> - <index name="NEWSLETTER_PROBLEM_QUEUE_ID" indexType="btree"> + <index referenceId="NEWSLETTER_PROBLEM_QUEUE_ID" indexType="btree"> <column name="queue_id"/> </index> </table> diff --git a/app/code/Magento/OfflineShipping/etc/db_schema.xml b/app/code/Magento/OfflineShipping/etc/db_schema.xml index 80f4b56a1723d..0510ce9b9b8eb 100644 --- a/app/code/Magento/OfflineShipping/etc/db_schema.xml +++ b/app/code/Magento/OfflineShipping/etc/db_schema.xml @@ -25,10 +25,10 @@ comment="Price"/> <column xsi:type="decimal" name="cost" scale="4" precision="12" unsigned="false" nullable="false" default="0" comment="Cost"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="pk"/> </constraint> - <constraint xsi:type="unique" name="UNQ_D60821CDB2AFACEE1566CFC02D0D4CAA"> + <constraint xsi:type="unique" referenceId="UNQ_D60821CDB2AFACEE1566CFC02D0D4CAA"> <column name="website_id"/> <column name="dest_country_id"/> <column name="dest_region_id"/> diff --git a/app/code/Magento/Paypal/etc/db_schema.xml b/app/code/Magento/Paypal/etc/db_schema.xml index 0441231e64ac3..4dc283fcb48ce 100644 --- a/app/code/Magento/Paypal/etc/db_schema.xml +++ b/app/code/Magento/Paypal/etc/db_schema.xml @@ -21,19 +21,19 @@ <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="true" identity="false" comment="Store Id"/> <column xsi:type="varchar" name="agreement_label" nullable="true" length="255" comment="Agreement Label"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="agreement_id"/> </constraint> - <constraint xsi:type="foreign" name="PAYPAL_BILLING_AGREEMENT_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="PAYPAL_BILLING_AGREEMENT_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="paypal_billing_agreement" column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="PAYPAL_BILLING_AGREEMENT_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="PAYPAL_BILLING_AGREEMENT_STORE_ID_STORE_STORE_ID" table="paypal_billing_agreement" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <index name="PAYPAL_BILLING_AGREEMENT_CUSTOMER_ID" indexType="btree"> + <index referenceId="PAYPAL_BILLING_AGREEMENT_CUSTOMER_ID" indexType="btree"> <column name="customer_id"/> </index> - <index name="PAYPAL_BILLING_AGREEMENT_STORE_ID" indexType="btree"> + <index referenceId="PAYPAL_BILLING_AGREEMENT_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -43,17 +43,17 @@ comment="Agreement Id"/> <column xsi:type="int" name="order_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Order Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="agreement_id"/> <column name="order_id"/> </constraint> - <constraint xsi:type="foreign" name="PAYPAL_BILLING_AGRT_ORDER_AGRT_ID_PAYPAL_BILLING_AGRT_AGRT_ID" + <constraint xsi:type="foreign" referenceId="PAYPAL_BILLING_AGRT_ORDER_AGRT_ID_PAYPAL_BILLING_AGRT_AGRT_ID" table="paypal_billing_agreement_order" column="agreement_id" referenceTable="paypal_billing_agreement" referenceColumn="agreement_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="PAYPAL_BILLING_AGREEMENT_ORDER_ORDER_ID_SALES_ORDER_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="PAYPAL_BILLING_AGREEMENT_ORDER_ORDER_ID_SALES_ORDER_ENTITY_ID" table="paypal_billing_agreement_order" column="order_id" referenceTable="sales_order" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="PAYPAL_BILLING_AGREEMENT_ORDER_ORDER_ID" indexType="btree"> + <index referenceId="PAYPAL_BILLING_AGREEMENT_ORDER_ORDER_ID" indexType="btree"> <column name="order_id"/> </index> </table> @@ -64,10 +64,10 @@ <column xsi:type="varchar" name="account_id" nullable="true" length="64" comment="Account Id"/> <column xsi:type="varchar" name="filename" nullable="true" length="24" comment="Filename"/> <column xsi:type="timestamp" name="last_modified" on_update="false" nullable="true" comment="Last Modified"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="report_id"/> </constraint> - <constraint xsi:type="unique" name="PAYPAL_SETTLEMENT_REPORT_REPORT_DATE_ACCOUNT_ID"> + <constraint xsi:type="unique" referenceId="PAYPAL_SETTLEMENT_REPORT_REPORT_DATE_ACCOUNT_ID"> <column name="report_date"/> <column name="account_id"/> </constraint> @@ -105,13 +105,13 @@ <column xsi:type="varchar" name="payment_tracking_id" nullable="true" length="255" comment="Payment Tracking ID"/> <column xsi:type="varchar" name="store_id" nullable="true" length="50" comment="Store ID"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="row_id"/> </constraint> - <constraint xsi:type="foreign" name="FK_E183E488F593E0DE10C6EBFFEBAC9B55" table="paypal_settlement_report_row" + <constraint xsi:type="foreign" referenceId="FK_E183E488F593E0DE10C6EBFFEBAC9B55" table="paypal_settlement_report_row" column="report_id" referenceTable="paypal_settlement_report" referenceColumn="report_id" onDelete="CASCADE"/> - <index name="PAYPAL_SETTLEMENT_REPORT_ROW_REPORT_ID" indexType="btree"> + <index referenceId="PAYPAL_SETTLEMENT_REPORT_ROW_REPORT_ID" indexType="btree"> <column name="report_id"/> </index> </table> @@ -122,12 +122,12 @@ default="0" comment="Website Id"/> <column xsi:type="text" name="content" nullable="true" comment="Content"/> <column xsi:type="timestamp" name="updated_at" on_update="false" nullable="true" comment="Updated At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="cert_id"/> </constraint> - <constraint xsi:type="foreign" name="PAYPAL_CERT_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" table="paypal_cert" + <constraint xsi:type="foreign" referenceId="PAYPAL_CERT_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" table="paypal_cert" column="website_id" referenceTable="store_website" referenceColumn="website_id" onDelete="CASCADE"/> - <index name="PAYPAL_CERT_WEBSITE_ID" indexType="btree"> + <index referenceId="PAYPAL_CERT_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> </table> @@ -138,10 +138,10 @@ <column xsi:type="varchar" name="txn_id" nullable="true" length="100" comment="Txn Id"/> <column xsi:type="blob" name="additional_information" nullable="true" comment="Additional Information"/> <column xsi:type="timestamp" name="created_at" on_update="false" nullable="true" comment="Created At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="transaction_id"/> </constraint> - <constraint xsi:type="unique" name="PAYPAL_PAYMENT_TRANSACTION_TXN_ID"> + <constraint xsi:type="unique" referenceId="PAYPAL_PAYMENT_TRANSACTION_TXN_ID"> <column name="txn_id"/> </constraint> </table> diff --git a/app/code/Magento/Persistent/Model/QuoteManager.php b/app/code/Magento/Persistent/Model/QuoteManager.php index 8937a4920cb23..cd7ce400a0be1 100644 --- a/app/code/Magento/Persistent/Model/QuoteManager.php +++ b/app/code/Magento/Persistent/Model/QuoteManager.php @@ -109,7 +109,7 @@ public function setGuest($checkQuote = false) public function convertCustomerCartToGuest() { /** @var $quote \Magento\Quote\Model\Quote */ - $quote = $this->quoteRepository->get($this->checkoutSession->getQuote()->getId()); + $quote = $this->quoteRepository->get($this->checkoutSession->getQuoteId()); if ($quote && $quote->getId()) { $this->_setQuotePersistent = false; $quote->setIsActive(true) diff --git a/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php b/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php index 5b96acae1d747..e5de8e7d4aade 100644 --- a/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php @@ -245,8 +245,8 @@ public function testConvertCustomerCartToGuest() $emailArgs = ['email' => null]; $this->checkoutSessionMock->expects($this->once()) - ->method('getQuote')->willReturn($this->quoteMock); - $this->quoteMock->expects($this->exactly(2))->method('getId')->willReturn($quoteId); + ->method('getQuoteId')->willReturn($quoteId); + $this->quoteMock->expects($this->once())->method('getId')->willReturn($quoteId); $this->quoteRepositoryMock->expects($this->once())->method('get')->with($quoteId)->willReturn($this->quoteMock); $this->quoteMock->expects($this->once()) ->method('setIsActive')->with(true)->willReturn($this->quoteMock); @@ -286,21 +286,19 @@ public function testConvertCustomerCartToGuest() public function testConvertCustomerCartToGuestWithEmptyQuote() { $this->checkoutSessionMock->expects($this->once()) - ->method('getQuote')->willReturn($this->quoteMock); - $this->quoteMock->expects($this->once())->method('getId')->willReturn(null); + ->method('getQuoteId')->willReturn(null); $this->quoteRepositoryMock->expects($this->once())->method('get')->with(null)->willReturn(null); - $this->model->convertCustomerCartToGuest(); } public function testConvertCustomerCartToGuestWithEmptyQuoteId() { $this->checkoutSessionMock->expects($this->once()) - ->method('getQuote')->willReturn($this->quoteMock); - $this->quoteMock->expects($this->once())->method('getId')->willReturn(1); + ->method('getQuoteId')->willReturn(1); $quoteWithNoId = $this->quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); $quoteWithNoId->expects($this->once())->method('getId')->willReturn(null); $this->quoteRepositoryMock->expects($this->once())->method('get')->with(1)->willReturn($quoteWithNoId); + $this->quoteMock->expects($this->once())->method('getId')->willReturn(1); $this->model->convertCustomerCartToGuest(); } } diff --git a/app/code/Magento/Persistent/etc/db_schema.xml b/app/code/Magento/Persistent/etc/db_schema.xml index 68678fc60f096..5021d240417b2 100644 --- a/app/code/Magento/Persistent/etc/db_schema.xml +++ b/app/code/Magento/Persistent/etc/db_schema.xml @@ -18,22 +18,22 @@ <column xsi:type="text" name="info" nullable="true" comment="Session Data"/> <column xsi:type="timestamp" name="updated_at" on_update="true" nullable="false" default="CURRENT_TIMESTAMP" comment="Updated At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="persistent_id"/> </constraint> - <constraint xsi:type="foreign" name="PERSISTENT_SESSION_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="PERSISTENT_SESSION_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="persistent_session" column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="PERSISTENT_SESSION_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" + <constraint xsi:type="foreign" referenceId="PERSISTENT_SESSION_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" table="persistent_session" column="website_id" referenceTable="store_website" referenceColumn="website_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="PERSISTENT_SESSION_KEY"> + <constraint xsi:type="unique" referenceId="PERSISTENT_SESSION_KEY"> <column name="key"/> </constraint> - <constraint xsi:type="unique" name="PERSISTENT_SESSION_CUSTOMER_ID"> + <constraint xsi:type="unique" referenceId="PERSISTENT_SESSION_CUSTOMER_ID"> <column name="customer_id"/> </constraint> - <index name="PERSISTENT_SESSION_UPDATED_AT" indexType="btree"> + <index referenceId="PERSISTENT_SESSION_UPDATED_AT" indexType="btree"> <column name="updated_at"/> </index> </table> diff --git a/app/code/Magento/ProductAlert/etc/db_schema.xml b/app/code/Magento/ProductAlert/etc/db_schema.xml index ddf8be8a37e9c..62f0eda16afa1 100644 --- a/app/code/Magento/ProductAlert/etc/db_schema.xml +++ b/app/code/Magento/ProductAlert/etc/db_schema.xml @@ -26,25 +26,25 @@ default="0" comment="Product alert send count"/> <column xsi:type="smallint" name="status" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Product alert status"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="alert_price_id"/> </constraint> - <constraint xsi:type="foreign" name="PRODUCT_ALERT_PRICE_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="PRODUCT_ALERT_PRICE_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="product_alert_price" column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="PRODUCT_ALERT_PRICE_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="PRODUCT_ALERT_PRICE_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID" table="product_alert_price" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="PRODUCT_ALERT_PRICE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" + <constraint xsi:type="foreign" referenceId="PRODUCT_ALERT_PRICE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" table="product_alert_price" column="website_id" referenceTable="store_website" referenceColumn="website_id" onDelete="CASCADE"/> - <index name="PRODUCT_ALERT_PRICE_CUSTOMER_ID" indexType="btree"> + <index referenceId="PRODUCT_ALERT_PRICE_CUSTOMER_ID" indexType="btree"> <column name="customer_id"/> </index> - <index name="PRODUCT_ALERT_PRICE_PRODUCT_ID" indexType="btree"> + <index referenceId="PRODUCT_ALERT_PRICE_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> - <index name="PRODUCT_ALERT_PRICE_WEBSITE_ID" indexType="btree"> + <index referenceId="PRODUCT_ALERT_PRICE_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> </table> @@ -65,25 +65,25 @@ default="0" comment="Send Count"/> <column xsi:type="smallint" name="status" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Product alert status"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="alert_stock_id"/> </constraint> - <constraint xsi:type="foreign" name="PRODUCT_ALERT_STOCK_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" + <constraint xsi:type="foreign" referenceId="PRODUCT_ALERT_STOCK_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" table="product_alert_stock" column="website_id" referenceTable="store_website" referenceColumn="website_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="PRODUCT_ALERT_STOCK_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="PRODUCT_ALERT_STOCK_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="product_alert_stock" column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="PRODUCT_ALERT_STOCK_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="PRODUCT_ALERT_STOCK_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID" table="product_alert_stock" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="PRODUCT_ALERT_STOCK_CUSTOMER_ID" indexType="btree"> + <index referenceId="PRODUCT_ALERT_STOCK_CUSTOMER_ID" indexType="btree"> <column name="customer_id"/> </index> - <index name="PRODUCT_ALERT_STOCK_PRODUCT_ID" indexType="btree"> + <index referenceId="PRODUCT_ALERT_STOCK_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> - <index name="PRODUCT_ALERT_STOCK_WEBSITE_ID" indexType="btree"> + <index referenceId="PRODUCT_ALERT_STOCK_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> </table> diff --git a/app/code/Magento/ProductVideo/etc/db_schema.xml b/app/code/Magento/ProductVideo/etc/db_schema.xml index ceaf4d7fbd85d..bfe087d9a5769 100644 --- a/app/code/Magento/ProductVideo/etc/db_schema.xml +++ b/app/code/Magento/ProductVideo/etc/db_schema.xml @@ -18,14 +18,14 @@ <column xsi:type="varchar" name="title" nullable="true" length="255" comment="Title"/> <column xsi:type="text" name="description" nullable="true" comment="Page Meta Description"/> <column xsi:type="text" name="metadata" nullable="true" comment="Video meta data"/> - <constraint xsi:type="foreign" name="FK_6FDF205946906B0E653E60AA769899F8" + <constraint xsi:type="foreign" referenceId="FK_6FDF205946906B0E653E60AA769899F8" table="catalog_product_entity_media_gallery_value_video" column="value_id" referenceTable="catalog_product_entity_media_gallery" referenceColumn="value_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="CAT_PRD_ENTT_MDA_GLR_VAL_VIDEO_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_MDA_GLR_VAL_VIDEO_STORE_ID_STORE_STORE_ID" table="catalog_product_entity_media_gallery_value_video" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="CAT_PRD_ENTT_MDA_GLR_VAL_VIDEO_VAL_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="CAT_PRD_ENTT_MDA_GLR_VAL_VIDEO_VAL_ID_STORE_ID"> <column name="value_id"/> <column name="store_id"/> </constraint> diff --git a/app/code/Magento/Quote/Model/Product/Plugin/MarkQuotesRecollectMassDisabled.php b/app/code/Magento/Quote/Model/Product/Plugin/MarkQuotesRecollectMassDisabled.php new file mode 100644 index 0000000000000..f18bb46fa63fb --- /dev/null +++ b/app/code/Magento/Quote/Model/Product/Plugin/MarkQuotesRecollectMassDisabled.php @@ -0,0 +1,55 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Quote\Model\Product\Plugin; + +use Magento\Catalog\Model\Product\Attribute\Source\Status; +use Magento\Catalog\Model\Product\Action as ProductAction; +use Magento\Quote\Model\ResourceModel\Quote as QuoteResource; + +/** + * Remove quote items after mass disabling products + */ +class MarkQuotesRecollectMassDisabled +{ + /** @var QuoteResource$quoteResource */ + private $quoteResource; + + /** + * @param QuoteResource $quoteResource + */ + public function __construct( + QuoteResource $quoteResource + ) { + $this->quoteResource = $quoteResource; + } + + /** + * Clean quote items after mass disabling product + * + * @param \Magento\Catalog\Model\Product\Action $subject + * @param \Magento\Catalog\Model\Product\Action $result + * @param int[] $productIds + * @param int[] $attrData + * @param int $storeId + * @return \Magento\Catalog\Model\Product\Action + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterUpdateAttributes( + ProductAction $subject, + ProductAction $result, + $productIds, + $attrData, + $storeId + ): ProductAction { + if (isset($attrData['status']) && $attrData['status'] === Status::STATUS_DISABLED) { + $this->quoteResource->markQuotesRecollect($productIds); + } + + return $result; + } +} diff --git a/app/code/Magento/Quote/Model/Quote/TotalsCollector.php b/app/code/Magento/Quote/Model/Quote/TotalsCollector.php index 8fa03232a0e8d..9442cf2f5f1cb 100644 --- a/app/code/Magento/Quote/Model/Quote/TotalsCollector.php +++ b/app/code/Magento/Quote/Model/Quote/TotalsCollector.php @@ -103,6 +103,8 @@ public function __construct( } /** + * Collect quote totals. + * * @param \Magento\Quote\Model\Quote $quote * @return Address\Total */ @@ -115,6 +117,8 @@ public function collectQuoteTotals(\Magento\Quote\Model\Quote $quote) } /** + * Collect quote. + * * @param \Magento\Quote\Model\Quote $quote * @return \Magento\Quote\Model\Quote\Address\Total */ @@ -172,6 +176,8 @@ public function collect(\Magento\Quote\Model\Quote $quote) } /** + * Validate coupon code. + * * @param \Magento\Quote\Model\Quote $quote * @return $this */ @@ -203,11 +209,12 @@ protected function _validateCouponCode(\Magento\Quote\Model\Quote $quote) */ protected function _collectItemsQtys(\Magento\Quote\Model\Quote $quote) { + $quoteItems = $quote->getAllVisibleItems(); $quote->setItemsCount(0); $quote->setItemsQty(0); $quote->setVirtualItemsQty(0); - foreach ($quote->getAllVisibleItems() as $item) { + foreach ($quoteItems as $item) { if ($item->getParentItem()) { continue; } @@ -231,6 +238,8 @@ protected function _collectItemsQtys(\Magento\Quote\Model\Quote $quote) } /** + * Collect address total. + * * @param \Magento\Quote\Model\Quote $quote * @param Address $address * @return Address\Total diff --git a/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php b/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php index 4ca7d75af9e37..abecec395865d 100644 --- a/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php +++ b/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php @@ -3,9 +3,16 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Quote\Model\ResourceModel\Quote\Item; -use \Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection; +use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection; +use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus; +use Magento\Quote\Model\Quote; +use Magento\Quote\Model\Quote\Item as QuoteItem; +use Magento\Quote\Model\ResourceModel\Quote\Item as ResourceQuoteItem; /** * Quote item resource collection @@ -50,6 +57,11 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\VersionContro */ private $storeManager; + /** + * @var bool $recollectQuote + */ + private $recollectQuote = false; + /** * @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory * @param \Psr\Log\LoggerInterface $logger @@ -102,7 +114,7 @@ public function __construct( */ protected function _construct() { - $this->_init(\Magento\Quote\Model\Quote\Item::class, \Magento\Quote\Model\ResourceModel\Quote\Item::class); + $this->_init(QuoteItem::class, ResourceQuoteItem::class); } /** @@ -110,7 +122,7 @@ protected function _construct() * * @return int */ - public function getStoreId() + public function getStoreId(): int { // Fallback to current storeId if no quote is provided // (see https://github.com/magento/magento2/commit/9d3be732a88884a66d667b443b3dc1655ddd0721) @@ -119,12 +131,12 @@ public function getStoreId() } /** - * Set Quote object to Collection + * Set Quote object to Collection. * - * @param \Magento\Quote\Model\Quote $quote + * @param Quote $quote * @return $this */ - public function setQuote($quote) + public function setQuote($quote): self { $this->_quote = $quote; $quoteId = $quote->getId(); @@ -138,13 +150,15 @@ public function setQuote($quote) } /** - * Reset the collection and join it to quotes table. Optionally can select items with specified product id only. + * Reset the collection and inner join it to quotes table. + * + * Optionally can select items with specified product id only * * @param string $quotesTableName * @param int $productId * @return $this */ - public function resetJoinQuotes($quotesTableName, $productId = null) + public function resetJoinQuotes($quotesTableName, $productId = null): self { $this->getSelect()->reset()->from( ['qi' => $this->getResource()->getMainTable()], @@ -161,11 +175,11 @@ public function resetJoinQuotes($quotesTableName, $productId = null) } /** - * After load processing + * After load processing. * * @return $this */ - protected function _afterLoad() + protected function _afterLoad(): self { parent::_afterLoad(); @@ -194,11 +208,11 @@ protected function _afterLoad() } /** - * Add options to items + * Add options to items. * * @return $this */ - protected function _assignOptions() + protected function _assignOptions(): self { $itemIds = array_keys($this->_items); $optionCollection = $this->_itemOptionCollectionFactory->create()->addItemFilter($itemIds); @@ -212,12 +226,12 @@ protected function _assignOptions() } /** - * Add products to items and item options + * Add products to items and item options. * * @return $this * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - protected function _assignProducts() + protected function _assignProducts(): self { \Magento\Framework\Profiler::start('QUOTE:' . __METHOD__, ['group' => 'QUOTE', 'method' => __METHOD__]); $productCollection = $this->_productCollectionFactory->create()->setStoreId( @@ -239,46 +253,30 @@ protected function _assignProducts() ['collection' => $productCollection] ); - $recollectQuote = false; foreach ($this as $item) { + /** @var ProductInterface $product */ $product = $productCollection->getItemById($item->getProductId()); - if ($product) { + $isValidProduct = $this->isValidProduct($product); + $qtyOptions = []; + if ($isValidProduct) { $product->setCustomOptions([]); - $qtyOptions = []; - $optionProductIds = []; - foreach ($item->getOptions() as $option) { - /** - * Call type-specific logic for product associated with quote item - */ - $product->getTypeInstance()->assignProductToOption( - $productCollection->getItemById($option->getProductId()), - $option, - $product - ); - - if (is_object($option->getProduct()) && $option->getProduct()->getId() != $product->getId()) { - $optionProductIds[$option->getProduct()->getId()] = $option->getProduct()->getId(); - } - } - - if ($optionProductIds) { - foreach ($optionProductIds as $optionProductId) { - $qtyOption = $item->getOptionByCode('product_qty_' . $optionProductId); - if ($qtyOption) { - $qtyOptions[$optionProductId] = $qtyOption; - } + $optionProductIds = $this->getOptionProductIds($item, $product, $productCollection); + foreach ($optionProductIds as $optionProductId) { + $qtyOption = $item->getOptionByCode('product_qty_' . $optionProductId); + if ($qtyOption) { + $qtyOptions[$optionProductId] = $qtyOption; } } - - $item->setQtyOptions($qtyOptions)->setProduct($product); } else { $item->isDeleted(true); - $recollectQuote = true; + $this->recollectQuote = true; + } + if (!$item->isDeleted()) { + $item->setQtyOptions($qtyOptions)->setProduct($product); + $item->checkData(); } - $item->checkData(); } - - if ($recollectQuote && $this->_quote) { + if ($this->recollectQuote && $this->_quote) { $this->_quote->collectTotals(); } \Magento\Framework\Profiler::stop('QUOTE:' . __METHOD__); @@ -286,6 +284,57 @@ protected function _assignProducts() return $this; } + /** + * Get product Ids from option. + * + * @param QuoteItem $item + * @param ProductInterface $product + * @param ProductCollection $productCollection + * @return array + */ + private function getOptionProductIds( + QuoteItem $item, + ProductInterface $product, + ProductCollection $productCollection + ): array { + $optionProductIds = []; + foreach ($item->getOptions() as $option) { + /** + * Call type-specific logic for product associated with quote item + */ + $product->getTypeInstance()->assignProductToOption( + $productCollection->getItemById($option->getProductId()), + $option, + $product + ); + + if (is_object($option->getProduct()) && $option->getProduct()->getId() != $product->getId()) { + $isValidProduct = $this->isValidProduct($option->getProduct()); + if (!$isValidProduct && !$item->isDeleted()) { + $item->isDeleted(true); + $this->recollectQuote = true; + continue; + } + $optionProductIds[$option->getProduct()->getId()] = $option->getProduct()->getId(); + } + } + + return $optionProductIds; + } + + /** + * Check is valid product. + * + * @param ProductInterface $product + * @return bool + */ + private function isValidProduct(ProductInterface $product): bool + { + $result = ($product && (int)$product->getStatus() !== ProductStatus::STATUS_DISABLED); + + return $result; + } + /** * Prevents adding stock status filter to the collection of products. * @@ -294,7 +343,7 @@ protected function _assignProducts() * * @see \Magento\CatalogInventory\Helper\Stock::addIsInStockFilterToCollection */ - private function skipStockStatusFilter(ProductCollection $productCollection) + private function skipStockStatusFilter(ProductCollection $productCollection): void { $productCollection->setFlag('has_stock_status_filter', true); } @@ -304,7 +353,7 @@ private function skipStockStatusFilter(ProductCollection $productCollection) * * @return void */ - private function removeItemsWithAbsentProducts() + private function removeItemsWithAbsentProducts(): void { if (count($this->_productIds) === 0) { return; diff --git a/app/code/Magento/Quote/Test/Mftf/ActionGroup/ChangeStatusProductUsingProductGridActionGroup.xml b/app/code/Magento/Quote/Test/Mftf/ActionGroup/ChangeStatusProductUsingProductGridActionGroup.xml new file mode 100644 index 0000000000000..dba4a94f3db2a --- /dev/null +++ b/app/code/Magento/Quote/Test/Mftf/ActionGroup/ChangeStatusProductUsingProductGridActionGroup.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd"> + <!--Disabled a product by filtering grid and using change status action--> + <actionGroup name="ChangeStatusProductUsingProductGridActionGroup"> + <arguments> + <argument name="product"/> + <argument name="status" defaultValue="Enable" type="string" /> + </arguments> + <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="visitAdminProductPage"/> + <waitForPageLoad time="60" stepKey="waitForPageLoadInitial"/> + <conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFiltersInitial"/> + <click selector="{{AdminProductGridFilterSection.filters}}" stepKey="openProductFilters"/> + <fillField selector="{{AdminProductGridFilterSection.skuFilter}}" userInput="{{product.sku}}" stepKey="fillProductSkuFilter"/> + <click selector="{{AdminProductGridFilterSection.applyFilters}}" stepKey="clickApplyFilters"/> + <see selector="{{AdminProductGridSection.productGridCell('1', 'SKU')}}" userInput="{{product.sku}}" stepKey="seeProductSkuInGrid"/> + <click selector="{{AdminProductGridSection.multicheckDropdown}}" stepKey="openMulticheckDropdown"/> + <click selector="{{AdminProductGridSection.multicheckOption('Select All')}}" stepKey="selectAllProductInFilteredGrid"/> + + <click selector="{{AdminProductGridSection.bulkActionDropdown}}" stepKey="clickActionDropdown"/> + <click selector="{{AdminProductGridSection.bulkActionOption('Change status')}}" stepKey="clickChangeStatusAction"/> + <click selector="{{AdminProductGridSection.changeStatus('status')}}" stepKey="clickChangeStatusDisabled" parameterized="true"/> + <see selector="{{AdminMessagesSection.success}}" userInput="A total of 1 record(s) have been updated." stepKey="seeSuccessMessage"/> + <conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFiltersInitial2"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Quote/Test/Mftf/Section/AdminProductGridSection.xml b/app/code/Magento/Quote/Test/Mftf/Section/AdminProductGridSection.xml new file mode 100644 index 0000000000000..32ac73aca7c03 --- /dev/null +++ b/app/code/Magento/Quote/Test/Mftf/Section/AdminProductGridSection.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd"> + <section name="AdminProductGridSection"> + <element name="changeStatus" selector="//div[contains(@class,'admin__data-grid-header-row') and contains(@class, 'row')]//div[contains(@class, 'action-menu-item')]//ul/li/span[text() = '{{status}}']" stepKey="clickChangeStatus" parameterized="true"/> + </section> +</sections> diff --git a/app/code/Magento/Quote/Test/Mftf/Test/StorefrontGuestCheckoutDisabledProductTest.xml b/app/code/Magento/Quote/Test/Mftf/Test/StorefrontGuestCheckoutDisabledProductTest.xml new file mode 100644 index 0000000000000..ab0db2dac643e --- /dev/null +++ b/app/code/Magento/Quote/Test/Mftf/Test/StorefrontGuestCheckoutDisabledProductTest.xml @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontGuestCheckoutDisabledProductTest"> + <annotations> + <features value="Checkout"/> + <stories value="Checkout via the Storefront"/> + <title value="Remove item from cart if product disabled"/> + <description value="Remove item from cart if simple or configurable product is disabled"/> + <severity value="MAJOR"/> + <testCaseId value="MAGETWO-95857"/> + <group value="checkout"/> + </annotations> + <before> + <createData entity="SimpleSubCategory" stepKey="createCategory"/> + <createData entity="_defaultProduct" stepKey="createSimpleProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <!-- Create the configurable product based on the data in the /data folder --> + <createData entity="ApiConfigurableProduct" stepKey="createConfigProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + + <!-- Make the configurable product have two options, that are children of the default attribute set --> + <createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/> + <createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOption1"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <createData entity="productAttributeOption2" stepKey="createConfigProductAttributeOption2"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <createData entity="AddToDefaultSet" stepKey="createConfigAddToAttributeSet"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <getData entity="ProductAttributeOptionGetter" index="1" stepKey="getConfigAttributeOption1"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </getData> + <getData entity="ProductAttributeOptionGetter" index="2" stepKey="getConfigAttributeOption2"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </getData> + + <!-- Create the 2 children that will be a part of the configurable product --> + <createData entity="ApiSimpleOne" stepKey="createConfigChildProduct1"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeOption1"/> + </createData> + <createData entity="ApiSimpleTwo" stepKey="createConfigChildProduct2"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeOption2"/> + </createData> + + <!-- Assign the two products to the configurable product --> + <createData entity="ConfigurableProductTwoOptions" stepKey="createConfigProductOption"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeOption1"/> + <requiredEntity createDataKey="getConfigAttributeOption2"/> + </createData> + <createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddChild1"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigChildProduct1"/> + </createData> + <createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddChild2"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigChildProduct2"/> + </createData> + </before> + <after> + <deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> + <deleteData createDataKey="createConfigChildProduct1" stepKey="deleteConfigChildProduct1"/> + <deleteData createDataKey="createConfigChildProduct2" stepKey="deleteConfigChildProduct2"/> + <deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/> + </after> + <!-- Step 1: Add simple product to shopping cart --> + <amOnPage url="{{StorefrontProductPage.url($$createSimpleProduct.name$$)}}" stepKey="amOnSimpleProductPage"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + <actionGroup ref="AddSimpleProductToCart" stepKey="cartAddSimpleProductToCart"> + <argument name="product" value="$$createSimpleProduct$$"/> + <argument name="productCount" value="1"/> + </actionGroup> + <amOnPage url="{{StorefrontProductPage.url($$createConfigProduct.custom_attributes[url_key]$$)}}" stepKey="goToConfigProductPage"/> + <waitForPageLoad stepKey="waitForStoreFrontLoad"/> + <selectOption selector="{{StorefrontProductInfoMainSection.productAttributeOptionsSelectButton}}" userInput="$$getConfigAttributeOption1.value$$" stepKey="selectOption"/> + <click selector="{{StorefrontProductInfoMainSection.AddToCart}}" stepKey="clickAddToCart" /> + <waitForElement selector="{{StorefrontMessagesSection.messageProductAddedToCart($$createConfigProduct.name$$)}}" time="30" stepKey="assertMessage"/> + <!--Disabled via admin panel--> + <openNewTab stepKey="openNewTab"/> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + <!-- Find the first simple product that we just created using the product grid and go to its page--> + <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="visitAdminProductPage"/> + <waitForPageLoad stepKey="waitForAdminProductGridLoad"/> + <conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFiltersInitial"/> + <actionGroup ref="filterProductGridBySku" stepKey="findCreatedProduct"> + <argument name="product" value="$$createConfigChildProduct1$$"/> + </actionGroup> + <waitForPageLoad stepKey="waitForFiltersToBeApplied"/> + <click selector="{{AdminProductGridSection.firstRow}}" stepKey="clickOnProductPage"/> + <waitForPageLoad stepKey="waitForProductPageLoad"/> + <!-- Disabled child configurable product --> + <click selector="{{AdminProductFormSection.enableProductAttributeLabel}}" stepKey="clickDisableProduct"/> + <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSaveProduct"/> + <waitForPageLoad stepKey="waitForProductPageSaved"/> + <!-- Disabled simple product from grid --> + <actionGroup ref="ChangeStatusProductUsingProductGridActionGroup" stepKey="disabledProductFromGrid"> + <argument name="product" value="$$createSimpleProduct$$"/> + <argument name="status" value="Disable"/> + </actionGroup> + <closeTab stepKey="closeTab"/> + <!--Check cart--> + <reloadPage stepKey="reloadPage"/> + <waitForPageLoad stepKey="waitForCheckoutPageReload2"/> + <click selector="{{StorefrontMiniCartSection.show}}" stepKey="clickMiniCart"/> + <dontSeeElement selector="{{StorefrontMiniCartSection.quantity}}" stepKey="dontSeeCartItem"/> + </test> +</tests> diff --git a/app/code/Magento/Quote/etc/db_schema.xml b/app/code/Magento/Quote/etc/db_schema.xml index 725825e976ad7..7dd215b87e8cc 100644 --- a/app/code/Magento/Quote/etc/db_schema.xml +++ b/app/code/Magento/Quote/etc/db_schema.xml @@ -87,17 +87,17 @@ <column xsi:type="smallint" name="trigger_recollect" padding="6" unsigned="false" nullable="false" identity="false" default="0" comment="Trigger Recollect"/> <column xsi:type="text" name="ext_shipping_info" nullable="true" comment="Ext Shipping Info"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="QUOTE_STORE_ID_STORE_STORE_ID" table="quote" column="store_id" + <constraint xsi:type="foreign" referenceId="QUOTE_STORE_ID_STORE_STORE_ID" table="quote" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <index name="QUOTE_CUSTOMER_ID_STORE_ID_IS_ACTIVE" indexType="btree"> + <index referenceId="QUOTE_CUSTOMER_ID_STORE_ID_IS_ACTIVE" indexType="btree"> <column name="customer_id"/> <column name="store_id"/> <column name="is_active"/> </index> - <index name="QUOTE_STORE_ID" indexType="btree"> + <index referenceId="QUOTE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -202,12 +202,12 @@ <column xsi:type="text" name="vat_request_date" nullable="true" comment="Vat Request Date"/> <column xsi:type="smallint" name="vat_request_success" padding="6" unsigned="false" nullable="true" identity="false" comment="Vat Request Success"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="address_id"/> </constraint> - <constraint xsi:type="foreign" name="QUOTE_ADDRESS_QUOTE_ID_QUOTE_ENTITY_ID" table="quote_address" + <constraint xsi:type="foreign" referenceId="QUOTE_ADDRESS_QUOTE_ID_QUOTE_ENTITY_ID" table="quote_address" column="quote_id" referenceTable="quote" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="QUOTE_ADDRESS_QUOTE_ID" indexType="btree"> + <index referenceId="QUOTE_ADDRESS_QUOTE_ID" indexType="btree"> <column name="quote_id"/> </index> </table> @@ -289,25 +289,25 @@ nullable="true" comment="Discount Tax Compensation Amount"/> <column xsi:type="decimal" name="base_discount_tax_compensation_amount" scale="4" precision="12" unsigned="false" nullable="true" comment="Base Discount Tax Compensation Amount"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="item_id"/> </constraint> - <constraint xsi:type="foreign" name="QUOTE_ITEM_PARENT_ITEM_ID_QUOTE_ITEM_ITEM_ID" table="quote_item" + <constraint xsi:type="foreign" referenceId="QUOTE_ITEM_PARENT_ITEM_ID_QUOTE_ITEM_ITEM_ID" table="quote_item" column="parent_item_id" referenceTable="quote_item" referenceColumn="item_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="QUOTE_ITEM_QUOTE_ID_QUOTE_ENTITY_ID" table="quote_item" column="quote_id" + <constraint xsi:type="foreign" referenceId="QUOTE_ITEM_QUOTE_ID_QUOTE_ENTITY_ID" table="quote_item" column="quote_id" referenceTable="quote" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="QUOTE_ITEM_STORE_ID_STORE_STORE_ID" table="quote_item" column="store_id" + <constraint xsi:type="foreign" referenceId="QUOTE_ITEM_STORE_ID_STORE_STORE_ID" table="quote_item" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <index name="QUOTE_ITEM_PARENT_ITEM_ID" indexType="btree"> + <index referenceId="QUOTE_ITEM_PARENT_ITEM_ID" indexType="btree"> <column name="parent_item_id"/> </index> - <index name="QUOTE_ITEM_PRODUCT_ID" indexType="btree"> + <index referenceId="QUOTE_ITEM_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> - <index name="QUOTE_ITEM_QUOTE_ID" indexType="btree"> + <index referenceId="QUOTE_ITEM_QUOTE_ID" indexType="btree"> <column name="quote_id"/> </index> - <index name="QUOTE_ITEM_STORE_ID" indexType="btree"> + <index referenceId="QUOTE_ITEM_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -382,25 +382,25 @@ nullable="true" comment="Discount Tax Compensation Amount"/> <column xsi:type="decimal" name="base_discount_tax_compensation_amount" scale="4" precision="12" unsigned="false" nullable="true" comment="Base Discount Tax Compensation Amount"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="address_item_id"/> </constraint> - <constraint xsi:type="foreign" name="QUOTE_ADDRESS_ITEM_QUOTE_ADDRESS_ID_QUOTE_ADDRESS_ADDRESS_ID" + <constraint xsi:type="foreign" referenceId="QUOTE_ADDRESS_ITEM_QUOTE_ADDRESS_ID_QUOTE_ADDRESS_ADDRESS_ID" table="quote_address_item" column="quote_address_id" referenceTable="quote_address" referenceColumn="address_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="QUOTE_ADDR_ITEM_PARENT_ITEM_ID_QUOTE_ADDR_ITEM_ADDR_ITEM_ID" + <constraint xsi:type="foreign" referenceId="QUOTE_ADDR_ITEM_PARENT_ITEM_ID_QUOTE_ADDR_ITEM_ADDR_ITEM_ID" table="quote_address_item" column="parent_item_id" referenceTable="quote_address_item" referenceColumn="address_item_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="QUOTE_ADDRESS_ITEM_QUOTE_ITEM_ID_QUOTE_ITEM_ITEM_ID" + <constraint xsi:type="foreign" referenceId="QUOTE_ADDRESS_ITEM_QUOTE_ITEM_ID_QUOTE_ITEM_ITEM_ID" table="quote_address_item" column="quote_item_id" referenceTable="quote_item" referenceColumn="item_id" onDelete="CASCADE"/> - <index name="QUOTE_ADDRESS_ITEM_QUOTE_ADDRESS_ID" indexType="btree"> + <index referenceId="QUOTE_ADDRESS_ITEM_QUOTE_ADDRESS_ID" indexType="btree"> <column name="quote_address_id"/> </index> - <index name="QUOTE_ADDRESS_ITEM_PARENT_ITEM_ID" indexType="btree"> + <index referenceId="QUOTE_ADDRESS_ITEM_PARENT_ITEM_ID" indexType="btree"> <column name="parent_item_id"/> </index> - <index name="QUOTE_ADDRESS_ITEM_QUOTE_ITEM_ID" indexType="btree"> + <index referenceId="QUOTE_ADDRESS_ITEM_QUOTE_ITEM_ID" indexType="btree"> <column name="quote_item_id"/> </index> </table> @@ -413,12 +413,12 @@ comment="Product Id"/> <column xsi:type="varchar" name="code" nullable="false" length="255" comment="Code"/> <column xsi:type="text" name="value" nullable="true" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="option_id"/> </constraint> - <constraint xsi:type="foreign" name="QUOTE_ITEM_OPTION_ITEM_ID_QUOTE_ITEM_ITEM_ID" table="quote_item_option" + <constraint xsi:type="foreign" referenceId="QUOTE_ITEM_OPTION_ITEM_ID_QUOTE_ITEM_ITEM_ID" table="quote_item_option" column="item_id" referenceTable="quote_item" referenceColumn="item_id" onDelete="CASCADE"/> - <index name="QUOTE_ITEM_OPTION_ITEM_ID" indexType="btree"> + <index referenceId="QUOTE_ITEM_OPTION_ITEM_ID" indexType="btree"> <column name="item_id"/> </index> </table> @@ -449,12 +449,12 @@ <column xsi:type="text" name="additional_data" nullable="true" comment="Additional Data"/> <column xsi:type="varchar" name="cc_ss_issue" nullable="true" length="255" comment="Cc Ss Issue"/> <column xsi:type="text" name="additional_information" nullable="true" comment="Additional Information"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="payment_id"/> </constraint> - <constraint xsi:type="foreign" name="QUOTE_PAYMENT_QUOTE_ID_QUOTE_ENTITY_ID" table="quote_payment" + <constraint xsi:type="foreign" referenceId="QUOTE_PAYMENT_QUOTE_ID_QUOTE_ENTITY_ID" table="quote_payment" column="quote_id" referenceTable="quote" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="QUOTE_PAYMENT_QUOTE_ID" indexType="btree"> + <index referenceId="QUOTE_PAYMENT_QUOTE_ID" indexType="btree"> <column name="quote_id"/> </index> </table> @@ -476,13 +476,13 @@ comment="Price"/> <column xsi:type="text" name="error_message" nullable="true" comment="Error Message"/> <column xsi:type="text" name="method_title" nullable="true" comment="Method Title"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="rate_id"/> </constraint> - <constraint xsi:type="foreign" name="QUOTE_SHIPPING_RATE_ADDRESS_ID_QUOTE_ADDRESS_ADDRESS_ID" + <constraint xsi:type="foreign" referenceId="QUOTE_SHIPPING_RATE_ADDRESS_ID_QUOTE_ADDRESS_ADDRESS_ID" table="quote_shipping_rate" column="address_id" referenceTable="quote_address" referenceColumn="address_id" onDelete="CASCADE"/> - <index name="QUOTE_SHIPPING_RATE_ADDRESS_ID" indexType="btree"> + <index referenceId="QUOTE_SHIPPING_RATE_ADDRESS_ID" indexType="btree"> <column name="address_id"/> </index> </table> @@ -492,16 +492,16 @@ <column xsi:type="int" name="quote_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Quote ID"/> <column xsi:type="varchar" name="masked_id" nullable="true" length="32" comment="Masked ID"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> <column name="quote_id"/> </constraint> - <constraint xsi:type="foreign" name="QUOTE_ID_MASK_QUOTE_ID_QUOTE_ENTITY_ID" table="quote_id_mask" + <constraint xsi:type="foreign" referenceId="QUOTE_ID_MASK_QUOTE_ID_QUOTE_ENTITY_ID" table="quote_id_mask" column="quote_id" referenceTable="quote" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="QUOTE_ID_MASK_QUOTE_ID" indexType="btree"> + <index referenceId="QUOTE_ID_MASK_QUOTE_ID" indexType="btree"> <column name="quote_id"/> </index> - <index name="QUOTE_ID_MASK_MASKED_ID" indexType="btree"> + <index referenceId="QUOTE_ID_MASK_MASKED_ID" indexType="btree"> <column name="masked_id"/> </index> </table> diff --git a/app/code/Magento/Quote/etc/di.xml b/app/code/Magento/Quote/etc/di.xml index bc131b2987a8c..cd5e62307fdca 100644 --- a/app/code/Magento/Quote/etc/di.xml +++ b/app/code/Magento/Quote/etc/di.xml @@ -98,6 +98,9 @@ <plugin name="clean_quote_items_after_product_delete" type="Magento\Quote\Model\Product\Plugin\RemoveQuoteItems"/> <plugin name="update_quote_items_after_product_save" type="Magento\Quote\Model\Product\Plugin\UpdateQuoteItems"/> </type> + <type name="Magento\Catalog\Model\Product\Action"> + <plugin name="quoteProductMassChange" type="Magento\Quote\Model\Product\Plugin\MarkQuotesRecollectMassDisabled"/> + </type> <type name="Magento\Quote\Model\ValidationRules\QuoteValidationComposite"> <arguments> <argument name="validationRules" xsi:type="array"> diff --git a/app/code/Magento/ReleaseNotification/etc/db_schema.xml b/app/code/Magento/ReleaseNotification/etc/db_schema.xml index 367957fc17732..6f3aa481f73d4 100644 --- a/app/code/Magento/ReleaseNotification/etc/db_schema.xml +++ b/app/code/Magento/ReleaseNotification/etc/db_schema.xml @@ -15,13 +15,13 @@ comment="Viewer admin user ID"/> <column xsi:type="varchar" name="last_view_version" nullable="false" length="16" comment="Viewer last view on product version"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="RELEASE_NOTIFICATION_VIEWER_LOG_VIEWER_ID_ADMIN_USER_USER_ID" + <constraint xsi:type="foreign" referenceId="RELEASE_NOTIFICATION_VIEWER_LOG_VIEWER_ID_ADMIN_USER_USER_ID" table="release_notification_viewer_log" column="viewer_id" referenceTable="admin_user" referenceColumn="user_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="RELEASE_NOTIFICATION_VIEWER_LOG_VIEWER_ID"> + <constraint xsi:type="unique" referenceId="RELEASE_NOTIFICATION_VIEWER_LOG_VIEWER_ID"> <column name="viewer_id"/> </constraint> </table> diff --git a/app/code/Magento/Reports/etc/db_schema.xml b/app/code/Magento/Reports/etc/db_schema.xml index f6c8074411bfc..1321ebba4d3d6 100644 --- a/app/code/Magento/Reports/etc/db_schema.xml +++ b/app/code/Magento/Reports/etc/db_schema.xml @@ -21,33 +21,33 @@ comment="Store Id"/> <column xsi:type="timestamp" name="added_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Added At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="index_id"/> </constraint> - <constraint xsi:type="foreign" name="REPORT_CMPD_PRD_IDX_CSTR_ID_CSTR_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="REPORT_CMPD_PRD_IDX_CSTR_ID_CSTR_ENTT_ENTT_ID" table="report_compared_product_index" column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="REPORT_CMPD_PRD_IDX_PRD_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="REPORT_CMPD_PRD_IDX_PRD_ID_CAT_PRD_ENTT_ENTT_ID" table="report_compared_product_index" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="REPORT_COMPARED_PRODUCT_INDEX_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="REPORT_COMPARED_PRODUCT_INDEX_STORE_ID_STORE_STORE_ID" table="report_compared_product_index" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <constraint xsi:type="unique" name="REPORT_COMPARED_PRODUCT_INDEX_VISITOR_ID_PRODUCT_ID"> + <constraint xsi:type="unique" referenceId="REPORT_COMPARED_PRODUCT_INDEX_VISITOR_ID_PRODUCT_ID"> <column name="visitor_id"/> <column name="product_id"/> </constraint> - <constraint xsi:type="unique" name="REPORT_COMPARED_PRODUCT_INDEX_CUSTOMER_ID_PRODUCT_ID"> + <constraint xsi:type="unique" referenceId="REPORT_COMPARED_PRODUCT_INDEX_CUSTOMER_ID_PRODUCT_ID"> <column name="customer_id"/> <column name="product_id"/> </constraint> - <index name="REPORT_COMPARED_PRODUCT_INDEX_STORE_ID" indexType="btree"> + <index referenceId="REPORT_COMPARED_PRODUCT_INDEX_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="REPORT_COMPARED_PRODUCT_INDEX_ADDED_AT" indexType="btree"> + <index referenceId="REPORT_COMPARED_PRODUCT_INDEX_ADDED_AT" indexType="btree"> <column name="added_at"/> </index> - <index name="REPORT_COMPARED_PRODUCT_INDEX_PRODUCT_ID" indexType="btree"> + <index referenceId="REPORT_COMPARED_PRODUCT_INDEX_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> </table> @@ -65,33 +65,33 @@ comment="Store Id"/> <column xsi:type="timestamp" name="added_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Added At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="index_id"/> </constraint> - <constraint xsi:type="foreign" name="REPORT_VIEWED_PRD_IDX_CSTR_ID_CSTR_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="REPORT_VIEWED_PRD_IDX_CSTR_ID_CSTR_ENTT_ENTT_ID" table="report_viewed_product_index" column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="REPORT_VIEWED_PRD_IDX_PRD_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="REPORT_VIEWED_PRD_IDX_PRD_ID_CAT_PRD_ENTT_ENTT_ID" table="report_viewed_product_index" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="REPORT_VIEWED_PRODUCT_INDEX_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="REPORT_VIEWED_PRODUCT_INDEX_STORE_ID_STORE_STORE_ID" table="report_viewed_product_index" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <constraint xsi:type="unique" name="REPORT_VIEWED_PRODUCT_INDEX_VISITOR_ID_PRODUCT_ID"> + <constraint xsi:type="unique" referenceId="REPORT_VIEWED_PRODUCT_INDEX_VISITOR_ID_PRODUCT_ID"> <column name="visitor_id"/> <column name="product_id"/> </constraint> - <constraint xsi:type="unique" name="REPORT_VIEWED_PRODUCT_INDEX_CUSTOMER_ID_PRODUCT_ID"> + <constraint xsi:type="unique" referenceId="REPORT_VIEWED_PRODUCT_INDEX_CUSTOMER_ID_PRODUCT_ID"> <column name="customer_id"/> <column name="product_id"/> </constraint> - <index name="REPORT_VIEWED_PRODUCT_INDEX_STORE_ID" indexType="btree"> + <index referenceId="REPORT_VIEWED_PRODUCT_INDEX_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="REPORT_VIEWED_PRODUCT_INDEX_ADDED_AT" indexType="btree"> + <index referenceId="REPORT_VIEWED_PRODUCT_INDEX_ADDED_AT" indexType="btree"> <column name="added_at"/> </index> - <index name="REPORT_VIEWED_PRODUCT_INDEX_PRODUCT_ID" indexType="btree"> + <index referenceId="REPORT_VIEWED_PRODUCT_INDEX_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> </table> @@ -101,7 +101,7 @@ <column xsi:type="varchar" name="event_name" nullable="false" length="64" comment="Event Name"/> <column xsi:type="smallint" name="customer_login" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Customer Login"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="event_type_id"/> </constraint> </table> @@ -120,27 +120,27 @@ default="0" comment="Subtype"/> <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Store Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="event_id"/> </constraint> - <constraint xsi:type="foreign" name="REPORT_EVENT_STORE_ID_STORE_STORE_ID" table="report_event" + <constraint xsi:type="foreign" referenceId="REPORT_EVENT_STORE_ID_STORE_STORE_ID" table="report_event" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="REPORT_EVENT_EVENT_TYPE_ID_REPORT_EVENT_TYPES_EVENT_TYPE_ID" + <constraint xsi:type="foreign" referenceId="REPORT_EVENT_EVENT_TYPE_ID_REPORT_EVENT_TYPES_EVENT_TYPE_ID" table="report_event" column="event_type_id" referenceTable="report_event_types" referenceColumn="event_type_id" onDelete="CASCADE"/> - <index name="REPORT_EVENT_EVENT_TYPE_ID" indexType="btree"> + <index referenceId="REPORT_EVENT_EVENT_TYPE_ID" indexType="btree"> <column name="event_type_id"/> </index> - <index name="REPORT_EVENT_SUBJECT_ID" indexType="btree"> + <index referenceId="REPORT_EVENT_SUBJECT_ID" indexType="btree"> <column name="subject_id"/> </index> - <index name="REPORT_EVENT_OBJECT_ID" indexType="btree"> + <index referenceId="REPORT_EVENT_OBJECT_ID" indexType="btree"> <column name="object_id"/> </index> - <index name="REPORT_EVENT_SUBTYPE" indexType="btree"> + <index referenceId="REPORT_EVENT_SUBTYPE" indexType="btree"> <column name="subtype"/> </index> - <index name="REPORT_EVENT_STORE_ID" indexType="btree"> + <index referenceId="REPORT_EVENT_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -159,24 +159,24 @@ default="0" comment="Number of Views"/> <column xsi:type="smallint" name="rating_pos" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Rating Pos"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="REPORT_VIEWED_PRODUCT_AGGREGATED_DAILY_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="REPORT_VIEWED_PRODUCT_AGGREGATED_DAILY_STORE_ID_STORE_STORE_ID" table="report_viewed_product_aggregated_daily" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="REPORT_VIEWED_PRD_AGGRED_DAILY_PRD_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="REPORT_VIEWED_PRD_AGGRED_DAILY_PRD_ID_CAT_PRD_ENTT_ENTT_ID" table="report_viewed_product_aggregated_daily" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="REPORT_VIEWED_PRD_AGGRED_DAILY_PERIOD_STORE_ID_PRD_ID"> + <constraint xsi:type="unique" referenceId="REPORT_VIEWED_PRD_AGGRED_DAILY_PERIOD_STORE_ID_PRD_ID"> <column name="period"/> <column name="store_id"/> <column name="product_id"/> </constraint> - <index name="REPORT_VIEWED_PRODUCT_AGGREGATED_DAILY_STORE_ID" indexType="btree"> + <index referenceId="REPORT_VIEWED_PRODUCT_AGGREGATED_DAILY_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="REPORT_VIEWED_PRODUCT_AGGREGATED_DAILY_PRODUCT_ID" indexType="btree"> + <index referenceId="REPORT_VIEWED_PRODUCT_AGGREGATED_DAILY_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> </table> @@ -195,24 +195,24 @@ default="0" comment="Number of Views"/> <column xsi:type="smallint" name="rating_pos" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Rating Pos"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="REPORT_VIEWED_PRODUCT_AGGREGATED_MONTHLY_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="REPORT_VIEWED_PRODUCT_AGGREGATED_MONTHLY_STORE_ID_STORE_STORE_ID" table="report_viewed_product_aggregated_monthly" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="REPORT_VIEWED_PRD_AGGRED_MONTHLY_PRD_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="REPORT_VIEWED_PRD_AGGRED_MONTHLY_PRD_ID_CAT_PRD_ENTT_ENTT_ID" table="report_viewed_product_aggregated_monthly" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="REPORT_VIEWED_PRD_AGGRED_MONTHLY_PERIOD_STORE_ID_PRD_ID"> + <constraint xsi:type="unique" referenceId="REPORT_VIEWED_PRD_AGGRED_MONTHLY_PERIOD_STORE_ID_PRD_ID"> <column name="period"/> <column name="store_id"/> <column name="product_id"/> </constraint> - <index name="REPORT_VIEWED_PRODUCT_AGGREGATED_MONTHLY_STORE_ID" indexType="btree"> + <index referenceId="REPORT_VIEWED_PRODUCT_AGGREGATED_MONTHLY_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="REPORT_VIEWED_PRODUCT_AGGREGATED_MONTHLY_PRODUCT_ID" indexType="btree"> + <index referenceId="REPORT_VIEWED_PRODUCT_AGGREGATED_MONTHLY_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> </table> @@ -231,24 +231,24 @@ default="0" comment="Number of Views"/> <column xsi:type="smallint" name="rating_pos" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Rating Pos"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="REPORT_VIEWED_PRODUCT_AGGREGATED_YEARLY_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="REPORT_VIEWED_PRODUCT_AGGREGATED_YEARLY_STORE_ID_STORE_STORE_ID" table="report_viewed_product_aggregated_yearly" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="REPORT_VIEWED_PRD_AGGRED_YEARLY_PRD_ID_CAT_PRD_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="REPORT_VIEWED_PRD_AGGRED_YEARLY_PRD_ID_CAT_PRD_ENTT_ENTT_ID" table="report_viewed_product_aggregated_yearly" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="REPORT_VIEWED_PRD_AGGRED_YEARLY_PERIOD_STORE_ID_PRD_ID"> + <constraint xsi:type="unique" referenceId="REPORT_VIEWED_PRD_AGGRED_YEARLY_PERIOD_STORE_ID_PRD_ID"> <column name="period"/> <column name="store_id"/> <column name="product_id"/> </constraint> - <index name="REPORT_VIEWED_PRODUCT_AGGREGATED_YEARLY_STORE_ID" indexType="btree"> + <index referenceId="REPORT_VIEWED_PRODUCT_AGGREGATED_YEARLY_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="REPORT_VIEWED_PRODUCT_AGGREGATED_YEARLY_PRODUCT_ID" indexType="btree"> + <index referenceId="REPORT_VIEWED_PRODUCT_AGGREGATED_YEARLY_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> </table> diff --git a/app/code/Magento/Review/Model/ResourceModel/Review/Product/Collection.php b/app/code/Magento/Review/Model/ResourceModel/Review/Product/Collection.php index 99c963501a9d4..4e55484e5dd94 100644 --- a/app/code/Magento/Review/Model/ResourceModel/Review/Product/Collection.php +++ b/app/code/Magento/Review/Model/ResourceModel/Review/Product/Collection.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Review\Model\ResourceModel\Review\Product; use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; @@ -403,12 +404,20 @@ public function getAllIds($limit = null, $offset = null) public function getResultingIds() { $idsSelect = clone $this->getSelect(); - $idsSelect->reset(Select::LIMIT_COUNT); - $idsSelect->reset(Select::LIMIT_OFFSET); - $idsSelect->reset(Select::COLUMNS); - $idsSelect->reset(Select::ORDER); - $idsSelect->columns('rt.review_id'); - return $this->getConnection()->fetchCol($idsSelect); + $data = $this->getConnection() + ->fetchAll( + $idsSelect + ->reset(Select::LIMIT_COUNT) + ->reset(Select::LIMIT_OFFSET) + ->columns('rt.review_id') + ); + + return array_map( + function ($value) { + return $value['review_id']; + }, + $data + ); } /** diff --git a/app/code/Magento/Review/etc/db_schema.xml b/app/code/Magento/Review/etc/db_schema.xml index 2ae43ea608eca..d1090d413384b 100644 --- a/app/code/Magento/Review/etc/db_schema.xml +++ b/app/code/Magento/Review/etc/db_schema.xml @@ -11,7 +11,7 @@ <column xsi:type="smallint" name="entity_id" padding="5" unsigned="true" nullable="false" identity="true" comment="Review entity id"/> <column xsi:type="varchar" name="entity_code" nullable="false" length="32" comment="Review entity code"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> </table> @@ -19,7 +19,7 @@ <column xsi:type="smallint" name="status_id" padding="5" unsigned="true" nullable="false" identity="true" comment="Status id"/> <column xsi:type="varchar" name="status_code" nullable="false" length="32" comment="Status code"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="status_id"/> </constraint> </table> @@ -34,20 +34,20 @@ default="0" comment="Product id"/> <column xsi:type="smallint" name="status_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Status code"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="review_id"/> </constraint> - <constraint xsi:type="foreign" name="REVIEW_ENTITY_ID_REVIEW_ENTITY_ENTITY_ID" table="review" column="entity_id" + <constraint xsi:type="foreign" referenceId="REVIEW_ENTITY_ID_REVIEW_ENTITY_ENTITY_ID" table="review" column="entity_id" referenceTable="review_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="REVIEW_STATUS_ID_REVIEW_STATUS_STATUS_ID" table="review" column="status_id" + <constraint xsi:type="foreign" referenceId="REVIEW_STATUS_ID_REVIEW_STATUS_STATUS_ID" table="review" column="status_id" referenceTable="review_status" referenceColumn="status_id" onDelete="NO ACTION"/> - <index name="REVIEW_ENTITY_ID" indexType="btree"> + <index referenceId="REVIEW_ENTITY_ID" indexType="btree"> <column name="entity_id"/> </index> - <index name="REVIEW_STATUS_ID" indexType="btree"> + <index referenceId="REVIEW_STATUS_ID" indexType="btree"> <column name="status_id"/> </index> - <index name="REVIEW_ENTITY_PK_VALUE" indexType="btree"> + <index referenceId="REVIEW_ENTITY_PK_VALUE" indexType="btree"> <column name="entity_pk_value"/> </index> </table> @@ -63,23 +63,23 @@ <column xsi:type="varchar" name="nickname" nullable="false" length="128" comment="User nickname"/> <column xsi:type="int" name="customer_id" padding="10" unsigned="true" nullable="true" identity="false" comment="Customer Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="detail_id"/> </constraint> - <constraint xsi:type="foreign" name="REVIEW_DETAIL_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="review_detail" + <constraint xsi:type="foreign" referenceId="REVIEW_DETAIL_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="review_detail" column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="SET NULL"/> - <constraint xsi:type="foreign" name="REVIEW_DETAIL_REVIEW_ID_REVIEW_REVIEW_ID" table="review_detail" + <constraint xsi:type="foreign" referenceId="REVIEW_DETAIL_REVIEW_ID_REVIEW_REVIEW_ID" table="review_detail" column="review_id" referenceTable="review" referenceColumn="review_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="REVIEW_DETAIL_STORE_ID_STORE_STORE_ID" table="review_detail" + <constraint xsi:type="foreign" referenceId="REVIEW_DETAIL_STORE_ID_STORE_STORE_ID" table="review_detail" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <index name="REVIEW_DETAIL_REVIEW_ID" indexType="btree"> + <index referenceId="REVIEW_DETAIL_REVIEW_ID" indexType="btree"> <column name="review_id"/> </index> - <index name="REVIEW_DETAIL_STORE_ID" indexType="btree"> + <index referenceId="REVIEW_DETAIL_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="REVIEW_DETAIL_CUSTOMER_ID" indexType="btree"> + <index referenceId="REVIEW_DETAIL_CUSTOMER_ID" indexType="btree"> <column name="customer_id"/> </index> </table> @@ -96,13 +96,13 @@ default="0" comment="Summarized rating"/> <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Store ID"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="primary_id"/> </constraint> - <constraint xsi:type="foreign" name="REVIEW_ENTITY_SUMMARY_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="REVIEW_ENTITY_SUMMARY_STORE_ID_STORE_STORE_ID" table="review_entity_summary" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <index name="REVIEW_ENTITY_SUMMARY_STORE_ID" indexType="btree"> + <index referenceId="REVIEW_ENTITY_SUMMARY_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -111,15 +111,15 @@ comment="Review ID"/> <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Store ID"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="review_id"/> <column name="store_id"/> </constraint> - <constraint xsi:type="foreign" name="REVIEW_STORE_REVIEW_ID_REVIEW_REVIEW_ID" table="review_store" + <constraint xsi:type="foreign" referenceId="REVIEW_STORE_REVIEW_ID_REVIEW_REVIEW_ID" table="review_store" column="review_id" referenceTable="review" referenceColumn="review_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="REVIEW_STORE_STORE_ID_STORE_STORE_ID" table="review_store" + <constraint xsi:type="foreign" referenceId="REVIEW_STORE_STORE_ID_STORE_STORE_ID" table="review_store" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <index name="REVIEW_STORE_STORE_ID" indexType="btree"> + <index referenceId="REVIEW_STORE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -127,10 +127,10 @@ <column xsi:type="smallint" name="entity_id" padding="5" unsigned="true" nullable="false" identity="true" comment="Entity ID"/> <column xsi:type="varchar" name="entity_code" nullable="false" length="64" comment="Entity Code"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="unique" name="RATING_ENTITY_ENTITY_CODE"> + <constraint xsi:type="unique" referenceId="RATING_ENTITY_ENTITY_CODE"> <column name="entity_code"/> </constraint> </table> @@ -144,15 +144,15 @@ default="0" comment="Rating Position On Storefront"/> <column xsi:type="smallint" name="is_active" padding="6" unsigned="false" nullable="false" identity="false" default="1" comment="Rating is active."/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="rating_id"/> </constraint> - <constraint xsi:type="foreign" name="RATING_ENTITY_ID_RATING_ENTITY_ENTITY_ID" table="rating" column="entity_id" + <constraint xsi:type="foreign" referenceId="RATING_ENTITY_ID_RATING_ENTITY_ENTITY_ID" table="rating" column="entity_id" referenceTable="rating_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="RATING_RATING_CODE"> + <constraint xsi:type="unique" referenceId="RATING_RATING_CODE"> <column name="rating_code"/> </constraint> - <index name="RATING_ENTITY_ID" indexType="btree"> + <index referenceId="RATING_ENTITY_ID" indexType="btree"> <column name="entity_id"/> </index> </table> @@ -166,12 +166,12 @@ default="0" comment="Rating Option Value"/> <column xsi:type="smallint" name="position" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Ration option position on Storefront"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="option_id"/> </constraint> - <constraint xsi:type="foreign" name="RATING_OPTION_RATING_ID_RATING_RATING_ID" table="rating_option" + <constraint xsi:type="foreign" referenceId="RATING_OPTION_RATING_ID_RATING_RATING_ID" table="rating_option" column="rating_id" referenceTable="rating" referenceColumn="rating_id" onDelete="CASCADE"/> - <index name="RATING_OPTION_RATING_ID" indexType="btree"> + <index referenceId="RATING_OPTION_RATING_ID" indexType="btree"> <column name="rating_id"/> </index> </table> @@ -195,15 +195,15 @@ default="0" comment="Percent amount"/> <column xsi:type="smallint" name="value" padding="6" unsigned="false" nullable="false" identity="false" default="0" comment="Vote option value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="vote_id"/> </constraint> - <constraint xsi:type="foreign" name="RATING_OPTION_VOTE_OPTION_ID_RATING_OPTION_OPTION_ID" + <constraint xsi:type="foreign" referenceId="RATING_OPTION_VOTE_OPTION_ID_RATING_OPTION_OPTION_ID" table="rating_option_vote" column="option_id" referenceTable="rating_option" referenceColumn="option_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="RATING_OPTION_VOTE_REVIEW_ID_REVIEW_REVIEW_ID" table="rating_option_vote" + <constraint xsi:type="foreign" referenceId="RATING_OPTION_VOTE_REVIEW_ID_REVIEW_REVIEW_ID" table="rating_option_vote" column="review_id" referenceTable="review" referenceColumn="review_id" onDelete="CASCADE"/> - <index name="RATING_OPTION_VOTE_OPTION_ID" indexType="btree"> + <index referenceId="RATING_OPTION_VOTE_OPTION_ID" indexType="btree"> <column name="option_id"/> </index> </table> @@ -224,19 +224,19 @@ identity="false" default="0" comment="Vote percent approved by admin"/> <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Store Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="primary_id"/> </constraint> - <constraint xsi:type="foreign" name="RATING_OPTION_VOTE_AGGREGATED_RATING_ID_RATING_RATING_ID" + <constraint xsi:type="foreign" referenceId="RATING_OPTION_VOTE_AGGREGATED_RATING_ID_RATING_RATING_ID" table="rating_option_vote_aggregated" column="rating_id" referenceTable="rating" referenceColumn="rating_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="RATING_OPTION_VOTE_AGGREGATED_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="RATING_OPTION_VOTE_AGGREGATED_STORE_ID_STORE_STORE_ID" table="rating_option_vote_aggregated" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <index name="RATING_OPTION_VOTE_AGGREGATED_RATING_ID" indexType="btree"> + <index referenceId="RATING_OPTION_VOTE_AGGREGATED_RATING_ID" indexType="btree"> <column name="rating_id"/> </index> - <index name="RATING_OPTION_VOTE_AGGREGATED_STORE_ID" indexType="btree"> + <index referenceId="RATING_OPTION_VOTE_AGGREGATED_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -245,15 +245,15 @@ default="0" comment="Rating id"/> <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Store id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="rating_id"/> <column name="store_id"/> </constraint> - <constraint xsi:type="foreign" name="RATING_STORE_STORE_ID_STORE_STORE_ID" table="rating_store" + <constraint xsi:type="foreign" referenceId="RATING_STORE_STORE_ID_STORE_STORE_ID" table="rating_store" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="RATING_STORE_RATING_ID_RATING_RATING_ID" table="rating_store" + <constraint xsi:type="foreign" referenceId="RATING_STORE_RATING_ID_RATING_RATING_ID" table="rating_store" column="rating_id" referenceTable="rating" referenceColumn="rating_id" onDelete="CASCADE"/> - <index name="RATING_STORE_STORE_ID" indexType="btree"> + <index referenceId="RATING_STORE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -263,15 +263,15 @@ <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Store Id"/> <column xsi:type="varchar" name="value" nullable="false" length="255" comment="Rating Label"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="rating_id"/> <column name="store_id"/> </constraint> - <constraint xsi:type="foreign" name="RATING_TITLE_RATING_ID_RATING_RATING_ID" table="rating_title" + <constraint xsi:type="foreign" referenceId="RATING_TITLE_RATING_ID_RATING_RATING_ID" table="rating_title" column="rating_id" referenceTable="rating" referenceColumn="rating_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="RATING_TITLE_STORE_ID_STORE_STORE_ID" table="rating_title" + <constraint xsi:type="foreign" referenceId="RATING_TITLE_STORE_ID_STORE_STORE_ID" table="rating_title" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <index name="RATING_TITLE_STORE_ID" indexType="btree"> + <index referenceId="RATING_TITLE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> diff --git a/app/code/Magento/Sales/Model/Download.php b/app/code/Magento/Sales/Model/Download.php index 6d3ad8491253a..a76b72bfa41dd 100644 --- a/app/code/Magento/Sales/Model/Download.php +++ b/app/code/Magento/Sales/Model/Download.php @@ -8,6 +8,9 @@ use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Exception\LocalizedException; +/** + * Class Download. Represents download logic for files + */ class Download { /** @@ -36,6 +39,8 @@ class Download protected $rootDirBasePath; /** + * Constructor method + * * @param \Magento\Framework\Filesystem $filesystem * @param \Magento\MediaStorage\Helper\File\Storage\Database $fileStorageDatabase * @param \Magento\MediaStorage\Model\File\Storage\DatabaseFactory $storageDatabaseFactory @@ -78,11 +83,14 @@ public function downloadFile($info) $this->_fileFactory->create( $info['title'], ['value' => $this->_rootDir->getRelativePath($relativePath), 'type' => 'filename'], - $this->rootDirBasePath + $this->rootDirBasePath, + $info['type'] ); } /** + * Method checks, if file can be returned depends on the given filepath + * * @param string $relativePath * @return bool */ diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index 03b4f78b14187..345ff036a2be6 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -1372,7 +1372,10 @@ public function getParentItemsRandomCollection($limit = 1) */ protected function _getItemsRandomCollection($limit, $nonChildrenOnly = false) { - $collection = $this->_orderItemCollectionFactory->create()->setOrderFilter($this)->setRandomOrder(); + $collection = $this->_orderItemCollectionFactory->create() + ->setOrderFilter($this) + ->setRandomOrder() + ->setPageSize($limit); if ($nonChildrenOnly) { $collection->filterByParent(); @@ -1386,9 +1389,7 @@ protected function _getItemsRandomCollection($limit, $nonChildrenOnly = false) $products )->setVisibility( $this->_productVisibility->getVisibleInSiteIds() - )->addPriceData()->setPageSize( - $limit - )->load(); + )->addPriceData()->load(); foreach ($collection as $item) { $product = $productsCollection->getItemById($item->getProductId()); diff --git a/app/code/Magento/Sales/Test/Unit/Model/DownloadTest.php b/app/code/Magento/Sales/Test/Unit/Model/DownloadTest.php deleted file mode 100644 index dd430f8a03304..0000000000000 --- a/app/code/Magento/Sales/Test/Unit/Model/DownloadTest.php +++ /dev/null @@ -1,262 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Sales\Test\Unit\Model; - -use Magento\Framework\App\Filesystem\DirectoryList; - -class DownloadTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var \Magento\Sales\Model\Download - */ - protected $model; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $filesystemMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $storageMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $storageFactoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $httpFileFactoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $writeDirectoryMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $driverMock; - - protected function setUp() - { - $this->writeDirectoryMock = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\Write::class) - ->disableOriginalConstructor() - ->getMock(); - $this->filesystemMock = $this->getMockBuilder(\Magento\Framework\Filesystem::class) - ->disableOriginalConstructor() - ->getMock(); - $this->filesystemMock->expects($this->any()) - ->method('getDirectoryWrite') - ->with(DirectoryList::MEDIA) - ->will($this->returnValue($this->writeDirectoryMock)); - - $this->driverMock = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\DriverInterface::class); - $this->storageMock = $this->getMockBuilder(\Magento\MediaStorage\Helper\File\Storage\Database::class) - ->disableOriginalConstructor() - ->getMock(); - $this->storageFactoryMock = $this->getMockBuilder( - \Magento\MediaStorage\Model\File\Storage\DatabaseFactory::class - )->disableOriginalConstructor() - ->setMethods(['create', 'checkDbUsage']) - ->getMock(); - $this->httpFileFactoryMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http\FileFactory::class) - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - $this->model = new \Magento\Sales\Model\Download( - $this->filesystemMock, - $this->storageMock, - $this->storageFactoryMock, - $this->httpFileFactoryMock - ); - } - - public function testInstanceOf() - { - $model = new \Magento\Sales\Model\Download( - $this->filesystemMock, - $this->storageMock, - $this->storageFactoryMock, - $this->httpFileFactoryMock - ); - $this->assertInstanceOf(\Magento\Sales\Model\Download::class, $model); - } - - /** - * @param $realPatchCheck - * @param $isFile - * @param $isReadable - * @expectedException \Magento\Framework\Exception\LocalizedException - * @dataProvider dataProviderForTestDownloadFileException - */ - public function testDownloadFileException($realPatchCheck, $isFile, $isReadable) - { - $info = ['order_path' => 'test/path', 'quote_path' => 'test/path2', 'title' => 'test title']; - - $this->writeDirectoryMock->expects($this->any()) - ->method('getAbsolutePath') - ->will($this->returnArgument(0)); - $this->writeDirectoryMock->expects($this->any()) - ->method('getDriver') - ->willReturn($this->driverMock); - $this->driverMock->expects($this->any())->method('getRealPath')->willReturn($realPatchCheck); - $this->writeDirectoryMock->expects($this->any()) - ->method('isFile') - ->will($this->returnValue($isFile)); - $this->writeDirectoryMock->expects($this->any()) - ->method('isReadable') - ->will($this->returnValue($isReadable)); - - $this->storageFactoryMock->expects($this->any()) - ->method('checkDbUsage') - ->will($this->returnValue(false)); - $this->httpFileFactoryMock->expects($this->never())->method('create'); - - $this->model->downloadFile($info); - } - - /** - * @return array - */ - public function dataProviderForTestDownloadFileException() - { - return [ - [1, true, false], - [1, false, true], - [false, true, true], - ]; - } - - /** - * @expectedException \Magento\Framework\Exception\LocalizedException - */ - public function testDownloadFileNoStorage() - { - $info = ['order_path' => 'test/path', 'quote_path' => 'test/path2', 'title' => 'test title']; - $isFile = true; - $isReadable = false; - - $this->writeDirectoryMock->expects($this->any()) - ->method('getAbsolutePath') - ->will($this->returnArgument(0)); - $this->writeDirectoryMock->expects($this->any()) - ->method('getDriver') - ->willReturn($this->driverMock); - $this->driverMock->expects($this->any())->method('getRealPath')->willReturn(true); - - $this->writeDirectoryMock->expects($this->any()) - ->method('isFile') - ->will($this->returnValue($isFile)); - $this->writeDirectoryMock->expects($this->any()) - ->method('isReadable') - ->will($this->returnValue($isReadable)); - - $this->storageMock->expects($this->any()) - ->method('checkDbUsage') - ->will($this->returnValue(true)); - - $storageDatabaseMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Storage\Database::class) - ->disableOriginalConstructor() - ->getMock(); - $storageDatabaseMock->expects($this->at(0)) - ->method('loadByFilename') - ->with($this->equalTo($info['order_path'])) - ->will($this->returnSelf()); - $storageDatabaseMock->expects($this->at(2)) - ->method('loadByFilename') - ->with($this->equalTo($info['quote_path'])) - ->will($this->returnSelf()); - - $storageDatabaseMock->expects($this->any()) - ->method('getId') - ->will($this->returnValue(false)); - - $this->storageFactoryMock->expects($this->any()) - ->method('create') - ->will($this->returnValue($storageDatabaseMock)); - $this->httpFileFactoryMock->expects($this->never())->method('create'); - - $this->model->downloadFile($info); - } - - public function testDownloadFile() - { - $info = ['order_path' => 'test/path', 'quote_path' => 'test/path2', 'title' => 'test title']; - $isFile = true; - $isReadable = false; - - $writeMock = $this->getMockBuilder(\Magento\Framework\Filesystem\File\Write::class) - ->disableOriginalConstructor() - ->getMock(); - $writeMock->expects($this->any()) - ->method('lock'); - $writeMock->expects($this->any()) - ->method('write'); - $writeMock->expects($this->any()) - ->method('unlock'); - $writeMock->expects($this->any()) - ->method('close'); - - $this->writeDirectoryMock->expects($this->any()) - ->method('getAbsolutePath') - ->will($this->returnArgument(0)); - $this->writeDirectoryMock->expects($this->any()) - ->method('getDriver') - ->willReturn($this->driverMock); - $this->driverMock->expects($this->any())->method('getRealPath')->willReturn(true); - - $this->writeDirectoryMock->expects($this->any()) - ->method('isFile') - ->will($this->returnValue($isFile)); - $this->writeDirectoryMock->expects($this->any()) - ->method('isReadable') - ->will($this->returnValue($isReadable)); - $this->writeDirectoryMock->expects($this->any()) - ->method('openFile') - ->will($this->returnValue($writeMock)); - $this->writeDirectoryMock->expects($this->once()) - ->method('getRelativePath') - ->with($info['order_path']) - ->will($this->returnArgument(0)); - - $this->storageMock->expects($this->any()) - ->method('checkDbUsage') - ->will($this->returnValue(true)); - - $storageDatabaseMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Storage\Database::class) - ->disableOriginalConstructor() - ->setMethods(['loadByFilename', 'getId', '__wakeup']) - ->getMock(); - $storageDatabaseMock->expects($this->any()) - ->method('loadByFilename') - ->will($this->returnSelf()); - - $storageDatabaseMock->expects($this->any()) - ->method('getId') - ->will($this->returnValue(true)); - - $this->storageFactoryMock->expects($this->any()) - ->method('create') - ->will($this->returnValue($storageDatabaseMock)); - - $this->httpFileFactoryMock->expects($this->once()) - ->method('create') - ->with( - $info['title'], - ['value' => $info['order_path'], 'type' => 'filename'], - DirectoryList::MEDIA, - 'application/octet-stream', - null - ); - - $result = $this->model->downloadFile($info); - $this->assertNull($result); - } -} diff --git a/app/code/Magento/Sales/etc/db_schema.xml b/app/code/Magento/Sales/etc/db_schema.xml index fda6e75cf00c6..1310204dcc8f3 100644 --- a/app/code/Magento/Sales/etc/db_schema.xml +++ b/app/code/Magento/Sales/etc/db_schema.xml @@ -252,46 +252,46 @@ nullable="true" comment="Base Shipping Incl Tax"/> <column xsi:type="varchar" name="coupon_rule_name" nullable="true" length="255" comment="Coupon Sales Rule Name"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_ORDER_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="sales_order" + <constraint xsi:type="foreign" referenceId="SALES_ORDER_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="sales_order" column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="SET NULL"/> - <constraint xsi:type="foreign" name="SALES_ORDER_STORE_ID_STORE_STORE_ID" table="sales_order" column="store_id" + <constraint xsi:type="foreign" referenceId="SALES_ORDER_STORE_ID_STORE_STORE_ID" table="sales_order" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <constraint xsi:type="unique" name="SALES_ORDER_INCREMENT_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="SALES_ORDER_INCREMENT_ID_STORE_ID"> <column name="increment_id"/> <column name="store_id"/> </constraint> - <index name="SALES_ORDER_STATUS" indexType="btree"> + <index referenceId="SALES_ORDER_STATUS" indexType="btree"> <column name="status"/> </index> - <index name="SALES_ORDER_STATE" indexType="btree"> + <index referenceId="SALES_ORDER_STATE" indexType="btree"> <column name="state"/> </index> - <index name="SALES_ORDER_STORE_ID" indexType="btree"> + <index referenceId="SALES_ORDER_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="SALES_ORDER_CREATED_AT" indexType="btree"> + <index referenceId="SALES_ORDER_CREATED_AT" indexType="btree"> <column name="created_at"/> </index> - <index name="SALES_ORDER_CUSTOMER_ID" indexType="btree"> + <index referenceId="SALES_ORDER_CUSTOMER_ID" indexType="btree"> <column name="customer_id"/> </index> - <index name="SALES_ORDER_EXT_ORDER_ID" indexType="btree"> + <index referenceId="SALES_ORDER_EXT_ORDER_ID" indexType="btree"> <column name="ext_order_id"/> </index> - <index name="SALES_ORDER_QUOTE_ID" indexType="btree"> + <index referenceId="SALES_ORDER_QUOTE_ID" indexType="btree"> <column name="quote_id"/> </index> - <index name="SALES_ORDER_UPDATED_AT" indexType="btree"> + <index referenceId="SALES_ORDER_UPDATED_AT" indexType="btree"> <column name="updated_at"/> </index> - <index name="SALES_ORDER_SEND_EMAIL" indexType="btree"> + <index referenceId="SALES_ORDER_SEND_EMAIL" indexType="btree"> <column name="send_email"/> </index> - <index name="SALES_ORDER_EMAIL_SENT" indexType="btree"> + <index referenceId="SALES_ORDER_EMAIL_SENT" indexType="btree"> <column name="email_sent"/> </index> </table> @@ -334,47 +334,47 @@ <column xsi:type="varchar" name="payment_method" nullable="true" length="255" comment="Payment Method"/> <column xsi:type="decimal" name="total_refunded" scale="4" precision="12" unsigned="false" nullable="true" comment="Total Refunded"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="unique" name="SALES_ORDER_GRID_INCREMENT_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="SALES_ORDER_GRID_INCREMENT_ID_STORE_ID"> <column name="increment_id"/> <column name="store_id"/> </constraint> - <index name="SALES_ORDER_GRID_STATUS" indexType="btree"> + <index referenceId="SALES_ORDER_GRID_STATUS" indexType="btree"> <column name="status"/> </index> - <index name="SALES_ORDER_GRID_STORE_ID" indexType="btree"> + <index referenceId="SALES_ORDER_GRID_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="SALES_ORDER_GRID_BASE_GRAND_TOTAL" indexType="btree"> + <index referenceId="SALES_ORDER_GRID_BASE_GRAND_TOTAL" indexType="btree"> <column name="base_grand_total"/> </index> - <index name="SALES_ORDER_GRID_BASE_TOTAL_PAID" indexType="btree"> + <index referenceId="SALES_ORDER_GRID_BASE_TOTAL_PAID" indexType="btree"> <column name="base_total_paid"/> </index> - <index name="SALES_ORDER_GRID_GRAND_TOTAL" indexType="btree"> + <index referenceId="SALES_ORDER_GRID_GRAND_TOTAL" indexType="btree"> <column name="grand_total"/> </index> - <index name="SALES_ORDER_GRID_TOTAL_PAID" indexType="btree"> + <index referenceId="SALES_ORDER_GRID_TOTAL_PAID" indexType="btree"> <column name="total_paid"/> </index> - <index name="SALES_ORDER_GRID_SHIPPING_NAME" indexType="btree"> + <index referenceId="SALES_ORDER_GRID_SHIPPING_NAME" indexType="btree"> <column name="shipping_name"/> </index> - <index name="SALES_ORDER_GRID_BILLING_NAME" indexType="btree"> + <index referenceId="SALES_ORDER_GRID_BILLING_NAME" indexType="btree"> <column name="billing_name"/> </index> - <index name="SALES_ORDER_GRID_CREATED_AT" indexType="btree"> + <index referenceId="SALES_ORDER_GRID_CREATED_AT" indexType="btree"> <column name="created_at"/> </index> - <index name="SALES_ORDER_GRID_CUSTOMER_ID" indexType="btree"> + <index referenceId="SALES_ORDER_GRID_CUSTOMER_ID" indexType="btree"> <column name="customer_id"/> </index> - <index name="SALES_ORDER_GRID_UPDATED_AT" indexType="btree"> + <index referenceId="SALES_ORDER_GRID_UPDATED_AT" indexType="btree"> <column name="updated_at"/> </index> - <index name="FTI_65B9E9925EC58F0C7C2E2F6379C233E7" indexType="fulltext"> + <index referenceId="FTI_65B9E9925EC58F0C7C2E2F6379C233E7" indexType="fulltext"> <column name="increment_id"/> <column name="billing_name"/> <column name="shipping_name"/> @@ -419,13 +419,13 @@ <column xsi:type="text" name="vat_request_date" nullable="true" comment="Vat Request Date"/> <column xsi:type="smallint" name="vat_request_success" padding="6" unsigned="false" nullable="true" identity="false" comment="Vat Request Success"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_ORDER_ADDRESS_PARENT_ID_SALES_ORDER_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="SALES_ORDER_ADDRESS_PARENT_ID_SALES_ORDER_ENTITY_ID" table="sales_order_address" column="parent_id" referenceTable="sales_order" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="SALES_ORDER_ADDRESS_PARENT_ID" indexType="btree"> + <index referenceId="SALES_ORDER_ADDRESS_PARENT_ID" indexType="btree"> <column name="parent_id"/> </index> </table> @@ -444,16 +444,16 @@ comment="Created At"/> <column xsi:type="varchar" name="entity_name" nullable="true" length="32" comment="Shows what entity history is bind to."/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_ORDER_STATUS_HISTORY_PARENT_ID_SALES_ORDER_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="SALES_ORDER_STATUS_HISTORY_PARENT_ID_SALES_ORDER_ENTITY_ID" table="sales_order_status_history" column="parent_id" referenceTable="sales_order" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="SALES_ORDER_STATUS_HISTORY_PARENT_ID" indexType="btree"> + <index referenceId="SALES_ORDER_STATUS_HISTORY_PARENT_ID" indexType="btree"> <column name="parent_id"/> </index> - <index name="SALES_ORDER_STATUS_HISTORY_CREATED_AT" indexType="btree"> + <index referenceId="SALES_ORDER_STATUS_HISTORY_CREATED_AT" indexType="btree"> <column name="created_at"/> </index> </table> @@ -586,17 +586,17 @@ comment="Discount Refunded"/> <column xsi:type="decimal" name="base_discount_refunded" scale="4" precision="12" unsigned="false" nullable="true" comment="Base Discount Refunded"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="item_id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_ORDER_ITEM_ORDER_ID_SALES_ORDER_ENTITY_ID" table="sales_order_item" + <constraint xsi:type="foreign" referenceId="SALES_ORDER_ITEM_ORDER_ID_SALES_ORDER_ENTITY_ID" table="sales_order_item" column="order_id" referenceTable="sales_order" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="SALES_ORDER_ITEM_STORE_ID_STORE_STORE_ID" table="sales_order_item" + <constraint xsi:type="foreign" referenceId="SALES_ORDER_ITEM_STORE_ID_STORE_STORE_ID" table="sales_order_item" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <index name="SALES_ORDER_ITEM_ORDER_ID" indexType="btree"> + <index referenceId="SALES_ORDER_ITEM_ORDER_ID" indexType="btree"> <column name="order_id"/> </index> - <index name="SALES_ORDER_ITEM_STORE_ID" indexType="btree"> + <index referenceId="SALES_ORDER_ITEM_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -684,13 +684,13 @@ <column xsi:type="varchar" name="cc_trans_id" nullable="true" length="32" comment="Cc Trans Id"/> <column xsi:type="varchar" name="address_status" nullable="true" length="32" comment="Address Status"/> <column xsi:type="text" name="additional_information" nullable="true" comment="Additional Information"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_ORDER_PAYMENT_PARENT_ID_SALES_ORDER_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="SALES_ORDER_PAYMENT_PARENT_ID_SALES_ORDER_ENTITY_ID" table="sales_order_payment" column="parent_id" referenceTable="sales_order" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="SALES_ORDER_PAYMENT_PARENT_ID" indexType="btree"> + <index referenceId="SALES_ORDER_PAYMENT_PARENT_ID" indexType="btree"> <column name="parent_id"/> </index> </table> @@ -727,36 +727,36 @@ <column xsi:type="text" name="customer_note" nullable="true" comment="Customer Note"/> <column xsi:type="smallint" name="customer_note_notify" padding="5" unsigned="true" nullable="true" identity="false" comment="Customer Note Notify"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_SHIPMENT_ORDER_ID_SALES_ORDER_ENTITY_ID" table="sales_shipment" + <constraint xsi:type="foreign" referenceId="SALES_SHIPMENT_ORDER_ID_SALES_ORDER_ENTITY_ID" table="sales_shipment" column="order_id" referenceTable="sales_order" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="SALES_SHIPMENT_STORE_ID_STORE_STORE_ID" table="sales_shipment" + <constraint xsi:type="foreign" referenceId="SALES_SHIPMENT_STORE_ID_STORE_STORE_ID" table="sales_shipment" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <constraint xsi:type="unique" name="SALES_SHIPMENT_INCREMENT_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="SALES_SHIPMENT_INCREMENT_ID_STORE_ID"> <column name="increment_id"/> <column name="store_id"/> </constraint> - <index name="SALES_SHIPMENT_STORE_ID" indexType="btree"> + <index referenceId="SALES_SHIPMENT_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="SALES_SHIPMENT_TOTAL_QTY" indexType="btree"> + <index referenceId="SALES_SHIPMENT_TOTAL_QTY" indexType="btree"> <column name="total_qty"/> </index> - <index name="SALES_SHIPMENT_ORDER_ID" indexType="btree"> + <index referenceId="SALES_SHIPMENT_ORDER_ID" indexType="btree"> <column name="order_id"/> </index> - <index name="SALES_SHIPMENT_CREATED_AT" indexType="btree"> + <index referenceId="SALES_SHIPMENT_CREATED_AT" indexType="btree"> <column name="created_at"/> </index> - <index name="SALES_SHIPMENT_UPDATED_AT" indexType="btree"> + <index referenceId="SALES_SHIPMENT_UPDATED_AT" indexType="btree"> <column name="updated_at"/> </index> - <index name="SALES_SHIPMENT_SEND_EMAIL" indexType="btree"> + <index referenceId="SALES_SHIPMENT_SEND_EMAIL" indexType="btree"> <column name="send_email"/> </index> - <index name="SALES_SHIPMENT_EMAIL_SENT" indexType="btree"> + <index referenceId="SALES_SHIPMENT_EMAIL_SENT" indexType="btree"> <column name="email_sent"/> </index> </table> @@ -788,44 +788,44 @@ comment="Shipping Method Name"/> <column xsi:type="timestamp" name="created_at" on_update="false" nullable="true" comment="Created At"/> <column xsi:type="timestamp" name="updated_at" on_update="false" nullable="true" comment="Updated At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="unique" name="SALES_SHIPMENT_GRID_INCREMENT_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="SALES_SHIPMENT_GRID_INCREMENT_ID_STORE_ID"> <column name="increment_id"/> <column name="store_id"/> </constraint> - <index name="SALES_SHIPMENT_GRID_STORE_ID" indexType="btree"> + <index referenceId="SALES_SHIPMENT_GRID_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="SALES_SHIPMENT_GRID_TOTAL_QTY" indexType="btree"> + <index referenceId="SALES_SHIPMENT_GRID_TOTAL_QTY" indexType="btree"> <column name="total_qty"/> </index> - <index name="SALES_SHIPMENT_GRID_ORDER_INCREMENT_ID" indexType="btree"> + <index referenceId="SALES_SHIPMENT_GRID_ORDER_INCREMENT_ID" indexType="btree"> <column name="order_increment_id"/> </index> - <index name="SALES_SHIPMENT_GRID_SHIPMENT_STATUS" indexType="btree"> + <index referenceId="SALES_SHIPMENT_GRID_SHIPMENT_STATUS" indexType="btree"> <column name="shipment_status"/> </index> - <index name="SALES_SHIPMENT_GRID_ORDER_STATUS" indexType="btree"> + <index referenceId="SALES_SHIPMENT_GRID_ORDER_STATUS" indexType="btree"> <column name="order_status"/> </index> - <index name="SALES_SHIPMENT_GRID_CREATED_AT" indexType="btree"> + <index referenceId="SALES_SHIPMENT_GRID_CREATED_AT" indexType="btree"> <column name="created_at"/> </index> - <index name="SALES_SHIPMENT_GRID_UPDATED_AT" indexType="btree"> + <index referenceId="SALES_SHIPMENT_GRID_UPDATED_AT" indexType="btree"> <column name="updated_at"/> </index> - <index name="SALES_SHIPMENT_GRID_ORDER_CREATED_AT" indexType="btree"> + <index referenceId="SALES_SHIPMENT_GRID_ORDER_CREATED_AT" indexType="btree"> <column name="order_created_at"/> </index> - <index name="SALES_SHIPMENT_GRID_SHIPPING_NAME" indexType="btree"> + <index referenceId="SALES_SHIPMENT_GRID_SHIPPING_NAME" indexType="btree"> <column name="shipping_name"/> </index> - <index name="SALES_SHIPMENT_GRID_BILLING_NAME" indexType="btree"> + <index referenceId="SALES_SHIPMENT_GRID_BILLING_NAME" indexType="btree"> <column name="billing_name"/> </index> - <index name="FTI_086B40C8955F167B8EA76653437879B4" indexType="fulltext"> + <index referenceId="FTI_086B40C8955F167B8EA76653437879B4" indexType="fulltext"> <column name="increment_id"/> <column name="order_increment_id"/> <column name="shipping_name"/> @@ -855,13 +855,13 @@ <column xsi:type="text" name="description" nullable="true" comment="Description"/> <column xsi:type="varchar" name="name" nullable="true" length="255" comment="Name"/> <column xsi:type="varchar" name="sku" nullable="true" length="255" comment="Sku"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_SHIPMENT_ITEM_PARENT_ID_SALES_SHIPMENT_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="SALES_SHIPMENT_ITEM_PARENT_ID_SALES_SHIPMENT_ENTITY_ID" table="sales_shipment_item" column="parent_id" referenceTable="sales_shipment" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="SALES_SHIPMENT_ITEM_PARENT_ID" indexType="btree"> + <index referenceId="SALES_SHIPMENT_ITEM_PARENT_ID" indexType="btree"> <column name="parent_id"/> </index> </table> @@ -883,19 +883,19 @@ comment="Created At"/> <column xsi:type="timestamp" name="updated_at" on_update="true" nullable="false" default="CURRENT_TIMESTAMP" comment="Updated At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_SHIPMENT_TRACK_PARENT_ID_SALES_SHIPMENT_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="SALES_SHIPMENT_TRACK_PARENT_ID_SALES_SHIPMENT_ENTITY_ID" table="sales_shipment_track" column="parent_id" referenceTable="sales_shipment" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="SALES_SHIPMENT_TRACK_PARENT_ID" indexType="btree"> + <index referenceId="SALES_SHIPMENT_TRACK_PARENT_ID" indexType="btree"> <column name="parent_id"/> </index> - <index name="SALES_SHIPMENT_TRACK_ORDER_ID" indexType="btree"> + <index referenceId="SALES_SHIPMENT_TRACK_ORDER_ID" indexType="btree"> <column name="order_id"/> </index> - <index name="SALES_SHIPMENT_TRACK_CREATED_AT" indexType="btree"> + <index referenceId="SALES_SHIPMENT_TRACK_CREATED_AT" indexType="btree"> <column name="created_at"/> </index> </table> @@ -911,16 +911,16 @@ <column xsi:type="text" name="comment" nullable="true" comment="Comment"/> <column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Created At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_SHIPMENT_COMMENT_PARENT_ID_SALES_SHIPMENT_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="SALES_SHIPMENT_COMMENT_PARENT_ID_SALES_SHIPMENT_ENTITY_ID" table="sales_shipment_comment" column="parent_id" referenceTable="sales_shipment" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="SALES_SHIPMENT_COMMENT_CREATED_AT" indexType="btree"> + <index referenceId="SALES_SHIPMENT_COMMENT_CREATED_AT" indexType="btree"> <column name="created_at"/> </index> - <index name="SALES_SHIPMENT_COMMENT_PARENT_ID" indexType="btree"> + <index referenceId="SALES_SHIPMENT_COMMENT_PARENT_ID" indexType="btree"> <column name="parent_id"/> </index> </table> @@ -1013,39 +1013,39 @@ <column xsi:type="text" name="customer_note" nullable="true" comment="Customer Note"/> <column xsi:type="smallint" name="customer_note_notify" padding="5" unsigned="true" nullable="true" identity="false" comment="Customer Note Notify"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_INVOICE_ORDER_ID_SALES_ORDER_ENTITY_ID" table="sales_invoice" + <constraint xsi:type="foreign" referenceId="SALES_INVOICE_ORDER_ID_SALES_ORDER_ENTITY_ID" table="sales_invoice" column="order_id" referenceTable="sales_order" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="SALES_INVOICE_STORE_ID_STORE_STORE_ID" table="sales_invoice" + <constraint xsi:type="foreign" referenceId="SALES_INVOICE_STORE_ID_STORE_STORE_ID" table="sales_invoice" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <constraint xsi:type="unique" name="SALES_INVOICE_INCREMENT_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="SALES_INVOICE_INCREMENT_ID_STORE_ID"> <column name="increment_id"/> <column name="store_id"/> </constraint> - <index name="SALES_INVOICE_STORE_ID" indexType="btree"> + <index referenceId="SALES_INVOICE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="SALES_INVOICE_GRAND_TOTAL" indexType="btree"> + <index referenceId="SALES_INVOICE_GRAND_TOTAL" indexType="btree"> <column name="grand_total"/> </index> - <index name="SALES_INVOICE_ORDER_ID" indexType="btree"> + <index referenceId="SALES_INVOICE_ORDER_ID" indexType="btree"> <column name="order_id"/> </index> - <index name="SALES_INVOICE_STATE" indexType="btree"> + <index referenceId="SALES_INVOICE_STATE" indexType="btree"> <column name="state"/> </index> - <index name="SALES_INVOICE_CREATED_AT" indexType="btree"> + <index referenceId="SALES_INVOICE_CREATED_AT" indexType="btree"> <column name="created_at"/> </index> - <index name="SALES_INVOICE_UPDATED_AT" indexType="btree"> + <index referenceId="SALES_INVOICE_UPDATED_AT" indexType="btree"> <column name="updated_at"/> </index> - <index name="SALES_INVOICE_SEND_EMAIL" indexType="btree"> + <index referenceId="SALES_INVOICE_SEND_EMAIL" indexType="btree"> <column name="send_email"/> </index> - <index name="SALES_INVOICE_EMAIL_SENT" indexType="btree"> + <index referenceId="SALES_INVOICE_EMAIL_SENT" indexType="btree"> <column name="email_sent"/> </index> </table> @@ -1087,41 +1087,41 @@ <column xsi:type="timestamp" name="updated_at" on_update="false" nullable="true" comment="Updated At"/> <column xsi:type="decimal" name="base_grand_total" scale="4" precision="12" unsigned="false" nullable="true" comment="Base Grand Total"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="unique" name="SALES_INVOICE_GRID_INCREMENT_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="SALES_INVOICE_GRID_INCREMENT_ID_STORE_ID"> <column name="increment_id"/> <column name="store_id"/> </constraint> - <index name="SALES_INVOICE_GRID_STORE_ID" indexType="btree"> + <index referenceId="SALES_INVOICE_GRID_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="SALES_INVOICE_GRID_GRAND_TOTAL" indexType="btree"> + <index referenceId="SALES_INVOICE_GRID_GRAND_TOTAL" indexType="btree"> <column name="grand_total"/> </index> - <index name="SALES_INVOICE_GRID_ORDER_ID" indexType="btree"> + <index referenceId="SALES_INVOICE_GRID_ORDER_ID" indexType="btree"> <column name="order_id"/> </index> - <index name="SALES_INVOICE_GRID_STATE" indexType="btree"> + <index referenceId="SALES_INVOICE_GRID_STATE" indexType="btree"> <column name="state"/> </index> - <index name="SALES_INVOICE_GRID_ORDER_INCREMENT_ID" indexType="btree"> + <index referenceId="SALES_INVOICE_GRID_ORDER_INCREMENT_ID" indexType="btree"> <column name="order_increment_id"/> </index> - <index name="SALES_INVOICE_GRID_CREATED_AT" indexType="btree"> + <index referenceId="SALES_INVOICE_GRID_CREATED_AT" indexType="btree"> <column name="created_at"/> </index> - <index name="SALES_INVOICE_GRID_UPDATED_AT" indexType="btree"> + <index referenceId="SALES_INVOICE_GRID_UPDATED_AT" indexType="btree"> <column name="updated_at"/> </index> - <index name="SALES_INVOICE_GRID_ORDER_CREATED_AT" indexType="btree"> + <index referenceId="SALES_INVOICE_GRID_ORDER_CREATED_AT" indexType="btree"> <column name="order_created_at"/> </index> - <index name="SALES_INVOICE_GRID_BILLING_NAME" indexType="btree"> + <index referenceId="SALES_INVOICE_GRID_BILLING_NAME" indexType="btree"> <column name="billing_name"/> </index> - <index name="FTI_95D9C924DD6A8734EB8B5D01D60F90DE" indexType="fulltext"> + <index referenceId="FTI_95D9C924DD6A8734EB8B5D01D60F90DE" indexType="fulltext"> <column name="increment_id"/> <column name="order_increment_id"/> <column name="billing_name"/> @@ -1130,7 +1130,7 @@ <column name="customer_name"/> <column name="customer_email"/> </index> - <index name="SALES_INVOICE_GRID_BASE_GRAND_TOTAL" indexType="btree"> + <index referenceId="SALES_INVOICE_GRID_BASE_GRAND_TOTAL" indexType="btree"> <column name="base_grand_total"/> </index> </table> @@ -1180,13 +1180,13 @@ unsigned="false" nullable="true" comment="Base Discount Tax Compensation Amount"/> <column xsi:type="text" name="tax_ratio" nullable="true" comment="Ratio of tax invoiced over tax of the order item"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_INVOICE_ITEM_PARENT_ID_SALES_INVOICE_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="SALES_INVOICE_ITEM_PARENT_ID_SALES_INVOICE_ENTITY_ID" table="sales_invoice_item" column="parent_id" referenceTable="sales_invoice" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="SALES_INVOICE_ITEM_PARENT_ID" indexType="btree"> + <index referenceId="SALES_INVOICE_ITEM_PARENT_ID" indexType="btree"> <column name="parent_id"/> </index> </table> @@ -1202,16 +1202,16 @@ <column xsi:type="text" name="comment" nullable="true" comment="Comment"/> <column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Created At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_INVOICE_COMMENT_PARENT_ID_SALES_INVOICE_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="SALES_INVOICE_COMMENT_PARENT_ID_SALES_INVOICE_ENTITY_ID" table="sales_invoice_comment" column="parent_id" referenceTable="sales_invoice" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="SALES_INVOICE_COMMENT_CREATED_AT" indexType="btree"> + <index referenceId="SALES_INVOICE_COMMENT_CREATED_AT" indexType="btree"> <column name="created_at"/> </index> - <index name="SALES_INVOICE_COMMENT_PARENT_ID" indexType="btree"> + <index referenceId="SALES_INVOICE_COMMENT_PARENT_ID" indexType="btree"> <column name="parent_id"/> </index> </table> @@ -1312,39 +1312,39 @@ <column xsi:type="text" name="customer_note" nullable="true" comment="Customer Note"/> <column xsi:type="smallint" name="customer_note_notify" padding="5" unsigned="true" nullable="true" identity="false" comment="Customer Note Notify"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_CREDITMEMO_ORDER_ID_SALES_ORDER_ENTITY_ID" table="sales_creditmemo" + <constraint xsi:type="foreign" referenceId="SALES_CREDITMEMO_ORDER_ID_SALES_ORDER_ENTITY_ID" table="sales_creditmemo" column="order_id" referenceTable="sales_order" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="SALES_CREDITMEMO_STORE_ID_STORE_STORE_ID" table="sales_creditmemo" + <constraint xsi:type="foreign" referenceId="SALES_CREDITMEMO_STORE_ID_STORE_STORE_ID" table="sales_creditmemo" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <constraint xsi:type="unique" name="SALES_CREDITMEMO_INCREMENT_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="SALES_CREDITMEMO_INCREMENT_ID_STORE_ID"> <column name="increment_id"/> <column name="store_id"/> </constraint> - <index name="SALES_CREDITMEMO_STORE_ID" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="SALES_CREDITMEMO_ORDER_ID" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_ORDER_ID" indexType="btree"> <column name="order_id"/> </index> - <index name="SALES_CREDITMEMO_CREDITMEMO_STATUS" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_CREDITMEMO_STATUS" indexType="btree"> <column name="creditmemo_status"/> </index> - <index name="SALES_CREDITMEMO_STATE" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_STATE" indexType="btree"> <column name="state"/> </index> - <index name="SALES_CREDITMEMO_CREATED_AT" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_CREATED_AT" indexType="btree"> <column name="created_at"/> </index> - <index name="SALES_CREDITMEMO_UPDATED_AT" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_UPDATED_AT" indexType="btree"> <column name="updated_at"/> </index> - <index name="SALES_CREDITMEMO_SEND_EMAIL" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_SEND_EMAIL" indexType="btree"> <column name="send_email"/> </index> - <index name="SALES_CREDITMEMO_EMAIL_SENT" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_EMAIL_SENT" indexType="btree"> <column name="email_sent"/> </index> </table> @@ -1386,47 +1386,47 @@ comment="Adjustment Negative"/> <column xsi:type="decimal" name="order_base_grand_total" scale="4" precision="12" unsigned="false" nullable="true" comment="Order Grand Total"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="unique" name="SALES_CREDITMEMO_GRID_INCREMENT_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="SALES_CREDITMEMO_GRID_INCREMENT_ID_STORE_ID"> <column name="increment_id"/> <column name="store_id"/> </constraint> - <index name="SALES_CREDITMEMO_GRID_ORDER_INCREMENT_ID" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_GRID_ORDER_INCREMENT_ID" indexType="btree"> <column name="order_increment_id"/> </index> - <index name="SALES_CREDITMEMO_GRID_CREATED_AT" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_GRID_CREATED_AT" indexType="btree"> <column name="created_at"/> </index> - <index name="SALES_CREDITMEMO_GRID_UPDATED_AT" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_GRID_UPDATED_AT" indexType="btree"> <column name="updated_at"/> </index> - <index name="SALES_CREDITMEMO_GRID_ORDER_CREATED_AT" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_GRID_ORDER_CREATED_AT" indexType="btree"> <column name="order_created_at"/> </index> - <index name="SALES_CREDITMEMO_GRID_STATE" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_GRID_STATE" indexType="btree"> <column name="state"/> </index> - <index name="SALES_CREDITMEMO_GRID_BILLING_NAME" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_GRID_BILLING_NAME" indexType="btree"> <column name="billing_name"/> </index> - <index name="SALES_CREDITMEMO_GRID_ORDER_STATUS" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_GRID_ORDER_STATUS" indexType="btree"> <column name="order_status"/> </index> - <index name="SALES_CREDITMEMO_GRID_BASE_GRAND_TOTAL" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_GRID_BASE_GRAND_TOTAL" indexType="btree"> <column name="base_grand_total"/> </index> - <index name="SALES_CREDITMEMO_GRID_STORE_ID" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_GRID_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="SALES_CREDITMEMO_GRID_ORDER_BASE_GRAND_TOTAL" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_GRID_ORDER_BASE_GRAND_TOTAL" indexType="btree"> <column name="order_base_grand_total"/> </index> - <index name="SALES_CREDITMEMO_GRID_ORDER_ID" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_GRID_ORDER_ID" indexType="btree"> <column name="order_id"/> </index> - <index name="FTI_32B7BA885941A8254EE84AE650ABDC86" indexType="fulltext"> + <index referenceId="FTI_32B7BA885941A8254EE84AE650ABDC86" indexType="fulltext"> <column name="increment_id"/> <column name="order_increment_id"/> <column name="billing_name"/> @@ -1482,13 +1482,13 @@ unsigned="false" nullable="true" comment="Base Discount Tax Compensation Amount"/> <column xsi:type="text" name="tax_ratio" nullable="true" comment="Ratio of tax in the creditmemo item over tax of the order item"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_CREDITMEMO_ITEM_PARENT_ID_SALES_CREDITMEMO_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="SALES_CREDITMEMO_ITEM_PARENT_ID_SALES_CREDITMEMO_ENTITY_ID" table="sales_creditmemo_item" column="parent_id" referenceTable="sales_creditmemo" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="SALES_CREDITMEMO_ITEM_PARENT_ID" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_ITEM_PARENT_ID" indexType="btree"> <column name="parent_id"/> </index> </table> @@ -1504,16 +1504,16 @@ <column xsi:type="text" name="comment" nullable="true" comment="Comment"/> <column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Created At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_CREDITMEMO_COMMENT_PARENT_ID_SALES_CREDITMEMO_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="SALES_CREDITMEMO_COMMENT_PARENT_ID_SALES_CREDITMEMO_ENTITY_ID" table="sales_creditmemo_comment" column="parent_id" referenceTable="sales_creditmemo" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="SALES_CREDITMEMO_COMMENT_CREATED_AT" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_COMMENT_CREATED_AT" indexType="btree"> <column name="created_at"/> </index> - <index name="SALES_CREDITMEMO_COMMENT_PARENT_ID" indexType="btree"> + <index referenceId="SALES_CREDITMEMO_COMMENT_PARENT_ID" indexType="btree"> <column name="parent_id"/> </index> </table> @@ -1533,18 +1533,18 @@ comment="Invoiced Captured"/> <column xsi:type="decimal" name="invoiced_not_captured" scale="4" precision="12" unsigned="false" nullable="true" comment="Invoiced Not Captured"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_INVOICED_AGGREGATED_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="SALES_INVOICED_AGGREGATED_STORE_ID_STORE_STORE_ID" table="sales_invoiced_aggregated" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <constraint xsi:type="unique" name="SALES_INVOICED_AGGREGATED_PERIOD_STORE_ID_ORDER_STATUS"> + <constraint xsi:type="unique" referenceId="SALES_INVOICED_AGGREGATED_PERIOD_STORE_ID_ORDER_STATUS"> <column name="period"/> <column name="store_id"/> <column name="order_status"/> </constraint> - <index name="SALES_INVOICED_AGGREGATED_STORE_ID" indexType="btree"> + <index referenceId="SALES_INVOICED_AGGREGATED_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -1565,18 +1565,18 @@ comment="Invoiced Captured"/> <column xsi:type="decimal" name="invoiced_not_captured" scale="4" precision="12" unsigned="false" nullable="true" comment="Invoiced Not Captured"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_INVOICED_AGGREGATED_ORDER_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="SALES_INVOICED_AGGREGATED_ORDER_STORE_ID_STORE_STORE_ID" table="sales_invoiced_aggregated_order" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <constraint xsi:type="unique" name="SALES_INVOICED_AGGREGATED_ORDER_PERIOD_STORE_ID_ORDER_STATUS"> + <constraint xsi:type="unique" referenceId="SALES_INVOICED_AGGREGATED_ORDER_PERIOD_STORE_ID_ORDER_STATUS"> <column name="period"/> <column name="store_id"/> <column name="order_status"/> </constraint> - <index name="SALES_INVOICED_AGGREGATED_ORDER_STORE_ID" indexType="btree"> + <index referenceId="SALES_INVOICED_AGGREGATED_ORDER_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -1619,18 +1619,18 @@ nullable="false" default="0" comment="Total Discount Amount"/> <column xsi:type="decimal" name="total_discount_amount_actual" scale="4" precision="12" unsigned="false" nullable="false" default="0" comment="Total Discount Amount Actual"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_ORDER_AGGREGATED_CREATED_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="SALES_ORDER_AGGREGATED_CREATED_STORE_ID_STORE_STORE_ID" table="sales_order_aggregated_created" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <constraint xsi:type="unique" name="SALES_ORDER_AGGREGATED_CREATED_PERIOD_STORE_ID_ORDER_STATUS"> + <constraint xsi:type="unique" referenceId="SALES_ORDER_AGGREGATED_CREATED_PERIOD_STORE_ID_ORDER_STATUS"> <column name="period"/> <column name="store_id"/> <column name="order_status"/> </constraint> - <index name="SALES_ORDER_AGGREGATED_CREATED_STORE_ID" indexType="btree"> + <index referenceId="SALES_ORDER_AGGREGATED_CREATED_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -1673,18 +1673,18 @@ nullable="false" default="0" comment="Total Discount Amount"/> <column xsi:type="decimal" name="total_discount_amount_actual" scale="4" precision="12" unsigned="false" nullable="false" default="0" comment="Total Discount Amount Actual"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_ORDER_AGGREGATED_UPDATED_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="SALES_ORDER_AGGREGATED_UPDATED_STORE_ID_STORE_STORE_ID" table="sales_order_aggregated_updated" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <constraint xsi:type="unique" name="SALES_ORDER_AGGREGATED_UPDATED_PERIOD_STORE_ID_ORDER_STATUS"> + <constraint xsi:type="unique" referenceId="SALES_ORDER_AGGREGATED_UPDATED_PERIOD_STORE_ID_ORDER_STATUS"> <column name="period"/> <column name="store_id"/> <column name="order_status"/> </constraint> - <index name="SALES_ORDER_AGGREGATED_UPDATED_STORE_ID" indexType="btree"> + <index referenceId="SALES_ORDER_AGGREGATED_UPDATED_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -1705,27 +1705,27 @@ <column xsi:type="blob" name="additional_information" nullable="true" comment="Additional Information"/> <column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Created At"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="transaction_id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_PAYMENT_TRANSACTION_ORDER_ID_SALES_ORDER_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="SALES_PAYMENT_TRANSACTION_ORDER_ID_SALES_ORDER_ENTITY_ID" table="sales_payment_transaction" column="order_id" referenceTable="sales_order" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="FK_B99FF1A06402D725EBDB0F3A7ECD47A2" table="sales_payment_transaction" + <constraint xsi:type="foreign" referenceId="FK_B99FF1A06402D725EBDB0F3A7ECD47A2" table="sales_payment_transaction" column="parent_id" referenceTable="sales_payment_transaction" referenceColumn="transaction_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="SALES_PAYMENT_TRANSACTION_PAYMENT_ID_SALES_ORDER_PAYMENT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="SALES_PAYMENT_TRANSACTION_PAYMENT_ID_SALES_ORDER_PAYMENT_ENTT_ID" table="sales_payment_transaction" column="payment_id" referenceTable="sales_order_payment" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="SALES_PAYMENT_TRANSACTION_ORDER_ID_PAYMENT_ID_TXN_ID"> + <constraint xsi:type="unique" referenceId="SALES_PAYMENT_TRANSACTION_ORDER_ID_PAYMENT_ID_TXN_ID"> <column name="order_id"/> <column name="payment_id"/> <column name="txn_id"/> </constraint> - <index name="SALES_PAYMENT_TRANSACTION_PARENT_ID" indexType="btree"> + <index referenceId="SALES_PAYMENT_TRANSACTION_PARENT_ID" indexType="btree"> <column name="parent_id"/> </index> - <index name="SALES_PAYMENT_TRANSACTION_PAYMENT_ID" indexType="btree"> + <index referenceId="SALES_PAYMENT_TRANSACTION_PAYMENT_ID" indexType="btree"> <column name="payment_id"/> </index> </table> @@ -1743,18 +1743,18 @@ comment="Online Refunded"/> <column xsi:type="decimal" name="offline_refunded" scale="4" precision="12" unsigned="false" nullable="true" comment="Offline Refunded"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_REFUNDED_AGGREGATED_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="SALES_REFUNDED_AGGREGATED_STORE_ID_STORE_STORE_ID" table="sales_refunded_aggregated" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <constraint xsi:type="unique" name="SALES_REFUNDED_AGGREGATED_PERIOD_STORE_ID_ORDER_STATUS"> + <constraint xsi:type="unique" referenceId="SALES_REFUNDED_AGGREGATED_PERIOD_STORE_ID_ORDER_STATUS"> <column name="period"/> <column name="store_id"/> <column name="order_status"/> </constraint> - <index name="SALES_REFUNDED_AGGREGATED_STORE_ID" indexType="btree"> + <index referenceId="SALES_REFUNDED_AGGREGATED_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -1773,18 +1773,18 @@ comment="Online Refunded"/> <column xsi:type="decimal" name="offline_refunded" scale="4" precision="12" unsigned="false" nullable="true" comment="Offline Refunded"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_REFUNDED_AGGREGATED_ORDER_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="SALES_REFUNDED_AGGREGATED_ORDER_STORE_ID_STORE_STORE_ID" table="sales_refunded_aggregated_order" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <constraint xsi:type="unique" name="SALES_REFUNDED_AGGREGATED_ORDER_PERIOD_STORE_ID_ORDER_STATUS"> + <constraint xsi:type="unique" referenceId="SALES_REFUNDED_AGGREGATED_ORDER_PERIOD_STORE_ID_ORDER_STATUS"> <column name="period"/> <column name="store_id"/> <column name="order_status"/> </constraint> - <index name="SALES_REFUNDED_AGGREGATED_ORDER_STORE_ID" indexType="btree"> + <index referenceId="SALES_REFUNDED_AGGREGATED_ORDER_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -1802,19 +1802,19 @@ comment="Total Shipping"/> <column xsi:type="decimal" name="total_shipping_actual" scale="4" precision="12" unsigned="false" nullable="true" comment="Total Shipping Actual"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_SHIPPING_AGGREGATED_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="SALES_SHIPPING_AGGREGATED_STORE_ID_STORE_STORE_ID" table="sales_shipping_aggregated" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <constraint xsi:type="unique" name="SALES_SHPP_AGGRED_PERIOD_STORE_ID_ORDER_STS_SHPP_DESCRIPTION"> + <constraint xsi:type="unique" referenceId="SALES_SHPP_AGGRED_PERIOD_STORE_ID_ORDER_STS_SHPP_DESCRIPTION"> <column name="period"/> <column name="store_id"/> <column name="order_status"/> <column name="shipping_description"/> </constraint> - <index name="SALES_SHIPPING_AGGREGATED_STORE_ID" indexType="btree"> + <index referenceId="SALES_SHIPPING_AGGREGATED_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -1833,19 +1833,19 @@ comment="Total Shipping"/> <column xsi:type="decimal" name="total_shipping_actual" scale="4" precision="12" unsigned="false" nullable="true" comment="Total Shipping Actual"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_SHIPPING_AGGREGATED_ORDER_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="SALES_SHIPPING_AGGREGATED_ORDER_STORE_ID_STORE_STORE_ID" table="sales_shipping_aggregated_order" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <constraint xsi:type="unique" name="UNQ_C05FAE47282EEA68654D0924E946761F"> + <constraint xsi:type="unique" referenceId="UNQ_C05FAE47282EEA68654D0924E946761F"> <column name="period"/> <column name="store_id"/> <column name="order_status"/> <column name="shipping_description"/> </constraint> - <index name="SALES_SHIPPING_AGGREGATED_ORDER_STORE_ID" indexType="btree"> + <index referenceId="SALES_SHIPPING_AGGREGATED_ORDER_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -1864,21 +1864,21 @@ default="0" comment="Qty Ordered"/> <column xsi:type="smallint" name="rating_pos" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Rating Pos"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_BESTSELLERS_AGGREGATED_DAILY_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="SALES_BESTSELLERS_AGGREGATED_DAILY_STORE_ID_STORE_STORE_ID" table="sales_bestsellers_aggregated_daily" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="SALES_BESTSELLERS_AGGREGATED_DAILY_PERIOD_STORE_ID_PRODUCT_ID"> + <constraint xsi:type="unique" referenceId="SALES_BESTSELLERS_AGGREGATED_DAILY_PERIOD_STORE_ID_PRODUCT_ID"> <column name="period"/> <column name="store_id"/> <column name="product_id"/> </constraint> - <index name="SALES_BESTSELLERS_AGGREGATED_DAILY_STORE_ID" indexType="btree"> + <index referenceId="SALES_BESTSELLERS_AGGREGATED_DAILY_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="SALES_BESTSELLERS_AGGREGATED_DAILY_PRODUCT_ID" indexType="btree"> + <index referenceId="SALES_BESTSELLERS_AGGREGATED_DAILY_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> </table> @@ -1897,21 +1897,21 @@ default="0" comment="Qty Ordered"/> <column xsi:type="smallint" name="rating_pos" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Rating Pos"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_BESTSELLERS_AGGREGATED_MONTHLY_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="SALES_BESTSELLERS_AGGREGATED_MONTHLY_STORE_ID_STORE_STORE_ID" table="sales_bestsellers_aggregated_monthly" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="SALES_BESTSELLERS_AGGREGATED_MONTHLY_PERIOD_STORE_ID_PRODUCT_ID"> + <constraint xsi:type="unique" referenceId="SALES_BESTSELLERS_AGGREGATED_MONTHLY_PERIOD_STORE_ID_PRODUCT_ID"> <column name="period"/> <column name="store_id"/> <column name="product_id"/> </constraint> - <index name="SALES_BESTSELLERS_AGGREGATED_MONTHLY_STORE_ID" indexType="btree"> + <index referenceId="SALES_BESTSELLERS_AGGREGATED_MONTHLY_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="SALES_BESTSELLERS_AGGREGATED_MONTHLY_PRODUCT_ID" indexType="btree"> + <index referenceId="SALES_BESTSELLERS_AGGREGATED_MONTHLY_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> </table> @@ -1930,21 +1930,21 @@ default="0" comment="Qty Ordered"/> <column xsi:type="smallint" name="rating_pos" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Rating Pos"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_BESTSELLERS_AGGREGATED_YEARLY_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="SALES_BESTSELLERS_AGGREGATED_YEARLY_STORE_ID_STORE_STORE_ID" table="sales_bestsellers_aggregated_yearly" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="SALES_BESTSELLERS_AGGREGATED_YEARLY_PERIOD_STORE_ID_PRODUCT_ID"> + <constraint xsi:type="unique" referenceId="SALES_BESTSELLERS_AGGREGATED_YEARLY_PERIOD_STORE_ID_PRODUCT_ID"> <column name="period"/> <column name="store_id"/> <column name="product_id"/> </constraint> - <index name="SALES_BESTSELLERS_AGGREGATED_YEARLY_STORE_ID" indexType="btree"> + <index referenceId="SALES_BESTSELLERS_AGGREGATED_YEARLY_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="SALES_BESTSELLERS_AGGREGATED_YEARLY_PRODUCT_ID" indexType="btree"> + <index referenceId="SALES_BESTSELLERS_AGGREGATED_YEARLY_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> </table> @@ -1969,10 +1969,10 @@ comment="Process"/> <column xsi:type="decimal" name="base_real_amount" scale="4" precision="12" unsigned="false" nullable="true" comment="Base Real Amount"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="tax_id"/> </constraint> - <index name="SALES_ORDER_TAX_ORDER_ID_PRIORITY_POSITION" indexType="btree"> + <index referenceId="SALES_ORDER_TAX_ORDER_ID_PRIORITY_POSITION" indexType="btree"> <column name="order_id"/> <column name="priority"/> <column name="position"/> @@ -1999,30 +1999,30 @@ comment="Id of the associated item"/> <column xsi:type="varchar" name="taxable_item_type" nullable="false" length="32" comment="Type of the taxable item"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="tax_item_id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_ORDER_TAX_ITEM_ASSOCIATED_ITEM_ID_SALES_ORDER_ITEM_ITEM_ID" + <constraint xsi:type="foreign" referenceId="SALES_ORDER_TAX_ITEM_ASSOCIATED_ITEM_ID_SALES_ORDER_ITEM_ITEM_ID" table="sales_order_tax_item" column="associated_item_id" referenceTable="sales_order_item" referenceColumn="item_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="SALES_ORDER_TAX_ITEM_TAX_ID_SALES_ORDER_TAX_TAX_ID" + <constraint xsi:type="foreign" referenceId="SALES_ORDER_TAX_ITEM_TAX_ID_SALES_ORDER_TAX_TAX_ID" table="sales_order_tax_item" column="tax_id" referenceTable="sales_order_tax" referenceColumn="tax_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="SALES_ORDER_TAX_ITEM_ITEM_ID_SALES_ORDER_ITEM_ITEM_ID" + <constraint xsi:type="foreign" referenceId="SALES_ORDER_TAX_ITEM_ITEM_ID_SALES_ORDER_ITEM_ITEM_ID" table="sales_order_tax_item" column="item_id" referenceTable="sales_order_item" referenceColumn="item_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="SALES_ORDER_TAX_ITEM_TAX_ID_ITEM_ID"> + <constraint xsi:type="unique" referenceId="SALES_ORDER_TAX_ITEM_TAX_ID_ITEM_ID"> <column name="tax_id"/> <column name="item_id"/> </constraint> - <index name="SALES_ORDER_TAX_ITEM_ITEM_ID" indexType="btree"> + <index referenceId="SALES_ORDER_TAX_ITEM_ITEM_ID" indexType="btree"> <column name="item_id"/> </index> </table> <table name="sales_order_status" resource="sales" engine="innodb" comment="Sales Order Status Table"> <column xsi:type="varchar" name="status" nullable="false" length="32" comment="Status"/> <column xsi:type="varchar" name="label" nullable="false" length="128" comment="Label"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="status"/> </constraint> </table> @@ -2033,11 +2033,11 @@ default="0" comment="Is Default"/> <column xsi:type="smallint" name="visible_on_front" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Visible on front"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="status"/> <column name="state"/> </constraint> - <constraint xsi:type="foreign" name="SALES_ORDER_STATUS_STATE_STATUS_SALES_ORDER_STATUS_STATUS" + <constraint xsi:type="foreign" referenceId="SALES_ORDER_STATUS_STATE_STATUS_SALES_ORDER_STATUS_STATUS" table="sales_order_status_state" column="status" referenceTable="sales_order_status" referenceColumn="status" onDelete="CASCADE"/> </table> @@ -2046,17 +2046,17 @@ <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Store Id"/> <column xsi:type="varchar" name="label" nullable="false" length="128" comment="Label"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="status"/> <column name="store_id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_ORDER_STATUS_LABEL_STATUS_SALES_ORDER_STATUS_STATUS" + <constraint xsi:type="foreign" referenceId="SALES_ORDER_STATUS_LABEL_STATUS_SALES_ORDER_STATUS_STATUS" table="sales_order_status_label" column="status" referenceTable="sales_order_status" referenceColumn="status" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="SALES_ORDER_STATUS_LABEL_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="SALES_ORDER_STATUS_LABEL_STORE_ID_STORE_STORE_ID" table="sales_order_status_label" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <index name="SALES_ORDER_STATUS_LABEL_STORE_ID" indexType="btree"> + <index referenceId="SALES_ORDER_STATUS_LABEL_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> diff --git a/app/code/Magento/SalesRule/etc/db_schema.xml b/app/code/Magento/SalesRule/etc/db_schema.xml index a81a0b0a50f23..8dbdf76387cd8 100644 --- a/app/code/Magento/SalesRule/etc/db_schema.xml +++ b/app/code/Magento/SalesRule/etc/db_schema.xml @@ -46,10 +46,10 @@ identity="false" default="0" comment="Use Auto Generation"/> <column xsi:type="int" name="uses_per_coupon" padding="11" unsigned="false" nullable="false" identity="false" default="0" comment="User Per Coupon"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="rule_id"/> </constraint> - <index name="SALESRULE_IS_ACTIVE_SORT_ORDER_TO_DATE_FROM_DATE" indexType="btree"> + <index referenceId="SALESRULE_IS_ACTIVE_SORT_ORDER_TO_DATE_FROM_DATE" indexType="btree"> <column name="is_active"/> <column name="sort_order"/> <column name="to_date"/> @@ -76,19 +76,19 @@ comment="Coupon Code Creation Date"/> <column xsi:type="smallint" name="type" padding="6" unsigned="false" nullable="true" identity="false" default="0" comment="Coupon Code Type"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="coupon_id"/> </constraint> - <constraint xsi:type="foreign" name="SALESRULE_COUPON_RULE_ID_SALESRULE_RULE_ID" table="salesrule_coupon" + <constraint xsi:type="foreign" referenceId="SALESRULE_COUPON_RULE_ID_SALESRULE_RULE_ID" table="salesrule_coupon" column="rule_id" referenceTable="salesrule" referenceColumn="rule_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="SALESRULE_COUPON_CODE"> + <constraint xsi:type="unique" referenceId="SALESRULE_COUPON_CODE"> <column name="code"/> </constraint> - <constraint xsi:type="unique" name="SALESRULE_COUPON_RULE_ID_IS_PRIMARY"> + <constraint xsi:type="unique" referenceId="SALESRULE_COUPON_RULE_ID_IS_PRIMARY"> <column name="rule_id"/> <column name="is_primary"/> </constraint> - <index name="SALESRULE_COUPON_RULE_ID" indexType="btree"> + <index referenceId="SALESRULE_COUPON_RULE_ID" indexType="btree"> <column name="rule_id"/> </index> </table> @@ -99,17 +99,17 @@ comment="Customer Id"/> <column xsi:type="int" name="times_used" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Times Used"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="coupon_id"/> <column name="customer_id"/> </constraint> - <constraint xsi:type="foreign" name="SALESRULE_COUPON_USAGE_COUPON_ID_SALESRULE_COUPON_COUPON_ID" + <constraint xsi:type="foreign" referenceId="SALESRULE_COUPON_USAGE_COUPON_ID_SALESRULE_COUPON_COUPON_ID" table="salesrule_coupon_usage" column="coupon_id" referenceTable="salesrule_coupon" referenceColumn="coupon_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="SALESRULE_COUPON_USAGE_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="SALESRULE_COUPON_USAGE_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="salesrule_coupon_usage" column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <index name="SALESRULE_COUPON_USAGE_CUSTOMER_ID" indexType="btree"> + <index referenceId="SALESRULE_COUPON_USAGE_CUSTOMER_ID" indexType="btree"> <column name="customer_id"/> </index> </table> @@ -122,19 +122,19 @@ default="0" comment="Customer Id"/> <column xsi:type="smallint" name="times_used" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Times Used"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="rule_customer_id"/> </constraint> - <constraint xsi:type="foreign" name="SALESRULE_CUSTOMER_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="SALESRULE_CUSTOMER_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="salesrule_customer" column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="SALESRULE_CUSTOMER_RULE_ID_SALESRULE_RULE_ID" table="salesrule_customer" + <constraint xsi:type="foreign" referenceId="SALESRULE_CUSTOMER_RULE_ID_SALESRULE_RULE_ID" table="salesrule_customer" column="rule_id" referenceTable="salesrule" referenceColumn="rule_id" onDelete="CASCADE"/> - <index name="SALESRULE_CUSTOMER_RULE_ID_CUSTOMER_ID" indexType="btree"> + <index referenceId="SALESRULE_CUSTOMER_RULE_ID_CUSTOMER_ID" indexType="btree"> <column name="rule_id"/> <column name="customer_id"/> </index> - <index name="SALESRULE_CUSTOMER_CUSTOMER_ID_RULE_ID" indexType="btree"> + <index referenceId="SALESRULE_CUSTOMER_CUSTOMER_ID_RULE_ID" indexType="btree"> <column name="customer_id"/> <column name="rule_id"/> </index> @@ -147,18 +147,18 @@ <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Store Id"/> <column xsi:type="varchar" name="label" nullable="true" length="255" comment="Label"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="label_id"/> </constraint> - <constraint xsi:type="foreign" name="SALESRULE_LABEL_RULE_ID_SALESRULE_RULE_ID" table="salesrule_label" + <constraint xsi:type="foreign" referenceId="SALESRULE_LABEL_RULE_ID_SALESRULE_RULE_ID" table="salesrule_label" column="rule_id" referenceTable="salesrule" referenceColumn="rule_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="SALESRULE_LABEL_STORE_ID_STORE_STORE_ID" table="salesrule_label" + <constraint xsi:type="foreign" referenceId="SALESRULE_LABEL_STORE_ID_STORE_STORE_ID" table="salesrule_label" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="SALESRULE_LABEL_RULE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="SALESRULE_LABEL_RULE_ID_STORE_ID"> <column name="rule_id"/> <column name="store_id"/> </constraint> - <index name="SALESRULE_LABEL_STORE_ID" indexType="btree"> + <index referenceId="SALESRULE_LABEL_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -171,31 +171,31 @@ comment="Customer Group Id"/> <column xsi:type="smallint" name="attribute_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Attribute Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="rule_id"/> <column name="website_id"/> <column name="customer_group_id"/> <column name="attribute_id"/> </constraint> - <constraint xsi:type="foreign" name="SALESRULE_PRD_ATTR_ATTR_ID_EAV_ATTR_ATTR_ID" + <constraint xsi:type="foreign" referenceId="SALESRULE_PRD_ATTR_ATTR_ID_EAV_ATTR_ATTR_ID" table="salesrule_product_attribute" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="SALESRULE_PRD_ATTR_CSTR_GROUP_ID_CSTR_GROUP_CSTR_GROUP_ID" + <constraint xsi:type="foreign" referenceId="SALESRULE_PRD_ATTR_CSTR_GROUP_ID_CSTR_GROUP_CSTR_GROUP_ID" table="salesrule_product_attribute" column="customer_group_id" referenceTable="customer_group" referenceColumn="customer_group_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="SALESRULE_PRODUCT_ATTRIBUTE_RULE_ID_SALESRULE_RULE_ID" + <constraint xsi:type="foreign" referenceId="SALESRULE_PRODUCT_ATTRIBUTE_RULE_ID_SALESRULE_RULE_ID" table="salesrule_product_attribute" column="rule_id" referenceTable="salesrule" referenceColumn="rule_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="SALESRULE_PRODUCT_ATTRIBUTE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" + <constraint xsi:type="foreign" referenceId="SALESRULE_PRODUCT_ATTRIBUTE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" table="salesrule_product_attribute" column="website_id" referenceTable="store_website" referenceColumn="website_id" onDelete="CASCADE"/> - <index name="SALESRULE_PRODUCT_ATTRIBUTE_WEBSITE_ID" indexType="btree"> + <index referenceId="SALESRULE_PRODUCT_ATTRIBUTE_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> - <index name="SALESRULE_PRODUCT_ATTRIBUTE_CUSTOMER_GROUP_ID" indexType="btree"> + <index referenceId="SALESRULE_PRODUCT_ATTRIBUTE_CUSTOMER_GROUP_ID" indexType="btree"> <column name="customer_group_id"/> </index> - <index name="SALESRULE_PRODUCT_ATTRIBUTE_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="SALESRULE_PRODUCT_ATTRIBUTE_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> </table> @@ -221,22 +221,22 @@ <column xsi:type="decimal" name="total_amount_actual" scale="4" precision="12" unsigned="false" nullable="false" default="0" comment="Total Amount Actual"/> <column xsi:type="varchar" name="rule_name" nullable="true" length="255" comment="Rule Name"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="SALESRULE_COUPON_AGGREGATED_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="SALESRULE_COUPON_AGGREGATED_STORE_ID_STORE_STORE_ID" table="salesrule_coupon_aggregated" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="SALESRULE_COUPON_AGGRED_PERIOD_STORE_ID_ORDER_STS_COUPON_CODE"> + <constraint xsi:type="unique" referenceId="SALESRULE_COUPON_AGGRED_PERIOD_STORE_ID_ORDER_STS_COUPON_CODE"> <column name="period"/> <column name="store_id"/> <column name="order_status"/> <column name="coupon_code"/> </constraint> - <index name="SALESRULE_COUPON_AGGREGATED_STORE_ID" indexType="btree"> + <index referenceId="SALESRULE_COUPON_AGGREGATED_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="SALESRULE_COUPON_AGGREGATED_RULE_NAME" indexType="btree"> + <index referenceId="SALESRULE_COUPON_AGGREGATED_RULE_NAME" indexType="btree"> <column name="rule_name"/> </index> </table> @@ -263,22 +263,22 @@ <column xsi:type="decimal" name="total_amount_actual" scale="4" precision="12" unsigned="false" nullable="false" default="0" comment="Total Amount Actual"/> <column xsi:type="varchar" name="rule_name" nullable="true" length="255" comment="Rule Name"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="SALESRULE_COUPON_AGGREGATED_UPDATED_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="SALESRULE_COUPON_AGGREGATED_UPDATED_STORE_ID_STORE_STORE_ID" table="salesrule_coupon_aggregated_updated" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="UNQ_7196FA120A4F0F84E1B66605E87E213E"> + <constraint xsi:type="unique" referenceId="UNQ_7196FA120A4F0F84E1B66605E87E213E"> <column name="period"/> <column name="store_id"/> <column name="order_status"/> <column name="coupon_code"/> </constraint> - <index name="SALESRULE_COUPON_AGGREGATED_UPDATED_STORE_ID" indexType="btree"> + <index referenceId="SALESRULE_COUPON_AGGREGATED_UPDATED_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="SALESRULE_COUPON_AGGREGATED_UPDATED_RULE_NAME" indexType="btree"> + <index referenceId="SALESRULE_COUPON_AGGREGATED_UPDATED_RULE_NAME" indexType="btree"> <column name="rule_name"/> </index> </table> @@ -299,22 +299,22 @@ <column xsi:type="decimal" name="total_amount" scale="4" precision="12" unsigned="false" nullable="false" default="0" comment="Total Amount"/> <column xsi:type="varchar" name="rule_name" nullable="true" length="255" comment="Rule Name"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="SALESRULE_COUPON_AGGREGATED_ORDER_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="SALESRULE_COUPON_AGGREGATED_ORDER_STORE_ID_STORE_STORE_ID" table="salesrule_coupon_aggregated_order" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="UNQ_1094D1FBBCBB11704A29DEF3ACC37D2B"> + <constraint xsi:type="unique" referenceId="UNQ_1094D1FBBCBB11704A29DEF3ACC37D2B"> <column name="period"/> <column name="store_id"/> <column name="order_status"/> <column name="coupon_code"/> </constraint> - <index name="SALESRULE_COUPON_AGGREGATED_ORDER_STORE_ID" indexType="btree"> + <index referenceId="SALESRULE_COUPON_AGGREGATED_ORDER_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="SALESRULE_COUPON_AGGREGATED_ORDER_RULE_NAME" indexType="btree"> + <index referenceId="SALESRULE_COUPON_AGGREGATED_ORDER_RULE_NAME" indexType="btree"> <column name="rule_name"/> </index> </table> @@ -323,16 +323,16 @@ comment="Rule ID"/> <column xsi:type="smallint" name="website_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Website Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="rule_id"/> <column name="website_id"/> </constraint> - <constraint xsi:type="foreign" name="SALESRULE_WEBSITE_RULE_ID_SALESRULE_RULE_ID" table="salesrule_website" + <constraint xsi:type="foreign" referenceId="SALESRULE_WEBSITE_RULE_ID_SALESRULE_RULE_ID" table="salesrule_website" column="rule_id" referenceTable="salesrule" referenceColumn="rule_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="SALESRULE_WEBSITE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" + <constraint xsi:type="foreign" referenceId="SALESRULE_WEBSITE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" table="salesrule_website" column="website_id" referenceTable="store_website" referenceColumn="website_id" onDelete="CASCADE"/> - <index name="SALESRULE_WEBSITE_WEBSITE_ID" indexType="btree"> + <index referenceId="SALESRULE_WEBSITE_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> </table> @@ -342,17 +342,17 @@ comment="Rule ID"/> <column xsi:type="int" name="customer_group_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Customer Group Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="rule_id"/> <column name="customer_group_id"/> </constraint> - <constraint xsi:type="foreign" name="SALESRULE_CUSTOMER_GROUP_RULE_ID_SALESRULE_RULE_ID" + <constraint xsi:type="foreign" referenceId="SALESRULE_CUSTOMER_GROUP_RULE_ID_SALESRULE_RULE_ID" table="salesrule_customer_group" column="rule_id" referenceTable="salesrule" referenceColumn="rule_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="SALESRULE_CSTR_GROUP_CSTR_GROUP_ID_CSTR_GROUP_CSTR_GROUP_ID" + <constraint xsi:type="foreign" referenceId="SALESRULE_CSTR_GROUP_CSTR_GROUP_ID_CSTR_GROUP_CSTR_GROUP_ID" table="salesrule_customer_group" column="customer_group_id" referenceTable="customer_group" referenceColumn="customer_group_id" onDelete="CASCADE"/> - <index name="SALESRULE_CUSTOMER_GROUP_CUSTOMER_GROUP_ID" indexType="btree"> + <index referenceId="SALESRULE_CUSTOMER_GROUP_CUSTOMER_GROUP_ID" indexType="btree"> <column name="customer_group_id"/> </index> </table> diff --git a/app/code/Magento/SalesSequence/etc/db_schema.xml b/app/code/Magento/SalesSequence/etc/db_schema.xml index 530a9a33b0cfe..0e580b85bd608 100644 --- a/app/code/Magento/SalesSequence/etc/db_schema.xml +++ b/app/code/Magento/SalesSequence/etc/db_schema.xml @@ -23,13 +23,13 @@ <column xsi:type="int" name="warning_value" padding="10" unsigned="true" nullable="false" identity="false" comment="WarningValue for sequence"/> <column xsi:type="boolean" name="is_active" nullable="false" default="false" comment="isActive flag"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="profile_id"/> </constraint> - <constraint xsi:type="foreign" name="SALES_SEQUENCE_PROFILE_META_ID_SALES_SEQUENCE_META_META_ID" + <constraint xsi:type="foreign" referenceId="SALES_SEQUENCE_PROFILE_META_ID_SALES_SEQUENCE_META_META_ID" table="sales_sequence_profile" column="meta_id" referenceTable="sales_sequence_meta" referenceColumn="meta_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="SALES_SEQUENCE_PROFILE_META_ID_PREFIX_SUFFIX"> + <constraint xsi:type="unique" referenceId="SALES_SEQUENCE_PROFILE_META_ID_PREFIX_SUFFIX"> <column name="meta_id"/> <column name="prefix"/> <column name="suffix"/> @@ -42,10 +42,10 @@ <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Store Id"/> <column xsi:type="varchar" name="sequence_table" nullable="false" length="32" comment="table for sequence"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="meta_id"/> </constraint> - <constraint xsi:type="unique" name="SALES_SEQUENCE_META_ENTITY_TYPE_STORE_ID"> + <constraint xsi:type="unique" referenceId="SALES_SEQUENCE_META_ENTITY_TYPE_STORE_ID"> <column name="entity_type"/> <column name="store_id"/> </constraint> diff --git a/app/code/Magento/Search/Model/Query.php b/app/code/Magento/Search/Model/Query.php index 365e03b3648a7..d8c92a4801e8c 100644 --- a/app/code/Magento/Search/Model/Query.php +++ b/app/code/Magento/Search/Model/Query.php @@ -5,7 +5,6 @@ */ namespace Magento\Search\Model; -use Magento\Framework\App\ResourceConnection; use Magento\Search\Model\ResourceModel\Query\Collection as QueryCollection; use Magento\Search\Model\ResourceModel\Query\CollectionFactory as QueryCollectionFactory; use Magento\Search\Model\SearchCollectionInterface as Collection; @@ -296,8 +295,7 @@ public function getMaxQueryLength() } /** - * @return string - * @codeCoverageIgnore + * @inheritdoc */ public function getQueryText() { @@ -305,6 +303,8 @@ public function getQueryText() } /** + * Check if query maximum length exceeded. + * * @return bool * @codeCoverageIgnore */ @@ -314,6 +314,8 @@ public function isQueryTextExceeded() } /** + * Check if minimum query length reached. + * * @return bool * @codeCoverageIgnore * @since 100.1.0 diff --git a/app/code/Magento/Search/Model/Search/PageSizeProvider.php b/app/code/Magento/Search/Model/Search/PageSizeProvider.php new file mode 100644 index 0000000000000..5572bac6addc3 --- /dev/null +++ b/app/code/Magento/Search/Model/Search/PageSizeProvider.php @@ -0,0 +1,54 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Search\Model\Search; + +/** + * Returns max page size by search engine name + * @api + */ +class PageSizeProvider +{ + /** + * @var \Magento\Search\Model\EngineResolver + */ + private $engineResolver; + + /** + * @var array + */ + private $pageSizeBySearchEngine; + + /** + * @param \Magento\Search\Model\EngineResolver $engineResolver + * @param array $pageSizeBySearchEngine + */ + public function __construct( + \Magento\Search\Model\EngineResolver $engineResolver, + array $pageSizeBySearchEngine = [] + ) { + $this->engineResolver = $engineResolver; + $this->pageSizeBySearchEngine = $pageSizeBySearchEngine; + } + + /** + * Returns max_page_size depends on engine + * + * @return integer + */ + public function getMaxPageSize() : int + { + $searchEngine = $this->engineResolver->getCurrentSearchEngine(); + + $pageSize = PHP_INT_MAX; + if (isset($this->pageSizeBySearchEngine[$searchEngine])) { + $pageSize = $this->pageSizeBySearchEngine[$searchEngine]; + } + + return (int)$pageSize; + } +} diff --git a/app/code/Magento/Search/Test/Unit/Model/Search/PageSizeProviderTest.php b/app/code/Magento/Search/Test/Unit/Model/Search/PageSizeProviderTest.php new file mode 100644 index 0000000000000..982d00bd9f648 --- /dev/null +++ b/app/code/Magento/Search/Test/Unit/Model/Search/PageSizeProviderTest.php @@ -0,0 +1,61 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Search\Test\Unit\Model\Search; + +use Magento\Search\Model\Search\PageSizeProvider; + +class PageSizeProviderTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var PageSizeProvider + */ + private $model; + + /** + * @var \Magento\Search\Model\EngineResolver|\PHPUnit_Framework_MockObject_MockObject + */ + private $pageSizeBySearchEngineMock; + + public function setUp() + { + $this->pageSizeBySearchEngineMock = $this->getMockBuilder(\Magento\Search\Model\EngineResolver::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->model = new PageSizeProvider( + + $this->pageSizeBySearchEngineMock, + ['search' => 10, + 'catalogSearch3' => 11 + ] + ); + } + + /** + * @param string $searchEngine + * @param int $size + * @dataProvider getPageSizeDataProvider + */ + public function testGetPageSize($searchEngine, $size) + { + $this->pageSizeBySearchEngineMock + ->expects($this->once()) + ->method('getCurrentSearchEngine') + ->willReturn($searchEngine); + $this->assertEquals($size, $this->model->getMaxPageSize()); + } + + public function getPageSizeDataProvider() + { + return [ + ['search', 10], + ['catalogSearch3', 11], + ['newSearch', PHP_INT_MAX] + ]; + } +} diff --git a/app/code/Magento/Search/etc/db_schema.xml b/app/code/Magento/Search/etc/db_schema.xml index 9b2dfb493dbb8..754af7d246d6d 100644 --- a/app/code/Magento/Search/etc/db_schema.xml +++ b/app/code/Magento/Search/etc/db_schema.xml @@ -26,24 +26,24 @@ default="0" comment="Processed status"/> <column xsi:type="timestamp" name="updated_at" on_update="true" nullable="false" default="CURRENT_TIMESTAMP" comment="Updated at"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="query_id"/> </constraint> - <constraint xsi:type="foreign" name="SEARCH_QUERY_STORE_ID_STORE_STORE_ID" table="search_query" + <constraint xsi:type="foreign" referenceId="SEARCH_QUERY_STORE_ID_STORE_STORE_ID" table="search_query" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="SEARCH_QUERY_QUERY_TEXT_STORE_ID"> + <constraint xsi:type="unique" referenceId="SEARCH_QUERY_QUERY_TEXT_STORE_ID"> <column name="query_text"/> <column name="store_id"/> </constraint> - <index name="SEARCH_QUERY_QUERY_TEXT_STORE_ID_POPULARITY" indexType="btree"> + <index referenceId="SEARCH_QUERY_QUERY_TEXT_STORE_ID_POPULARITY" indexType="btree"> <column name="query_text"/> <column name="store_id"/> <column name="popularity"/> </index> - <index name="SEARCH_QUERY_STORE_ID" indexType="btree"> + <index referenceId="SEARCH_QUERY_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="SEARCH_QUERY_IS_PROCESSED" indexType="btree"> + <index referenceId="SEARCH_QUERY_IS_PROCESSED" indexType="btree"> <column name="is_processed"/> </index> </table> @@ -55,21 +55,21 @@ default="0" comment="Store Id - identifies the store view these synonyms belong to"/> <column xsi:type="smallint" name="website_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Website Id - identifies the website id these synonyms belong to"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="group_id"/> </constraint> - <constraint xsi:type="foreign" name="SEARCH_SYNONYMS_STORE_ID_STORE_STORE_ID" table="search_synonyms" + <constraint xsi:type="foreign" referenceId="SEARCH_SYNONYMS_STORE_ID_STORE_STORE_ID" table="search_synonyms" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="SEARCH_SYNONYMS_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" + <constraint xsi:type="foreign" referenceId="SEARCH_SYNONYMS_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" table="search_synonyms" column="website_id" referenceTable="store_website" referenceColumn="website_id" onDelete="CASCADE"/> - <index name="SEARCH_SYNONYMS_SYNONYMS" indexType="fulltext"> + <index referenceId="SEARCH_SYNONYMS_SYNONYMS" indexType="fulltext"> <column name="synonyms"/> </index> - <index name="SEARCH_SYNONYMS_STORE_ID" indexType="btree"> + <index referenceId="SEARCH_SYNONYMS_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index name="SEARCH_SYNONYMS_WEBSITE_ID" indexType="btree"> + <index referenceId="SEARCH_SYNONYMS_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> </table> diff --git a/app/code/Magento/Security/etc/db_schema.xml b/app/code/Magento/Security/etc/db_schema.xml index f14e6de79e894..ce7143582ce69 100644 --- a/app/code/Magento/Security/etc/db_schema.xml +++ b/app/code/Magento/Security/etc/db_schema.xml @@ -21,15 +21,15 @@ comment="Update Time"/> <column xsi:type="varchar" name="ip" nullable="false" length="15" onCreate="migrateDataFrom(ip)" comment="Remote user IP"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="ADMIN_USER_SESSION_USER_ID_ADMIN_USER_USER_ID" table="admin_user_session" + <constraint xsi:type="foreign" referenceId="ADMIN_USER_SESSION_USER_ID_ADMIN_USER_USER_ID" table="admin_user_session" column="user_id" referenceTable="admin_user" referenceColumn="user_id" onDelete="CASCADE"/> - <index name="ADMIN_USER_SESSION_SESSION_ID" indexType="btree"> + <index referenceId="ADMIN_USER_SESSION_SESSION_ID" indexType="btree"> <column name="session_id"/> </index> - <index name="ADMIN_USER_SESSION_USER_ID" indexType="btree"> + <index referenceId="ADMIN_USER_SESSION_USER_ID" indexType="btree"> <column name="user_id"/> </index> </table> @@ -45,13 +45,13 @@ comment="Timestamp when the event occurs"/> <column xsi:type="varchar" name="ip" nullable="false" length="15" onCreate="migrateDataFrom(ip)" comment="Remote user IP"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <index name="PASSWORD_RESET_REQUEST_EVENT_ACCOUNT_REFERENCE" indexType="btree"> + <index referenceId="PASSWORD_RESET_REQUEST_EVENT_ACCOUNT_REFERENCE" indexType="btree"> <column name="account_reference"/> </index> - <index name="PASSWORD_RESET_REQUEST_EVENT_CREATED_AT" indexType="btree"> + <index referenceId="PASSWORD_RESET_REQUEST_EVENT_CREATED_AT" indexType="btree"> <column name="created_at"/> </index> </table> diff --git a/app/code/Magento/SendFriend/etc/db_schema.xml b/app/code/Magento/SendFriend/etc/db_schema.xml index 7537f67cf552a..b9551749dfc6d 100644 --- a/app/code/Magento/SendFriend/etc/db_schema.xml +++ b/app/code/Magento/SendFriend/etc/db_schema.xml @@ -16,13 +16,13 @@ comment="Log time"/> <column xsi:type="smallint" name="website_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Website ID"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="log_id"/> </constraint> - <index name="SENDFRIEND_LOG_IP" indexType="btree"> + <index referenceId="SENDFRIEND_LOG_IP" indexType="btree"> <column name="ip"/> </index> - <index name="SENDFRIEND_LOG_TIME" indexType="btree"> + <index referenceId="SENDFRIEND_LOG_TIME" indexType="btree"> <column name="time"/> </index> </table> diff --git a/app/code/Magento/Signifyd/etc/db_schema.xml b/app/code/Magento/Signifyd/etc/db_schema.xml index 6f41b883c71e1..8d47321c38b29 100644 --- a/app/code/Magento/Signifyd/etc/db_schema.xml +++ b/app/code/Magento/Signifyd/etc/db_schema.xml @@ -24,15 +24,15 @@ <column xsi:type="varchar" name="review_disposition" nullable="true" length="32" comment="Review_disposition"/> <column xsi:type="timestamp" name="created_at" on_update="false" nullable="true" comment="Created_at"/> <column xsi:type="timestamp" name="updated_at" on_update="false" nullable="true" comment="Updated_at"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="SIGNIFYD_CASE_ORDER_ID_SALES_ORDER_ENTITY_ID" table="signifyd_case" + <constraint xsi:type="foreign" referenceId="SIGNIFYD_CASE_ORDER_ID_SALES_ORDER_ENTITY_ID" table="signifyd_case" column="order_id" referenceTable="sales_order" referenceColumn="entity_id" onDelete="SET NULL"/> - <constraint xsi:type="unique" name="SIGNIFYD_CASE_ORDER_ID"> + <constraint xsi:type="unique" referenceId="SIGNIFYD_CASE_ORDER_ID"> <column name="order_id"/> </constraint> - <constraint xsi:type="unique" name="SIGNIFYD_CASE_CASE_ID"> + <constraint xsi:type="unique" referenceId="SIGNIFYD_CASE_CASE_ID"> <column name="case_id"/> </constraint> </table> diff --git a/app/code/Magento/Sitemap/etc/db_schema.xml b/app/code/Magento/Sitemap/etc/db_schema.xml index 82a9b8ef5148c..b3c028b626b73 100644 --- a/app/code/Magento/Sitemap/etc/db_schema.xml +++ b/app/code/Magento/Sitemap/etc/db_schema.xml @@ -16,12 +16,12 @@ <column xsi:type="timestamp" name="sitemap_time" on_update="false" nullable="true" comment="Sitemap Time"/> <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Store id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="sitemap_id"/> </constraint> - <constraint xsi:type="foreign" name="SITEMAP_STORE_ID_STORE_STORE_ID" table="sitemap" column="store_id" + <constraint xsi:type="foreign" referenceId="SITEMAP_STORE_ID_STORE_STORE_ID" table="sitemap" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <index name="SITEMAP_STORE_ID" indexType="btree"> + <index referenceId="SITEMAP_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> diff --git a/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminCreateStoreViewActionGroup.xml b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminCreateStoreViewActionGroup.xml index 99ca7991e5e90..6cbbb7ae22014 100644 --- a/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminCreateStoreViewActionGroup.xml +++ b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminCreateStoreViewActionGroup.xml @@ -24,7 +24,17 @@ <waitForElementVisible selector="{{AdminConfirmationModalSection.ok}}" stepKey="waitForModal" /> <see selector="{{AdminConfirmationModalSection.title}}" userInput="Warning message" stepKey="seeWarning" /> <click selector="{{AdminConfirmationModalSection.ok}}" stepKey="dismissModal" /> - <waitForElementVisible selector="{{AdminStoresGridSection.storeFilterTextField}}" stepKey="waitForPageReolad"/> + <waitForElementNotVisible selector="{{AdminNewStoreViewActionsSection.loadingMask}}" stepKey="waitForElementVisible"/> + </actionGroup> + <!--Save the Store view--> + <actionGroup name="AdminCreateStoreViewActionSaveGroup"> + <waitForLoadingMaskToDisappear stepKey="waitForGridLoad"/> + <waitForElementVisible selector="{{AdminStoresGridSection.websiteFilterTextField}}" stepKey="waitForStoreGridToReload2"/> <see userInput="You saved the store view." stepKey="seeSavedMessage" /> </actionGroup> + <!--Save the same Store view code for code validation--> + <actionGroup name="AdminCreateStoreViewCodeUniquenessActionGroup"> + <waitForLoadingMaskToDisappear stepKey="waitForForm"/> + <see userInput="Store with the same code already exists." stepKey="seeMessage" /> + </actionGroup> </actionGroups> diff --git a/app/code/Magento/Store/Test/Mftf/Section/AdminNewStoreViewActionsSection.xml b/app/code/Magento/Store/Test/Mftf/Section/AdminNewStoreViewActionsSection.xml index faffc69dc6975..0e3a74fccf9f0 100644 --- a/app/code/Magento/Store/Test/Mftf/Section/AdminNewStoreViewActionsSection.xml +++ b/app/code/Magento/Store/Test/Mftf/Section/AdminNewStoreViewActionsSection.xml @@ -11,5 +11,6 @@ <element name="delete" type="button" selector="#delete" timeout="30"/> <element name="resetButton" type="button" selector="#reset" timeout="30"/> <element name="saveButton" type="button" selector="#save" timeout="60"/> + <element name="loadingMask" type="text" selector=".loading-mask"/> </section> </sections> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreViewTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreViewTest.xml index 54d392d0c06f1..e7a3d03f337db 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreViewTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreViewTest.xml @@ -15,15 +15,25 @@ <description value="Admin should be able to create a store view"/> <group value="storeView"/> <severity value="AVERAGE"/> + <testCaseId value="MAGETWO-95111"/> </annotations> <before> <actionGroup ref="LoginActionGroup" stepKey="login"/> + <actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createStoreView" /> + <!--<createData stepKey="b2" entity="customStoreGroup"/>--> </before> - <actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createStoreView" /> - <!--Confirm new store view on Store Grid--> + <!--Save store view on Store Grid--> + <actionGroup ref="AdminCreateStoreViewActionSaveGroup" stepKey="createStoreViewSave" /> + <!--Confirm new store view created on Store Grid--> <fillField selector="{{AdminStoresGridSection.storeFilterTextField}}" userInput="{{customStore.name}}" stepKey="fillStoreViewFilter"/> <click selector="{{AdminStoresGridSection.searchButton}}" stepKey="clickSearch" /> <waitForPageLoad stepKey="waitForPageLoad"/> <see selector="{{AdminStoresGridSection.storeNameInFirstRow}}" userInput="{{customStore.name}}" stepKey="seeNewStoreView" /> + <!--Creating the same store view to validate the code uniqueness on store form--> + <actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createStoreView2" /> + <actionGroup ref="AdminCreateStoreViewCodeUniquenessActionGroup" stepKey="createStoreViewCode" /> + <after> + <actionGroup ref="logout" stepKey="logout"/> + </after> </test> </tests> diff --git a/app/code/Magento/Store/etc/db_schema.xml b/app/code/Magento/Store/etc/db_schema.xml index 3c2bc3e3c117b..6eea94b8deec7 100644 --- a/app/code/Magento/Store/etc/db_schema.xml +++ b/app/code/Magento/Store/etc/db_schema.xml @@ -18,16 +18,16 @@ identity="false" default="0" comment="Default Group Id"/> <column xsi:type="smallint" name="is_default" padding="5" unsigned="true" nullable="true" identity="false" default="0" comment="Defines Is Website Default"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="website_id"/> </constraint> - <constraint xsi:type="unique" name="STORE_WEBSITE_CODE"> + <constraint xsi:type="unique" referenceId="STORE_WEBSITE_CODE"> <column name="code"/> </constraint> - <index name="STORE_WEBSITE_SORT_ORDER" indexType="btree"> + <index referenceId="STORE_WEBSITE_SORT_ORDER" indexType="btree"> <column name="sort_order"/> </index> - <index name="STORE_WEBSITE_DEFAULT_GROUP_ID" indexType="btree"> + <index referenceId="STORE_WEBSITE_DEFAULT_GROUP_ID" indexType="btree"> <column name="default_group_id"/> </index> </table> @@ -42,18 +42,18 @@ <column xsi:type="smallint" name="default_store_id" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Default Store Id"/> <column xsi:type="varchar" name="code" nullable="true" length="32" comment="Store group unique code"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="group_id"/> </constraint> - <constraint xsi:type="foreign" name="STORE_GROUP_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" table="store_group" + <constraint xsi:type="foreign" referenceId="STORE_GROUP_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" table="store_group" column="website_id" referenceTable="store_website" referenceColumn="website_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="STORE_GROUP_CODE"> + <constraint xsi:type="unique" referenceId="STORE_GROUP_CODE"> <column name="code"/> </constraint> - <index name="STORE_GROUP_WEBSITE_ID" indexType="btree"> + <index referenceId="STORE_GROUP_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> - <index name="STORE_GROUP_DEFAULT_STORE_ID" indexType="btree"> + <index referenceId="STORE_GROUP_DEFAULT_STORE_ID" indexType="btree"> <column name="default_store_id"/> </index> </table> @@ -70,24 +70,24 @@ default="0" comment="Store Sort Order"/> <column xsi:type="smallint" name="is_active" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Store Activity"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="store_id"/> </constraint> - <constraint xsi:type="foreign" name="STORE_GROUP_ID_STORE_GROUP_GROUP_ID" table="store" column="group_id" + <constraint xsi:type="foreign" referenceId="STORE_GROUP_ID_STORE_GROUP_GROUP_ID" table="store" column="group_id" referenceTable="store_group" referenceColumn="group_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="STORE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" table="store" + <constraint xsi:type="foreign" referenceId="STORE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" table="store" column="website_id" referenceTable="store_website" referenceColumn="website_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="STORE_CODE"> + <constraint xsi:type="unique" referenceId="STORE_CODE"> <column name="code"/> </constraint> - <index name="STORE_WEBSITE_ID" indexType="btree"> + <index referenceId="STORE_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> - <index name="STORE_IS_ACTIVE_SORT_ORDER" indexType="btree"> + <index referenceId="STORE_IS_ACTIVE_SORT_ORDER" indexType="btree"> <column name="is_active"/> <column name="sort_order"/> </index> - <index name="STORE_GROUP_ID" indexType="btree"> + <index referenceId="STORE_GROUP_ID" indexType="btree"> <column name="group_id"/> </index> </table> diff --git a/app/code/Magento/Swatches/Test/Mftf/Section/AdminManageSwatchSection.xml b/app/code/Magento/Swatches/Test/Mftf/Section/AdminManageSwatchSection.xml index 25e03676f6870..6538af3178060 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Section/AdminManageSwatchSection.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Section/AdminManageSwatchSection.xml @@ -15,6 +15,7 @@ <element name="addSwatchText" type="button" selector="#add_new_swatch_text_option_button"/> <element name="swatchTextByIndex" type="input" selector="input[name='swatchtext[value][option_{{index}}][0]']" parameterized="true"/> <element name="nthSwatchText" type="input" selector="#swatch-text-options-panel table tbody tr:nth-of-type({{var}}) td:nth-of-type(3) input" parameterized="true"/> + <element name="nthIsDefault" type="input" selector="(//input[@name='defaultvisual[]'])[{{var}}]" parameterized="true"/> <element name="nthSwatchAdminDescription" type="input" selector="#swatch-text-options-panel table tbody tr:nth-of-type({{var}}) td:nth-of-type(4) input" parameterized="true"/> <!-- Selector for Admin Description input where the index is zero-based --> <element name="swatchAdminDescriptionByIndex" type="input" selector="input[name='optiontext[value][option_{{index}}][0]']" parameterized="true"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/AdminCreateVisualSwatchWithNonValidOptionsTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/AdminCreateVisualSwatchWithNonValidOptionsTest.xml index 50dcfbf3da090..b03f771875957 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/AdminCreateVisualSwatchWithNonValidOptionsTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/AdminCreateVisualSwatchWithNonValidOptionsTest.xml @@ -21,11 +21,9 @@ </before> <after> <!-- Remove attribute --> - <actionGroup ref="navigateToCreatedProductAttribute" stepKey="navigateToAttribute"> + <actionGroup ref="deleteProductAttribute" stepKey="deleteAttribute"> <argument name="ProductAttribute" value="visualSwatchAttribute"/> </actionGroup> - <click selector="{{AttributePropertiesSection.DeleteAttribute}}" stepKey="deleteAttribute"/> - <actionGroup ref="logout" stepKey="logout"/> </after> @@ -49,7 +47,7 @@ <!-- Add new swatch option without label --> <click selector="{{AdminManageSwatchSection.addSwatch}}" stepKey="clickAddSwatch1"/> - <actionGroup ref="openSwatchMenuByIndex" stepKey="clickSwatch2"> + <actionGroup ref="openSwatchMenuByIndex" stepKey="clickSwatch1"> <argument name="index" value="0"/> </actionGroup> <click selector="{{AdminManageSwatchSection.nthChooseColor('1')}}" stepKey="clickChooseColor1"/> @@ -66,6 +64,34 @@ <fillField selector="{{AdminManageSwatchSection.adminInputByIndex('0')}}" userInput="red" stepKey="fillAdmin1"/> + <!-- Add 2 additional new swatch options --> + <click selector="{{AdminManageSwatchSection.addSwatch}}" stepKey="clickAddSwatch2"/> + <actionGroup ref="openSwatchMenuByIndex" stepKey="clickSwatch2"> + <argument name="index" value="1"/> + </actionGroup> + <click selector="{{AdminManageSwatchSection.nthChooseColor('2')}}" stepKey="clickChooseColor2"/> + <actionGroup ref="setColorPickerByHex" stepKey="fillHex2"> + <argument name="nthColorPicker" value="2"/> + <argument name="hexColor" value="00ff00"/> + </actionGroup> + <fillField selector="{{AdminManageSwatchSection.adminInputByIndex('1')}}" + userInput="green" stepKey="fillAdmin2"/> + + <click selector="{{AdminManageSwatchSection.addSwatch}}" stepKey="clickAddSwatch3"/> + <actionGroup ref="openSwatchMenuByIndex" stepKey="clickSwatch3"> + <argument name="index" value="2"/> + </actionGroup> + <click selector="{{AdminManageSwatchSection.nthChooseColor('3')}}" stepKey="clickChooseColor3"/> + <actionGroup ref="setColorPickerByHex" stepKey="fillHex3"> + <argument name="nthColorPicker" value="3"/> + <argument name="hexColor" value="0000ff"/> + </actionGroup> + <fillField selector="{{AdminManageSwatchSection.adminInputByIndex('2')}}" + userInput="blue" stepKey="fillAdmin3"/> + + <!-- Mark second option as default --> + <click selector="{{AdminManageSwatchSection.nthIsDefault('2')}}" stepKey="setSecondOptionAsDefault"/> + <!-- Go to Storefront Properties tab --> <scrollToTopOfPage stepKey="scrollToTop"/> <click selector="{{StorefrontPropertiesSection.StoreFrontPropertiesTab}}" stepKey="goToStorefrontPropertiesTab"/> @@ -73,7 +99,14 @@ <!-- Save the new product attribute --> <click selector="{{AttributePropertiesSection.Save}}" stepKey="clickSave2"/> - <waitForElementVisible selector="{{AdminProductMessagesSection.successMessage}}" + <waitForPageLoad stepKey="waitForGridPageLoad"/> + <seeElement selector="{{AdminProductMessagesSection.successMessage}}" stepKey="waitForSuccessMessage"/> + + <actionGroup ref="navigateToCreatedProductAttribute" stepKey="navigateToAttribute"> + <argument name="ProductAttribute" value="visualSwatchAttribute"/> + </actionGroup> + <!-- Check attribute data --> + <seeCheckboxIsChecked selector="{{AdminManageSwatchSection.nthIsDefault('2')}}" stepKey="CheckDefaultOption"/> </test> </tests> \ No newline at end of file diff --git a/app/code/Magento/Swatches/etc/db_schema.xml b/app/code/Magento/Swatches/etc/db_schema.xml index c960f27b0fb54..3dafbc3876494 100644 --- a/app/code/Magento/Swatches/etc/db_schema.xml +++ b/app/code/Magento/Swatches/etc/db_schema.xml @@ -20,20 +20,20 @@ <column xsi:type="smallint" name="type" padding="5" unsigned="true" nullable="false" identity="false" comment="Swatch type: 0 - text, 1 - visual color, 2 - visual image"/> <column xsi:type="varchar" name="value" nullable="true" length="255" comment="Swatch Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="swatch_id"/> </constraint> - <constraint xsi:type="foreign" name="EAV_ATTRIBUTE_OPTION_SWATCH_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="EAV_ATTRIBUTE_OPTION_SWATCH_STORE_ID_STORE_STORE_ID" table="eav_attribute_option_swatch" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="EAV_ATTR_OPT_SWATCH_OPT_ID_EAV_ATTR_OPT_OPT_ID" + <constraint xsi:type="foreign" referenceId="EAV_ATTR_OPT_SWATCH_OPT_ID_EAV_ATTR_OPT_OPT_ID" table="eav_attribute_option_swatch" column="option_id" referenceTable="eav_attribute_option" referenceColumn="option_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="EAV_ATTRIBUTE_OPTION_SWATCH_STORE_ID_OPTION_ID"> + <constraint xsi:type="unique" referenceId="EAV_ATTRIBUTE_OPTION_SWATCH_STORE_ID_OPTION_ID"> <column name="store_id"/> <column name="option_id"/> </constraint> - <index name="EAV_ATTRIBUTE_OPTION_SWATCH_SWATCH_ID" indexType="btree"> + <index referenceId="EAV_ATTRIBUTE_OPTION_SWATCH_SWATCH_ID" indexType="btree"> <column name="swatch_id"/> </index> </table> diff --git a/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js b/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js index 0fc7b2ec48b5e..a7ac45176316c 100644 --- a/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js +++ b/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js @@ -438,25 +438,24 @@ define([ .collapse('hide'); editForm.on('beforeSubmit', function () { - var swatchValues = [], - optionContainer; + var optionContainer, optionsValues; activePanel = swatchTextPanel.hasClass(activePanelClass) ? swatchTextPanel : swatchVisualPanel; optionContainer = activePanel.find('table tbody'); if (activePanel.hasClass(activePanelClass)) { - optionContainer - .find('input') - .each(function () { - swatchValues.push(this.name + '=' + $(this).val()); - }); - + optionsValues = $.map( + optionContainer.find('tr'), + function (row) { + return $(row).find('input, select, textarea').serialize(); + } + ); $('<input>') .attr({ type: 'hidden', name: 'serialized_options' }) - .val(JSON.stringify(swatchValues)) + .val(JSON.stringify(optionsValues)) .prependTo(editForm); } diff --git a/app/code/Magento/Tax/etc/db_schema.xml b/app/code/Magento/Tax/etc/db_schema.xml index 6e83a64791969..f5227a9ef3a66 100644 --- a/app/code/Magento/Tax/etc/db_schema.xml +++ b/app/code/Magento/Tax/etc/db_schema.xml @@ -13,7 +13,7 @@ <column xsi:type="varchar" name="class_name" nullable="false" length="255" comment="Class Name"/> <column xsi:type="varchar" name="class_type" nullable="false" length="8" default="CUSTOMER" comment="Class Type"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="class_id"/> </constraint> </table> @@ -27,14 +27,14 @@ comment="Position"/> <column xsi:type="int" name="calculate_subtotal" padding="11" unsigned="false" nullable="false" identity="false" comment="Calculate off subtotal option"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="tax_calculation_rule_id"/> </constraint> - <index name="TAX_CALCULATION_RULE_PRIORITY_POSITION" indexType="btree"> + <index referenceId="TAX_CALCULATION_RULE_PRIORITY_POSITION" indexType="btree"> <column name="priority"/> <column name="position"/> </index> - <index name="TAX_CALCULATION_RULE_CODE" indexType="btree"> + <index referenceId="TAX_CALCULATION_RULE_CODE" indexType="btree"> <column name="code"/> </index> </table> @@ -54,18 +54,18 @@ comment="Zip From"/> <column xsi:type="int" name="zip_to" padding="10" unsigned="true" nullable="true" identity="false" comment="Zip To"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="tax_calculation_rate_id"/> </constraint> - <index name="TAX_CALCULATION_RATE_TAX_COUNTRY_ID_TAX_REGION_ID_TAX_POSTCODE" indexType="btree"> + <index referenceId="TAX_CALCULATION_RATE_TAX_COUNTRY_ID_TAX_REGION_ID_TAX_POSTCODE" indexType="btree"> <column name="tax_country_id"/> <column name="tax_region_id"/> <column name="tax_postcode"/> </index> - <index name="TAX_CALCULATION_RATE_CODE" indexType="btree"> + <index referenceId="TAX_CALCULATION_RATE_CODE" indexType="btree"> <column name="code"/> </index> - <index name="IDX_CA799F1E2CB843495F601E56C84A626D" indexType="btree"> + <index referenceId="IDX_CA799F1E2CB843495F601E56C84A626D" indexType="btree"> <column name="tax_calculation_rate_id"/> <column name="tax_country_id"/> <column name="tax_region_id"/> @@ -84,31 +84,31 @@ identity="false" comment="Customer Tax Class Id"/> <column xsi:type="smallint" name="product_tax_class_id" padding="6" unsigned="false" nullable="false" identity="false" comment="Product Tax Class Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="tax_calculation_id"/> </constraint> - <constraint xsi:type="foreign" name="TAX_CALCULATION_PRODUCT_TAX_CLASS_ID_TAX_CLASS_CLASS_ID" + <constraint xsi:type="foreign" referenceId="TAX_CALCULATION_PRODUCT_TAX_CLASS_ID_TAX_CLASS_CLASS_ID" table="tax_calculation" column="product_tax_class_id" referenceTable="tax_class" referenceColumn="class_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="TAX_CALCULATION_CUSTOMER_TAX_CLASS_ID_TAX_CLASS_CLASS_ID" + <constraint xsi:type="foreign" referenceId="TAX_CALCULATION_CUSTOMER_TAX_CLASS_ID_TAX_CLASS_CLASS_ID" table="tax_calculation" column="customer_tax_class_id" referenceTable="tax_class" referenceColumn="class_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="TAX_CALC_TAX_CALC_RATE_ID_TAX_CALC_RATE_TAX_CALC_RATE_ID" + <constraint xsi:type="foreign" referenceId="TAX_CALC_TAX_CALC_RATE_ID_TAX_CALC_RATE_TAX_CALC_RATE_ID" table="tax_calculation" column="tax_calculation_rate_id" referenceTable="tax_calculation_rate" referenceColumn="tax_calculation_rate_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="TAX_CALC_TAX_CALC_RULE_ID_TAX_CALC_RULE_TAX_CALC_RULE_ID" + <constraint xsi:type="foreign" referenceId="TAX_CALC_TAX_CALC_RULE_ID_TAX_CALC_RULE_TAX_CALC_RULE_ID" table="tax_calculation" column="tax_calculation_rule_id" referenceTable="tax_calculation_rule" referenceColumn="tax_calculation_rule_id" onDelete="CASCADE"/> - <index name="TAX_CALCULATION_TAX_CALCULATION_RULE_ID" indexType="btree"> + <index referenceId="TAX_CALCULATION_TAX_CALCULATION_RULE_ID" indexType="btree"> <column name="tax_calculation_rule_id"/> </index> - <index name="TAX_CALCULATION_CUSTOMER_TAX_CLASS_ID" indexType="btree"> + <index referenceId="TAX_CALCULATION_CUSTOMER_TAX_CLASS_ID" indexType="btree"> <column name="customer_tax_class_id"/> </index> - <index name="TAX_CALCULATION_PRODUCT_TAX_CLASS_ID" indexType="btree"> + <index referenceId="TAX_CALCULATION_PRODUCT_TAX_CLASS_ID" indexType="btree"> <column name="product_tax_class_id"/> </index> - <index name="TAX_CALC_TAX_CALC_RATE_ID_CSTR_TAX_CLASS_ID_PRD_TAX_CLASS_ID" indexType="btree"> + <index referenceId="TAX_CALC_TAX_CALC_RATE_ID_CSTR_TAX_CLASS_ID_PRD_TAX_CLASS_ID" indexType="btree"> <column name="tax_calculation_rate_id"/> <column name="customer_tax_class_id"/> <column name="product_tax_class_id"/> @@ -122,20 +122,20 @@ <column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Store Id"/> <column xsi:type="varchar" name="value" nullable="false" length="255" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="tax_calculation_rate_title_id"/> </constraint> - <constraint xsi:type="foreign" name="TAX_CALCULATION_RATE_TITLE_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="TAX_CALCULATION_RATE_TITLE_STORE_ID_STORE_STORE_ID" table="tax_calculation_rate_title" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="FK_37FB965F786AD5897BB3AE90470C42AB" table="tax_calculation_rate_title" + <constraint xsi:type="foreign" referenceId="FK_37FB965F786AD5897BB3AE90470C42AB" table="tax_calculation_rate_title" column="tax_calculation_rate_id" referenceTable="tax_calculation_rate" referenceColumn="tax_calculation_rate_id" onDelete="CASCADE"/> - <index name="TAX_CALCULATION_RATE_TITLE_TAX_CALCULATION_RATE_ID_STORE_ID" indexType="btree"> + <index referenceId="TAX_CALCULATION_RATE_TITLE_TAX_CALCULATION_RATE_ID_STORE_ID" indexType="btree"> <column name="tax_calculation_rate_id"/> <column name="store_id"/> </index> - <index name="TAX_CALCULATION_RATE_TITLE_STORE_ID" indexType="btree"> + <index referenceId="TAX_CALCULATION_RATE_TITLE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -151,20 +151,20 @@ default="0" comment="Orders Count"/> <column xsi:type="float" name="tax_base_amount_sum" unsigned="false" nullable="true" comment="Tax Base Amount Sum"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="TAX_ORDER_AGGREGATED_CREATED_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="TAX_ORDER_AGGREGATED_CREATED_STORE_ID_STORE_STORE_ID" table="tax_order_aggregated_created" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="TAX_ORDER_AGGRED_CREATED_PERIOD_STORE_ID_CODE_PERCENT_ORDER_STS"> + <constraint xsi:type="unique" referenceId="TAX_ORDER_AGGRED_CREATED_PERIOD_STORE_ID_CODE_PERCENT_ORDER_STS"> <column name="period"/> <column name="store_id"/> <column name="code"/> <column name="percent"/> <column name="order_status"/> </constraint> - <index name="TAX_ORDER_AGGREGATED_CREATED_STORE_ID" indexType="btree"> + <index referenceId="TAX_ORDER_AGGREGATED_CREATED_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -181,20 +181,20 @@ default="0" comment="Orders Count"/> <column xsi:type="float" name="tax_base_amount_sum" unsigned="false" nullable="true" comment="Tax Base Amount Sum"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="id"/> </constraint> - <constraint xsi:type="foreign" name="TAX_ORDER_AGGREGATED_UPDATED_STORE_ID_STORE_STORE_ID" + <constraint xsi:type="foreign" referenceId="TAX_ORDER_AGGREGATED_UPDATED_STORE_ID_STORE_STORE_ID" table="tax_order_aggregated_updated" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="TAX_ORDER_AGGRED_UPDATED_PERIOD_STORE_ID_CODE_PERCENT_ORDER_STS"> + <constraint xsi:type="unique" referenceId="TAX_ORDER_AGGRED_UPDATED_PERIOD_STORE_ID_CODE_PERCENT_ORDER_STS"> <column name="period"/> <column name="store_id"/> <column name="code"/> <column name="percent"/> <column name="order_status"/> </constraint> - <index name="TAX_ORDER_AGGREGATED_UPDATED_STORE_ID" indexType="btree"> + <index referenceId="TAX_ORDER_AGGREGATED_UPDATED_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> diff --git a/app/code/Magento/Theme/etc/db_schema.xml b/app/code/Magento/Theme/etc/db_schema.xml index ee1185e6e576d..7f3a3fc607947 100644 --- a/app/code/Magento/Theme/etc/db_schema.xml +++ b/app/code/Magento/Theme/etc/db_schema.xml @@ -20,7 +20,7 @@ <column xsi:type="smallint" name="type" padding="6" unsigned="false" nullable="false" identity="false" comment="Theme type: 0:physical, 1:virtual, 2:staging"/> <column xsi:type="text" name="code" nullable="true" comment="Full theme code, including package"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="theme_id"/> </constraint> </table> @@ -35,10 +35,10 @@ <column xsi:type="smallint" name="sort_order" padding="6" unsigned="false" nullable="false" identity="false" default="0" comment="Sort Order"/> <column xsi:type="boolean" name="is_temporary" nullable="false" default="false" comment="Is Temporary File"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="theme_files_id"/> </constraint> - <constraint xsi:type="foreign" name="THEME_FILE_THEME_ID_THEME_THEME_ID" table="theme_file" column="theme_id" + <constraint xsi:type="foreign" referenceId="THEME_FILE_THEME_ID_THEME_THEME_ID" table="theme_file" column="theme_id" referenceTable="theme" referenceColumn="theme_id" onDelete="CASCADE"/> </table> <table name="design_change" resource="default" engine="innodb" comment="Design Changes"> @@ -49,12 +49,12 @@ <column xsi:type="varchar" name="design" nullable="true" length="255" comment="Design"/> <column xsi:type="date" name="date_from" comment="First Date of Design Activity"/> <column xsi:type="date" name="date_to" comment="Last Date of Design Activity"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="design_change_id"/> </constraint> - <constraint xsi:type="foreign" name="DESIGN_CHANGE_STORE_ID_STORE_STORE_ID" table="design_change" + <constraint xsi:type="foreign" referenceId="DESIGN_CHANGE_STORE_ID_STORE_STORE_ID" table="design_change" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <index name="DESIGN_CHANGE_STORE_ID" indexType="btree"> + <index referenceId="DESIGN_CHANGE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> diff --git a/app/code/Magento/Tinymce3/Model/Config/Gallery/Config.php b/app/code/Magento/Tinymce3/Model/Config/Gallery/Config.php new file mode 100644 index 0000000000000..d11a3fa6e8a0c --- /dev/null +++ b/app/code/Magento/Tinymce3/Model/Config/Gallery/Config.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Tinymce3\Model\Config\Gallery; + +/** + * Class Config adds information about required configurations to display media gallery of tinymce3 editor + * + * @deprecated use \Magento\Cms\Model\Wysiwyg\DefaultConfigProvider instead + */ +class Config implements \Magento\Framework\Data\Wysiwyg\ConfigProviderInterface +{ + /** + * @var \Magento\Backend\Model\UrlInterface + */ + private $backendUrl; + + /** + * @param \Magento\Backend\Model\UrlInterface $backendUrl + */ + public function __construct( + \Magento\Backend\Model\UrlInterface $backendUrl + ) { + $this->backendUrl = $backendUrl; + } + + /** + * Returns media gallery config + * + * @param \Magento\Framework\DataObject $config + * @return \Magento\Framework\DataObject + */ + public function getConfig(\Magento\Framework\DataObject $config) : \Magento\Framework\DataObject + { + $config->addData( + [ + 'add_images' => true, + 'files_browser_window_url' => $this->backendUrl->getUrl('cms/wysiwyg_images/index'), + ] + ); + + return $config; + } +} diff --git a/app/code/Magento/Tinymce3/Test/Mftf/Section/AdminTinymce3FileldsSection.xml b/app/code/Magento/Tinymce3/Test/Mftf/Section/AdminTinymce3FileldsSection.xml index 1730996937ca2..76c0a9e1fe797 100644 --- a/app/code/Magento/Tinymce3/Test/Mftf/Section/AdminTinymce3FileldsSection.xml +++ b/app/code/Magento/Tinymce3/Test/Mftf/Section/AdminTinymce3FileldsSection.xml @@ -13,6 +13,7 @@ </section> <section name="TinyMCESection"> <element name="TinyMCE3" type="text" selector="#cms_page_form_content_tbl"/> + <element name="InsertImageBtnTinyMCE3" type="button" selector="#cms_page_form_content_image"/> </section> <section name="NewsletterWYSIWYGSection"> <element name="TinyMCE3" type="text" selector="#cms_page_form_content_tbl"/> diff --git a/app/code/Magento/Tinymce3/composer.json b/app/code/Magento/Tinymce3/composer.json index 946bfe13f3473..52e980052a87f 100644 --- a/app/code/Magento/Tinymce3/composer.json +++ b/app/code/Magento/Tinymce3/composer.json @@ -4,9 +4,11 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", + "magento/module-backend": "*", "magento/module-ui": "*", "magento/module-variable": "*", "magento/module-widget": "*" + }, "suggest": { "magento/module-cms": "*" diff --git a/app/code/Magento/Tinymce3/etc/adminhtml/di.xml b/app/code/Magento/Tinymce3/etc/adminhtml/di.xml index bf1ec7748294e..53ab66c7ef21f 100644 --- a/app/code/Magento/Tinymce3/etc/adminhtml/di.xml +++ b/app/code/Magento/Tinymce3/etc/adminhtml/di.xml @@ -22,7 +22,7 @@ <item name="Magento_Tinymce3/tinymce3Adapter" xsi:type="string">Magento\Tinymce3\Model\Config\Widget\Config</item> </argument> <argument name="galleryConfigProvider" xsi:type="array"> - <item name="Magento_Tinymce3/tinymce3Adapter" xsi:type="string">Magento\Cms\Model\WysiwygDefaultConfig</item> + <item name="Magento_Tinymce3/tinymce3Adapter" xsi:type="string">Magento\Tinymce3\Model\Config\Gallery\Config</item> </argument> </arguments> </type> diff --git a/app/code/Magento/Translation/etc/db_schema.xml b/app/code/Magento/Translation/etc/db_schema.xml index 523ef3a1279d0..a0d08467acf06 100644 --- a/app/code/Magento/Translation/etc/db_schema.xml +++ b/app/code/Magento/Translation/etc/db_schema.xml @@ -18,12 +18,12 @@ <column xsi:type="varchar" name="locale" nullable="false" length="20" default="en_US" comment="Locale"/> <column xsi:type="bigint" name="crc_string" padding="20" unsigned="false" nullable="false" identity="false" default="1591228201" comment="Translation String CRC32 Hash"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="key_id"/> </constraint> - <constraint xsi:type="foreign" name="TRANSLATION_STORE_ID_STORE_STORE_ID" table="translation" column="store_id" + <constraint xsi:type="foreign" referenceId="TRANSLATION_STORE_ID_STORE_STORE_ID" table="translation" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="TRANSLATION_STORE_ID_LOCALE_CRC_STRING_STRING"> + <constraint xsi:type="unique" referenceId="TRANSLATION_STORE_ID_LOCALE_CRC_STRING_STRING"> <column name="store_id"/> <column name="locale"/> <column name="crc_string"/> diff --git a/app/code/Magento/Ui/etc/db_schema.xml b/app/code/Magento/Ui/etc/db_schema.xml index d07329df9eb21..e2a04b0cdc72d 100644 --- a/app/code/Magento/Ui/etc/db_schema.xml +++ b/app/code/Magento/Ui/etc/db_schema.xml @@ -20,12 +20,12 @@ <column xsi:type="longtext" name="config" nullable="true" comment="Bookmark config"/> <column xsi:type="datetime" name="created_at" on_update="false" nullable="false" comment="Bookmark created at"/> <column xsi:type="datetime" name="updated_at" on_update="false" nullable="false" comment="Bookmark updated at"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="bookmark_id"/> </constraint> - <constraint xsi:type="foreign" name="UI_BOOKMARK_USER_ID_ADMIN_USER_USER_ID" table="ui_bookmark" + <constraint xsi:type="foreign" referenceId="UI_BOOKMARK_USER_ID_ADMIN_USER_USER_ID" table="ui_bookmark" column="user_id" referenceTable="admin_user" referenceColumn="user_id" onDelete="CASCADE"/> - <index name="UI_BOOKMARK_USER_ID_NAMESPACE_IDENTIFIER" indexType="btree"> + <index referenceId="UI_BOOKMARK_USER_ID_NAMESPACE_IDENTIFIER" indexType="btree"> <column name="user_id"/> <column name="namespace"/> <column name="identifier"/> diff --git a/app/code/Magento/UrlRewrite/Model/Exception/UrlAlreadyExistsException.php b/app/code/Magento/UrlRewrite/Model/Exception/UrlAlreadyExistsException.php index c7e83819f2569..c7071076bd55a 100644 --- a/app/code/Magento/UrlRewrite/Model/Exception/UrlAlreadyExistsException.php +++ b/app/code/Magento/UrlRewrite/Model/Exception/UrlAlreadyExistsException.php @@ -8,10 +8,12 @@ use Magento\Framework\Phrase; /** + * Specific exception for URL key already exists + * * @api * @since 100.2.0 */ -class UrlAlreadyExistsException extends \Magento\Framework\Exception\LocalizedException +class UrlAlreadyExistsException extends \Magento\Framework\Exception\AlreadyExistsException { /** * @var array @@ -34,6 +36,8 @@ public function __construct(Phrase $phrase = null, \Exception $cause = null, $co } /** + * Get URLs + * * @return array * @since 100.2.0 */ diff --git a/app/code/Magento/UrlRewrite/etc/db_schema.xml b/app/code/Magento/UrlRewrite/etc/db_schema.xml index af328873deee7..6e0014873202d 100644 --- a/app/code/Magento/UrlRewrite/etc/db_schema.xml +++ b/app/code/Magento/UrlRewrite/etc/db_schema.xml @@ -23,17 +23,17 @@ <column xsi:type="smallint" name="is_autogenerated" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Is rewrite generated automatically flag"/> <column xsi:type="varchar" name="metadata" nullable="true" length="255" comment="Meta data for url rewrite"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="url_rewrite_id"/> </constraint> - <constraint xsi:type="unique" name="URL_REWRITE_REQUEST_PATH_STORE_ID"> + <constraint xsi:type="unique" referenceId="URL_REWRITE_REQUEST_PATH_STORE_ID"> <column name="request_path"/> <column name="store_id"/> </constraint> - <index name="URL_REWRITE_TARGET_PATH" indexType="btree"> + <index referenceId="URL_REWRITE_TARGET_PATH" indexType="btree"> <column name="target_path"/> </index> - <index name="URL_REWRITE_STORE_ID_ENTITY_ID" indexType="btree"> + <index referenceId="URL_REWRITE_STORE_ID_ENTITY_ID" indexType="btree"> <column name="store_id"/> <column name="entity_id"/> </index> diff --git a/app/code/Magento/User/etc/db_schema.xml b/app/code/Magento/User/etc/db_schema.xml index df9b39a27883d..c3356a96b94a7 100644 --- a/app/code/Magento/User/etc/db_schema.xml +++ b/app/code/Magento/User/etc/db_schema.xml @@ -37,10 +37,10 @@ <column xsi:type="timestamp" name="first_failure" on_update="false" nullable="true" comment="First Failure"/> <column xsi:type="timestamp" name="lock_expires" on_update="false" nullable="true" comment="Expiration Lock Dates"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="user_id"/> </constraint> - <constraint xsi:type="unique" name="ADMIN_USER_USERNAME"> + <constraint xsi:type="unique" referenceId="ADMIN_USER_USERNAME"> <column name="username"/> </constraint> </table> @@ -54,12 +54,12 @@ comment="Deprecated"/> <column xsi:type="int" name="last_updated" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Last Updated"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="password_id"/> </constraint> - <constraint xsi:type="foreign" name="ADMIN_PASSWORDS_USER_ID_ADMIN_USER_USER_ID" table="admin_passwords" + <constraint xsi:type="foreign" referenceId="ADMIN_PASSWORDS_USER_ID_ADMIN_USER_USER_ID" table="admin_passwords" column="user_id" referenceTable="admin_user" referenceColumn="user_id" onDelete="CASCADE"/> - <index name="ADMIN_PASSWORDS_USER_ID" indexType="btree"> + <index referenceId="ADMIN_PASSWORDS_USER_ID" indexType="btree"> <column name="user_id"/> </index> </table> diff --git a/app/code/Magento/Variable/etc/db_schema.xml b/app/code/Magento/Variable/etc/db_schema.xml index d89bdb7e710b7..239e3b49983c1 100644 --- a/app/code/Magento/Variable/etc/db_schema.xml +++ b/app/code/Magento/Variable/etc/db_schema.xml @@ -12,10 +12,10 @@ comment="Variable Id"/> <column xsi:type="varchar" name="code" nullable="true" length="255" comment="Variable Code"/> <column xsi:type="varchar" name="name" nullable="true" length="255" comment="Variable Name"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="variable_id"/> </constraint> - <constraint xsi:type="unique" name="VARIABLE_CODE"> + <constraint xsi:type="unique" referenceId="VARIABLE_CODE"> <column name="code"/> </constraint> </table> @@ -28,18 +28,18 @@ default="0" comment="Store Id"/> <column xsi:type="text" name="plain_value" nullable="true" comment="Plain Text Value"/> <column xsi:type="text" name="html_value" nullable="true" comment="Html Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="unique" name="VARIABLE_VALUE_VARIABLE_ID_STORE_ID"> + <constraint xsi:type="unique" referenceId="VARIABLE_VALUE_VARIABLE_ID_STORE_ID"> <column name="variable_id"/> <column name="store_id"/> </constraint> - <constraint xsi:type="foreign" name="VARIABLE_VALUE_STORE_ID_STORE_STORE_ID" table="variable_value" + <constraint xsi:type="foreign" referenceId="VARIABLE_VALUE_STORE_ID_STORE_STORE_ID" table="variable_value" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="VARIABLE_VALUE_VARIABLE_ID_VARIABLE_VARIABLE_ID" table="variable_value" + <constraint xsi:type="foreign" referenceId="VARIABLE_VALUE_VARIABLE_ID_VARIABLE_VARIABLE_ID" table="variable_value" column="variable_id" referenceTable="variable" referenceColumn="variable_id" onDelete="CASCADE"/> - <index name="VARIABLE_VALUE_STORE_ID" indexType="btree"> + <index referenceId="VARIABLE_VALUE_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> diff --git a/app/code/Magento/Vault/etc/db_schema.xml b/app/code/Magento/Vault/etc/db_schema.xml index e9645e211ae9b..8a7c8dc4aa9fb 100644 --- a/app/code/Magento/Vault/etc/db_schema.xml +++ b/app/code/Magento/Vault/etc/db_schema.xml @@ -24,18 +24,18 @@ <column xsi:type="text" name="details" nullable="true" comment="Details"/> <column xsi:type="boolean" name="is_active" nullable="false" default="true"/> <column xsi:type="boolean" name="is_visible" nullable="false" default="true"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="VAULT_PAYMENT_TOKEN_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="VAULT_PAYMENT_TOKEN_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="vault_payment_token" column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="VAULT_PAYMENT_TOKEN_PAYMENT_METHOD_CODE_CSTR_ID_GATEWAY_TOKEN"> + <constraint xsi:type="unique" referenceId="VAULT_PAYMENT_TOKEN_PAYMENT_METHOD_CODE_CSTR_ID_GATEWAY_TOKEN"> <column name="payment_method_code"/> <column name="customer_id"/> <column name="gateway_token"/> </constraint> - <constraint xsi:type="unique" name="VAULT_PAYMENT_TOKEN_PUBLIC_HASH"> + <constraint xsi:type="unique" referenceId="VAULT_PAYMENT_TOKEN_PUBLIC_HASH"> <column name="public_hash"/> </constraint> </table> @@ -45,14 +45,14 @@ comment="Order payment Id"/> <column xsi:type="int" name="payment_token_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Payment token Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="order_payment_id"/> <column name="payment_token_id"/> </constraint> - <constraint xsi:type="foreign" name="FK_CF37B9D854256534BE23C818F6291CA2" + <constraint xsi:type="foreign" referenceId="FK_CF37B9D854256534BE23C818F6291CA2" table="vault_payment_token_order_payment_link" column="order_payment_id" referenceTable="sales_order_payment" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="FK_4ED894655446D385894580BECA993862" + <constraint xsi:type="foreign" referenceId="FK_4ED894655446D385894580BECA993862" table="vault_payment_token_order_payment_link" column="payment_token_id" referenceTable="vault_payment_token" referenceColumn="entity_id" onDelete="CASCADE"/> </table> diff --git a/app/code/Magento/Weee/etc/db_schema.xml b/app/code/Magento/Weee/etc/db_schema.xml index 49b201acb3375..1b07168247011 100644 --- a/app/code/Magento/Weee/etc/db_schema.xml +++ b/app/code/Magento/Weee/etc/db_schema.xml @@ -21,30 +21,30 @@ comment="State"/> <column xsi:type="smallint" name="attribute_id" padding="5" unsigned="true" nullable="false" identity="false" comment="Attribute Id"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="value_id"/> </constraint> - <constraint xsi:type="foreign" name="WEEE_TAX_COUNTRY_DIRECTORY_COUNTRY_COUNTRY_ID" table="weee_tax" + <constraint xsi:type="foreign" referenceId="WEEE_TAX_COUNTRY_DIRECTORY_COUNTRY_COUNTRY_ID" table="weee_tax" column="country" referenceTable="directory_country" referenceColumn="country_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="WEEE_TAX_ENTITY_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID" table="weee_tax" + <constraint xsi:type="foreign" referenceId="WEEE_TAX_ENTITY_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID" table="weee_tax" column="entity_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="WEEE_TAX_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" table="weee_tax" + <constraint xsi:type="foreign" referenceId="WEEE_TAX_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID" table="weee_tax" column="website_id" referenceTable="store_website" referenceColumn="website_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="WEEE_TAX_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" table="weee_tax" + <constraint xsi:type="foreign" referenceId="WEEE_TAX_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID" table="weee_tax" column="attribute_id" referenceTable="eav_attribute" referenceColumn="attribute_id" onDelete="CASCADE"/> - <index name="WEEE_TAX_WEBSITE_ID" indexType="btree"> + <index referenceId="WEEE_TAX_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> - <index name="WEEE_TAX_ENTITY_ID" indexType="btree"> + <index referenceId="WEEE_TAX_ENTITY_ID" indexType="btree"> <column name="entity_id"/> </index> - <index name="WEEE_TAX_COUNTRY" indexType="btree"> + <index referenceId="WEEE_TAX_COUNTRY" indexType="btree"> <column name="country"/> </index> - <index name="WEEE_TAX_ATTRIBUTE_ID" indexType="btree"> + <index referenceId="WEEE_TAX_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> </table> diff --git a/app/code/Magento/Widget/etc/db_schema.xml b/app/code/Magento/Widget/etc/db_schema.xml index 149bb27fcdb2a..a82e6aae20296 100644 --- a/app/code/Magento/Widget/etc/db_schema.xml +++ b/app/code/Magento/Widget/etc/db_schema.xml @@ -14,10 +14,10 @@ comment="Widget code for template directive"/> <column xsi:type="varchar" name="widget_type" nullable="true" length="255" comment="Widget Type"/> <column xsi:type="text" name="parameters" nullable="true" comment="Parameters"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="widget_id"/> </constraint> - <index name="WIDGET_WIDGET_CODE" indexType="btree"> + <index referenceId="WIDGET_WIDGET_CODE" indexType="btree"> <column name="widget_code"/> </index> </table> @@ -32,10 +32,10 @@ <column xsi:type="text" name="widget_parameters" nullable="true" comment="Widget parameters"/> <column xsi:type="smallint" name="sort_order" padding="5" unsigned="true" nullable="false" identity="false" default="0" comment="Sort order"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="instance_id"/> </constraint> - <constraint xsi:type="foreign" name="WIDGET_INSTANCE_THEME_ID_THEME_THEME_ID" table="widget_instance" + <constraint xsi:type="foreign" referenceId="WIDGET_INSTANCE_THEME_ID_THEME_THEME_ID" table="widget_instance" column="theme_id" referenceTable="theme" referenceColumn="theme_id" onDelete="CASCADE"/> </table> <table name="widget_instance_page" resource="default" engine="innodb" comment="Instance of Widget on Page"> @@ -49,13 +49,13 @@ <column xsi:type="varchar" name="page_for" nullable="true" length="25" comment="For instance entities"/> <column xsi:type="text" name="entities" nullable="true" comment="Catalog entities (comma separated)"/> <column xsi:type="varchar" name="page_template" nullable="true" length="255" comment="Path to widget template"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="page_id"/> </constraint> - <constraint xsi:type="foreign" name="WIDGET_INSTANCE_PAGE_INSTANCE_ID_WIDGET_INSTANCE_INSTANCE_ID" + <constraint xsi:type="foreign" referenceId="WIDGET_INSTANCE_PAGE_INSTANCE_ID_WIDGET_INSTANCE_INSTANCE_ID" table="widget_instance_page" column="instance_id" referenceTable="widget_instance" referenceColumn="instance_id" onDelete="CASCADE"/> - <index name="WIDGET_INSTANCE_PAGE_INSTANCE_ID" indexType="btree"> + <index referenceId="WIDGET_INSTANCE_PAGE_INSTANCE_ID" indexType="btree"> <column name="instance_id"/> </index> </table> @@ -64,17 +64,17 @@ comment="Page Id"/> <column xsi:type="int" name="layout_update_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Layout Update Id"/> - <constraint xsi:type="foreign" name="WIDGET_INSTANCE_PAGE_LAYOUT_PAGE_ID_WIDGET_INSTANCE_PAGE_PAGE_ID" + <constraint xsi:type="foreign" referenceId="WIDGET_INSTANCE_PAGE_LAYOUT_PAGE_ID_WIDGET_INSTANCE_PAGE_PAGE_ID" table="widget_instance_page_layout" column="page_id" referenceTable="widget_instance_page" referenceColumn="page_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="WIDGET_INSTANCE_PAGE_LYT_LYT_UPDATE_ID_LYT_UPDATE_LYT_UPDATE_ID" + <constraint xsi:type="foreign" referenceId="WIDGET_INSTANCE_PAGE_LYT_LYT_UPDATE_ID_LYT_UPDATE_LYT_UPDATE_ID" table="widget_instance_page_layout" column="layout_update_id" referenceTable="layout_update" referenceColumn="layout_update_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="WIDGET_INSTANCE_PAGE_LAYOUT_LAYOUT_UPDATE_ID_PAGE_ID"> + <constraint xsi:type="unique" referenceId="WIDGET_INSTANCE_PAGE_LAYOUT_LAYOUT_UPDATE_ID_PAGE_ID"> <column name="layout_update_id"/> <column name="page_id"/> </constraint> - <index name="WIDGET_INSTANCE_PAGE_LAYOUT_PAGE_ID" indexType="btree"> + <index referenceId="WIDGET_INSTANCE_PAGE_LAYOUT_PAGE_ID" indexType="btree"> <column name="page_id"/> </index> </table> @@ -87,10 +87,10 @@ default="0" comment="Sort Order"/> <column xsi:type="timestamp" name="updated_at" on_update="true" nullable="true" default="0" comment="Last Update Timestamp"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="layout_update_id"/> </constraint> - <index name="LAYOUT_UPDATE_HANDLE" indexType="btree"> + <index referenceId="LAYOUT_UPDATE_HANDLE" indexType="btree"> <column name="handle"/> </index> </table> @@ -105,20 +105,20 @@ default="0" comment="Layout Update Id"/> <column xsi:type="boolean" name="is_temporary" nullable="false" default="false" comment="Defines whether Layout Update is Temporary"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="layout_link_id"/> </constraint> - <constraint xsi:type="foreign" name="LAYOUT_LINK_LAYOUT_UPDATE_ID_LAYOUT_UPDATE_LAYOUT_UPDATE_ID" + <constraint xsi:type="foreign" referenceId="LAYOUT_LINK_LAYOUT_UPDATE_ID_LAYOUT_UPDATE_LAYOUT_UPDATE_ID" table="layout_link" column="layout_update_id" referenceTable="layout_update" referenceColumn="layout_update_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="LAYOUT_LINK_STORE_ID_STORE_STORE_ID" table="layout_link" column="store_id" + <constraint xsi:type="foreign" referenceId="LAYOUT_LINK_STORE_ID_STORE_STORE_ID" table="layout_link" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="LAYOUT_LINK_THEME_ID_THEME_THEME_ID" table="layout_link" column="theme_id" + <constraint xsi:type="foreign" referenceId="LAYOUT_LINK_THEME_ID_THEME_THEME_ID" table="layout_link" column="theme_id" referenceTable="theme" referenceColumn="theme_id" onDelete="CASCADE"/> - <index name="LAYOUT_LINK_LAYOUT_UPDATE_ID" indexType="btree"> + <index referenceId="LAYOUT_LINK_LAYOUT_UPDATE_ID" indexType="btree"> <column name="layout_update_id"/> </index> - <index name="LAYOUT_LINK_STORE_ID_THEME_ID_LAYOUT_UPDATE_ID_IS_TEMPORARY" indexType="btree"> + <index referenceId="LAYOUT_LINK_STORE_ID_THEME_ID_LAYOUT_UPDATE_ID_IS_TEMPORARY" indexType="btree"> <column name="store_id"/> <column name="theme_id"/> <column name="layout_update_id"/> diff --git a/app/code/Magento/Wishlist/Controller/Index/DownloadCustomOption.php b/app/code/Magento/Wishlist/Controller/Index/DownloadCustomOption.php index e43a03e72d87c..b87afa8e5d0c4 100644 --- a/app/code/Magento/Wishlist/Controller/Index/DownloadCustomOption.php +++ b/app/code/Magento/Wishlist/Controller/Index/DownloadCustomOption.php @@ -6,12 +6,16 @@ namespace Magento\Wishlist\Controller\Index; use Magento\Framework\App\Action; +use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\ObjectManager; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Serialize\Serializer\Json; -class DownloadCustomOption extends \Magento\Wishlist\Controller\AbstractIndex +/** + * Class DownloadCustomOption. Represents request-flow logic for option's file download + */ +class DownloadCustomOption extends \Magento\Wishlist\Controller\AbstractIndex implements HttpGetActionInterface { /** * @var \Magento\Framework\App\Response\Http\FileFactory @@ -26,6 +30,8 @@ class DownloadCustomOption extends \Magento\Wishlist\Controller\AbstractIndex private $json; /** + * Constructor method + * * @param Action\Context $context * @param \Magento\Framework\App\Response\Http\FileFactory $fileResponseFactory * @param Json|null $json @@ -92,7 +98,8 @@ public function execute() $this->_fileResponseFactory->create( $info['title'], ['value' => $info['quote_path'], 'type' => 'filename'], - DirectoryList::ROOT + DirectoryList::ROOT, + $info['type'] ); } } catch (\Exception $e) { diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/DownloadCustomOptionTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/DownloadCustomOptionTest.php deleted file mode 100644 index 6fefe18cf8975..0000000000000 --- a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/DownloadCustomOptionTest.php +++ /dev/null @@ -1,154 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Wishlist\Test\Unit\Controller\Index; - -class DownloadCustomOptionTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var \Magento\Wishlist\Controller\Index\DownloadCustomOption - */ - protected $model; - - /** - * @var \Magento\Framework\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject - */ - protected $contextMock; - - /** - * @var \Magento\Framework\App\Response\Http\FileFactory|\PHPUnit_Framework_MockObject_MockObject - */ - protected $fileResponseFactoryMock; - - /** - * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $requestMock; - - /** - * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $objectManagerMock; - - /** - * @var \Magento\Framework\Controller\ResultFactory|\PHPUnit_Framework_MockObject_MockObject - */ - protected $resultFactoryMock; - - /** - * @var \Magento\Framework\Serialize\Serializer\Json|\PHPUnit_Framework_MockObject_MockObject - */ - protected $jsonMock; - - protected function setUp() - { - $this->fileResponseFactoryMock = $this->getMockBuilder(\Magento\Framework\App\Response\Http\FileFactory::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->jsonMock = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) - ->disableOriginalConstructor() - ->setMethods(['create', 'get', 'configure']) - ->getMock(); - - $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->resultFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->contextMock = $this->getMockBuilder(\Magento\Framework\App\Action\Context::class) - ->disableOriginalConstructor() - ->getMock(); - $this->contextMock->expects($this->any()) - ->method('getObjectManager') - ->willReturn($this->objectManagerMock); - $this->contextMock->expects($this->any()) - ->method('getRequest') - ->willReturn($this->requestMock); - $this->contextMock->expects($this->any()) - ->method('getResultFactory') - ->willReturn($this->resultFactoryMock); - - $this->model = new \Magento\Wishlist\Controller\Index\DownloadCustomOption( - $this->contextMock, - $this->fileResponseFactoryMock, - $this->jsonMock - ); - } - - public function testExecute() - { - $data = [ - 'number' => 42, - 'string' => 'string_value', - 'boolean' => true, - 'collection' => [1, 2, 3], - 'secret_key' => 999 - ]; - $serialized_data = json_encode($data); - - $optionMock = $this->getMockBuilder(\Magento\Wishlist\Model\Item\Option::class) - ->disableOriginalConstructor() - ->setMethods(['getProductId', 'load', 'getId', 'getValue']) - ->getMock(); - $optionMock->expects($this->any()) - ->method('load') - ->willReturnSelf(); - $optionMock->expects($this->any()) - ->method('getId') - ->willReturn(true); - $optionMock->expects($this->any()) - ->method('getProductId') - ->willReturn('some_value'); - $optionMock->expects($this->any()) - ->method('getValue') - ->willReturn($serialized_data); - - $productOptionMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option::class) - ->disableOriginalConstructor() - ->setMethods(['getProductId', 'load', 'getId', 'getType']) - ->getMock(); - $productOptionMock->expects($this->any()) - ->method('load') - ->willReturnSelf(); - $productOptionMock->expects($this->any()) - ->method('getId') - ->willReturn(true); - $productOptionMock->expects($this->any()) - ->method('getProductId') - ->willReturn('some_value'); - $productOptionMock->expects($this->any()) - ->method('getType') - ->willReturn('file'); - - $this->objectManagerMock->expects($this->any()) - ->method('create') - ->willReturnMap( - [ - [\Magento\Wishlist\Model\Item\Option::class, [], $optionMock], - [\Magento\Catalog\Model\Product\Option::class, [], $productOptionMock] - ] - ); - - $this->requestMock->expects($this->any()) - ->method('getParam') - ->willReturn(1); - - $this->jsonMock->expects($this->once()) - ->method('unserialize') - ->willReturnCallback(function ($value) { - return json_decode($value, true); - }); - - $this->assertEquals(null, $this->model->execute()); - } -} diff --git a/app/code/Magento/Wishlist/etc/db_schema.xml b/app/code/Magento/Wishlist/etc/db_schema.xml index 73fcb7ce0cab4..8a02f411ad0db 100644 --- a/app/code/Magento/Wishlist/etc/db_schema.xml +++ b/app/code/Magento/Wishlist/etc/db_schema.xml @@ -16,16 +16,16 @@ default="0" comment="Sharing flag (0 or 1)"/> <column xsi:type="varchar" name="sharing_code" nullable="true" length="32" comment="Sharing encrypted code"/> <column xsi:type="timestamp" name="updated_at" on_update="false" nullable="true" comment="Last updated date"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="wishlist_id"/> </constraint> - <constraint xsi:type="foreign" name="WISHLIST_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="wishlist" + <constraint xsi:type="foreign" referenceId="WISHLIST_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID" table="wishlist" column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="unique" name="WISHLIST_CUSTOMER_ID"> + <constraint xsi:type="unique" referenceId="WISHLIST_CUSTOMER_ID"> <column name="customer_id"/> </constraint> - <index name="WISHLIST_SHARED" indexType="btree"> + <index referenceId="WISHLIST_SHARED" indexType="btree"> <column name="shared"/> </index> </table> @@ -42,23 +42,23 @@ <column xsi:type="text" name="description" nullable="true" comment="Short description of wish list item"/> <column xsi:type="decimal" name="qty" scale="4" precision="12" unsigned="false" nullable="false" comment="Qty"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="wishlist_item_id"/> </constraint> - <constraint xsi:type="foreign" name="WISHLIST_ITEM_WISHLIST_ID_WISHLIST_WISHLIST_ID" table="wishlist_item" + <constraint xsi:type="foreign" referenceId="WISHLIST_ITEM_WISHLIST_ID_WISHLIST_WISHLIST_ID" table="wishlist_item" column="wishlist_id" referenceTable="wishlist" referenceColumn="wishlist_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="WISHLIST_ITEM_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID" + <constraint xsi:type="foreign" referenceId="WISHLIST_ITEM_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID" table="wishlist_item" column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="WISHLIST_ITEM_STORE_ID_STORE_STORE_ID" table="wishlist_item" + <constraint xsi:type="foreign" referenceId="WISHLIST_ITEM_STORE_ID_STORE_STORE_ID" table="wishlist_item" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="SET NULL"/> - <index name="WISHLIST_ITEM_WISHLIST_ID" indexType="btree"> + <index referenceId="WISHLIST_ITEM_WISHLIST_ID" indexType="btree"> <column name="wishlist_id"/> </index> - <index name="WISHLIST_ITEM_PRODUCT_ID" indexType="btree"> + <index referenceId="WISHLIST_ITEM_PRODUCT_ID" indexType="btree"> <column name="product_id"/> </index> - <index name="WISHLIST_ITEM_STORE_ID" indexType="btree"> + <index referenceId="WISHLIST_ITEM_STORE_ID" indexType="btree"> <column name="store_id"/> </index> </table> @@ -71,10 +71,10 @@ comment="Product Id"/> <column xsi:type="varchar" name="code" nullable="false" length="255" comment="Code"/> <column xsi:type="text" name="value" nullable="true" comment="Value"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="option_id"/> </constraint> - <constraint xsi:type="foreign" name="FK_A014B30B04B72DD0EAB3EECD779728D6" table="wishlist_item_option" + <constraint xsi:type="foreign" referenceId="FK_A014B30B04B72DD0EAB3EECD779728D6" table="wishlist_item_option" column="wishlist_item_id" referenceTable="wishlist_item" referenceColumn="wishlist_item_id" onDelete="CASCADE"/> </table> diff --git a/app/design/frontend/Magento/blank/Magento_Swatches/web/css/source/_module.less b/app/design/frontend/Magento/blank/Magento_Swatches/web/css/source/_module.less index 6dc25501c92db..f42efa3569598 100644 --- a/app/design/frontend/Magento/blank/Magento_Swatches/web/css/source/_module.less +++ b/app/design/frontend/Magento/blank/Magento_Swatches/web/css/source/_module.less @@ -26,7 +26,7 @@ @swatch-option-text__background: @swatch-option__background; @swatch-option-text__color: #686868; -@swatch-option-text__selected__background-color: @color-white !important; +@swatch-option-text__selected__background-color: @color-white; // Size and Manufacturer attributes @attr-swatch-option__background: @swatch-option__background; @@ -143,7 +143,7 @@ margin-right: 7px; &.selected { - .lib-css(background-color, @swatch-option-text__selected__background-color); + .lib-css(background-color, @swatch-option-text__selected__background-color) !important; } } diff --git a/app/etc/db_schema.xml b/app/etc/db_schema.xml index be13c28ee029b..d7af9091b238d 100644 --- a/app/etc/db_schema.xml +++ b/app/etc/db_schema.xml @@ -10,7 +10,7 @@ <table name="patch_list" resource="default" comment="List of data/schema patches"> <column xsi:type="int" name="patch_id" identity="true" comment="Patch Auto Increment" /> <column xsi:type="varchar" name="patch_name" length="1024" nullable="false" comment="Patch Class Name" /> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="patch_id" /> </constraint> </table> diff --git a/app/etc/di.xml b/app/etc/di.xml index db979f9b76382..b374645240ff7 100755 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -1484,6 +1484,27 @@ </argument> </arguments> </type> + <virtualType name="Magento\Framework\Setup\Declaration\Schema\Config\SchemaLocator" type="Magento\Framework\Config\SchemaLocator"> + <arguments> + <argument name="realPath" xsi:type="string">urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd</argument> + </arguments> + </virtualType> + <virtualType name="Magento\Framework\Setup\Declaration\Schema\FileSystem\XmlReader" type="Magento\Framework\Config\Reader\Filesystem"> + <arguments> + <argument name="fileResolver" xsi:type="object">Magento\Framework\Config\FileResolverByModule</argument> + <argument name="converter" xsi:type="object">Magento\Framework\Setup\Declaration\Schema\Config\Converter</argument> + <argument name="schemaLocator" xsi:type="object">Magento\Framework\Setup\Declaration\Schema\Config\SchemaLocator</argument> + <argument name="fileName" xsi:type="string">db_schema.xml</argument> + <argument name="idAttributes" xsi:type="array"> + <item name="/schema/table" xsi:type="string">name</item> + <item name="/schema/table/column" xsi:type="string">name</item> + <item name="/schema/table/constraint" xsi:type="string">referenceId</item> + <item name="/schema/table/index" xsi:type="string">referenceId</item> + <item name="/schema/table/index/column" xsi:type="string">name</item> + <item name="/schema/table/constraint/column" xsi:type="string">name</item> + </argument> + </arguments> + </virtualType> <type name="Magento\Framework\Setup\Declaration\Schema\OperationsExecutor"> <arguments> <argument name="operations" xsi:type="array"> diff --git a/dev/tests/api-functional/_files/Magento/TestModuleDefaultHydrator/etc/db_schema.xml b/dev/tests/api-functional/_files/Magento/TestModuleDefaultHydrator/etc/db_schema.xml index d9bba3ca5dbe8..3c71e2fde48fa 100644 --- a/dev/tests/api-functional/_files/Magento/TestModuleDefaultHydrator/etc/db_schema.xml +++ b/dev/tests/api-functional/_files/Magento/TestModuleDefaultHydrator/etc/db_schema.xml @@ -11,10 +11,10 @@ <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="true"/> <column xsi:type="int" name="customer_id" padding="10" unsigned="true" nullable="false" identity="false"/> <column xsi:type="varchar" name="value" nullable="true" length="255"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="entity_id"/> </constraint> - <constraint xsi:type="foreign" name="CSTR_EXTENSION_ATTR_ENTT_CSTR_ID_CSTR_ENTT_ENTT_ID" + <constraint xsi:type="foreign" referenceId="CSTR_EXTENSION_ATTR_ENTT_CSTR_ID_CSTR_ENTT_ENTT_ID" table="testmodule_default_hydrator_extension_attribute_entity" column="customer_id" referenceTable="customer_entity" referenceColumn="entity_id" onDelete="CASCADE"/> </table> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php index 57d775cdeb736..3d644a2a32274 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php @@ -91,15 +91,18 @@ public function persist(FixtureInterface $fixture = null) $data['frontend_label'] = [0 => $data['frontend_label']]; if (isset($data['options'])) { + $optionsData = []; foreach ($data['options'] as $key => $values) { + $optionRowData = []; $index = 'option_' . $key; if ($values['is_default'] == 'Yes') { - $data['default'][] = $index; + $optionRowData['default'][] = $index; } - $data['option']['value'][$index] = [$values['admin'], $values['view']]; - $data['option']['order'][$index] = $key; + $optionRowData['option']['value'][$index] = [$values['admin'], $values['view']]; + $optionRowData['option']['order'][$index] = $key; + $optionsData[] = $optionRowData; } - unset($data['options']); + $data['options'] = $optionsData; } $data = $this->changeStructureOfTheData($data); @@ -139,12 +142,16 @@ public function persist(FixtureInterface $fixture = null) * @param array $data * @return array */ - protected function changeStructureOfTheData(array $data) + protected function changeStructureOfTheData(array $data): array { - $serializedOptions = $this->getSerializeOptions($data, ['option']); + if (!isset($data['options'])) { + return $data; + } + + $serializedOptions = $this->getSerializeOptions($data['options']); if ($serializedOptions) { $data['serialized_options'] = $serializedOptions; - unset($data['option']); + unset($data['options']); } return $data; @@ -154,52 +161,15 @@ protected function changeStructureOfTheData(array $data) * Provides serialized product attribute options. * * @param array $data - * @param array $optionKeys - * @return array + * @return string */ - protected function getSerializeOptions(array $data, array $optionKeys): string + protected function getSerializeOptions(array $data): string { $options = []; - foreach ($optionKeys as $optionKey) { - if (!empty($data[$optionKey])) { - $options = array_merge( - $options, - $this->getEncodedOptions([$optionKey => $data[$optionKey]]) - ); - } + foreach ($data as $optionRowData) { + $options[] = http_build_query($optionRowData); } return json_encode($options); } - - /** - * Provides encoded attribute values. - * - * @param array $data - * @return array - */ - private function getEncodedOptions(array $data): array - { - $optionsData = []; - $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($data)); - foreach ($iterator as $value) { - $depth = $iterator->getDepth(); - $option = ''; - - $level = 0; - $option .= $iterator->getSubIterator($level)->key(); - $level++; - - while ($level <= $depth) { - $option .= '[' . $iterator->getSubIterator($level)->key() . ']'; - $level++; - } - - $option .= '=' . $value; - - $optionsData[] = $option; - } - - return $optionsData; - } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.xml index 460cc29b183e0..8fbb64f4579b1 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.xml @@ -33,6 +33,7 @@ <constraint name="Magento\Catalog\Test\Constraint\AssertProductInGrid" /> </variation> <variation name="ProductTypeSwitchingOnCreationTestVariation4"> + <data name="issue" xsi:type="string">MSI-1624</data> <data name="createProduct" xsi:type="string">configurable</data> <data name="product" xsi:type="string">catalogProductVirtual::required_fields</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutOfflinePaymentMethodsTest.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutOfflinePaymentMethodsTest.xml index 2cb0e2874040b..7c12b546d1359 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutOfflinePaymentMethodsTest.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutOfflinePaymentMethodsTest.xml @@ -105,6 +105,7 @@ <data name="issue" xsi:type="string">MAGETWO-66737: Magento\Checkout\Test\TestCase\OnePageCheckoutTest with OnePageCheckoutTestVariation3 and 4 is not stable</data> </variation> <variation name="OnePageCheckoutTestVariation4" summary="One Page Checkout Products with Special Prices" ticketId="MAGETWO-12429"> + <data name="issue" xsi:type="string">MAGETWO-95659: Fix and Unskip MTF OnePageCheckoutOfflinePaymentMethodsTest</data> <data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test, severity:S0</data> <data name="products/0" xsi:type="string">catalogProductSimple::product_with_special_price</data> <data name="products/1" xsi:type="string">configurableProduct::product_with_special_price</data> diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/Handler/SwatchProductAttribute/Curl.php b/dev/tests/functional/tests/app/Magento/Swatches/Test/Handler/SwatchProductAttribute/Curl.php index 5e4a5cc45fe69..f4adb9dec1250 100644 --- a/dev/tests/functional/tests/app/Magento/Swatches/Test/Handler/SwatchProductAttribute/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/Handler/SwatchProductAttribute/Curl.php @@ -29,23 +29,32 @@ public function __construct(DataInterface $configuration, EventManagerInterface ]; } + /** + * @inheritdoc + */ + protected function changeStructureOfTheData(array $data): array + { + return parent::changeStructureOfTheData($data); + } + /** * Re-map options from default options structure to swatches structure, * as swatches was initially created with name convention differ from other attributes. * - * @param array $data - * @return array + * @inheritdoc */ - protected function changeStructureOfTheData(array $data) + protected function getSerializeOptions(array $data): string { - $data['optiontext'] = $data['option']; - $data['swatchtext'] = [ - 'value' => $data['option']['value'] - ]; - $data['serialized_options'] = $this->getSerializeOptions($data, ['optiontext', 'swatchtext']); - unset($data['option']); - $data = parent::changeStructureOfTheData($data); + $options = []; + foreach ($data as $optionRowData) { + $optionRowData['optiontext'] = $optionRowData['option']; + $optionRowData['swatchtext'] = [ + 'value' => $optionRowData['option']['value'] + ]; + unset($optionRowData['option']); + $options[] = http_build_query($optionRowData); + } - return $data; + return json_encode($options); } } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php index 1f70ad0f7df6b..ab8c29889eabd 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php @@ -298,13 +298,15 @@ public function testLargeOptionsDataSet() $optionsData = []; $expectedOptionsLabels = []; for ($i = 0; $i < $optionsCount; $i++) { - $order = $i + 1; - $expectedOptionLabelOnStoreView = "value_{$i}_store_1"; + $expectedOptionLabelOnStoreView = 'value_' . $i . '_store_1'; $expectedOptionsLabels[$i+1] = $expectedOptionLabelOnStoreView; - $optionsData []= "option[order][option_{$i}]={$order}"; - $optionsData []= "option[value][option_{$i}][0]=value_{$i}_admin"; - $optionsData []= "option[value][option_{$i}][1]={$expectedOptionLabelOnStoreView}"; - $optionsData []= "option[delete][option_{$i}="; + $optionId = 'option_' . $i; + $optionRowData = []; + $optionRowData['option']['order'][$optionId] = $i + 1; + $optionRowData['option']['value'][$optionId][0] = 'value_' . $i . '_admin'; + $optionRowData['option']['value'][$optionId][1] = $expectedOptionLabelOnStoreView; + $optionRowData['option']['delete'][$optionId] = ''; + $optionsData[] = http_build_query($optionRowData); } $attributeData['serialized_options'] = json_encode($optionsData); $this->getRequest()->setMethod(HttpRequest::METHOD_POST); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php index e7a2d17586a93..37ef60208861d 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php @@ -6,6 +6,8 @@ namespace Magento\Catalog\Model\Product\Option\Type\File; +use Magento\Framework\Math\Random; + /** * @magentoDataFixture Magento/Catalog/_files/validate_image.php * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -48,11 +50,18 @@ protected function setUp() $fileSize = $this->objectManager->create(\Magento\Framework\File\Size::class); $this->maxFileSize = $fileSize->getMaxFileSize(); $this->maxFileSizeInMb = $fileSize->getMaxFileSizeInMb(); + $random = $this->getMockBuilder(Random::class) + ->disableOriginalConstructor() + ->getMock(); + $random->expects($this->any()) + ->method('getRandomString') + ->willReturn('RandomString'); $this->model = $this->objectManager->create( - \Magento\Catalog\Model\Product\Option\Type\File\ValidatorFile::class, + ValidatorFile::class, [ - 'httpFactory' => $this->httpFactoryMock + 'httpFactory' => $this->httpFactoryMock, + 'random' => $random, ] ); } @@ -350,8 +359,8 @@ protected function expectedValidate() return [ 'type' => 'image/jpeg', 'title' => 'test.jpg', - 'quote_path' => 'custom_options/quote/t/e/a071b9ffc8fda6df1652c05a4c61bf8a.jpg', - 'order_path' => 'custom_options/order/t/e/a071b9ffc8fda6df1652c05a4c61bf8a.jpg', + 'quote_path' => 'custom_options/quote/t/e/RandomString', + 'order_path' => 'custom_options/order/t/e/RandomString', 'size' => '3046', 'width' => 136, 'height' => 131, diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/category_duplicates.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/category_duplicates.php index d3825675b7244..46d5bfea6459c 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/category_duplicates.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/category_duplicates.php @@ -15,7 +15,7 @@ )->setParentId( 2 )->setPath( - '1/2' + '1/2/444' )->setLevel( '2' )->setDefaultSortBy( diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/category_duplicates_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/category_duplicates_rollback.php new file mode 100644 index 0000000000000..ceaad3a00329f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/category_duplicates_rollback.php @@ -0,0 +1,35 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Framework\Exception\NoSuchEntityException; + +/** @var \Magento\Framework\ObjectManagerInterface $objectManager */ +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + +/** @var \Magento\Framework\Registry $registry */ +$registry = $objectManager->get(\Magento\Framework\Registry::class); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $collection */ +$categoryCollection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Category\Collection::class); +$categoryCollection + ->addAttributeToFilter('level', 2) + ->load() + ->delete(); + +/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ +$productRepository = $objectManager->get(\Magento\Catalog\Api\ProductRepositoryInterface::class); +try { + $product = $productRepository->get('simple3', false, null, true); + $productRepository->delete($product); +} catch (NoSuchEntityException $e) { +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php index 237d7660da9bd..a48b5d43e501b 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php @@ -431,7 +431,7 @@ public function getBehaviorDataProvider(): array 'Append behavior with new product' => [ 'importFile' => 'product_with_custom_options_new.csv', 'sku' => 'simple_new', - 'expectedOptionsQty' => 4, + 'expectedOptionsQty' => 5, ], ]; } @@ -1292,12 +1292,10 @@ public function categoryTestDataProvider() * @magentoAppArea adminhtml * @magentoDbIsolation disabled * @magentoAppIsolation enabled - * @magentoDataFixture Magento/Catalog/_files/category_duplicates.php + * @magentoDataFixture Magento/CatalogImportExport/_files/update_category_duplicates.php */ public function testProductDuplicateCategories() { - $this->markTestSkipped('Due to MAGETWO-48956'); - $csvFixture = 'products_duplicate_category.csv'; // import data from CSV file $pathToFile = __DIR__ . '/_files/' . $csvFixture; @@ -1322,19 +1320,6 @@ public function testProductDuplicateCategories() $this->assertTrue($errors->getErrorsCount() === 0); - /** @var \Magento\Catalog\Model\Category $category */ - $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Catalog\Model\Category::class - ); - - $category->load(444); - - $this->assertTrue($category !== null); - - $category->setName( - 'Category 2-updated' - )->save(); - $this->_model->importData(); $errorProcessor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( @@ -1643,6 +1628,45 @@ public function testImportWithoutUrlKeys() } } + /** + * Make sure the absence of a url_key column in the csv file won't erase the url key of the existing products. + * To reach the goal we need to not send the name column, as the url key is generated from it. + * + * @magentoDataFixture Magento/Catalog/_files/product_simple_with_url_key.php + * @magentoDbIsolation disabled + * @magentoAppIsolation enabled + */ + public function testImportWithoutUrlKeysAndName() + { + $products = [ + 'simple1' => 'url-key', + 'simple2' => 'url-key2', + ]; + $filesystem = $this->objectManager->create(\Magento\Framework\Filesystem::class); + $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT); + $source = $this->objectManager->create( + \Magento\ImportExport\Model\Import\Source\Csv::class, + [ + 'file' => __DIR__ . '/_files/products_to_import_without_url_keys_and_name.csv', + 'directory' => $directory + ] + ); + + $errors = $this->_model->setParameters( + ['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'catalog_product'] + ) + ->setSource($source) + ->validateData(); + + $this->assertTrue($errors->getErrorsCount() == 0); + $this->_model->importData(); + + $productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); + foreach ($products as $productSku => $productUrlKey) { + $this->assertEquals($productUrlKey, $productRepository->get($productSku)->getUrlKey()); + } + } + /** * @magentoAppIsolation enabled */ diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/product_with_custom_options_new.csv b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/product_with_custom_options_new.csv index 7fe8832cd5804..f276a96cd1d38 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/product_with_custom_options_new.csv +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/product_with_custom_options_new.csv @@ -1,2 +1,2 @@ sku,store_view_code,attribute_set_code,product_type,categories,product_websites,name,description,short_description,weight,product_online,tax_class_name,visibility,price,special_price,special_price_from_date,special_price_to_date,url_key,meta_title,meta_keywords,meta_description,base_image,base_image_label,small_image,small_image_label,thumbnail_image,thumbnail_image_label,created_at,updated_at,new_from_date,new_to_date,display_product_options_in,map_price,msrp_price,map_enabled,gift_message_available,custom_design,custom_design_from,custom_design_to,custom_layout_update,page_layout,product_options_container,msrp_display_actual_price_type,country_of_manufacture,additional_attributes,qty,out_of_stock_qty,use_config_min_qty,is_qty_decimal,allow_backorders,use_config_backorders,min_cart_qty,use_config_min_sale_qty,max_cart_qty,use_config_max_sale_qty,is_in_stock,notify_on_stock_below,use_config_notify_stock_qty,manage_stock,use_config_manage_stock,use_config_qty_increments,qty_increments,use_config_enable_qty_inc,enable_qty_increments,is_decimal_divided,website_id,related_skus,crosssell_skus,upsell_skus,additional_images,additional_image_labels,hide_from_product_page,custom_options,bundle_price_type,bundle_sku_type,bundle_price_view,bundle_weight_type,bundle_values,associated_skus -simple_new,,Default,simple,,base,"New Product",,,,1,"Taxable Goods","Catalog, Search",10.0000,,,,new-product,"New Product","New Product","New Product ",,,,,,,"2015-10-20 07:05:38","2015-10-20 07:05:38",,,"Block after Info Column",,,,,,,,,,,,,"has_options=1,quantity_and_stock_status=In Stock,required_options=1",100.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,0,1,1.0000,0,0,0,1,,,,,,,"name=New Radio,type=radio,required=1,price=3.0000,price_type=fixed,sku=4-1-radio,option_title=Option 1|name=New Radio,type=radio,required=1,price=3.0000,price_type=fixed,sku=4-2-radio,option_title=Option 2|name=New Select,type=drop_down,required=1,price=3.0000,price_type=fixed,sku=3-1-select,option_title=Option 1|name=New Select,type=drop_down,required=1,price=3.0000,price_type=fixed,sku=3-2-select,option_title=Option2|name=Test Date and Time Title,type=date_time,required=1,price=2.0000,price_type=fixed,sku=2-date|name=Test Field Title,type=field,required=1,price=0.0000,price_type=fixed,sku=1-text,max_characters=10",,,,,, +simple_new,,Default,simple,,base,"New Product",,,,1,"Taxable Goods","Catalog, Search",10.0000,,,,new-product,"New Product","New Product","New Product ",,,,,,,"2015-10-20 07:05:38","2015-10-20 07:05:38",,,"Block after Info Column",,,,,,,,,,,,,"has_options=1,quantity_and_stock_status=In Stock,required_options=1",100.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,0,1,1.0000,0,0,0,1,,,,,,,"name=New Radio,type=radio,required=1,price=3.0000,price_type=fixed,sku=4-1-radio,option_title=Option 1|name=New Radio,type=radio,required=1,price=3.0000,price_type=fixed,sku=4-2-radio,option_title=Option 2|name=New Select,type=drop_down,required=1,price=3.0000,price_type=fixed,sku=3-1-select,option_title=Option 1|name=New Select,type=drop_down,required=1,price=3.0000,price_type=fixed,sku=3-2-select,option_title=Option2|name=Test Date and Time Title,type=date_time,required=1,price=2.0000,price_type=fixed,sku=2-date|name=Test Field Title,type=field,required=1,price=0.0000,price_type=fixed,sku=1-text,max_characters=10|name=New Select With Zero Price,type=drop_down,required=1,price=0,price_type=fixed,sku=3-1-select,option_title=Option 1",,,,,, diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/products_to_import_without_url_keys_and_name.csv b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/products_to_import_without_url_keys_and_name.csv new file mode 100644 index 0000000000000..8ea6ab92a0295 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/products_to_import_without_url_keys_and_name.csv @@ -0,0 +1,3 @@ +sku,price +simple1,25 +simple2,34 diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/_files/update_category_duplicates.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/_files/update_category_duplicates.php new file mode 100644 index 0000000000000..53d30e834a07d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/_files/update_category_duplicates.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +require dirname(dirname(__DIR__)) . '/Catalog/_files/category_duplicates.php'; + +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + +/** @var \Magento\Catalog\Model\Category $category */ +$categoryModel = $objectManager->create(\Magento\Catalog\Model\Category::class); +$categoryModel->setStoreId(\Magento\Store\Model\Store::DEFAULT_STORE_ID); + +$categoryModel->load(444) + ->setName('Category 2-updated') + ->save(); diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/_files/update_category_duplicates_rollback.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/_files/update_category_duplicates_rollback.php new file mode 100644 index 0000000000000..ca0f379a03dc5 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/_files/update_category_duplicates_rollback.php @@ -0,0 +1,20 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +require dirname(dirname(__DIR__)) . '/Catalog/_files/category_duplicates_rollback.php'; + +//Delete products created in CSV import +/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ +$productRepository = $objectManager->get(\Magento\Catalog\Api\ProductRepositoryInterface::class); +$csvProductSkus = ['simple1', 'simple2', 'simple3']; +foreach ($csvProductSkus as $sku) { + try { + $product = $productRepository->get($sku, false, null, true); + $productRepository->delete($product); + } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { + } +} diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Plugin/Model/Quote/ResetQuoteAddressesTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Plugin/Model/Quote/ResetQuoteAddressesTest.php index e533dbfa0c879..994076badddae 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/Plugin/Model/Quote/ResetQuoteAddressesTest.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/Plugin/Model/Quote/ResetQuoteAddressesTest.php @@ -52,9 +52,15 @@ public function testAfterRemoveItem(): void $cart = Bootstrap::getObjectManager()->create(Cart::class); $activeQuote = $cart->getQuote(); + // Dummy data is still persisted here. This is sufficient to check that it is removed + $activeQuote->getExtensionAttributes()->setShippingAssignments(['test']); + $cart->removeItem($activeQuote->getAllVisibleItems()[0]->getId()); $cart->save(); + // Check that the shipping assignments were also unset + $this->assertEmpty($activeQuote->getExtensionAttributes()->getShippingAssignments()); + /** @var Quote $quote */ $quote = Bootstrap::getObjectManager()->create(Quote::class); $quote->load('test_order_with_virtual_product', 'reserved_order_id'); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/ResetPasswordTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/ResetPasswordTest.php index 8fa77a7388be2..789978d8180d0 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/ResetPasswordTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/ResetPasswordTest.php @@ -34,7 +34,7 @@ public function testResetPasswordSuccess() $this->passwordResetRequestEventCreate( \Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST ); - $this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_POST); + $this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_GET); $this->dispatch('backend/customer/index/resetPassword'); $this->assertSessionMessages( $this->equalTo(['The customer will receive an email with a link to reset password.']), @@ -44,18 +44,18 @@ public function testResetPasswordSuccess() } /** - * Checks reset password functionality cannot be performed with GET request + * Checks reset password functionality cannot be performed with POST request * * @magentoConfigFixture current_store customer/password/limit_password_reset_requests_method 0 * @magentoConfigFixture current_store customer/password/min_time_between_password_reset_requests 0 * @magentoDataFixture Magento/Customer/_files/customer.php */ - public function testResetPasswordWithGet() + public function testResetPasswordWithPost() { $this->passwordResetRequestEventCreate( \Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST ); - $this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_GET); + $this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_POST); $this->dispatch('backend/customer/index/resetPassword'); $this->assertEquals('noroute', $this->getRequest()->getControllerName()); } @@ -74,7 +74,7 @@ public function testResetPasswordMinTimeError() $this->passwordResetRequestEventCreate( \Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST ); - $this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_POST); + $this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_GET); $this->dispatch('backend/customer/index/resetPassword'); $this->assertSessionMessages( $this->equalTo(['The customer will receive an email with a link to reset password.']), @@ -97,7 +97,7 @@ public function testResetPasswordLimitError() $this->passwordResetRequestEventCreate( \Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST ); - $this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_POST); + $this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_GET); $this->dispatch('backend/customer/index/resetPassword'); $this->assertSessionMessages( $this->equalTo(['The customer will receive an email with a link to reset password.']), @@ -122,7 +122,7 @@ public function testResetPasswordWithSecurityViolationException() $this->passwordResetRequestEventCreate( \Magento\Security\Model\PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST ); - $this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_POST); + $this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_GET); $this->dispatch('backend/customer/index/resetPassword'); $this->assertSessionMessages( $this->equalTo(['The customer will receive an email with a link to reset password.']), diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php index 4262967aa8d1a..2fe49efd74a6d 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php @@ -738,7 +738,7 @@ public function testValidateCustomerWithAddressFailure() public function testResetPasswordActionNoCustomerId() { // No customer ID in post, will just get redirected to base - $this->getRequest()->setMethod(HttpRequest::METHOD_POST); + $this->getRequest()->setMethod(HttpRequest::METHOD_GET); $this->dispatch('backend/customer/index/resetPassword'); $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl)); } @@ -749,7 +749,7 @@ public function testResetPasswordActionNoCustomerId() public function testResetPasswordActionBadCustomerId() { // Bad customer ID in post, will just get redirected to base - $this->getRequest()->setMethod(HttpRequest::METHOD_POST); + $this->getRequest()->setMethod(HttpRequest::METHOD_GET); $this->getRequest()->setPostValue(['customer_id' => '789']); $this->dispatch('backend/customer/index/resetPassword'); $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl)); @@ -761,7 +761,7 @@ public function testResetPasswordActionBadCustomerId() public function testResetPasswordActionSuccess() { $this->getRequest()->setPostValue(['customer_id' => '1']); - $this->getRequest()->setMethod(HttpRequest::METHOD_POST); + $this->getRequest()->setMethod(HttpRequest::METHOD_GET); $this->dispatch('backend/customer/index/resetPassword'); $this->assertSessionMessages( $this->equalTo(['The customer will receive an email with a link to reset password.']), diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Model/Plugin/PluginTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Model/Plugin/PluginTest.php index 39db400d2d637..dbc666e49b6cf 100644 --- a/dev/tests/integration/testsuite/Magento/Newsletter/Model/Plugin/PluginTest.php +++ b/dev/tests/integration/testsuite/Magento/Newsletter/Model/Plugin/PluginTest.php @@ -167,4 +167,42 @@ private function verifySubscriptionNotExist($email) $this->assertEquals(0, (int)$subscriber->getId()); return $subscriber; } + + /** + * @magentoAppArea adminhtml + * @magentoDbIsolation enabled + */ + public function testCustomerWithZeroStoreIdIsSubscribed() + { + $objectManager = Bootstrap::getObjectManager(); + + $currentStore = $objectManager->get( + \Magento\Store\Model\StoreManagerInterface::class + )->getStore()->getId(); + + $subscriber = $objectManager->create(\Magento\Newsletter\Model\Subscriber::class); + /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ + $subscriber->setStoreId($currentStore) + ->setCustomerId(0) + ->setSubscriberEmail('customer@example.com') + ->setSubscriberStatus(\Magento\Newsletter\Model\Subscriber::STATUS_SUBSCRIBED) + ->save(); + + /** @var \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerFactory */ + $customerFactory = $objectManager->get(\Magento\Customer\Api\Data\CustomerInterfaceFactory::class); + $customerDataObject = $customerFactory->create() + ->setFirstname('Firstname') + ->setLastname('Lastname') + ->setStoreId(0) + ->setEmail('customer@example.com'); + /** @var \Magento\Customer\Api\Data\CustomerInterface $customer */ + $customer = $this->accountManagement->createAccount($customerDataObject); + + $this->customerRepository->save($customer); + + $subscriber->loadByEmail('customer@example.com'); + + $this->assertEquals($customer->getId(), (int)$subscriber->getCustomerId()); + $this->assertEquals($currentStore, (int)$subscriber->getStoreId()); + } } diff --git a/dev/tests/integration/testsuite/Magento/Sales/CustomerData/LastOrderedItemsTest.php b/dev/tests/integration/testsuite/Magento/Sales/CustomerData/LastOrderedItemsTest.php new file mode 100644 index 0000000000000..7800d2363b364 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/CustomerData/LastOrderedItemsTest.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\CustomerData; + +use Magento\Framework\ObjectManagerInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; +use Magento\Customer\Model\Session; + +/** + * @magentoAppIsolation enabled + */ +class LastOrderedItemsTest extends TestCase +{ + /** + * @var ObjectManagerInterface + */ + private $objectManager; + + public function setUp() + { + $this->objectManager = Bootstrap::getObjectManager(); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order_with_customer_and_multiple_order_items.php + */ + public function testDefaultFormatterIsAppliedWhenBasicIntegration() + { + /** @var Session $customerSession */ + $customerSession = $this->objectManager->get(Session::class); + $customerSession->loginById(1); + + /** @var LastOrderedItems $customerDataSectionSource */ + $customerDataSectionSource = $this->objectManager->get(LastOrderedItems::class); + $data = $customerDataSectionSource->getSectionData(); + $this->assertEquals( + LastOrderedItems::SIDEBAR_ORDER_LIMIT, + count($data['items']), + 'Section items count should not be greater then ' . LastOrderedItems::SIDEBAR_ORDER_LIMIT + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_with_customer_and_multiple_order_items.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_with_customer_and_multiple_order_items.php new file mode 100644 index 0000000000000..08c54844f2749 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_with_customer_and_multiple_order_items.php @@ -0,0 +1,13 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +include __DIR__ . '/order_with_multiple_items.php'; +include __DIR__ . '/../../../Magento/Customer/_files/customer.php'; + +$customerIdFromFixture = 1; +/** @var $order \Magento\Sales\Model\Order */ +$order->setCustomerId($customerIdFromFixture)->setCustomerIsGuest(false)->save(); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_with_multiple_items.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_with_multiple_items.php new file mode 100644 index 0000000000000..ae0523d34fd2f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_with_multiple_items.php @@ -0,0 +1,82 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +require 'order.php'; +/** @var \Magento\Catalog\Model\Product $product */ +/** @var \Magento\Sales\Model\Order $order */ +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + +require __DIR__ . '/../../../Magento/Catalog/_files/product_simple.php'; +$orderItems[] = [ + 'product_id' => $product->getId(), + 'base_price' => 123, + 'order_id' => $order->getId(), + 'price' => 123, + 'row_total' => 126, + 'product_type' => 'simple' +]; + +require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_duplicated.php'; +$orderItems[] = [ + 'product_id' => $product->getId(), + 'base_price' => 123, + 'order_id' => $order->getId(), + 'price' => 123, + 'row_total' => 126, + 'product_type' => 'simple' +]; + +require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_with_full_option_set.php'; +$orderItems[] = [ + 'product_id' => $product->getId(), + 'base_price' => 123, + 'order_id' => $order->getId(), + 'price' => 123, + 'row_total' => 126, + 'product_type' => 'simple' +]; + +require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_with_url_key.php'; +$orderItems[] = [ + 'product_id' => $product->getId(), + 'base_price' => 123, + 'order_id' => $order->getId(), + 'price' => 123, + 'row_total' => 126, + 'product_type' => 'simple' +]; + +require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_with_all_fields.php'; +$orderItems[] = [ + 'product_id' => $product->getId(), + 'base_price' => 123, + 'order_id' => $order->getId(), + 'price' => 123, + 'row_total' => 126, + 'product_type' => 'simple' +]; + +require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_with_custom_attribute.php'; +$orderItems[] = [ + 'product_id' => $product->getId(), + 'base_price' => 123, + 'order_id' => $order->getId(), + 'price' => 123, + 'row_total' => 126, + 'product_type' => 'simple' +]; + +/** @var array $orderItemData */ +foreach ($orderItems as $orderItemData) { + /** @var $orderItem \Magento\Sales\Model\Order\Item */ + $orderItem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Sales\Model\Order\Item::class + ); + $orderItem + ->setData($orderItemData) + ->save(); +} diff --git a/dev/tests/integration/testsuite/Magento/Swatches/Controller/Adminhtml/Product/AttributeTest.php b/dev/tests/integration/testsuite/Magento/Swatches/Controller/Adminhtml/Product/AttributeTest.php index 5b7a80bb38dfd..f806674d29705 100644 --- a/dev/tests/integration/testsuite/Magento/Swatches/Controller/Adminhtml/Product/AttributeTest.php +++ b/dev/tests/integration/testsuite/Magento/Swatches/Controller/Adminhtml/Product/AttributeTest.php @@ -55,15 +55,17 @@ private function getSwatchVisualDataSet(int $optionsCount) : array $optionsData = []; $expectedOptionsLabels = []; for ($i = 0; $i < $optionsCount; $i++) { - $order = $i + 1; - $expectedOptionLabelOnStoreView = "value_{$i}_store_1"; + $expectedOptionLabelOnStoreView = 'value_' . $i .'_store_1'; $expectedOptionsLabels[$i+1] = $expectedOptionLabelOnStoreView; - $optionsData []= "optionvisual[order][option_{$i}]={$order}"; - $optionsData []= "defaultvisual[]=option_{$i}"; - $optionsData []= "swatchvisual[value][option_{$i}]={$this->getRandomColor()}"; - $optionsData []= "optionvisual[value][option_{$i}][0]=value_{$i}_admin"; - $optionsData []= "optionvisual[value][option_{$i}][1]={$expectedOptionLabelOnStoreView}"; - $optionsData []= "optionvisual[delete][option_{$i}]="; + $optionId = 'option_' .$i; + $optionRowData = []; + $optionRowData['optionvisual']['order'][$optionId] = $i + 1; + $optionRowData['defaultvisual'][] = $optionId; + $optionRowData['swatchvisual']['value'][$optionId] = $this->getRandomColor(); + $optionRowData['optionvisual']['value'][$optionId][0] = 'value_' . $i .'_admin'; + $optionRowData['optionvisual']['value'][$optionId][1] = $expectedOptionLabelOnStoreView; + $optionRowData['optionvisual']['delete'][$optionId] = ''; + $optionsData[] = http_build_query($optionRowData); } return [ 'attribute_data' => array_merge_recursive( @@ -95,15 +97,17 @@ private function getSwatchTextDataSet(int $optionsCount) : array $optionsData = []; $expectedOptionsLabels = []; for ($i = 0; $i < $optionsCount; $i++) { - $order = $i + 1; - $expectedOptionLabelOnStoreView = "value_{$i}_store_1"; + $expectedOptionLabelOnStoreView = 'value_' . $i . '_store_1'; $expectedOptionsLabels[$i+1] = $expectedOptionLabelOnStoreView; - $optionsData []= "optiontext[order][option_{$i}]={$order}"; - $optionsData []= "defaulttext[]=option_{$i}"; - $optionsData []= "swatchtext[value][option_{$i}]=x{$i}"; - $optionsData []= "optiontext[value][option_{$i}][0]=value_{$i}_admin"; - $optionsData []= "optiontext[value][option_{$i}][1]={$expectedOptionLabelOnStoreView}"; - $optionsData []= "optiontext[delete][option_{$i}]="; + $optionId = 'option_' . $i; + $optionRowData = []; + $optionRowData['optiontext']['order'][$optionId] = $i + 1; + $optionRowData['defaulttext'][] = $optionId; + $optionRowData['swatchtext']['value'][$optionId] = 'x' . $i ; + $optionRowData['optiontext']['value'][$optionId][0] = 'value_' . $i . '_admin'; + $optionRowData['optiontext']['value'][$optionId][1]= $expectedOptionLabelOnStoreView; + $optionRowData['optiontext']['delete'][$optionId]=''; + $optionsData[] = http_build_query($optionRowData); } return [ 'attribute_data' => array_merge_recursive( diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/error-processor.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/error-processor.test.js new file mode 100644 index 0000000000000..772250eb7c66a --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/error-processor.test.js @@ -0,0 +1,72 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +/*eslint max-nested-callbacks: 0*/ +define([ + 'squire' +], function (Squire) { + 'use strict'; + + describe('Magento_Checkout/js/model/error-processor', function () { + var injector = new Squire(), + mocks = { + 'mage/url': { + /** Method stub. */ + build: jasmine.createSpy() + }, + 'Magento_Ui/js/model/messageList': jasmine.createSpy('globalList') + }, + model; + + beforeEach(function (done) { + injector.mock(mocks); + injector.require([ + 'Magento_Checkout/js/model/error-processor' + ], function (processor) { + model = processor; + + done(); + }); + }); + + describe('Check process method', function () { + it('check on success response with valid response data', function () { + var messageObject = { + message: 'Valid error message!' + }, + messageContainer = jasmine.createSpyObj('globalMessageList', ['addErrorMessage']); + + model.process({ + status: 200, + responseText: JSON.stringify(messageObject) + }, messageContainer); + expect(messageContainer.addErrorMessage).toHaveBeenCalledWith(messageObject); + }); + + it('check on success response with invalid response data', function () { + var messageContainer = jasmine.createSpyObj('globalMessageList', ['addErrorMessage']); + + model.process({ + status: 200, + responseText: '' + }, messageContainer); + expect(messageContainer.addErrorMessage) + .toHaveBeenCalledWith('Something went wrong with your request. Please try again later.'); + }); + + it('check on failed status', function () { + var messageContainer = jasmine.createSpyObj('globalMessageList', ['addErrorMessage']); + + spyOn(window.location, 'replace').and.callFake(function () {}); + model.process({ + status: 401, + responseText: '' + }, messageContainer); + expect(mocks['mage/url'].build) + .toHaveBeenCalled(); + }); + }); + }); +}); diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml index 5b8a4c8f37c99..ae6c98e4627d2 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml @@ -21,7 +21,7 @@ <column xsi:type="bigint" name="bigint_default_nullable" padding="2" nullable="true" default="1" unsigned="true"/> <column xsi:type="bigint" name="bigint_not_default_not_nullable" padding="2" nullable="false" unsigned="true"/> - <constraint xsi:type="primary" name="tinyint_primary"> + <constraint xsi:type="primary" referenceId="tinyint_primary"> <column name="tinyint_ref"/> </constraint> </table> @@ -30,7 +30,7 @@ nullable="true"/> <column xsi:type="smallint" name="int_disabled_auto_increment" default="0" identity="false" padding="12" unsigned="true" nullable="true"/> - <constraint xsi:type="unique" name="AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE"> + <constraint xsi:type="unique" referenceId="AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE"> <column name="int_auto_increment_with_nullable"/> </constraint> </table> @@ -53,15 +53,15 @@ <column xsi:type="boolean" name="boolean"/> <column xsi:type="varbinary" name="varbinary_rename" default="10101" disabled="true"/> <!--Constraints--> - <constraint xsi:type="unique" name="TEST_TABLE_SMALLINT_BIGINT"> + <constraint xsi:type="unique" referenceId="TEST_TABLE_UNIQUE"> <column name="smallint"/> <column name="bigint"/> </constraint> - <constraint xsi:type="foreign" name="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF" + <constraint xsi:type="foreign" referenceId="TEST_TABLE_TINYINT_REFERENCE" column="tinyint" table="test_table" referenceTable="reference_table" referenceColumn="tinyint_ref" onDelete="NO ACTION"/> <!--Indexes--> - <index name="TEST_TABLE_TINYINT_BIGINT" indexType="btree"> + <index referenceId="TEST_TABLE_INDEX" indexType="btree"> <column name="tinyint"/> <column name="bigint"/> </index> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/foreign_key_interpreter_result.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/foreign_key_interpreter_result.php index 76fcf6b2fad11..e3068c1bd7625 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/foreign_key_interpreter_result.php +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/foreign_key_interpreter_result.php @@ -33,7 +33,7 @@ 'constraint' => [ 'TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF' => [ 'type' => 'foreign', - 'name' => 'TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF', + 'referenceId' => 'TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF', 'column' => 'tinyint', 'table' => 'test_table', 'referenceTable' => 'reference_table', diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php index cd42a1e8fc360..a064d096f6d38 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php @@ -93,7 +93,7 @@ 'tinyint_ref' => 'tinyint_ref', ], 'type' => 'primary', - 'name' => 'tinyint_primary', + 'referenceId' => 'tinyint_primary', ], ], 'name' => 'reference_table', @@ -125,7 +125,7 @@ 'int_auto_increment_with_nullable' => 'int_auto_increment_with_nullable', ], 'type' => 'unique', - 'name' => 'AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE', + 'referenceId' => 'AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE', ], ], 'name' => 'auto_increment_test', @@ -225,17 +225,17 @@ ], ], 'constraint' => [ - 'TEST_TABLE_SMALLINT_BIGINT' => [ + 'TEST_TABLE_UNIQUE' => [ 'column' => [ 'smallint' => 'smallint', 'bigint' => 'bigint', ], 'type' => 'unique', - 'name' => 'TEST_TABLE_SMALLINT_BIGINT', + 'referenceId' => 'TEST_TABLE_UNIQUE', ], - 'TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF' => [ + 'TEST_TABLE_TINYINT_REFERENCE' => [ 'type' => 'foreign', - 'name' => 'TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF', + 'referenceId' => 'TEST_TABLE_TINYINT_REFERENCE', 'column' => 'tinyint', 'table' => 'test_table', 'referenceTable' => 'reference_table', @@ -244,12 +244,12 @@ ], ], 'index' => [ - 'TEST_TABLE_TINYINT_BIGINT' => [ + 'TEST_TABLE_INDEX' => [ 'column' => [ 'tinyint' => 'tinyint', 'bigint' => 'bigint', ], - 'name' => 'TEST_TABLE_TINYINT_BIGINT', + 'referenceId' => 'TEST_TABLE_INDEX', 'indexType' => 'btree', ], ], diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/base_update/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/base_update/db_schema.xml index 7384c4ed7baab..af66686e77b42 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/base_update/db_schema.xml +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/base_update/db_schema.xml @@ -9,7 +9,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd"> <table name="reference_table" resource="default" comment="Reference table"> <column xsi:type="smallint" name="smallint_ref" padding="6" nullable="false" unsigned="false" identity="true" comment="Smallint"/> - <constraint xsi:type="primary" name="tinyint_primary"> + <constraint xsi:type="primary" referenceId="tinyint_primary"> <column name="smallint_ref"/> </constraint> </table> @@ -22,14 +22,14 @@ <column xsi:type="mediumtext" name="mediumtext" comment="Mediumtext"/> <column xsi:type="varchar" name="varchar" length="254" nullable="true" comment="Varchar"/> <column xsi:type="boolean" name="boolean" comment="Boolean"/> - <constraint xsi:type="unique" name="TEST_TABLE_SMALLINT_BIGINT"> + <constraint xsi:type="unique" referenceId="TEST_TABLE_SMALLINT_BIGINT"> <column name="smallint"/> <column name="bigint"/> </constraint> - <constraint xsi:type="foreign" name="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF" + <constraint xsi:type="foreign" referenceId="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF" column="smallint" table="test_table" referenceTable="reference_table" referenceColumn="smallint_ref" onDelete="CASCADE"/> - <index name="TEST_TABLE_BIGINT" indexType="btree"> + <index referenceId="TEST_TABLE_BIGINT" indexType="btree"> <column name="bigint"/> </index> </table> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/before_rollback/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/before_rollback/db_schema.xml index 4d3d51b9c0237..8c42f9efd129a 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/before_rollback/db_schema.xml +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/before_rollback/db_schema.xml @@ -20,7 +20,7 @@ <table name="store_owner" comment="Store owner information" engine="innodb" resource="default"> <column name="owner_id" xsi:type="smallint" nullable="false" unsigned="false" identity="true" /> <column name="store_owner_name" onCreate="migrateDataFrom(label)" xsi:type="varchar" length="255" comment="Store Owner Name" /> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="owner_id" /> </constraint> </table> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml index 0adcd5c52f962..4f9a5ab6d5a92 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml @@ -21,7 +21,7 @@ <column xsi:type="bigint" name="bigint_default_nullable" padding="2" nullable="true" default="123" unsigned="true"/> <column xsi:type="bigint" name="bigint_not_default_not_nullable" nullable="false" unsigned="false"/> - <constraint xsi:type="primary" name="tinyint_primary"> + <constraint xsi:type="primary" referenceId="tinyint_primary"> <column name="tinyint_ref"/> </constraint> </table> @@ -29,7 +29,7 @@ <column xsi:type="int" name="int_auto_increment_with_nullable" padding="15" unsigned="true" nullable="true"/> <column xsi:type="smallint" name="int_disabled_auto_increment" default="0" identity="false" padding="12" unsigned="true" nullable="true"/> - <constraint xsi:type="unique" name="AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE"> + <constraint xsi:type="unique" referenceId="AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE"> <column name="int_auto_increment_with_nullable"/> </constraint> </table> @@ -52,15 +52,15 @@ <column xsi:type="boolean" name="boolean" default="true"/> <column xsi:type="varbinary" name="varbinary_rename" default="10101" disabled="true"/> <!--Constraints--> - <constraint xsi:type="unique" name="TEST_TABLE_SMALLINT_BIGINT"> + <constraint xsi:type="unique" referenceId="TEST_TABLE_SMALLINT_BIGINT"> <column name="smallint"/> <column name="bigint"/> </constraint> - <constraint xsi:type="foreign" name="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF" + <constraint xsi:type="foreign" referenceId="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF" column="tinyint" table="test_table" referenceTable="reference_table" referenceColumn="tinyint_ref" onDelete="NO ACTION"/> <!--Indexes--> - <index name="TEST_TABLE_TINYINT_BIGINT" indexType="btree"> + <index referenceId="TEST_TABLE_TINYINT_BIGINT" indexType="btree"> <column name="tinyint"/> <column name="bigint"/> </index> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml index 4b78f436eab37..a3c4fe010fd35 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml @@ -20,14 +20,14 @@ <column xsi:type="bigint" name="bigint_default_nullable" padding="2" nullable="true" default="1" unsigned="true"/> <column xsi:type="bigint" name="bigint_not_default_not_nullable" padding="2" nullable="false" unsigned="true"/> - <constraint xsi:type="primary" name="tinyint_primary"> + <constraint xsi:type="primary" referenceId="tinyint_primary"> <column name="tinyint_ref"/> </constraint> </table> <table name="auto_increment_test" resource="default"> <column xsi:type="int" name="int_auto_increment_with_nullable" identity="true" padding="12" unsigned="true" nullable="true"/> - <constraint xsi:type="unique" name="AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE"> + <constraint xsi:type="unique" referenceId="AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE"> <column name="int_auto_increment_with_nullable"/> </constraint> </table> @@ -50,15 +50,15 @@ <column xsi:type="boolean" name="boolean"/> <column xsi:type="varbinary" name="varbinary_rename" default="10101" disabled="false"/> <!--Constraints--> - <constraint xsi:type="unique" name="TEST_TABLE_SMALLINT_BIGINT"> + <constraint xsi:type="unique" referenceId="TEST_TABLE_SMALLINT_BIGINT"> <column name="smallint"/> <column name="bigint"/> </constraint> - <constraint xsi:type="foreign" name="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF" + <constraint xsi:type="foreign" referenceId="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF" column="tinyint" table="test_table" referenceTable="reference_table" referenceColumn="tinyint_ref" onDelete="NO ACTION"/> <!--Indexes--> - <index name="TEST_TABLE_TINYINT_BIGINT" indexType="btree"> + <index referenceId="TEST_TABLE_TINYINT_BIGINT" indexType="btree"> <column name="tinyint"/> <column name="bigint"/> </index> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml index 68f2810e8eed7..93e6e13eb36f8 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml @@ -22,11 +22,11 @@ <column xsi:type="bigint" name="bigint_default_nullable" padding="2" nullable="true" default="1" unsigned="true"/> <column xsi:type="bigint" name="bigint_not_default_not_nullable" padding="2" nullable="false" unsigned="true"/> - <constraint xsi:type="primary" name="tinyint_primary"> + <constraint xsi:type="primary" referenceId="tinyint_primary"> <column name="tinyint_ref"/> <column name="smallint_ref"/> </constraint> - <constraint xsi:type="unique" name="REFERENCE_TABLE_SMALLINT_REF"> + <constraint xsi:type="unique" referenceId="REFERENCE_TABLE_SMALLINT_REF"> <column name="smallint_ref"/> </constraint> </table> @@ -35,7 +35,7 @@ nullable="true"/> <column xsi:type="smallint" name="int_disabled_auto_increment" default="0" identity="false" padding="12" unsigned="true" nullable="true"/> - <constraint xsi:type="unique" name="AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE"> + <constraint xsi:type="unique" referenceId="AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE"> <column name="int_auto_increment_with_nullable"/> </constraint> </table> @@ -60,23 +60,23 @@ <column xsi:type="boolean" name="boolean"/> <column xsi:type="varbinary" name="varbinary_rename" default="10101" disabled="true"/> <!--Constraints--> - <constraint xsi:type="unique" name="TEST_TABLE_SMALLINT_FLOAT"> + <constraint xsi:type="unique" referenceId="TEST_TABLE_SMALLINT_FLOAT"> <column name="smallint"/> <column name="float"/> </constraint> - <constraint xsi:type="unique" name="TEST_TABLE_DOUBLE"> + <constraint xsi:type="unique" referenceId="TEST_TABLE_DOUBLE"> <column name="double"/> </constraint> - <constraint xsi:type="foreign" name="some_foreign_key_new" column="smallint_main" table="test_table" + <constraint xsi:type="foreign" referenceId="some_foreign_key_new" column="smallint_main" table="test_table" referenceTable="reference_table" referenceColumn="smallint_ref" onDelete="CASCADE"/> - <constraint xsi:type="foreign" name="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF" + <constraint xsi:type="foreign" referenceId="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF" column="tinyint" table="test_table" referenceTable="reference_table" referenceColumn="tinyint_ref" onDelete="SET NULL"/> - <constraint xsi:type="foreign" name="FK_FB77604C299EB8612D01E4AF8D9931F2" + <constraint xsi:type="foreign" referenceId="FK_FB77604C299EB8612D01E4AF8D9931F2" column="integer_main" table="test_table" referenceTable="auto_increment_test" referenceColumn="int_auto_increment_with_nullable"/> <!--Indexes--> - <index name="TEST_TABLE_TINYINT_BIGINT" indexType="btree"> + <index referenceId="TEST_TABLE_TINYINT_BIGINT" indexType="btree"> <column name="tinyint"/> <column name="bigint"/> </index> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/drop_table/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/drop_table/db_schema.xml index 0a0131e500641..8a73d9e225546 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/drop_table/db_schema.xml +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/drop_table/db_schema.xml @@ -12,7 +12,7 @@ nullable="true"/> <column xsi:type="smallint" name="int_disabled_auto_increment" default="0" identity="false" padding="12" unsigned="true" nullable="true"/> - <constraint xsi:type="unique" name="AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE"> + <constraint xsi:type="unique" referenceId="AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE"> <column name="int_auto_increment_with_nullable"/> </constraint> </table> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/db_schema.xml index e4a5ca05d02fe..479c4c87f6143 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/db_schema.xml +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/db_schema.xml @@ -12,7 +12,7 @@ </table> <table name="test_table" resource="default"> <column xsi:type="tinyint" name="tinyint" default="0" padding="7" nullable="true" unsigned="false"/> - <constraint xsi:type="foreign" name="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF" + <constraint xsi:type="foreign" referenceId="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF" column="tinyint" table="test_table" referenceTable="reference_table" referenceColumn="tinyint_ref"/> </table> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/index_to_disable/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/index_to_disable/db_schema.xml new file mode 100644 index 0000000000000..e10803af248c2 --- /dev/null +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/index_to_disable/db_schema.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd"> + <table name="test_table" resource="default"> + <!--Columns--> + <column xsi:type="smallint" identity="true" name="smallint" padding="3" nullable="true"/> + <column xsi:type="tinyint" name="tinyint" padding="7" nullable="true" unsigned="false"/> + <column xsi:type="bigint" name="bigint" default="0" padding="13" nullable="true" unsigned="false"/> + <column xsi:type="varchar" name="varchar" length="254" nullable="true"/> + <!--Constraints--> + <constraint xsi:type="unique" referenceId="TEST_TABLE_UNIQUE"> + <column name="smallint"/> + <column name="bigint"/> + </constraint> + <!--Indexes--> + <index referenceId="TEST_TABLE_INDEX" indexType="btree"> + <column name="tinyint"/> + <column name="bigint"/> + </index> + <index referenceId="TEST_TABLE_INDEX_VARCHAR" indexType="btree"> + <column name="varchar"/> + </index> + </table> +</schema> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml index 6b92440ca92f5..1347a1ba8e3b1 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml @@ -9,7 +9,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd"> <table name="reference_table" resource="default" comment="Reference table"> <column xsi:type="smallint" name="smallint_ref" padding="6" nullable="false" unsigned="false" identity="true" comment="Smallint"/> - <constraint xsi:type="primary" name="tinyint_primary"> + <constraint xsi:type="primary" referenceId="tinyint_primary"> <column name="smallint_ref"/> </constraint> </table> @@ -22,14 +22,14 @@ <column xsi:type="mediumtext" name="mediumtext" comment="Mediumtext"/> <column xsi:type="varchar" name="varchar" length="254" nullable="true" comment="Varchar"/> <column xsi:type="boolean" name="boolean" comment="Boolean"/> - <constraint xsi:type="unique" name="TEST_TABLE_SMALLINT_BIGINT"> + <constraint xsi:type="unique" referenceId="TEST_TABLE_SMALLINT_BIGINT"> <column name="smallint"/> <column name="bigint"/> </constraint> - <constraint xsi:type="foreign" name="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF" + <constraint xsi:type="foreign" referenceId="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF" column="smallint" table="test_table" referenceTable="reference_table" referenceColumn="smallint_ref" onDelete="CASCADE"/> - <index name="TEST_TABLE_BIGINT" indexType="btree"> + <index referenceId="TEST_TABLE_BIGINT" indexType="btree"> <column name="bigint"/> </index> </table> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/whitelist_upgrade/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/whitelist_upgrade/db_schema.xml new file mode 100644 index 0000000000000..90eaf91b10743 --- /dev/null +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/whitelist_upgrade/db_schema.xml @@ -0,0 +1,60 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd"> + <table name="reference_table" resource="default"> + <column xsi:type="tinyint" name="tinyint_ref" padding="7" nullable="false" identity="true" unsigned="false"/> + <column xsi:type="tinyint" name="tinyint_without_padding" default="0" nullable="false" unsigned="false"/> + <column xsi:type="bigint" name="bigint_without_padding" default="0" nullable="false" unsigned="false"/> + <column xsi:type="smallint" name="smallint_without_padding" default="0" nullable="false" unsigned="false"/> + <column xsi:type="int" name="integer_without_padding" default="0" nullable="false" unsigned="false"/> + <column xsi:type="smallint" name="smallint_with_big_padding" padding="254" default="0" nullable="false" + unsigned="false"/> + <column xsi:type="smallint" name="smallint_without_default" padding="2" nullable="true" unsigned="false"/> + <column xsi:type="int" name="int_without_unsigned" padding="2" nullable="true"/> + <column xsi:type="int" name="int_unsigned" padding="2" nullable="true" unsigned="true"/> + <column xsi:type="bigint" name="bigint_default_nullable" padding="2" nullable="true" default="1" + unsigned="true"/> + <column xsi:type="bigint" name="bigint_not_default_not_nullable" padding="2" nullable="false" unsigned="true"/> + <constraint xsi:type="primary" referenceId="tinyint_primary"> + <column name="tinyint_ref"/> + </constraint> + </table> + <table name="test_table" resource="default"> + <!--Columns--> + <column xsi:type="smallint" identity="true" name="smallint" padding="3" nullable="true"/> + <column xsi:type="tinyint" name="tinyint" padding="7" nullable="true" unsigned="false"/> + <column xsi:type="bigint" name="bigint" default="0" padding="13" nullable="true" unsigned="false"/> + <column xsi:type="float" name="float" default="0" scale="4" precision="12"/> + <column xsi:type="decimal" name="double" default="11111111.111111" precision="14" scale="6"/> + <column xsi:type="decimal" name="decimal" default="0" scale="4" precision="15"/> + <column xsi:type="date" name="date"/> + <column xsi:type="timestamp" name="timestamp" default="CURRENT_TIMESTAMP" on_update="true"/> + <column xsi:type="datetime" name="datetime" default="0"/> + <column xsi:type="longtext" name="longtext"/> + <column xsi:type="mediumtext" name="mediumtext"/> + <column xsi:type="varchar" name="varchar" length="254" nullable="true"/> + <column xsi:type="mediumblob" name="mediumblob"/> + <column xsi:type="blob" name="blob"/> + <column xsi:type="boolean" name="boolean"/> + <column xsi:type="varbinary" name="varbinary_rename" default="10101" disabled="true"/> + <!--Constraints--> + <constraint xsi:type="unique" referenceId="TEST_TABLE_UNIQUE"> + <column name="smallint"/> + <column name="bigint"/> + </constraint> + <constraint xsi:type="foreign" referenceId="TEST_TABLE_TINYINT_REFERENCE" + column="tinyint" table="test_table" + referenceTable="reference_table" referenceColumn="tinyint_ref" onDelete="NO ACTION"/> + <!--Indexes--> + <index referenceId="TEST_TABLE_INDEX" indexType="btree"> + <column name="tinyint"/> + <column name="bigint"/> + </index> + </table> +</schema> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule3/etc/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule3/etc/db_schema.xml index b6ff634e6ef1d..9bd6c438455b2 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule3/etc/db_schema.xml +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule3/etc/db_schema.xml @@ -11,7 +11,7 @@ <column xsi:type="tinyint" name="tinyint_ref" padding="7" nullable="false" identity="true" unsigned="false"/> <column xsi:type="int" name="some_integer" default="0" nullable="false" unsigned="false"/> <column xsi:type="varchar" name="for_patch_testing" comment="For patch testing" /> - <constraint xsi:type="primary" name="tinyint_primary"> + <constraint xsi:type="primary" referenceId="tinyint_primary"> <column name="tinyint_ref"/> </constraint> </table> @@ -21,10 +21,10 @@ <column xsi:type="tinyint" name="tinyint" padding="7" nullable="true" unsigned="false"/> <column xsi:type="varchar" name="varchar" length="254" nullable="true"/> <column xsi:type="varbinary" name="varbinary" default="10101" /> - <constraint xsi:type="foreign" name="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF" + <constraint xsi:type="foreign" referenceId="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF" column="tinyint" table="test_table" referenceTable="reference_table" referenceColumn="tinyint_ref" onDelete="CASCADE"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="smallint" /> </constraint> </table> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule4/etc/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule4/etc/db_schema.xml index 4520cd9e4d406..8082157524ad4 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule4/etc/db_schema.xml +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule4/etc/db_schema.xml @@ -11,7 +11,7 @@ <column xsi:type="int" name="page_id" nullable="false" /> <column xsi:type="varchar" name="email" nullable="false" /> <column xsi:type="varchar" name="title" /> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="page_id" /> <column name="email" /> </constraint> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule4/revisions/remove_title_column/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule4/revisions/remove_title_column/db_schema.xml index 9d868c0168826..0eeff4174870a 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule4/revisions/remove_title_column/db_schema.xml +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule4/revisions/remove_title_column/db_schema.xml @@ -10,7 +10,7 @@ <table name="test_table" resource="default" comment="Test Table"> <column xsi:type="int" name="page_id" nullable="false" /> <column xsi:type="varchar" name="email" nullable="false" /> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="page_id" /> <column name="email" /> </constraint> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule4/revisions/restore_title_column/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule4/revisions/restore_title_column/db_schema.xml index 4520cd9e4d406..8082157524ad4 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule4/revisions/restore_title_column/db_schema.xml +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule4/revisions/restore_title_column/db_schema.xml @@ -11,7 +11,7 @@ <column xsi:type="int" name="page_id" nullable="false" /> <column xsi:type="varchar" name="email" nullable="false" /> <column xsi:type="varchar" name="title" /> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="page_id" /> <column name="email" /> </constraint> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule5/etc/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule5/etc/db_schema.xml index b6ff634e6ef1d..9bd6c438455b2 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule5/etc/db_schema.xml +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule5/etc/db_schema.xml @@ -11,7 +11,7 @@ <column xsi:type="tinyint" name="tinyint_ref" padding="7" nullable="false" identity="true" unsigned="false"/> <column xsi:type="int" name="some_integer" default="0" nullable="false" unsigned="false"/> <column xsi:type="varchar" name="for_patch_testing" comment="For patch testing" /> - <constraint xsi:type="primary" name="tinyint_primary"> + <constraint xsi:type="primary" referenceId="tinyint_primary"> <column name="tinyint_ref"/> </constraint> </table> @@ -21,10 +21,10 @@ <column xsi:type="tinyint" name="tinyint" padding="7" nullable="true" unsigned="false"/> <column xsi:type="varchar" name="varchar" length="254" nullable="true"/> <column xsi:type="varbinary" name="varbinary" default="10101" /> - <constraint xsi:type="foreign" name="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF" + <constraint xsi:type="foreign" referenceId="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF" column="tinyint" table="test_table" referenceTable="reference_table" referenceColumn="tinyint_ref" onDelete="CASCADE"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="smallint" /> </constraint> </table> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule6/etc/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule6/etc/db_schema.xml index 9263004c6e7f6..d6be9376cb4da 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule6/etc/db_schema.xml +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule6/etc/db_schema.xml @@ -21,7 +21,7 @@ <column xsi:type="bigint" name="bigint_default_nullable" padding="2" nullable="true" default="1" unsigned="true"/> <column xsi:type="bigint" name="bigint_not_default_not_nullable" padding="2" nullable="false" unsigned="true"/> - <constraint xsi:type="primary" name="tinyint_primary"> + <constraint xsi:type="primary" referenceId="tinyint_primary"> <column name="tinyint_ref"/> </constraint> </table> @@ -30,7 +30,7 @@ nullable="true"/> <column xsi:type="smallint" name="int_disabled_auto_increment" default="0" identity="false" padding="12" unsigned="true" nullable="true"/> - <constraint xsi:type="unique" name="AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE"> + <constraint xsi:type="unique" referenceId="AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE"> <column name="int_auto_increment_with_nullable"/> </constraint> </table> @@ -53,15 +53,15 @@ <column xsi:type="boolean" name="boolean"/> <column xsi:type="varbinary" name="varbinary_rename" default="10101" disabled="true"/> <!--Constraints--> - <constraint xsi:type="unique" name="TEST_TABLE_SMALLINT_BIGINT"> + <constraint xsi:type="unique" referenceId="TEST_TABLE_SMALLINT_BIGINT"> <column name="smallint"/> <column name="bigint"/> </constraint> - <constraint xsi:type="foreign" name="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF" + <constraint xsi:type="foreign" referenceId="TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF" column="tinyint" table="test_table" referenceTable="reference_table" referenceColumn="tinyint_ref" onDelete="NO ACTION"/> <!--Indexes--> - <index name="TEST_TABLE_TINYINT_BIGINT" indexType="btree"> + <index referenceId="TEST_TABLE_TINYINT_BIGINT" indexType="btree"> <column name="tinyint"/> <column name="bigint"/> </index> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/disable_index_by_external_module/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/disable_index_by_external_module/db_schema.xml new file mode 100644 index 0000000000000..f8860731aa808 --- /dev/null +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/disable_index_by_external_module/db_schema.xml @@ -0,0 +1,13 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd"> + <table name="test_table" resource="default"> + <index referenceId="TEST_TABLE_INDEX_VARCHAR" disabled="1"/> + </table> +</schema> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/disable_index_by_external_module/db_schema_whitelist.json b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/disable_index_by_external_module/db_schema_whitelist.json new file mode 100644 index 0000000000000..a65bb6aab1c43 --- /dev/null +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/disable_index_by_external_module/db_schema_whitelist.json @@ -0,0 +1,7 @@ +{ + "test_table": { + "index": { + "TEST_TABLE_VARCHAR": true + } + } +} diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/disable_index_by_external_module/module.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/disable_index_by_external_module/module.xml new file mode 100644 index 0000000000000..a0b9bbe483bcf --- /dev/null +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/disable_index_by_external_module/module.xml @@ -0,0 +1,14 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> + <module name="Magento_TestSetupDeclarationModule8"> + <sequence> + <module name="Magento_TestSetupDeclarationModule1" /> + </sequence> + </module> +</config> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/incosistence_reference_definition/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/incosistence_reference_definition/db_schema.xml index e39f0a04bcf5f..1b7d0dcb93ce7 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/incosistence_reference_definition/db_schema.xml +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/incosistence_reference_definition/db_schema.xml @@ -9,13 +9,13 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd"> <table name="test_table" resource="default" comment="Test Table"> <column xsi:type="int" name="page_id" nullable="false" unsigned="false" identity="true"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="page_id"/> </constraint> </table> <table name="dependent" resource="default" comment="Lol"> <column xsi:type="int" name="page_id_on" nullable="true" unsigned="true"/> - <constraint xsi:type="foreign" name="FOREIGN" table="dependent" column="page_id_on" referenceColumn="page_id" + <constraint xsi:type="foreign" referenceId="FOREIGN" table="dependent" column="page_id_on" referenceColumn="page_id" referenceTable="test_table"/> </table> </schema> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/invalid_primary_key/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/invalid_primary_key/db_schema.xml index 4ecee62286418..b42d74aea06a1 100644 --- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/invalid_primary_key/db_schema.xml +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/invalid_primary_key/db_schema.xml @@ -11,7 +11,7 @@ <column xsi:type="int" name="page_id" nullable="false" identity="true" /> <column xsi:type="varchar" name="email" nullable="true" /> <column xsi:type="varchar" name="title" /> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="page_id" /> <column name="email" /> </constraint> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/unpatterned_fk_name/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/unpatterned_fk_name/db_schema.xml new file mode 100644 index 0000000000000..eebeb154adf43 --- /dev/null +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/unpatterned_fk_name/db_schema.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd"> + <table name="test_table" resource="default" comment="Test Table"> + <column xsi:type="int" name="page_id" nullable="false" unsigned="false" identity="true"/> + <constraint xsi:type="primary" referenceId="PRIMARY"> + <column name="page_id"/> + </constraint> + </table> + <table name="test_scope_table" resource="default" comment="Test Scope Table"> + <column xsi:type="int" name="scope_id" nullable="false" unsigned="false" identity="true"/> + <constraint xsi:type="primary" referenceId="PRIMARY"> + <column name="scope_id"/> + </constraint> + </table> + <table name="dependent" resource="default" comment="Lol"> + <column xsi:type="int" name="page_id_on" nullable="false" unsigned="false"/> + <column xsi:type="int" name="scope_id_on" nullable="false" unsigned="false"/> + <!-- Expected name in DB: DEPENDENT_PAGE_ID_ON_TEST_TABLE_PAGE_ID --> + <constraint xsi:type="foreign" referenceId="DEPENDENT_PAGE_ID_ON_TEST_TABLE_PAGE_ID" table="dependent" column="page_id_on" referenceColumn="page_id" + referenceTable="test_table"/> + <!-- Expected name in DB: DEPENDENT_SCOPE_ID_ON_TEST_SCOPE_TABLE_SCOPE_ID --> + <constraint xsi:type="foreign" referenceId="ScopeIDOnTOScopeTableAndScopeId" table="dependent" column="scope_id_on" referenceColumn="scope_id" + referenceTable="test_scope_table"/> + </table> +</schema> diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/whitelist_upgrade/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/whitelist_upgrade/db_schema.xml new file mode 100644 index 0000000000000..05ce3318ef73b --- /dev/null +++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule8/revisions/whitelist_upgrade/db_schema.xml @@ -0,0 +1,28 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd"> + <table name="reference_test" resource="default"> + <column xsi:type="smallint" identity="true" name="entity_id" padding="3" nullable="true"/> + <column xsi:type="smallint" identity="true" name="product_id" padding="3" nullable="true"/> + <index referenceId="ENTITY_ID_INDEX" indexType="btree"> + <column name="entity_id"/> + </index> + <constraint xsi:type="unique" referenceId="UNIQUE_PAIR"> + <column name="entity_id"/> + <column name="product_id"/> + </constraint> + <constraint xsi:type="foreign" referenceId="TEST_TABLE_TINYINT_REFERENCE" + column="entity_id" table="reference_test" + referenceTable="test_table" referenceColumn="smallint" onDelete="NO ACTION"/> + </table> + <table name="auto_increment_test" resource="default"> + <column xsi:type="int" name="int_counter" padding="12" unsigned="true" + nullable="true"/> + </table> +</schema> diff --git a/dev/tests/setup-integration/testsuite/Magento/Developer/Console/Command/TablesWhitelistGenerateCommandTest.php b/dev/tests/setup-integration/testsuite/Magento/Developer/Console/Command/TablesWhitelistGenerateCommandTest.php index 77f2d741fc6b5..434c99cb98765 100644 --- a/dev/tests/setup-integration/testsuite/Magento/Developer/Console/Command/TablesWhitelistGenerateCommandTest.php +++ b/dev/tests/setup-integration/testsuite/Magento/Developer/Console/Command/TablesWhitelistGenerateCommandTest.php @@ -11,6 +11,7 @@ use Magento\TestFramework\TestCase\SetupTestCase; use Magento\Framework\Console\Cli; use Magento\TestFramework\Deploy\CliCommand; +use Magento\TestFramework\Deploy\TestModuleManager; /** * The purpose of this test is to verify the declaration:generate:whitelist command. @@ -42,6 +43,11 @@ class TablesWhitelistGenerateCommandTest extends SetupTestCase */ private $cliCommand; + /** + * @var TestModuleManager + */ + private $moduleManager; + /** * {@inheritdoc} */ @@ -56,20 +62,43 @@ public function setUp() ); $this->cliCommand = $this->objectManager->get(CliCommand::class); $this->tester = new CommandTester($this->command); + $this->moduleManager = $this->objectManager->get(TestModuleManager::class); } /** - * Execute generate command for whitelist on module Magento_TestSetupDeclarationModule1. - * - * @param array $expectedWhitelistContent + * Execute generate command for whitelist. * * @moduleName Magento_TestSetupDeclarationModule1 - * @dataProvider contentsDataProvider + * @moduleName Magento_TestSetupDeclarationModule8 + * @throws \Exception + */ + public function testExecute() + { + $modules = [ + 'Magento_TestSetupDeclarationModule1', + 'Magento_TestSetupDeclarationModule8', + ]; + + $this->cliCommand->install($modules); + foreach ($modules as $moduleName) { + $this->moduleManager->updateRevision( + $moduleName, + 'whitelist_upgrade', + 'db_schema.xml', + 'etc' + ); + } + + foreach ($modules as $moduleName) { + $this->checkWhitelistFile($moduleName); + } + } + + /** + * @param string $moduleName */ - public function testExecute(array $expectedWhitelistContent) + private function checkWhitelistFile(string $moduleName) { - $moduleName = 'Magento_TestSetupDeclarationModule1'; - $this->cliCommand->install([$moduleName]); $modulePath = $this->componentRegistrar->getPath('module', $moduleName); $whiteListFileName = $modulePath . DIRECTORY_SEPARATOR @@ -79,124 +108,25 @@ public function testExecute(array $expectedWhitelistContent) //run bin/magento declaration:generate:whitelist Magento_TestSetupDeclarationModule1 command. $this->tester->execute(['--module-name' => $moduleName], ['interactive' => false]); - $this->assertSame(Cli::RETURN_SUCCESS, $this->tester->getStatusCode()); $this->assertFileExists($whiteListFileName); $this->assertContains('', $this->tester->getDisplay()); - $whitelistContent = json_decode(file_get_contents($whiteListFileName), true); - $this->assertEquals($expectedWhitelistContent, $whitelistContent); - } - - /** - * Data provider for whitelist contents. - * - * @return array - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function contentsDataProvider(): array - { - return [ - [ - 'content' => [ - 'reference_table' => - [ - 'column' => - [ - 'tinyint_ref' => true, - 'tinyint_without_padding' => true, - 'bigint_without_padding' => true, - 'integer_without_padding' => true, - 'smallint_with_big_padding' => true, - 'smallint_without_default' => true, - 'int_without_unsigned' => true, - 'int_unsigned' => true, - 'bigint_default_nullable' => true, - 'bigint_not_default_not_nullable' => true, - 'smallint_without_padding' => true, - ], - 'constraint' => - [ - 'tinyint_primary' => true, - ], - ], - 'auto_increment_test' => - [ - 'column' => - [ - 'int_auto_increment_with_nullable' => true, - 'int_disabled_auto_increment' => true, - ], - 'constraint' => - [ - 'AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE' => true, - ], - ], - 'test_table' => - [ - 'column' => - [ - 'smallint' => true, - 'tinyint' => true, - 'bigint' => true, - 'float' => true, - 'double' => true, - 'decimal' => true, - 'date' => true, - 'timestamp' => true, - 'datetime' => true, - 'longtext' => true, - 'mediumtext' => true, - 'varchar' => true, - 'mediumblob' => true, - 'blob' => true, - 'boolean' => true, - 'varbinary_rename' => true, - ], - 'index' => - [ - 'TEST_TABLE_TINYINT_BIGINT' => true, - ], - 'constraint' => - [ - 'TEST_TABLE_SMALLINT_BIGINT' => true, - 'TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF' => true, - ], - ], - 'store' => - [ - 'column' => - [ - 'store_owner_id' => true, - 'store_owner' => true, - ], - 'constraint' => - [ - 'STORE_STORE_OWNER_ID_STORE_OWNER_OWNER_ID' => true, - ], - ], - 'store_owner' => - [ - 'column' => - [ - 'owner_id' => true, - 'label' => true, - ], - 'constraint' => - [ - '' => true, - ], - ], - 'some_table' => - [ - 'column' => - [ - 'some_column' => true, - ], - ], - ], - ], - ]; + $whitelistFileContent = file_get_contents($whiteListFileName); + $expectedWhitelistContent = file_get_contents( + dirname(__DIR__, 2) + . DIRECTORY_SEPARATOR + . implode( + DIRECTORY_SEPARATOR, + [ + '_files', + 'WhitelistGenerate', + str_replace('Magento_', '', $moduleName), + 'db_schema_whitelist.json' + ] + ) + ); + $this->assertEquals($expectedWhitelistContent, $whitelistFileContent); } } diff --git a/dev/tests/setup-integration/testsuite/Magento/Developer/_files/WhitelistGenerate/TestSetupDeclarationModule1/db_schema_whitelist.json b/dev/tests/setup-integration/testsuite/Magento/Developer/_files/WhitelistGenerate/TestSetupDeclarationModule1/db_schema_whitelist.json new file mode 100644 index 0000000000000..55005b82ab8b5 --- /dev/null +++ b/dev/tests/setup-integration/testsuite/Magento/Developer/_files/WhitelistGenerate/TestSetupDeclarationModule1/db_schema_whitelist.json @@ -0,0 +1,80 @@ +{ + "reference_table": { + "column": { + "tinyint_ref": true, + "tinyint_without_padding": true, + "bigint_without_padding": true, + "integer_without_padding": true, + "smallint_with_big_padding": true, + "smallint_without_default": true, + "int_without_unsigned": true, + "int_unsigned": true, + "bigint_default_nullable": true, + "bigint_not_default_not_nullable": true, + "smallint_without_padding": true + }, + "constraint": { + "tinyint_primary": true, + "PRIMARY": true + } + }, + "auto_increment_test": { + "column": { + "int_auto_increment_with_nullable": true, + "int_disabled_auto_increment": true + }, + "constraint": { + "AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE": true + } + }, + "test_table": { + "column": { + "smallint": true, + "tinyint": true, + "bigint": true, + "float": true, + "double": true, + "decimal": true, + "date": true, + "timestamp": true, + "datetime": true, + "longtext": true, + "mediumtext": true, + "varchar": true, + "mediumblob": true, + "blob": true, + "boolean": true, + "varbinary_rename": true + }, + "index": { + "TEST_TABLE_TINYINT_BIGINT": true + }, + "constraint": { + "TEST_TABLE_SMALLINT_BIGINT": true, + "TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF": true + } + }, + "store": { + "column": { + "store_owner_id": true, + "store_owner": true + }, + "constraint": { + "STORE_STORE_OWNER_ID_STORE_OWNER_OWNER_ID": true + } + }, + "store_owner": { + "column": { + "owner_id": true, + "label": true + }, + "constraint": { + "": true + } + }, + "some_table": { + "column": { + "some_column": true + } + } +} \ No newline at end of file diff --git a/dev/tests/setup-integration/testsuite/Magento/Developer/_files/WhitelistGenerate/TestSetupDeclarationModule8/db_schema_whitelist.json b/dev/tests/setup-integration/testsuite/Magento/Developer/_files/WhitelistGenerate/TestSetupDeclarationModule8/db_schema_whitelist.json new file mode 100644 index 0000000000000..b4209edfe471a --- /dev/null +++ b/dev/tests/setup-integration/testsuite/Magento/Developer/_files/WhitelistGenerate/TestSetupDeclarationModule8/db_schema_whitelist.json @@ -0,0 +1,20 @@ +{ + "reference_test": { + "column": { + "entity_id": true, + "product_id": true + }, + "index": { + "REFERENCE_TEST_ENTITY_ID": true + }, + "constraint": { + "REFERENCE_TEST_ENTITY_ID_PRODUCT_ID": true, + "REFERENCE_TEST_ENTITY_ID_TEST_TABLE_SMALLINT": true + } + }, + "auto_increment_test": { + "column": { + "int_counter": true + } + } +} \ No newline at end of file diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php index 34d432e566fec..f6497e8e4b162 100644 --- a/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php +++ b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php @@ -79,8 +79,26 @@ public function testInstallation() //Second time installation should not find anything as we do not change anything self::assertNull($diff->getAll()); + $this->compareStructures(); + } + + /** + * Compare structure of DB and declared structure. + */ + private function compareStructures() + { $shardData = $this->describeTable->describeShard(Sharding::DEFAULT_CONNECTION); - self::assertEquals($this->getTrimmedData(), $shardData); + foreach ($this->getTrimmedData() as $tableName => $sql) { + $this->assertArrayHasKey($tableName, $shardData); + /** + * MySQL 8.0 and above does not provide information about the ON DELETE instruction + * if ON DELETE NO ACTION + */ + if (preg_match('#ON DELETE\s+NO ACTION#i', $shardData[$tableName] === 1)) { + preg_replace('#ON DELETE\s+NO ACTION#i', '', $sql); + self::assertEquals($sql, $shardData[$tableName]); + } + } } /** @@ -110,8 +128,7 @@ public function testInstallationWithColumnsModification() $this->schemaConfig->getDbConfig() ); self::assertNull($diff->getAll()); - $shardData = $this->describeTable->describeShard(Sharding::DEFAULT_CONNECTION); - self::assertEquals($this->getTrimmedData(), $shardData); + $this->compareStructures(); } /** @@ -156,8 +173,7 @@ public function testInstallationWithColumnsRemoval() $this->schemaConfig->getDbConfig() ); self::assertNull($diff->getAll()); - $shardData = $this->describeTable->describeShard(Sharding::DEFAULT_CONNECTION); - self::assertEquals($this->getTrimmedData(), $shardData); + $this->compareStructures(); } /** @@ -296,4 +312,68 @@ public function testTableRename() ->from($this->resourceConnection->getTableName('some_table_renamed')); self::assertEquals([$dataToMigrate], $adapter->fetchAll($select)); } + + /** + * @moduleName Magento_TestSetupDeclarationModule8 + */ + public function testForeignKeyReferenceId() + { + $this->cliCommad->install( + ['Magento_TestSetupDeclarationModule8'] + ); + $this->moduleManager->updateRevision( + 'Magento_TestSetupDeclarationModule8', + 'unpatterned_fk_name', + 'db_schema.xml', + 'etc' + ); + $this->cliCommad->upgrade(); + $tableStatements = $this->describeTable->describeShard('default'); + $tableSql = $tableStatements['dependent']; + $this->assertRegExp('/CONSTRAINT\s`DEPENDENT_PAGE_ID_ON_TEST_TABLE_PAGE_ID`/', $tableSql); + $this->assertRegExp('/CONSTRAINT\s`DEPENDENT_SCOPE_ID_ON_TEST_SCOPE_TABLE_SCOPE_ID`/', $tableSql); + } + + /** + * @moduleName Magento_TestSetupDeclarationModule1 + * @moduleName Magento_TestSetupDeclarationModule8 + */ + public function testDisableIndexByExternalModule() + { + $this->cliCommad->install( + ['Magento_TestSetupDeclarationModule1', 'Magento_TestSetupDeclarationModule8'] + ); + $this->moduleManager->updateRevision( + 'Magento_TestSetupDeclarationModule1', + 'index_to_disable', + 'db_schema.xml', + 'etc' + ); + $this->moduleManager->updateRevision( + 'Magento_TestSetupDeclarationModule8', + 'disable_index_by_external_module', + 'db_schema.xml', + 'etc' + ); + $this->moduleManager->updateRevision( + 'Magento_TestSetupDeclarationModule8', + 'disable_index_by_external_module', + 'db_schema_whitelist.json', + 'etc' + ); + $this->moduleManager->updateRevision( + 'Magento_TestSetupDeclarationModule8', + 'disable_index_by_external_module', + 'module.xml', + 'etc' + ); + $this->cliCommad->upgrade(); + $tableStatements = $this->describeTable->describeShard('default'); + $tableSql = $tableStatements['test_table']; + $this->assertNotRegExp( + '/KEY\s+`TEST_TABLE_VARCHAR`\s+\(`varchar`\)/', + $tableSql, + 'Index is not being disabled by external module' + ); + } } diff --git a/dev/tests/static/framework/Magento/Sniffs/Annotation/AnnotationFormatValidator.php b/dev/tests/static/framework/Magento/Sniffs/Annotation/AnnotationFormatValidator.php index 71ad99bb5c3e0..899a65c375321 100644 --- a/dev/tests/static/framework/Magento/Sniffs/Annotation/AnnotationFormatValidator.php +++ b/dev/tests/static/framework/Magento/Sniffs/Annotation/AnnotationFormatValidator.php @@ -125,7 +125,7 @@ private function validateShortDescriptionFormat( $phpcsFile->addFixableError($error, $shortPtr, 'MethodAnnotation'); } if (strtolower($tokens[$shortPtr]['content']) === '{@inheritdoc}') { - $error = '{@inheritdoc} imports only short description, annotation must have long description'; + $error = 'If the @inheritdoc not inline it shouldn’t have braces'; $phpcsFile->addFixableError($error, $shortPtr, 'MethodAnnotation'); } $shortPtrContent = $tokens[$shortPtr]['content']; diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php index cbf499c8dad38..5bcc712be6f74 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php @@ -712,7 +712,6 @@ 'Magento\Sales\Block\Reorder\Sidebar', '\Magento\Sales\CustomerData\LastOrderedItems::SIDEBAR_ORDER_LIMIT', ], - ['ENTITY', 'Magento\Framework\App\Config\ValueInterface'], ['XML_PATH_ALLOW_CURRENCIES_INSTALLED', 'Magento\Framework\Locale\CurrencyInterface'], [ 'DEFAULT_CURRENCY', diff --git a/lib/internal/Magento/Framework/App/Config/MetadataConfigTypeProcessor.php b/lib/internal/Magento/Framework/App/Config/MetadataConfigTypeProcessor.php index 6eb5fd7e9d3b1..bc23032903d23 100644 --- a/lib/internal/Magento/Framework/App/Config/MetadataConfigTypeProcessor.php +++ b/lib/internal/Magento/Framework/App/Config/MetadataConfigTypeProcessor.php @@ -11,6 +11,9 @@ use Magento\Framework\App\Config\Spi\PostProcessorInterface; use Magento\Framework\App\ObjectManager; +/** + * Post-process config values using their backend models. + */ class MetadataConfigTypeProcessor implements PostProcessorInterface { /** @@ -114,9 +117,14 @@ private function processScopeData( $scopeCode = null ) { foreach ($this->_metadata as $path => $metadata) { - $configPath = $this->configPathResolver->resolve($path, $scope, $scopeCode); - if (!empty($this->configSource->get($configPath))) { - continue; + try { + $configPath = $this->configPathResolver->resolve($path, $scope, $scopeCode); + if (!empty($this->configSource->get($configPath))) { + continue; + } + } catch (\Throwable $exception) { + //Failed to load scopes or config source, perhaps config data received is outdated. + return $data; } /** @var \Magento\Framework\App\Config\Data\ProcessorInterface $processor */ $processor = $this->_processorFactory->get($metadata['backendModel']); diff --git a/lib/internal/Magento/Framework/App/Config/Value.php b/lib/internal/Magento/Framework/App/Config/Value.php index c85b484d51ce2..6fde4dded4695 100644 --- a/lib/internal/Magento/Framework/App/Config/Value.php +++ b/lib/internal/Magento/Framework/App/Config/Value.php @@ -8,6 +8,10 @@ /** * Config data model * + * This model is temporarily marked as API since {@see \Magento\Framework\App\Config\ValueInterface} doesn't fit + * developers' needs of extensibility. In 2.4 we are going to introduce a new interface which should cover all needs + * and deprecate the mentioned together with the model + * * @method string getScope() * @method \Magento\Framework\App\Config\ValueInterface setScope(string $value) * @method int getScopeId() @@ -17,6 +21,8 @@ * @method string getValue() * @method \Magento\Framework\App\Config\ValueInterface setValue(string $value) * + * @api + * * @SuppressWarnings(PHPMD.NumberOfChildren) */ class Value extends \Magento\Framework\Model\AbstractModel implements \Magento\Framework\App\Config\ValueInterface @@ -107,7 +113,7 @@ public function getFieldsetDataValue($key) } /** - * {@inheritdoc} + * Processing object after save data * * {@inheritdoc}. In addition, it sets status 'invalidate' for config caches * @@ -123,7 +129,7 @@ public function afterSave() } /** - * {@inheritdoc} + * Processing object after delete data * * {@inheritdoc}. In addition, it sets status 'invalidate' for config caches * diff --git a/lib/internal/Magento/Framework/App/Config/ValueInterface.php b/lib/internal/Magento/Framework/App/Config/ValueInterface.php index 1e0747acc36f2..0aa600b84dcce 100644 --- a/lib/internal/Magento/Framework/App/Config/ValueInterface.php +++ b/lib/internal/Magento/Framework/App/Config/ValueInterface.php @@ -10,16 +10,22 @@ /** * Interface \Magento\Framework\App\Config\ValueInterface * + * This interface cannot be marked as API since doesn't fit developers' needs of extensibility. In 2.4 we are going + * to introduce a new interface which should cover all needs and deprecate the this one with the model + * {@see \Magento\Framework\App\Config\Value} */ interface ValueInterface { /** * Table name + * + * @deprecated since it is not used */ const ENTITY = 'config_data'; /** * Check if config data value was changed + * * @todo this method should be make as protected * @return bool */ diff --git a/lib/internal/Magento/Framework/Filesystem/Directory/ReadInterface.php b/lib/internal/Magento/Framework/Filesystem/Directory/ReadInterface.php index 5519245ec24b4..61108c64dda44 100644 --- a/lib/internal/Magento/Framework/Filesystem/Directory/ReadInterface.php +++ b/lib/internal/Magento/Framework/Filesystem/Directory/ReadInterface.php @@ -7,7 +7,7 @@ /** * Interface \Magento\Framework\Filesystem\Directory\ReadInterface - * + * @api */ interface ReadInterface { diff --git a/lib/internal/Magento/Framework/Filesystem/Directory/WriteInterface.php b/lib/internal/Magento/Framework/Filesystem/Directory/WriteInterface.php index c72651a78dad3..186cbcb81bff2 100644 --- a/lib/internal/Magento/Framework/Filesystem/Directory/WriteInterface.php +++ b/lib/internal/Magento/Framework/Filesystem/Directory/WriteInterface.php @@ -7,7 +7,7 @@ /** * Interface \Magento\Framework\Filesystem\Directory\WriteInterface - * + * @api */ interface WriteInterface extends ReadInterface { diff --git a/lib/internal/Magento/Framework/Filesystem/File/ReadFactory.php b/lib/internal/Magento/Framework/Filesystem/File/ReadFactory.php index 38b581da752b7..5d9badf42073f 100644 --- a/lib/internal/Magento/Framework/Filesystem/File/ReadFactory.php +++ b/lib/internal/Magento/Framework/Filesystem/File/ReadFactory.php @@ -8,6 +8,10 @@ use Magento\Framework\Filesystem\DriverInterface; use Magento\Framework\Filesystem\DriverPool; +/** + * Opens a file for reading + * @api + */ class ReadFactory { /** @@ -28,7 +32,7 @@ public function __construct(DriverPool $driverPool) } /** - * Create a readable file + * Create a {@see ReaderInterface} * * @param string $path * @param DriverInterface|string $driver Driver or driver code diff --git a/lib/internal/Magento/Framework/Filesystem/File/WriteFactory.php b/lib/internal/Magento/Framework/Filesystem/File/WriteFactory.php index a45d6a62488f6..af2a43ceaedc3 100644 --- a/lib/internal/Magento/Framework/Filesystem/File/WriteFactory.php +++ b/lib/internal/Magento/Framework/Filesystem/File/WriteFactory.php @@ -8,6 +8,10 @@ use Magento\Framework\Filesystem\DriverInterface; use Magento\Framework\Filesystem\DriverPool; +/** + * Opens a file for reading and/or writing + * @api + */ class WriteFactory extends ReadFactory { /** @@ -29,12 +33,12 @@ public function __construct(DriverPool $driverPool) } /** - * Create a readable file. + * Create a {@see WriterInterface} * * @param string $path * @param DriverInterface|string $driver Driver or driver code * @param string $mode [optional] - * @return Write + * @return WriteInterface */ public function create($path, $driver, $mode = 'r') { diff --git a/lib/internal/Magento/Framework/Indexer/IndexStructure.php b/lib/internal/Magento/Framework/Indexer/IndexStructure.php index c9376f00b711e..a39de2d5b8a62 100644 --- a/lib/internal/Magento/Framework/Indexer/IndexStructure.php +++ b/lib/internal/Magento/Framework/Indexer/IndexStructure.php @@ -13,6 +13,12 @@ use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver; use Magento\Framework\Search\Request\Dimension; +/** + * Full text search index structure. + * + * @deprecated + * @see \Magento\ElasticSearch + */ class IndexStructure implements IndexStructureInterface { /** @@ -58,9 +64,7 @@ public function __construct( } /** - * @param string $index - * @param Dimension[] $dimensions - * @return void + * @inheritdoc */ public function delete($index, array $dimensions = []) { @@ -69,10 +73,7 @@ public function delete($index, array $dimensions = []) } /** - * @param string $index - * @param array $fields - * @param Dimension[] $dimensions - * @return void + * @inheritdoc */ public function create($index, array $fields, array $dimensions = []) { @@ -83,6 +84,8 @@ public function create($index, array $fields, array $dimensions = []) } /** + * Create full text index. + * * @param string $tableName * @throws \Zend_Db_Exception * @return void @@ -94,6 +97,8 @@ protected function createFulltextIndex($tableName) } /** + * Configure full text index table. + * * @param Table $table * @return Table */ @@ -129,6 +134,8 @@ protected function configureFulltextTable(Table $table) } /** + * Create flat index. + * * @param string $tableName * @param array $fields * @throws \Zend_Db_Exception @@ -160,6 +167,8 @@ protected function createFlatIndex($tableName, array $fields) } /** + * Drop table. + * * @param AdapterInterface $connection * @param string $tableName * @return void diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Adapter.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Adapter.php index 11bd746eb71e5..897b67d8d46ec 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Adapter.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Adapter.php @@ -14,6 +14,8 @@ /** * MySQL Search Adapter * + * @deprecated + * @see \Magento\ElasticSearch * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Adapter implements AdapterInterface @@ -104,6 +106,8 @@ private function getDocuments(Table $table) } /** + * Get connection. + * * @return false|\Magento\Framework\DB\Adapter\AdapterInterface */ private function getConnection() diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder.php index 47d991274b9e0..4a5802dd44e04 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder.php @@ -15,6 +15,10 @@ use Magento\Framework\Search\RequestInterface; /** + * MySQL search aggregation builder. + * + * @deprecated + * @see \Magento\ElasticSearch * @api */ class Builder @@ -66,6 +70,8 @@ public function __construct( } /** + * Build aggregations. + * * @param RequestInterface $request * @param Table $documentsTable * @param array $documents @@ -77,6 +83,8 @@ public function build(RequestInterface $request, Table $documentsTable, array $d } /** + * Process aggregations. + * * @param RequestInterface $request * @param Table $documentsTable * @param array $documents @@ -102,7 +110,7 @@ private function processAggregations(RequestInterface $request, Table $documents } /** - * Extract document ids + * Extract document ids. * * @param array $documents * @return array @@ -113,7 +121,7 @@ private function extractDocumentIds(array $documents) } /** - * Get document ids + * Get document ids. * * @param Table $documentsTable * @return array @@ -128,7 +136,7 @@ private function getDocumentIds(Table $documentsTable) } /** - * Get Connection + * Get Connection. * * @return AdapterInterface */ diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/BucketInterface.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/BucketInterface.php index 90220676e0068..4fa2474d2258e 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/BucketInterface.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/BucketInterface.php @@ -11,12 +11,16 @@ use Magento\Framework\Search\Request\Dimension; /** - * Interface \Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder\BucketInterface + * MySQL search aggregation bucket builder. * + * @deprecated + * @see \Magento\ElasticSearch */ interface BucketInterface { /** + * Build bucket. + * * @param DataProviderInterface $dataProvider * @param Dimension[] $dimensions * @param RequestBucketInterface $bucket diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Container.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Container.php index cba29ad6287d3..844cfc9f8741d 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Container.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Container.php @@ -5,6 +5,12 @@ */ namespace Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder; +/** + * MySQL search aggregation container builder. + * + * @deprecated + * @see \Magento\ElasticSearch + */ class Container { /** @@ -21,6 +27,8 @@ public function __construct(array $buckets) } /** + * Get bucket by type. + * * @param string $bucketType * @return BucketInterface */ diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Dynamic.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Dynamic.php index 481b2252dbf69..46828ab7a8c73 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Dynamic.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Dynamic.php @@ -12,6 +12,12 @@ use Magento\Framework\Search\Request\Aggregation\DynamicBucket; use Magento\Framework\Search\Request\BucketInterface as RequestBucketInterface; +/** + * MySQL search dynamic aggregation builder. + * + * @deprecated + * @see \Magento\ElasticSearch + */ class Dynamic implements BucketInterface { /** @@ -37,7 +43,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function build( DataProviderInterface $dataProvider, diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Metrics.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Metrics.php index 840f94622183a..e4cdb04052ef2 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Metrics.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Metrics.php @@ -7,6 +7,12 @@ use Magento\Framework\Search\Request\BucketInterface as RequestBucketInterface; +/** + * MySQL search aggregation metrics builder. + * + * @deprecated + * @see \Magento\ElasticSearch + */ class Metrics { /** diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Range.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Range.php index 29fc6806b50e7..aced57c100130 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Range.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Range.php @@ -14,6 +14,12 @@ use Magento\Framework\Search\Request\BucketInterface as RequestBucketInterface; use Magento\Framework\Translate\AdapterInterface; +/** + * MySQL search aggregation range builder. + * + * @deprecated + * @see \Magento\ElasticSearch + */ class Range implements BucketInterface { const GREATER_THAN = '>='; @@ -46,7 +52,7 @@ public function __construct(Metrics $metricsBuilder, ResourceConnection $resourc } /** - * {@inheritdoc} + * @inheritdoc */ public function build( DataProviderInterface $dataProvider, @@ -70,6 +76,8 @@ public function build( } /** + * Generate case. + * * @param Select $select * @param AggregationRange[] $ranges * @return Select diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Term.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Term.php index 78ff7b04fd39c..547526be43ccd 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Term.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Builder/Term.php @@ -9,6 +9,12 @@ use Magento\Framework\Search\Adapter\Mysql\Aggregation\DataProviderInterface; use Magento\Framework\Search\Request\BucketInterface as RequestBucketInterface; +/** + * MySQL search aggregation term builder. + * + * @deprecated + * @see \Magento\ElasticSearch + */ class Term implements BucketInterface { /** @@ -25,7 +31,7 @@ public function __construct(Metrics $metricsBuilder) } /** - * {@inheritdoc} + * @inheritdoc */ public function build( DataProviderInterface $dataProvider, diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/DataProviderContainer.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/DataProviderContainer.php index 6a817bcbddf82..565b5eeef3351 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/DataProviderContainer.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/DataProviderContainer.php @@ -6,6 +6,10 @@ namespace Magento\Framework\Search\Adapter\Mysql\Aggregation; /** + * MySQL search data provider container. + * + * @deprecated + * @see \Magento\ElasticSearch * @api */ class DataProviderContainer @@ -24,6 +28,8 @@ public function __construct(array $dataProviders) } /** + * Get data provider by index name. + * * @param string $indexName * @return DataProviderInterface */ diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/DataProviderInterface.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/DataProviderInterface.php index b18269335bc6f..c251265c694d2 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/DataProviderInterface.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/DataProviderInterface.php @@ -11,8 +11,10 @@ use Magento\Framework\Search\Request\Dimension; /** - * Interface \Magento\Framework\Search\Adapter\Mysql\Aggregation\DataProviderInterface + * MySQL search data provider. * + * @deprecated + * @see \Magento\ElasticSearch */ interface DataProviderInterface { diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Interval.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Interval.php index ed5640d42274f..ba41a535f45c9 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Interval.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Aggregation/Interval.php @@ -8,6 +8,12 @@ use Magento\Framework\DB\Select; use Magento\Framework\Search\Dynamic\IntervalInterface; +/** + * MySQL search aggregation interval. + * + * @deprecated + * @see \Magento\ElasticSearch + */ class Interval implements IntervalInterface { /** @@ -41,7 +47,7 @@ private function getValueFiled() } /** - * {@inheritdoc} + * @inheritdoc * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ public function load($limit, $offset = null, $lower = null, $upper = null) @@ -64,7 +70,7 @@ public function load($limit, $offset = null, $lower = null, $upper = null) } /** - * {@inheritdoc} + * @inheritdoc * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ public function loadPrevious($data, $index, $lower = null) @@ -86,7 +92,7 @@ public function loadPrevious($data, $index, $lower = null) } /** - * {@inheritdoc} + * @inheritdoc * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ public function loadNext($data, $rightIndex, $upper = null) @@ -124,6 +130,8 @@ public function loadNext($data, $rightIndex, $upper = null) } /** + * Convert array values to float. + * * @param array $prices * @return array */ diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php index 4d255705bf7df..756d9edc6fbe1 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/AggregationFactory.php @@ -7,6 +7,9 @@ /** * Aggregation Factory + * + * @deprecated + * @see \Magento\ElasticSearch */ class AggregationFactory { diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/ConditionManager.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ConditionManager.php index 41d6b14b6a477..e56559563c35a 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/ConditionManager.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ConditionManager.php @@ -9,7 +9,11 @@ use Magento\Framework\DB\Adapter\AdapterInterface; /** + * MySQL search condition manager + * * @api + * @deprecated + * @see \Magento\ElasticSearch */ class ConditionManager { @@ -30,6 +34,8 @@ public function __construct(ResourceConnection $resource) } /** + * Wrap query with parentheses. + * * @param string $query * @return string */ @@ -41,6 +47,8 @@ public function wrapBrackets($query) } /** + * Combine multiple queries. + * * @param string[] $queries * @param string $unionOperator * @return string @@ -54,6 +62,8 @@ public function combineQueries(array $queries, $unionOperator) } /** + * Generate query condition. + * * @param string $field * @param string $operator * @param mixed $value diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php index 3ca0e94852a5e..4e8854fad353a 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/DocumentFactory.php @@ -13,7 +13,10 @@ /** * Document Factory + * * @api + * @deprecated + * @see \Magento\ElasticSearch */ class DocumentFactory { diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/Field.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/Field.php index 72495e68a26ff..0a340e7f76dc0 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/Field.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/Field.php @@ -6,6 +6,11 @@ namespace Magento\Framework\Search\Adapter\Mysql\Field; +/** + * @inheritdoc + * @deprecated + * @see \Magento\ElasticSearch + */ class Field implements FieldInterface { /** @@ -36,6 +41,8 @@ public function __construct($column, $attributeId = null, $type = self::TYPE_FUL } /** + * Get column. + * * @return string */ public function getColumn() @@ -44,6 +51,8 @@ public function getColumn() } /** + * Get attribute ID. + * * @return int|null */ public function getAttributeId() @@ -52,6 +61,8 @@ public function getAttributeId() } /** + * Get type. + * * @return int */ public function getType() diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/FieldFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/FieldFactory.php index 9a3c55965740e..066d1832aefbf 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/FieldFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/FieldFactory.php @@ -7,7 +7,11 @@ namespace Magento\Framework\Search\Adapter\Mysql\Field; /** + * MySQL search field factory. + * * @api + * @deprecated + * @see \Magento\ElasticSearch */ class FieldFactory { diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/FieldInterface.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/FieldInterface.php index 5f4e0027a8508..7dc74f39709f9 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/FieldInterface.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/FieldInterface.php @@ -7,8 +7,10 @@ namespace Magento\Framework\Search\Adapter\Mysql\Field; /** - * Interface \Magento\Framework\Search\Adapter\Mysql\Field\FieldInterface + * MySQL search field. * + * @deprecated + * @see \Magento\ElasticSearch */ interface FieldInterface { @@ -16,19 +18,22 @@ interface FieldInterface const TYPE_FULLTEXT = 2; /** - * Get type of index + * Get type of index. + * * @return int */ public function getType(); /** - * Get ID of attribute + * Get ID of attribute. + * * @return int */ public function getAttributeId(); /** - * Get field name + * Get field nam. + * * @return string */ public function getColumn(); diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/Resolver.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/Resolver.php index 5146177783ae2..908d6ccc50746 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/Resolver.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/Resolver.php @@ -5,6 +5,9 @@ */ namespace Magento\Framework\Search\Adapter\Mysql\Field; +/** + * @inheritdoc + */ class Resolver implements ResolverInterface { /** @@ -21,7 +24,7 @@ public function __construct(FieldFactory $fieldFactory) } /** - * {@inheritdoc} + * @inheritdoc */ public function resolve(array $fields) { diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/ResolverInterface.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/ResolverInterface.php index f275c4f1b1c14..5455b91d73020 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/ResolverInterface.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Field/ResolverInterface.php @@ -6,13 +6,15 @@ namespace Magento\Framework\Search\Adapter\Mysql\Field; /** - * Interface \Magento\Framework\Search\Adapter\Mysql\Field\ResolverInterface + * MySQL search field resolver. * + * @deprecated + * @see \Magento\ElasticSearch */ interface ResolverInterface { /** - * Resolve field + * Resolve field. * * @param array $fields * @return FieldInterface[] diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder.php index 80074ffc5e2b9..ce02bef244fbb 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder.php @@ -15,6 +15,7 @@ use Magento\Framework\Search\Request\Query\BoolExpression; /** + * @inheritdoc * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Builder implements BuilderInterface @@ -58,7 +59,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function build(RequestFilterInterface $filter, $conditionType) { @@ -66,6 +67,8 @@ public function build(RequestFilterInterface $filter, $conditionType) } /** + * Process filter. + * * @param RequestFilterInterface $filter * @param bool $isNegation * @return string @@ -87,6 +90,8 @@ private function processFilter(RequestFilterInterface $filter, $isNegation) } /** + * Process boolean filter. + * * @param RequestFilterInterface|\Magento\Framework\Search\Request\Filter\Bool $filter * @param bool $isNegation * @return string @@ -111,6 +116,8 @@ private function processBoolFilter(RequestFilterInterface $filter, $isNegation) } /** + * Build filters. + * * @param \Magento\Framework\Search\Request\FilterInterface[] $filters * @param string $unionOperator * @param bool $isNegation @@ -127,6 +134,8 @@ private function buildFilters(array $filters, $unionOperator, $isNegation) } /** + * Check if condition type is 'negative'. + * * @param string $conditionType * @return bool */ diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/FilterInterface.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/FilterInterface.php index 787866a2bca38..6f8b63955a0c1 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/FilterInterface.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/FilterInterface.php @@ -8,12 +8,16 @@ use Magento\Framework\Search\Request\FilterInterface as RequestFilterInterface; /** - * Interface \Magento\Framework\Search\Adapter\Mysql\Filter\Builder\FilterInterface + * MySQL search filter builder. * + * @deprecated + * @see \Magento\ElasticSearch */ interface FilterInterface { /** + * Build filter. + * * @param RequestFilterInterface $filter * @param bool $isNegation * @return string diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Range.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Range.php index d4ee9542c5934..d14bfdcb548d3 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Range.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Range.php @@ -9,6 +9,12 @@ use Magento\Framework\Search\Request\Filter\Range as RangeFilterRequest; use Magento\Framework\Search\Request\FilterInterface as RequestFilterInterface; +/** + * Range filter builder. + * + * @deprecated + * @see \Magento\ElasticSearch + */ class Range implements FilterInterface { const CONDITION_PART_GREATER_THAN = '>='; @@ -31,7 +37,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function buildFilter( RequestFilterInterface $filter, @@ -48,6 +54,8 @@ public function buildFilter( } /** + * Get left condition filter part. + * * @param RequestFilterInterface|RangeFilterRequest $filter * @param bool $isNegation * @return string @@ -62,6 +70,8 @@ private function getLeftConditionPart(RequestFilterInterface $filter, $isNegatio } /** + * Get right condition filter part. + * * @param RequestFilterInterface|RangeFilterRequest $filter * @param bool $isNegation * @return string @@ -76,6 +86,8 @@ private function getRightConditionPart(RequestFilterInterface $filter, $isNegati } /** + * Get filter part. + * * @param string $field * @param string $operator * @param string $value @@ -89,6 +101,8 @@ private function getPart($field, $operator, $value) } /** + * Get condition union operator. + * * @param bool $isNegation * @return string */ diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Term.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Term.php index 3ac755de2b8a3..c89ef50f3cb35 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Term.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Term.php @@ -8,6 +8,12 @@ use Magento\Framework\Search\Adapter\Mysql\ConditionManager; use Magento\Framework\Search\Request\FilterInterface as RequestFilterInterface; +/** + * Term filter builder. + * + * @deprecated + * @see \Magento\ElasticSearch + */ class Term implements FilterInterface { const CONDITION_OPERATOR_EQUALS = '='; @@ -30,7 +36,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function buildFilter( RequestFilterInterface $filter, @@ -46,6 +52,8 @@ public function buildFilter( } /** + * Get condition operator. + * * @param string|array $value * @param bool $isNegation * @return string diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Wildcard.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Wildcard.php index 308d1d564301d..9a2776ac20b2c 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Wildcard.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Builder/Wildcard.php @@ -7,6 +7,12 @@ use Magento\Framework\Search\Adapter\Mysql\ConditionManager; +/** + * Wildcard filter builder. + * + * @deprecated + * @see \Magento\ElasticSearch + */ class Wildcard implements FilterInterface { const CONDITION_LIKE = 'LIKE'; @@ -27,7 +33,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function buildFilter( \Magento\Framework\Search\Request\FilterInterface $filter, diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/BuilderInterface.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/BuilderInterface.php index ec3b88ad24507..3da989333d668 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/BuilderInterface.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/BuilderInterface.php @@ -8,12 +8,16 @@ use Magento\Framework\Search\Request\FilterInterface as RequestFilterInterface; /** - * Interface \Magento\Framework\Search\Adapter\Mysql\Filter\BuilderInterface + * MySQL search filter builder. * + * @deprecated + * @see \Magento\ElasticSearch */ interface BuilderInterface { /** + * Buil filter. + * * @param RequestFilterInterface $filter * @param string $conditionType * @return string diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Preprocessor.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Preprocessor.php index a8bb8e255f2cb..32d134cfe8d6d 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Preprocessor.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/Preprocessor.php @@ -8,6 +8,9 @@ use Magento\Framework\Search\Adapter\Mysql\ConditionManager; use Magento\Framework\Search\Request\FilterInterface; +/** + * @inheritdoc + */ class Preprocessor implements PreprocessorInterface { /** @@ -24,7 +27,7 @@ public function __construct(ConditionManager $conditionManager) } /** - * {@inheritdoc} + * @inheritdoc */ public function process(FilterInterface $filter, $isNegation, $query) { diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/PreprocessorInterface.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/PreprocessorInterface.php index 430b775337b7f..eb0bbc6f3b563 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/PreprocessorInterface.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Filter/PreprocessorInterface.php @@ -8,12 +8,16 @@ use Magento\Framework\Search\Request\FilterInterface; /** - * Interface \Magento\Framework\Search\Adapter\Mysql\Filter\PreprocessorInterface + * MySQL search filter pre-processor. * + * @deprecated + * @see \Magento\ElasticSearch */ interface PreprocessorInterface { /** + * Process filter. + * * @param FilterInterface $filter * @param bool $isNegation * @param string $query diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/IndexBuilderInterface.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/IndexBuilderInterface.php index 73c20406f35df..fbd35455c2294 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/IndexBuilderInterface.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/IndexBuilderInterface.php @@ -10,6 +10,9 @@ /** * Build base Query for Index + * + * @deprecated + * @see \Magento\ElasticSearch */ interface IndexBuilderInterface { diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Mapper.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Mapper.php index fb4ff5d298c12..e97a6690dbcc2 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Mapper.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Mapper.php @@ -22,8 +22,11 @@ /** * Mapper class. Maps library request to specific adapter dependent query + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @deprecated + * @see \Magento\ElasticSearch */ class Mapper { @@ -344,6 +347,8 @@ private function processFilterQuery( } /** + * Add match queries to select. + * * @param RequestInterface $request * @param QueryContainer $queryContainer * @param ScoreBuilder $scoreBuilder @@ -380,6 +385,8 @@ private function addDerivedQueries( } /** + * Get connection. + * * @return false|\Magento\Framework\DB\Adapter\AdapterInterface */ private function getConnection() @@ -388,6 +395,8 @@ private function getConnection() } /** + * Add match queries to select. + * * @param RequestInterface $request * @param Select $select * @param IndexBuilderInterface $indexBuilder @@ -424,6 +433,8 @@ private function addMatchQueries( } /** + * Join previous result to select. + * * @param Select $query * @param Table $previousResultTable * @param ScoreBuilder $scoreBuilder diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/Match.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/Match.php index 8e3758817adf0..fb44e4037bcf7 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/Match.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/Match.php @@ -15,7 +15,11 @@ use Magento\Framework\Search\Adapter\Preprocessor\PreprocessorInterface; /** + * MySQL search query match. + * * @api + * @deprecated + * @see \Magento\ElasticSearch */ class Match implements QueryInterface { @@ -69,7 +73,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function build( ScoreBuilder $scoreBuilder, @@ -113,6 +117,8 @@ public function build( } /** + * Prepare query. + * * @param string $queryValue * @param string $conditionType * @return string diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/QueryInterface.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/QueryInterface.php index a2446264d48d7..6796a1f995e4f 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/QueryInterface.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/QueryInterface.php @@ -8,12 +8,16 @@ use Magento\Framework\Search\Adapter\Mysql\ScoreBuilder; /** - * Interface \Magento\Framework\Search\Adapter\Mysql\Query\Builder\QueryInterface + * MySQL search query builder. * + * @deprecated + * @see \Magento\ElasticSearch */ interface QueryInterface { /** + * Build query. + * * @param \Magento\Framework\Search\Adapter\Mysql\ScoreBuilder $scoreBuilder * @param \Magento\Framework\DB\Select $select * @param \Magento\Framework\Search\Request\QueryInterface $query diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/MatchContainer.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/MatchContainer.php index b694cd48a07af..6ed3338c040e2 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/MatchContainer.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/MatchContainer.php @@ -10,6 +10,12 @@ // @codeCoverageIgnore +/** + * MySQL search query match container. + * + * @deprecated + * @see \Magento\ElasticSearch + */ class MatchContainer { /** @@ -34,6 +40,8 @@ public function __construct(QueryInterface $request, $conditionType) } /** + * Get request. + * * @return QueryInterface */ public function getRequest() @@ -42,6 +50,8 @@ public function getRequest() } /** + * Get condition type. + * * @return string */ public function getConditionType() diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/MatchContainerFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/MatchContainerFactory.php index ba103e060ae7c..cb10de7bdcbbc 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/MatchContainerFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/MatchContainerFactory.php @@ -7,6 +7,9 @@ /** * MatchContainer Factory + * + * @deprecated + * @see \Magento\ElasticSearch */ class MatchContainerFactory { diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/QueryContainer.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/QueryContainer.php index be8507838e44f..9161a30f9bc51 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/QueryContainer.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/QueryContainer.php @@ -9,6 +9,12 @@ use Magento\Framework\DB\Select; use Magento\Framework\Search\Request\QueryInterface as RequestQueryInterface; +/** + * MySQL search query container. + * + * @deprecated + * @see \Magento\ElasticSearch + */ class QueryContainer { const DERIVED_QUERY_PREFIX = 'derived_'; @@ -32,6 +38,8 @@ public function __construct(MatchContainerFactory $matchContainerFactory) } /** + * Add query to select. + * * @param Select $select * @param RequestQueryInterface $query * @param string $conditionType @@ -54,6 +62,8 @@ public function addMatchQuery( } /** + * Get queries. + * * @return MatchContainer[] */ public function getMatchQueries() diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/QueryContainerFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/QueryContainerFactory.php index 70fefec13dd88..59ee4bb045b2a 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/QueryContainerFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/QueryContainerFactory.php @@ -7,6 +7,9 @@ /** * MatchContainer Factory + * + * @deprecated + * @see \Magento\ElasticSearch */ class QueryContainerFactory { diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php index 8a269d8d95bc2..776dab93c2dcd 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ResponseFactory.php @@ -7,6 +7,9 @@ /** * Response Factory + * + * @deprecated + * @see \Magento\ElasticSearch */ class ResponseFactory { diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilder.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilder.php index 190d3a04ed210..1cc417f891c19 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilder.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilder.php @@ -9,6 +9,8 @@ * Class for generating sql condition for calculating store manager * * @api + * @deprecated + * @see \Magento\ElasticSearch */ class ScoreBuilder { diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderFactory.php index 4a7612fcc3042..70aa749fd859f 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/ScoreBuilderFactory.php @@ -7,6 +7,9 @@ /** * ScoreBuilder Factory + * + * @deprecated + * @see \Magento\ElasticSearch */ class ScoreBuilderFactory { diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/TemporaryStorage.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/TemporaryStorage.php index dcb977bfa2ae8..60ee2d5706067 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/TemporaryStorage.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/TemporaryStorage.php @@ -13,7 +13,11 @@ use Magento\Framework\DB\Select; /** + * MySQL search temporary storage. + * * @api + * @deprecated + * @see \Magento\ElasticSearch */ class TemporaryStorage { @@ -100,6 +104,8 @@ private function populateTemporaryTable(Table $table, $data) } /** + * Store select results in temporary table. + * * @param Select $select * @return Table * @throws \Zend_Db_Exception @@ -112,6 +118,8 @@ public function storeDocumentsFromSelect(Select $select) } /** + * Get connection. + * * @return false|AdapterInterface */ private function getConnection() @@ -120,6 +128,8 @@ private function getConnection() } /** + * Create temporary table for search select results. + * * @return Table * @throws \Zend_Db_Exception */ diff --git a/lib/internal/Magento/Framework/Search/Adapter/Mysql/TemporaryStorageFactory.php b/lib/internal/Magento/Framework/Search/Adapter/Mysql/TemporaryStorageFactory.php index 4a282faf317ce..208f6b39b9eb4 100644 --- a/lib/internal/Magento/Framework/Search/Adapter/Mysql/TemporaryStorageFactory.php +++ b/lib/internal/Magento/Framework/Search/Adapter/Mysql/TemporaryStorageFactory.php @@ -12,6 +12,8 @@ * * @codeCoverageIgnore * @api + * @deprecated + * @see \Magento\ElasticSearch */ class TemporaryStorageFactory { diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Config/Converter.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Config/Converter.php index ed3f6326cd604..149ad996a5fc4 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Config/Converter.php +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Config/Converter.php @@ -5,6 +5,8 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Framework\Setup\Declaration\Schema\Config; /** @@ -23,7 +25,7 @@ class Converter implements \Magento\Framework\Config\ConverterInterface * @param \DOMDocument $source * @return array */ - public function convert($source) + public function convert($source): array { $output = $this->recursiveConvert($this->getTablesNode($source)); return $output; @@ -37,7 +39,7 @@ public function convert($source) * @param \DOMDocument $element * @return \DOMNodeList */ - private function getTablesNode(\DOMDocument $element) + private function getTablesNode(\DOMDocument $element): \DOMNodeList { return $element->getElementsByTagName('table'); } @@ -48,21 +50,21 @@ private function getTablesNode(\DOMDocument $element) * @param \Traversable $source * @return array */ - private function recursiveConvert(\Traversable $source) + private function recursiveConvert(\Traversable $source): array { $output = []; foreach ($source as $element) { if ($element instanceof \DOMElement) { - $key = $element->getAttribute('name'); + $key = $this->getIdAttributeValue($element); if ($element->hasChildNodes()) { $output[$element->tagName][$key] = array_replace( $this->recursiveConvert($element->childNodes), - $this->interpretateAttributes($element) + $this->interpretAttributes($element) ); - } else if ($this->hasAttributesExceptName($element)) { - $output[$element->tagName][$key] = $this->interpretateAttributes($element); + } elseif ($this->hasAttributesExceptIdAttribute($element)) { + $output[$element->tagName][$key] = $this->interpretAttributes($element); } else { $output[$element->tagName][$key] = $key; } @@ -73,25 +75,48 @@ private function recursiveConvert(\Traversable $source) } /** - * Check whether we have any attributes except name XSI:TYPE is in another namespace. - * Note: name is mandatory attribute. + * Provide the value of the ID attribute for each element. + * + * @param \DOMElement $element + * @return string + */ + private function getIdAttributeValue(\DOMElement $element): string + { + $idAttributeValue = ''; + switch ($element->tagName) { + case ('table'): + case ('column'): + $idAttributeValue = $element->getAttribute('name'); + break; + case ('index'): + case ('constraint'): + $idAttributeValue = $element->getAttribute('referenceId'); + break; + } + + return $idAttributeValue; + } + + /** + * Check whether we have any attributes except ID attribute. * * @param \DOMElement $element * @return bool */ - private function hasAttributesExceptName(\DOMElement $element) + private function hasAttributesExceptIdAttribute(\DOMElement $element) { return $element->hasAttribute('xsi:type') || $element->attributes->length >= 2; } /** * Mix attributes that comes from XML schema with default ones. + * * So if you will not have some attribute in schema - it will be taken from default one. * * @param \DOMElement $domElement - * @return mixed + * @return array */ - private function interpretateAttributes(\DOMElement $domElement) + private function interpretAttributes(\DOMElement $domElement): array { $attributes = $this->getAttributes($domElement); $xsiType = $domElement->getAttribute('xsi:type'); @@ -109,7 +134,7 @@ private function interpretateAttributes(\DOMElement $domElement) * @param \DOMElement $element * @return array */ - private function getAttributes(\DOMElement $element) + private function getAttributes(\DOMElement $element): array { $attributes = []; $attributeNodes = $element->attributes; diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Config/SchemaLocator.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Config/SchemaLocator.php deleted file mode 100644 index 5319c469f0458..0000000000000 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Config/SchemaLocator.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Framework\Setup\Declaration\Schema\Config; - -/** - * This is system class that provides .xsd file for validation XML schema. - */ -class SchemaLocator implements \Magento\Framework\Config\SchemaLocatorInterface -{ - /** - * Path to corresponding XSD file with validation rules for merged config. - * - * @var string - */ - protected $_schema = null; - - /** - * Path to corresponding XSD file with validation rules for separate config files. - * - * @var string - */ - protected $_perFileSchema = null; - - /** - * Constructor. - * - * @param \Magento\Framework\Config\Dom\UrnResolver $urnResolver - * @param string $schemaUrn - */ - public function __construct( - \Magento\Framework\Config\Dom\UrnResolver $urnResolver, - $schemaUrn = 'urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd' - ) { - $this->_schema = $urnResolver->getRealPath($schemaUrn); - $this->_perFileSchema = $this->_schema; - } - - /** - * Get path to merged config schema. - * - * @return string|null - */ - public function getSchema() - { - return $this->_schema; - } - - /** - * Get path to pre file validation schema. - * - * @return string|null - */ - public function getPerFileSchema() - { - return $this->_perFileSchema; - } -} diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/MySQL/Definition/Constraints/ForeignKey.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/MySQL/Definition/Constraints/ForeignKey.php index 1a9b42355f5e2..6d11542bb49d3 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/MySQL/Definition/Constraints/ForeignKey.php +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/MySQL/Definition/Constraints/ForeignKey.php @@ -43,7 +43,6 @@ public function __construct(ResourceConnection $resourceConnection) } /** - * @param Reference $foreignKey * @inheritdoc */ public function toDefinition(ElementInterface $foreignKey) @@ -95,7 +94,7 @@ public function fromDefinition(array $data) 'column' => $match[2], 'referenceTable' => $match[5], 'referenceColumn' => $match[6], - 'onDelete' => isset($match[7]) ? $match[8] : '' + 'onDelete' => isset($match[7]) ? $match[8] : 'NO ACTION' ]; } } diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Declaration/SchemaBuilder.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Declaration/SchemaBuilder.php index 830fcb293a8f1..34a99f26a4ef1 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Declaration/SchemaBuilder.php +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Declaration/SchemaBuilder.php @@ -3,11 +3,12 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Framework\Setup\Declaration\Schema\Declaration; -use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\Phrase; -use Magento\Framework\Setup\Declaration\Schema\TableNameResolver; +use Magento\Framework\Setup\Declaration\Schema\Declaration\TableElement\ElementNameResolver; use Magento\Framework\Stdlib\BooleanUtils; use Magento\Framework\Setup\Exception; use Magento\Framework\Setup\Declaration\Schema\Dto\Column; @@ -19,8 +20,7 @@ use Magento\Framework\Setup\Declaration\Schema\Sharding; /** - * This type of builder is responsible for converting ENTIRE data, that comes from XML - * into DTO`s format, with aggregation root: Schema. + * This type of builder is responsible for converting ENTIRE data, that comes from XML into DTO`s format. * * Note: SchemaBuilder can not be used for one structural element, like column or constraint * because it should have references to other DTO objects. @@ -69,9 +69,9 @@ class SchemaBuilder private $resourceConnection; /** - * @var TableNameResolver + * @var ElementNameResolver */ - private $tableNameResolver; + private $elementNameResolver; /** * SchemaBuilder constructor. @@ -81,8 +81,7 @@ class SchemaBuilder * @param Sharding $sharding * @param ValidationComposite $validationComposite * @param \Magento\Framework\App\ResourceConnection $resourceConnection - * @param TableNameResolver $tableNameResolver - * @internal param array $tablesData + * @param ElementNameResolver $elementNameResolver */ public function __construct( ElementFactory $elementFactory, @@ -90,18 +89,19 @@ public function __construct( Sharding $sharding, ValidationComposite $validationComposite, \Magento\Framework\App\ResourceConnection $resourceConnection, - TableNameResolver $tableNameResolver + ElementNameResolver $elementNameResolver ) { $this->sharding = $sharding; $this->elementFactory = $elementFactory; $this->booleanUtils = $booleanUtils; $this->validationComposite = $validationComposite; $this->resourceConnection = $resourceConnection; - $this->tableNameResolver = $tableNameResolver; + $this->elementNameResolver = $elementNameResolver; } /** * Add tables data to builder. + * * Tables data holds tables information: columns, constraints, indexes, attributes. * * @param array $tablesData @@ -140,7 +140,7 @@ private function validate(Schema $schema) * @throws Exception * @return Schema */ - public function build(Schema $schema) + public function build(Schema $schema): Schema { foreach ($this->tablesData as $tableData) { if (!$schema->getTableByName($tableData['name'])) { @@ -161,7 +161,7 @@ public function build(Schema $schema) * @param array $tableData * @return string */ - private function getStructuralElementResource(array $tableData) + private function getStructuralElementResource(array $tableData): string { return isset($tableData['resource']) && $this->sharding->canUseResource($tableData['resource']) ? $tableData['resource'] : 'default'; @@ -173,7 +173,7 @@ private function getStructuralElementResource(array $tableData) * @param array $structuralElementData * @return bool */ - private function isDisabled($structuralElementData) + private function isDisabled(array $structuralElementData): bool { return isset($structuralElementData['disabled']) && $this->booleanUtils->toBoolean($structuralElementData['disabled']); @@ -181,14 +181,15 @@ private function isDisabled($structuralElementData) /** * Instantiate column DTO objects from array. + * * If column was renamed new key will be associated to it. * - * @param array $tableData - * @param string $resource - * @param Table $table + * @param array $tableData + * @param string $resource + * @param Table $table * @return array */ - private function processColumns(array $tableData, $resource, Table $table) + private function processColumns(array $tableData, string $resource, Table $table): array { $columns = []; @@ -208,12 +209,12 @@ private function processColumns(array $tableData, $resource, Table $table) /** * Process generic data that is support by all 3 child types: columns, constraints, indexes. * - * @param array $elementData - * @param Table $table - * @param $resource + * @param array $elementData + * @param string $resource + * @param Table $table * @return array */ - private function processGenericData(array $elementData, $resource, Table $table) + private function processGenericData(array $elementData, string $resource, Table $table): array { $elementData['table'] = $table; $elementData['resource'] = $resource; @@ -223,13 +224,14 @@ private function processGenericData(array $elementData, $resource, Table $table) /** * Process tables and add them to schema. + * * If table already exists - then we need to skip it. * * @param Schema $schema - * @param array $tableData - * @return \Magento\Framework\Setup\Declaration\Schema\Dto\Table + * @param array $tableData + * @return Table */ - private function processTable(Schema $schema, array $tableData) + private function processTable(Schema $schema, array $tableData): Table { if (!$schema->getTableByName($tableData['name'])) { $resource = $this->getStructuralElementResource($tableData); @@ -250,11 +252,13 @@ private function processTable(Schema $schema, array $tableData) } /** + * Provides column by name. + * * @param string $columnName * @param Table $table * @return Column */ - private function getColumnByName(string $columnName, Table $table) + private function getColumnByName(string $columnName, Table $table): Column { $columnCandidate = $table->getColumnByName($columnName); @@ -274,7 +278,7 @@ private function getColumnByName(string $columnName, Table $table) * @param Table $table * @return array */ - private function convertColumnNamesToObjects(array $columnNames, Table $table) + private function convertColumnNamesToObjects(array $columnNames, Table $table): array { $columns = []; @@ -285,44 +289,15 @@ private function convertColumnNamesToObjects(array $columnNames, Table $table) return $columns; } - /** - * Provides the full index name based on the prefix value. - * - * @param string $name - * @param Table $table - * @param array $columns - * @param string $type - * @return string - */ - private function getFullIndexName( - string $name, - Table $table, - array $columns, - string $type = AdapterInterface::INDEX_TYPE_INDEX - ) { - if (AdapterInterface::INDEX_TYPE_PRIMARY === $type) { - return $name; - } - - $tableName = $this->tableNameResolver->getNameOfOriginTable($table->getName()); - - return $this->resourceConnection - ->getIdxName( - $tableName, - $columns, - $type - ); - } - /** * Convert and instantiate index objects. * - * @param array $tableData - * @param $resource - * @param Table $table + * @param array $tableData + * @param string $resource + * @param Table $table * @return Index[] */ - private function processIndexes(array $tableData, $resource, Table $table) + private function processIndexes(array $tableData, string $resource, Table $table): array { if (!isset($tableData['index'])) { return []; @@ -335,20 +310,10 @@ private function processIndexes(array $tableData, $resource, Table $table) continue; } - /** - * Temporary solution. - * @see MAGETWO-91365 - */ - $indexType = AdapterInterface::INDEX_TYPE_INDEX; - if (isset($indexData['indexType']) && $indexData['indexType'] === AdapterInterface::INDEX_TYPE_FULLTEXT) { - $indexType = $indexData['indexType']; - } - - $indexData['name'] = $this->getFullIndexName( - $indexData['name'], + $indexData['name'] = $this->elementNameResolver->getFullIndexName( $table, $indexData['column'], - $indexType + $indexData['indexType'] ?? null ); $indexData = $this->processGenericData($indexData, $resource, $table); $indexData['columns'] = $this->convertColumnNamesToObjects($indexData['column'], $table); @@ -363,12 +328,12 @@ private function processIndexes(array $tableData, $resource, Table $table) * Convert and instantiate constraint objects. * * @param array $tableData - * @param $resource + * @param string $resource * @param Schema $schema * @param Table $table * @return Constraint[] */ - private function processConstraints(array $tableData, $resource, Schema $schema, Table $table) + private function processConstraints(array $tableData, string $resource, Schema $schema, Table $table): array { if (!isset($tableData['constraint'])) { return []; @@ -408,21 +373,16 @@ private function processConstraints(array $tableData, $resource, Schema $schema, $constraintData['referenceColumn'], $constraintData['referenceTable'] ); - /** - * Calculation of the full name of Foreign Key based on the prefix value. - */ - $constraintData['name'] = $this->resourceConnection - ->getFkName( - $this->tableNameResolver->getNameOfOriginTable($table->getName()), - $constraintData['column']->getName(), - $constraintData['referenceTable']->getName(), - $constraintData['referenceColumn']->getName() - ); + $constraintData['name'] = $this->elementNameResolver->getFullFKName( + $table, + $constraintData['column'], + $constraintData['referenceTable'], + $constraintData['referenceColumn'] + ); $constraint = $this->elementFactory->create($constraintData['type'], $constraintData); $constraints[$constraint->getName()] = $constraint; } else { - $constraintData['name'] = $this->getFullIndexName( - $constraintData['name'], + $constraintData['name'] = $this->elementNameResolver->getFullIndexName( $table, $constraintData['column'], $constraintData['type'] diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Declaration/TableElement/ElementNameResolver.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Declaration/TableElement/ElementNameResolver.php new file mode 100644 index 0000000000000..fe7d1a822dae1 --- /dev/null +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Declaration/TableElement/ElementNameResolver.php @@ -0,0 +1,188 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Setup\Declaration\Schema\Declaration\TableElement; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\Setup\Declaration\Schema\Dto\Column; +use Magento\Framework\Setup\Declaration\Schema\Dto\Table; +use Magento\Framework\Setup\Declaration\Schema\TableNameResolver; + +/** + * Provide names of table elements with autogenerated names. + */ +class ElementNameResolver +{ + /** + * @var TableNameResolver + */ + private $tableNameResolver; + + /** + * @var ResourceConnection + */ + private $resourceConnection; + + /** + * @param TableNameResolver $tableNameResolver + * @param ResourceConnection $resourceConnection + */ + public function __construct(TableNameResolver $tableNameResolver, ResourceConnection $resourceConnection) + { + $this->tableNameResolver = $tableNameResolver; + $this->resourceConnection = $resourceConnection; + } + + /** + * Provide the full index name based on the prefix value. + * + * @param Table $table + * @param string[] $columns + * @param string $type + * @return string + */ + public function getFullIndexName( + Table $table, + array $columns, + ?string $type = AdapterInterface::INDEX_TYPE_INDEX + ): string { + if (AdapterInterface::INDEX_TYPE_PRIMARY === $type) { + return strtoupper(AdapterInterface::INDEX_TYPE_PRIMARY); + } + + /** + * Temporary solution. + * @see MAGETWO-91365 + */ + $isIndexTypeOutOfList = false === array_search( + $type, + [AdapterInterface::INDEX_TYPE_FULLTEXT, AdapterInterface::INDEX_TYPE_UNIQUE] + ); + if ($type && $isIndexTypeOutOfList) { + $type = AdapterInterface::INDEX_TYPE_INDEX; + } + + $tableName = $this->tableNameResolver->getNameOfOriginTable($table->getName()); + + return $this->resourceConnection + ->getIdxName( + $tableName, + $columns, + $type + ); + } + + /** + * Provide the index name without prefix value. + * + * @param string $name + * @param Table $table + * @param string[] $columns + * @param string $type + * @return string + */ + public function getIndexNameWithoutPrefix( + string $name, + Table $table, + array $columns, + ?string $type = AdapterInterface::INDEX_TYPE_INDEX + ): string { + if (AdapterInterface::INDEX_TYPE_PRIMARY === $type) { + return strtoupper(AdapterInterface::INDEX_TYPE_PRIMARY); + } + + $nameWithoutPrefix = $name; + + if ($this->resourceConnection->getTablePrefix()) { + /** + * Temporary solution. + * @see MAGETWO-91365 + */ + $isIndexTypeOutOfList = false === array_search( + $type, + [AdapterInterface::INDEX_TYPE_FULLTEXT, AdapterInterface::INDEX_TYPE_UNIQUE] + ); + if ($type && $isIndexTypeOutOfList) { + $type = AdapterInterface::INDEX_TYPE_INDEX; + } + + $nameWithoutPrefix = $this->resourceConnection + ->getConnection($table->getResource()) + ->getIndexName( + $this->tableNameResolver->getNameOfOriginTable( + $table->getNameWithoutPrefix() + ), + $columns, + $type + ); + } + + return $nameWithoutPrefix; + } + + /** + * Provide the full foreign key name based on the prefix value. + * + * @param Table $table + * @param Column $column + * @param Table $referenceTable + * @param Column $referenceColumn + * @return string + */ + public function getFullFKName( + Table $table, + Column $column, + Table $referenceTable, + Column $referenceColumn + ): string { + $fkName = $this->resourceConnection + ->getFkName( + $this->tableNameResolver->getNameOfOriginTable($table->getName()), + $column->getName(), + $referenceTable->getName(), + $referenceColumn->getName() + ); + + return $fkName; + } + + /** + * Provide the foreign key name without prefix value. + * + * @param string $name + * @param Table $table + * @param Column $column + * @param Table $referenceTable + * @param Column $referenceColumn + * @return string + */ + public function getFKNameWithoutPrefix( + string $name, + Table $table, + Column $column, + Table $referenceTable, + Column $referenceColumn + ): string { + $nameWithoutPrefix = $name; + + if ($this->resourceConnection->getTablePrefix()) { + $nameWithoutPrefix = $this->resourceConnection + ->getConnection($table->getResource()) + ->getForeignKeyName( + $this->tableNameResolver->getNameOfOriginTable( + $table->getNameWithoutPrefix() + ), + $column->getName(), + $referenceTable->getNameWithoutPrefix(), + $referenceColumn->getName() + ); + } + + return $nameWithoutPrefix; + } +} diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Foreign.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Foreign.php index 0e1ad0768c4da..040549a5611ca 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Foreign.php +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Foreign.php @@ -7,6 +7,7 @@ use Magento\Framework\App\ResourceConnection; use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Setup\Declaration\Schema\Declaration\TableElement\ElementNameResolver; use Magento\Framework\Setup\Declaration\Schema\TableNameResolver; /** @@ -39,28 +40,36 @@ class Foreign implements FactoryInterface */ private $tableNameResolver; + /** + * @var ElementNameResolver + */ + private $elementNameResolver; + /** * Constructor. * * @param ObjectManagerInterface $objectManager * @param ResourceConnection $resourceConnection * @param TableNameResolver $tableNameResolver + * @param ElementNameResolver $elementNameResolver * @param string $className */ public function __construct( ObjectManagerInterface $objectManager, ResourceConnection $resourceConnection, TableNameResolver $tableNameResolver, + ElementNameResolver $elementNameResolver, $className = \Magento\Framework\Setup\Declaration\Schema\Dto\Constraints\Reference::class ) { $this->objectManager = $objectManager; $this->resourceConnection = $resourceConnection; $this->className = $className; $this->tableNameResolver = $tableNameResolver; + $this->elementNameResolver = $elementNameResolver; } /** - * {@inheritdoc} + * @inheritdoc */ public function create(array $data) { @@ -68,22 +77,13 @@ public function create(array $data) $data['onDelete'] = self::DEFAULT_ON_DELETE; } - $nameWithoutPrefix = $data['name']; - - if ($this->resourceConnection->getTablePrefix()) { - $nameWithoutPrefix = $this->resourceConnection - ->getConnection($data['table']->getResource()) - ->getForeignKeyName( - $this->tableNameResolver->getNameOfOriginTable( - $data['table']->getNameWithoutPrefix() - ), - $data['column']->getName(), - $data['referenceTable']->getNameWithoutPrefix(), - $data['referenceColumn']->getName() - ); - } - - $data['nameWithoutPrefix'] = $nameWithoutPrefix; + $data['nameWithoutPrefix'] = $this->elementNameResolver->getFKNameWithoutPrefix( + $data['name'], + $data['table'], + $data['column'], + $data['referenceTable'], + $data['referenceColumn'] + ); return $this->objectManager->create($this->className, $data); } diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Index.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Index.php index dd2acd7608867..715f98c4177c0 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Index.php +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Index.php @@ -8,6 +8,7 @@ use Magento\Framework\App\ResourceConnection; use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Setup\Declaration\Schema\Declaration\TableElement\ElementNameResolver; use Magento\Framework\Setup\Declaration\Schema\TableNameResolver; /** @@ -40,28 +41,36 @@ class Index implements FactoryInterface */ private $tableNameResolver; + /** + * @var ElementNameResolver + */ + private $elementNameResolver; + /** * Constructor. * * @param ObjectManagerInterface $objectManager * @param ResourceConnection $resourceConnection * @param TableNameResolver $tableNameResolver + * @param ElementNameResolver $elementNameResolver * @param string $className */ public function __construct( ObjectManagerInterface $objectManager, ResourceConnection $resourceConnection, TableNameResolver $tableNameResolver, + ElementNameResolver $elementNameResolver, $className = \Magento\Framework\Setup\Declaration\Schema\Dto\Index::class ) { $this->objectManager = $objectManager; $this->resourceConnection = $resourceConnection; $this->className = $className; $this->tableNameResolver = $tableNameResolver; + $this->elementNameResolver = $elementNameResolver; } /** - * {@inheritdoc} + * @inheritdoc */ public function create(array $data) { @@ -69,29 +78,12 @@ public function create(array $data) $data['indexType'] = self::DEFAULT_INDEX_TYPE; } - $nameWithoutPrefix = $data['name']; - - if ($this->resourceConnection->getTablePrefix()) { - /** - * Temporary solution. - * @see MAGETWO-91365 - */ - $indexType = AdapterInterface::INDEX_TYPE_INDEX; - if ($data['indexType'] === AdapterInterface::INDEX_TYPE_FULLTEXT) { - $indexType = $data['indexType']; - } - $nameWithoutPrefix = $this->resourceConnection - ->getConnection($data['table']->getResource()) - ->getIndexName( - $this->tableNameResolver->getNameOfOriginTable( - $data['table']->getNameWithoutPrefix() - ), - $data['column'], - $indexType - ); - } - - $data['nameWithoutPrefix'] = $nameWithoutPrefix; + $data['nameWithoutPrefix'] = $this->elementNameResolver->getIndexNameWithoutPrefix( + $data['name'], + $data['table'], + $data['column'], + $data['indexType'] + ); return $this->objectManager->create($this->className, $data); } diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Unique.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Unique.php index 57e5270b0c82e..141e4a7083200 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Unique.php +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Unique.php @@ -7,6 +7,7 @@ use Magento\Framework\App\ResourceConnection; use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Setup\Declaration\Schema\Declaration\TableElement\ElementNameResolver; use Magento\Framework\Setup\Declaration\Schema\TableNameResolver; /** @@ -34,46 +35,45 @@ class Unique implements FactoryInterface */ private $tableNameResolver; + /** + * @var ElementNameResolver + */ + private $elementNameResolver; + /** * Constructor. * * @param ObjectManagerInterface $objectManager * @param ResourceConnection $resourceConnection * @param TableNameResolver $tableNameResolver + * @param ElementNameResolver $elementNameResolver * @param string $className */ public function __construct( ObjectManagerInterface $objectManager, ResourceConnection $resourceConnection, TableNameResolver $tableNameResolver, + ElementNameResolver $elementNameResolver, $className = \Magento\Framework\Setup\Declaration\Schema\Dto\Constraints\Internal::class ) { $this->objectManager = $objectManager; $this->resourceConnection = $resourceConnection; $this->className = $className; $this->tableNameResolver = $tableNameResolver; + $this->elementNameResolver = $elementNameResolver; } /** - * {@inheritdoc} + * @inheritdoc */ public function create(array $data) { - $nameWithoutPrefix = $data['name']; - - if ($this->resourceConnection->getTablePrefix()) { - $nameWithoutPrefix = $this->resourceConnection - ->getConnection($data['table']->getResource()) - ->getIndexName( - $this->tableNameResolver->getNameOfOriginTable( - $data['table']->getNameWithoutPrefix() - ), - $data['column'], - $data['type'] - ); - } - - $data['nameWithoutPrefix'] = $nameWithoutPrefix; + $data['nameWithoutPrefix'] = $this->elementNameResolver->getIndexNameWithoutPrefix( + $data['name'], + $data['table'], + $data['column'], + $data['type'] + ); return $this->objectManager->create($this->className, $data); } diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Table.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Table.php index b4e1e978ea674..b864a3d927b0a 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Table.php +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Table.php @@ -134,7 +134,7 @@ public function getConstraints() } /** - * Returns constraint by name + * Get constraint by name. * * @param string $name * @return Constraint | bool @@ -194,7 +194,7 @@ public function getInternalConstraints() : array } /** - * Returns index by name + * Get index by name * * @param string $name * @return Index | bool @@ -325,7 +325,7 @@ public function getElementType() } /** - * Returns engine name + * Get engine name * * @return string */ @@ -369,7 +369,7 @@ public function getCollation() : string } /** - * Returns name without prefix + * Get name without prefix * * @return string */ @@ -379,7 +379,7 @@ public function getNameWithoutPrefix(): string } /** - * Returns comment + * Get comment * * @return null|string */ diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/FileSystem/XmlReader.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/FileSystem/XmlReader.php deleted file mode 100644 index bd835c35fd890..0000000000000 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/FileSystem/XmlReader.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Framework\Setup\Declaration\Schema\FileSystem; - -use Magento\Framework\Config\FileResolverByModule; -use Magento\Framework\Config\ReaderInterface; - -/** - * DB Schema XML configuration reader. - * Reads schema config from db_schema.xml files in enabled modules. - */ -class XmlReader extends \Magento\Framework\Config\Reader\Filesystem implements ReaderInterface -{ - /** - * Attributes by names of which we will do nodes merge. - * - * @var array - */ - private $idAttributes = [ - '/schema/table' => 'name', - '/schema/table/column' => 'name', - '/schema/table/constraint' => 'name', - '/schema/table/index' => 'name', - '/schema/table/index/column' => 'name', - '/schema/table/constraint/column' => 'name', - ]; - - /** - * XmlReader constructor. - * - * @param FileResolverByModule $fileResolver - * @param \Magento\Framework\Setup\Declaration\Schema\Config\Converter $converter - * @param \Magento\Framework\Setup\Declaration\Schema\Config\SchemaLocator $schemaLocator - * @param \Magento\Framework\Config\ValidationStateInterface $validationState - * @param string $fileName - * @param string $domDocumentClass - * @param string $defaultScope - */ - public function __construct( - FileResolverByModule $fileResolver, - \Magento\Framework\Setup\Declaration\Schema\Config\Converter $converter, - \Magento\Framework\Setup\Declaration\Schema\Config\SchemaLocator $schemaLocator, - \Magento\Framework\Config\ValidationStateInterface $validationState, - $fileName = 'db_schema.xml', - $domDocumentClass = \Magento\Framework\Config\Dom::class, - $defaultScope = 'global' - ) { - parent::__construct( - $fileResolver, - $converter, - $schemaLocator, - $validationState, - $fileName, - $this->idAttributes, - $domDocumentClass, - $defaultScope - ); - } -} diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Operations/AddColumn.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Operations/AddColumn.php index 9a42090ad31db..71a1e2f92dfd8 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Operations/AddColumn.php +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Operations/AddColumn.php @@ -110,7 +110,7 @@ private function getTemporaryIndexHistory(Column $column) Index::TYPE, [ 'name' => self::TEMPORARY_KEY, - 'column' => $column->getName(), + 'column' => [$column->getName()], 'columns' => [$column], 'table' => $column->getTable() ] @@ -119,7 +119,7 @@ private function getTemporaryIndexHistory(Column $column) } /** - * {@inheritdoc} + * @inheritdoc */ public function getOperationName() { @@ -127,7 +127,7 @@ public function getOperationName() } /** - * @return bool + * @inheritdoc */ public function isOperationDestructive() { @@ -187,7 +187,7 @@ private function setupTriggersIfExists(Statement $statement, ElementHistory $ele } /** - * {@inheritdoc} + * @inheritdoc */ public function doOperation(ElementHistory $elementHistory) { diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Operations/DropReference.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Operations/DropReference.php index 4a5f651a10815..95fc1c42210be 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Operations/DropReference.php +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Operations/DropReference.php @@ -35,18 +35,15 @@ public function __construct(DropElement $dropElement) } /** - * {@inheritdoc} - * We can drop references and this will not cause any issues. - * - * @return bool + * @inheritdoc */ public function isOperationDestructive() { - return false; + return true; } /** - * {@inheritdoc} + * @inheritdoc */ public function getOperationName() { @@ -54,7 +51,7 @@ public function getOperationName() } /** - * {@inheritdoc} + * @inheritdoc */ public function doOperation(ElementHistory $elementHistory) { diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/constraints/constraint.xsd b/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/constraints/constraint.xsd index 8c264bd95a076..3eed77c37caac 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/constraints/constraint.xsd +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/constraints/constraint.xsd @@ -10,6 +10,6 @@ <xs:attributeGroup name="baseConstraint"> <xs:attributeGroup ref="basicOperations" /> - <xs:attribute name="name" type="nameType" use="required" /> + <xs:attribute name="referenceId" type="referenceIdType" use="required" /> </xs:attributeGroup> </xs:schema> diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/index.xsd b/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/index.xsd index ead4fc5604fcb..cd08e3f43ad43 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/index.xsd +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/index.xsd @@ -19,7 +19,7 @@ </xs:sequence> <xs:attribute name="indexType" type="indexType" /> - <xs:attribute name="name" type="nameType" /> + <xs:attribute name="referenceId" type="referenceIdType" use="required" /> <xs:attribute name="disabled" type="xs:boolean" /> </xs:complexType> diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/name.xsd b/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/name.xsd index 82db095d66821..dbebdefbda0c2 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/name.xsd +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/name.xsd @@ -16,4 +16,18 @@ <xs:maxLength value="64" /> </xs:restriction> </xs:simpleType> + <xs:simpleType name="referenceIdType"> + <xs:union memberTypes="nameType"> + <xs:simpleType> + <xs:annotation> + <xs:documentation> + The attribute can contain only [A-Z0-9_]. + </xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:pattern value="[A-Z0-9_]+" /> + </xs:restriction> + </xs:simpleType> + </xs:union> + </xs:simpleType> </xs:schema> diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/schema.xsd b/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/schema.xsd index 66cd19d051280..a2f8611c4bd33 100644 --- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/schema.xsd +++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/schema.xsd @@ -39,9 +39,38 @@ <xs:element name="schema"> <xs:complexType> <xs:sequence minOccurs="0" maxOccurs="unbounded"> - <xs:element name="table" type="table"/> + <xs:element name="table" type="table"> + <xs:unique name="uniqueColumnName"> + <xs:annotation> + <xs:documentation>Column name be unique for each table</xs:documentation> + </xs:annotation> + <xs:selector xpath="column" /> + <xs:field xpath="@name" /> + </xs:unique> + <xs:unique name="uniqueIndexReferenceId"> + <xs:annotation> + <xs:documentation>Reference ID should be unique for indexes</xs:documentation> + </xs:annotation> + <xs:selector xpath="index" /> + <xs:field xpath="@referenceId" /> + </xs:unique> + <xs:unique name="uniqueConstraintReferenceId"> + <xs:annotation> + <xs:documentation>Reference ID should be unique for constraints</xs:documentation> + </xs:annotation> + <xs:selector xpath="constraint" /> + <xs:field xpath="@referenceId" /> + </xs:unique> + </xs:element> </xs:sequence> </xs:complexType> + <xs:unique name="uniqueTableName"> + <xs:annotation> + <xs:documentation>Table name should be unique for each module</xs:documentation> + </xs:annotation> + <xs:selector xpath="table" /> + <xs:field xpath="@name" /> + </xs:unique> </xs:element> <xs:complexType name="table"> @@ -55,7 +84,7 @@ <xs:element name="constraint" /> <xs:element name="index" type="index" /> </xs:choice> - <xs:attribute name="name" type="xs:string" /> + <xs:attribute name="name" type="xs:string" use="required" /> <xs:attribute name="resource" type="resourceType" /> <xs:attribute name="engine" type="engineType" /> <xs:attribute name="comment" type="xs:string" /> diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/Declaration/Schema/Config/ConverterTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/Declaration/Schema/Config/ConverterTest.php index 2bb4bbcdb8d06..80b0517f7bfd3 100644 --- a/lib/internal/Magento/Framework/Setup/Test/Unit/Declaration/Schema/Config/ConverterTest.php +++ b/lib/internal/Magento/Framework/Setup/Test/Unit/Declaration/Schema/Config/ConverterTest.php @@ -46,7 +46,7 @@ public function testConvert() <table name="test_table" resource="default"> <column xsi:type="int" name="id" nullable="false" identity="true" comment="Id"/> <column xsi:type="varchar" name="data" length="100" identity="false" comment="Data"/> - <constraint xsi:type="primary" name="PRIMARY"> + <constraint xsi:type="primary" referenceId="PRIMARY_INDEX"> <column name="id"/> </constraint> </table> @@ -74,12 +74,12 @@ public function testConvert() ], ], 'constraint' => [ - 'PRIMARY' => [ + 'PRIMARY_INDEX' => [ 'column' => [ 'id' => 'id', ], 'type' => 'primary', - 'name' => 'PRIMARY', + 'referenceId' => 'PRIMARY_INDEX', ], ], 'name' => 'test_table', diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/Declaration/Schema/Db/SchemaBuilderTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/Declaration/Schema/Db/SchemaBuilderTest.php index 15dfcc746407e..4e0c129204012 100644 --- a/lib/internal/Magento/Framework/Setup/Test/Unit/Declaration/Schema/Db/SchemaBuilderTest.php +++ b/lib/internal/Magento/Framework/Setup/Test/Unit/Declaration/Schema/Db/SchemaBuilderTest.php @@ -299,9 +299,6 @@ public function testBuild(array $columns, array $references, array $constraints, * @param array $references * @param array $constraints * @param array $indexes - * @expectedException \Exception - * @expectedExceptionMessage - * User Warning: Column unknown_column does not exist for index/constraint FIRST_INDEX in table second_table */ public function testBuildUnknownIndexColumn(array $columns, array $references, array $constraints, array $indexes) { @@ -315,6 +312,10 @@ public function testBuildUnknownIndexColumn(array $columns, array $references, a Schema::class, ['resourceConnection' => $resourceConnectionMock] ); + $this->expectException(\Exception::class); + $this->expectExceptionMessage( + 'User Warning: Column unknown_column does not exist for index/constraint FIRST_INDEX in table second_table.' + ); $this->model->build($schema); } diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/Declaration/Schema/Dto/Factories/ForeignTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/Declaration/Schema/Dto/Factories/ForeignTest.php deleted file mode 100644 index ee4331e7bfc5b..0000000000000 --- a/lib/internal/Magento/Framework/Setup/Test/Unit/Declaration/Schema/Dto/Factories/ForeignTest.php +++ /dev/null @@ -1,187 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\Framework\Setup\Test\Unit\Declaration\Schema\Dto\Factories; - -use Magento\Framework\App\ResourceConnection; -use Magento\Framework\DataObject; -use Magento\Framework\DB\Adapter\AdapterInterface; -use Magento\Framework\ObjectManagerInterface; -use Magento\Framework\Setup\Declaration\Schema\Dto\Constraints\Reference; -use Magento\Framework\Setup\Declaration\Schema\Dto\Factories\Foreign; -use Magento\Framework\Setup\Declaration\Schema\Dto\Table; -use Magento\Framework\Setup\Declaration\Schema\TableNameResolver; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; - -/** - * Test foreign factory. - */ -class ForeignTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var ObjectManagerHelper - */ - private $objectManagerHelper; - - /** - * @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $objectManagerMock; - - /** - * @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject - */ - private $resourceConnectionMock; - - /** - * @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $adapterMock; - - /** - * @var TableNameResolver|\PHPUnit_Framework_MockObject_MockObject - */ - private $tableNameResolver; - - /** - * @var Foreign - */ - private $foreignFactory; - - public function setUp() - { - $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $this->resourceConnectionMock = $this->getMockBuilder(ResourceConnection::class) - ->disableOriginalConstructor() - ->getMock(); - $this->adapterMock = $this->getMockBuilder(AdapterInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $this->tableNameResolver = $this->getMockBuilder(TableNameResolver::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->foreignFactory = $this->objectManagerHelper->getObject( - Foreign::class, - [ - 'objectManager' => $this->objectManagerMock, - 'resourceConnection' => $this->resourceConnectionMock, - 'tableNameResolver' => $this->tableNameResolver, - ] - ); - } - - /** - * @param string $prefix - * @dataProvider createDataProvider - */ - public function testCreate(string $prefix) - { - $resource = 'default'; - $tableNameWithoutPrefix = 'table_name'; - $tableName = $prefix . $tableNameWithoutPrefix; - - $columnName = 'entity_id'; - $referenceTableName = 'second_table'; - $referenceColumnName = 'website_id'; - - $foreignKeyNameWithoutPrefix = 'table_name_field_name'; - $foreignKeyName = $prefix . $foreignKeyNameWithoutPrefix; - - $table = $this->objectManagerHelper->getObject( - DataObject::class, - [ - 'data' => [ - 'resource' => $resource, - 'name' => $tableName, - 'name_without_prefix' => $tableNameWithoutPrefix, - ], - ] - ); - - $columnMock = $this->objectManagerHelper->getObject( - DataObject::class, - [ - 'data' => ['name' => $columnName], - ] - ); - - $referenceTableMock = $this->objectManagerHelper->getObject( - DataObject::class, - [ - 'data' => ['name_without_prefix' => $referenceTableName], - ] - ); - - $referenceColumnMock = $this->objectManagerHelper->getObject( - DataObject::class, - [ - 'data' => ['name' => $referenceColumnName], - ] - ); - - $data = [ - 'name' => $foreignKeyName, - 'table' => $table, - 'column' => $columnMock, - 'referenceTable' => $referenceTableMock, - 'referenceColumn' => $referenceColumnMock, - ]; - - $expectedData = array_merge( - $data, - [ - 'onDelete' => Foreign::DEFAULT_ON_DELETE, - 'nameWithoutPrefix' => $foreignKeyNameWithoutPrefix, - ] - ); - - $this->resourceConnectionMock - ->method('getTablePrefix') - ->willReturn($prefix); - - $this->resourceConnectionMock - ->method('getConnection') - ->with($resource) - ->willReturn($this->adapterMock); - - $this->tableNameResolver - ->method('getNameOfOriginTable') - ->with($tableNameWithoutPrefix) - ->willReturn($tableNameWithoutPrefix); - - $this->adapterMock - ->method('getForeignKeyName') - ->with($tableNameWithoutPrefix, $columnName, $referenceTableName, $referenceColumnName) - ->willReturn($foreignKeyNameWithoutPrefix); - - $this->objectManagerMock - ->expects($this->once()) - ->method('create') - ->with(Reference::class, $expectedData); - - $this->foreignFactory->create($data); - } - - /** - * @return array - */ - public function createDataProvider(): array - { - return [ - 'Prefix is defined' => [ - 'pref_', - ], - 'Prefix is not defined' => [ - '', - ], - ]; - } -} diff --git a/lib/web/css/source/lib/_forms.less b/lib/web/css/source/lib/_forms.less index b1c7a49da4a7a..531cf3d34ad76 100644 --- a/lib/web/css/source/lib/_forms.less +++ b/lib/web/css/source/lib/_forms.less @@ -288,7 +288,7 @@ .lib-form-element-input(@_type: select); } - select[multiple="multiple"] { + select[multiple] { .lib-css(height, auto); background-image: none; } diff --git a/lib/web/jquery/jquery.mobile.custom.js b/lib/web/jquery/jquery.mobile.custom.js index 3b02f5346484c..f289b97b91d83 100644 --- a/lib/web/jquery/jquery.mobile.custom.js +++ b/lib/web/jquery/jquery.mobile.custom.js @@ -1,141 +1,25 @@ /* -* jQuery Mobile v1.5.0-alpha.1 +* jQuery Mobile v1.4.3 * http://jquerymobile.com * -* Copyright jQuery Foundation, Inc. and other contributors +* Copyright 2010, 2014 jQuery Foundation, Inc. and other contributors * Released under the MIT license. * http://jquery.org/license * */ (function ( root, doc, factory ) { - if ( typeof define === "function" && define.amd ) { - // AMD. Register as an anonymous module. - define( [ "jquery" ], function ( $ ) { - factory( $, root, doc ); - return $.mobile; - }); - } else { - // Browser globals - factory( root.jQuery, root, doc ); - } -}( this, document, function ( jQuery, window, document, undefined ) {/*! - * jQuery Mobile Scroll Events @VERSION - * http://jquerymobile.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Scroll -//>>group: Events -//>>description: Scroll events including: scrollstart, scrollstop - - ( function( factory ) { - if ( typeof define === "function" && define.amd ) { - - // AMD. Register as an anonymous module. - define( 'events/scroll',[ "jquery" ], factory ); - } else { - - // Browser globals - factory( jQuery ); - } - } )( function( $ ) { - - var scrollEvent = "touchmove scroll"; - -// setup new event shortcuts - $.each( [ "scrollstart", "scrollstop" ], function( i, name ) { - - $.fn[ name ] = function( fn ) { - return fn ? this.bind( name, fn ) : this.trigger( name ); - }; - - // jQuery < 1.8 - if ( $.attrFn ) { - $.attrFn[ name ] = true; - } - } ); - -// also handles scrollstop - $.event.special.scrollstart = { - - enabled: true, - setup: function() { - - var thisObject = this, - $this = $( thisObject ), - scrolling, - timer; - - function trigger( event, state ) { - var originalEventType = event.type; - - scrolling = state; - - event.type = scrolling ? "scrollstart" : "scrollstop"; - $.event.dispatch.call( thisObject, event ); - event.type = originalEventType; - } - - var scrollStartHandler = $.event.special.scrollstart.handler = function ( event ) { - - if ( !$.event.special.scrollstart.enabled ) { - return; - } - - if ( !scrolling ) { - trigger( event, true ); - } - - clearTimeout( timer ); - timer = setTimeout( function() { - trigger( event, false ); - }, 50 ); - }; - - // iPhone triggers scroll after a small delay; use touchmove instead - $this.on( scrollEvent, scrollStartHandler ); - }, - teardown: function() { - $( this ).off( scrollEvent, $.event.special.scrollstart.handler ); - } - }; - - $.each( { - scrollstop: "scrollstart" - }, function( event, sourceEvent ) { - - $.event.special[ event ] = { - setup: function() { - $( this ).bind( sourceEvent, $.noop ); - }, - teardown: function() { - $( this ).unbind( sourceEvent ); - } - }; - } ); - - return $.event.special; - } ); - - /*! - * jQuery Mobile Virtual Mouse @VERSION - * http://jquerymobile.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Virtual Mouse (vmouse) Bindings -//>>group: Core -//>>description: Normalizes touch/mouse events. -//>>docs: http://api.jquerymobile.com/?s=vmouse - -// This plugin is an experiment for abstracting away the touch and mouse + if ( typeof define === "function" && define.amd ) { + // AMD. Register as an anonymous module. + define( [ "jquery" ], function ( $ ) { + factory( $, root, doc ); + return $.mobile; + }); + } else { + // Browser globals + factory( root.jQuery, root, doc ); + } +}( this, document, function ( jQuery, window, document, undefined ) {// This plugin is an experiment for abstracting away the touch and mouse // events so that developers don't have to worry about which method of input // the device their document is loaded on supports. // @@ -150,912 +34,831 @@ // The current version exposes the following virtual events to jQuery bind methods: // "vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel" - ( function( factory ) { - if ( typeof define === "function" && define.amd ) { - - // AMD. Register as an anonymous module. - define( 'vmouse',[ "jquery" ], factory ); - } else { - - // Browser globals - factory( jQuery ); - } - } )( function( $ ) { - - var dataPropertyName = "virtualMouseBindings", - touchTargetPropertyName = "virtualTouchID", - touchEventProps = "clientX clientY pageX pageY screenX screenY".split( " " ), - virtualEventNames = "vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split( " " ), - generalProps = ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " + - "metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ), - mouseHookProps = $.event.mouseHooks ? $.event.mouseHooks.props : [], - mouseEventProps = generalProps.concat( mouseHookProps ), - activeDocHandlers = {}, - resetTimerID = 0, - startX = 0, - startY = 0, - didScroll = false, - clickBlockList = [], - blockMouseTriggers = false, - blockTouchTriggers = false, - eventCaptureSupported = "addEventListener" in document, - $document = $( document ), - nextTouchID = 1, - lastTouchID = 0, threshold, - i; - - $.vmouse = { - moveDistanceThreshold: 10, - clickDistanceThreshold: 10, - resetTimerDuration: 1500, - maximumTimeBetweenTouches: 100 - }; - - function getNativeEvent( event ) { - - while ( event && typeof event.originalEvent !== "undefined" ) { - event = event.originalEvent; - } - return event; - } - - function createVirtualEvent( event, eventType ) { - - var t = event.type, - oe, props, ne, prop, ct, touch, i, j, len; - - event = $.Event( event ); - event.type = eventType; - - oe = event.originalEvent; - props = generalProps; - - // addresses separation of $.event.props in to $.event.mouseHook.props and Issue 3280 - // https://github.com/jquery/jquery-mobile/issues/3280 - if ( t.search( /^(mouse|click)/ ) > -1 ) { - props = mouseEventProps; - } - - // copy original event properties over to the new event - // this would happen if we could call $.event.fix instead of $.Event - // but we don't have a way to force an event to be fixed multiple times - if ( oe ) { - for ( i = props.length; i; ) { - prop = props[ --i ]; - event[ prop ] = oe[ prop ]; - } - } - - // make sure that if the mouse and click virtual events are generated - // without a .which one is defined - if ( t.search( /mouse(down|up)|click/ ) > -1 && !event.which ) { - event.which = 1; - } - - if ( t.search( /^touch/ ) !== -1 ) { - ne = getNativeEvent( oe ); - t = ne.touches; - ct = ne.changedTouches; - touch = ( t && t.length ) ? t[ 0 ] : ( ( ct && ct.length ) ? ct[ 0 ] : undefined ); - - if ( touch ) { - for ( j = 0, len = touchEventProps.length; j < len; j++ ) { - prop = touchEventProps[ j ]; - event[ prop ] = touch[ prop ]; - } - } - } - - return event; - } - - function getVirtualBindingFlags( element ) { - - var flags = {}, - b, k; - - while ( element ) { - - b = $.data( element, dataPropertyName ); - - for ( k in b ) { - if ( b[ k ] ) { - flags[ k ] = flags.hasVirtualBinding = true; - } - } - element = element.parentNode; - } - return flags; - } - - function getClosestElementWithVirtualBinding( element, eventType ) { - var b; - while ( element ) { - - b = $.data( element, dataPropertyName ); - - if ( b && ( !eventType || b[ eventType ] ) ) { - return element; - } - element = element.parentNode; - } - return null; - } - - function enableTouchBindings() { - blockTouchTriggers = false; - } - - function disableTouchBindings() { - blockTouchTriggers = true; - } - - function enableMouseBindings() { - lastTouchID = 0; - clickBlockList.length = 0; - blockMouseTriggers = false; - - // When mouse bindings are enabled, our - // touch bindings are disabled. - disableTouchBindings(); - } - - function disableMouseBindings() { - // When mouse bindings are disabled, our - // touch bindings are enabled. - enableTouchBindings(); - } - - function clearResetTimer() { - if ( resetTimerID ) { - clearTimeout( resetTimerID ); - resetTimerID = 0; - } - } - - function startResetTimer() { - clearResetTimer(); - resetTimerID = setTimeout( function() { - resetTimerID = 0; - enableMouseBindings(); - }, $.vmouse.resetTimerDuration ); - } - - function triggerVirtualEvent( eventType, event, flags ) { - var ve; - - if ( ( flags && flags[ eventType ] ) || - ( !flags && getClosestElementWithVirtualBinding( event.target, eventType ) ) ) { - - ve = createVirtualEvent( event, eventType ); - - $( event.target ).trigger( ve ); - } - - return ve; - } - - function mouseEventCallback( event ) { - var touchID = $.data( event.target, touchTargetPropertyName ), - ve; - - // It is unexpected if a click event is received before a touchend - // or touchmove event, however this is a known behavior in Mobile - // Safari when Mobile VoiceOver (as of iOS 8) is enabled and the user - // double taps to activate a link element. In these cases if a touch - // event is not received within the maximum time between touches, - // re-enable mouse bindings and call the mouse event handler again. - if ( event.type === "click" && $.data( event.target, "lastTouchType" ) === "touchstart" ) { - setTimeout( function() { - if ( $.data( event.target, "lastTouchType" ) === "touchstart" ) { - enableMouseBindings(); - delete $.data( event.target ).lastTouchType; - mouseEventCallback( event ); - } - }, $.vmouse.maximumTimeBetweenTouches ); - } - - if ( !blockMouseTriggers && ( !lastTouchID || lastTouchID !== touchID ) ) { - ve = triggerVirtualEvent( "v" + event.type, event ); - if ( ve ) { - if ( ve.isDefaultPrevented() ) { - event.preventDefault(); - } - if ( ve.isPropagationStopped() ) { - event.stopPropagation(); - } - if ( ve.isImmediatePropagationStopped() ) { - event.stopImmediatePropagation(); - } - } - } - } - - function handleTouchStart( event ) { - - var touches = getNativeEvent( event ).touches, - target, flags, t; - - if ( touches && touches.length === 1 ) { - - target = event.target; - flags = getVirtualBindingFlags( target ); - - $.data( event.target, "lastTouchType", event.type ); - - if ( flags.hasVirtualBinding ) { - - lastTouchID = nextTouchID++; - $.data( target, touchTargetPropertyName, lastTouchID ); - - clearResetTimer(); - - disableMouseBindings(); - didScroll = false; - - t = getNativeEvent( event ).touches[ 0 ]; - startX = t.pageX; - startY = t.pageY; - - triggerVirtualEvent( "vmouseover", event, flags ); - triggerVirtualEvent( "vmousedown", event, flags ); - } - } - } - - function handleScroll( event ) { - if ( blockTouchTriggers ) { - return; - } - - if ( !didScroll ) { - triggerVirtualEvent( "vmousecancel", event, getVirtualBindingFlags( event.target ) ); - } - - $.data( event.target, "lastTouchType", event.type ); - - didScroll = true; - startResetTimer(); - } - - function handleTouchMove( event ) { - if ( blockTouchTriggers ) { - return; - } - - var t = getNativeEvent( event ).touches[ 0 ], - didCancel = didScroll, - moveThreshold = $.vmouse.moveDistanceThreshold, - flags = getVirtualBindingFlags( event.target ); - - $.data( event.target, "lastTouchType", event.type ); - - didScroll = didScroll || - ( Math.abs( t.pageX - startX ) > moveThreshold || - Math.abs( t.pageY - startY ) > moveThreshold ); - - if ( didScroll && !didCancel ) { - triggerVirtualEvent( "vmousecancel", event, flags ); - } - - triggerVirtualEvent( "vmousemove", event, flags ); - startResetTimer(); - } - - function handleTouchEnd( event ) { - if ( blockTouchTriggers || $.data( event.target, "lastTouchType" ) === undefined ) { - return; - } - - disableTouchBindings(); - delete $.data( event.target ).lastTouchType; - - var flags = getVirtualBindingFlags( event.target ), - ve, t; - triggerVirtualEvent( "vmouseup", event, flags ); - - if ( !didScroll ) { - ve = triggerVirtualEvent( "vclick", event, flags ); - if ( ve && ve.isDefaultPrevented() ) { - // The target of the mouse events that follow the touchend - // event don't necessarily match the target used during the - // touch. This means we need to rely on coordinates for blocking - // any click that is generated. - t = getNativeEvent( event ).changedTouches[ 0 ]; - clickBlockList.push( { - touchID: lastTouchID, - x: t.clientX, - y: t.clientY - } ); - - // Prevent any mouse events that follow from triggering - // virtual event notifications. - blockMouseTriggers = true; - } - } - triggerVirtualEvent( "vmouseout", event, flags ); - didScroll = false; - - startResetTimer(); - } - - function hasVirtualBindings( ele ) { - var bindings = $.data( ele, dataPropertyName ), - k; - - if ( bindings ) { - for ( k in bindings ) { - if ( bindings[ k ] ) { - return true; - } - } - } - return false; - } - - function dummyMouseHandler() { - } - - function getSpecialEventObject( eventType ) { - var realType = eventType.substr( 1 ); - - return { - setup: function( /* data, namespace */ ) { - // If this is the first virtual mouse binding for this element, - // add a bindings object to its data. - - if ( !hasVirtualBindings( this ) ) { - $.data( this, dataPropertyName, {} ); - } - - // If setup is called, we know it is the first binding for this - // eventType, so initialize the count for the eventType to zero. - var bindings = $.data( this, dataPropertyName ); - bindings[ eventType ] = true; - - // If this is the first virtual mouse event for this type, - // register a global handler on the document. - - activeDocHandlers[ eventType ] = ( activeDocHandlers[ eventType ] || 0 ) + 1; - - if ( activeDocHandlers[ eventType ] === 1 ) { - $document.bind( realType, mouseEventCallback ); - } - - // Some browsers, like Opera Mini, won't dispatch mouse/click events - // for elements unless they actually have handlers registered on them. - // To get around this, we register dummy handlers on the elements. - - $( this ).bind( realType, dummyMouseHandler ); - - // For now, if event capture is not supported, we rely on mouse handlers. - if ( eventCaptureSupported ) { - // If this is the first virtual mouse binding for the document, - // register our touchstart handler on the document. - - activeDocHandlers[ "touchstart" ] = ( activeDocHandlers[ "touchstart" ] || 0 ) + 1; - - if ( activeDocHandlers[ "touchstart" ] === 1 ) { - $document.bind( "touchstart", handleTouchStart ) - .bind( "touchend", handleTouchEnd ) - - // On touch platforms, touching the screen and then dragging your finger - // causes the window content to scroll after some distance threshold is - // exceeded. On these platforms, a scroll prevents a click event from being - // dispatched, and on some platforms, even the touchend is suppressed. To - // mimic the suppression of the click event, we need to watch for a scroll - // event. Unfortunately, some platforms like iOS don't dispatch scroll - // events until *AFTER* the user lifts their finger (touchend). This means - // we need to watch both scroll and touchmove events to figure out whether - // or not a scroll happenens before the touchend event is fired. - - .bind( "touchmove", handleTouchMove ) - .bind( "scroll", handleScroll ); - } - } - }, - - teardown: function( /* data, namespace */ ) { - // If this is the last virtual binding for this eventType, - // remove its global handler from the document. - - --activeDocHandlers[eventType]; - - if ( !activeDocHandlers[ eventType ] ) { - $document.unbind( realType, mouseEventCallback ); - } - - if ( eventCaptureSupported ) { - // If this is the last virtual mouse binding in existence, - // remove our document touchstart listener. - - --activeDocHandlers["touchstart"]; - - if ( !activeDocHandlers[ "touchstart" ] ) { - $document.unbind( "touchstart", handleTouchStart ) - .unbind( "touchmove", handleTouchMove ) - .unbind( "touchend", handleTouchEnd ) - .unbind( "scroll", handleScroll ); - } - } - - var $this = $( this ), - bindings = $.data( this, dataPropertyName ); - - // teardown may be called when an element was - // removed from the DOM. If this is the case, - // jQuery core may have already stripped the element - // of any data bindings so we need to check it before - // using it. - if ( bindings ) { - bindings[ eventType ] = false; - } +(function( $, window, document, undefined ) { + +var dataPropertyName = "virtualMouseBindings", + touchTargetPropertyName = "virtualTouchID", + virtualEventNames = "vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split( " " ), + touchEventProps = "clientX clientY pageX pageY screenX screenY".split( " " ), + mouseHookProps = $.event.mouseHooks ? $.event.mouseHooks.props : [], + mouseEventProps = $.event.props.concat( mouseHookProps ), + activeDocHandlers = {}, + resetTimerID = 0, + startX = 0, + startY = 0, + didScroll = false, + clickBlockList = [], + blockMouseTriggers = false, + blockTouchTriggers = false, + eventCaptureSupported = "addEventListener" in document, + $document = $( document ), + nextTouchID = 1, + lastTouchID = 0, threshold, + i; + +$.vmouse = { + moveDistanceThreshold: 10, + clickDistanceThreshold: 10, + resetTimerDuration: 1500 +}; + +function getNativeEvent( event ) { + + while ( event && typeof event.originalEvent !== "undefined" ) { + event = event.originalEvent; + } + return event; +} + +function createVirtualEvent( event, eventType ) { + + var t = event.type, + oe, props, ne, prop, ct, touch, i, j, len; + + event = $.Event( event ); + event.type = eventType; + + oe = event.originalEvent; + props = $.event.props; + + // addresses separation of $.event.props in to $.event.mouseHook.props and Issue 3280 + // https://github.com/jquery/jquery-mobile/issues/3280 + if ( t.search( /^(mouse|click)/ ) > -1 ) { + props = mouseEventProps; + } + + // copy original event properties over to the new event + // this would happen if we could call $.event.fix instead of $.Event + // but we don't have a way to force an event to be fixed multiple times + if ( oe ) { + for ( i = props.length, prop; i; ) { + prop = props[ --i ]; + event[ prop ] = oe[ prop ]; + } + } + + // make sure that if the mouse and click virtual events are generated + // without a .which one is defined + if ( t.search(/mouse(down|up)|click/) > -1 && !event.which ) { + event.which = 1; + } + + if ( t.search(/^touch/) !== -1 ) { + ne = getNativeEvent( oe ); + t = ne.touches; + ct = ne.changedTouches; + touch = ( t && t.length ) ? t[0] : ( ( ct && ct.length ) ? ct[ 0 ] : undefined ); + + if ( touch ) { + for ( j = 0, len = touchEventProps.length; j < len; j++) { + prop = touchEventProps[ j ]; + event[ prop ] = touch[ prop ]; + } + } + } + + return event; +} + +function getVirtualBindingFlags( element ) { + + var flags = {}, + b, k; + + while ( element ) { + + b = $.data( element, dataPropertyName ); + + for ( k in b ) { + if ( b[ k ] ) { + flags[ k ] = flags.hasVirtualBinding = true; + } + } + element = element.parentNode; + } + return flags; +} + +function getClosestElementWithVirtualBinding( element, eventType ) { + var b; + while ( element ) { + + b = $.data( element, dataPropertyName ); + + if ( b && ( !eventType || b[ eventType ] ) ) { + return element; + } + element = element.parentNode; + } + return null; +} + +function enableTouchBindings() { + blockTouchTriggers = false; +} + +function disableTouchBindings() { + blockTouchTriggers = true; +} + +function enableMouseBindings() { + lastTouchID = 0; + clickBlockList.length = 0; + blockMouseTriggers = false; + + // When mouse bindings are enabled, our + // touch bindings are disabled. + disableTouchBindings(); +} + +function disableMouseBindings() { + // When mouse bindings are disabled, our + // touch bindings are enabled. + enableTouchBindings(); +} + +function startResetTimer() { + clearResetTimer(); + resetTimerID = setTimeout( function() { + resetTimerID = 0; + enableMouseBindings(); + }, $.vmouse.resetTimerDuration ); +} + +function clearResetTimer() { + if ( resetTimerID ) { + clearTimeout( resetTimerID ); + resetTimerID = 0; + } +} + +function triggerVirtualEvent( eventType, event, flags ) { + var ve; + + if ( ( flags && flags[ eventType ] ) || + ( !flags && getClosestElementWithVirtualBinding( event.target, eventType ) ) ) { + + ve = createVirtualEvent( event, eventType ); + + $( event.target).trigger( ve ); + } + + return ve; +} + +function mouseEventCallback( event ) { + var touchID = $.data( event.target, touchTargetPropertyName ), + ve; + + if ( !blockMouseTriggers && ( !lastTouchID || lastTouchID !== touchID ) ) { + ve = triggerVirtualEvent( "v" + event.type, event ); + if ( ve ) { + if ( ve.isDefaultPrevented() ) { + event.preventDefault(); + } + if ( ve.isPropagationStopped() ) { + event.stopPropagation(); + } + if ( ve.isImmediatePropagationStopped() ) { + event.stopImmediatePropagation(); + } + } + } +} + +function handleTouchStart( event ) { + + var touches = getNativeEvent( event ).touches, + target, flags, t; + + if ( touches && touches.length === 1 ) { + + target = event.target; + flags = getVirtualBindingFlags( target ); + + if ( flags.hasVirtualBinding ) { + + lastTouchID = nextTouchID++; + $.data( target, touchTargetPropertyName, lastTouchID ); + + clearResetTimer(); + + disableMouseBindings(); + didScroll = false; + + t = getNativeEvent( event ).touches[ 0 ]; + startX = t.pageX; + startY = t.pageY; + + triggerVirtualEvent( "vmouseover", event, flags ); + triggerVirtualEvent( "vmousedown", event, flags ); + } + } +} + +function handleScroll( event ) { + if ( blockTouchTriggers ) { + return; + } + + if ( !didScroll ) { + triggerVirtualEvent( "vmousecancel", event, getVirtualBindingFlags( event.target ) ); + } + + didScroll = true; + startResetTimer(); +} + +function handleTouchMove( event ) { + if ( blockTouchTriggers ) { + return; + } + + var t = getNativeEvent( event ).touches[ 0 ], + didCancel = didScroll, + moveThreshold = $.vmouse.moveDistanceThreshold, + flags = getVirtualBindingFlags( event.target ); + + didScroll = didScroll || + ( Math.abs( t.pageX - startX ) > moveThreshold || + Math.abs( t.pageY - startY ) > moveThreshold ); + + if ( didScroll && !didCancel ) { + triggerVirtualEvent( "vmousecancel", event, flags ); + } + + triggerVirtualEvent( "vmousemove", event, flags ); + startResetTimer(); +} + +function handleTouchEnd( event ) { + if ( blockTouchTriggers ) { + return; + } + + disableTouchBindings(); + + var flags = getVirtualBindingFlags( event.target ), + ve, t; + triggerVirtualEvent( "vmouseup", event, flags ); + + if ( !didScroll ) { + ve = triggerVirtualEvent( "vclick", event, flags ); + if ( ve && ve.isDefaultPrevented() ) { + // The target of the mouse events that follow the touchend + // event don't necessarily match the target used during the + // touch. This means we need to rely on coordinates for blocking + // any click that is generated. + t = getNativeEvent( event ).changedTouches[ 0 ]; + clickBlockList.push({ + touchID: lastTouchID, + x: t.clientX, + y: t.clientY + }); + + // Prevent any mouse events that follow from triggering + // virtual event notifications. + blockMouseTriggers = true; + } + } + triggerVirtualEvent( "vmouseout", event, flags); + didScroll = false; + + startResetTimer(); +} + +function hasVirtualBindings( ele ) { + var bindings = $.data( ele, dataPropertyName ), + k; + + if ( bindings ) { + for ( k in bindings ) { + if ( bindings[ k ] ) { + return true; + } + } + } + return false; +} + +function dummyMouseHandler() {} + +function getSpecialEventObject( eventType ) { + var realType = eventType.substr( 1 ); + + return { + setup: function(/* data, namespace */) { + // If this is the first virtual mouse binding for this element, + // add a bindings object to its data. + + if ( !hasVirtualBindings( this ) ) { + $.data( this, dataPropertyName, {} ); + } + + // If setup is called, we know it is the first binding for this + // eventType, so initialize the count for the eventType to zero. + var bindings = $.data( this, dataPropertyName ); + bindings[ eventType ] = true; + + // If this is the first virtual mouse event for this type, + // register a global handler on the document. + + activeDocHandlers[ eventType ] = ( activeDocHandlers[ eventType ] || 0 ) + 1; + + if ( activeDocHandlers[ eventType ] === 1 ) { + $document.bind( realType, mouseEventCallback ); + } + + // Some browsers, like Opera Mini, won't dispatch mouse/click events + // for elements unless they actually have handlers registered on them. + // To get around this, we register dummy handlers on the elements. + + $( this ).bind( realType, dummyMouseHandler ); + + // For now, if event capture is not supported, we rely on mouse handlers. + if ( eventCaptureSupported ) { + // If this is the first virtual mouse binding for the document, + // register our touchstart handler on the document. + + activeDocHandlers[ "touchstart" ] = ( activeDocHandlers[ "touchstart" ] || 0) + 1; + + if ( activeDocHandlers[ "touchstart" ] === 1 ) { + $document.bind( "touchstart", handleTouchStart ) + .bind( "touchend", handleTouchEnd ) + + // On touch platforms, touching the screen and then dragging your finger + // causes the window content to scroll after some distance threshold is + // exceeded. On these platforms, a scroll prevents a click event from being + // dispatched, and on some platforms, even the touchend is suppressed. To + // mimic the suppression of the click event, we need to watch for a scroll + // event. Unfortunately, some platforms like iOS don't dispatch scroll + // events until *AFTER* the user lifts their finger (touchend). This means + // we need to watch both scroll and touchmove events to figure out whether + // or not a scroll happenens before the touchend event is fired. + + .bind( "touchmove", handleTouchMove ) + .bind( "scroll", handleScroll ); + } + } + }, + + teardown: function(/* data, namespace */) { + // If this is the last virtual binding for this eventType, + // remove its global handler from the document. + + --activeDocHandlers[ eventType ]; + + if ( !activeDocHandlers[ eventType ] ) { + $document.unbind( realType, mouseEventCallback ); + } + + if ( eventCaptureSupported ) { + // If this is the last virtual mouse binding in existence, + // remove our document touchstart listener. + + --activeDocHandlers[ "touchstart" ]; + + if ( !activeDocHandlers[ "touchstart" ] ) { + $document.unbind( "touchstart", handleTouchStart ) + .unbind( "touchmove", handleTouchMove ) + .unbind( "touchend", handleTouchEnd ) + .unbind( "scroll", handleScroll ); + } + } + + var $this = $( this ), + bindings = $.data( this, dataPropertyName ); + + // teardown may be called when an element was + // removed from the DOM. If this is the case, + // jQuery core may have already stripped the element + // of any data bindings so we need to check it before + // using it. + if ( bindings ) { + bindings[ eventType ] = false; + } - // Unregister the dummy event handler. + // Unregister the dummy event handler. - $this.unbind( realType, dummyMouseHandler ); + $this.unbind( realType, dummyMouseHandler ); - // If this is the last virtual mouse binding on the - // element, remove the binding data from the element. - - if ( !hasVirtualBindings( this ) ) { - $this.removeData( dataPropertyName ); - } - } - }; - } + // If this is the last virtual mouse binding on the + // element, remove the binding data from the element. + + if ( !hasVirtualBindings( this ) ) { + $this.removeData( dataPropertyName ); + } + } + }; +} // Expose our custom events to the jQuery bind/unbind mechanism. - for ( i = 0; i < virtualEventNames.length; i++ ) { - $.event.special[ virtualEventNames[ i ] ] = getSpecialEventObject( virtualEventNames[ i ] ); - } +for ( i = 0; i < virtualEventNames.length; i++ ) { + $.event.special[ virtualEventNames[ i ] ] = getSpecialEventObject( virtualEventNames[ i ] ); +} // Add a capture click handler to block clicks. // Note that we require event capture support for this so if the device // doesn't support it, we punt for now and rely solely on mouse events. - if ( eventCaptureSupported ) { - document.addEventListener( "click", function( e ) { - var cnt = clickBlockList.length, - target = e.target, - x, y, ele, i, o, touchID; - - if ( cnt ) { - x = e.clientX; - y = e.clientY; - threshold = $.vmouse.clickDistanceThreshold; - - // The idea here is to run through the clickBlockList to see if - // the current click event is in the proximity of one of our - // vclick events that had preventDefault() called on it. If we find - // one, then we block the click. - // - // Why do we have to rely on proximity? - // - // Because the target of the touch event that triggered the vclick - // can be different from the target of the click event synthesized - // by the browser. The target of a mouse/click event that is synthesized - // from a touch event seems to be implementation specific. For example, - // some browsers will fire mouse/click events for a link that is near - // a touch event, even though the target of the touchstart/touchend event - // says the user touched outside the link. Also, it seems that with most - // browsers, the target of the mouse/click event is not calculated until the - // time it is dispatched, so if you replace an element that you touched - // with another element, the target of the mouse/click will be the new - // element underneath that point. - // - // Aside from proximity, we also check to see if the target and any - // of its ancestors were the ones that blocked a click. This is necessary - // because of the strange mouse/click target calculation done in the - // Android 2.1 browser, where if you click on an element, and there is a - // mouse/click handler on one of its ancestors, the target will be the - // innermost child of the touched element, even if that child is no where - // near the point of touch. - - ele = target; - - while ( ele ) { - for ( i = 0; i < cnt; i++ ) { - o = clickBlockList[ i ]; - touchID = 0; - - if ( ( ele === target && Math.abs( o.x - x ) < threshold && Math.abs( o.y - y ) < threshold ) || - $.data( ele, touchTargetPropertyName ) === o.touchID ) { - // XXX: We may want to consider removing matches from the block list - // instead of waiting for the reset timer to fire. - e.preventDefault(); - e.stopPropagation(); - return; - } - } - ele = ele.parentNode; - } - } - }, true ); - } - } ); - - /*! - * jQuery Mobile Namespace @VERSION - * http://jquerymobile.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Namespace -//>>group: Core -//>>description: The mobile namespace on the jQuery object - - ( function( factory ) { - if ( typeof define === "function" && define.amd ) { - - // AMD. Register as an anonymous module. - define( 'ns',[ "jquery" ], factory ); - } else { - - // Browser globals - factory( jQuery ); - } - } )( function( $ ) { - - $.mobile = { version: "@VERSION" }; - - return $.mobile; - } ); - - /*! - * jQuery Mobile Touch Support Test @VERSION - * http://jquerymobile.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Touch support test -//>>group: Core -//>>description: Touch feature test - - ( function( factory ) { - if ( typeof define === "function" && define.amd ) { - - // AMD. Register as an anonymous module. - define( 'support/touch',[ - "jquery", - "../ns" ], factory ); - } else { - - // Browser globals - factory( jQuery ); - } - } )( function( $ ) { - - var support = { - touch: "ontouchend" in document - }; - - $.mobile.support = $.mobile.support || {}; - $.extend( $.support, support ); - $.extend( $.mobile.support, support ); - - return $.support; - } ); - - /*! - * jQuery Mobile Touch Events @VERSION - * http://jquerymobile.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -//>>label: Touch -//>>group: Events -//>>description: Touch events including: touchstart, touchmove, touchend, tap, taphold, swipe, swipeleft, swiperight - - ( function( factory ) { - if ( typeof define === "function" && define.amd ) { - - // AMD. Register as an anonymous module. - define( 'events/touch',[ - "jquery", - "../vmouse", - "../support/touch" ], factory ); - } else { - - // Browser globals - factory( jQuery ); - } - } )( function( $ ) { - var $document = $( document ), - supportTouch = $.mobile.support.touch, - touchStartEvent = supportTouch ? "touchstart" : "mousedown", - touchStopEvent = supportTouch ? "touchend" : "mouseup", - touchMoveEvent = supportTouch ? "touchmove" : "mousemove"; - -// setup new event shortcuts - $.each( ( "touchstart touchmove touchend " + - "tap taphold " + - "swipe swipeleft swiperight" ).split( " " ), function( i, name ) { - - $.fn[ name ] = function( fn ) { - return fn ? this.bind( name, fn ) : this.trigger( name ); - }; - - // jQuery < 1.8 - if ( $.attrFn ) { - $.attrFn[ name ] = true; - } - } ); - - function triggerCustomEvent( obj, eventType, event, bubble ) { - var originalType = event.type; - event.type = eventType; - if ( bubble ) { - $.event.trigger( event, undefined, obj ); - } else { - $.event.dispatch.call( obj, event ); - } - event.type = originalType; - } - -// also handles taphold - $.event.special.tap = { - tapholdThreshold: 750, - emitTapOnTaphold: true, - setup: function() { - var thisObject = this, - $this = $( thisObject ), - isTaphold = false; - - $this.bind( "vmousedown", function( event ) { - isTaphold = false; - if ( event.which && event.which !== 1 ) { - return true; - } - - var origTarget = event.target, - timer, clickHandler; - - function clearTapTimer() { - if ( timer ) { - $this.bind( "vclick", clickHandler ); - clearTimeout( timer ); - } - } - - function clearTapHandlers() { - clearTapTimer(); - - $this.unbind( "vclick", clickHandler ) - .unbind( "vmouseup", clearTapTimer ); - $document.unbind( "vmousecancel", clearTapHandlers ); - } - - clickHandler = function( event ) { - clearTapHandlers(); - - // ONLY trigger a 'tap' event if the start target is - // the same as the stop target. - if ( !isTaphold && origTarget === event.target ) { - triggerCustomEvent( thisObject, "tap", event ); - } else if ( isTaphold ) { - event.preventDefault(); - } - }; - - $this.bind( "vmouseup", clearTapTimer ); - - $document.bind( "vmousecancel", clearTapHandlers ); - - timer = setTimeout( function() { - if ( !$.event.special.tap.emitTapOnTaphold ) { - isTaphold = true; - } - timer = 0; - triggerCustomEvent( thisObject, "taphold", $.Event( "taphold", { target: origTarget } ) ); - }, $.event.special.tap.tapholdThreshold ); - } ); - }, - teardown: function() { - $( this ).unbind( "vmousedown" ).unbind( "vclick" ).unbind( "vmouseup" ); - $document.unbind( "vmousecancel" ); - } - }; - -// Also handles swipeleft, swiperight - $.event.special.swipe = { - - // More than this horizontal displacement, and we will suppress scrolling. - scrollSupressionThreshold: 30, - - // More time than this, and it isn't a swipe. - durationThreshold: 1000, - - // Swipe horizontal displacement must be more than this. - horizontalDistanceThreshold: window.devicePixelRatio >= 2 ? 15 : 30, - - // Swipe vertical displacement must be less than this. - verticalDistanceThreshold: window.devicePixelRatio >= 2 ? 15 : 30, - - getLocation: function( event ) { - var winPageX = window.pageXOffset, - winPageY = window.pageYOffset, - x = event.clientX, - y = event.clientY; - - if ( event.pageY === 0 && Math.floor( y ) > Math.floor( event.pageY ) || - event.pageX === 0 && Math.floor( x ) > Math.floor( event.pageX ) ) { - - // iOS4 clientX/clientY have the value that should have been - // in pageX/pageY. While pageX/page/ have the value 0 - x = x - winPageX; - y = y - winPageY; - } else if ( y < ( event.pageY - winPageY ) || x < ( event.pageX - winPageX ) ) { - - // Some Android browsers have totally bogus values for clientX/Y - // when scrolling/zooming a page. Detectable since clientX/clientY - // should never be smaller than pageX/pageY minus page scroll - x = event.pageX - winPageX; - y = event.pageY - winPageY; - } - - return { - x: x, - y: y - }; - }, - - start: function( event ) { - var data = event.originalEvent.touches ? - event.originalEvent.touches[ 0 ] : event, - location = $.event.special.swipe.getLocation( data ); - return { - time: ( new Date() ).getTime(), - coords: [ location.x, location.y ], - origin: $( event.target ) - }; - }, - - stop: function( event ) { - var data = event.originalEvent.touches ? - event.originalEvent.touches[ 0 ] : event, - location = $.event.special.swipe.getLocation( data ); - return { - time: ( new Date() ).getTime(), - coords: [ location.x, location.y ] - }; - }, - - handleSwipe: function( start, stop, thisObject, origTarget ) { - if ( stop.time - start.time < $.event.special.swipe.durationThreshold && - Math.abs( start.coords[ 0 ] - stop.coords[ 0 ] ) > $.event.special.swipe.horizontalDistanceThreshold && - Math.abs( start.coords[ 1 ] - stop.coords[ 1 ] ) < $.event.special.swipe.verticalDistanceThreshold ) { - var direction = start.coords[ 0 ] > stop.coords[ 0 ] ? "swipeleft" : "swiperight"; - - triggerCustomEvent( thisObject, "swipe", $.Event( "swipe", { target: origTarget, swipestart: start, swipestop: stop } ), true ); - triggerCustomEvent( thisObject, direction, $.Event( direction, { target: origTarget, swipestart: start, swipestop: stop } ), true ); - return true; - } - return false; - - }, - - // This serves as a flag to ensure that at most one swipe event event is - // in work at any given time - eventInProgress: false, - - setup: function() { - var events, - thisObject = this, - $this = $( thisObject ), - context = {}; - - // Retrieve the events data for this element and add the swipe context - events = $.data( this, "mobile-events" ); - if ( !events ) { - events = { length: 0 }; - $.data( this, "mobile-events", events ); - } - events.length++; - events.swipe = context; - - context.start = function( event ) { - - // Bail if we're already working on a swipe event - if ( $.event.special.swipe.eventInProgress ) { - return; - } - $.event.special.swipe.eventInProgress = true; - - var stop, - start = $.event.special.swipe.start( event ), - origTarget = event.target, - emitted = false; - - context.move = function( event ) { - if ( !start || event.isDefaultPrevented() ) { - return; - } - - stop = $.event.special.swipe.stop( event ); - if ( !emitted ) { - emitted = $.event.special.swipe.handleSwipe( start, stop, thisObject, origTarget ); - if ( emitted ) { - - // Reset the context to make way for the next swipe event - $.event.special.swipe.eventInProgress = false; - } - } - // prevent scrolling - if ( Math.abs( start.coords[ 0 ] - stop.coords[ 0 ] ) > $.event.special.swipe.scrollSupressionThreshold ) { - event.preventDefault(); - } - }; - - context.stop = function() { - emitted = true; - - // Reset the context to make way for the next swipe event - $.event.special.swipe.eventInProgress = false; - $document.off( touchMoveEvent, context.move ); - context.move = null; - }; - - $document.on( touchMoveEvent, context.move ) - .one( touchStopEvent, context.stop ); - }; - $this.on( touchStartEvent, context.start ); - }, - - teardown: function() { - var events, context; - - events = $.data( this, "mobile-events" ); - if ( events ) { - context = events.swipe; - delete events.swipe; - events.length--; - if ( events.length === 0 ) { - $.removeData( this, "mobile-events" ); - } - } - - if ( context ) { - if ( context.start ) { - $( this ).off( touchStartEvent, context.start ); - } - if ( context.move ) { - $document.off( touchMoveEvent, context.move ); - } - if ( context.stop ) { - $document.off( touchStopEvent, context.stop ); - } - } - } - }; - $.each( { - taphold: "tap", - swipeleft: "swipe.left", - swiperight: "swipe.right" - }, function( event, sourceEvent ) { - - $.event.special[ event ] = { - setup: function() { - $( this ).bind( sourceEvent, $.noop ); - }, - teardown: function() { - $( this ).unbind( sourceEvent ); - } - }; - } ); - - return $.event.special; - } ); - +if ( eventCaptureSupported ) { + document.addEventListener( "click", function( e ) { + var cnt = clickBlockList.length, + target = e.target, + x, y, ele, i, o, touchID; + + if ( cnt ) { + x = e.clientX; + y = e.clientY; + threshold = $.vmouse.clickDistanceThreshold; + + // The idea here is to run through the clickBlockList to see if + // the current click event is in the proximity of one of our + // vclick events that had preventDefault() called on it. If we find + // one, then we block the click. + // + // Why do we have to rely on proximity? + // + // Because the target of the touch event that triggered the vclick + // can be different from the target of the click event synthesized + // by the browser. The target of a mouse/click event that is synthesized + // from a touch event seems to be implementation specific. For example, + // some browsers will fire mouse/click events for a link that is near + // a touch event, even though the target of the touchstart/touchend event + // says the user touched outside the link. Also, it seems that with most + // browsers, the target of the mouse/click event is not calculated until the + // time it is dispatched, so if you replace an element that you touched + // with another element, the target of the mouse/click will be the new + // element underneath that point. + // + // Aside from proximity, we also check to see if the target and any + // of its ancestors were the ones that blocked a click. This is necessary + // because of the strange mouse/click target calculation done in the + // Android 2.1 browser, where if you click on an element, and there is a + // mouse/click handler on one of its ancestors, the target will be the + // innermost child of the touched element, even if that child is no where + // near the point of touch. + + ele = target; + + while ( ele ) { + for ( i = 0; i < cnt; i++ ) { + o = clickBlockList[ i ]; + touchID = 0; + + if ( ( ele === target && Math.abs( o.x - x ) < threshold && Math.abs( o.y - y ) < threshold ) || + $.data( ele, touchTargetPropertyName ) === o.touchID ) { + // XXX: We may want to consider removing matches from the block list + // instead of waiting for the reset timer to fire. + e.preventDefault(); + e.stopPropagation(); + return; + } + } + ele = ele.parentNode; + } + } + }, true); +} +})( jQuery, window, document ); + +(function( $ ) { + $.mobile = {}; +}( jQuery )); + + (function( $, undefined ) { + var support = { + touch: "ontouchend" in document + }; + + $.mobile.support = $.mobile.support || {}; + $.extend( $.support, support ); + $.extend( $.mobile.support, support ); + }( jQuery )); + + +(function( $, window, undefined ) { + var $document = $( document ), + supportTouch = $.mobile.support.touch, + scrollEvent = "touchmove scroll", + touchStartEvent = supportTouch ? "touchstart" : "mousedown", + touchStopEvent = supportTouch ? "touchend" : "mouseup", + touchMoveEvent = supportTouch ? "touchmove" : "mousemove"; + + // setup new event shortcuts + $.each( ( "touchstart touchmove touchend " + + "tap taphold " + + "swipe swipeleft swiperight " + + "scrollstart scrollstop" ).split( " " ), function( i, name ) { + + $.fn[ name ] = function( fn ) { + return fn ? this.bind( name, fn ) : this.trigger( name ); + }; + + // jQuery < 1.8 + if ( $.attrFn ) { + $.attrFn[ name ] = true; + } + }); + + function triggerCustomEvent( obj, eventType, event, bubble ) { + var originalType = event.type; + event.type = eventType; + if ( bubble ) { + $.event.trigger( event, undefined, obj ); + } else { + $.event.dispatch.call( obj, event ); + } + event.type = originalType; + } + + // also handles scrollstop + $.event.special.scrollstart = { + + enabled: true, + setup: function() { + + var thisObject = this, + $this = $( thisObject ), + scrolling, + timer; + + function trigger( event, state ) { + scrolling = state; + triggerCustomEvent( thisObject, scrolling ? "scrollstart" : "scrollstop", event ); + } + + // iPhone triggers scroll after a small delay; use touchmove instead + $this.bind( scrollEvent, function( event ) { + + if ( !$.event.special.scrollstart.enabled ) { + return; + } + + if ( !scrolling ) { + trigger( event, true ); + } + + clearTimeout( timer ); + timer = setTimeout( function() { + trigger( event, false ); + }, 50 ); + }); + }, + teardown: function() { + $( this ).unbind( scrollEvent ); + } + }; + + // also handles taphold + $.event.special.tap = { + tapholdThreshold: 750, + emitTapOnTaphold: true, + setup: function() { + var thisObject = this, + $this = $( thisObject ), + isTaphold = false; + + $this.bind( "vmousedown", function( event ) { + isTaphold = false; + if ( event.which && event.which !== 1 ) { + return false; + } + + var origTarget = event.target, + timer; + + function clearTapTimer() { + clearTimeout( timer ); + } + + function clearTapHandlers() { + clearTapTimer(); + + $this.unbind( "vclick", clickHandler ) + .unbind( "vmouseup", clearTapTimer ); + $document.unbind( "vmousecancel", clearTapHandlers ); + } + + function clickHandler( event ) { + clearTapHandlers(); + + // ONLY trigger a 'tap' event if the start target is + // the same as the stop target. + if ( !isTaphold && origTarget === event.target ) { + triggerCustomEvent( thisObject, "tap", event ); + } else if ( isTaphold ) { + event.preventDefault(); + } + } + + $this.bind( "vmouseup", clearTapTimer ) + .bind( "vclick", clickHandler ); + $document.bind( "vmousecancel", clearTapHandlers ); + + timer = setTimeout( function() { + if ( !$.event.special.tap.emitTapOnTaphold ) { + isTaphold = true; + } + triggerCustomEvent( thisObject, "taphold", $.Event( "taphold", { target: origTarget } ) ); + }, $.event.special.tap.tapholdThreshold ); + }); + }, + teardown: function() { + $( this ).unbind( "vmousedown" ).unbind( "vclick" ).unbind( "vmouseup" ); + $document.unbind( "vmousecancel" ); + } + }; + + // Also handles swipeleft, swiperight + $.event.special.swipe = { + + // More than this horizontal displacement, and we will suppress scrolling. + scrollSupressionThreshold: 30, + + // More time than this, and it isn't a swipe. + durationThreshold: 1000, + + // Swipe horizontal displacement must be more than this. + horizontalDistanceThreshold: 30, + + // Swipe vertical displacement must be less than this. + verticalDistanceThreshold: 30, + + getLocation: function ( event ) { + var winPageX = window.pageXOffset, + winPageY = window.pageYOffset, + x = event.clientX, + y = event.clientY; + + if ( event.pageY === 0 && Math.floor( y ) > Math.floor( event.pageY ) || + event.pageX === 0 && Math.floor( x ) > Math.floor( event.pageX ) ) { + + // iOS4 clientX/clientY have the value that should have been + // in pageX/pageY. While pageX/page/ have the value 0 + x = x - winPageX; + y = y - winPageY; + } else if ( y < ( event.pageY - winPageY) || x < ( event.pageX - winPageX ) ) { + + // Some Android browsers have totally bogus values for clientX/Y + // when scrolling/zooming a page. Detectable since clientX/clientY + // should never be smaller than pageX/pageY minus page scroll + x = event.pageX - winPageX; + y = event.pageY - winPageY; + } + + return { + x: x, + y: y + }; + }, + + start: function( event ) { + var data = event.originalEvent.touches ? + event.originalEvent.touches[ 0 ] : event, + location = $.event.special.swipe.getLocation( data ); + return { + time: ( new Date() ).getTime(), + coords: [ location.x, location.y ], + origin: $( event.target ) + }; + }, + + stop: function( event ) { + var data = event.originalEvent.touches ? + event.originalEvent.touches[ 0 ] : event, + location = $.event.special.swipe.getLocation( data ); + return { + time: ( new Date() ).getTime(), + coords: [ location.x, location.y ] + }; + }, + + handleSwipe: function( start, stop, thisObject, origTarget ) { + if ( stop.time - start.time < $.event.special.swipe.durationThreshold && + Math.abs( start.coords[ 0 ] - stop.coords[ 0 ] ) > $.event.special.swipe.horizontalDistanceThreshold && + Math.abs( start.coords[ 1 ] - stop.coords[ 1 ] ) < $.event.special.swipe.verticalDistanceThreshold ) { + var direction = start.coords[0] > stop.coords[ 0 ] ? "swipeleft" : "swiperight"; + + triggerCustomEvent( thisObject, "swipe", $.Event( "swipe", { target: origTarget, swipestart: start, swipestop: stop }), true ); + triggerCustomEvent( thisObject, direction,$.Event( direction, { target: origTarget, swipestart: start, swipestop: stop } ), true ); + return true; + } + return false; + + }, + + // This serves as a flag to ensure that at most one swipe event event is + // in work at any given time + eventInProgress: false, + + setup: function() { + var events, + thisObject = this, + $this = $( thisObject ), + context = {}; + + // Retrieve the events data for this element and add the swipe context + events = $.data( this, "mobile-events" ); + if ( !events ) { + events = { length: 0 }; + $.data( this, "mobile-events", events ); + } + events.length++; + events.swipe = context; + + context.start = function( event ) { + + // Bail if we're already working on a swipe event + if ( $.event.special.swipe.eventInProgress ) { + return; + } + $.event.special.swipe.eventInProgress = true; + + var stop, + start = $.event.special.swipe.start( event ), + origTarget = event.target, + emitted = false; + + context.move = function( event ) { + if ( !start ) { + return; + } + + stop = $.event.special.swipe.stop( event ); + if ( !emitted ) { + emitted = $.event.special.swipe.handleSwipe( start, stop, thisObject, origTarget ); + if ( emitted ) { + + // Reset the context to make way for the next swipe event + $.event.special.swipe.eventInProgress = false; + } + } + // prevent scrolling + if ( Math.abs( start.coords[ 0 ] - stop.coords[ 0 ] ) > $.event.special.swipe.scrollSupressionThreshold ) { + event.preventDefault(); + } + }; + + context.stop = function() { + emitted = true; + + // Reset the context to make way for the next swipe event + $.event.special.swipe.eventInProgress = false; + $document.off( touchMoveEvent, context.move ); + context.move = null; + }; + + $document.on( touchMoveEvent, context.move ) + .one( touchStopEvent, context.stop ); + }; + $this.on( touchStartEvent, context.start ); + }, + + teardown: function() { + var events, context; + + events = $.data( this, "mobile-events" ); + if ( events ) { + context = events.swipe; + delete events.swipe; + events.length--; + if ( events.length === 0 ) { + $.removeData( this, "mobile-events" ); + } + } + + if ( context ) { + if ( context.start ) { + $( this ).off( touchStartEvent, context.start ); + } + if ( context.move ) { + $document.off( touchMoveEvent, context.move ); + } + if ( context.stop ) { + $document.off( touchStopEvent, context.stop ); + } + } + } + }; + $.each({ + scrollstop: "scrollstart", + taphold: "tap", + swipeleft: "swipe.left", + swiperight: "swipe.right" + }, function( event, sourceEvent ) { + + $.event.special[ event ] = { + setup: function() { + $( this ).bind( sourceEvent, $.noop ); + }, + teardown: function() { + $( this ).unbind( sourceEvent ); + } + }; + }); + +})( jQuery, this ); })); diff --git a/lib/web/magnifier/magnifier.js b/lib/web/magnifier/magnifier.js index 150c8adf0b22b..0807a4c394995 100644 --- a/lib/web/magnifier/magnifier.js +++ b/lib/web/magnifier/magnifier.js @@ -554,6 +554,15 @@ thumbObj.src = thumb.src; } + /** + * Hide magnifier when mouse exceeds image bounds. + */ + function onMouseLeave() { + onThumbLeave(); + isOverThumb = false; + $magnifierPreview.addClass(MagnifyCls.magnifyHidden); + } + function onMousemove(e) { pos.x = e.clientX; pos.y = e.clientY; @@ -564,15 +573,9 @@ isOverThumb = inBounds; } - if (inBounds && isOverThumb) { - if(gMode === 'outside'){ - $magnifierPreview.removeClass(MagnifyCls.magnifyHidden); - } + if (inBounds && isOverThumb && gMode === 'outside') { + $magnifierPreview.removeClass(MagnifyCls.magnifyHidden); move(); - } else { - onThumbLeave(); - isOverThumb = false; - $magnifierPreview.addClass(MagnifyCls.magnifyHidden); } } @@ -589,6 +592,8 @@ }); $box.on('mousemove', onMousemove); + $box.on('mouseleave', onMouseLeave); + _init($box, customUserOptions); } }(jQuery)); diff --git a/pub/errors/processor.php b/pub/errors/processor.php index e64956dce17c2..32fab8d0b0780 100644 --- a/pub/errors/processor.php +++ b/pub/errors/processor.php @@ -257,15 +257,10 @@ public function getHostUrl() /** * Define server http host */ - if (!empty($_SERVER['HTTP_HOST'])) { - $host = $_SERVER['HTTP_HOST']; - } elseif (!empty($_SERVER['SERVER_NAME'])) { - $host = $_SERVER['SERVER_NAME']; - } else { - $host = 'localhost'; - } + $host = $this->resolveHostName(); - $isSecure = (!empty($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'] != 'off'); + $isSecure = (!empty($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'] !== 'off') + || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && ($_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'); $url = ($isSecure ? 'https://' : 'http://') . $host; $port = explode(':', $host); @@ -277,6 +272,23 @@ public function getHostUrl() return $url; } + /** + * Resolve hostname + * + * @return string + */ + private function resolveHostName() : string + { + if (!empty($_SERVER['HTTP_HOST'])) { + $host = $_SERVER['HTTP_HOST']; + } elseif (!empty($_SERVER['SERVER_NAME'])) { + $host = $_SERVER['SERVER_NAME']; + } else { + $host = 'localhost'; + } + return $host; + } + /** * Retrieve base URL * diff --git a/setup/pub/magento/setup/app.js b/setup/pub/magento/setup/app.js index b433e3f19c8bf..f0abd15d106c2 100644 --- a/setup/pub/magento/setup/app.js +++ b/setup/pub/magento/setup/app.js @@ -56,6 +56,9 @@ app.config(['$httpProvider', '$stateProvider', function ($httpProvider, $statePr return $delegate; }); }) + .config(['$locationProvider', function($locationProvider) { + $locationProvider.hashPrefix(''); + }]) .run(function ($rootScope, $state) { $rootScope.$state = $state; });