Skip to content

Commit acd713f

Browse files
author
Oleksii Korshenko
authored
Merge pull request #1624 from magento-engcom/develop-prs
Public Pull Requests #11644 Magento sets ISO invalid language code [2.3-develop Backport] by @crissanclick #11665 Fix app/code/Magento/Backend/Block/Media/Uploader.php getConfigJson() method by @adrian-martinez-interactiv4 #11524 Fix Filter Customer Report Review by @osrecio #11642 Coupon codes not showing in invoice [2.3-develop Backport] by @crissanclick #11519 [Port 2.3-develop] Append shipment comment to shipment if appendComment is true by @JeroenVanLeusden Fixed Public Issues #11540 Magento sets iso invalid language code in html header #10301 Customer review report search Bug in 2.1.x, 2.2 #10168 Coupon codes not showing in invoice #11207 Shipment API won't append comment to email
2 parents 9ed7081 + f24ce2e commit acd713f

File tree

7 files changed

+78
-11
lines changed

7 files changed

+78
-11
lines changed

app/code/Magento/Backend/Block/Media/Uploader.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Backend\Block\Media;
77

88
use Magento\Framework\App\ObjectManager;
9+
use Magento\Framework\Serialize\Serializer\Json;
910

1011
/**
1112
* Adminhtml media library uploader
@@ -30,25 +31,24 @@ class Uploader extends \Magento\Backend\Block\Widget
3031
protected $_fileSizeService;
3132

3233
/**
33-
* @var \Magento\Framework\Json\EncoderInterface
34+
* @var Json
3435
*/
35-
protected $_jsonEncoder;
36+
private $jsonEncoder;
3637

3738
/**
3839
* @param \Magento\Backend\Block\Template\Context $context
3940
* @param \Magento\Framework\File\Size $fileSize
4041
* @param array $data
41-
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
42+
* @param Json $jsonEncoder
4243
*/
4344
public function __construct(
4445
\Magento\Backend\Block\Template\Context $context,
4546
\Magento\Framework\File\Size $fileSize,
4647
array $data = [],
47-
\Magento\Framework\Json\EncoderInterface $jsonEncoder = null
48+
Json $jsonEncoder = null
4849
) {
49-
$this->_jsonEncoder = $jsonEncoder ?:
50-
ObjectManager::getInstance()->get(\Magento\Framework\Json\EncoderInterface::class);
5150
$this->_fileSizeService = $fileSize;
51+
$this->jsonEncoder = $jsonEncoder ?: ObjectManager::getInstance()->get(Json::class);
5252
parent::__construct($context, $data);
5353
}
5454

@@ -118,7 +118,7 @@ public function getJsObjectName()
118118
*/
119119
public function getConfigJson()
120120
{
121-
return $this->_jsonEncoder->encode($this->getConfig()->getData());
121+
return $this->jsonEncoder->encode($this->getConfig()->getData());
122122
}
123123

124124
/**

app/code/Magento/Reports/Model/ResourceModel/Review/Customer/Collection.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,36 @@ protected function _joinCustomers()
103103
return $this;
104104
}
105105

106+
/**
107+
* {@inheritdoc}
108+
*
109+
* Additional processing of 'customer_name' field is required, as it is a concat field, which can not be aliased.
110+
* @see _joinCustomers
111+
*/
112+
public function addFieldToFilter($field, $condition = null)
113+
{
114+
if ($field === 'customer_name') {
115+
$field = $this->getConnection()->getConcatSql(['customer.firstname', 'customer.lastname'], ' ');
116+
}
117+
118+
return parent::addFieldToFilter($field, $condition);
119+
}
120+
106121
/**
107122
* Get select count sql
108123
*
109124
* @return string
110125
*/
111126
public function getSelectCountSql()
112127
{
113-
$countSelect = clone $this->_select;
128+
$countSelect = clone $this->getSelect();
114129
$countSelect->reset(\Magento\Framework\DB\Select::ORDER);
115130
$countSelect->reset(\Magento\Framework\DB\Select::GROUP);
116131
$countSelect->reset(\Magento\Framework\DB\Select::HAVING);
117132
$countSelect->reset(\Magento\Framework\DB\Select::LIMIT_COUNT);
118133
$countSelect->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET);
119134
$countSelect->reset(\Magento\Framework\DB\Select::COLUMNS);
135+
$countSelect->reset(\Magento\Framework\DB\Select::WHERE);
120136

