Skip to content

Commit 4e0e41c

Browse files
merge magento/2.3-develop into magento-trigger/MC-17627
2 parents 538516c + 88d78b2 commit 4e0e41c

File tree

8 files changed

+257
-35
lines changed

8 files changed

+257
-35
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,42 @@
1+
# Magento_Authorizenet module
2+
13
The Magento_Authorizenet module implements the integration with the Authorize.Net payment gateway and makes the latter available as a payment method in Magento.
4+
5+
## Extensibility
6+
7+
Extension developers can interact with the Magento_Authorizenet module. For more information about the Magento extension mechanism, see [Magento plug-ins](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html).
8+
9+
[The Magento dependency injection mechanism](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/depend-inj.html) enables you to override the functionality of the Magento_Authorizenet module.
10+
11+
### Events
12+
13+
This module dispatches the following events:
14+
15+
- `checkout_directpost_placeOrder` event in the `\Magento\Authorizenet\Controller\Directpost\Payment\Place::placeCheckoutOrder()` method. Parameters:
16+
- `result` is a data object (`\Magento\Framework\DataObject` class).
17+
- `action` is a controller object (`\Magento\Authorizenet\Controller\Directpost\Payment\Place`).
18+
19+
- `order_cancel_after` event in the `\Magento\Authorizenet\Model\Directpost::declineOrder()` method. Parameters:
20+
- `order` is an order object (`\Magento\Sales\Model\Order` class).
21+
22+
23+
This module observes the following events:
24+
25+
- `checkout_submit_all_after` event in the `Magento\Authorizenet\Observer\SaveOrderAfterSubmitObserver` file.
26+
- `checkout_directpost_placeOrder` event in the `Magento\Authorizenet\Observer\AddFieldsToResponseObserver` file.
27+
28+
For information about events in Magento 2, see [Events and observers](http://devdocs.magento.com/guides/v2.3/extension-dev-guide/events-and-observers.html#events).
29+
30+
### Layouts
31+
32+
This module introduces the following layouts and layout handles in the `view/adminhtml/layout` directory:
33+
34+
- `adminhtml_authorizenet_directpost_payment_redirect`
35+
36+
This module introduces the following layouts and layout handles in the `view/frontend/layout` directory:
37+
38+
- `authorizenet_directpost_payment_backendresponse`
39+
- `authorizenet_directpost_payment_redirect`
40+
- `authorizenet_directpost_payment_response`
41+
42+
For more information about layouts in Magento 2, see the [Layout documentation](https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/layout-overview.html).

app/code/Magento/Checkout/view/frontend/templates/cart/form.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<span><?= $block->escapeHtml(__('Continue Shopping')) ?></span>
5757
</a>
5858
<?php endif; ?>
59-
<button type="submit"
59+
<button type="button"
6060
name="update_cart_action"
6161
data-cart-empty=""
6262
value="empty_cart"

app/code/Magento/Checkout/view/frontend/web/js/shopping-cart.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ define([
1414
_create: function () {
1515
var items, i, reload;
1616

17-
$(this.options.emptyCartButton).on('click', $.proxy(function (event) {
18-
if (event.detail === 0) {
19-
return;
20-
}
21-
17+
$(this.options.emptyCartButton).on('click', $.proxy(function () {
2218
$(this.options.emptyCartButton).attr('name', 'update_cart_action_temp');
2319
$(this.options.updateCartActionContainer)
2420
.attr('name', 'update_cart_action').attr('value', 'empty_cart');
21+
22+
if ($(this.options.emptyCartButton).parents('form').length > 0) {
23+
$(this.options.emptyCartButton).parents('form').submit();
24+
}
2525
}, this));
2626
items = $.find('[data-role="cart-item-qty"]');
2727

app/code/Magento/Cron/etc/adminhtml/system.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,27 @@
1515
<label>Cron configuration options for group: </label>
1616
<field id="schedule_generate_every" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
1717
<label>Generate Schedules Every</label>
18+
<validate>validate-zero-or-greater validate-digits</validate>
1819
</field>
1920
<field id="schedule_ahead_for" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
2021
<label>Schedule Ahead for</label>
22+
<validate>validate-zero-or-greater validate-digits</validate>
2123
</field>
2224
<field id="schedule_lifetime" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
2325
<label>Missed if Not Run Within</label>
26+
<validate>validate-zero-or-greater validate-digits</validate>
2427
</field>
2528
<field id="history_cleanup_every" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
2629
<label>History Cleanup Every</label>
30+
<validate>validate-zero-or-greater validate-digits</validate>
2731
</field>
2832
<field id="history_success_lifetime" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
2933
<label>Success History Lifetime</label>
34+
<validate>validate-zero-or-greater validate-digits</validate>
3035
</field>
3136
<field id="history_failure_lifetime" translate="label" type="text" sortOrder="60" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
3237
<label>Failure History Lifetime</label>
38+
<validate>validate-zero-or-greater validate-digits</validate>
3339
</field>
3440
<field id="use_separate_process" translate="label" type="select" sortOrder="70" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
3541
<label>Use Separate Process</label>

app/code/Magento/Customer/Model/AttributeMetadataConverter.php

Lines changed: 73 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,36 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Customer\Model;
79

810
use Magento\Customer\Api\Data\OptionInterfaceFactory;
911
use Magento\Customer\Api\Data\ValidationRuleInterfaceFactory;
1012
use Magento\Customer\Api\Data\AttributeMetadataInterfaceFactory;
1113
use Magento\Eav\Api\Data\AttributeDefaultValueInterface;
14+
use Magento\Framework\App\Config\ScopeConfigInterface;
15+
use Magento\Framework\App\ObjectManager;
1216

1317
/**
1418
* Converter for AttributeMetadata
1519
*/
1620
class AttributeMetadataConverter
1721
{
22+
/**
23+
* Attribute Code get options from system config
24+
*
25+
* @var array
26+
*/
27+
private const ATTRIBUTE_CODE_LIST_FROM_SYSTEM_CONFIG = ['prefix', 'suffix'];
28+
29+
/**
30+
* XML Path to get address config
31+
*
32+
* @var string
33+
*/
34+
private const XML_CUSTOMER_ADDRESS = 'customer/address/';
35+
1836
/**
1937
* @var OptionInterfaceFactory
2038
*/
@@ -35,24 +53,32 @@ class AttributeMetadataConverter
3553
*/
3654
protected $dataObjectHelper;
3755

56+
/**
57+
* @var ScopeConfigInterface
58+
*/
59+
private $scopeConfig;
60+
3861
/**
3962
* Initialize the Converter
4063
*
4164
* @param OptionInterfaceFactory $optionFactory
4265
* @param ValidationRuleInterfaceFactory $validationRuleFactory
4366
* @param AttributeMetadataInterfaceFactory $attributeMetadataFactory
4467
* @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
68+
* @param ScopeConfigInterface $scopeConfig
4569
*/
4670
public function __construct(
4771
OptionInterfaceFactory $optionFactory,
4872
ValidationRuleInterfaceFactory $validationRuleFactory,
4973
AttributeMetadataInterfaceFactory $attributeMetadataFactory,
50-
\Magento\Framework\Api\DataObjectHelper $dataObjectHelper
74+
\Magento\Framework\Api\DataObjectHelper $dataObjectHelper,
75+
ScopeConfigInterface $scopeConfig = null
5176
) {
5277
$this->optionFactory = $optionFactory;
5378
$this->validationRuleFactory = $validationRuleFactory;
5479
$this->attributeMetadataFactory = $attributeMetadataFactory;
5580
$this->dataObjectHelper = $dataObjectHelper;
81+
$this->scopeConfig = $scopeConfig ?? ObjectManager::getInstance()->get(ScopeConfigInterface::class);
5682
}
5783

5884
/**
@@ -64,28 +90,34 @@ public function __construct(
6490
public function createMetadataAttribute($attribute)
6591
{
6692
$options = [];
67-
if ($attribute->usesSource()) {
68-
foreach ($attribute->getSource()->getAllOptions() as $option) {
69-
$optionDataObject = $this->optionFactory->create();
70-
if (!is_array($option['value'])) {
71-
$optionDataObject->setValue($option['value']);
72-
} else {
73-
$optionArray = [];
74-
foreach ($option['value'] as $optionArrayValues) {
75-
$optionObject = $this->optionFactory->create();
76-
$this->dataObjectHelper->populateWithArray(
77-
$optionObject,
78-
$optionArrayValues,
79-
\Magento\Customer\Api\Data\OptionInterface::class
80-
);
81-
$optionArray[] = $optionObject;
93+
94+
if (in_array($attribute->getAttributeCode(), self::ATTRIBUTE_CODE_LIST_FROM_SYSTEM_CONFIG)) {
95+
$options = $this->getOptionFromConfig($attribute->getAttributeCode());
96+
} else {
97+
if ($attribute->usesSource()) {
98+
foreach ($attribute->getSource()->getAllOptions() as $option) {
99+
$optionDataObject = $this->optionFactory->create();
100+
if (!is_array($option['value'])) {
101+
$optionDataObject->setValue($option['value']);
102+
} else {
103+
$optionArray = [];
104+
foreach ($option['value'] as $optionArrayValues) {
105+
$optionObject = $this->optionFactory->create();
106+
$this->dataObjectHelper->populateWithArray(
107+
$optionObject,
108+
$optionArrayValues,
109+
\Magento\Customer\Api\Data\OptionInterface::class
110+
);
111+
$optionArray[] = $optionObject;
112+
}
113+
$optionDataObject->setOptions($optionArray);
82114
}
83-
$optionDataObject->setOptions($optionArray);
115+
$optionDataObject->setLabel($option['label']);
116+
$options[] = $optionDataObject;
84117
}
85-
$optionDataObject->setLabel($option['label']);
86-
$options[] = $optionDataObject;
87118
}
88119
}
120+
89121
$validationRules = [];
90122
foreach ((array)$attribute->getValidateRules() as $name => $value) {
91123
$validationRule = $this->validationRuleFactory->create()
@@ -122,4 +154,26 @@ public function createMetadataAttribute($attribute)
122154
->setIsFilterableInGrid($attribute->getIsFilterableInGrid())
123155
->setIsSearchableInGrid($attribute->getIsSearchableInGrid());
124156
}
157+
158+
/**
159+
* Get option from System Config instead of Use Source (Prefix, Suffix)
160+
*
161+
* @param string $attributeCode
162+
* @return \Magento\Customer\Api\Data\OptionInterface[]
163+
*/
164+
private function getOptionFromConfig($attributeCode)
165+
{
166+
$result = [];
167+
$value = $this->scopeConfig->getValue(self::XML_CUSTOMER_ADDRESS . $attributeCode . '_options');
168+
if ($value) {
169+
$optionArray = explode(';', $value);
170+
foreach ($optionArray as $value) {
171+
$optionObject = $this->optionFactory->create();
172+
$optionObject->setLabel($value);
173+
$optionObject->setValue($value);
174+
$result[] = $optionObject;
175+
}
176+
}
177+
return $result;
178+
}
125179
}

app/code/Magento/Newsletter/Model/Subscriber.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,7 @@ public function isStatusChanged()
353353
*/
354354
public function isSubscribed()
355355
{
356-
if ($this->getId() && $this->getStatus() == self::STATUS_SUBSCRIBED) {
357-
return true;
358-
}
359-
360-
return false;
356+
return $this->getId() && (int)$this->getStatus() === self::STATUS_SUBSCRIBED;
361357
}
362358

363359
/**

0 commit comments

Comments
 (0)