Skip to content

Commit 5ab1fa2

Browse files
author
Oleksandr Karpenko
committed
Merge branch 'develop' of https://github.corp.magento.com/magento2/magento2ce into develop
2 parents 72643bf + 951694c commit 5ab1fa2

File tree

208 files changed

+2350
-1156
lines changed

Some content is hidden

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

208 files changed

+2350
-1156
lines changed

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Action.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ protected function _toOptionHtml($action, \Magento\Framework\DataObject $row)
8282
$actionCaption = '';
8383
$this->_transformActionData($action, $actionCaption, $row);
8484

85-
$htmlAttibutes = ['value' => $this->escapeHtml($this->_jsonEncoder->encode($action))];
86-
$actionAttributes->setData($htmlAttibutes);
85+
$htmlAttributes = ['value' => $this->escapeHtml($this->_jsonEncoder->encode($action))];
86+
$actionAttributes->setData($htmlAttributes);
8787
return '<option ' . $actionAttributes->serialize() . '>' . $actionCaption . '</option>';
8888
}
8989

app/code/Magento/Backend/view/adminhtml/templates/store/switcher/form/renderer/fieldset.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<?php else: ?>
2626
<?php echo $block->getHintHtml() ?>
2727
<?php endif; ?>
28-
<div class="tree-store-scope">
28+
<div class="admin__fieldset tree-store-scope">
2929
<?php if ($_element->getComment()): ?>
3030
<p class="comment"><?php echo $block->escapeHtml($_element->getComment()) ?></p>
3131
<?php endif; ?>

app/code/Magento/Braintree/view/frontend/web/template/payment/form.html

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,26 +105,24 @@
105105
</div>
106106
<!-- /ko -->
107107
<!-- ko if: (isVaultEnabled())-->
108-
<div class="field">
108+
<div class="field choice">
109109
<input type="checkbox"
110110
name="vault[is_enabled]"
111-
class="checkbox-inline"
111+
class="checkbox"
112112
data-bind="attr: {'id': getCode() + '_vault_enabler'}, checked: vaultEnabler.isActivePaymentTokenEnabler"/>
113113
<label class="label" data-bind="attr: {'for': getCode() + '_vault_enabler'}">
114114
<span><!-- ko i18n: 'Save for later use.'--><!-- /ko --></span>
115115
</label>
116-
<div class="control _with-tooltip">
117-
<div class="field-tooltip toggle">
116+
<div class="field-tooltip toggle">
118117
<span class="field-tooltip-action action-vault"
119118
tabindex="0"
120119
data-toggle="dropdown"
121120
data-bind="attr: {title: $t('What is this?')}, mageInit: {'dropdown':{'activeClass': '_active'}}">
122121
<span translate="'What is this?'"></span>
123122
</span>
124-
<div class="field-tooltip-content"
125-
data-target="dropdown"
126-
translate="'We store you payment information securely on Braintree servers via SSL.'"></div>
127-
</div>
123+
<div class="field-tooltip-content"
124+
data-target="dropdown"
125+
translate="'We store you payment information securely on Braintree servers via SSL.'"></div>
128126
</div>
129127
</div>
130128
<!-- /ko -->

app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ protected function getBundleSelections()
578578
'parentSelections' => 'bundle_selections',
579579
'changer' => 'option_info.type',
580580
'dataType' => Form\Element\DataType\Boolean::NAME,
581-
'label' => __('Default'),
581+
'label' => __('Is Default'),
582582
'dataScope' => 'is_default',
583583
'prefer' => 'radio',
584584
'value' => '0',

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ abstract class Category extends \Magento\Backend\App\Action
1717
*/
1818
const ADMIN_RESOURCE = 'Magento_Catalog::categories';
1919

20+
/**
21+
* @var \Magento\Framework\Stdlib\DateTime\Filter\DateTime
22+
*/
23+
private $dateTimeFilter;
24+
2025
/**
2126
* Initialize requested category and put it into registry.
2227
* Root category can be returned, if inappropriate store/category is specified
@@ -107,4 +112,41 @@ protected function ajaxRequestResponse($category, $resultPage)
107112
$resultJson->setData($eventResponse->getData());
108113
return $resultJson;
109114
}
115+
116+
/**
117+
* @return \Magento\Framework\Stdlib\DateTime\Filter\DateTime
118+
*
119+
* @deprecated
120+
*/
121+
private function getDateTimeFilter()
122+
{
123+
if ($this->dateTimeFilter === null) {
124+
$this->dateTimeFilter = \Magento\Framework\App\ObjectManager::getInstance()
125+
->get(\Magento\Framework\Stdlib\DateTime\Filter\DateTime::class);
126+
}
127+
return $this->dateTimeFilter;
128+
}
129+
130+
/**
131+
* Datetime data preprocessing
132+
*
133+
* @param \Magento\Catalog\Model\Category $category
134+
* @param array $postData
135+
*
136+
* @return array
137+
*/
138+
protected function dateTimePreprocessing($category, $postData)
139+
{
140+
$dateFieldFilters = [];
141+
$attributes = $category->getAttributes();
142+
foreach ($attributes as $attrKey => $attribute) {
143+
if ($attribute->getBackend()->getType() == 'datetime') {
144+
if (array_key_exists($attrKey, $postData) && $postData[$attrKey] != '') {
145+
$dateFieldFilters[$attrKey] = $this->getDateTimeFilter();
146+
}
147+
}
148+
}
149+
$inputFilter = new \Zend_Filter_Input($dateFieldFilters, [], $postData);
150+
return $inputFilter->getUnescaped();
151+
}
110152
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ public function execute()
5050
return $resultRedirect->setPath('catalog/*/', ['_current' => true, 'id' => null]);
5151
}
5252

