Skip to content

Commit

Permalink
Merge pull request #5302 from magento-tsg-csl3/2.4-develop-pr12
Browse files Browse the repository at this point in the history
[TSG-CSL3] For 2.4 (pr3)
  • Loading branch information
zakdma committed Feb 10, 2020
2 parents f9a487d + 43a4696 commit 90ea3f1
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 23 deletions.
1 change: 1 addition & 0 deletions app/code/Magento/Cookie/view/frontend/web/js/notices.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ define([

if ($.mage.cookies.get(this.options.cookieName)) {
this.element.hide();
$(document).trigger('user:allowed:save:cookie');
} else {
window.location.href = this.options.noCookiesUrl;
}
Expand Down
15 changes: 15 additions & 0 deletions app/code/Magento/Customer/Model/Address/Validator/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
namespace Magento\Customer\Model\Address\Validator;

use Magento\Customer\Api\AddressMetadataInterface;
use Magento\Customer\Model\Address\AbstractAddress;
use Magento\Customer\Model\Address\ValidatorInterface;

Expand Down Expand Up @@ -87,6 +88,7 @@ private function checkRequiredFields(AbstractAddress $address)
*/
private function checkOptionalFields(AbstractAddress $address)
{
$this->reloadAddressAttributes($address);
$errors = [];
if ($this->isTelephoneRequired()
&& !\Zend_Validate::is($address->getTelephone(), 'NotEmpty')
Expand Down Expand Up @@ -148,4 +150,17 @@ private function isFaxRequired()
{
return $this->eavConfig->getAttribute('customer_address', 'fax')->getIsRequired();
}

/**
* Reload address attributes for the certain store
*
* @param AbstractAddress $address
* @return void
*/
private function reloadAddressAttributes(AbstractAddress $address): void
{
$attributeSetId = $address->getAttributeSetId() ?: AddressMetadataInterface::ATTRIBUTE_SET_ID_ADDRESS;
$address->setData('attribute_set_id', $attributeSetId);
$this->eavConfig->getEntityAttributes(AddressMetadataInterface::ENTITY_TYPE_ADDRESS, $address);
}
}
28 changes: 16 additions & 12 deletions app/code/Magento/Eav/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ private function loadAttributes($entityTypeCode)
/**
* Associate object with identifier
*
* @param mixed $obj
* @param mixed $id
* @param mixed $obj
* @param mixed $id
* @return void
* @codeCoverageIgnore
*/
Expand All @@ -271,8 +271,8 @@ private function saveAttribute(AbstractAttribute $attribute, $entityTypeCode, $a
/**
* Specify reference for entity type id
*
* @param int $id
* @param string $code
* @param int $id
* @param string $code
* @return $this
* @codeCoverageIgnore
*/
Expand All @@ -296,9 +296,9 @@ protected function _getEntityTypeReference($id)
/**
* Specify reference between entity attribute id and attribute code
*
* @param int $id
* @param string $code
* @param string $entityTypeCode
* @param int $id
* @param string $code
* @param string $entityTypeCode
* @return $this
*/
protected function _addAttributeReference($id, $code, $entityTypeCode)
Expand Down Expand Up @@ -522,9 +522,9 @@ public function getAttributes($entityType)
/**
* Get attribute by code for entity type
*
* @param mixed $entityType
* @param mixed $code
* @return AbstractAttribute
* @param mixed $entityType
* @param mixed $code
* @return AbstractAttribute
* @throws LocalizedException
*/
public function getAttribute($entityType, $code)
Expand Down Expand Up @@ -737,8 +737,8 @@ public function getEntityAttributeCodes($entityType, $object = null)
/**
* Get all entity type attributes
*
* @param int|string|Type $entityType
* @param \Magento\Framework\DataObject|null $object
* @param int|string|Type $entityType
* @param \Magento\Framework\DataObject|null $object
* @return AbstractAttribute[]
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
Expand Down Expand Up @@ -822,6 +822,10 @@ protected function _createAttribute($entityType, $attributeData)
$fullAttributeData = array_key_exists('is_required', $attributeData);

if ($existsFullAttribute || (!$existsFullAttribute && !$fullAttributeData)) {
$scopeIsRequired = $attributeData['scope_is_required'] ?? null;
if ($scopeIsRequired !== null) {
$attribute->setData('scope_is_required', $scopeIsRequired);
}
return $attribute;
}
}
Expand Down
26 changes: 15 additions & 11 deletions app/code/Magento/Paypal/Model/Payflowlink.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro
*
* @var string
*/
protected $_code = \Magento\Paypal\Model\Config::METHOD_PAYFLOWLINK;
protected $_code = Config::METHOD_PAYFLOWLINK;

/**
* @var string
Expand Down Expand Up @@ -116,6 +116,11 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro
*/
private $mathRandom;

/**
* @var \Magento\Framework\App\RequestInterface
*/
private $_requestHttp;

/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
Expand Down Expand Up @@ -237,8 +242,8 @@ public function isActive($storeId = null)
public function initialize($paymentAction, $stateObject)
{
switch ($paymentAction) {
case \Magento\Paypal\Model\Config::PAYMENT_ACTION_AUTH:
case \Magento\Paypal\Model\Config::PAYMENT_ACTION_SALE:
case Config::PAYMENT_ACTION_AUTH:
case Config::PAYMENT_ACTION_SALE:
$payment = $this->getInfoInstance();
/** @var Order $order */
$order = $payment->getOrder();
Expand Down Expand Up @@ -345,6 +350,7 @@ protected function _processOrder(\Magento\Sales\Model\Order $order)
$payment->registerAuthorizationNotification($payment->getBaseAmountAuthorized());
break;
case self::TRXTYPE_SALE:
$order->setState(Order::STATE_PROCESSING);
$payment->registerCaptureNotification($payment->getBaseAmountAuthorized());
break;
default:
Expand Down Expand Up @@ -500,14 +506,12 @@ public function buildBasicRequest()
*/
protected function _getTrxTokenType()
{
switch ($this->getConfigData('payment_action')) {
case \Magento\Paypal\Model\Config::PAYMENT_ACTION_AUTH:
return self::TRXTYPE_AUTH_ONLY;
case \Magento\Paypal\Model\Config::PAYMENT_ACTION_SALE:
return self::TRXTYPE_SALE;
default:
break;
}
$tokenTypes = [
Config::PAYMENT_ACTION_AUTH => self::TRXTYPE_AUTH_ONLY,
Config::PAYMENT_ACTION_SALE => self::TRXTYPE_SALE
];

return $tokenTypes[$this->getConfigData('payment_action')] ?? '';
}

/**
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Sales/Model/Order/ProductOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function add(OrderItemInterface $orderItem): void
{
/** @var DataObject $request */
$request = $orderItem->getBuyRequest();
$request->setProductOptions($orderItem->getProductOptions());

$productType = $orderItem->getProductType();
if (isset($this->processorPool[$productType])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Customer\Model;

use Magento\Customer\Model\Metadata\AddressMetadata;
use Magento\Eav\Model\Config;
use Magento\Store\Model\StoreManagerInterface;
use Magento\TestFramework\Helper\Bootstrap;

class CustomerAddressAttributeTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Config
*/
private $config;

/**
* @var StoreManagerInterface
*/
private $storeManager;

/**
* @inheritdoc
*/
protected function setUp()
{
$objectManager = Bootstrap::getObjectManager();
$this->config = $objectManager->get(Config::class);
$this->storeManager = $objectManager->get(StoreManagerInterface::class);
}

/**
* Tests cached scope_is_required attribute value for a certain website
*
* @return void
* @magentoDataFixture Magento/Store/_files/second_website_with_two_stores.php
*/
public function testGetScopeIsRequiredAttributeValueFromCache(): void
{
$attributeCode = 'telephone';
$entityType = AddressMetadata::ENTITY_TYPE_ADDRESS;
$attribute = $this->config->getAttribute($entityType, $attributeCode);
$currentStore = $this->storeManager->getStore();
$secondWebsite = $this->storeManager->getWebsite('test');
$attribute->setWebsite($secondWebsite->getId());
$attribute->setData('scope_is_required', '0');
$attribute->save();
$this->config->getAttribute($entityType, $attributeCode);
$this->storeManager->setCurrentStore('fixture_second_store');
try {
$this->config->getEntityAttributes($attribute->getEntityTypeId(), $attribute);
$scopeAttribute = $this->config->getAttribute($entityType, $attributeCode);
$this->assertEquals(0, $scopeAttribute->getIsRequired());
} finally {
$this->storeManager->setCurrentStore($currentStore);
}
}
}

0 comments on commit 90ea3f1

Please sign in to comment.