Skip to content

Commit ab94eea

Browse files
committed
Merge remote-tracking branch 'origin/2.3-develop' into 2.3-develop-pr141
2 parents ebbfd32 + e45a5d6 commit ab94eea

File tree

160 files changed

+5399
-1347
lines changed

Some content is hidden

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

160 files changed

+5399
-1347
lines changed

app/code/Magento/Braintree/Plugin/DisableQuoteAddressValidation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
namespace Magento\Braintree\Plugin;
99

1010
use Magento\Quote\Model\QuoteManagement;
11-
use Magento\Quote\Api\CartManagementInterface;
1211
use Magento\Quote\Model\Quote;
1312

1413
/**
@@ -36,7 +35,8 @@ public function beforeSubmit(
3635
$orderData = []
3736
) {
3837
if ($quote->getPayment()->getMethod() == 'braintree_paypal' &&
39-
$quote->getCheckoutMethod() == CartManagementInterface::METHOD_GUEST) {
38+
(!$quote->getCustomer() || !$quote->getCustomer()->getAddresses())
39+
) {
4040
$billingAddress = $quote->getBillingAddress();
4141
$billingAddress->setShouldIgnoreValidation(true);
4242
$quote->setBillingAddress($billingAddress);
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Braintree\Test\Unit\Plugin;
9+
10+
use Magento\Braintree\Plugin\DisableQuoteAddressValidation;
11+
use Magento\Customer\Api\Data\CustomerInterface;
12+
use Magento\Quote\Model\Quote;
13+
use Magento\Quote\Model\Quote\Address;
14+
use Magento\Quote\Model\Quote\Payment;
15+
use Magento\Quote\Model\QuoteManagement;
16+
use PHPUnit\Framework\TestCase;
17+
18+
class DisableQuoteAddressValidationTest extends TestCase
19+
{
20+
/**
21+
* @var DisableQuoteAddressValidation
22+
*/
23+
private $model;
24+
25+
/**
26+
* @inheritDoc
27+
*/
28+
protected function setUp()
29+
{
30+
parent::setUp();
31+
$this->model = new DisableQuoteAddressValidation();
32+
}
33+
34+
/**
35+
* @param string $paymentMethod
36+
* @param bool $isGuest
37+
* @param array $addresses
38+
* @param bool $skipValidation
39+
* @throws \Magento\Framework\Exception\LocalizedException
40+
* @dataProvider beforeSubmitDataProvider
41+
*/
42+
public function testBeforeSubmit(
43+
string $paymentMethod,
44+
bool $isGuest,
45+
array $addresses,
46+
bool $skipValidation
47+
) {
48+
$subject = $this->createMock(QuoteManagement::class);
49+
$quote = $this->createMock(Quote::class);
50+
$payment = $this->createMock(Payment::class);
51+
$customer = $this->createMock(CustomerInterface::class);
52+
$billingAddress = $this->createPartialMock(Address::class, ['setShouldIgnoreValidation']);
53+
$quote->method('getPayment')->willReturn($payment);
54+
$quote->method('getCustomer')->willReturn($isGuest ? null : $customer);
55+
$quote->method('getBillingAddress')->willReturn($billingAddress);
56+
$customer->method('getAddresses')->willReturn($addresses);
57+
$payment->method('getMethod')->willReturn($paymentMethod);
58+
$billingAddress->expects($skipValidation ? $this->once() : $this->never())
59+
->method('setShouldIgnoreValidation')
60+
->with(true);
61+
$this->model->beforeSubmit($subject, $quote, []);
62+
}
63+
64+
/**
65+
* @return array
66+
*/
67+
public function beforeSubmitDataProvider(): array
68+
{
69+
return [
70+
['braintree_paypal', true, [] ,true],
71+
['braintree_paypal', false, [], true],
72+
['braintree_paypal', false, [[]], false],
73+
['payflowpro', true, [] ,false],
74+
['payflowpro', false, [], false],
75+
['payflowpro', false, [[]], false],
76+
];
77+
}
78+
}

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

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,27 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\Catalog\Controller\Adminhtml\Product\Attribute;
89

