Skip to content

Commit 9b50b19

Browse files
Merge pull request #1869 from magento-borg/MAGETWO-85893-2.3-develop-merge
[borg] MAGETWO-85893: Updating 2.3-develop
2 parents 5017fda + fc97826 commit 9b50b19

File tree

125 files changed

+4634
-1785
lines changed

Some content is hidden

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

125 files changed

+4634
-1785
lines changed

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

Lines changed: 76 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -7,75 +7,93 @@
77

88
namespace Magento\Catalog\Controller\Adminhtml\Product\Attribute;
99

10+
use Magento\Backend\App\Action\Context;
11+
use Magento\Backend\Model\View\Result\Redirect;
12+
use Magento\Catalog\Api\Data\ProductAttributeInterface;
13+
use Magento\Catalog\Controller\Adminhtml\Product\Attribute;
14+
use Magento\Catalog\Helper\Product;
15+
use Magento\Catalog\Model\Product\AttributeSet\BuildFactory;
16+
use Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory;
17+
use Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\Validator;
18+
use Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory;
19+
use Magento\Eav\Model\Entity\Attribute\Set;
20+
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory;
21+
use Magento\Framework\Cache\FrontendInterface;
22+
use Magento\Framework\Controller\Result\Json;
1023
use Magento\Framework\Controller\ResultFactory;
1124
use Magento\Framework\Exception\AlreadyExistsException;
25+
use Magento\Framework\Exception\LocalizedException;
26+
use Magento\Framework\Filter\FilterManager;
27+
use Magento\Framework\Registry;
28+
use Magento\Framework\View\LayoutFactory;
29+
use Magento\Framework\View\Result\PageFactory;
1230

1331
/**
1432
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1533
*/
16-
class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Attribute
34+
class Save extends Attribute
1735
{
1836
/**
19-
* @var \Magento\Catalog\Model\Product\AttributeSet\BuildFactory
37+
* @var BuildFactory
2038
*/
2139
protected $buildFactory;
2240

2341
/**
24-
* @var \Magento\Framework\Filter\FilterManager
42+
* @var FilterManager
2543
*/
2644
protected $filterManager;
2745

2846
/**
29-
* @var \Magento\Catalog\Helper\Product
47+
* @var Product
3048
*/
3149
protected $productHelper;
3250

3351
/**
34-
* @var \Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory
52+
* @var AttributeFactory
3553
*/
3654
protected $attributeFactory;
3755

3856
/**
39-
* @var \Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory
57+
* @var ValidatorFactory
4058
*/
4159
protected $validatorFactory;
4260

4361
/**
44-
* @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory
62+
* @var CollectionFactory
4563
*/
4664
protected $groupCollectionFactory;
4765

4866
/**
49-
* @var \Magento\Framework\View\LayoutFactory
67+
* @var LayoutFactory
5068
*/
5169
private $layoutFactory;
5270

5371
/**
54-
* @param \Magento\Backend\App\Action\Context $context
55-
* @param \Magento\Framework\Cache\FrontendInterface $attributeLabelCache
56-
* @param \Magento\Framework\Registry $coreRegistry
57-
* @param \Magento\Catalog\Model\Product\AttributeSet\BuildFactory $buildFactory
58-
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
59-
* @param \Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory $attributeFactory
60-
* @param \Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory $validatorFactory
61-
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory $groupCollectionFactory
62-
* @param \Magento\Framework\Filter\FilterManager $filterManager
63-
* @param \Magento\Catalog\Helper\Product $productHelper
64-
* @param \Magento\Framework\View\LayoutFactory $layoutFactory
72+
* @param Context $context
73+
* @param FrontendInterface $attributeLabelCache
74+
* @param Registry $coreRegistry
75+
* @param BuildFactory $buildFactory
76+
* @param PageFactory $resultPageFactory
77+
* @param AttributeFactory $attributeFactory
78+
* @param ValidatorFactory $validatorFactory
79+
* @param CollectionFactory $groupCollectionFactory
80+
* @param FilterManager $filterManager
81+
* @param Product $productHelper
82+
* @param LayoutFactory $layoutFactory
6583
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
6684
*/
6785
public function __construct(
68-
\Magento\Backend\App\Action\Context $context,
69-
\Magento\Framework\Cache\FrontendInterface $attributeLabelCache,
70-
\Magento\Framework\Registry $coreRegistry,
71-
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
72-
\Magento\Catalog\Model\Product\AttributeSet\BuildFactory $buildFactory,
73-
\Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory $attributeFactory,
74-
\Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory $validatorFactory,
75-
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory $groupCollectionFactory,
76-
\Magento\Framework\Filter\FilterManager $filterManager,
77-
\Magento\Catalog\Helper\Product $productHelper,
78-
\Magento\Framework\View\LayoutFactory $layoutFactory
86+
Context $context,
87+
FrontendInterface $attributeLabelCache,
88+
Registry $coreRegistry,
89+
PageFactory $resultPageFactory,
90+
BuildFactory $buildFactory,
91+
AttributeFactory $attributeFactory,
92+
ValidatorFactory $validatorFactory,
93+
CollectionFactory $groupCollectionFactory,
94+
FilterManager $filterManager,
95+
Product $productHelper,
96+
LayoutFactory $layoutFactory
7997
) {
8098
parent::__construct($context, $attributeLabelCache, $coreRegistry, $resultPageFactory);
8199
$this->buildFactory = $buildFactory;
@@ -88,7 +106,7 @@ public function __construct(
88106
}
89107

90108
/**
91-
* @return \Magento\Backend\Model\View\Result\Redirect
109+
* @return Redirect
92110
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
93111
* @SuppressWarnings(PHPMD.NPathComplexity)
94112
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
@@ -105,32 +123,43 @@ public function execute()
105123
$name = trim($name);
106124

107125
try {
108-
/** @var $attributeSet \Magento\Eav\Model\Entity\Attribute\Set */
126+
/** @var $attributeSet Set */
109127
$attributeSet = $this->buildFactory->create()
110128
->setEntityTypeId($this->_entityTypeId)
111129
->setSkeletonId($setId)
112130
->setName($name)
113131
->getAttributeSet();
114132
} catch (AlreadyExistsException $alreadyExists) {
115-
$this->messageManager->addError(__('An attribute set named \'%1\' already exists.', $name));
133+
$this->messageManager->addErrorMessage(__('An attribute set named \'%1\' already exists.', $name));
116134
$this->_session->setAttributeData($data);
117135
return $this->returnResult('catalog/*/edit', ['_current' => true], ['error' => true]);
118-
} catch (\Magento\Framework\Exception\LocalizedException $e) {
119-
$this->messageManager->addError($e->getMessage());
136+
} catch (LocalizedException $e) {
137+
$this->messageManager->addErrorMessage($e->getMessage());
120138
} catch (\Exception $e) {
121-
$this->messageManager->addException($e, __('Something went wrong while saving the attribute.'));
139+
$this->messageManager->addExceptionMessage(
140+
$e,
141+
__('Something went wrong while saving the attribute.')
142+
);
122143
}
123144
}
124145

