Skip to content

Commit d6bb4de

Browse files
authored
Merge pull request #1266 from magento-south/PRS
Fixed issues: - MAGETWO-52783 [FT] CreateVirtualProductEntityTestVariation5 fail because cannot import custom options from another product - MAGETWO-59489 [Github] Can't change reset password template #6885 - MAGETWO-60972 FPT price should not applied for dynamic bundle product - MAGETWO-54256 [SWAT] Store view, store and website CRUD takes long time with no warning - MAGETWO-57651 Catalog Price not applying to bundle options - MAGETWO-68794 Password policy does not work correctly - MAGETWO-69351 Fatal error if admin try to add some SKU with additional space symbol
2 parents ec23f60 + 07a66a2 commit d6bb4de

File tree

49 files changed

+1278
-300
lines changed

Some content is hidden

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

49 files changed

+1278
-300
lines changed

app/code/Magento/Backend/Block/System/Store/Edit.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
*/
66
namespace Magento\Backend\Block\System\Store;
77

8+
use Magento\Framework\App\ObjectManager;
9+
use Magento\Framework\Serialize\SerializerInterface;
10+
811
/**
12+
* @api
13+
*
914
* Adminhtml store edit
1015
*/
1116
class Edit extends \Magento\Backend\Block\Widget\Form\Container
@@ -17,17 +22,25 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container
1722
*/
1823
protected $_coreRegistry = null;
1924

25+
/**
26+
* @var SerializerInterface
27+
*/
28+
private $serializer;
29+
2030
/**
2131
* @param \Magento\Backend\Block\Widget\Context $context
2232
* @param \Magento\Framework\Registry $registry
2333
* @param array $data
34+
* @param SerializerInterface|null $serializer
2435
*/
2536
public function __construct(
2637
\Magento\Backend\Block\Widget\Context $context,
2738
\Magento\Framework\Registry $registry,
28-
array $data = []
39+
array $data = [],
40+
SerializerInterface $serializer = null
2941
) {
3042
$this->_coreRegistry = $registry;
43+
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class);
3144
parent::__construct($context, $data);
3245
}
3346

