Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.2-develop
Browse files Browse the repository at this point in the history
Accepted Public Pull Requests:
 - magento#20739: [Backport] issue fixed magento#20563 Go to shipping information, Update qty & Addresses� (by @amol2jcommerce)
 - magento#20744: [Backport] recent-order-product-title-misaligned (by @amol2jcommerce)
 - magento#20270: [Backport] Fixed-Widget-option-labels-are-misalinged (by @amol2jcommerce)
 - magento#20613: [Backport] admin-order-info-issue2.2 (by @dipti2jcommerce)
 - magento#20418: [Backport] issue fixed magento#20304 No space between step title and saved address in c� (by @shikhamis11)
 - magento#20285: [Backport]magento#20222 Canary islands in ups carrier 2.2 (by @duckchip)
 - magento#18809: [Backport] catalog:images:resize total images count calculates incorrectly magento#18387 (by @vpodorozh)
 - magento#19461: [Backport 2.2] issue magento#18931 fixed. (by @JeroenVanLeusden)
 - magento#19655: Fixed - Shipping issue on PayPal Express magento#14712 (by @ssp58bleuciel)


Fixed GitHub Issues:
 - magento#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 magento#20739 by @amol2jcommerce in 2.2-develop branch
   Related commits:
     1. 6e7281d

 - magento#20500: Recent Order Product Title Misaligned in Sidebar (reported by @parag2jcommerce) has been fixed in magento#20744 by @amol2jcommerce in 2.2-develop branch
   Related commits:
     1. a971270
     2. 81d8781
     3. 73cb5c8

 - magento#20113: Widget option labels are misalinged (reported by @yashwant2jcommerce) has been fixed in magento#20270 by @amol2jcommerce in 2.2-develop branch
   Related commits:
     1. 936d71f
     2. 935d3d2

 - magento#20609: Currency rate value not align proper in order information tab  when we create creditmemo from admin (reported by @dipti2jcommerce) has been fixed in magento#20613 by @dipti2jcommerce in 2.2-develop branch
   Related commits:
     1. 7bf7ce1

 - magento#20304: No space between step title and saved address in checkout  (reported by @swetacedcoss) has been fixed in magento#20418 by @shikhamis11 in 2.2-develop branch
   Related commits:
     1. 16d7461

 - magento#18387: catalog:images:resize fails to process all images -> Possible underlying Magento/Framework/DB/Query/Generator issue (reported by @gwharton) has been fixed in magento#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

 - magento#18931: Product added to shopping cart / comparison list message not translated by default (reported by @arnoudhgz) has been fixed in magento#19461 by @JeroenVanLeusden in 2.2-develop branch
   Related commits:
     1. 3b521b0

 - magento#14712: Shipping issue on PayPal Express (reported by @raymond62) has been fixed in magento#19655 by @ssp58bleuciel in 2.2-develop branch
   Related commits:
     1. 8a059e6
     2. 8bdcca9
     3. c3d5010
  • Loading branch information
magento-engcom-team authored Jan 31, 2019
2 parents 3f4f56c + 7b1855c commit d700436
Show file tree
Hide file tree
Showing 15 changed files with 289 additions and 10 deletions.
13 changes: 11 additions & 2 deletions app/code/Magento/Catalog/Model/ResourceModel/Product/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Magento\Framework\App\ResourceConnection;

