Skip to content

Commit 90ea3f1

Browse files
authored
Merge pull request #5302 from magento-tsg-csl3/2.4-develop-pr12
[TSG-CSL3] For 2.4 (pr3)
2 parents f9a487d + 43a4696 commit 90ea3f1

File tree

6 files changed

+111
-23
lines changed

6 files changed

+111
-23
lines changed

app/code/Magento/Cookie/view/frontend/web/js/notices.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ define([
3030

3131
if ($.mage.cookies.get(this.options.cookieName)) {
3232
this.element.hide();
33+
$(document).trigger('user:allowed:save:cookie');
3334
} else {
3435
window.location.href = this.options.noCookiesUrl;
3536
}

app/code/Magento/Customer/Model/Address/Validator/General.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Customer\Model\Address\Validator;
77

8+
use Magento\Customer\Api\AddressMetadataInterface;
89
use Magento\Customer\Model\Address\AbstractAddress;
910
use Magento\Customer\Model\Address\ValidatorInterface;
1011

@@ -87,6 +88,7 @@ private function checkRequiredFields(AbstractAddress $address)
8788
*/
8889
private function checkOptionalFields(AbstractAddress $address)
8990
{
91+
$this->reloadAddressAttributes($address);
9092
$errors = [];
9193
if ($this->isTelephoneRequired()
9294
&& !\Zend_Validate::is($address->getTelephone(), 'NotEmpty')
@@ -148,4 +150,17 @@ private function isFaxRequired()
148150
{
149151
return $this->eavConfig->getAttribute('customer_address', 'fax')->getIsRequired();
150152
}
153+
154+
/**
155+
* Reload address attributes for the certain store
156+
*
157+
* @param AbstractAddress $address
158+
* @return void
159+
*/
160+
private function reloadAddressAttributes(AbstractAddress $address): void
161+
{
162+
$attributeSetId = $address->getAttributeSetId() ?: AddressMetadataInterface::ATTRIBUTE_SET_ID_ADDRESS;
163+
$address->setData('attribute_set_id', $attributeSetId);
164+
$this->eavConfig->getEntityAttributes(AddressMetadataInterface::ENTITY_TYPE_ADDRESS, $address);
165+
}
151166
}

app/code/Magento/Eav/Model/Config.php

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ private function loadAttributes($entityTypeCode)
245245
/**
246246
* Associate object with identifier
247247
*
248-
* @param mixed $obj
249-
* @param mixed $id
248+
* @param mixed $obj
249+
* @param mixed $id
250250
* @return void
251251
* @codeCoverageIgnore
252252
*/
@@ -271,8 +271,8 @@ private function saveAttribute(AbstractAttribute $attribute, $entityTypeCode, $a
271271
/**
272272
* Specify reference for entity type id
273273
*
274-
* @param int $id
275-
* @param string $code
274+
* @param int $id
275+
* @param string $code
276276
* @return $this
277277
* @codeCoverageIgnore
278278
*/
@@ -296,9 +296,9 @@ protected function _getEntityTypeReference($id)
296296
/**
297297
* Specify reference between entity attribute id and attribute code
298298
*
299-
* @param int $id
300-
* @param string $code
301-
* @param string $entityTypeCode
299+
* @param int $id
300+
* @param string $code
301+
* @param string $entityTypeCode
302302
* @return $this
303303
*/
304304
protected function _addAttributeReference($id, $code, $entityTypeCode)
@@ -522,9 +522,9 @@ public function getAttributes($entityType)
522522
/**
523523
* Get attribute by code for entity type
524524
*
525-
* @param mixed $entityType
526-
* @param mixed $code
527-
* @return AbstractAttribute
525+
* @param mixed $entityType
526+
* @param mixed $code
527+
* @return AbstractAttribute
528528
* @throws LocalizedException
529529
*/
530530
public function getAttribute($entityType, $code)
@@ -737,8 +737,8 @@ public function getEntityAttributeCodes($entityType, $object = null)
737737
/**
738738
* Get all entity type attributes
739739
*
740-
* @param int|string|Type $entityType
741-
* @param \Magento\Framework\DataObject|null $object
740+
* @param int|string|Type $entityType
741+
* @param \Magento\Framework\DataObject|null $object
742742
* @return AbstractAttribute[]
743743
*
744744
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
@@ -822,6 +822,10 @@ protected function _createAttribute($entityType, $attributeData)
822822
$fullAttributeData = array_key_exists('is_required', $attributeData);
823823

824824
if ($existsFullAttribute || (!$existsFullAttribute && !$fullAttributeData)) {
825+
$scopeIsRequired = $attributeData['scope_is_required'] ?? null;
826+
if ($scopeIsRequired !== null) {
827+
$attribute->setData('scope_is_required', $scopeIsRequired);
828+
}
825829
return $attribute;
826830
}
827831
}

app/code/Magento/Paypal/Model/Payflowlink.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro
3636
*
3737
* @var string
3838
*/
39-
protected $_code = \Magento\Paypal\Model\Config::METHOD_PAYFLOWLINK;
39+
protected $_code = Config::METHOD_PAYFLOWLINK;
4040

4141
/**
4242
* @var string
@@ -116,6 +116,11 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro
116116
*/
117117
private $mathRandom;
118118

119+
/**
120+
* @var \Magento\Framework\App\RequestInterface
121+
*/
122+
private $_requestHttp;
123+
119124
/**
120125
* @param \Magento\Framework\Model\Context $context
121126
* @param \Magento\Framework\Registry $registry
@@ -237,8 +242,8 @@ public function isActive($storeId = null)
237242
public function initialize($paymentAction, $stateObject)
238243
{
239244
switch ($paymentAction) {
240-
case \Magento\Paypal\Model\Config::PAYMENT_ACTION_AUTH:
241-
case \Magento\Paypal\Model\Config::PAYMENT_ACTION_SALE:
245+
case Config::PAYMENT_ACTION_AUTH:
246+
case Config::PAYMENT_ACTION_SALE:
242247
$payment = $this->getInfoInstance();
243248
/** @var Order $order */
244249
$order = $payment->getOrder();
@@ -345,6 +350,7 @@ protected function _processOrder(\Magento\Sales\Model\Order $order)
345350
$payment->registerAuthorizationNotification($payment->getBaseAmountAuthorized());
346351
break;
347352
case self::TRXTYPE_SALE:
353+
$order->setState(Order::STATE_PROCESSING);
348354
$payment->registerCaptureNotification($payment->getBaseAmountAuthorized());
349355
break;
350356
default:
@@ -500,14 +506,12 @@ public function buildBasicRequest()
500506
*/
501507
protected function _getTrxTokenType()
502508
{
503-
switch ($this->getConfigData('payment_action')) {
504-
case \Magento\Paypal\Model\Config::PAYMENT_ACTION_AUTH:
505-
return self::TRXTYPE_AUTH_ONLY;
506-
case \Magento\Paypal\Model\Config::PAYMENT_ACTION_SALE:
507-
return self::TRXTYPE_SALE;
508-
default:
509-
break;
510-
}
509+
$tokenTypes = [
510+
Config::PAYMENT_ACTION_AUTH => self::TRXTYPE_AUTH_ONLY,
511+
Config::PAYMENT_ACTION_SALE => self::TRXTYPE_SALE
512+
];
513+
514+
return $tokenTypes[$this->getConfigData('payment_action')] ?? '';
511515
}
512516

513517
/**

app/code/Magento/Sales/Model/Order/ProductOption.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public function add(OrderItemInterface $orderItem): void
5959
{
6060
/** @var DataObject $request */
6161
$request = $orderItem->getBuyRequest();
62+
$request->setProductOptions($orderItem->getProductOptions());
6263

6364
$productType = $orderItem->getProductType();
6465
if (isset($this->processorPool[$productType])
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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\Customer\Model;
9+
10+
use Magento\Customer\Model\Metadata\AddressMetadata;
11+
use Magento\Eav\Model\Config;
12+
use Magento\Store\Model\StoreManagerInterface;
13+
use Magento\TestFramework\Helper\Bootstrap;
14+
15+
class CustomerAddressAttributeTest extends \PHPUnit\Framework\TestCase
16+
{
17+
/**
18+
* @var Config
19+
*/
20+
private $config;
21+
22+
/**
23+
* @var StoreManagerInterface
24+
*/
25+
private $storeManager;
26+
27+
/**
28+
* @inheritdoc
29+
*/
30+
protected function setUp()
31+
{
32+
$objectManager = Bootstrap::getObjectManager();
33+
$this->config = $objectManager->get(Config::class);
34+
$this->storeManager = $objectManager->get(StoreManagerInterface::class);
35+
}
36+
37+
/**
38+
* Tests cached scope_is_required attribute value for a certain website
39+
*
40+
* @return void
41+
* @magentoDataFixture Magento/Store/_files/second_website_with_two_stores.php
42+
*/
43+
public function testGetScopeIsRequiredAttributeValueFromCache(): void
44+
{
45+
$attributeCode = 'telephone';
46+
$entityType = AddressMetadata::ENTITY_TYPE_ADDRESS;
47+
$attribute = $this->config->getAttribute($entityType, $attributeCode);
48+
$currentStore = $this->storeManager->getStore();
49+
$secondWebsite = $this->storeManager->getWebsite('test');
50+
$attribute->setWebsite($secondWebsite->getId());
51+
$attribute->setData('scope_is_required', '0');
52+
$attribute->save();
53+
$this->config->getAttribute($entityType, $attributeCode);
54+
$this->storeManager->setCurrentStore('fixture_second_store');
55+
try {
56+
$this->config->getEntityAttributes($attribute->getEntityTypeId(), $attribute);
57+
$scopeAttribute = $this->config->getAttribute($entityType, $attributeCode);
58+
$this->assertEquals(0, $scopeAttribute->getIsRequired());
59+
} finally {
60+
$this->storeManager->setCurrentStore($currentStore);
61+
}
62+
}
63+
}

0 commit comments

Comments
 (0)