Skip to content

Commit 15c881e

Browse files
🔃 [Magento Community Engineering] Community Contributions - 2.4-develop
Accepted Community Pull Requests: - #26273: MFTF: Replace <amOnPage> with <actionGroup> for Admin log out (by @lbajsarowicz) - #26274: MFTF: Replace incorrect URLs in Tests and ActionGroups (by @lbajsarowicz) - #26264: Issue 23521 (by @aleromano89) - #25946: Add plugin for SalesOrderItemRepository gift message (#19093) (by @lfolco) - #26268: Fix #14001 - M2.2.3 directory_country_region_name locale fix? 8bytes zh_Hans_CN(11bytes) ca_ES_VALENCIA(14bytes) (by @Bartlomiejsz) - #26259: Fix invalid XML Schema location (by @lbajsarowicz) - #26183: Added Fix for - 26181 (by @divyajyothi5321) - #26237: Added Fix for 25936 (by @divyajyothi5321) - #26234: [Align some space between input and update button Minicart] (by @hitesh-wagento) - #26215: Disabled the sorting option in status column on cache grid (by @srsathish92) - #26169: Added Fix for issue 26168 (by @divyajyothi5321) - #26029: Fixed keyboard arrow keys behavior for number fields in AdobeStock grid (by @rogyar) - #26207: #26206 Add information about currently reindexed index. (by @lbajsarowicz) Fixed GitHub Issues: - #23521: Unable to run \Magento\Downloadable\Test\Unit\Helper\DownloadTest without internet connection / dns resolution (reported by @adrian-martinez-interactiv4) has been fixed in #26264 by @aleromano89 in 2.4-develop branch Related commits: 1. 95fc06f 2. b015b65 3. 05ecfda - #19093: API: salesOrderItemRepository does not include gift message (reported by @nthurston) has been fixed in #25946 by @lfolco in 2.4-develop branch Related commits: 1. 30b5818 2. f076e55 - #14001: M2.2.3 directory_country_region_name locale fix? 8bytes zh_Hans_CN(11bytes) ca_ES_VALENCIA(14bytes) (reported by @jiyun) has been fixed in #26268 by @Bartlomiejsz in 2.4-develop branch Related commits: 1. 5fe7454 - #26181: Out of stock text is not aligned properly with add to cart button at list page in responsive (reported by @divyajyothi5321) has been fixed in #26183 by @divyajyothi5321 in 2.4-develop branch Related commits: 1. e520c8b 2. aaf1478 3. b87672a 4. 7117ac4 5. 135df0b 6. 6a7179a 7. 4c545f2 8. 3a7ec0d - #25936: Regular Price Label Alignment Issues in Frontend (reported by @divyajyothi5321) has been fixed in #26237 by @divyajyothi5321 in 2.4-develop branch Related commits: 1. c39e85c - #26227: Need some space between input and update button Minicart (reported by @hitesh-wagento) has been fixed in #26234 by @hitesh-wagento in 2.4-develop branch Related commits: 1. 69f6da0 2. 7e5e6c7 - #26208: Sorting issue for status column for Cache Management (reported by @hasim32) has been fixed in #26215 by @srsathish92 in 2.4-develop branch Related commits: 1. e4e4b4e - #26168: Input Checkbox Alignment Issue at checkout page in Safari Browser (reported by @divyajyothi5321) has been fixed in #26169 by @divyajyothi5321 in 2.4-develop branch Related commits: 1. 9882e96 - #26206: Missing information about currently reindexed index on failure (reported by @lbajsarowicz) has been fixed in #26207 by @lbajsarowicz in 2.4-develop branch Related commits: 1. 1ca03a3 2. 79fe786 3. 84b1310 4. 80684d7 5. 5bdadc0
2 parents 01ab2cd + f169869 commit 15c881e

File tree

48 files changed

+341
-86
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+341
-86
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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="AdminLogoutActionGroup">
12+
<amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/>
13+
</actionGroup>
14+
</actionGroups>

app/code/Magento/Backend/view/adminhtml/layout/adminhtml_cache_block.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
<argument name="type" xsi:type="string">options</argument>
8181
<argument name="width" xsi:type="string">120</argument>
8282
<argument name="align" xsi:type="string">left</argument>
83+
<argument name="sortable" xsi:type="string">0</argument>
8384
<argument name="options" xsi:type="array">
8485
<item name="disabled" xsi:type="array">
8586
<item name="value" xsi:type="string">0</item>

app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAdminEditDataTest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
<waitForPageLoad stepKey="waitForElementAdded"/>
8080

