Skip to content

Commit b3947ad

Browse files
author
Oleksii Korshenko
committed
MAGETWO-87057: [EngCom Team] Batch 5. Forwardports to 2.3-develop #1286
- Merge Pull Request magento-engcom/magento2ce#1286 from magento-engcom-team/magento2:batch-5-forwardport-2.3-develop - Merged commits: 1. b529c16 2. c25b34e 3. 0742a0b 4. 45f4535 5. 6c1e5be 6. d9eec50 7. 34b8ad8 8. 2c96f79 9. 0a03029 10. fc38208 11. edc9ae2 12. 8052842 13. 9067b19 14. 660a0a1 15. 612bfbb 16. 523aabe 17. 5600c82 18. e5cb3c1 19. 097b701 20. 6c7aee0 21. 0fffced
2 parents 8e77e2f + 0fffced commit b3947ad

File tree

20 files changed

+274
-53
lines changed

20 files changed

+274
-53
lines changed

app/code/Magento/Catalog/Model/Product/Attribute/OptionManagement.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ public function getItems($attributeCode)
4040
*/
4141
public function add($attributeCode, $option)
4242
{
43+
/** @var \Magento\Eav\Api\Data\AttributeOptionInterface[] $currentOptions */
44+
$currentOptions = $this->getItems($attributeCode);
45+
if (is_array($currentOptions)) {
46+
array_walk($currentOptions, function (&$attributeOption) {
47+
/** @var \Magento\Eav\Api\Data\AttributeOptionInterface $attributeOption */
48+
$attributeOption = $attributeOption->getLabel();
49+
});
50+
if (in_array($option->getLabel(), $currentOptions)) {
51+
return false;
52+
}
53+
}
4354
return $this->eavOptionManagement->add(
4455
\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE,
4556
$attributeCode,

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/js.phtml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,11 @@ function switchDefaultValueField()
196196

197197
<?php foreach ($this->helper('Magento\Catalog\Helper\Data')->getAttributeHiddenFields() as $type => $fields): ?>
198198
case '<?= /* @escapeNotVerified */ $type ?>':
199+
var isFrontTabHidden = false;
199200
<?php foreach ($fields as $one): ?>
200201
<?php if ($one == '_front_fieldset'): ?>
201202
getFrontTab().hide();
203+
isFrontTabHidden = true;
202204
<?php elseif ($one == '_default_value'): ?>
203205
defaultValueTextVisibility =
204206
defaultValueTextareaVisibility =
@@ -210,6 +212,10 @@ function switchDefaultValueField()
210212
setRowVisibility('<?= /* @escapeNotVerified */ $one ?>', false);
211213
<?php endif; ?>
212214
<?php endforeach; ?>
215+
216+
if (!isFrontTabHidden){
217+
getFrontTab().show();
218+
}
213219
break;
214220
<?php endforeach; ?>
215221

app/code/Magento/Customer/etc/adminhtml/system.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@
198198
<field id="street_lines" translate="label comment" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
199199
<label>Number of Lines in a Street Address</label>
200200
<backend_model>Magento\Customer\Model\Config\Backend\Address\Street</backend_model>
201-
<comment>Leave empty for default (2). Valid range: 1-4</comment>
201+
<comment>Valid range: 1-4</comment>
202+
<validate>required-entry validate-digits validate-digits-range digits-range-1-4</validate>
202203
</field>
203204
<field id="prefix_show" translate="label comment" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0">
204205
<label>Show Prefix</label>

app/code/Magento/Eav/Model/Entity/Attribute/Backend/JsonEncoded.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function afterLoad($object)
5858
{
5959
parent::afterLoad($object);
6060
$attrCode = $this->getAttribute()->getAttributeCode();
61-
$object->setData($attrCode, $this->jsonSerializer->unserialize($object->getData($attrCode)));
61+
$object->setData($attrCode, $this->jsonSerializer->unserialize($object->getData($attrCode) ?: '{}'));
6262
return $this;
6363
}
6464
}

app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Backend/JsonEncodedTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,18 @@ public function testAfterLoad()
9595
$this->model->afterLoad($product);
9696
$this->assertEquals([1, 2, 3], $product->getData('json_encoded'));
9797
}
98+
99+
/**
100+
* Test after load handler with null attribute value
101+
*/
102+
public function testAfterLoadWithNullAttributeValue()
103+
{
104+
$product = new \Magento\Framework\DataObject(
105+
[
106+
'json_encoded' => null
107+
]
108+
);
109+
$this->model->afterLoad($product);
110+
$this->assertEquals([], $product->getData('json_encoded'));
111+
}
98112
}

