Skip to content

Commit 42040b0

Browse files
committed
Merge remote-tracking branch 'origin/2.2-develop' into MAGETWO-82385
2 parents ea2219d + ddd278a commit 42040b0

File tree

10 files changed

+227
-124
lines changed

10 files changed

+227
-124
lines changed

app/code/Magento/Catalog/Block/Adminhtml/Category/AbstractCategory.php

Lines changed: 72 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
use Magento\Framework\Data\Tree\Node;
99
use Magento\Store\Model\Store;
10+
use Magento\Framework\Registry;
11+
use Magento\Catalog\Model\ResourceModel\Category\Tree;
12+
use Magento\Catalog\Model\CategoryFactory;
13+
use Magento\Backend\Block\Template\Context;
14+
use Magento\Catalog\Model\Category;
1015

1116
/**
1217
* Class AbstractCategory
@@ -16,17 +21,17 @@ class AbstractCategory extends \Magento\Backend\Block\Template
1621
/**
1722
* Core registry
1823
*
19-
* @var \Magento\Framework\Registry
24+
* @var Registry
2025
*/
2126
protected $_coreRegistry = null;
2227

2328
/**
24-
* @var \Magento\Catalog\Model\ResourceModel\Category\Tree
29+
* @var Tree
2530
*/
2631
protected $_categoryTree;
2732

2833
/**
29-
* @var \Magento\Catalog\Model\CategoryFactory
34+
* @var CategoryFactory
3035
*/
3136
protected $_categoryFactory;
3237

@@ -36,17 +41,17 @@ class AbstractCategory extends \Magento\Backend\Block\Template
3641
protected $_withProductCount;
3742

3843
/**
39-
* @param \Magento\Backend\Block\Template\Context $context
40-
* @param \Magento\Catalog\Model\ResourceModel\Category\Tree $categoryTree
41-
* @param \Magento\Framework\Registry $registry
42-
* @param \Magento\Catalog\Model\CategoryFactory $categoryFactory
44+
* @param Context $context
45+
* @param Tree $categoryTree
46+
* @param Registry $registry
47+
* @param CategoryFactory $categoryFactory
4348
* @param array $data
4449
*/
4550
public function __construct(
46-
\Magento\Backend\Block\Template\Context $context,
47-
\Magento\Catalog\Model\ResourceModel\Category\Tree $categoryTree,
48-
\Magento\Framework\Registry $registry,
49-
\Magento\Catalog\Model\CategoryFactory $categoryFactory,
51+
Context $context,
52+
Tree $categoryTree,
53+
Registry $registry,
54+
CategoryFactory $categoryFactory,
5055
array $data = []
5156
) {
5257
$this->_categoryTree = $categoryTree;
@@ -67,36 +72,47 @@ public function getCategory()
6772
}
6873

6974
/**
75+
* Get category id
76+
*
7077
* @return int|string|null
7178
*/
7279
public function getCategoryId()
7380
{
7481
if ($this->getCategory()) {
75-
return $this->getCategory()->getId();
82+
return $this->getCategory()
83+
->getId();
7684
}
77-
return \Magento\Catalog\Model\Category::TREE_ROOT_ID;
85+
return Category::TREE_ROOT_ID;
7886
}
7987

8088
/**
89+
* Get category name
90+
*
8191
* @return string
8292
*/
8393
public function getCategoryName()
8494
{
85-
return $this->getCategory()->getName();
95+
return $this->getCategory()
96+
->getName();
8697
}
8798

8899
/**
100+
* Get category path
101+
*
89102
* @return mixed
90103
*/
91104
public function getCategoryPath()
92105
{
93106
if ($this->getCategory()) {
94-
return $this->getCategory()->getPath();
107+
return $this->getCategory()
108+
->getPath();
95109
}
96-
return \Magento\Catalog\Model\Category::TREE_ROOT_ID;
110+
return Category::TREE_ROOT_ID;
97111
}
98112

99113
/**
114+
* Check store root category
115+
*
100116
* @return bool
101117
*/
102118
public function hasStoreRootCategory()
@@ -109,15 +125,20 @@ public function hasStoreRootCategory()
109125
}
110126

111127
/**
128+
* Get store from request
129+
*
112130
* @return Store
113131
*/
114132
public function getStore()
115133
{
116-
$storeId = (int)$this->getRequest()->getParam('store');
134+
$storeId = (int)$this->getRequest()
135+
->getParam('store');
117136
return $this->_storeManager->getStore($storeId);
118137
}
119138

