Skip to content

Commit 774e991

Browse files
merge magento/2.2-develop into magento-tsg/2.2-develop-pr104
2 parents afb69c5 + dbb41dc commit 774e991

File tree

87 files changed

+1114
-397
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1114
-397
lines changed

app/code/Magento/Backend/Block/Dashboard/Bar.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Backend\Block\Dashboard;
77

8+
use Magento\Store\Model\Store;
9+
810
/**
911
* Adminhtml dashboard bar block
1012
*
@@ -73,6 +75,7 @@ public function setCurrency($currency)
7375
* Retrieve currency model if not set then return currency model for current store
7476
*
7577
* @return \Magento\Directory\Model\Currency
78+
* @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
7679
*/
7780
public function getCurrency()
7881
{
@@ -90,7 +93,8 @@ public function getCurrency()
9093
$this->getRequest()->getParam('group')
9194
)->getWebsite()->getBaseCurrency();
9295
} else {
93-
$this->_currentCurrencyCode = $this->_storeManager->getStore()->getBaseCurrency();
96+
$this->_currentCurrencyCode = $this->_storeManager->getStore(Store::DEFAULT_STORE_ID)
97+
->getBaseCurrency();
9498
}
9599
}
96100

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertAdminDashboardPageIsVisibleActionGroup">
12+
<seeInCurrentUrl url="{{AdminDashboardPage.url}}" stepKey="seeDashboardUrl"/>
13+
<see userInput="Dashboard" selector="{{AdminHeaderSection.pageTitle}}" stepKey="seeDashboardTitle"/>
14+
</actionGroup>
15+
</actionGroups>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="ChangedCookieDomainForMainWebsiteConfigData">
12+
<data key="path">web/cookie/cookie_domain</data>
13+
<data key="scope">website</data>
14+
<data key="scope_code">base</data>
15+
<data key="value">testDomain.com</data>
16+
</entity>
17+
<entity name="EmptyCookieDomainForMainWebsiteConfigData">
18+
<data key="path">web/cookie/cookie_domain</data>
19+
<data key="scope">website</data>
20+
<data key="scope_code">base</data>
21+
<data key="value">''</data>
22+
</entity>
23+
</entities>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminLoginAfterChangeCookieDomainTest">
12+
<annotations>
13+
<features value="Backend"/>
14+
<stories value="Login on the Admin Backend"/>
15+
<title value="Admin user can login after changing cookie domain on main website scope without changing cookie domain on default scope"/>
16+
<description value="Admin user can login after changing cookie domain on main website scope without changing cookie domain on default scope"/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="MC-17931"/>
19+
<useCaseId value="MC-17292"/>
20+
<group value="backend"/>
21+
</annotations>
22+
<before>
23+
<magentoCLI command="config:set {{ChangedCookieDomainForMainWebsiteConfigData.path}} --scope={{ChangedCookieDomainForMainWebsiteConfigData.scope}} --scope-code={{ChangedCookieDomainForMainWebsiteConfigData.scope_code}} {{ChangedCookieDomainForMainWebsiteConfigData.value}}" stepKey="changeDomainForMainWebsiteBeforeTestRun"/>
24+
<magentoCLI command="cache:flush config" stepKey="flushCacheBeforeTestRun"/>
25+
</before>
26+
<after>
27+
<magentoCLI command="config:set {{EmptyCookieDomainForMainWebsiteConfigData.path}} --scope={{EmptyCookieDomainForMainWebsiteConfigData.scope}} --scope-code={{EmptyCookieDomainForMainWebsiteConfigData.scope_code}} {{EmptyCookieDomainForMainWebsiteConfigData.value}}" stepKey="changeDomainForMainWebsiteAfterTestComplete"/>
28+
<magentoCLI command="cache:flush config" stepKey="flushCacheAfterTestComplete"/>
29+
</after>
30+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
31+
<actionGroup ref="AssertAdminDashboardPageIsVisibleActionGroup" stepKey="seeDashboardPage"/>
32+
<actionGroup ref="logout" stepKey="logoutFromAdmin"/>
33+
</test>
34+
</tests>

