Skip to content

Commit d895fab

Browse files
committed
Merge remote-tracking branch 'origin/2.2-develop' into 2.2-develop-pr51
2 parents 7006b75 + cfba0e1 commit d895fab

File tree

20 files changed

+111
-21
lines changed

20 files changed

+111
-21
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/Product/Attribute/Backend/Sku.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ protected function _generateUniqueSku($object)
9797
public function beforeSave($object)
9898
{
9999
$this->_generateUniqueSku($object);
100+
$this->trimValue($object);
100101
return parent::beforeSave($object);
101102
}
102103

@@ -127,4 +128,17 @@ protected function _getLastSimilarAttributeValueIncrement($attribute, $object)
127128
$data = $connection->fetchOne($select, $bind);
128129
return abs((int)str_replace($value, '', $data));
129130
}
131+
132+
/**
133+
* @param Product $object
134+
* @return void
135+
*/
136+
private function trimValue($object)
137+
{
138+
$attrCode = $this->getAttribute()->getAttributeCode();
139+
$value = $object->getData($attrCode);
140+
if ($value) {
141+
$object->setData($attrCode, trim($value));
142+
}
143+
}
130144
}

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/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ protected function customizeNameListeners(array $meta)
373373
$skuPath . static::META_CONFIG_PATH,
374374
$meta,
375375
[
376-
'autoImportIfEmpty' => true
376+
'autoImportIfEmpty' => true,
377+
'validation' => ['no-marginal-whitespace' => true]
377378
]
378379
);
379380

app/code/Magento/CatalogImportExport/Model/Import/Product/Validator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\CatalogImportExport\Model\Import\Product;
99
use Magento\Framework\Validator\AbstractValidator;
10+
use Magento\Catalog\Model\Product\Attribute\Backend\Sku;
1011

1112
/**
1213
* Class Validator
@@ -69,6 +70,8 @@ protected function textValidation($attrCode, $type)
6970
$val = $this->string->cleanString($this->_rowData[$attrCode]);
7071
if ($type == 'text') {
7172
$valid = $this->string->strlen($val) < Product::DB_MAX_TEXT_LENGTH;
73+
} else if ($attrCode == Product::COL_SKU) {
74+
$valid = $this->string->strlen($val) <= SKU::SKU_MAX_LENGTH;
7275
} else {
7376
$valid = $this->string->strlen($val) < Product::DB_MAX_VARCHAR_LENGTH;
7477
}

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/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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
9+
<event name="customer_login">
10+
<observer name="customer_log_login" instance="Magento\Customer\Observer\LogLastLoginAtObserver" />
11+
</event>
12+
</config>

0 commit comments

Comments
 (0)