120139
/**
140+
* Get root category for tree
141+
*
121142
* @param mixed|null $parentNodeCategory
122143
* @param int $recursionLevel
123144
* @return Node|array|null
@@ -130,13 +151,14 @@ public function getRoot($parentNodeCategory = null, $recursionLevel = 3)
130151
}
131152
$root = $this->_coreRegistry->registry('root');
132153
if ($root === null) {
133-
$storeId = (int)$this->getRequest()->getParam('store');
154+
$storeId = (int)$this->getRequest()
155+
->getParam('store');
134156

135157
if ($storeId) {
136158
$store = $this->_storeManager->getStore($storeId);
137159
$rootId = $store->getRootCategoryId();
138160
} else {
139-
$rootId = \Magento\Catalog\Model\Category::TREE_ROOT_ID;
161+
$rootId = Category::TREE_ROOT_ID;
140162
}
141163

142164
$tree = $this->_categoryTree->load(null, $recursionLevel);
@@ -149,10 +171,11 @@ public function getRoot($parentNodeCategory = null, $recursionLevel = 3)
149171

150172
$root = $tree->getNodeById($rootId);
151173

152-
if ($root && $rootId != \Magento\Catalog\Model\Category::TREE_ROOT_ID) {
174+
if ($root) {
153175
$root->setIsVisible(true);
154-
} elseif ($root && $root->getId() == \Magento\Catalog\Model\Category::TREE_ROOT_ID) {
155-
$root->setName(__('Root'));
176+
if ($root->getId() == Category::TREE_ROOT_ID) {
177+
$root->setName(__('Root'));
178+
}
156179
}
157180

158181
$this->_coreRegistry->register('root', $root);
@@ -162,22 +185,28 @@ public function getRoot($parentNodeCategory = null, $recursionLevel = 3)
162185
}
163186

164187
/**
188+
* Get Default Store Id
189+
*
165190
* @return int
166191
*/
167192
protected function _getDefaultStoreId()
168193
{
169-
return \Magento\Store\Model\Store::DEFAULT_STORE_ID;
194+
return Store::DEFAULT_STORE_ID;
170195
}
171196

