Skip to content

Commit d59c993

Browse files
committed
Merge remote-tracking branch 'origin/2.2-develop' into MAGETWO-73301
2 parents b0066e3 + d65f99a commit d59c993

File tree

18 files changed

+125
-24
lines changed

18 files changed

+125
-24
lines changed

app/code/Magento/Catalog/Model/Api/SearchCriteria/CollectionProcessor/ConditionProcessor/ProductCategoryCondition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private function getCategoryIds(Filter $filter): array
102102
}
103103
}
104104

105-
return array_unique(array_merge($categoryIds, ...$childCategoryIds));
105+
return array_map('intval', array_unique(array_merge($categoryIds, ...$childCategoryIds)));
106106
}
107107

108108
/**

app/code/Magento/Catalog/Model/ProductCategoryList.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ public function getCategoryIds($productId)
8181
Select::SQL_UNION_ALL
8282
);
8383

84-
$this->categoryIdList[$productId] = $this->productResource->getConnection()->fetchCol($unionSelect);
84+
$this->categoryIdList[$productId] = array_map(
85+
'intval',
86+
$this->productResource->getConnection()->fetchCol($unionSelect)
87+
);
8588
}
8689

8790
return $this->categoryIdList[$productId];

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,7 +1803,8 @@ protected function _productLimitationJoinWebsite()
18031803
}
18041804
$conditions[] = $this->getConnection()->quoteInto(
18051805
'product_website.website_id IN(?)',
1806-
$filters['website_ids']
1806+
$filters['website_ids'],
1807+
'int'
18071808
);
18081809
} elseif (isset(
18091810
$filters['store_id']
@@ -1815,7 +1816,7 @@ protected function _productLimitationJoinWebsite()
18151816
) {
18161817
$joinWebsite = true;
18171818
$websiteId = $this->_storeManager->getStore($filters['store_id'])->getWebsiteId();
1818-
$conditions[] = $this->getConnection()->quoteInto('product_website.website_id = ?', $websiteId);
1819+
$conditions[] = $this->getConnection()->quoteInto('product_website.website_id = ?', $websiteId, 'int');
18191820
}
18201821

18211822
$fromPart = $this->getSelect()->getPart(\Magento\Framework\DB\Select::FROM);
@@ -2011,12 +2012,12 @@ protected function _applyProductLimitations()
20112012

20122013
$conditions = [
20132014
'cat_index.product_id=e.entity_id',
2014-
$this->getConnection()->quoteInto('cat_index.store_id=?', $filters['store_id']),
2015+
$this->getConnection()->quoteInto('cat_index.store_id=?', $filters['store_id'], 'int'),
20152016
];
20162017
if (isset($filters['visibility']) && !isset($filters['store_table'])) {
2017-
$conditions[] = $this->getConnection()->quoteInto('cat_index.visibility IN(?)', $filters['visibility']);
2018+
$conditions[] = $this->getConnection()->quoteInto('cat_index.visibility IN(?)', $filters['visibility'], 'int');
20182019
}
2019-
$conditions[] = $this->getConnection()->quoteInto('cat_index.category_id=?', $filters['category_id']);
2020+
$conditions[] = $this->getConnection()->quoteInto('cat_index.category_id=?', $filters['category_id'], 'int');
20202021
if (isset($filters['category_is_anchor'])) {
20212022
$conditions[] = $this->getConnection()->quoteInto('cat_index.is_parent=?', $filters['category_is_anchor']);
20222023
}

app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,20 @@ public function getSearchableAttributes($backendType = null)
316316
/** @var \Magento\Eav\Model\Entity\Attribute[] $attributes */
317317
$attributes = $productAttributes->getItems();
318318

319+
/**
320+
* @deprecated Event argument catelogsearch_searchable_attributes_load_after.
321+
* @see catalogsearch_searchable_attributes_load_after instead.
322+
*/
319323
$this->eventManager->dispatch(
320324
'catelogsearch_searchable_attributes_load_after',
321325
['engine' => $this->engine, 'attributes' => $attributes]
322326
);
323327

328+
$this->eventManager->dispatch(
329+
'catalogsearch_searchable_attributes_load_after',
330+
['engine' => $this->engine, 'attributes' => $attributes]
331+
);
332+
324333
$entity = $this->eavConfig->getEntityType(\Magento\Catalog\Model\Product::ENTITY)->getEntity();
325334

