Skip to content

Commit dfa038a

Browse files
author
Hayder Sharhan
committed
Merge remote-tracking branch 'remotes/origin/develop' into bug-fixes
2 parents dcb1603 + f2efe76 commit dfa038a

File tree

207 files changed

+6673
-2810
lines changed

Some content is hidden

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

207 files changed

+6673
-2810
lines changed

app/code/Magento/Backend/Helper/Dashboard/Order.php

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

8+
use Magento\Framework\App\ObjectManager;
9+
810
/**
911
* Adminhtml dashboard helper for orders
1012
*/
@@ -23,18 +25,24 @@ class Order extends \Magento\Backend\Helper\Dashboard\AbstractDashboard
2325
/**
2426
* @param \Magento\Framework\App\Helper\Context $context
2527
* @param \Magento\Reports\Model\ResourceModel\Order\Collection $orderCollection
26-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
2728
*/
2829
public function __construct(
2930
\Magento\Framework\App\Helper\Context $context,
30-
\Magento\Reports\Model\ResourceModel\Order\Collection $orderCollection,
31-
\Magento\Store\Model\StoreManagerInterface $storeManager
31+
\Magento\Reports\Model\ResourceModel\Order\Collection $orderCollection
3232
) {
3333
$this->_orderCollection = $orderCollection;
34-
$this->_storeManager = $storeManager;
35-
parent::__construct(
36-
$context
37-
);
34+
parent::__construct($context);
35+
}
36+
37+
/**
38+
* @return \Magento\SalesRule\Model\RuleFactory
39+
* @deprecated
40+
*/
41+
public function getStoreManager()
42+
{
43+
if ($this->_storeManager instanceof \Magento\Store\Model\StoreManagerInterface) {
44+
$this->_storeManager = ObjectManager::getInstance()->get('\Magento\Store\Model\StoreManagerInterface');
45+
}
3846
}
3947