8181
<!-- Go to the shopping cart page and grab the value of the option title -->
82-
<amOnPage url="/checkout/cart/" stepKey="onPageShoppingCart"/>
82+
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="onPageShoppingCart"/>
8383
<waitForPageLoad stepKey="waitForCartPageLoad"/>
8484
<grabTextFrom selector="{{CheckoutCartProductSection.nthBundleOptionName('1')}}" stepKey="grabTotalBefore"/>
8585

@@ -100,7 +100,7 @@
100100
<see stepKey="assertSuccess2" selector="{{AdminProductMessagesSection.successMessage}}" userInput="You saved the product."/>
101101

102102
<!-- Go to the shopping cart page and make sure the title has changed -->
103-
<amOnPage url="/checkout/cart/" stepKey="onPageShoppingCart1"/>
103+
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="onPageShoppingCart1"/>
104104
<waitForPageLoad stepKey="waitForCartPageLoad1"/>
105105
<grabTextFrom selector="{{CheckoutCartProductSection.nthBundleOptionName('1')}}" stepKey="grabTotalAfter"/>
106106
<assertNotEquals expected="{$grabTotalBefore}" expectedType="string" actual="{$grabTotalAfter}" actualType="string" stepKey="assertNotEquals"/>

app/code/Magento/Bundle/Test/Mftf/Test/StorefrontEditBundleProductTest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
<waitForPageLoad stepKey="waitForElementAdded2"/>
8787

8888
<!-- Go to the shopping cart page and edit the first product -->
89-
<amOnPage url="/checkout/cart/" stepKey="onPageShoppingCart"/>
89+
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="onPageShoppingCart"/>
9090
<waitForPageLoad stepKey="waitForCartPageLoad"/>
9191
<waitForElementVisible stepKey="waitForInfoDropdown" selector="{{CheckoutCartSummarySection.total}}"/>
9292
<waitForPageLoad stepKey="waitForCartPageLoad3"/>
@@ -104,7 +104,7 @@
104104
<waitForPageLoad stepKey="waitForElementAdded3"/>
105105

106106
<!-- Go to the shopping cart page -->
107-
<amOnPage url="/checkout/cart/" stepKey="onPageShoppingCart2"/>
107+
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="onPageShoppingCart2"/>
108108
<waitForPageLoad stepKey="waitForCartPageLoad2"/>
109109

110110
<!-- Assert that the options are both there and the proce no longer matches -->

app/code/Magento/Captcha/Test/Mftf/Section/CaptchaFormsDisplayingSection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="CaptchaFormsDisplayingSection">
1212
<element name="store" type="button" selector="#menu-magento-backend-stores"/>
1313
<element name="config" type="button" selector="//li[@data-ui-id='menu-magento-config-system-config']//span"/>

app/code/Magento/Catalog/Test/Mftf/Metadata/image_content-meta.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88

99
<operations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataOperation.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataOperation.xsd">
1111
<operation name="CreateImageContent" dataType="ImageContent" type="create">
1212
<field key="base64_encoded_data" required="true">string</field>
1313
<field key="type" required="true">string</field>

app/code/Magento/Catalog/Test/Mftf/Test/AdminApplyTierPriceToProductTest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<seeElement selector="{{StorefrontCategoryProductSection.productPriceFinal('90')}}" stepKey="assertProductFinalPriceIs90_1"/>
6161
<seeElement selector="{{StorefrontCategoryProductSection.productPriceLabel('Regular Price')}}" stepKey="assertRegularPriceLabel_1"/>
6262
<seeElement selector="{{StorefrontCategoryProductSection.productPriceOld('100')}}" stepKey="assertRegularPriceAmount_1"/>
63-
<amOnPage url="customer/account/logout/" stepKey="logoutCustomer1"/>
63+
<amOnPage url="{{StorefrontCustomerLogoutPage.url}}" stepKey="logoutCustomer1"/>
6464
<waitForPageLoad time="30" stepKey="waitForPageLoad2"/>
6565
<amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="navigateToCategoryPage2"/>
6666
<waitForPageLoad time="30" stepKey="waitForPageLoad3"/>
@@ -116,7 +116,7 @@
116116
<seeElement selector="{{StorefrontCategoryProductSection.productPriceFinal('100')}}" stepKey="assertProductFinalPriceIs100_2"/>
117117
<seeElement selector="{{StorefrontCategoryProductSection.productPriceLabel('As low as')}}" stepKey="assertAsLowAsPriceLabel_1"/>
118118
<seeElement selector="{{StorefrontCategoryProductSection.productPriceLinkAfterLabel('As low as', '82')}}" stepKey="assertPriceAfterAsLowAsLabel_1"/>
119-
<amOnPage url="customer/account/logout/" stepKey="logoutCustomer2"/>
119+
<amOnPage url="{{StorefrontCustomerLogoutPage.url}}" stepKey="logoutCustomer2"/>
120120
<waitForPageLoad time="30" stepKey="waitForPageLoad7"/>
121121
<amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="navigateToCategoryPage6"/>
122122
<waitForPageLoad time="30" stepKey="waitForPageLoad8"/>

