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

Commit 6f22a17

Browse files
committed
Merge remote-tracking branch 'magento2/2.3-develop' into msi-core-changes-no-history
2 parents bb6bac3 + 447a24d commit 6f22a17

File tree

61 files changed

+630
-192
lines changed

Some content is hidden

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

61 files changed

+630
-192
lines changed

app/code/Magento/Catalog/Cron/DeleteOutdatedPriceValues.php

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,46 @@ public function __construct(
4848
}
4949

5050
/**
51-
* Delete all price values for non-admin stores if PRICE_SCOPE is global
51+
* Delete all price values for non-admin stores if PRICE_SCOPE is set to global.
5252
*
5353
* @return void
5454
*/
5555
public function execute()
5656
{
57-
$priceScope = $this->scopeConfig->getValue(Store::XML_PATH_PRICE_SCOPE);
58-
if ($priceScope == Store::PRICE_SCOPE_GLOBAL) {
59-
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $priceAttribute */
60-
$priceAttribute = $this->attributeRepository
61-
->get(ProductAttributeInterface::ENTITY_TYPE_CODE, ProductAttributeInterface::CODE_PRICE);
62-
$connection = $this->resource->getConnection();
63-
$conditions = [
64-
$connection->quoteInto('attribute_id = ?', $priceAttribute->getId()),
65-
$connection->quoteInto('store_id != ?', Store::DEFAULT_STORE_ID),
66-
];
57+
if (!$this->isPriceScopeSetToGlobal()) {
58+
return;
59+
}
60+
61+
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $priceAttribute */
62+
$priceAttribute = $this->attributeRepository
63+
->get(ProductAttributeInterface::ENTITY_TYPE_CODE, ProductAttributeInterface::CODE_PRICE);
64+
$connection = $this->resource->getConnection();
65+
$conditions = [
66+
$connection->quoteInto('attribute_id = ?', $priceAttribute->getId()),
67+
$connection->quoteInto('store_id != ?', Store::DEFAULT_STORE_ID),
68+
];
6769

68-
$connection->delete(
69-
$priceAttribute->getBackend()->getTable(),
70-
$conditions
71-
);
70+
$connection->delete(
71+
$priceAttribute->getBackend()->getTable(),
72+
$conditions
73+
);
74+
}
75+
76+
/**
77+
* Checks if price scope config option explicitly equal to global value.
78+
*
79+
* Such strict comparision is required to prevent price deleting when
80+
* price scope config option is null for some reason.
81+
*
82+
* @return bool
83+
*/
84+
private function isPriceScopeSetToGlobal()
85+
{
86+
$priceScope = $this->scopeConfig->getValue(Store::XML_PATH_PRICE_SCOPE);
87+
if ($priceScope === null) {
88+
return false;
7289
}
90+
91+
return (int)$priceScope === Store::PRICE_SCOPE_GLOBAL;
7392
}
7493
}

app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@
173173
</uploaderConfig>
174174
<previewTmpl>Magento_Catalog/image-preview</previewTmpl>
175175
<openDialogTitle>Media Gallery</openDialogTitle>
176+
<initialMediaGalleryOpenSubpath>catalog/category</initialMediaGalleryOpenSubpath>
176177
<allowedExtensions>jpg jpeg gif png</allowedExtensions>
177178
<maxFileSize>4194304</maxFileSize>
178179
</settings>

