Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 413b04c

Browse files
author
Sergey Shvets
committed
Merge branch '2.2-develop' of github.com:magento/magento2ce into chaika-pr22
2 parents f8d5abc + 29bc9ad commit 413b04c

File tree

12 files changed

+285
-53
lines changed

12 files changed

+285
-53
lines changed

app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection
6161
/**
6262
* @var string|null
6363
*/
64-
private $order = null;
64+
private $relevanceOrderDirection = null;
6565

6666
/**
6767
* @var string
@@ -361,9 +361,19 @@ protected function _renderFiltersBefore()
361361
[]
362362
);
363363

364-
if ($this->order && 'relevance' === $this->order['field']) {
365-
$this->getSelect()->order('search_result.'. TemporaryStorage::FIELD_SCORE . ' ' . $this->order['dir']);
364+
if ($this->relevanceOrderDirection) {
365+
$this->getSelect()->order(
366+
'search_result.'. TemporaryStorage::FIELD_SCORE . ' ' . $this->relevanceOrderDirection
367+
);
366368
}
369+
370+
/*
371+
* This order is required to force search results be the same
372+
* for the same requests and products with the same relevance
373+
* NOTE: this does not replace existing orders but ADDs one more
374+
*/
375+
$this->setOrder('entity_id');
376+
367377
return parent::_renderFiltersBefore();
368378
}
369379

@@ -385,10 +395,12 @@ protected function _renderFilters()
385395
*/
386396
public function setOrder($attribute, $dir = Select::SQL_DESC)
387397
{
388-
$this->order = ['field' => $attribute, 'dir' => $dir];
389-
if ($attribute !== 'relevance') {
398+
if ($attribute === 'relevance') {
399+
$this->relevanceOrderDirection = $dir;
400+
} else {
390401
parent::setOrder($attribute, $dir);
391402
}
403+
392404
return $this;
393405
}
394406

app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@
4141
<item name="total" xsi:type="string" translate="true">Row Total</item>
4242
</argument>
4343
</arguments>
44-
<block class="Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer" as="default" template="Magento_Sales::order/view/items/renderer/default.phtml">
45-
<arguments>
46-
<argument name="columns" xsi:type="array">
47-
<item name="product" xsi:type="string" translate="false">col-product</item>
48-
<item name="status" xsi:type="string" translate="false">col-status</item>
49-
<item name="price-original" xsi:type="string" translate="false">col-price-original</item>
50-
<item name="price" xsi:type="string" translate="false">col-price</item>
51-
<item name="qty" xsi:type="string" translate="false">col-ordered-qty</item>
52-
<item name="subtotal" xsi:type="string" translate="false">col-subtotal</item>
53-
<item name="tax-amount" xsi:type="string" translate="false">col-tax-amount</item>
54-
<item name="tax-percent" xsi:type="string" translate="false">col-tax-percent</item>
55-
<item name="discont" xsi:type="string" translate="false">col-discont</item>
56-
<item name="total" xsi:type="string" translate="false">col-total</item>
57-
</argument>
58-
</arguments>
44+
<block class="Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer" as="default" name="default_order_items_renderer" template="Magento_Sales::order/view/items/renderer/default.phtml">
45+
<arguments>
46+
<argument name="columns" xsi:type="array">
47+
<item name="product" xsi:type="string" translate="false">col-product</item>
48+
<item name="status" xsi:type="string" translate="false">col-status</item>
49+
<item name="price-original" xsi:type="string" translate="false">col-price-original</item>
50+
<item name="price" xsi:type="string" translate="false">col-price</item>
51+
<item name="qty" xsi:type="string" translate="false">col-ordered-qty</item>
52+
<item name="subtotal" xsi:type="string" translate="false">col-subtotal</item>
53+
<item name="tax-amount" xsi:type="string" translate="false">col-tax-amount</item>
54+
<item name="tax-percent" xsi:type="string" translate="false">col-tax-percent</item>
55+
<item name="discont" xsi:type="string" translate="false">col-discont</item>
56+
<item name="total" xsi:type="string" translate="false">col-total</item>
57+
</argument>
58+
</arguments>
5959
</block>
6060
<block class="Magento\Sales\Block\Adminhtml\Items\Column\Qty" name="column_qty" template="Magento_Sales::items/column/qty.phtml" group="column"/>
6161
<block class="Magento\Sales\Block\Adminhtml\Items\Column\Name" name="column_name" template="Magento_Sales::items/column/name.phtml" group="column"/>

app/design/frontend/Magento/luma/Magento_Theme/web/css/source/_module.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@
333333
.widget.block {
334334
.lib-css(margin, @indent__base 0);
335335
}
336+
.links .widget.block { margin: 0; }
336337
}
337338