326335
foreach ($attributes as $attribute) {

app/code/Magento/CatalogWidget/Block/Product/ProductsList.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public function getProductPriceHtml(
196196
? $arguments['display_minimal_price']
197197
: true;
198198

199-
/** @var \Magento\Framework\Pricing\Render $priceRender */
199+
/** @var \Magento\Framework\Pricing\Render $priceRender */
200200
$priceRender = $this->getLayout()->getBlock('product.price.render.default');
201201

202202
$price = '';
@@ -338,7 +338,7 @@ public function getPagerHtml()
338338
if (!$this->pager) {
339339
$this->pager = $this->getLayout()->createBlock(
340340
\Magento\Catalog\Block\Product\Widget\Html\Pager::class,
341-
'widget.products.list.pager'
341+
$this->getWidgetPagerBlockName()
342342
);
343343

344344
$this->pager->setUseContainer(true)
@@ -398,4 +398,19 @@ private function getPriceCurrency()
398398
}
399399
return $this->priceCurrency;
400400
}
401+
402+
/**
403+
* @return string
404+
*/
405+
private function getWidgetPagerBlockName()
406+
{
407+
$pageName = $this->getData('page_var_name');
408+
$pagerBlockName = 'widget.products.list.pager';
409+
410+
if (!$pageName) {
411+
return $pagerBlockName;
412+
}
413+
414+
return $pagerBlockName . '.' . $pageName;
415+
}
401416
}

app/code/Magento/Checkout/Model/PaymentInformationManagement.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,8 @@ public function savePaymentInformation(
114114
$quote->setDataChanges(true);
115115
$shippingAddress = $quote->getShippingAddress();
116116
if ($shippingAddress && $shippingAddress->getShippingMethod()) {
117-
$shippingDataArray = explode('_', $shippingAddress->getShippingMethod());
118-
$shippingCarrier = array_shift($shippingDataArray);
119-
$shippingAddress->setLimitCarrier($shippingCarrier);
117+
$shippingRate = $shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod());
118+
$shippingAddress->setLimitCarrier($shippingRate->getCarrier());
120119
}
121120
}
122121
$this->paymentMethodManagement->set($cartId, $paymentMethod);

app/code/Magento/Checkout/Test/Unit/Model/PaymentInformationManagementTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,11 @@ private function getMockForAssignBillingAddress($cartId, $billingAddressMock)
168168
$billingAddressId = 1;
169169
$quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
170170
$quoteBillingAddress = $this->createMock(\Magento\Quote\Model\Quote\Address::class);
171+
$shippingRate = $this->createPartialMock(\Magento\Quote\Model\Quote\Address\Rate::class, []);
172+
$shippingRate->setCarrier('flatrate');
171173
$quoteShippingAddress = $this->createPartialMock(
172174
\Magento\Quote\Model\Quote\Address::class,
173-
['setLimitCarrier', 'getShippingMethod']
175+
['setLimitCarrier', 'getShippingMethod', 'getShippingRateByCode']
174176
);
175177
$this->cartRepositoryMock->expects($this->any())->method('getActive')->with($cartId)->willReturn($quoteMock);
176178
$quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($quoteBillingAddress);
@@ -179,6 +181,7 @@ private function getMockForAssignBillingAddress($cartId, $billingAddressMock)
179181
$quoteMock->expects($this->once())->method('removeAddress')->with($billingAddressId);
180182
$quoteMock->expects($this->once())->method('setBillingAddress')->with($billingAddressMock);
181183
$quoteMock->expects($this->once())->method('setDataChanges')->willReturnSelf();
184+
$quoteShippingAddress->expects($this->any())->method('getShippingRateByCode')->willReturn($shippingRate);
182185
$quoteShippingAddress->expects($this->any())->method('getShippingMethod')->willReturn('flatrate_flatrate');
183186
$quoteShippingAddress->expects($this->once())->method('setLimitCarrier')->with('flatrate')->willReturnSelf();
184187
}