app/code/Magento/CatalogInventory/Model/Source/Stock.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,23 @@ public function getAllOptions()
2626
['value' => \Magento\CatalogInventory\Model\Stock::STOCK_OUT_OF_STOCK, 'label' => __('Out of Stock')]
2727
];
2828
}
29+
30+
/**
31+
* Add Value Sort To Collection Select.
32+
*
33+
* @param \Magento\Eav\Model\Entity\Collection\AbstractCollection $collection
34+
* @param string $dir
35+
*
36+
* @return $this
37+
*/
38+
public function addValueSortToCollection($collection, $dir = \Magento\Framework\Data\Collection::SORT_ORDER_DESC)
39+
{
40+
$collection->getSelect()->joinLeft(
41+
['stock_item_table' => 'cataloginventory_stock_item'],
42+
"e.entity_id=stock_item_table.product_id",
43+
[]
44+
);
45+
$collection->getSelect()->order("stock_item_table.qty $dir");
46+
return $this;
47+
}
2948
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\CatalogInventory\Test\Unit\Model\Source;
8+
9+
use PHPUnit\Framework\TestCase;
10+
11+
class StockTest extends TestCase
12+
{
13+
/**
14+
* @var \Magento\CatalogInventory\Model\Source\Stock
15+
*/
16+
private $model;
17+
18+
protected function setUp()
19+
{
20+
$this->model = new \Magento\CatalogInventory\Model\Source\Stock();
21+
}
22+
23+
public function testAddValueSortToCollection()
24+
{
25+
$selectMock = $this->createMock(\Magento\Framework\DB\Select::class);
26+
$collectionMock = $this->createMock(\Magento\Eav\Model\Entity\Collection\AbstractCollection::class);
27+
$collectionMock->expects($this->atLeastOnce())->method('getSelect')->willReturn($selectMock);
28+
29+
$selectMock->expects($this->once())
30+
->method('joinLeft')
31+
->with(
32+
['stock_item_table' => 'cataloginventory_stock_item'],
33+
"e.entity_id=stock_item_table.product_id",
34+
[]
35+
)
36+
->willReturnSelf();
37+
$selectMock->expects($this->once())
38+
->method('order')
39+
->with("stock_item_table.qty DESC")
40+
->willReturnSelf();
41+
42+
$this->model->addValueSortToCollection($collectionMock);
43+
}
44+
}

