Skip to content

Commit

Permalink
Merge pull request #5915 from magento-tango/PR-2020-07-21
Browse files Browse the repository at this point in the history
[tango] Bugfix delivery
  • Loading branch information
dhorytskyi authored Jul 22, 2020
2 parents bc9e5cf + 0afb093 commit e45a5d6
Show file tree
Hide file tree
Showing 36 changed files with 614 additions and 99 deletions.
5 changes: 5 additions & 0 deletions app/code/Magento/CatalogSearch/Model/Advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* @api
*/
define([], function () {
define(['underscore'], function (_) {
'use strict';

/**
Expand Down Expand Up @@ -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 {*}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand All @@ -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(
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public function __construct(
* @param array $context
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function getFields(array $context = []): array
{
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}
}
39 changes: 29 additions & 10 deletions app/code/Magento/Elasticsearch/Model/Adapter/Index/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/**
Expand Down Expand Up @@ -40,7 +43,7 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function build()
{
Expand All @@ -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,
Expand All @@ -71,55 +82,63 @@ public function build()
}

/**
* {@inheritdoc}
* Setter for storeId property
*
* @param int $storeId
* @return void
*/
public function setStoreId($storeId)
{
$this->storeId = $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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

/**
* Persistent Session Observer
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
*/
class SynchronizePersistentOnLoginObserver implements ObserverInterface
{
Expand Down Expand Up @@ -63,6 +66,8 @@ public function __construct(
}

/**
* Synchronize persistent session data with logged in customer
*
* @param Observer $observer
* @return void
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -30,7 +30,7 @@
<table>
<tr class="email-intro">
<td>
<p class="greeting">{{trans "%name," name=$billing.name}}</p>
<p class="greeting">{{trans "%name," name=$order_data.customer_name}}</p>
<p>
{{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 <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!--@vars {
"var comment|escape|nl2br":"Credit Memo Comment",
"var creditmemo.increment_id":"Credit Memo Id",
"var billing.name":"Guest Customer Name",
"var order_data.customer_name":"Guest Customer Name",
"var order.increment_id":"Order Id",
"var order_data.frontend_status_label":"Order Status",
"var store.frontend_name":"Store Frontend Name",
Expand All @@ -21,7 +21,7 @@
<table>
<tr class="email-intro">
<td>
<p class="greeting">{{trans "%name," name=$billing.name}}</p>
<p class="greeting">{{trans "%name," name=$order_data.customer_name}}</p>
<p>
{{trans
"Your order #%increment_id has been updated with a status of <strong>%order_status</strong>."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!--@subject {{trans "Invoice for your %store_name order" store_name=$store.frontend_name}} @-->
<!--@vars {
"var formattedBillingAddress|raw":"Billing Address",
"var billing.name":"Guest Customer Name",
"var order_data.customer_name":"Guest Customer Name",
"var comment|escape|nl2br":"Invoice Comment",
"var invoice.increment_id":"Invoice Id",
"layout handle=\"sales_email_order_invoice_items\" invoice=$invoice order=$order":"Invoice Items Grid",
Expand All @@ -30,7 +30,7 @@
<table>
<tr class="email-intro">
<td>
<p class="greeting">{{trans "%name," name=$billing.name}}</p>
<p class="greeting">{{trans "%name," name=$order_data.customer_name}}</p>
<p>
{{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 <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
-->
<!--@subject {{trans "Update to your %store_name invoice" store_name=$store.frontend_name}} @-->
<!--@vars {
"var billing.name":"Guest Customer Name",
"var order_data.customer_name":"Guest Customer Name",
"var comment|escape|nl2br":"Invoice Comment",
"var invoice.increment_id":"Invoice Id",
"var order.increment_id":"Order Id",
Expand All @@ -21,7 +21,7 @@
<table>
<tr class="email-intro">
<td>
<p class="greeting">{{trans "%name," name=$billing.name}}</p>
<p class="greeting">{{trans "%name," name=$order_data.customer_name}}</p>
<p>
{{trans
"Your order #%increment_id has been updated with a status of <strong>%order_status</strong>."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
-->
<!--@subject {{trans "Update to your %store_name order" store_name=$store.frontend_name}} @-->
<!--@vars {
"var billing.name":"Guest Customer Name",
"var order_data.customer_name":"Guest Customer Name",
"var comment|escape|nl2br":"Order Comment",
"var order.increment_id":"Order Id",
"var order_data.frontend_status_label":"Order Status",
Expand All @@ -20,7 +20,7 @@
<table>
<tr class="email-intro">
<td>
<p class="greeting">{{trans "%name," name=$billing.name}}</p>
<p class="greeting">{{trans "%name," name=$order_data.customer_name}}</p>
<p>
{{trans
"Your order #%increment_id has been updated with a status of <strong>%order_status</strong>."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!--@subject {{trans "Your %store_name order has shipped" store_name=$store.frontend_name}} @-->
<!--@vars {
"var formattedBillingAddress|raw":"Billing Address",
"var billing.name":"Guest Customer Name",
"var order_data.customer_name":"Guest Customer Name",
"var order.increment_id":"Order Id",
"var payment_html|raw":"Payment Details",
"var comment|escape|nl2br":"Shipment Comment",
Expand All @@ -31,7 +31,7 @@
<table>
<tr class="email-intro">
<td>
<p class="greeting">{{trans "%name," name=$billing.name}}</p>
<p class="greeting">{{trans "%name," name=$order_data.customer_name}}</p>
<p>
{{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 <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.
Expand Down
Loading

0 comments on commit e45a5d6

Please sign in to comment.