/**
* Class for fast retrieval of all product images
* Class for retrieval of all product images
*/
class Image
{
Expand Down Expand Up @@ -76,15 +76,24 @@ public function getAllProductImages(): \Generator

/**
* Get the number of unique pictures of products
*
* @return int
*/
public function getCountAllProductImages(): int
{
$select = $this->getVisibleImagesSelect()->reset('columns')->columns('count(*)');
$select = $this->getVisibleImagesSelect()
->reset('columns')
->reset('distinct')
->columns(
new \Zend_Db_Expr('count(distinct value)')
);

return (int) $this->connection->fetchOne($select);
}

/**
* Return Select to fetch all products images
*
* @return Select
*/
private function getVisibleImagesSelect(): Select
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product;

use Magento\Catalog\Model\ResourceModel\Product\Image;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Query\Generator;
use Magento\Framework\DB\Select;
use Magento\Framework\App\ResourceConnection;
use Magento\Catalog\Model\ResourceModel\Product\Gallery;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Magento\Framework\DB\Query\BatchIteratorInterface;

class ImageTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
*/
protected $objectManager;

/**
* @var AdapterInterface | MockObject
*/
protected $connectionMock;

/**
* @var Generator | MockObject
*/
protected $generatorMock;

/**
* @var ResourceConnection | MockObject
*/
protected $resourceMock;

protected function setUp()
{
$this->objectManager =
new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->connectionMock = $this->createMock(AdapterInterface::class);
$this->resourceMock = $this->createMock(ResourceConnection::class);
$this->resourceMock->method('getConnection')
->willReturn($this->connectionMock);
$this->resourceMock->method('getTableName')
->willReturnArgument(0);
$this->generatorMock = $this->createMock(Generator::class);
}

/**
* @return MockObject
*/
protected function getVisibleImagesSelectMock(): MockObject
{
$selectMock = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->getMock();
$selectMock->expects($this->once())
->method('distinct')
->willReturnSelf();
$selectMock->expects($this->once())
->method('from')
->with(
['images' => Gallery::GALLERY_TABLE],
'value as filepath'
)->willReturnSelf();
$selectMock->expects($this->once())
->method('where')
->with('disabled = 0')
->willReturnSelf();

return $selectMock;
}

/**
* @param int $imagesCount
* @dataProvider dataProvider
*/
public function testGetCountAllProductImages(int $imagesCount)
{
$selectMock = $this->getVisibleImagesSelectMock();
$selectMock->expects($this->exactly(2))
->method('reset')
->withConsecutive(
['columns'],
['distinct']
)->willReturnSelf();
$selectMock->expects($this->once())
->method('columns')
->with(new \Zend_Db_Expr('count(distinct value)'))
->willReturnSelf();

$this->connectionMock->expects($this->once())
->method('select')
->willReturn($selectMock);
$this->connectionMock->expects($this->once())
->method('fetchOne')
->with($selectMock)
->willReturn($imagesCount);

$imageModel = $this->objectManager->getObject(
Image::class,
[
'generator' => $this->generatorMock,
'resourceConnection' => $this->resourceMock
]
);

$this->assertSame(
$imagesCount,
$imageModel->getCountAllProductImages()
);
}

/**
* @param int $imagesCount
* @param int $batchSize
* @dataProvider dataProvider
*/
public function testGetAllProductImages(
int $imagesCount,
int $batchSize
) {
$this->connectionMock->expects($this->once())
->method('select')
->willReturn($this->getVisibleImagesSelectMock());

$batchCount = (int)ceil($imagesCount / $batchSize);
$fetchResultsCallback = $this->getFetchResultCallbackForBatches($imagesCount, $batchSize);
$this->connectionMock->expects($this->exactly($batchCount))
->method('fetchAll')
->will($this->returnCallback($fetchResultsCallback));

/** @var Select | MockObject $selectMock */
$selectMock = $this->getMockBuilder(Select::class)
->disableOriginalConstructor()
->getMock();

$this->generatorMock->expects($this->once())
->method('generate')
->with(
'value_id',
$selectMock,
$batchSize,
BatchIteratorInterface::NON_UNIQUE_FIELD_ITERATOR
)->will(
$this->returnCallback(
$this->getBatchIteratorCallback($selectMock, $batchCount)
)
);

$imageModel = $this->objectManager->getObject(
Image::class,
[
'generator' => $this->generatorMock,
'resourceConnection' => $this->resourceMock,
'batchSize' => $batchSize
]
);

$this->assertCount($imagesCount, $imageModel->getAllProductImages());
}

/**
* @param int $imagesCount
* @param int $batchSize
* @return \Closure
*/
protected function getFetchResultCallbackForBatches(
int $imagesCount,
int $batchSize
): \Closure {
$fetchResultsCallback = function () use (&$imagesCount, $batchSize) {
$batchSize =
($imagesCount >= $batchSize) ? $batchSize : $imagesCount;
$imagesCount -= $batchSize;

$getFetchResults = function ($batchSize): array {
$result = [];
$count = $batchSize;
while ($count) {
$count--;
$result[$count] = $count;
}

return $result;
};

return $getFetchResults($batchSize);
};

return $fetchResultsCallback;
}

/**
* @param Select | MockObject $selectMock
* @param int $batchCount
* @return \Closure
*/
protected function getBatchIteratorCallback(
MockObject $selectMock,
int $batchCount
): \Closure {
$iteratorCallback = function () use ($batchCount, $selectMock): array {
$result = [];
$count = $batchCount;
while ($count) {
$count--;
$result[$count] = $selectMock;
}

return $result;
};

return $iteratorCallback;
}

/**
* Data Provider
* @return array
*/
public function dataProvider(): array
{
return [
[300, 300],
[300, 100],
[139, 100],
[67, 10],
[154, 47],
[0, 100]
];
}
}
1 change: 1 addition & 0 deletions app/code/Magento/Catalog/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -798,3 +798,4 @@ Details,Details
"Add To Compare","Add To Compare"
"Learn more","Learn more"
"Recently Viewed","Recently Viewed"
"You added product %1 to the <a href=""%2"">comparison list</a>.","You added product %1 to the <a href=""%2"">comparison list</a>."
1 change: 1 addition & 0 deletions app/code/Magento/Checkout/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,4 @@ Payment,Payment
"Item in Cart","Item in Cart"
"Items in Cart","Items in Cart"
"Close","Close"
"You added %1 to your <a href=""%2"">shopping cart</a>.","You added %1 to your <a href=""%2"">shopping cart</a>."
7 changes: 5 additions & 2 deletions app/code/Magento/Quote/Model/Quote/Address/Total/Shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use Magento\Quote\Api\Data\AddressInterface;
use Magento\Quote\Model\Quote\Address\FreeShippingInterface;

