Skip to content

Commit dfe7b89

Browse files
🔃 [Magento Community Engineering] Community Contributions - 2.4-develop latest changes
Accepted Community Pull Requests:
2 parents ed5c06d + 069654e commit dfe7b89

File tree

29 files changed

+601
-74
lines changed

29 files changed

+601
-74
lines changed

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ For more detailed information on contribution please read our [beginners guide](
1717

1818
1. Contributions must adhere to the [Magento coding standards](https://devdocs.magento.com/guides/v2.4/coding-standards/bk-coding-standards.html).
1919
2. Pull requests (PRs) must be accompanied by a meaningful description of their purpose. Comprehensive descriptions increase the chances of a pull request being merged quickly and without additional clarification requests.
20-
3. Commits must be accompanied by meaningful commit messages. Please see the [Magento Pull Request Template](https://github.com/magento/magento2/blob/2.3-develop/.github/PULL_REQUEST_TEMPLATE.md) for more information.
20+
3. Commits must be accompanied by meaningful commit messages. Please see the [Magento Pull Request Template](https://github.com/magento/magento2/blob/HEAD/.github/PULL_REQUEST_TEMPLATE.md) for more information.
2121
4. PRs which include bug fixes must be accompanied with a step-by-step description of how to reproduce the bug.
2222
3. PRs which include new logic or new features must be submitted along with:
2323
* Unit/integration test coverage

app/code/Magento/Catalog/Model/Category.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ public function getAvailableSortBy()
10371037
{
10381038
$available = $this->getData(self::KEY_AVAILABLE_SORT_BY);
10391039
if (empty($available)) {
1040-
return [];
1040+
return null;
10411041
}
10421042
if ($available && !is_array($available)) {
10431043
$available = explode(',', $available);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminSetBackordersOnProductAdvancedInventoryActionGroup">
12+
<annotations>
13+
<description>Deselects the "Use Config Settings" checkbox and set the "Backorders" select value to required</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="backorders" type="string" defaultValue="Allow Qty Below 0"/>
17+
</arguments>
18+
19+
<uncheckOption selector="{{AdminProductFormAdvancedInventorySection.useConfigSettingsForBackorders}}" stepKey="uncheckUseConfigSettings"/>
20+
<selectOption selector="{{AdminProductFormAdvancedInventorySection.backorders}}" userInput="{{backorders}}" stepKey="fillBackorders"/>
21+
</actionGroup>
22+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontAddProductWithBackordersAllowedOnProductLevelToCartTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<stories value="Manage inventory, backorders"/>
15+
<title value="Add Product to Cart, Backorders Allowed On Product Level"/>
16+
<severity value="MAJOR"/>
17+
<description value="Customer should be able to add products to Cart if product qty less or equal 0 and Backorders are allowed on Product level"/>
18+
<group value="catalog"/>
19+
</annotations>
20+
21+
<before>
22+
<createData entity="SimpleProductInStockQuantityZero" stepKey="createProduct"/>
23+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
24+
</before>
25+
26+
<after>
27+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
28+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
29+
</after>
30+
31+
<actionGroup ref="NavigateToCreatedProductEditPageActionGroup" stepKey="openCreatedProductEditPage">
32+
<argument name="product" value="$$createProduct$$"/>
33+
</actionGroup>
34+
<actionGroup ref="AdminClickOnAdvancedInventoryLinkActionGroup" stepKey="clickOnAdvancedInventoryLink"/>
35+
<actionGroup ref="AdminSetBackordersOnProductAdvancedInventoryActionGroup" stepKey="allowBackorders"/>
36+
<actionGroup ref="AdminFillAdvancedInventoryQtyActionGroup" stepKey="fillProductQty">
37+
<argument name="qty" value="-5"/>
38+
</actionGroup>
39+
<actionGroup ref="AdminSubmitAdvancedInventoryFormActionGroup" stepKey="clickDoneButton"/>
40+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct"/>
41+
42+
<actionGroup ref="AddSimpleProductToCartActionGroup" stepKey="gotoAndAddProductToCart">
43+
<argument name="product" value="$$createProduct$$"/>
44+
</actionGroup>
45+
46+
<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="gotoCart"/>
47+
<actionGroup ref="AssertStorefrontCheckoutCartItemsActionGroup" stepKey="assertProductItemInCheckOutCart">
48+
<argument name="productName" value="$$createProduct.name$$"/>
49+
<argument name="productSku" value="$$createProduct.sku$$"/>
50+
<argument name="productPrice" value="$$createProduct.price$$"/>
51+
<argument name="subtotal" value="$$createProduct.price$$" />
52+
<argument name="qty" value="1"/>
53+
</actionGroup>
54+
</test>
55+
</tests>

app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,18 @@ define([
6363

6464
this._bind();
6565

66+
this._isInitializingItems = true;
67+
this._initializedItemCount = 0;
68+
this._lastInitializedElement = null;
69+
6670
$.each(this.options.images, $.proxy(function (index, imageData) {
6771
this.element.trigger('addItem', imageData);
6872
}, this));
6973

74+
this._updateImagesRoles();
75+
this._contentUpdated();
76+
77+
this._isInitializingItems = false;
7078
this.options.initialized = true;
7179
},
7280

@@ -186,13 +194,23 @@ define([
186194
* @private
187195
*/
188196
_addItem: function (event, imageData) {
189-
var count = this.element.find(this.options.imageSelector).length,
190-
element,
197+
var element,
191198
imgElement,
192-
position = count + 1,
199+
lastElement,
200+
count,
201+
position;
202+
203+
if (this._isInitializingItems) {
204+
count = this._initializedItemCount++;
205+
lastElement = this._lastInitializedElement;
206+
} else {
207+
count = this.element.find(this.options.imageSelector).length;
193208
lastElement = this.element.find(this.options.imageSelector + ':last');
209+
}
210+
211+
position = count + 1;
194212

195-
if (lastElement.length === 1) {
213+
if (lastElement && lastElement.length === 1) {
196214
position = parseInt(lastElement.data('imageData').position || count, 10) + 1;
197215
}
198216
imageData = $.extend({
@@ -214,6 +232,8 @@ define([
214232
element.insertAfter(lastElement);
215233
}
216234

235+
this._lastInitializedElement = element;
236+
217237
if (!this.options.initialized &&
218238
this.options.images.length === 0 ||
219239
this.options.initialized &&
@@ -235,8 +255,10 @@ define([
235255
}
236256
}, this));
237257

238-
this._updateImagesRoles();
239-
this._contentUpdated();
258+
if (!this._isInitializingItems) {
259+
this._updateImagesRoles();
260+
this._contentUpdated();
261+
}
240262
},
241263

242264
/**

app/code/Magento/CatalogInventory/Test/Mftf/Section/AdminProductFormAdvancedInventorySection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,7 @@
3232
<element name="minQtyConfigSetting" type="checkbox" selector="//input[@name='product[stock_data][use_config_min_qty]']" timeout="30"/>
3333
<element name="advancedInventoryModal" type="block" selector=".product_form_product_form_advanced_inventory_modal[data-role=modal]"/>
3434
<element name="maxiQtyAllowedInCartError" type="text" selector="[name='product[stock_data][max_sale_qty]'] + label.admin__field-error"/>
35+
<element name="backorders" type="select" selector="//*[@name='product[stock_data][backorders]']"/>
36+
<element name="useConfigSettingsForBackorders" type="checkbox" selector="//input[@name='product[stock_data][use_config_backorders]']"/>
3537
</section>
3638
</sections>

app/code/Magento/Csp/etc/config.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
<frame-ancestors>
107107
<policy_id>frame-ancestors</policy_id>
108108
<self>1</self>
109-
<inline>1</inline>
109+
<inline>0</inline>
110110
<eval>0</eval>
111111
<dynamic>0</dynamic>
112112
</frame-ancestors>
@@ -217,7 +217,7 @@
217217
<frame-ancestors>
218218
<policy_id>frame-ancestors</policy_id>
219219
<self>1</self>
220-
<inline>1</inline>
220+
<inline>0</inline>
221221
<eval>0</eval>
222222
<dynamic>0</dynamic>
223223
</frame-ancestors>

app/code/Magento/Customer/Controller/Account/CreatePassword.php

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,22 @@
99

1010
use Magento\Customer\Api\AccountManagementInterface;
1111
use Magento\Customer\Model\ForgotPasswordToken\ConfirmCustomerByToken;
12+
use Magento\Customer\Model\ForgotPasswordToken\GetCustomerByToken;
1213
use Magento\Customer\Model\Session;
13-
use Magento\Framework\App\Action\HttpGetActionInterface;
14-
use Magento\Framework\View\Result\PageFactory;
1514
use Magento\Framework\App\Action\Context;
15+
use Magento\Framework\App\Action\HttpGetActionInterface;
1616
use Magento\Framework\App\ObjectManager;
17+
use Magento\Framework\Controller\Result\Redirect;
18+
use Magento\Framework\View\Result\Page;
19+
use Magento\Framework\View\Result\PageFactory;
1720

1821
/**
19-
* Class CreatePassword
20-
*
21-
* @package Magento\Customer\Controller\Account
22+
* Controller for front-end customer password reset form
2223
*/
2324
class CreatePassword extends \Magento\Customer\Controller\AbstractAccount implements HttpGetActionInterface
2425
{
2526
/**
26-
* @var \Magento\Customer\Api\AccountManagementInterface
27+
* @var AccountManagementInterface
2728
*/
2829
protected $accountManagement;
2930

@@ -38,37 +39,46 @@ class CreatePassword extends \Magento\Customer\Controller\AbstractAccount implem
3839
protected $resultPageFactory;
3940

4041
/**
41-
* @var \Magento\Customer\Model\ForgotPasswordToken\ConfirmCustomerByToken
42+
* @var ConfirmCustomerByToken
4243
*/
4344
private $confirmByToken;
4445

4546
/**
46-
* @param \Magento\Framework\App\Action\Context $context
47-
* @param \Magento\Customer\Model\Session $customerSession
48-
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
49-
* @param \Magento\Customer\Api\AccountManagementInterface $accountManagement
50-
* @param \Magento\Customer\Model\ForgotPasswordToken\ConfirmCustomerByToken $confirmByToken
47+
* @var GetCustomerByToken
48+
*/
49+
private $getByToken;
50+
51+
/**
52+
* @param Context $context
53+
* @param Session $customerSession
54+
* @param PageFactory $resultPageFactory
55+
* @param AccountManagementInterface $accountManagement
56+
* @param ConfirmCustomerByToken|null $confirmByToken
57+
* @param GetCustomerByToken|null $getByToken
5158
*/
5259
public function __construct(
5360
Context $context,
5461
Session $customerSession,
5562
PageFactory $resultPageFactory,
5663
AccountManagementInterface $accountManagement,
57-
ConfirmCustomerByToken $confirmByToken = null
64+
ConfirmCustomerByToken $confirmByToken = null,
65+
GetCustomerByToken $getByToken = null
5866
) {
5967
$this->session = $customerSession;
6068
$this->resultPageFactory = $resultPageFactory;
6169
$this->accountManagement = $accountManagement;
6270
$this->confirmByToken = $confirmByToken
6371
?? ObjectManager::getInstance()->get(ConfirmCustomerByToken::class);
72+
$this->getByToken = $getByToken
73+
?? ObjectManager::getInstance()->get(GetCustomerByToken::class);
6474

6575
parent::__construct($context);
6676
}
6777

6878
/**
6979
* Resetting password handler
7080
*
71-
* @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\View\Result\Page
81+
* @return Redirect|Page
7282
*/
7383
public function execute()
7484
{
@@ -83,14 +93,19 @@ public function execute()
8393

8494
$this->confirmByToken->execute($resetPasswordToken);
8595

96+
// Extend token validity to avoid expiration while this form is
97+
// being completed by the user.
98+
$customer = $this->getByToken->execute($resetPasswordToken);
99+
$this->accountManagement->changeResetPasswordLinkToken($customer, $resetPasswordToken);
100+
86101
if ($isDirectLink) {
87102
$this->session->setRpToken($resetPasswordToken);
88103
$resultRedirect = $this->resultRedirectFactory->create();
89104
$resultRedirect->setPath('*/*/createpassword');
90105

91106
return $resultRedirect;
92107
} else {
93-
/** @var \Magento\Framework\View\Result\Page $resultPage */
108+
/** @var Page $resultPage */
94109
$resultPage = $this->resultPageFactory->create();
95110
$resultPage->getLayout()
96111
->getBlock('resetPassword')
@@ -100,7 +115,7 @@ public function execute()
100115
}
101116
} catch (\Exception $exception) {
102117
$this->messageManager->addErrorMessage(__('Your password reset link has expired.'));
103-
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
118+
/** @var Redirect $resultRedirect */
104119
$resultRedirect = $this->resultRedirectFactory->create();
105120
$resultRedirect->setPath('*/*/forgotpassword');
106121

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public function getLoginUrlParams()
120120
ScopeInterface::SCOPE_STORE
121121
)
122122
&& !$this->customerSession->getNoReferer()
123+
&& $this->request->isGet()
123124
) {
124125
$referer = $this->urlBuilder->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true]);
125126
$referer = $this->urlEncoder->encode($referer);

app/code/Magento/Fedex/Setup/Patch/Data/ConfigureFedexDefaults.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public function apply()
9797
} elseif (stripos($mapOld['path'], 'free_method') !== false && isset($codes['method'][$mapOld['value']])) {
9898
$mapNew = $codes['method'][$mapOld['value']];
9999
} elseif (stripos($mapOld['path'], 'allowed_methods') !== false) {
100+
$mapNew = [];
100101
foreach (explode(',', $mapOld['value']) as $shippingMethod) {
101102
if (isset($codes['method'][$shippingMethod])) {
102103
$mapNew[] = $codes['method'][$shippingMethod];

app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Creditmemos.php

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,67 @@
55
*/
66
namespace Magento\Sales\Block\Adminhtml\Order\View\Tab;
77

8+
use Magento\Backend\Block\Widget\Tab\TabInterface;
9+
use Magento\Framework\App\ObjectManager;
10+
use Magento\Framework\AuthorizationInterface;
11+
use Magento\Framework\View\Element\Context;
12+
use Magento\Framework\View\Element\Text\ListText;
13+
814
/**
915
* Order Credit Memos grid
1016
*
1117
* @api
1218
* @since 100.0.2
1319
*/
14-
class Creditmemos extends \Magento\Framework\View\Element\Text\ListText implements
15-
\Magento\Backend\Block\Widget\Tab\TabInterface
20+
class Creditmemos extends ListText implements TabInterface
1621
{
1722
/**
18-
* {@inheritdoc}
23+
* @var AuthorizationInterface
24+
*/
25+
private $authorization;
26+
27+
/**
28+
* Creditmemos constructor.
29+
*
30+
* @param Context $context
31+
* @param array $data
32+
* @param AuthorizationInterface|null $authorization
33+
*/
34+
public function __construct(
35+
Context $context,
36+
array $data = [],
37+
?AuthorizationInterface $authorization = null
38+
) {
39+
$this->authorization = $authorization ?? ObjectManager::getInstance()->get(AuthorizationInterface::class);
40+
parent::__construct($context, $data);
41+
}
42+
43+
/**
44+
* @inheritdoc
1945
*/
2046
public function getTabLabel()
2147
{
2248
return __('Credit Memos');
2349
}
2450

2551
/**
26-
* {@inheritdoc}
52+
* @inheritdoc
2753
*/
2854
public function getTabTitle()
2955
{
3056
return __('Order Credit Memos');
3157
}
3258

3359
/**
34-
* {@inheritdoc}
60+
* @inheritdoc
3561
*/
3662
public function canShowTab()
3763
{
38-
return true;
64+
return $this->authorization->isAllowed('Magento_Sales::sales_creditmemo');
3965
}
4066

4167
/**
42-
* {@inheritdoc}
68+
* @inheritdoc
4369
*/
4470
public function isHidden()
4571
{

0 commit comments

Comments
 (0)