4048
/**

app/code/Magento/Backend/view/adminhtml/templates/system/search.phtml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,19 @@
2727
</form>
2828
<script data-template="search-suggest" type="text/x-magento-template">
2929
<ul class="search-global-menu">
30-
<% if (data.items.length) { %>
30+
<li class="item">
31+
<a href="<?php /* @escapeNotVerified */ echo $block->getURL('catalog/product/index/'); ?>?search=<%- data.term%>" class="title">"<%- data.term%>" in Products</a>
32+
</li>
33+
<li class="item">
34+
<a href="<?php /* @escapeNotVerified */ echo $block->getURL('sales/order/index/'); ?>?search=<%- data.term%>" class="title">"<%- data.term%>" in Orders</a>
35+
</li>
36+
<li class="item">
37+
<a href="<?php /* @escapeNotVerified */ echo $block->getURL('customer/index/index/'); ?>?search=<%- data.term%>" class="title">"<%- data.term%>" in Customers</a>
38+
</li>
39+
<li class="item">
40+
<a href="<?php /* @escapeNotVerified */ echo $block->getURL('cms/page/index/'); ?>?search=<%- data.term%>" class="title">"<%- data.term%>" in Pages</a>
41+
</li>
42+
<% if (data.items.length) { %>
3143
<% _.each(data.items, function(value){ %>
3244
<li class="item"
3345
<%- data.optionData(value) %>

app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function execute()
100100

101101
$data['general'] = $this->getRequest()->getPostValue();
102102
$isNewCategory = !isset($data['general']['entity_id']);
103-
$data = $this->stringToBoolConverting($this->stringToBoolInputs, $data);
103+
$data = $this->stringToBoolConverting($data);
104104
$data = $this->imagePreprocessing($data);
105105
$storeId = isset($data['general']['store_id']) ? $data['general']['store_id'] : null;
106106
$parentId = isset($data['general']['parent']) ? $data['general']['parent'] : null;
@@ -121,11 +121,9 @@ public function execute()
121121
foreach ($generalPost['use_config'] as $attributeCode => $attributeValue) {
122122
if ($attributeValue) {
123123
$useConfig[] = $attributeCode;
124+
$category->setData($attributeCode, null);
124125
}
125126
}
126-
foreach ($useConfig as $attributeCode) {
127-
$category->setData($attributeCode, null);
128-
}
129127
}
130128

131129
$category->setAttributeSetId($category->getDefaultAttributeSetId());
@@ -148,7 +146,7 @@ public function execute()
148146
if (isset($generalPost['use_default']) && !empty($generalPost['use_default'])) {
149147
foreach ($generalPost['use_default'] as $attributeCode => $attributeValue) {
150148
if ($attributeValue) {
151-
$category->setData($attributeCode, false);
149+
$category->setData($attributeCode, null);
152150
}
153151
}
154152
}
@@ -234,8 +232,7 @@ public function imagePreprocessing($data)
234232
{
235233
if (!isset($_FILES) || (isset($_FILES['image']) && $_FILES['image']['name'] === '' )) {
236234
unset($data['general']['image']);
237-
if (
238-
isset($data['general']['savedImage']['delete']) &&
235+
if (isset($data['general']['savedImage']['delete']) &&
239236
$data['general']['savedImage']['delete']
240237
) {
241238
$data['general']['image']['delete'] = $data['general']['savedImage']['delete'];
@@ -247,17 +244,20 @@ public function imagePreprocessing($data)
247244
/**
248245
* Converting inputs from string to boolean
249246
*
250-
* @param array $stringToBoolInputs
251247
* @param array $data
248+
* @param array $stringToBoolInputs
252249
*
253250
* @return array
254251
*/
255-
public function stringToBoolConverting($stringToBoolInputs, $data)
252+
public function stringToBoolConverting($data, $stringToBoolInputs = null)
256253
{
254+
if (null === $stringToBoolInputs) {
255+
$stringToBoolInputs = $this->stringToBoolInputs;
256+
}
257257
foreach ($stringToBoolInputs as $key => $value) {
258258
if (is_array($value)) {
259259
if (isset($data[$key])) {
260-
$data[$key] = $this->stringToBoolConverting($value, $data[$key]);
260+
$data[$key] = $this->stringToBoolConverting($data[$key], $value);
261261
}
262262
} else {
263263
if (isset($data[$value])) {

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function initialize(\Magento\Catalog\Model\Product $product)
160160

161161
foreach ($useDefaults as $attributeCode => $useDefaultState) {
162162
if ($useDefaultState) {
163-
$product->setData($attributeCode, false);
163+
$product->setData($attributeCode, null);
164164
}
165165
}
166166

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,9 @@ public function getStoreIds()
571571
public function getStoreId()
572572
{
573573
if ($this->hasData('store_id')) {
574-
return $this->_getData('store_id');
574+
return (int)$this->_getData('store_id');
575575
}
576-
return $this->_storeManager->getStore()->getId();
576+
return (int)$this->_storeManager->getStore()->getId();
577577
}
578578

579579
/**
@@ -1261,6 +1261,7 @@ public function toFlatArray()
12611261
}
12621262

12631263
//@codeCoverageIgnoreStart
1264+
12641265
/**
12651266
* Set parent category ID
12661267
*

app/code/Magento/Catalog/Model/Category/Attribute/Backend/Sortby.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ public function beforeSave($object)
9696
if (!is_array($data)) {
9797
$data = [];
9898
}
99-
$object->setData($attributeCode, join(',', $data));
99+
$object->setData($attributeCode, implode(',', $data) ?: null);
100100
}
101101
if (!$object->hasData($attributeCode)) {
102-
$object->setData($attributeCode, false);
102+
$object->setData($attributeCode, null);
103103
}
104104
return $this;
105105
}

app/code/Magento/Catalog/Model/Category/DataProvider.php

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
use Magento\Eav\Model\Config;
1212
use Magento\Eav\Model\Entity\Type;
1313
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
14+
use Magento\Store\Model\Store;
1415
use Magento\Store\Model\StoreManagerInterface;
1516
use Magento\Ui\Component\Form\Field;
1617
use Magento\Ui\DataProvider\EavValidationRules;
18+
use Magento\Catalog\Model\CategoryFactory;
19+
use Magento\Framework\Exception\NoSuchEntityException;
1720

1821
/**
1922
* Class DataProvider
@@ -22,6 +25,11 @@
2225
*/
2326
class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
2427
{
28+
/**
29+
* @var string
30+
*/
31+
protected $requestScopeFieldName = 'store';
32+
2533
/**
2634
* @var array
2735
*/
@@ -86,8 +94,7 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
8694
/**
8795
* @var \Magento\Framework\App\RequestInterface
8896
*/
89-
private $request;
90-
97+
protected $request;
9198

9299
/**
93100
* @var Config
@@ -100,7 +107,12 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
100107
private $storeManager;
101108

102109
/**
103-
* Constructor
110+
* @var CategoryFactory
111+
*/
112+
private $categoryFactory;
113+
114+
/**
115+
* DataProvider constructor
104116
*
105117
* @param string $name
106118
* @param string $primaryFieldName
@@ -111,9 +123,9 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
111123
* @param \Magento\Framework\Registry $registry
112124
* @param Config $eavConfig
113125
* @param \Magento\Framework\App\RequestInterface $request
126+
* @param CategoryFactory $categoryFactory
114127
* @param array $meta
115128
* @param array $data
116-
* @throws \Magento\Framework\Exception\LocalizedException
117129
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
118130
*/
119131
public function __construct(
@@ -126,6 +138,7 @@ public function __construct(
126138
\Magento\Framework\Registry $registry,
127139
Config $eavConfig,
128140
\Magento\Framework\App\RequestInterface $request,
141+
CategoryFactory $categoryFactory,
129142
array $meta = [],
130143
array $data = []
131144
) {
@@ -136,6 +149,7 @@ public function __construct(
136149
$this->registry = $registry;
137150
$this->storeManager = $storeManager;
138151
$this->request = $request;
152+
$this->categoryFactory = $categoryFactory;
139153
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
140154
$this->meta = $this->prepareMeta($this->meta);
141155
}
@@ -282,7 +296,7 @@ protected function addUseConfigSettings($categoryData)
282296
protected function addUseDefaultSettings($category, $categoryData)
283297
{
284298
if ($category->getExistsStoreValueFlag('url_key') ||
285-
$category->getStoreId() === \Magento\Store\Model\Store::DEFAULT_STORE_ID
299+
$category->getStoreId() === Store::DEFAULT_STORE_ID
286300
) {
287301
$categoryData['use_default']['url_key'] = false;
288302
} else {
@@ -296,10 +310,25 @@ protected function addUseDefaultSettings($category, $categoryData)
296310
* Get current category
297311
*
298312
* @return Category
313+
* @throws NoSuchEntityException
299314
*/
300315
public function getCurrentCategory()
301316
{
302-
return $this->registry->registry('category');
317+
$category = $this->registry->registry('category');
318+
if ($category) {
319+
return $category;
320+
}
321+
$requestId = $this->request->getParam($this->requestFieldName);
322+
$requestScope = $this->request->getParam($this->requestScopeFieldName, Store::DEFAULT_STORE_ID);
323+
if ($requestId) {
324+
$category = $this->categoryFactory->create();
325+
$category->setStoreId($requestScope);
326+
$category->load($requestId);
327+
if (!$category->getId()) {
328+
throw NoSuchEntityException::singleField('id', $requestId);
329+
}
330+
}
331+
return $category;
303332
}
304333

305334
/**
@@ -349,7 +378,6 @@ protected function filterFields($categoryData)
349378
public function getDefaultMetaData($result)
350379
{
351380
$result['parent']['default'] = (int)$this->request->getParam('parent');
352-
$result['is_anchor']['default'] = false;
353381
$result['use_config.available_sort_by']['default'] = true;
354382
$result['use_config.default_sort_by']['default'] = true;
355383
$result['use_config.filter_price_range']['default'] = true;
@@ -418,14 +446,14 @@ protected function getFieldsMap()
418446
[
419447
'custom_use_parent_settings',
420448
'custom_apply_to_products',
449+
'custom_design',
421450
'page_layout',
422451
'custom_layout_update',
423452
],
424453
'schedule_design_update' =>
425454
[
426455
'custom_design_from',
427456
'custom_design_to',
428-
'custom_design',
429457
],
430458
'category_view_optimization' =>
431459
[

0 commit comments

Comments
 (0)