338339
.no-display:extend(.abs-no-display all) {

dev/tests/integration/testsuite/Magento/CatalogSearch/Model/ResourceModel/Fulltext/CollectionTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,45 @@ public function testLoadWithFilterSearch($request, $filters, $expectedCount)
3131
$this->assertCount($expectedCount, $items);
3232
}
3333

34+
/**
35+
* @magentoDataFixture Magento/Framework/Search/_files/products_with_the_same_search_score.php
36+
*/
37+
public function testSearchResultsAreTheSameForSameRequests()
38+
{
39+
$howManySearchRequests = 3;
40+
$previousResult = null;
41+
42+
$objManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
43+
44+
foreach (range(1, $howManySearchRequests) as $i) {
45+
/** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $fulltextCollection */
46+
$fulltextCollection = $objManager->create(
47+
\Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection::class,
48+
['searchRequestName' => 'quick_search_container']
49+
);
50+
51+
$fulltextCollection->addFieldToFilter('search_term', 'shorts');
52+
$fulltextCollection->setOrder('relevance');
53+
$fulltextCollection->load();
54+
$items = $fulltextCollection->getItems();
55+
$this->assertGreaterThan(
56+
0,
57+
count($items),
58+
sprintf("Search #%s result must not be empty", $i)
59+
);
60+
61+
if ($previousResult) {
62+
$this->assertEquals(
63+
$previousResult,
64+
array_keys($items),
65+
"Search result must be the same for the same requests"
66+
);
67+
}
68+
69+
$previousResult = array_keys($items);
70+
}
71+
}
72+
3473
public function filtersDataProviderSearch()
3574
{
3675
return [
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
use Magento\Catalog\Api\ProductRepositoryInterface;
8+
use Magento\Catalog\Model\Product;
9+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
10+
use Magento\Catalog\Model\Product\Type;
11+
use Magento\Catalog\Model\Product\Visibility;
12+
use Magento\TestFramework\Helper\Bootstrap;
13+
14+
Bootstrap::getInstance()->reinitialize();
15+
16+
/** @var ProductRepositoryInterface $productRepository */
17+
$productRepository = Bootstrap::getObjectManager()
18+
->create(ProductRepositoryInterface::class);
19+
20+
$howManyProducts = 5;
21+
22+
foreach (range(1, $howManyProducts) as $productId) {
23+
$product = Bootstrap::getObjectManager()->create(Product::class);
24+
$product->setTypeId(Type::TYPE_SIMPLE)
25+
->setAttributeSetId(4)
26+
->setWebsiteIds([1])
27+
->setName('Cool short' . $productId)
28+
->setSku('cool_shorts_' . $productId)
29+
->setPrice(42)
30+
->setShortDescription("Some description about shorts")
31+
->setTaxClassId(0)
32+
->setDescription('Some description about <b>shorts</b>')
33+
->setVisibility(Visibility::VISIBILITY_BOTH)
34+
->setStatus(Status::STATUS_ENABLED)
35+
->setStockData(
36+
[
37+
'use_config_manage_stock' => 1,
38+
'qty' => 100,
39+
'is_qty_decimal' => 0,
40+
'is_in_stock' => 1,
41+
]
42+
);
43+
44+
$productRepository->save($product);
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
/** @var \Magento\Framework\Registry $registry */
7+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
8+
$registry = $objectManager->get(\Magento\Framework\Registry::class);
9+
10+
$registry->unregister('isSecureArea');
11+
$registry->register('isSecureArea', true);
12+
13+
/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */
14+
$collection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
15+
$collection->addAttributeToSelect('id')->load();
16+
if ($collection->count() > 0) {
17+
$collection->delete();
18+
}
19+
20+
$registry->unregister('isSecureArea');
21+
$registry->register('isSecureArea', false);

dev/tests/integration/testsuite/Magento/Paypal/Controller/ExpressTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,10 @@ public function testStartActionCustomerToQuote()
141141
/**
142142
* Test return action with configurable product.
143143
*
144-
* #magentoDataFixture Magento/Paypal/_files/quote_express_configurable.php skipped due to MAGETWO-75517
144+
* @magentoDataFixture Magento/Paypal/_files/quote_express_configurable.php
145145
*/
146146
public function testReturnAction()
147147
{
148-
149-
$this->markTestSkipped('Test skipped due to MAGETWO-75517');
150148
$quote = $this->_objectManager->create(Quote::class);
151149
$quote->load('test_cart_with_configurable', 'reserved_order_id');
152150

dev/tests/integration/testsuite/Magento/Paypal/_files/quote_express_configurable.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727

2828
$requestInfo = new \Magento\Framework\DataObject(
2929
[
30-
'product' => 1,
31-
'selected_configurable_option' => 1,
32-
'qty' => 100,
30+
'product' => 2,
31+
'selected_configurable_option' => 2,
32+
'qty' => 1,
3333
'super_attribute' => [
3434
$attribute->getId() => $option->getId()
3535
]

dev/tests/unit/framework/bootstrap.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
error_reporting(E_ALL);
2121
ini_set('display_errors', 1);
2222

23+
/* For data consistency between displaying (printing) and serialization a float number */
24+
ini_set('precision', 14);
25+
ini_set('serialize_precision', 14);
26+
2327
/**
2428
* Set custom error handler
2529
*/

lib/internal/Magento/Framework/Module/Plugin/DbStatusValidator.php

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,22 @@ public function __construct(FrontendCacheInterface $cache, DbVersionInfo $dbVers
5050
public function beforeDispatch(FrontController $subject, RequestInterface $request)
5151
{
5252
if (!$this->cache->load('db_is_up_to_date')) {
53-
$errors = $this->dbVersionInfo->getDbVersionErrors();
54-
55-
if ($errors) {
53+
list($versionTooLowErrors, $versionTooHighErrors) = array_values($this->getGroupedDbVersionErrors());
54+
if ($versionTooHighErrors) {
55+
$message = 'Please update your modules: '
56+
. "Run \"composer install\" from the Magento root directory.\n"
57+
. "The following modules are outdated:\n%1";
58+
throw new LocalizedException(
59+
new Phrase($message, [implode("\n", $this->formatVersionTooHighErrors($versionTooHighErrors))])
60+
);
61+
} elseif ($versionTooLowErrors) {
5662
$message = 'Please upgrade your database: '
5763
. "Run \"bin/magento setup:upgrade\" from the Magento root directory.\n"
5864
. "The following modules are outdated:\n%1";
5965

60-
throw new LocalizedException(new Phrase($message, [implode("\n", $this->formatErrors($errors))]));
66+
throw new LocalizedException(
67+
new Phrase($message, [implode("\n", $this->formatVersionTooLowErrors($versionTooLowErrors))])
68+
);
6169
} else {
6270
$this->cache->save('true', 'db_is_up_to_date');
6371
}
@@ -70,7 +78,7 @@ public function beforeDispatch(FrontController $subject, RequestInterface $reque
7078
* @param array $errorsData array of error data from getOutOfDateDbErrors
7179
* @return array Messages that can be used to log the error
7280
*/
73-
private function formatErrors($errorsData)
81+
private function formatVersionTooLowErrors($errorsData)
7482
{
7583
$formattedErrors = [];
7684

@@ -82,4 +90,50 @@ private function formatErrors($errorsData)
8290

8391
return $formattedErrors;
8492
}
93+
94+
/**
95+
* Format each error in the error data from getOutOfDataDbErrors into a single message
96+
*
97+
* @param array $errorsData array of error data from getOutOfDateDbErrors
98+
* @return array Messages that can be used to log the error
99+
*/
100+
private function formatVersionTooHighErrors($errorsData)
101+
{
102+
$formattedErrors = [];
103+
104+
foreach ($errorsData as $error) {
105+
$formattedErrors[] = $error[DbVersionInfo::KEY_MODULE] . ' db ' . $error[DbVersionInfo::KEY_TYPE]
106+
. ' version: defined in codebase - ' . $error[DbVersionInfo::KEY_REQUIRED]
107+
. ', currently installed - ' . $error[DbVersionInfo::KEY_CURRENT];
108+
}
109+
110+
return $formattedErrors;
111+
}
112+
113+
/**
114+
* Return DB version errors grouped by 'version_too_low' and 'version_too_high'
115+
*
116+
* @return mixed
117+
*/
118+
private function getGroupedDbVersionErrors()
119+
{
120+
$allDbVersionErrors = $this->dbVersionInfo->getDbVersionErrors();
121+
return array_reduce(
122+
(array)$allDbVersionErrors,
123+
function ($carry, $item) {
124+
if ($item[DbVersionInfo::KEY_CURRENT] === 'none'
125+
|| $item[DbVersionInfo::KEY_CURRENT] < $item[DbVersionInfo::KEY_REQUIRED]
126+
) {
127+
$carry['version_too_low'][] = $item;
128+
} else {
129+
$carry['version_too_high'][] = $item;
130+
}
131+
return $carry;
132+
},
133+
[
134+
'version_too_low' => [],
135+
'version_too_high' => [],
136+
]
137+
);
138+
}
85139
}

0 commit comments

Comments
 (0)