53+
/**
54+
* Check if there are data in session (if there was an exception on saving category)
55+
*/
56+
$categoryData = $this->_getSession()->getCategoryData(true);
57+
if (is_array($categoryData)) {
58+
unset($categoryData['image']);
59+
$category->addData($categoryData);
60+
}
61+
5362
$resultPageFactory = $this->_objectManager->get('Magento\Framework\View\Result\PageFactory');
5463
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
5564
$resultPage = $resultPageFactory->create();

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,16 @@ public function execute()
8080
}
8181

8282
/**
83-
* Check if we have data in session (if during category save was exception)
83+
* Check if there are data in session (if there was an exception on saving category)
8484
*/
85-
$data = $this->_getSession()->getCategoryData(true);
86-
if (isset($data['general'])) {
87-
if (isset($data['general']['image']['delete'])) {
88-
$data['general']['image'] = null;
85+
$categoryData = $this->_getSession()->getCategoryData(true);
86+
if (is_array($categoryData)) {
87+
if (isset($categoryData['image']['delete'])) {
88+
$categoryData['image'] = null;
8989
} else {
90-
unset($data['general']['image']);
90+
unset($categoryData['image']);
9191
}
92-
$category->addData($data['general']);
92+
$category->addData($categoryData);
9393
}
9494

9595
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */

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

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
/**
1111
* Class Save
12-
*
12+
*
1313
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1414
*/
1515
class Save extends \Magento\Catalog\Controller\Adminhtml\Category
@@ -34,15 +34,13 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Category
3434
* @var array
3535
*/
3636
protected $stringToBoolInputs = [
37-
'general' => [
38-
'custom_use_parent_settings',
39-
'custom_apply_to_products',
40-
'is_active',
41-
'include_in_menu',
42-
'is_anchor',
43-
'use_default' => ['url_key'],
44-
'use_config' => ['available_sort_by', 'filter_price_range', 'default_sort_by']
45-
]
37+
'custom_use_parent_settings',
38+
'custom_apply_to_products',
39+
'is_active',
40+
'include_in_menu',
41+
'is_anchor',
42+
'use_default' => ['url_key'],
43+
'use_config' => ['available_sort_by', 'filter_price_range', 'default_sort_by']
4644
];
4745

4846
/**
@@ -110,15 +108,18 @@ public function execute()
110108
}
111109

112110
$data['general'] = $this->getRequest()->getPostValue();
113-
$isNewCategory = !isset($data['general']['entity_id']);
114-
$data = $this->stringToBoolConverting($data);
115-
$data = $this->imagePreprocessing($data);
116-
$storeId = isset($data['general']['store_id']) ? $data['general']['store_id'] : null;
111+
$categoryPostData = $data['general'];
112+
113+
$isNewCategory = !isset($categoryPostData['entity_id']);
114+
$categoryPostData = $this->stringToBoolConverting($categoryPostData);
115+
$categoryPostData = $this->imagePreprocessing($categoryPostData);
116+
$categoryPostData = $this->dateTimePreprocessing($category, $categoryPostData);
117+
$storeId = isset($categoryPostData['store_id']) ? $categoryPostData['store_id'] : null;
117118
$store = $this->storeManager->getStore($storeId);
118119
$this->storeManager->setCurrentStore($store->getCode());
119-
$parentId = isset($data['general']['parent']) ? $data['general']['parent'] : null;
120-
if ($data['general']) {
121-
$category->addData($this->_filterCategoryPostData($data['general']));
120+
$parentId = isset($categoryPostData['parent']) ? $categoryPostData['parent'] : null;
121+
if ($categoryPostData) {
122+
$category->addData($this->_filterCategoryPostData($categoryPostData));
122123
if ($isNewCategory) {
123124
$parentCategory = $this->getParentCategory($parentId, $storeId);
124125
$category->setPath($parentCategory->getPath());
@@ -128,10 +129,10 @@ public function execute()
128129
/**
129130
* Process "Use Config Settings" checkboxes
130131
*/
131-
$generalPost = $data['general'];
132+
132133
$useConfig = [];
133-
if (isset($generalPost['use_config']) && !empty($generalPost['use_config'])) {
134-
foreach ($generalPost['use_config'] as $attributeCode => $attributeValue) {
134+
if (isset($categoryPostData['use_config']) && !empty($categoryPostData['use_config'])) {
135+
foreach ($categoryPostData['use_config'] as $attributeCode => $attributeValue) {
135136
if ($attributeValue) {
136137
$useConfig[] = $attributeCode;
137138
$category->setData($attributeCode, null);
@@ -141,11 +142,11 @@ public function execute()
141142

142143
$category->setAttributeSetId($category->getDefaultAttributeSetId());
143144

144-
if (isset($data['general']['category_products'])
145-
&& is_string($data['general']['category_products'])
145+
if (isset($categoryPostData['category_products'])
146+
&& is_string($categoryPostData['category_products'])
146147
&& !$category->getProductsReadonly()
147148
) {
148-
$products = json_decode($data['general']['category_products'], true);
149+
$products = json_decode($categoryPostData['category_products'], true);
149150
$category->setPostedProducts($products);
150151
}
151152
$this->_eventManager->dispatch(
@@ -156,8 +157,8 @@ public function execute()
156157
/**
157158
* Check "Use Default Value" checkboxes values
158159
*/
159-
if (isset($generalPost['use_default']) && !empty($generalPost['use_default'])) {
160-
foreach ($generalPost['use_default'] as $attributeCode => $attributeValue) {
160+
if (isset($categoryPostData['use_default']) && !empty($categoryPostData['use_default'])) {
161+
foreach ($categoryPostData['use_default'] as $attributeCode => $attributeValue) {
161162
if ($attributeValue) {
162163
$category->setData($attributeCode, null);
163164
}
@@ -197,15 +198,15 @@ public function execute()
197198
} catch (\Magento\Framework\Exception\AlreadyExistsException $e) {
198199
$this->messageManager->addError($e->getMessage());
199200
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
200-
$this->_getSession()->setCategoryData($data);
201+
$this->_getSession()->setCategoryData($categoryPostData);
201202
} catch (\Magento\Framework\Exception\LocalizedException $e) {
202203
$this->messageManager->addError($e->getMessage());
203204
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
204-
$this->_getSession()->setCategoryData($data);
205+
$this->_getSession()->setCategoryData($categoryPostData);
205206
} catch (\Exception $e) {
206207
$this->messageManager->addError(__('Something went wrong while saving the category.'));
207208
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
208-
$this->_getSession()->setCategoryData($data);
209+
$this->_getSession()->setCategoryData($categoryPostData);
209210
}
210211
}
211212

@@ -248,9 +249,9 @@ public function execute()
248249
*/
249250
public function imagePreprocessing($data)
250251
{
251-
if (empty($data['general']['image'])) {
252-
unset($data['general']['image']);
253-
$data['general']['image']['delete'] = true;
252+
if (empty($data['image'])) {
253+
unset($data['image']);
254+
$data['image']['delete'] = true;
254255
}
255256
return $data;
256257
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ private function getCategoryLinkManagement()
251251

252252
/**
253253
* @return StoreManagerInterface
254+
* @deprecated
254255
*/
255256
private function getStoreManager()
256257
{
@@ -265,6 +266,7 @@ private function getStoreManager()
265266
* Retrieve data persistor
266267
*
267268
* @return DataPersistorInterface|mixed
269+
* @deprecated
268270
*/
269271
protected function getDataPersistor()
270272
{

app/code/Magento/Catalog/Controller/Adminhtml/Product/Validate.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Backend\App\Action;
1010
use Magento\Catalog\Controller\Adminhtml\Product;
1111
use Magento\Framework\App\ObjectManager;
12+
use Magento\Store\Model\StoreManagerInterface;
1213

1314
/**
1415
* Product validate
@@ -47,6 +48,11 @@ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product
4748
*/
4849
protected $initializationHelper;
4950

51+
/**
52+
* @var StoreManagerInterface
53+
*/
54+
private $storeManager;
55+
5056
/**
5157
* @param Action\Context $context
5258
* @param Builder $productBuilder
@@ -91,10 +97,12 @@ public function execute()
9197
if ($productData && !isset($productData['stock_data']['use_config_manage_stock'])) {
9298
$productData['stock_data']['use_config_manage_stock'] = 0;
9399
}
100+
$storeId = $this->getRequest()->getParam('store', 0);
101+
$store = $this->getStoreManager()->getStore($storeId);
102+
$this->getStoreManager()->setCurrentStore($store->getCode());
94103
/* @var $product \Magento\Catalog\Model\Product */
95104
$product = $this->productFactory->create();
96105
$product->setData('_edit_mode', true);
97-
$storeId = $this->getRequest()->getParam('store');
98106
if ($storeId) {
99107
$product->setStoreId($storeId);
100108
}
@@ -137,6 +145,19 @@ public function execute()
137145
return $this->resultJsonFactory->create()->setData($response);
138146
}
139147

148+
/**
149+
* @return StoreManagerInterface
150+
* @deprecated
151+
*/
152+
private function getStoreManager()
153+
{
154+
if (null === $this->storeManager) {
155+
$this->storeManager = \Magento\Framework\App\ObjectManager::getInstance()
156+
->get('Magento\Store\Model\StoreManagerInterface');
157+
}
158+
return $this->storeManager;
159+
}
160+
140161
/**
141162
* @return Initialization\Helper
142163
* @deprecated

0 commit comments

Comments
 (0)