Skip to content

Commit 2187b8b

Browse files
committed
Merge branch '2.3-develop' of https://github.com/magento/magento2ce into MC-35149
2 parents b6b377b + a620729 commit 2187b8b

File tree

38 files changed

+824
-350
lines changed

38 files changed

+824
-350
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/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.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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\Catalog\Model;
9+
10+
use Magento\Catalog\Api\ProductRepositoryInterface;
11+
use Magento\Framework\App\RequestInterface;
12+
use Magento\Framework\Exception\NoSuchEntityException;
13+
use Magento\PageCache\Model\Spi\PageCacheTagsPreprocessorInterface;
14+
use Magento\Store\Model\StoreManagerInterface;
15+
16+
/**
17+
* Add product identities to "noroute" page
18+
*
19+
* Ensure that "noroute" page has necessary product tags
20+
* so it can be invalidated once the product becomes visible again
21+
*/
22+
class ProductNotFoundPageCacheTags implements PageCacheTagsPreprocessorInterface
23+
{
24+
private const NOROUTE_ACTION_NAME = 'cms_noroute_index';
25+
/**
26+
* @var ProductRepositoryInterface
27+
*/
28+
private $productRepository;
29+
/**
30+
* @var StoreManagerInterface
31+
*/
32+
private $storeManager;
33+
/**
34+
* @var RequestInterface
35+
*/
36+
private $request;
37+
38+
/**
39+
* @param RequestInterface $request
40+
* @param ProductRepositoryInterface $productRepository
41+
* @param StoreManagerInterface $storeManager
42+
*/
43+
public function __construct(
44+
RequestInterface $request,
45+
ProductRepositoryInterface $productRepository,
46+
StoreManagerInterface $storeManager
47+
) {
48+
$this->productRepository = $productRepository;
49+
$this->storeManager = $storeManager;
50+
$this->request = $request;
51+
}
52+
53+
/**
54+
* @inheritDoc
55+
*/
56+
public function process(array $tags): array
57+
{
58+
if ($this->request->getFullActionName() === self::NOROUTE_ACTION_NAME) {
59+
try {
60+
$productId = (int) $this->request->getParam('id');
61+
$product = $this->productRepository->getById(
62+
$productId,
63+
false,
64+
$this->storeManager->getStore()->getId()
65+
);
66+
} catch (NoSuchEntityException $e) {
67+
$product = null;
68+
}
69+
if ($product) {
70+
$tags = array_merge($tags, $product->getIdentities());
71+
}
72+
}
73+
return $tags;
74+
}
75+
}

app/code/Magento/Catalog/Test/Unit/Model/Plugin/DefaultSortByUpdateCategorySavePluginTest.php

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

app/code/Magento/Catalog/etc/di.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,4 @@
13321332
</argument>
13331333
</arguments>
13341334
</type>
1335-
<type name="Magento\Catalog\Api\CategoryRepositoryInterface">
1336-
<plugin name="DefaultSortByUpdateCategorySavePlugin" type="Magento\Catalog\Model\Plugin\DefaultSortByUpdateCategorySavePlugin"/>
1337-
</type>
13381335
</config>

app/code/Magento/Catalog/etc/frontend/di.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,13 @@
115115
<plugin name="catalog_app_action_dispatch_controller_context_plugin"
116116
type="Magento\Catalog\Plugin\Framework\App\Action\ContextPlugin" />
117117
</type>
118+
<type name="\Magento\PageCache\Model\PageCacheTagsPreprocessorComposite">
119+
<arguments>
120+
<argument name="preprocessors" xsi:type="array">
121+
<item name="catalog_product_view" xsi:type="array">
122+
<item name="product_not_found" xsi:type="object">Magento\Catalog\Model\ProductNotFoundPageCacheTags</item>
123+
</item>
124+
</argument>
125+
</arguments>
126+
</type>
118127
</config>

0 commit comments

Comments
 (0)