app/code/Magento/Checkout/view/frontend/web/js/model/checkout-data-resolver.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,16 +218,31 @@ define([
218218
* Apply resolved billing address to quote
219219
*/
220220
applyBillingAddress: function () {
221-
var shippingAddress;
221+
var shippingAddress,
222+
isBillingAddressInitialized;
222223

223224
if (quote.billingAddress()) {
224225
selectBillingAddress(quote.billingAddress());
225226

226227
return;
227228
}
229+
230+
if (quote.isVirtual()) {
231+
isBillingAddressInitialized = addressList.some(function (addrs) {
232+
if (addrs.isDefaultBilling()) {
233+
selectBillingAddress(addrs);
234+
235+
return true;
236+
}
237+
238+
return false;
239+
});
240+
}
241+
228242
shippingAddress = quote.shippingAddress();
229243

230-
if (shippingAddress &&
244+
if (!isBillingAddressInitialized &&
245+
shippingAddress &&
231246
shippingAddress.canUseForBilling() &&
232247
(shippingAddress.isDefaultShipping() || !quote.isVirtual())
233248
) {

app/code/Magento/Integration/Model/CustomerTokenService.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Integration\Model\ResourceModel\Oauth\Token\CollectionFactory as TokenCollectionFactory;
1515
use Magento\Integration\Model\Oauth\Token\RequestThrottler;
1616
use Magento\Framework\Exception\AuthenticationException;
17+
use Magento\Framework\Event\ManagerInterface;
1718

1819
class CustomerTokenService implements \Magento\Integration\Api\CustomerTokenServiceInterface
1920
{
@@ -48,24 +49,33 @@ class CustomerTokenService implements \Magento\Integration\Api\CustomerTokenServ
4849
*/
4950
private $requestThrottler;
5051

52+
/**
53+
* @var Magento\Framework\Event\ManagerInterface
54+
*/
55+
private $eventManager;
56+
5157
/**
5258
* Initialize service
5359
*
5460
* @param TokenModelFactory $tokenModelFactory
5561
* @param AccountManagementInterface $accountManagement
5662
* @param TokenCollectionFactory $tokenModelCollectionFactory
5763
* @param \Magento\Integration\Model\CredentialsValidator $validatorHelper
64+
* @param \Magento\Framework\Event\ManagerInterface $eventManager
5865
*/
5966
public function __construct(
6067
TokenModelFactory $tokenModelFactory,
6168
AccountManagementInterface $accountManagement,
6269
TokenCollectionFactory $tokenModelCollectionFactory,
63-
CredentialsValidator $validatorHelper
70+
CredentialsValidator $validatorHelper,
71+
ManagerInterface $eventManager = null
6472
) {
6573
$this->tokenModelFactory = $tokenModelFactory;
6674
$this->accountManagement = $accountManagement;
6775
$this->tokenModelCollectionFactory = $tokenModelCollectionFactory;
6876
$this->validatorHelper = $validatorHelper;
77+
$this->eventManager = $eventManager ?: \Magento\Framework\App\ObjectManager::getInstance()
78+
->get(ManagerInterface::class);
6979
}
7080

7181
/**
@@ -83,6 +93,7 @@ public function createCustomerAccessToken($username, $password)
8393
__('You did not sign in correctly or your account is temporarily disabled.')
8494
);
8595
}
96+
$this->eventManager->dispatch('customer_login', ['customer' => $customerDataObject]);
8697
$this->getRequestThrottler()->resetAuthenticationFailuresCount($username, RequestThrottler::USER_TYPE_CUSTOMER);
8798
return $this->tokenModelFactory->create()->createCustomerToken($customerDataObject->getId())->getToken();
8899
}

app/code/Magento/Integration/Test/Unit/Model/CustomerTokenServiceTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ class CustomerTokenServiceTest extends \PHPUnit\Framework\TestCase
3232
/** @var \Magento\Integration\Model\Oauth\Token|\PHPUnit_Framework_MockObject_MockObject */
3333
private $_tokenMock;
3434

35+
/** @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */
36+
protected $manager;
37+
3538
protected function setUp()
3639
{
3740
$this->_tokenFactoryMock = $this->getMockBuilder(\Magento\Integration\Model\Oauth\TokenFactory::class)
@@ -67,11 +70,14 @@ protected function setUp()
6770
\Magento\Integration\Model\CredentialsValidator::class
6871
)->disableOriginalConstructor()->getMock();
6972

73+
$this->manager = $this->createMock(\Magento\Framework\Event\ManagerInterface::class);
74+
7075
$this->_tokenService = new \Magento\Integration\Model\CustomerTokenService(
7176
$this->_tokenFactoryMock,
7277
$this->_accountManagementMock,
7378
$this->_tokenModelCollectionFactoryMock,
74-
$this->validatorHelperMock
79+
$this->validatorHelperMock,
80+
$this->manager
7581
);
7682
}
7783

0 commit comments

Comments
 (0)