121137
$countSelect->columns(new \Zend_Db_Expr('COUNT(DISTINCT detail.customer_id)'));
122138

app/code/Magento/Sales/Model/Order/ShipmentDocumentFactory.php

+5
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ public function create(
9090
$appendComment,
9191
$comment->getIsVisibleOnFront()
9292
);
93+
94+
if ($appendComment) {
95+
$shipment->setCustomerNote($comment->getComment());
96+
$shipment->setCustomerNoteNotify($appendComment);
97+
}
9398
}
9499

95100
return $shipment;

app/code/Magento/Sales/Test/Unit/Model/Order/ShipmentDocumentFactoryTest.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function setUp()
9292

9393
$this->shipmentMock = $this->getMockBuilder(ShipmentInterface::class)
9494
->disableOriginalConstructor()
95-
->setMethods(['addComment', 'addTrack'])
95+
->setMethods(['addComment', 'addTrack', 'setCustomerNote', 'setCustomerNoteNotify'])
9696
->getMockForAbstractClass();
9797

9898
$this->hydratorPoolMock = $this->getMockBuilder(HydratorPool::class)
@@ -166,7 +166,7 @@ public function testCreate()
166166
if ($appendComment) {
167167
$comment = "New comment!";
168168
$visibleOnFront = true;
169-
$this->commentMock->expects($this->once())
169+
$this->commentMock->expects($this->exactly(2))
170170
->method('getComment')
171171
->willReturn($comment);
172172

@@ -178,6 +178,10 @@ public function testCreate()
178178
->method('addComment')
179179
->with($comment, $appendComment, $visibleOnFront)
180180
->willReturnSelf();
181+
182+
$this->shipmentMock->expects($this->once())
183+
->method('setCustomerNoteNotify')
184+
->with(true);
181185
}
182186

183187
$this->assertEquals(

app/code/Magento/Sales/etc/fieldset.xml

+6
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,12 @@
486486
<aspect name="to_quote_address_shipping" />
487487
<aspect name="to_cm"/>
488488
</field>
489+
<field name="discount_description">
490+
<aspect name="to_quote" />
491+
<aspect name="to_invoice" />
492+
<aspect name="to_shipment" />
493+
<aspect name="to_cm" />
494+
</field>
489495
<field name="shipping_amount">
490496
<aspect name="to_quote_address_shipping" />
491497
<aspect name="to_cm"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Reports\Model\ResourceModel\Review\Customer;
7+
8+
/**
9+
* @magentoAppArea adminhtml
10+
*/
11+
class CollectionTest extends \PHPUnit\Framework\TestCase
12+
{
13+
/**
14+
* @var \Magento\Reports\Model\ResourceModel\Review\Customer\Collection
15+
*/
16+
private $collection;
17+
18+
protected function setUp()
19+
{
20+
$this->collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
21+
\Magento\Reports\Model\ResourceModel\Review\Customer\Collection::class
22+
);
23+
}
24+
25+
/**
26+
* This tests covers issue described in:
27+
* https://github.com/magento/magento2/issues/10301
28+
*
29+
* @magentoDataFixture Magento/Review/_files/customer_review.php
30+
*/
31+
public function testSelectCountSql()
32+
{
33+
$this->collection->addFieldToFilter('customer_name', ['like' => '%John%'])->getItems();
34+
$this->assertEquals(1, $this->collection->getSize());
35+
}
36+
}

lib/internal/Magento/Framework/View/Page/Config.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public function __construct(
173173
$this->setElementAttribute(
174174
self::ELEMENT_TYPE_HTML,
175175
self::HTML_ATTRIBUTE_LANG,
176-
str_replace('_', '-', $this->localeResolver->getLocale())
176+
strstr($this->localeResolver->getLocale(), '_', true)
177177
);
178178
}
179179

0 commit comments

Comments
 (0)