@@ -127,4 +140,14 @@ protected function _buildFormClassName()
127140
{
128141
return parent::_buildFormClassName() . '\\' . ucwords($this->_coreRegistry->registry('store_type'));
129142
}
143+
144+
/**
145+
* Get data for store edit
146+
*
147+
* @return string
148+
*/
149+
public function getStoreData()
150+
{
151+
return $this->serializer->serialize($this->_coreRegistry->registry('store_data')->getData());
152+
}
130153
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
9+
<update handle="formkey"/>
10+
<body>
11+
<referenceContainer name="content">
12+
<block class="Magento\Backend\Block\Widget\Container" name="adminhtml_admin_delete_confirm" template="Magento_Backend::admin/delete_confirm.phtml"/>
13+
</referenceContainer>
14+
</body>
15+
</page>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
9+
<update handle="formkey"/>
10+
<body>
11+
<referenceContainer name="content">
12+
<block class="Magento\Backend\Block\System\Store\Edit" name="adminhtml_admin_save_confirm" template="Magento_Backend::admin/save_confirm.phtml"/>
13+
</referenceContainer>
14+
</body>
15+
</page>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
?>
7+
<script type="text/x-magento-init">
8+
{
9+
"#edit_form": {
10+
"Magento_Backend/js/delete-with-confirm": {}
11+
}
12+
}
13+
</script>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
/** @var \Magento\Backend\Block\System\Store\Edit $block */
8+
9+
?>
10+
<script type="text/x-magento-init">
11+
{
12+
"#edit_form": {
13+
"Magento_Backend/js/save-with-confirm": {
14+
"storeData": <?= /* @noEscape */ $block->getStoreData() ?>
15+
}
16+
}
17+
}
18+
</script>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
*
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
define([
7+
'jquery',
8+
'Magento_Backend/js/validate-store'
9+
], function ($, validateStore) {
10+
'use strict';
11+
12+
$.widget('mage.deleteWithConfirm', validateStore, {});
13+
14+
return $.mage.deleteWithConfirm;
15+
});
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
*
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
define([
7+
'jquery',
8+
'Magento_Backend/js/validate-store'
9+
], function ($, validateStore) {
10+
'use strict';
11+
12+
$.widget('mage.saveWithConfirm', validateStore, {
13+
14+
/**
15+
* Check is it need to show confirmation popup
16+
*
17+
* @returns {Boolean}
18+
*/
19+
_needConfirm: function () {
20+
21+
var storeData = this.settings.storeData,
22+
23+
/* edit store view*/
24+
storeViewEdit = $('[name="store[store_id]"]').length,
25+
groupId = $('[name="store[group_id]"]').val(),
26+
isNewStoreView = !$('[name="store[store_id]"]').val(),
27+
28+
/* edit store */
29+
storeEdit = $('[name="group[group_id]"]').length,
30+
storeId = $('[name="group[group_id]"]').val(),
31+
rootCategoryId = $('[name="group[root_category_id]"]').val(),
32+
defaultStoreView = $('[name="group[default_store_id]"]').val(),
33+
34+
/* edit website */
35+
websiteEdit = $('[name="website[website_id]"]').length,
36+
defaultStore = $('[name="website[default_group_id]"]').val(),
37+
38+
/* conditions */
39+
storeViewUpdated = storeViewEdit && (isNewStoreView || storeData['group_id'] !== groupId),
40+
storeUpdated = storeEdit && storeId &&
41+
(rootCategoryId !== null && storeData['root_category_id'] !== rootCategoryId ||
42+
defaultStoreView !== null && storeData['default_store_id'] !== defaultStoreView),
43+
websiteUpdated = websiteEdit && defaultStore !== null && storeData['default_group_id'] !== defaultStore;
44+
45+
return storeViewUpdated || storeUpdated || websiteUpdated;
46+
}
47+
});
48+
49+
return $.mage.saveWithConfirm;
50+
});
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
define([
6+
'jquery',
7+
'jquery/ui',
8+
'mage/dataPost',
9+
'mage/backend/validation',
10+
'Magento_Ui/js/modal/confirm'
11+
], function ($, jqueryUi, dataPost, validation, modalConfirm) {
12+
'use strict';
13+
14+
$.widget('mage.storeValidation', {
15+
16+
/**
17+
* Validation creation
18+
* @protected
19+
*/
20+
_create: function () {
21+
var form = this.element[0],
22+
validator = $.data(form, 'validator');
23+
24+
if (validator && validator.settings) {
25+
validator.settings.submitHandler = this._saveHandler;
26+
validator.settings.confirmCallback = this._needConfirm;
27+
$.extend(validator.settings, this.options);
28+
$.data(form, 'validator', validator);
29+
}
30+
},
31+
32+
/**
33+
* Check is it need to show confirmation popup
34+
*
35+
* @returns {Boolean}
36+
*/
37+
_needConfirm: function () {
38+
return true;
39+
},
40+
41+
/**
42+
* Save form with confirmation if needed
43+
*
44+
* @param {Object} form
45+
* @private
46+
*/
47+
_saveHandler: function (form) {
48+
var formData = {},
49+
requestData = {},
50+
options = $.data(form, 'validator').settings;
51+
52+
if ($(form).validation('isValid')) {
53+
$.each($(form).serializeArray(), function () {
54+
formData[this.name] = this.value || '';
55+
});
56+
requestData = {
57+
action: $(form).attr('action'),
58+
data: formData
59+
};
60+
61+
if (options.confirmCallback.call(this)) {
62+
modalConfirm({
63+
title: $.mage.__('Warning message'),
64+
content: $.mage.__('This operation can take a long time'),
65+
actions: {
66+
/**
67+
* 'Confirm' action handler.
68+
*/
69+
confirm: function () {
70+
dataPost().postData(requestData);
71+
}
72+
}
73+
});
74+
} else {
75+
dataPost().postData(requestData);
76+
}
77+
}
78+
}
79+
});
80+
81+
return $.mage.storeValidation;
82+
});
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Model;
7+
8+
use Magento\Catalog\Model\Indexer\Category\Product\AbstractAction;
9+
use Magento\Framework\DB\Select;
10+
use Magento\Framework\DB\Sql\UnionExpression;
11+
12+
/**
13+
* Provides info about product categories.
14+
*/
15+
class ProductCategoryList
16+
{
17+
/**
18+
* @var array
19+
*/
20+
private $categoryIdList = [];
21+
22+
/**
23+
* @var ResourceModel\Product
24+
*/
25+
private $productResource;
26+
27+
/**
28+
* @var ResourceModel\Category
29+
*/
30+
private $category;
31+
32+
/**
33+
* @param ResourceModel\Product $productResource
34+
* @param ResourceModel\Category $category
35+
*/
36+
public function __construct(
37+
ResourceModel\Product $productResource,
38+
ResourceModel\Category $category
39+
) {
40+
$this->productResource = $productResource;
41+
$this->category = $category;
42+
}
43+
44+
/**
45+
* Retrieve category id list where product is present.
46+
*
47+
* @param int $productId
48+
* @return array
49+
*/
50+
public function getCategoryIds($productId)
51+
{
52+
if (!isset($this->categoryIdList[$productId])) {
53+
$unionSelect = new UnionExpression(
54+
[
55+
$this->getCategorySelect($productId, $this->category->getCategoryProductTable()),
56+
$this->getCategorySelect(
57+
$productId,
58+
$this->productResource->getTable(AbstractAction::MAIN_INDEX_TABLE)
59+
)
60+
],
61+
Select::SQL_UNION_ALL
62+
);
63+
64+
$this->categoryIdList[$productId] = $this->productResource->getConnection()->fetchCol($unionSelect);
65+
}
66+
67+
return $this->categoryIdList[$productId];
68+
}
69+
70+
/**
71+
* Returns DB select.
72+
*
73+
* @param int $productId
74+
* @param string $tableName
75+
* @return Select
76+
*/
77+
public function getCategorySelect($productId, $tableName)
78+
{
79+
return $this->productResource->getConnection()->select()->from(
80+
$tableName,
81+
['category_id']
82+
)->where(
83+
'product_id = ?',
84+
$productId
85+
);
86+
}
87+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ public function get($sku, $editMode = false, $storeId = null, $forceReload = fal
248248
$product->load($productId);
249249
$this->cacheProduct($cacheKey, $product);
250250
}
251+
if (!isset($this->instances[$sku])) {
252+
$sku = trim($sku);
253+
}
251254
return $this->instances[$sku][$cacheKey];
252255
}
253256

0 commit comments

Comments
 (0)