Skip to content

Commit 0b5a79f

Browse files
committed
Merge branch '2.3-develop' into MC-19827
2 parents 58224cf + 88d78b2 commit 0b5a79f

File tree

22 files changed

+553
-134
lines changed

22 files changed

+553
-134
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/Test/Mftf/Test/StorefrontAddBundleDynamicProductToShoppingCartWithDisableMiniCartSidebarTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
<argument name="total" value="110.00"/>
110110
</actionGroup>
111111

112-
<!--Enabled Shopping Cart Sidebar -->
112+
<!--Enabled Mini Cart -->
113113
<magentoCLI stepKey="enableShoppingCartSidebar" command="config:set checkout/sidebar/display 1"/>
114114
<magentoCLI command="cache:flush" stepKey="flushCache"/>
115115
<reloadPage stepKey="reloadThePage"/>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
</field>
5858
</group>
5959
<group id="sidebar" translate="label" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1">
60-
<label>Shopping Cart Sidebar</label>
60+
<label>Mini Cart</label>
6161
<field id="display" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
62-
<label>Display Shopping Cart Sidebar</label>
62+
<label>Display Mini Cart</label>
6363
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
6464
</field>
6565
<field id="count" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">

app/code/Magento/Checkout/i18n/en_US.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ Shipping,Shipping
156156
"Number of Items to Display Pager","Number of Items to Display Pager"
157157
"My Cart Link","My Cart Link"
158158
"Display Cart Summary","Display Cart Summary"
159-
"Shopping Cart Sidebar","Shopping Cart Sidebar"
160-
"Display Shopping Cart Sidebar","Display Shopping Cart Sidebar"
159+
"Mini Cart","Mini Cart"
160+
"Display Mini Cart","Display Mini Cart"
161161
"Number of Items to Display Scrollbar","Number of Items to Display Scrollbar"
162162
"Maximum Number of Items to Display","Maximum Number of Items to Display"
163163
"Payment Failed Emails","Payment Failed Emails"

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/LayeredNavigation/Block/Navigation.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ public function getFilters()
121121
*/
122122
public function canShowBlock()
123123
{
124-
return $this->visibilityFlag->isEnabled($this->getLayer(), $this->getFilters());
124+
return $this->getLayer()->getCurrentCategory()->getDisplayMode() !== \Magento\Catalog\Model\Category::DM_PAGE
125+
&& $this->visibilityFlag->isEnabled($this->getLayer(), $this->getFilters());
125126
}
126127

127128
/**

app/code/Magento/LayeredNavigation/Test/Unit/Block/NavigationTest.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Magento\LayeredNavigation\Test\Unit\Block;
88

9+
use Magento\Catalog\Model\Category;
10+
911
class NavigationTest extends \PHPUnit\Framework\TestCase
1012
{
1113
/**
@@ -98,9 +100,61 @@ public function testCanShowBlock()
98100
->method('isEnabled')
99101
->with($this->catalogLayerMock, $filters)
100102
->will($this->returnValue($enabled));
103+
104+
$category = $this->createMock(Category::class);
105+
$this->catalogLayerMock->expects($this->atLeastOnce())->method('getCurrentCategory')->willReturn($category);
106+
$category->expects($this->once())->method('getDisplayMode')->willReturn(Category::DM_PRODUCT);
107+
101108
$this->assertEquals($enabled, $this->model->canShowBlock());
102109
}
103110

111+
/**
112+
* Test canShowBlock() with different category display types.
113+
*
114+
* @param string $mode
115+
* @param bool $result
116+
*
117+
* @dataProvider canShowBlockDataProvider
118+
*/
119+
public function testCanShowBlockWithDifferentDisplayModes(string $mode, bool $result)
120+
{
121+
$filters = ['To' => 'be', 'or' => 'not', 'to' => 'be'];
122+
123+
$this->filterListMock->expects($this->atLeastOnce())->method('getFilters')
124+
->with($this->catalogLayerMock)
125+
->will($this->returnValue($filters));
126+
$this->assertEquals($filters, $this->model->getFilters());
127+
128+
$this->visibilityFlagMock
129+
->expects($this->any())
130+
->method('isEnabled')
131+
->with($this->catalogLayerMock, $filters)
132+
->will($this->returnValue(true));
133+
134+
$category = $this->createMock(Category::class);
135+
$this->catalogLayerMock->expects($this->atLeastOnce())->method('getCurrentCategory')->willReturn($category);
136+
$category->expects($this->once())->method('getDisplayMode')->willReturn($mode);
137+
$this->assertEquals($result, $this->model->canShowBlock());
138+
}
139+
140+
public function canShowBlockDataProvider()
141+
{
142+
return [
143+
[
144+
Category::DM_PRODUCT,
145+
true,
146+
],
147+
[
148+
Category::DM_PAGE,
149+
false,
150+
],
151+
[
152+
Category::DM_MIXED,
153+
true,
154+
],
155+
];
156+
}
157+
104158
public function testGetClearUrl()
105159
{
106160
$this->filterListMock->expects($this->any())->method('getFilters')->will($this->returnValue([]));

0 commit comments

Comments
 (0)