10+
use Magento\Backend\App\Action\Context;
911
use Magento\Catalog\Controller\Adminhtml\Product\Attribute as AttributeAction;
12+
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
13+
use Magento\Eav\Model\Entity\Attribute\Set;
1014
use Magento\Eav\Model\Validator\Attribute\Code as AttributeCodeValidator;
1115
use Magento\Framework\App\Action\HttpGetActionInterface;
1216
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
1317
use Magento\Framework\App\ObjectManager;
18+
use Magento\Framework\Cache\FrontendInterface;
19+
use Magento\Framework\Controller\Result\JsonFactory;
20+
use Magento\Framework\Controller\ResultInterface;
1421
use Magento\Framework\DataObject;
1522
use Magento\Framework\Escaper;
23+
use Magento\Framework\Registry;
1624
use Magento\Framework\Serialize\Serializer\FormData;
25+
use Magento\Framework\View\LayoutFactory;
26+
use Magento\Framework\View\Result\PageFactory;
1727

1828
/**
1929
* Product attribute validate controller.
@@ -25,12 +35,12 @@ class Validate extends AttributeAction implements HttpGetActionInterface, HttpPo
2535
const DEFAULT_MESSAGE_KEY = 'message';
2636

2737
/**
28-
* @var \Magento\Framework\Controller\Result\JsonFactory
38+
* @var JsonFactory
2939
*/
3040
protected $resultJsonFactory;
3141

3242
/**
33-
* @var \Magento\Framework\View\LayoutFactory
43+
* @var LayoutFactory
3444
*/
3545
protected $layoutFactory;
3646

