Skip to content

Commit d700436

Browse files
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #20739: [Backport] issue fixed #20563 Go to shipping information, Update qty & Addresses� (by @amol2jcommerce) - #20744: [Backport] recent-order-product-title-misaligned (by @amol2jcommerce) - #20270: [Backport] Fixed-Widget-option-labels-are-misalinged (by @amol2jcommerce) - #20613: [Backport] admin-order-info-issue2.2 (by @dipti2jcommerce) - #20418: [Backport] issue fixed #20304 No space between step title and saved address in c� (by @shikhamis11) - #20285: [Backport]#20222 Canary islands in ups carrier 2.2 (by @duckchip) - #18809: [Backport] catalog:images:resize total images count calculates incorrectly #18387 (by @vpodorozh) - #19461: [Backport 2.2] issue #18931 fixed. (by @JeroenVanLeusden) - #19655: Fixed - Shipping issue on PayPal Express #14712 (by @ssp58bleuciel) Fixed GitHub Issues: - #20563: Go to shipping information, Update qty & Addresses and Enter a new address button Not aligned from left and right in 767px screen size (reported by @swetacedcoss) has been fixed in #20739 by @amol2jcommerce in 2.2-develop branch Related commits: 1. 6e7281d - #20500: Recent Order Product Title Misaligned in Sidebar (reported by @parag2jcommerce) has been fixed in #20744 by @amol2jcommerce in 2.2-develop branch Related commits: 1. a971270 2. 81d8781 3. 73cb5c8 - #20113: Widget option labels are misalinged (reported by @yashwant2jcommerce) has been fixed in #20270 by @amol2jcommerce in 2.2-develop branch Related commits: 1. 936d71f 2. 935d3d2 - #20609: Currency rate value not align proper in order information tab when we create creditmemo from admin (reported by @dipti2jcommerce) has been fixed in #20613 by @dipti2jcommerce in 2.2-develop branch Related commits: 1. 7bf7ce1 - #20304: No space between step title and saved address in checkout (reported by @swetacedcoss) has been fixed in #20418 by @shikhamis11 in 2.2-develop branch Related commits: 1. 16d7461 - #18387: catalog:images:resize fails to process all images -> Possible underlying Magento/Framework/DB/Query/Generator issue (reported by @gwharton) has been fixed in #18809 by @vpodorozh in 2.2-develop branch Related commits: 1. f114f2a 2. 95eeb9f 3. 84590de 4. 4653d3e 5. d2e5345 6. 2539a71 7. 76bd089 8. b81b550 9. 051d82d 10. 10a1a88 - #18931: Product added to shopping cart / comparison list message not translated by default (reported by @arnoudhgz) has been fixed in #19461 by @JeroenVanLeusden in 2.2-develop branch Related commits: 1. 3b521b0 - #14712: Shipping issue on PayPal Express (reported by @raymond62) has been fixed in #19655 by @ssp58bleuciel in 2.2-develop branch Related commits: 1. 8a059e6 2. 8bdcca9 3. c3d5010
2 parents 3f4f56c + 7b1855c commit d700436

File tree

15 files changed

+289
-10
lines changed

15 files changed

+289
-10
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Product/Image.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Magento\Framework\App\ResourceConnection;
1414

