diff --git a/app/code/Magento/CatalogSearch/Model/Advanced.php b/app/code/Magento/CatalogSearch/Model/Advanced.php index 5143762a07e08..b498cb09e34fa 100644 --- a/app/code/Magento/CatalogSearch/Model/Advanced.php +++ b/app/code/Magento/CatalogSearch/Model/Advanced.php @@ -233,6 +233,11 @@ public function addFilters($values) ? date('Y-m-d\TH:i:s\Z', strtotime($value['to'])) : ''; } + + if ($attribute->getAttributeCode() === 'sku') { + $value = mb_strtolower($value); + } + $condition = $this->_getResource()->prepareCondition( $attribute, $value, diff --git a/app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js b/app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js index a6d1de5fde255..eba9a8c3ea7ae 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js +++ b/app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js @@ -6,7 +6,7 @@ /** * @api */ -define([], function () { +define(['underscore'], function (_) { 'use strict'; /** @@ -44,7 +44,7 @@ define([], function () { vatId: addressData['vat_id'], sameAsBilling: addressData['same_as_billing'], saveInAddressBook: addressData['save_in_address_book'], - customAttributes: addressData['custom_attributes'], + customAttributes: _.toArray(addressData['custom_attributes']).reverse(), /** * @return {*} diff --git a/app/code/Magento/Downloadable/Observer/SaveDownloadableOrderItemObserver.php b/app/code/Magento/Downloadable/Observer/SaveDownloadableOrderItemObserver.php index 4f7939da478fa..84b7ecf0fbc99 100644 --- a/app/code/Magento/Downloadable/Observer/SaveDownloadableOrderItemObserver.php +++ b/app/code/Magento/Downloadable/Observer/SaveDownloadableOrderItemObserver.php @@ -81,12 +81,14 @@ public function __construct( */ public function execute(\Magento\Framework\Event\Observer $observer) { + /** @var \Magento\Sales\Model\Order\Item $orderItem */ $orderItem = $observer->getEvent()->getItem(); if (!$orderItem->getId()) { //order not saved in the database return $this; } - if ($orderItem->getProductType() != \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) { + $productType = $orderItem->getRealProductType() ?: $orderItem->getProductType(); + if ($productType != \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) { return $this; } $product = $orderItem->getProduct(); @@ -112,13 +114,13 @@ public function execute(\Magento\Framework\Event\Observer $observer) if ($linkIds = $orderItem->getProductOptionByCode('links')) { $linkPurchased = $this->_createPurchasedModel(); $this->_objectCopyService->copyFieldsetToTarget( - \downloadable_sales_copy_order::class, + 'downloadable_sales_copy_order', 'to_downloadable', $orderItem->getOrder(), $linkPurchased ); $this->_objectCopyService->copyFieldsetToTarget( - \downloadable_sales_copy_order_item::class, + 'downloadable_sales_copy_order_item', 'to_downloadable', $orderItem, $linkPurchased @@ -131,14 +133,12 @@ public function execute(\Magento\Framework\Event\Observer $observer) ScopeInterface::SCOPE_STORE ); $linkPurchased->setLinkSectionTitle($linkSectionTitle)->save(); - $linkStatus = \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PENDING; if ($orderStatusToEnableItem == \Magento\Sales\Model\Order\Item::STATUS_PENDING || $orderItem->getOrder()->getState() == \Magento\Sales\Model\Order::STATE_COMPLETE ) { $linkStatus = \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_AVAILABLE; } - foreach ($linkIds as $linkId) { if (isset($links[$linkId])) { $linkPurchasedItem = $this->_createPurchasedItemModel()->setPurchasedId( @@ -148,7 +148,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) ); $this->_objectCopyService->copyFieldsetToTarget( - \downloadable_sales_copy_link::class, + 'downloadable_sales_copy_link', 'to_purchased', $links[$linkId], $linkPurchasedItem diff --git a/app/code/Magento/Downloadable/Test/Unit/Observer/SaveDownloadableOrderItemObserverTest.php b/app/code/Magento/Downloadable/Test/Unit/Observer/SaveDownloadableOrderItemObserverTest.php index 756ec44edae42..452ac087a8691 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Observer/SaveDownloadableOrderItemObserverTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Observer/SaveDownloadableOrderItemObserverTest.php @@ -160,6 +160,9 @@ public function testSaveDownloadableOrderItem() $itemMock->expects($this->any()) ->method('getProductType') ->willReturn(DownloadableProductType::TYPE_DOWNLOADABLE); + $itemMock->expects($this->any()) + ->method('getRealProductType') + ->willReturn(DownloadableProductType::TYPE_DOWNLOADABLE); $this->orderMock->expects($this->once()) ->method('getStoreId') @@ -295,6 +298,9 @@ public function testSaveDownloadableOrderItemSavedPurchasedLink() $itemMock->expects($this->any()) ->method('getProductType') ->willReturn(DownloadableProductType::TYPE_DOWNLOADABLE); + $itemMock->expects($this->any()) + ->method('getRealProductType') + ->willReturn(DownloadableProductType::TYPE_DOWNLOADABLE); $purchasedLink = $this->getMockBuilder(\Magento\Downloadable\Model\Link\Purchased::class) ->disableOriginalConstructor() 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 index 7a5d6fcdcc1b1..f0e9958546bbd 100644 --- a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/StaticField.php +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/StaticField.php @@ -104,6 +104,7 @@ public function __construct( * @param array $context * @return array * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function getFields(array $context = []): array { @@ -120,6 +121,9 @@ public function getFields(array $context = []): array $allAttributes[$fieldName] = [ 'type' => $this->fieldTypeResolver->getFieldType($attributeAdapter), ]; + if ($this->isNeedToAddCustomAnalyzer($fieldName) && $this->getCustomAnalyzer($fieldName)) { + $allAttributes[$fieldName]['analyzer'] = $this->getCustomAnalyzer($fieldName); + } $index = $this->fieldIndexResolver->getFieldIndex($attributeAdapter); if (null !== $index) { @@ -174,4 +178,26 @@ public function getFields(array $context = []): array return $allAttributes; } + + /** + * Check is the custom analyzer exists for the field + * + * @param string $fieldName + * @return bool + */ + private function isNeedToAddCustomAnalyzer(string $fieldName): bool + { + return $fieldName === 'sku'; + } + + /** + * Getter for the field custom analyzer if it's exists + * + * @param string $fieldName + * @return string|null + */ + private function getCustomAnalyzer(string $fieldName): ?string + { + return $fieldName === 'sku' ? 'sku' : null; + } } diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/Index/Builder.php b/app/code/Magento/Elasticsearch/Model/Adapter/Index/Builder.php index 773faf49f8fda..1cad781ad6d74 100644 --- a/app/code/Magento/Elasticsearch/Model/Adapter/Index/Builder.php +++ b/app/code/Magento/Elasticsearch/Model/Adapter/Index/Builder.php @@ -8,6 +8,9 @@ use Magento\Framework\Locale\Resolver as LocaleResolver; use Magento\Elasticsearch\Model\Adapter\Index\Config\EsConfigInterface; +/** + * Index Builder + */ class Builder implements BuilderInterface { /** @@ -40,7 +43,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function build() { @@ -59,6 +62,14 @@ public function build() array_keys($filter) ), 'char_filter' => array_keys($charFilter) + ], + 'sku' => [ + 'type' => 'custom', + 'tokenizer' => 'keyword', + 'filter' => array_merge( + ['lowercase', 'keyword_repeat'], + array_keys($filter) + ), ] ], 'tokenizer' => $tokenizer, @@ -71,7 +82,10 @@ public function build() } /** - * {@inheritdoc} + * Setter for storeId property + * + * @param int $storeId + * @return void */ public function setStoreId($storeId) { @@ -79,47 +93,52 @@ public function setStoreId($storeId) } /** + * Return tokenizer configuration + * * @return array */ protected function getTokenizer() { - $tokenizer = [ + return [ 'default_tokenizer' => [ - 'type' => 'standard', - ], + 'type' => 'standard' + ] ]; - return $tokenizer; } /** + * Return filter configuration + * * @return array */ protected function getFilter() { - $filter = [ + return [ 'default_stemmer' => $this->getStemmerConfig(), 'unique_stem' => [ 'type' => 'unique', 'only_on_same_position' => true ] ]; - return $filter; } /** + * Return char filter configuration + * * @return array */ protected function getCharFilter() { - $charFilter = [ + return [ 'default_char_filter' => [ 'type' => 'html_strip', ], ]; - return $charFilter; } /** + * Return stemmer configuration + * * @return array */ protected function getStemmerConfig() diff --git a/app/code/Magento/Persistent/Observer/SynchronizePersistentOnLoginObserver.php b/app/code/Magento/Persistent/Observer/SynchronizePersistentOnLoginObserver.php index 52a2912c4b170..f0b05cb7850cc 100644 --- a/app/code/Magento/Persistent/Observer/SynchronizePersistentOnLoginObserver.php +++ b/app/code/Magento/Persistent/Observer/SynchronizePersistentOnLoginObserver.php @@ -11,6 +11,9 @@ /** * Persistent Session Observer + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) */ class SynchronizePersistentOnLoginObserver implements ObserverInterface { @@ -63,6 +66,8 @@ public function __construct( } /** + * Synchronize persistent session data with logged in customer + * * @param Observer $observer * @return void * @SuppressWarnings(PHPMD.CyclomaticComplexity) @@ -96,8 +101,9 @@ public function execute(Observer $observer) if (!$sessionModel->getId()) { /** @var \Magento\Persistent\Model\Session $sessionModel */ $sessionModel = $this->_sessionFactory->create(); - $sessionModel->setCustomerId($customer->getId())->save(); + $sessionModel->setCustomerId($customer->getId()); } + $sessionModel->save(); $this->_persistentSession->setSession($sessionModel); } diff --git a/app/code/Magento/Sales/view/frontend/email/creditmemo_new_guest.html b/app/code/Magento/Sales/view/frontend/email/creditmemo_new_guest.html index d8a8a0baeca98..f3d133a974082 100644 --- a/app/code/Magento/Sales/view/frontend/email/creditmemo_new_guest.html +++ b/app/code/Magento/Sales/view/frontend/email/creditmemo_new_guest.html @@ -10,7 +10,7 @@ "var comment|escape|nl2br":"Credit Memo Comment", "var creditmemo.increment_id":"Credit Memo Id", "layout handle=\"sales_email_order_creditmemo_items\" creditmemo=$creditmemo order=$order":"Credit Memo Items Grid", -"var billing.name":"Guest Customer Name (Billing)", +"var order_data.customer_name":"Guest Customer Name (Billing)", "var order.increment_id":"Order Id", "var payment_html|raw":"Payment Details", "var formattedShippingAddress|raw":"Shipping Address", @@ -30,7 +30,7 @@
- {{trans "%name," name=$billing.name}} +{{trans "%name," name=$order_data.customer_name}} {{trans "Thank you for your order from %store_name." store_name=$store.frontend_name}} {{trans 'If you have questions about your order, you can email us at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. diff --git a/app/code/Magento/Sales/view/frontend/email/creditmemo_update_guest.html b/app/code/Magento/Sales/view/frontend/email/creditmemo_update_guest.html index ed8f592b59638..64e9a61831956 100644 --- a/app/code/Magento/Sales/view/frontend/email/creditmemo_update_guest.html +++ b/app/code/Magento/Sales/view/frontend/email/creditmemo_update_guest.html @@ -8,7 +8,7 @@ |