app/code/Magento/Newsletter/Model/Subscriber.php

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ class Subscriber extends \Magento\Framework\Model\AbstractModel
9494
*/
9595
protected $_customerSession;
9696

97+
/**
98+
* Date
99+
* @var \Magento\Framework\Stdlib\DateTime\DateTime
100+
*/
101+
private $dateTime;
102+
97103
/**
98104
* Store manager
99105
*
@@ -134,9 +140,10 @@ class Subscriber extends \Magento\Framework\Model\AbstractModel
134140
* @param CustomerRepositoryInterface $customerRepository
135141
* @param AccountManagementInterface $customerAccountManagement
136142
* @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation
137-
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
138-
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
143+
* @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
144+
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
139145
* @param array $data
146+
* @param \Magento\Framework\Stdlib\DateTime\DateTime|null $dateTime
140147
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
141148
*/
142149
public function __construct(
@@ -152,13 +159,17 @@ public function __construct(
152159
\Magento\Framework\Translate\Inline\StateInterface $inlineTranslation,
153160
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
154161
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
155-
array $data = []
162+
array $data = [],
163+
\Magento\Framework\Stdlib\DateTime\DateTime $dateTime = null
156164
) {
157165
$this->_newsletterData = $newsletterData;
158166
$this->_scopeConfig = $scopeConfig;
159167
$this->_transportBuilder = $transportBuilder;
160168
$this->_storeManager = $storeManager;
161169
$this->_customerSession = $customerSession;
170+
$this->dateTime = $dateTime ?: \Magento\Framework\App\ObjectManager::getInstance()->get(
171+
\Magento\Framework\Stdlib\DateTime\DateTime::class
172+
);
162173
$this->customerRepository = $customerRepository;
163174
$this->customerAccountManagement = $customerAccountManagement;
164175
$this->inlineTranslation = $inlineTranslation;
@@ -812,4 +823,18 @@ public function getSubscriberFullName()
812823
}
813824
return $name;
814825
}
826+
827+
/**
828+
* Set date of last changed status
829+
*
830+
* @return $this
831+
*/
832+
public function beforeSave()
833+
{
834+
parent::beforeSave();
835+
if ($this->dataHasChangedFor('subscriber_status')) {
836+
$this->setChangeStatusAt($this->dateTime->gmtDate());
837+
}
838+
return $this;
839+
}
815840
}

app/code/Magento/Quote/Model/Quote.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ public function addCustomerAddress(\Magento\Customer\Api\Data\AddressInterface $
10461046
public function updateCustomerData(\Magento\Customer\Api\Data\CustomerInterface $customer)
10471047
{
10481048
$quoteCustomer = $this->getCustomer();
1049-
$this->dataObjectHelper->mergeDataObjects(get_class($quoteCustomer), $quoteCustomer, $customer);
1049+
$this->dataObjectHelper->mergeDataObjects(CustomerInterface::class, $quoteCustomer, $customer);
10501050
$this->setCustomer($quoteCustomer);
10511051
return $this;
10521052
}

app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected function _construct()
101101
*/
102102
public function getStoreId()
103103
{
104-
return (int)$this->_quote->getStoreId();
104+
return (int)$this->_productCollectionFactory->create()->getStoreId();
105105
}
106106

107107
/**

app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ define([
182182
useProductImageForSwatch = false,
183183
defaultValueUpdateImage = false,
184184
optionDefaultInputType = '',
185+
isFrontTabHidden = false,
185186
thing = this;
186187

187188
if (!this.frontendInput.length) {
@@ -247,6 +248,7 @@ define([
247248
switch (option) {
248249
case '_front_fieldset':
249250
thing.tabsFront.hide();
251+
isFrontTabHidden = true;
250252
break;
251253

252254
case '_default_value':
@@ -263,6 +265,11 @@ define([
263265
thing.setRowVisibility($('#' + option), false);
264266
}
265267
});
268+
269+
if (!isFrontTabHidden) {
270+
thing.tabsFront.show();
271+
}
272+
266273
} else {
267274
this.tabsFront.show();
268275
this.showDefaultRows();

app/code/Magento/Ui/Controller/Adminhtml/Index/Render.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ private function validateAclResource($dataProviderConfigData)
7979
{
8080
if (isset($dataProviderConfigData['aclResource'])) {
8181
if (!$this->_authorization->isAllowed($dataProviderConfigData['aclResource'])) {
82-
$this->_redirect('admin/denied');
82+
if (!$this->_request->isAjax()) {
83+
$this->_redirect('admin/denied');
84+
}
85+
8386
return false;
8487
}
8588
}

0 commit comments

Comments
 (0)