app/code/Magento/Backend/etc/adminhtml/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
<arguments>
8787
<argument name="lifetimePath" xsi:type="const">Magento\Backend\Model\Auth\Session::XML_PATH_SESSION_LIFETIME</argument>
8888
<argument name="sessionName" xsi:type="const">Magento\Backend\Model\Session\AdminConfig::SESSION_NAME_ADMIN</argument>
89+
<argument name="scopeType" xsi:type="const">Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT</argument>
8990
</arguments>
9091
</type>
9192
<type name="Magento\Framework\View\Result\PageFactory">

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,6 @@ protected function customizeNewDateRangeField(array $meta)
281281
$fromContainerPath = $this->arrayManager->slicePath($fromFieldPath, 0, -2);
282282
$toContainerPath = $this->arrayManager->slicePath($toFieldPath, 0, -2);
283283
$commonFieldsMeta = [
284-
'outputDateTimeToISO' => false,
285-
'inputDateTimeFormat' => 'YYYY-MM-DD h:mm',
286284
'options' => [
287285
'showsTime' => true,
288286
]

app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Magento\Framework\DB\Adapter\AdapterInterface;
1212
use Magento\CatalogInventory\Api\StockConfigurationInterface;
1313
use Magento\CatalogInventory\Model\Indexer\Stock\Action\Full;
14-
use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus;
1514

1615
/**
1716
* CatalogInventory Default Stock Status Indexer Resource Model
@@ -226,8 +225,6 @@ protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = f
226225
{
227226
$connection = $this->getConnection();
228227
$qtyExpr = $connection->getCheckSql('cisi.qty > 0', 'cisi.qty', 0);
229-
$metadata = $this->getMetadataPool()->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class);
230-
$linkField = $metadata->getLinkField();
231228

232229
$select = $connection->select()->from(
233230
['e' => $this->getTable('catalog_product_entity')],
@@ -241,12 +238,6 @@ protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = f
241238
['cisi' => $this->getTable('cataloginventory_stock_item')],
242239
'cisi.stock_id = cis.stock_id AND cisi.product_id = e.entity_id',
243240
[]
244-
)->joinInner(
245-
['mcpei' => $this->getTable('catalog_product_entity_int')],
246-
'e.' . $linkField . ' = mcpei.' . $linkField
247-
. ' AND mcpei.attribute_id = ' . $this->_getAttribute('status')->getId()
248-
. ' AND mcpei.value = ' . ProductStatus::STATUS_ENABLED,
249-
[]
250241
)->columns(
251242
['qty' => $qtyExpr]
252243
)->where(
@@ -317,7 +308,8 @@ protected function _updateIndex($entityIds)
317308
}
318309

319310
/**
320-
* Delete records by their ids from index table
311+
* Delete records by their ids from index table.
312+
*
321313
* Used to clean table before re-indexation
322314
*
323315
* @param array $ids
@@ -362,6 +354,8 @@ public function getIdxTable($table = null)
362354
}
363355

364356
/**
357+
* Get status expression
358+
*
365359
* @param AdapterInterface $connection
366360
* @param bool $isAggregate
367361
* @return mixed
@@ -387,6 +381,8 @@ protected function getStatusExpression(AdapterInterface $connection, $isAggregat
387381
}
388382

389383
/**
384+
* Get stock configuration
385+
*
390386
* @return StockConfigurationInterface
391387
*
392388
* @deprecated 100.1.0
@@ -402,6 +398,8 @@ protected function getStockConfiguration()
402398
}
403399

404400
/**
401+
* Get query processor composite
402+
*
405403
* @return QueryProcessorComposite
406404
*/
407405
private function getQueryProcessorComposite()

app/code/Magento/CatalogSearch/Model/Autocomplete/DataProvider.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@
1010
use Magento\Search\Model\QueryFactory;
1111
use Magento\Search\Model\Autocomplete\DataProviderInterface;
1212
use Magento\Search\Model\Autocomplete\ItemFactory;
13+
use Magento\Framework\App\Config\ScopeConfigInterface as ScopeConfig;
14+
use Magento\Store\Model\ScopeInterface;
1315

1416
class DataProvider implements DataProviderInterface
1517
{
18+
/**
19+
* Autocomplete limit
20+
*/
21+
private static $CONFIG_AUTOCOMPLETE_LIMIT = 'catalog/search/autocomplete_limit';
22+
1623
/**
1724
* Query factory
1825
*
@@ -27,16 +34,25 @@ class DataProvider implements DataProviderInterface
2734
*/
2835
protected $itemFactory;
2936

37+
/**
38+
* Scope Config Object
39+
*
40+
* @var ScopeConfig
41+
*/
42+
private $scopeConfig;
43+
3044
/**
3145
* @param QueryFactory $queryFactory
3246
* @param ItemFactory $itemFactory
3347
*/
3448
public function __construct(
3549
QueryFactory $queryFactory,
36-
ItemFactory $itemFactory
50+
ItemFactory $itemFactory,
51+
ScopeConfig $scopeConfig
3752
) {
3853
$this->queryFactory = $queryFactory;
3954
$this->itemFactory = $itemFactory;
55+
$this->scopeConfig = $scopeConfig;
4056
}
4157

4258
/**
@@ -46,6 +62,10 @@ public function getItems()
4662
{
4763
$collection = $this->getSuggestCollection();
4864
$query = $this->queryFactory->get()->getQueryText();
65+
$limit = (int) $this->scopeConfig->getValue(
66+
static::$CONFIG_AUTOCOMPLETE_LIMIT,
67+
ScopeInterface::SCOPE_STORE
68+
);
4969
$result = [];
5070
foreach ($collection as $item) {
5171
$resultItem = $this->itemFactory->create([
@@ -58,7 +78,7 @@ public function getItems()
5878
$result[] = $resultItem;
5979
}
6080
}
61-
return $result;
81+
return ($limit) ? array_splice($result, 0, $limit) : $result;
6282
}
6383

6484
/**

app/code/Magento/CatalogSearch/Test/Unit/Model/Autocomplete/DataProviderTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class DataProviderTest extends \PHPUnit\Framework\TestCase
2525
*/
2626
private $itemFactory;
2727

28+
/**
29+
* @var Magento\Framework\App\Config\ScopeConfigInterface |\PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
private $scopeConfig;
32+
2833
/**
2934
* @var \Magento\Search\Model\ResourceModel\Query\Collection |\PHPUnit_Framework_MockObject_MockObject
3035
*/
@@ -60,18 +65,25 @@ protected function setUp()
6065
->setMethods(['create'])
6166
->getMock();
6267

68+
$this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
69+
->setMethods(['getValue'])
70+
->disableOriginalConstructor()
71+
->getMockForAbstractClass();
72+
6373
$this->model = $helper->getObject(
6474
\Magento\CatalogSearch\Model\Autocomplete\DataProvider::class,
6575
[
6676
'queryFactory' => $queryFactory,
67-
'itemFactory' => $this->itemFactory
77+
'itemFactory' => $this->itemFactory,
78+
'scopeConfig' => $this->scopeConfig
6879
]
6980
);
7081
}
7182

7283
public function testGetItems()
7384
{
7485
$queryString = 'string';
86+
$limit = 3;
7587
$expected = ['title' => $queryString, 'num_results' => 100500];
7688
$collection = [
7789
['query_text' => 'string1', 'num_results' => 1],
@@ -80,6 +92,8 @@ public function testGetItems()
8092
['query_text' => 'string100', 'num_results' => 100],
8193
['query_text' => $queryString, 'num_results' => 100500]
8294
];
95+
$this->scopeConfig->method('getValue')
96+
->willReturn($limit);
8397
$this->buildCollection($collection);
8498
$this->query->expects($this->once())
8599
->method('getQueryText')
@@ -105,6 +119,7 @@ public function testGetItems()
105119
$this->itemFactory->expects($this->any())->method('create')->willReturn($itemMock);
106120
$result = $this->model->getItems();
107121
$this->assertEquals($expected, $result[0]->toArray());
122+
$this->assertEquals($limit, count($result));
108123
}
109124

110125
/**

app/code/Magento/CatalogSearch/etc/adminhtml/system.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
<comment>Number of popular search terms to be cached for faster response. Use “0” to cache all results after a term is searched for the second time.</comment>
3535
<validate>validate-digits</validate>
3636
</field>
37+
<field id="autocomplete_limit" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
38+
<label>Autocomplete Limit</label>
39+
<validate>validate-digits</validate>
40+
</field>
3741
<field id="enable_eav_indexer" translate="label" type="select" sortOrder="18" showInDefault="1" showInWebsite="0" showInStore="0">
3842
<label>Enable EAV Indexer</label>
3943
<comment>Enable/Disable Product EAV indexer to improve indexation speed. Make sure that indexer is not used by 3rd party extensions.</comment>

0 commit comments

Comments
 (0)