diff --git a/app/code/Magento/Cookie/view/frontend/web/js/notices.js b/app/code/Magento/Cookie/view/frontend/web/js/notices.js index 2c4a070130804..d61f8f9d32523 100644 --- a/app/code/Magento/Cookie/view/frontend/web/js/notices.js +++ b/app/code/Magento/Cookie/view/frontend/web/js/notices.js @@ -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; } diff --git a/app/code/Magento/Customer/Model/Address/Validator/General.php b/app/code/Magento/Customer/Model/Address/Validator/General.php index 7cbb6ef1ab623..4888cd227db48 100644 --- a/app/code/Magento/Customer/Model/Address/Validator/General.php +++ b/app/code/Magento/Customer/Model/Address/Validator/General.php @@ -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; @@ -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') @@ -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); + } } diff --git a/app/code/Magento/Eav/Model/Config.php b/app/code/Magento/Eav/Model/Config.php index 20126d5146c35..68dd68b59e8ee 100644 --- a/app/code/Magento/Eav/Model/Config.php +++ b/app/code/Magento/Eav/Model/Config.php @@ -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 */ @@ -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 */ @@ -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) @@ -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) @@ -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) @@ -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; } } diff --git a/app/code/Magento/Paypal/Model/Payflowlink.php b/app/code/Magento/Paypal/Model/Payflowlink.php index 690e09ffd8770..f16b117daf56e 100644 --- a/app/code/Magento/Paypal/Model/Payflowlink.php +++ b/app/code/Magento/Paypal/Model/Payflowlink.php @@ -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 @@ -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 @@ -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(); @@ -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: @@ -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')] ?? ''; } /** diff --git a/app/code/Magento/Sales/Model/Order/ProductOption.php b/app/code/Magento/Sales/Model/Order/ProductOption.php index dc9ec42e27e60..9a4f847b135e7 100644 --- a/app/code/Magento/Sales/Model/Order/ProductOption.php +++ b/app/code/Magento/Sales/Model/Order/ProductOption.php @@ -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]) diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerAddressAttributeTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerAddressAttributeTest.php new file mode 100644 index 0000000000000..866fd2c97207e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerAddressAttributeTest.php @@ -0,0 +1,63 @@ +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); + } + } +}