app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ define([
1010
'ko',
1111
'underscore',
1212
'sidebar',
13-
'mage/translate'
13+
'mage/translate',
14+
'mage/dropdown'
1415
], function (Component, customerData, $, ko, _) {
1516
'use strict';
1617

app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ public function getContentsUrl()
9494
{
9595
return $this->getUrl('cms/*/contents', [
9696
'type' => $this->getRequest()->getParam('type'),
97-
'use_storage_root' => (int) $this->getRequest()->getParam('use_storage_root'),
9897
]);
9998
}
10099

@@ -143,9 +142,7 @@ public function getNewfolderUrl()
143142
*/
144143
protected function getDeletefolderUrl()
145144
{
146-
return $this->getUrl('cms/*/deleteFolder', [
147-
'use_storage_root' => (int) $this->getRequest()->getParam('use_storage_root'),
148-
]);
145+
return $this->getUrl('cms/*/deleteFolder');
149146
}
150147

151148
/**
@@ -165,9 +162,7 @@ public function getDeleteFilesUrl()
165162
*/
166163
public function getOnInsertUrl()
167164
{
168-
return $this->getUrl('cms/*/onInsert', [
169-
'use_storage_root' => (int) $this->getRequest()->getParam('use_storage_root'),
170-
]);
165+
return $this->getUrl('cms/*/onInsert');
171166
}
172167

173168
/**

app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Tree.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,17 @@ public function getTreeJson()
9595
*/
9696
public function getTreeLoaderUrl()
9797
{
98+
$params = [];
99+
100+
$currentTreePath = $this->getRequest()->getParam('current_tree_path');
101+
102+
if (strlen($currentTreePath)) {
103+
$params['current_tree_path'] = $currentTreePath;
104+
}
105+
98106
return $this->getUrl(
99107
'cms/*/treeJson',
100-
['use_storage_root' => (int) $this->getRequest()->getParam('use_storage_root')]
108+
$params
101109
);
102110
}
103111

@@ -119,7 +127,14 @@ public function getRootNodeName()
119127
public function getTreeCurrentPath()
120128
{
121129
$treePath = ['root'];
122-
if ($path = $this->_coreRegistry->registry('storage')->getSession()->getCurrentPath()) {
130+
131+
if ($idEncodedPath = $this->getRequest()->getParam('current_tree_path')) {
132+
$path = $this->_cmsWysiwygImages->idDecode($idEncodedPath);
133+
} else {
134+
$path = $this->_coreRegistry->registry('storage')->getSession()->getCurrentPath();
135+
}
136+
137+
if (strlen($path)) {
123138
$path = str_replace($this->_cmsWysiwygImages->getStorageRoot(), '', $path);
124139
$relative = [];
125140
foreach (explode('/', $path) as $dirName) {
@@ -129,6 +144,7 @@ public function getTreeCurrentPath()
129144
}
130145
}
131146
}
147+
132148
return $treePath;
133149
}
134150

app/code/Magento/Cms/Helper/Wysiwyg/Images.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ public function getStorageRoot()
120120
*/
121121
public function getStorageRootSubpath()
122122
{
123-
return $this->_getRequest()->getParam('use_storage_root')
124-
? ''
125-
: \Magento\Cms\Model\Wysiwyg\Config::IMAGE_DIRECTORY;
123+
return '';
126124
}
127125

128126
/**

app/code/Magento/Cms/Model/Wysiwyg/Gallery/DefaultConfigProvider.php

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,37 @@ class DefaultConfigProvider implements \Magento\Framework\Data\Wysiwyg\ConfigPro
1313
*/
1414
private $backendUrl;
1515

16+
/**
17+
* @var \Magento\Cms\Helper\Wysiwyg\Images
18+
*/
19+
private $imagesHelper;
20+
1621
/**
1722
* @var array
1823
*/
1924
private $windowSize;
2025

26+
/**
27+
* @var string|null
28+
*/
29+
private $currentTreePath;
30+
2131
/**
2232
* @param \Magento\Backend\Model\UrlInterface $backendUrl
33+
* @param \Magento\Cms\Helper\Wysiwyg\Images $imagesHelper
2334
* @param array $windowSize
35+
* @param string|null $currentTreePath
2436
*/
25-
public function __construct(\Magento\Backend\Model\UrlInterface $backendUrl, array $windowSize = [])
26-
{
37+
public function __construct(
38+
\Magento\Backend\Model\UrlInterface $backendUrl,
39+
\Magento\Cms\Helper\Wysiwyg\Images $imagesHelper,
40+
array $windowSize = [],
41+
$currentTreePath = null
42+
) {
2743
$this->backendUrl = $backendUrl;
44+
$this->imagesHelper = $imagesHelper;
2845
$this->windowSize = $windowSize;
46+
$this->currentTreePath = $currentTreePath;
2947
}
3048

3149
/**
@@ -39,10 +57,22 @@ public function getConfig($config)
3957
'name' => 'image',
4058
]
4159
];
60+
61+
$fileBrowserUrlParams = [];
62+
63+
if (is_string($this->currentTreePath)) {
64+
$fileBrowserUrlParams = [
65+
'current_tree_path' => $this->imagesHelper->idEncode($this->currentTreePath),
66+
];
67+
}
68+
4269
return $config->addData(
4370
[
4471
'add_images' => true,
45-
'files_browser_window_url' => $this->backendUrl->getUrl('cms/wysiwyg_images/index'),
72+
'files_browser_window_url' => $this->backendUrl->getUrl(
73+
'cms/wysiwyg_images/index',
74+
$fileBrowserUrlParams
75+
),
4676
'files_browser_window_width' => $this->windowSize['width'],
4777
'files_browser_window_height' => $this->windowSize['height'],
4878
'plugins' => array_merge($pluginData, $imageData)

app/code/Magento/Cms/Test/Unit/Helper/Wysiwyg/ImagesTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class ImagesTest extends \PHPUnit\Framework\TestCase
7979

8080
protected function setUp()
8181
{
82-
$this->path = 'PATH/';
82+
$this->path = 'PATH';
8383
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
8484

8585
$this->eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class);
@@ -111,6 +111,7 @@ protected function setUp()
111111
[
112112
[WysiwygConfig::IMAGE_DIRECTORY, null, $this->getAbsolutePath(WysiwygConfig::IMAGE_DIRECTORY)],
113113
[null, null, $this->getAbsolutePath(null)],
114+
['', null, $this->getAbsolutePath('')],
114115
]
115116
);
116117

@@ -179,7 +180,7 @@ public function testSetStoreId()
179180
public function testGetStorageRoot()
180181
{
181182
$this->assertEquals(
182-
$this->getAbsolutePath(WysiwygConfig::IMAGE_DIRECTORY),
183+
$this->getAbsolutePath(''),
183184
$this->imagesHelper->getStorageRoot()
184185
);
185186
}
@@ -203,7 +204,7 @@ public function testGetTreeNodeName()
203204
public function testConvertPathToId()
204205
{
205206
$pathOne = '/test_path';
206-
$pathTwo = $this->getAbsolutePath(WysiwygConfig::IMAGE_DIRECTORY) . '/test_path';
207+
$pathTwo = $this->getAbsolutePath('') . '/test_path';
207208
$this->assertEquals(
208209
$this->imagesHelper->convertPathToId($pathOne),
209210
$this->imagesHelper->convertPathToId($pathTwo)
@@ -345,26 +346,25 @@ public function testGetCurrentPath($pathId, $expectedPath, $isExist)
345346
->willReturnMap(
346347
[
347348
['node', null, $pathId],
348-
['use_storage_root', null, false],
349349
]
350350
);
351351

352352
$this->directoryWriteMock->expects($this->any())
353353
->method('isDirectory')
354354
->willReturnMap(
355355
[
356-
['/../wysiwyg/test_path', true],
357-
['/../wysiwyg/my.jpg', false],
358-
['/../wysiwyg', true],
356+
['/../test_path', true],
357+
['/../my.jpg', false],
358+
['.', true],
359359
]
360360
);
361361
$this->directoryWriteMock->expects($this->any())
362362
->method('getRelativePath')
363363
->willReturnMap(
364364
[
365-
['PATH/wysiwyg/test_path', '/../wysiwyg/test_path'],
366-
['PATH/wysiwyg/my.jpg', '/../wysiwyg/my.jpg'],
367-
['PATH/wysiwyg', '/../wysiwyg'],
365+
['PATH/test_path', '/../test_path'],
366+
['PATH/my.jpg', '/../my.jpg'],
367+
['PATH', '.'],
368368
]
369369
);
370370
$this->directoryWriteMock->expects($this->once())
@@ -401,12 +401,12 @@ public function testGetCurrentPathThrowException()
401401
public function providerGetCurrentPath()
402402
{
403403
return [
404-
['L3Rlc3RfcGF0aA--', 'PATH/wysiwyg/test_path', true],
405-
['L215LmpwZw--', 'PATH/wysiwyg', true],
406-
[null, 'PATH/wysiwyg', true],
407-
['L3Rlc3RfcGF0aA--', 'PATH/wysiwyg/test_path', false],
408-
['L215LmpwZw--', 'PATH/wysiwyg', false],
409-
[null, 'PATH/wysiwyg', false],
404+
['L3Rlc3RfcGF0aA--', 'PATH/test_path', true],
405+
['L215LmpwZw--', 'PATH', true],
406+
[null, 'PATH', true],
407+
['L3Rlc3RfcGF0aA--', 'PATH/test_path', false],
408+
['L215LmpwZw--', 'PATH', false],
409+
[null, 'PATH', false],
410410
];
411411
}
412412

0 commit comments

Comments
 (0)