125146
$attributeId = $this->getRequest()->getParam('attribute_id');
126-
$attributeCode = $this->getRequest()->getParam('attribute_code')
127-
?: $this->generateCode($this->getRequest()->getParam('frontend_label')[0]);
147+
148+
/** @var $model ProductAttributeInterface */
149+
$model = $this->attributeFactory->create();
150+
if ($attributeId) {
151+
$model->load($attributeId);
152+
}
153+
$attributeCode = $model && $model->getId()
154+
? $model->getAttributeCode()
155+
: $this->getRequest()->getParam('attribute_code');
156+
$attributeCode = $attributeCode ?: $this->generateCode($this->getRequest()->getParam('frontend_label')[0]);
128157
if (strlen($attributeCode) > 0) {
129158
$validatorAttrCode = new \Zend_Validate_Regex(
130159
['pattern' => '/^[a-z\x{600}-\x{6FF}][a-z\x{600}-\x{6FF}_0-9]{0,30}$/u']
131160
);
132161
if (!$validatorAttrCode->isValid($attributeCode)) {
133-
$this->messageManager->addError(
162+
$this->messageManager->addErrorMessage(
134163
__(
135164
'Attribute code "%1" is invalid. Please use only letters (a-z), ' .
136165
'numbers (0-9) or underscore(_) in this field, first character should be a letter.',
@@ -148,11 +177,11 @@ public function execute()
148177

149178
//validate frontend_input
150179
if (isset($data['frontend_input'])) {
151-
/** @var $inputType \Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\Validator */
180+
/** @var $inputType Validator */
152181
$inputType = $this->validatorFactory->create();
153182
if (!$inputType->isValid($data['frontend_input'])) {
154183
foreach ($inputType->getMessages() as $message) {
155-
$this->messageManager->addError($message);
184+
$this->messageManager->addErrorMessage($message);
156185
}
157186
return $this->returnResult(
158187
'catalog/*/edit',
@@ -162,18 +191,14 @@ public function execute()
162191
}
163192
}
164193

165-
/* @var $model \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
166-
$model = $this->attributeFactory->create();
167-
168194
if ($attributeId) {
169-
$model->load($attributeId);
170195
if (!$model->getId()) {
171-
$this->messageManager->addError(__('This attribute no longer exists.'));
196+
$this->messageManager->addErrorMessage(__('This attribute no longer exists.'));
172197
return $this->returnResult('catalog/*/', [], ['error' => true]);
173198
}
174199
// entity type check
175200
if ($model->getEntityTypeId() != $this->_entityTypeId) {
176-
$this->messageManager->addError(__('We can\'t update the attribute.'));
201+
$this->messageManager->addErrorMessage(__('We can\'t update the attribute.'));
177202
$this->_session->setAttributeData($data);
178203
return $this->returnResult('catalog/*/', [], ['error' => true]);
179204
}
@@ -193,7 +218,7 @@ public function execute()
193218
);
194219
}
195220

196-
$data += ['is_filterable' => 0, 'is_filterable_in_search' => 0, 'apply_to' => []];
221+
$data += ['is_filterable' => 0, 'is_filterable_in_search' => 0];
197222

198223
if ($model->getIsUserDefined() === null || $model->getIsUserDefined() != 0) {
199224
$data['backend_type'] = $model->getBackendTypeByInput($data['frontend_input']);
@@ -241,7 +266,7 @@ public function execute()
241266

242267
try {
243268
$model->save();
244-
$this->messageManager->addSuccess(__('You saved the product attribute.'));
269+
$this->messageManager->addSuccessMessage(__('You saved the product attribute.'));
245270

246271
$this->_attributeLabelCache->clean();
247272
$this->_session->setAttributeData(false);
@@ -265,7 +290,7 @@ public function execute()
265290
}
266291
return $this->returnResult('catalog/*/', [], ['error' => false]);
267292
} catch (\Exception $e) {
268-
$this->messageManager->addError($e->getMessage());
293+
$this->messageManager->addErrorMessage($e->getMessage());
269294
$this->_session->setAttributeData($data);
270295
return $this->returnResult(
271296
'catalog/*/edit',
@@ -281,7 +306,7 @@ public function execute()
281306
* @param string $path
282307
* @param array $params
283308
* @param array $response
284-
* @return \Magento\Framework\Controller\Result\Json|\Magento\Backend\Model\View\Result\Redirect
309+
* @return Json|Redirect
285310
*/
286311
private function returnResult($path = '', array $params = [], array $response = [])
287312
{

app/code/Magento/Cms/Model/Block.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
namespace Magento\Cms\Model;
77

88
use Magento\Cms\Api\Data\BlockInterface;
9-
use Magento\Cms\Model\ResourceModel\Block as ResourceCmsBlock;
109
use Magento\Framework\DataObject\IdentityInterface;
1110
use Magento\Framework\Model\AbstractModel;
1211

@@ -57,6 +56,10 @@ protected function _construct()
5756
*/
5857
public function beforeSave()
5958
{
59+
if ($this->hasDataChanges()) {
60+
$this->setUpdateTime(null);
61+
}
62+
6063
$needle = 'block_id="' . $this->getId() . '"';
6164
if (false == strstr($this->getContent(), $needle)) {
6265
return parent::beforeSave();

app/code/Magento/Cms/Model/Page.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
namespace Magento\Cms\Model;
77

88
use Magento\Cms\Api\Data\PageInterface;
9-
use Magento\Cms\Model\ResourceModel\Page as ResourceCmsPage;
9+
use Magento\Cms\Helper\Page as PageHelper;
1010
use Magento\Framework\App\Config\ScopeConfigInterface;
1111
use Magento\Framework\DataObject\IdentityInterface;
1212
use Magento\Framework\Exception\LocalizedException;
1313
use Magento\Framework\Model\AbstractModel;
14-
use Magento\Cms\Helper\Page as PageHelper;
1514

1615
/**
1716
* Cms Page Model
@@ -547,6 +546,10 @@ public function beforeSave()
547546
$originalIdentifier = $this->getOrigData('identifier');
548547
$currentIdentifier = $this->getIdentifier();
549548

549+
if ($this->hasDataChanges()) {
550+
$this->setUpdateTime(null);
551+
}
552+
550553
if (!$this->getId() || $originalIdentifier === $currentIdentifier) {
551554
return parent::beforeSave();
552555
}

app/code/Magento/Cms/Model/ResourceModel/Block.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
use Magento\Cms\Api\Data\BlockInterface;
99
use Magento\Framework\DB\Select;
10+
use Magento\Framework\EntityManager\EntityManager;
11+
use Magento\Framework\EntityManager\MetadataPool;
1012
use Magento\Framework\Exception\LocalizedException;
1113
use Magento\Framework\Model\AbstractModel;
12-
use Magento\Framework\EntityManager\MetadataPool;
13-
use Magento\Framework\EntityManager\EntityManager;
1414
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
1515
use Magento\Framework\Model\ResourceModel\Db\Context;
1616
use Magento\Store\Model\Store;

app/code/Magento/Cms/Model/ResourceModel/Page.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66

77
namespace Magento\Cms\Model\ResourceModel;
88

9+
use Magento\Cms\Api\Data\PageInterface;
910
use Magento\Cms\Model\Page as CmsPage;
1011
use Magento\Framework\DB\Select;
12+
use Magento\Framework\EntityManager\EntityManager;
13+
use Magento\Framework\EntityManager\MetadataPool;
1114
use Magento\Framework\Exception\LocalizedException;
1215
use Magento\Framework\Model\AbstractModel;
13-
use Magento\Framework\EntityManager\MetadataPool;
1416
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
1517
use Magento\Framework\Model\ResourceModel\Db\Context;
1618
use Magento\Framework\Stdlib\DateTime;
1719
use Magento\Store\Model\Store;
1820
use Magento\Store\Model\StoreManagerInterface;
19-
use Magento\Framework\EntityManager\EntityManager;
20-
use Magento\Cms\Api\Data\PageInterface;
2121

2222
/**
2323
* Cms page mysql resource

0 commit comments

Comments
 (0)