app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckPaginationInStorefrontTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
<click selector="{{CatalogProductsSection.resetFilter}}" stepKey="clickOnResetFilter"/>
116116
<waitForPageLoad stepKey="waitForPageToLoad3"/>
117117
<selectOption selector="{{AdminProductGridFilterSection.productPerPage}}" userInput="30" stepKey="selectPagePerView"/>
118-
<wait stepKey="waitFroPageToLoad1" time="30"/>
118+
<waitForPageLoad stepKey="waitForPageToLoadProductPerPage" time="30"/>
119119
<fillField selector="{{AdminCategoryContentSection.productTableColumnName}}" userInput="pagi" stepKey="selectProduct1"/>
120120
<click selector="{{AdminCategoryContentSection.productSearch}}" stepKey="clickSearchButton"/>
121121
<waitForPageLoad stepKey="waitFroPageToLoad2"/>

app/code/Magento/CatalogRuleConfigurable/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithAssignedSimpleProductsTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@
258258
</actionGroup>
259259

260260
<!--Assert products prices in the cart -->
261-
<amOnPage url="/checkout/cart/" stepKey="amOnShoppingCartPage"/>
261+
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnShoppingCartPage"/>
262262
<waitForPageLoad stepKey="waitForShoppingCartPageLoad"/>
263263
<see userInput="$210.69" selector="{{CheckoutCartProductSection.ProductPriceByOption($$createFirstConfigProductAttributeFirstOption.option[store_labels][1][label]$$)}}" stepKey="assertFirstProductPriceForFirstProductOption"/>
264264
<see userInput="$120.70" selector="{{CheckoutCartProductSection.ProductPriceByOption($$createFirstConfigProductAttributeSecondOption.option[store_labels][1][label]$$)}}" stepKey="assertFirstProductPriceForSecondProductOption"/>

app/code/Magento/CatalogRuleConfigurable/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithOptionsTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@
212212
</actionGroup>
213213

214214
<!--Assert product price in the cart -->
215-
<amOnPage url="/checkout/cart/" stepKey="amOnShoppingCartPage"/>
215+
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnShoppingCartPage"/>
216216
<waitForPageLoad stepKey="waitForShoppingCartPageLoad"/>
217217
<see userInput="{{CatalogRuleToFixed.discount_amount}}" selector="{{CheckoutCartProductSection.ProductPriceByOption($$createConfigProductAttributeFirstOption.option[store_labels][1][label]$$)}}" stepKey="assertProductPriceForFirstProductOption"/>
218218
<see userInput="$110.70" selector="{{CheckoutCartProductSection.ProductPriceByOption($$createConfigProductAttributeSecondOption.option[store_labels][1][label]$$)}}" stepKey="assertProductPriceForSecondProductOption"/>

app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
<after>
3030
<!--Logout from customer account-->
31-
<amOnPage url="customer/account/logout/" stepKey="logoutCustomerOne"/>
31+
<amOnPage url="{{StorefrontCustomerLogoutPage.url}}" stepKey="logoutCustomerOne"/>
3232
<waitForPageLoad stepKey="waitLogoutCustomerOne"/>
3333
<actionGroup ref="logout" stepKey="adminLogout"/>
3434
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>

app/code/Magento/Config/Test/Mftf/ActionGroup/ConfigAdminAccountSharingActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<description>Goes to the 'Configuration' page for 'Admin'. Enables 'Admin Account Sharing'. Clicks on the Save button.</description>
1414
</annotations>
1515

16-
<amOnPage url="{{_ENV.MAGENTO_BACKEND_NAME}}/admin/system_config/edit/section/admin/" stepKey="navigateToConfigurationPage"/>
16+
<amOnPage url="{{AdminConfigAdvancedAdmin.url}}" stepKey="navigateToConfigurationPage"/>
1717
<waitForPageLoad stepKey="wait1"/>
1818
<conditionalClick stepKey="expandSecurityTab" selector="{{AdminSection.SecurityTab}}" dependentSelector="{{AdminSection.CheckIfTabExpand}}" visible="true"/>
1919
<waitForElementVisible selector="{{AdminSection.AdminAccountSharing}}" stepKey="waitForAdminAccountSharingDrpDown"/>