/**
* Collect totals for shipping.
*/
class Shipping extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
{
/**
Expand Down Expand Up @@ -111,7 +114,7 @@ public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Qu
{
$amount = $total->getShippingAmount();
$shippingDescription = $total->getShippingDescription();
$title = ($amount != 0 && $shippingDescription)
$title = ($shippingDescription)
? __('Shipping & Handling (%1)', $shippingDescription)
: __('Shipping & Handling');

Expand Down Expand Up @@ -227,7 +230,7 @@ private function getAssignmentWeightData(AddressInterface $address, array $items
* @param bool $addressFreeShipping
* @param float $itemWeight
* @param float $itemQty
* @param $freeShipping
* @param bool $freeShipping
* @return float
*/
private function getItemRowWeight(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ $customerUrl = $block->getCustomerViewUrl();
<?php if ($order->getBaseCurrencyCode() != $order->getOrderCurrencyCode()): ?>
<tr>
<th><?= $block->escapeHtml(__('%1 / %2 rate:', $order->getOrderCurrencyCode(), $order->getBaseCurrencyCode())) ?></th>
<th><?= $block->escapeHtml($order->getBaseToOrderRate()) ?></th>
<td><?= $block->escapeHtml($order->getBaseToOrderRate()) ?></td>
</tr>
<?php endif; ?>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ abstract class AbstractCarrierOnline extends AbstractCarrier

const GUAM_REGION_CODE = 'GU';

const SPAIN_COUNTRY_ID = 'ES';

const CANARY_ISLANDS_COUNTRY_ID = 'IC';

const SANTA_CRUZ_DE_TENERIFE_REGION_ID = 'Santa Cruz de Tenerife';

const LAS_PALMAS_REGION_ID = 'Las Palmas';

/**
* Array of quotes
*
Expand Down
8 changes: 8 additions & 0 deletions app/code/Magento/Ups/Model/Carrier.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,14 @@ public function setRequest(RateRequest $request)
$destCountry = self::GUAM_COUNTRY_ID;
}

// For UPS, Las Palmas and Santa Cruz de Tenerife will be represented by Canary Islands country
if (
$destCountry == self::SPAIN_COUNTRY_ID &&
($request->getDestRegionCode() == self::LAS_PALMAS_REGION_ID || $request->getDestRegionCode() == self::SANTA_CRUZ_DE_TENERIFE_REGION_ID)
) {
$destCountry = self::CANARY_ISLANDS_COUNTRY_ID;
}

$country = $this->_countryFactory->create()->load($destCountry);
$rowRequest->setDestCountry($country->getData('iso2_code') ?: $destCountry);

Expand Down
3 changes: 2 additions & 1 deletion app/design/adminhtml/Magento/backend/web/css/styles-old.less
Original file line number Diff line number Diff line change
Expand Up @@ -2738,7 +2738,8 @@
// ---------------------------------------------

#widget_instace_tabs_properties_section_content .widget-option-label {
margin-top: 6px;
margin-top: 7px;
display: inline-block;
}

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@

.product-items-names {
.product-item {
display: flex;
margin-bottom: @indent__s;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@

.product-items-names {
.product-item {
display: flex;
margin-bottom: @indent__s;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
.step-title {
&:extend(.abs-checkout-title all);
.lib-css(border-bottom, @checkout-step-title__border);
margin-bottom: 15px;
}

.step-content {
Expand Down
Loading

0 comments on commit d700436

Please sign in to comment.