1515
/**
16-
* Class for fast retrieval of all product images
16+
* Class for retrieval of all product images
1717
*/
1818
class Image
1919
{
@@ -76,15 +76,24 @@ public function getAllProductImages(): \Generator
7676

7777
/**
7878
* Get the number of unique pictures of products
79+
*
7980
* @return int
8081
*/
8182
public function getCountAllProductImages(): int
8283
{
83-
$select = $this->getVisibleImagesSelect()->reset('columns')->columns('count(*)');
84+
$select = $this->getVisibleImagesSelect()
85+
->reset('columns')
86+
->reset('distinct')
87+
->columns(
88+
new \Zend_Db_Expr('count(distinct value)')
89+
);
90+
8491
return (int) $this->connection->fetchOne($select);
8592
}
8693

8794
/**
95+
* Return Select to fetch all products images
96+
*
8897
* @return Select
8998
*/
9099
private function getVisibleImagesSelect(): Select
Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product;
9+
10+
use Magento\Catalog\Model\ResourceModel\Product\Image;
11+
use Magento\Framework\DB\Adapter\AdapterInterface;
12+
use Magento\Framework\DB\Query\Generator;
13+
use Magento\Framework\DB\Select;
14+
use Magento\Framework\App\ResourceConnection;
15+
use Magento\Catalog\Model\ResourceModel\Product\Gallery;
16+
use PHPUnit_Framework_MockObject_MockObject as MockObject;
17+
use Magento\Framework\DB\Query\BatchIteratorInterface;
18+
19+
class ImageTest extends \PHPUnit\Framework\TestCase
20+
{
21+
/**
22+
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
23+
*/
24+
protected $objectManager;
25+
26+
/**
27+
* @var AdapterInterface | MockObject
28+
*/
29+
protected $connectionMock;
30+
31+
/**
32+
* @var Generator | MockObject
33+
*/
34+
protected $generatorMock;
35+
36+
/**
37+
* @var ResourceConnection | MockObject
38+
*/
39+
protected $resourceMock;
40+
41+
protected function setUp()
42+
{
43+
$this->objectManager =
44+
new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
45+
$this->connectionMock = $this->createMock(AdapterInterface::class);
46+
$this->resourceMock = $this->createMock(ResourceConnection::class);
47+
$this->resourceMock->method('getConnection')
48+
->willReturn($this->connectionMock);
49+
$this->resourceMock->method('getTableName')
50+
->willReturnArgument(0);
51+
$this->generatorMock = $this->createMock(Generator::class);
52+
}
53+
54+
/**
55+
* @return MockObject
56+
*/
57+
protected function getVisibleImagesSelectMock(): MockObject
58+
{
59+
$selectMock = $this->getMockBuilder(Select::class)
60+
->disableOriginalConstructor()
61+
->getMock();
62+
$selectMock->expects($this->once())
63+
->method('distinct')
64+
->willReturnSelf();
65+
$selectMock->expects($this->once())
66+
->method('from')
67+
->with(
68+
['images' => Gallery::GALLERY_TABLE],
69+
'value as filepath'
70+
)->willReturnSelf();
71+
$selectMock->expects($this->once())
72+
->method('where')
73+
->with('disabled = 0')
74+
->willReturnSelf();
75+
76+
return $selectMock;
77+
}
78+
79+
/**
80+
* @param int $imagesCount
81+
* @dataProvider dataProvider
82+
*/
83+
public function testGetCountAllProductImages(int $imagesCount)
84+
{
85+
$selectMock = $this->getVisibleImagesSelectMock();
86+
$selectMock->expects($this->exactly(2))
87+
->method('reset')
88+
->withConsecutive(
89+
['columns'],
90+
['distinct']
91+
)->willReturnSelf();
92+
$selectMock->expects($this->once())
93+
->method('columns')
94+
->with(new \Zend_Db_Expr('count(distinct value)'))
95+
->willReturnSelf();
96+
97+
$this->connectionMock->expects($this->once())
98+
->method('select')
99+
->willReturn($selectMock);
100+
$this->connectionMock->expects($this->once())
101+
->method('fetchOne')
102+
->with($selectMock)
103+
->willReturn($imagesCount);
104+
105+
$imageModel = $this->objectManager->getObject(
106+
Image::class,
107+
[
108+
'generator' => $this->generatorMock,
109+
'resourceConnection' => $this->resourceMock
110+
]
111+
);
112+
113+
$this->assertSame(
114+
$imagesCount,
115+
$imageModel->getCountAllProductImages()
116+
);
117+
}
118+
119+
/**
120+
* @param int $imagesCount
121+
* @param int $batchSize
122+
* @dataProvider dataProvider
123+
*/
124+
public function testGetAllProductImages(
125+
int $imagesCount,
126+
int $batchSize
127+
) {
128+
$this->connectionMock->expects($this->once())
129+
->method('select')
130+
->willReturn($this->getVisibleImagesSelectMock());
131+
132+
$batchCount = (int)ceil($imagesCount / $batchSize);
133+
$fetchResultsCallback = $this->getFetchResultCallbackForBatches($imagesCount, $batchSize);
134+
$this->connectionMock->expects($this->exactly($batchCount))
135+
->method('fetchAll')
136+
->will($this->returnCallback($fetchResultsCallback));
137+
138+
/** @var Select | MockObject $selectMock */
139+
$selectMock = $this->getMockBuilder(Select::class)
140+
->disableOriginalConstructor()
141+
->getMock();
142+
143+
$this->generatorMock->expects($this->once())
144+
->method('generate')
145+
->with(
146+
'value_id',
147+
$selectMock,
148+
$batchSize,
149+
BatchIteratorInterface::NON_UNIQUE_FIELD_ITERATOR
150+
)->will(
151+
$this->returnCallback(
152+
$this->getBatchIteratorCallback($selectMock, $batchCount)
153+
)
154+
);
155+
156+
$imageModel = $this->objectManager->getObject(
157+
Image::class,
158+
[
159+
'generator' => $this->generatorMock,
160+
'resourceConnection' => $this->resourceMock,
161+
'batchSize' => $batchSize
162+
]
163+
);
164+
165+
$this->assertCount($imagesCount, $imageModel->getAllProductImages());
166+
}
167+
168+
/**
169+
* @param int $imagesCount
170+
* @param int $batchSize
171+
* @return \Closure
172+
*/
173+
protected function getFetchResultCallbackForBatches(
174+
int $imagesCount,
175+
int $batchSize
176+
): \Closure {
177+
$fetchResultsCallback = function () use (&$imagesCount, $batchSize) {
178+
$batchSize =
179+
($imagesCount >= $batchSize) ? $batchSize : $imagesCount;
180+
$imagesCount -= $batchSize;
181+
182+
$getFetchResults = function ($batchSize): array {
183+
$result = [];
184+
$count = $batchSize;
185+
while ($count) {
186+
$count--;
187+
$result[$count] = $count;
188+
}
189+
190+
return $result;
191+
};
192+
193+
return $getFetchResults($batchSize);
194+
};
195+
196+
return $fetchResultsCallback;
197+
}
198+
199+
/**
200+
* @param Select | MockObject $selectMock
201+
* @param int $batchCount
202+
* @return \Closure
203+
*/
204+
protected function getBatchIteratorCallback(
205+
MockObject $selectMock,
206+
int $batchCount
207+
): \Closure {
208+
$iteratorCallback = function () use ($batchCount, $selectMock): array {
209+
$result = [];
210+
$count = $batchCount;
211+
while ($count) {
212+
$count--;
213+
$result[$count] = $selectMock;
214+
}
215+
216+
return $result;
217+
};
218+
219+
return $iteratorCallback;
220+
}
221+
222+
/**
223+
* Data Provider
224+
* @return array
225+
*/
226+
public function dataProvider(): array
227+
{
228+
return [
229+
[300, 300],
230+
[300, 100],
231+
[139, 100],
232+
[67, 10],
233+
[154, 47],
234+
[0, 100]
235+
];
236+
}
237+
}

app/code/Magento/Catalog/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,3 +798,4 @@ Details,Details
798798
"Add To Compare","Add To Compare"
799799
"Learn more","Learn more"
800800
"Recently Viewed","Recently Viewed"
801+
"You added product %1 to the <a href=""%2"">comparison list</a>.","You added product %1 to the <a href=""%2"">comparison list</a>."

app/code/Magento/Checkout/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,4 @@ Payment,Payment
181181
"Item in Cart","Item in Cart"
182182
"Items in Cart","Items in Cart"
183183
"Close","Close"
184+
"You added %1 to your <a href=""%2"">shopping cart</a>.","You added %1 to your <a href=""%2"">shopping cart</a>."

app/code/Magento/Quote/Model/Quote/Address/Total/Shipping.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Magento\Quote\Api\Data\AddressInterface;
1010
use Magento\Quote\Model\Quote\Address\FreeShippingInterface;
1111

12+
/**
13+
* Collect totals for shipping.
14+
*/
1215
class Shipping extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
1316
{
1417
/**
@@ -111,7 +114,7 @@ public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Qu
111114
{
112115
$amount = $total->getShippingAmount();
113116
$shippingDescription = $total->getShippingDescription();
114-
$title = ($amount != 0 && $shippingDescription)
117+
$title = ($shippingDescription)
115118
? __('Shipping & Handling (%1)', $shippingDescription)
116119
: __('Shipping & Handling');
117120

@@ -227,7 +230,7 @@ private function getAssignmentWeightData(AddressInterface $address, array $items
227230
* @param bool $addressFreeShipping
228231
* @param float $itemWeight
229232
* @param float $itemQty
230-
* @param $freeShipping
233+
* @param bool $freeShipping
231234
* @return float
232235
*/
233236
private function getItemRowWeight(

app/code/Magento/Sales/view/adminhtml/templates/order/view/info.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ $customerUrl = $block->getCustomerViewUrl();
104104
<?php if ($order->getBaseCurrencyCode() != $order->getOrderCurrencyCode()): ?>
105105
<tr>
106106
<th><?= $block->escapeHtml(__('%1 / %2 rate:', $order->getOrderCurrencyCode(), $order->getBaseCurrencyCode())) ?></th>
107-
<th><?= $block->escapeHtml($order->getBaseToOrderRate()) ?></th>
107+
<td><?= $block->escapeHtml($order->getBaseToOrderRate()) ?></td>
108108
</tr>
109109
<?php endif; ?>
110110
</table>

app/code/Magento/Shipping/Model/Carrier/AbstractCarrierOnline.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ abstract class AbstractCarrierOnline extends AbstractCarrier
2828

2929
const GUAM_REGION_CODE = 'GU';
3030

31+
const SPAIN_COUNTRY_ID = 'ES';
32+
33+
const CANARY_ISLANDS_COUNTRY_ID = 'IC';
34+
35+
const SANTA_CRUZ_DE_TENERIFE_REGION_ID = 'Santa Cruz de Tenerife';
36+
37+
const LAS_PALMAS_REGION_ID = 'Las Palmas';
38+
3139
/**
3240
* Array of quotes
3341
*

app/code/Magento/Ups/Model/Carrier.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,14 @@ public function setRequest(RateRequest $request)
334334
$destCountry = self::GUAM_COUNTRY_ID;
335335
}
336336

337+
// For UPS, Las Palmas and Santa Cruz de Tenerife will be represented by Canary Islands country
338+
if (
339+
$destCountry == self::SPAIN_COUNTRY_ID &&
340+
($request->getDestRegionCode() == self::LAS_PALMAS_REGION_ID || $request->getDestRegionCode() == self::SANTA_CRUZ_DE_TENERIFE_REGION_ID)
341+
) {
342+
$destCountry = self::CANARY_ISLANDS_COUNTRY_ID;
343+
}
344+
337345
$country = $this->_countryFactory->create()->load($destCountry);
338346
$rowRequest->setDestCountry($country->getData('iso2_code') ?: $destCountry);
339347

app/design/adminhtml/Magento/backend/web/css/styles-old.less

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2738,7 +2738,8 @@
27382738
// ---------------------------------------------
27392739

27402740
#widget_instace_tabs_properties_section_content .widget-option-label {
2741-
margin-top: 6px;
2741+
margin-top: 7px;
2742+
display: inline-block;
27422743
}
27432744

27442745
//

app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/_module.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@
488488

489489
.product-items-names {
490490
.product-item {
491+
display: flex;
491492
margin-bottom: @indent__s;
492493
}
493494

0 commit comments

Comments
 (0)