app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
<waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" stepKey="waitForSuccessMessage"/>
132132

133133
<!-- Assert configurable product in cart -->
134-
<amOnPage url="/checkout/cart/" stepKey="amOnShoppingCartPage"/>
134+
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnShoppingCartPage"/>
135135
<waitForPageLoad stepKey="waitForShoppingCartPageLoad"/>
136136
<actionGroup ref="StorefrontCheckCartConfigurableProductActionGroup" stepKey="storefrontCheckCartConfigurableProductActionGroup">
137137
<argument name="product" value="ApiConfigurableProduct"/>

app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
<waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" stepKey="waitForSuccessMessage"/>
114114

115115
<!-- Assert configurable product in cart -->
116-
<amOnPage url="/checkout/cart/" stepKey="amOnShoppingCartPage"/>
116+
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnShoppingCartPage"/>
117117
<waitForPageLoad stepKey="waitForShoppingCartPageLoad"/>
118118
<actionGroup ref="StorefrontCheckCartConfigurableProductActionGroup" stepKey="storefrontCheckCartConfigurableProductActionGroup">
119119
<argument name="product" value="ApiConfigurableProduct"/>

app/code/Magento/Customer/Test/Mftf/ActionGroup/SignUpNewUserFromStorefrontActionGroup.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@
117117
<arguments>
118118
<argument name="address"/>
119119
</arguments>
120-
121-
<amOnPage url="customer/address/index/" stepKey="goToAddressPage"/>
120+
121+
<amOnPage url="{{StorefrontCustomerAddressesPage.url}}" stepKey="goToAddressPage"/>
122122
<waitForPageLoad stepKey="waitForAddressPageLoad"/>
123-
123+
124124
<!--Verify customer default billing address-->
125125
<see selector="{{StorefrontCustomerAddressesSection.defaultBillingAddress}}" userInput="{{address.firstname}} {{address.lastname}}" stepKey="seeAssertCustomerDefaultBillingAddressFirstnameAndLastname"/>
126126
<see selector="{{StorefrontCustomerAddressesSection.defaultBillingAddress}}" userInput="{{address.company}}" stepKey="seeAssertCustomerDefaultBillingAddressCompany"/>
@@ -139,7 +139,7 @@
139139
<argument name="address"/>
140140
</arguments>
141141

142-
<amOnPage url="customer/address/index/" stepKey="goToAddressPage"/>
142+
<amOnPage url="{{StorefrontCustomerAddressesPage.url}}" stepKey="goToAddressPage"/>
143143
<waitForPageLoad stepKey="waitForAddressPageLoad"/>
144144
<!--Verify customer default shipping address-->
145145
<see selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" userInput="{{address.firstname}} {{address.lastname}}" stepKey="seeAssertCustomerDefaultShippingAddressFirstnameAndLastname"/>
@@ -159,7 +159,7 @@
159159
<argument name="address"/>
160160
</arguments>
161161

162-
<amOnPage url="customer/address/index/" stepKey="goToAddressPage"/>
162+
<amOnPage url="{{StorefrontCustomerAddressesPage.url}}" stepKey="goToAddressPage"/>
163163
<waitForPageLoad stepKey="waitForAddressPageLoad"/>
164164

165165
<!--Verify customer default billing address-->
@@ -180,7 +180,7 @@
180180
<argument name="address"/>
181181
</arguments>
182182

183-
<amOnPage url="customer/address/index/" stepKey="goToAddressPage"/>
183+
<amOnPage url="{{StorefrontCustomerAddressesPage.url}}" stepKey="goToAddressPage"/>
184184
<waitForPageLoad stepKey="waitForAddressPageLoad"/>
185185

186186
<!--Verify customer default shipping address-->
@@ -202,7 +202,7 @@
202202
</arguments>
203203

204204
<!--Verify customer name on frontend-->
205-
<amOnPage url="customer/account/edit/" stepKey="goToAddressPage"/>
205+
<amOnPage url="{{StorefrontCustomerEditPage.url}}" stepKey="goToAddressPage"/>
206206
<waitForPageLoad stepKey="waitForAddressPageLoad"/>
207207
<click selector="{{StorefrontCustomerSidebarSection.sidebarCurrentTab('Account Information')}}" stepKey="clickAccountInformationFromSidebarCurrentTab"/>
208208
<waitForPageLoad stepKey="waitForAccountInformationTabToOpen"/>