172197
/**
198+
* Get category collection
199+
*
173200
* @return \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
174201
*/
175202
public function getCategoryCollection()
176203
{
177-
$storeId = $this->getRequest()->getParam('store', $this->_getDefaultStoreId());
204+
$storeId = $this->getRequest()
205+
->getParam('store', $this->_getDefaultStoreId());
178206
$collection = $this->getData('category_collection');
179207
if ($collection === null) {
180-
$collection = $this->_categoryFactory->create()->getCollection();
208+
$collection = $this->_categoryFactory->create()
209+
->getCollection();
181210

182211
$collection->addAttributeToSelect(
183212
'name'
@@ -212,11 +241,11 @@ public function getRootByIds($ids)
212241
if (null === $root) {
213242
$ids = $this->_categoryTree->getExistingCategoryIdsBySpecifiedIds($ids);
214243
$tree = $this->_categoryTree->loadByIds($ids);
215-
$rootId = \Magento\Catalog\Model\Category::TREE_ROOT_ID;
244+
$rootId = Category::TREE_ROOT_ID;
216245
$root = $tree->getNodeById($rootId);
217-
if ($root && $rootId != \Magento\Catalog\Model\Category::TREE_ROOT_ID) {
246+
if ($root && $rootId != Category::TREE_ROOT_ID) {
218247
$root->setIsVisible(true);
219-
} elseif ($root && $root->getId() == \Magento\Catalog\Model\Category::TREE_ROOT_ID) {
248+
} elseif ($root && $root->getId() == Category::TREE_ROOT_ID) {
220249
$root->setName(__('Root'));
221250
}
222251

@@ -227,6 +256,8 @@ public function getRootByIds($ids)
227256
}
228257

229258
/**
259+
* Get category node for tree
260+
*
230261
* @param mixed $parentNodeCategory
231262
* @param int $recursionLevel
232263
* @return Node
@@ -237,9 +268,9 @@ public function getNode($parentNodeCategory, $recursionLevel = 2)
237268
$node = $this->_categoryTree->loadNode($nodeId);
238269
$node->loadChildren($recursionLevel);
239270

240-
if ($node && $nodeId != \Magento\Catalog\Model\Category::TREE_ROOT_ID) {
271+
if ($node && $nodeId != Category::TREE_ROOT_ID) {
241272
$node->setIsVisible(true);
242-
} elseif ($node && $node->getId() == \Magento\Catalog\Model\Category::TREE_ROOT_ID) {
273+
} elseif ($node && $node->getId() == Category::TREE_ROOT_ID) {
243274
$node->setName(__('Root'));
244275
}
245276

@@ -249,17 +280,26 @@ public function getNode($parentNodeCategory, $recursionLevel = 2)
249280
}
250281

251282
/**
283+
* Get category save url
284+
*
252285
* @param array $args
253286
* @return string
254287
*/
255288
public function getSaveUrl(array $args = [])
256289
{
257-
$params = ['_current' => false, '_query' => false, 'store' => $this->getStore()->getId()];
290+
$params = [
291+
'_current' => false,
292+
'_query' => false,
293+
'store' => $this->getStore()
294+
->getId()
295+
];
258296
$params = array_merge($params, $args);
259297
return $this->getUrl('catalog/*/save', $params);
260298
}
261299

262300
/**
301+
* Get category edit url
302+
*
263303
* @return string
264304
*/
265305
public function getEditUrl()
@@ -279,7 +319,7 @@ public function getRootIds()
279319
{
280320
$ids = $this->getData('root_ids');
281321
if ($ids === null) {
282-
$ids = [\Magento\Catalog\Model\Category::TREE_ROOT_ID];
322+
$ids = [Category::TREE_ROOT_ID];
283323
foreach ($this->_storeManager->getGroups() as $store) {
284324
$ids[] = $store->getRootCategoryId();
285325
}

app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/checkboxes/tree.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
"categoryCheckboxTree": {
2121
"dataUrl": "<?= $block->escapeUrl($block->getLoadTreeUrl()) ?>",
2222
"divId": "<?= /* @noEscape */ $divId ?>",
23-
"rootVisible": <?= /* @noEscape */ $block->getRoot()->getIsVisible() ? 'true' : 'false' ?>,
23+
"rootVisible": false,
2424
"useAjax": <?= $block->escapeHtml($block->getUseAjax()) ?>,
2525
"currentNodeId": <?= (int)$block->getCategoryId() ?>,
2626
"jsFormObject": "<?= /* @noEscape */ $block->getJsFormObject() ?>",
2727
"name": "<?= $block->escapeHtml($block->getRoot()->getName()) ?>",
2828
"checked": "<?= $block->escapeHtml($block->getRoot()->getChecked()) ?>",
2929
"allowdDrop": <?= /* @noEscape */ $block->getRoot()->getIsVisible() ? 'true' : 'false' ?>,
3030
"rootId": <?= (int)$block->getRoot()->getId() ?>,
31-
"expanded": <?= (int)$block->getIsWasExpanded() ?>,
31+
"expanded": true,
3232
"categoryId": <?= (int)$block->getCategoryId() ?>,
3333
"treeJson": <?= /* @noEscape */ $block->getTreeJson() ?>
3434
}

app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/tree.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@
302302
}
303303
<?php endif;?>
304304
//updateContent(url); //commented since ajax requests replaced with http ones to load a category
305+
jQuery('#tree-div').find('.x-tree-node-el').first().remove();
305306
}
306307

307308
jQuery(function () {

app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/widget/tree.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ jQuery(function()
160160
loader: categoryLoader,
161161
enableDD: false,
162162
containerScroll: true,
163-
rootVisible: '<?= /* @escapeNotVerified */ $block->getRoot()->getIsVisible() ?>',
163+
rootVisible: false,
164164
useAjax: true,
165165
currentNodeId: <?= (int) $block->getCategoryId() ?>,
166166
addNodeTo: false
@@ -177,7 +177,7 @@ jQuery(function()
177177
text: 'Psw',
178178
draggable: false,
179179
id: <?= (int) $block->getRoot()->getId() ?>,
180-
expanded: <?= (int) $block->getIsWasExpanded() ?>,
180+
expanded: true,
181181
category_id: <?= (int) $block->getCategoryId() ?>
182182
};
183183

app/code/Magento/Msrp/view/base/web/js/msrp.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ define([
7373
this.initTierPopup();
7474
}
7575
$(this.options.cartButtonId).on('click', this._addToCartSubmit.bind(this));
76+
$(this.options.cartForm).on('submit', this._onSubmitForm.bind(this));
7677
},
7778

7879
/**
@@ -249,8 +250,10 @@ define([
249250

250251
/**
251252
* Handler for addToCart action
253+
*
254+
* @param {Object} e
252255
*/
253-
_addToCartSubmit: function () {
256+
_addToCartSubmit: function (e) {
254257
this.element.trigger('addToCart', this.element);
255258

256259
if (this.element.data('stop-processing')) {
@@ -266,8 +269,20 @@ define([
266269
if (this.options.addToCartUrl) {
267270
$('.mage-dropdown-dialog > .ui-dialog-content').dropdownDialog('close');
268271
}
272+
273+
e.preventDefault();
269274
$(this.options.cartForm).submit();
275+
},
270276

277+
/**
278+
* Handler for submit form
279+
*
280+
* @private
281+
*/
282+
_onSubmitForm: function () {
283+
if ($(this.options.cartForm).valid()) {
284+
$(this.options.cartButtonId).prop('disabled', true);
285+
}
271286
}
272287
});
273288

app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,14 @@ define([
179179
* @private
180180
*/
181181
clearEvents: function () {
182-
this.fotoramaItem.off(
183-
'fotorama:show.' + this.PV +
184-
' fotorama:showend.' + this.PV +
185-
' fotorama:fullscreenenter.' + this.PV +
186-
' fotorama:fullscreenexit.' + this.PV
187-
);
182+
if (this.fotoramaItem !== undefined) {
183+
this.fotoramaItem.off(
184+
'fotorama:show.' + this.PV +
185+
' fotorama:showend.' + this.PV +
186+
' fotorama:fullscreenenter.' + this.PV +
187+
' fotorama:fullscreenexit.' + this.PV
188+
);
189+
}
188190
},
189191

190192
/**

0 commit comments

Comments
 (0)