Skip to content

Commit 1a826a5

Browse files
committed
Merge branch 'MC-22994' into 2.3-develop-com-pr22
2 parents f8a5eb1 + faf9c0a commit 1a826a5

File tree

52 files changed

+1538
-414
lines changed

Some content is hidden

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

52 files changed

+1538
-414
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.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.

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Magento\Catalog\Api\Data\ProductInterface;
1111
use Magento\Catalog\Api\ProductLinkRepositoryInterface;
1212
use Magento\Catalog\Model\Product\Attribute\Backend\Media\EntryConverterPool;
13-
use Magento\Catalog\Model\FilterProductCustomAttribute;
1413
use Magento\Framework\Api\AttributeValueFactory;
1514
use Magento\Framework\App\Filesystem\DirectoryList;
1615
use Magento\Framework\App\ObjectManager;
@@ -973,6 +972,17 @@ public function afterSave()
973972
return $result;
974973
}
975974

975+
/**
976+
* @inheritDoc
977+
*/
978+
public function getCacheTags()
979+
{
980+
$identities = $this->getIdentities();
981+
$cacheTags = !empty($identities) ? (array) $identities : parent::getCacheTags();
982+
983+
return $cacheTags;
984+
}
985+
976986
/**
977987
* Set quantity for product
978988
*
@@ -2162,6 +2172,7 @@ public function reset()
21622172
*/
21632173
public function getCacheIdTags()
21642174
{
2175+
// phpstan:ignore "Call to an undefined static method"
21652176
$tags = parent::getCacheIdTags();
21662177
$affectedCategoryIds = $this->getAffectedCategoryIds();
21672178
if (!$affectedCategoryIds) {
@@ -2342,6 +2353,8 @@ public function isDisabled()
23422353
public function getImage()
23432354
{
23442355
$this->getTypeInstance()->setImageFromChildProduct($this);
2356+
2357+
// phpstan:ignore "Call to an undefined static method"
23452358
return parent::getImage();
23462359
}
23472360

@@ -2405,6 +2418,8 @@ public function reloadPriceInfo()
24052418
}
24062419
}
24072420

2421+
//phpcs:disable PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.MethodDoubleUnderscore
2422+
24082423
/**
24092424
* Return Data Object data in array format.
24102425
*
@@ -2432,6 +2447,8 @@ public function __toArray()
24322447
return $data;
24332448
}
24342449

2450+
//phpcs:enable PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.MethodDoubleUnderscore
2451+
24352452
/**
24362453
* Convert Category model into flat array.
24372454
*
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/Mftf/Metadata/product_attribute_set-meta.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<field key="attributeCode">string</field>
1616
<field key="sortOrder">integer</field>
1717
</operation>
18-
<operation name="DeleteProductAttributeFromAttributeSet" dataType="ProductAttributeSet" type="delete" auth="adminOauth" url="/V1/products/attribute-sets/{attribute_set_id}/attributes/{attribute_code}" method="DELETE">
18+
<operation name="DeleteProductAttributeFromAttributeSet" dataType="ProductAttributeSet" type="delete" auth="adminOauth" url="/V1/products/attribute-sets/{attributeSetId}/attributes/{attributeCode}" method="DELETE">
1919
<contentType>application/json</contentType>
2020
</operation>
2121
<operation name="GetProductAttributesFromDefaultSet" dataType="ProductAttributesFromDefaultSet" type="get" auth="adminOauth" url="/V1/products/attribute-sets/4/attributes" method="GET">

0 commit comments

Comments
 (0)