app/code/Magento/Directory/etc/db_schema.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
</table>
4646
<table name="directory_country_region_name" resource="default" engine="innodb"
4747
comment="Directory Country Region Name">
48-
<column xsi:type="varchar" name="locale" nullable="false" length="8" comment="Locale"/>
48+
<column xsi:type="varchar" name="locale" nullable="false" length="16" comment="Locale"/>
4949
<column xsi:type="int" name="region_id" padding="10" unsigned="true" nullable="false" identity="false"
5050
default="0" comment="Region ID"/>
5151
<column xsi:type="varchar" name="name" nullable="true" length="255" comment="Region Name"/>

app/code/Magento/Downloadable/Test/Unit/Helper/DownloadTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
*/
1818
class DownloadTest extends \PHPUnit\Framework\TestCase
1919
{
20+
/** @var array Result of get_headers() function */
21+
public static $headers;
22+
2023
/** @var DownloadHelper */
2124
protected $_helper;
2225

@@ -230,6 +233,7 @@ protected function _setupUrlMocks($size = self::FILE_SIZE, $url = self::URL, $ad
230233
$this->returnValue($this->_handleMock)
231234
);
232235

236+
self::$headers = ['200 OK'];
233237
$this->_helper->setResource($url, DownloadHelper::LINK_TYPE_URL);
234238
}
235239

app/code/Magento/Downloadable/Test/Unit/_files/download_mock.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,13 @@ function mime_content_type()
2222
{
2323
return DownloadTest::$mimeContentType;
2424
}
25+
26+
/**
27+
* Override standard function
28+
*
29+
* @return array
30+
*/
31+
function get_headers()
32+
{
33+
return DownloadTest::$headers;
34+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\GiftMessage\Model\Plugin;
9+
10+
use Magento\Framework\Exception\NoSuchEntityException;
11+
use Magento\GiftMessage\Api\OrderItemRepositoryInterface as GiftMessageItemRepositoryInterface;
12+
use Magento\Sales\Api\Data\OrderItemExtensionFactory;
13+
use Magento\Sales\Api\Data\OrderItemInterface;
14+
use Magento\Sales\Api\OrderItemRepositoryInterface;
15+
16+
/**
17+
* Plugin for adding gift message to order item
18+
*/
19+
class OrderItemGet
20+
{
21+
22+
/**
23+
* @var OrderItemExtensionFactory
24+
*/
25+
private $orderItemExtensionFactory;
26+
27+
/**
28+
* @var GiftMessageItemRepositoryInterface
29+
*/
30+
private $giftMessageItemRepository;
31+
32+
/**
33+
* OrderItemGet constructor.
34+
*
35+
* @param GiftMessageItemRepositoryInterface $giftMessageItemRepository
36+
* @param OrderItemExtensionFactory $orderItemExtensionFactory
37+
*/
38+
public function __construct(
39+
GiftMessageItemRepositoryInterface $giftMessageItemRepository,
40+
OrderItemExtensionFactory $orderItemExtensionFactory
41+
) {
42+
$this->giftMessageItemRepository = $giftMessageItemRepository;
43+
$this->orderItemExtensionFactory = $orderItemExtensionFactory;
44+
}
45+
46+
/**
47+
* Add gift message for order item
48+
*
49+
* @param OrderItemRepositoryInterface $subject
50+
* @param OrderItemInterface $orderItem
51+
* @return OrderItemInterface
52+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
53+
*/
54+
public function afterGet(OrderItemRepositoryInterface $subject, OrderItemInterface $orderItem)
55+
{
56+
$extensionAttributes = $orderItem->getExtensionAttributes();
57+
if ($extensionAttributes && $extensionAttributes->getGiftMessage()) {
58+
return $orderItem;
59+
}
60+
try {
61+
/* @var \Magento\GiftMessage\Api\Data\MessageInterface $giftMessage */
62+
$giftMessage = $this->giftMessageItemRepository->get(
63+
$orderItem->getOrderId(),
64+
$orderItem->getItemId()
65+
);
66+
} catch (NoSuchEntityException $e) {
67+
return $orderItem;
68+
}
69+
/** @var \Magento\Sales\Api\Data\OrderItemExtension $orderItemExtension */
70+
$orderItemExtension = $extensionAttributes ?: $this->orderItemExtensionFactory->create();
71+
$orderItemExtension->setGiftMessage($giftMessage);
72+
$orderItem->setExtensionAttributes($orderItemExtension);
73+
74+
return $orderItem;
75+
}
76+
}

app/code/Magento/GiftMessage/etc/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@
3737
</argument>
3838
</arguments>
3939
</type>
40+
<type name="Magento\Sales\Api\OrderItemRepositoryInterface">
41+
<plugin name="get_gift_message" type="Magento\GiftMessage\Model\Plugin\OrderItemGet"/>
42+
</type>
4043
</config>

0 commit comments

Comments
 (0)