@@ -57,25 +67,25 @@ class Validate extends AttributeAction implements HttpGetActionInterface, HttpPo
5767
/**
5868
* Constructor
5969
*
60-
* @param \Magento\Backend\App\Action\Context $context
61-
* @param \Magento\Framework\Cache\FrontendInterface $attributeLabelCache
62-
* @param \Magento\Framework\Registry $coreRegistry
63-
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
64-
* @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
65-
* @param \Magento\Framework\View\LayoutFactory $layoutFactory
70+
* @param Context $context
71+
* @param FrontendInterface $attributeLabelCache
72+
* @param Registry $coreRegistry
73+
* @param PageFactory $resultPageFactory
74+
* @param JsonFactory $resultJsonFactory
75+
* @param LayoutFactory $layoutFactory
6676
* @param array $multipleAttributeList
6777
* @param FormData|null $formDataSerializer
6878
* @param AttributeCodeValidator|null $attributeCodeValidator
6979
* @param Escaper $escaper
7080
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
7181
*/
7282
public function __construct(
73-
\Magento\Backend\App\Action\Context $context,
74-
\Magento\Framework\Cache\FrontendInterface $attributeLabelCache,
75-
\Magento\Framework\Registry $coreRegistry,
76-
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
77-
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
78-
\Magento\Framework\View\LayoutFactory $layoutFactory,
83+
Context $context,
84+
FrontendInterface $attributeLabelCache,
85+
Registry $coreRegistry,
86+
PageFactory $resultPageFactory,
87+
JsonFactory $resultJsonFactory,
88+
LayoutFactory $layoutFactory,
7989
array $multipleAttributeList = [],
8090
FormData $formDataSerializer = null,
8191
AttributeCodeValidator $attributeCodeValidator = null,
@@ -96,7 +106,7 @@ public function __construct(
96106
/**
97107
* @inheritdoc
98108
*
99-
* @return \Magento\Framework\Controller\ResultInterface
109+
* @return ResultInterface
100110
* @SuppressWarnings(PHPMD.NPathComplexity)
101111
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
102112
*/
@@ -118,14 +128,22 @@ public function execute()
118128

119129
$attributeCode = $this->getRequest()->getParam('attribute_code');
120130
$frontendLabel = $this->getRequest()->getParam('frontend_label');
121-
$attributeCode = $attributeCode ?: $this->generateCode($frontendLabel[0]);
122131
$attributeId = $this->getRequest()->getParam('attribute_id');
123-
$attribute = $this->_objectManager->create(
124-
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
125-
)->loadByCode(
126-
$this->_entityTypeId,
127-
$attributeCode
128-
);
132+
133+
if ($attributeId) {
134+
$attribute = $this->_objectManager->create(
135+
Attribute::class
136+
)->load($attributeId);
137+
$attributeCode = $attribute->getAttributeCode();
138+
} else {
139+
$attributeCode = $attributeCode ?: $this->generateCode($frontendLabel[0]);
140+
$attribute = $this->_objectManager->create(
141+
Attribute::class
142+
)->loadByCode(
143+
$this->_entityTypeId,
144+
$attributeCode
145+
);
146+
}
129147

130148
if ($attribute->getId() && !$attributeId || $attributeCode === 'product_type' || $attributeCode === 'type_id') {
131149
$message = strlen($this->getRequest()->getParam('attribute_code'))
@@ -145,8 +163,8 @@ public function execute()
145163

146164
if ($this->getRequest()->has('new_attribute_set_name')) {
147165
$setName = $this->getRequest()->getParam('new_attribute_set_name');
148-
/** @var $attributeSet \Magento\Eav\Model\Entity\Attribute\Set */
149-
$attributeSet = $this->_objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class);
166+
/** @var $attributeSet Set */
167+
$attributeSet = $this->_objectManager->create(Set::class);
150168
$attributeSet->setEntityTypeId($this->_entityTypeId)->load($setName, 'attribute_set_name');
151169
if ($attributeSet->getId()) {
152170
$setName = $this->escaper->escapeHtml($setName);
@@ -252,7 +270,7 @@ private function checkUniqueOption(DataObject $response, array $options = null)
252270
private function checkEmptyOption(DataObject $response, array $optionsForCheck = null)
253271
{
254272
foreach ($optionsForCheck as $optionValues) {
255-
if (isset($optionValues[0]) && trim($optionValues[0]) == '') {
273+
if (isset($optionValues[0]) && trim((string)$optionValues[0]) == '') {
256274
$this->setMessageToResponse($response, [__("The value of Admin scope can't be empty.")]);
257275
$response->setError(true);
258276
}

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements
8787
*
8888
* @var string
8989
*/
90-
protected $_cacheTag = self::CACHE_TAG;
90+
protected $_cacheTag = false;
9191

9292
/**
9393
* URL Model instance
@@ -1109,6 +1109,17 @@ public function afterSave()
11091109
return $result;
11101110
}
11111111

1112+
/**
1113+
* @inheritDoc
1114+
*/
1115+
public function getCacheTags()
1116+
{
1117+
$identities = $this->getIdentities();
1118+
$cacheTags = !empty($identities) ? (array) $identities : parent::getCacheTags();
1119+
1120+
return $cacheTags;
1121+
}
1122+
11121123
/**
11131124
* Init indexing process after category save
11141125
*

app/code/Magento/Catalog/Model/Category/Attribute/Backend/Sortby.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ public function beforeSave($object)
102102
}
103103
$object->setData($attributeCode, implode(',', $data) ?: null);
104104
}
105+
if ($attributeCode == 'default_sort_by') {
106+
$data = $object->getData($attributeCode);
107+
$attributeValue = is_array($data) ? reset($data) :
108+
(!empty($data)) ? $data : null;
109+
$object->setData($attributeCode, $attributeValue);
110+
}
105111
if (!$object->hasData($attributeCode)) {
106112
$object->setData($attributeCode, null);
107113
}

app/code/Magento/Catalog/Model/Plugin/DefaultSortByUpdateCategorySavePlugin.php

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)