Skip to content

Commit 440162d

Browse files
committed
Merge branch 'ACP2E-2950' of https://github.com/adobe-commerce-tier-4/magento2ce into 04-29-24-Tier4-Bugfix-Delivery
2 parents 8a4d812 + 59a6175 commit 440162d

File tree

4 files changed

+177
-4
lines changed

4 files changed

+177
-4
lines changed

app/code/Magento/Bundle/Model/Quote/Item/Option.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use Magento\Bundle\Model\Product\Price;
1111
use Magento\Bundle\Model\Product\Type;
1212
use Magento\Catalog\Model\Product;
13+
use Magento\Framework\App\ObjectManager;
14+
use Magento\Framework\Pricing\PriceCurrencyInterface;
1315
use Magento\Framework\Serialize\Serializer\Json;
1416

1517
/**
@@ -22,13 +24,21 @@ class Option
2224
*/
2325
private $serializer;
2426

27+
/**
28+
* @var PriceCurrencyInterface
29+
*/
30+
private $priceCurrency;
31+
2532
/**
2633
* @param Json $serializer
34+
* @param PriceCurrencyInterface $priceCurrency
2735
*/
2836
public function __construct(
29-
Json $serializer
37+
Json $serializer,
38+
?PriceCurrencyInterface $priceCurrency = null,
3039
) {
3140
$this->serializer = $serializer;
41+
$this->priceCurrency = $priceCurrency ?? ObjectManager::getInstance()->get(PriceCurrencyInterface::class);
3242
}
3343

3444
/**
@@ -83,7 +93,7 @@ private function getBundleSelectionAttributes(Product $product, Product $selecti
8393
'code' => 'bundle_selection_attributes',
8494
'value'=> $this->serializer->serialize(
8595
[
86-
'price' => $price,
96+
'price' => $this->priceCurrency->convert($price, $product->getStore()),
8797
'qty' => $qty,
8898
'option_label' => $bundleOption->getTitle(),
8999
'option_id' => $bundleOption->getId(),

app/code/Magento/Bundle/Test/Unit/Model/Quote/Item/OptionTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Magento\Catalog\Model\Product;
1717
use Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface;
1818
use Magento\Framework\Serialize\Serializer\Json;
19+
use Magento\Framework\Pricing\PriceCurrencyInterface;
1920
use PHPUnit\Framework\TestCase;
2021

2122
/**
@@ -34,8 +35,14 @@ class OptionTest extends TestCase
3435
protected function setUp(): void
3536
{
3637
parent::setUp();
38+
$priceCurrency = $this->createMock(PriceCurrencyInterface::class);
39+
40+
$priceCurrency->method('convert')
41+
->willReturnArgument(0);
42+
3743
$this->model = new Option(
38-
new Json()
44+
new Json(),
45+
$priceCurrency
3946
);
4047
}
4148

@@ -48,7 +55,7 @@ public function testGetSelectionOptions(array $customOptions, array $expected):
4855
{
4956
$bundleProduct = $this->getMockBuilder(Product::class)
5057
->disableOriginalConstructor()
51-
->onlyMethods(['getTypeInstance', 'getPriceModel'])
58+
->onlyMethods(['getTypeInstance', 'getPriceModel', 'getStore'])
5259
->getMock();
5360

5461
$typeInstance = $this->createMock(Type::class);

app/code/Magento/Sales/Test/Mftf/Section/StorefrontOrderDetailsSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<element name="paymentMethod" type="text" selector=".box-order-billing-method dt.title"/>
2121
<element name="shippingMethod" type="text" selector=".box-order-shipping-method div.box-content"/>
2222
<element name="productNameCell" type="text" selector="//*[contains(@class, 'product-item-name')]"/>
23+
<element name="bundleOptionPrice" type="text" selector=".item-options-container td.col.value span.price"/>
2324
<element name="shippingAddressBlock" type="block" selector=".block-order-details-view .box-order-shipping-address .box-content"/>
2425
</section>
2526
</sections>
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/************************************************************************
4+
*
5+
* Copyright 2024 Adobe
6+
* All Rights Reserved.
7+
*
8+
* NOTICE: All information contained herein is, and remains
9+
* the property of Adobe and its suppliers, if any. The intellectual
10+
* and technical concepts contained herein are proprietary to Adobe
11+
* and its suppliers and are protected by all applicable intellectual
12+
* property laws, including trade secret and copyright laws.
13+
* Dissemination of this information or reproduction of this material
14+
* is strictly forbidden unless prior written permission is obtained
15+
* from Adobe.
16+
* ************************************************************************
17+
*/
18+
-->
19+
20+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
22+
<test name="StorefrontCheckBundleOptionPriceInOtherCurrencyGuestTest">
23+
<annotations>
24+
<stories value="Order bundle"/>
25+
<title value="Bundle option price in order on Storefront"/>
26+
<description value="Checks bundle option price in other currency in order on Storefront"/>
27+
<severity value="MAJOR"/>
28+
<testCaseId value="AC-11749"/>
29+
<useCaseId value="ACP2E-2950"/>
30+
</annotations>
31+
<before>
32+
<!-- Set currency -->
33+
<magentoCLI command="config:set currency/options/allow EUR,PLN,USD" stepKey="setCurrencyAllow"/>
34+
<magentoCLI command="config:set currency/options/default PLN" stepKey="setCurrencyDisplay"/>
35+
36+
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/>
37+
38+
<actionGroup ref="AdminOpenCurrencyRatesPageActionGroup" stepKey="gotToCurrencyRatesPage"/>
39+
<actionGroup ref="AdminSetCurrencyRatesActionGroup" stepKey="setCurrencyRate">
40+
<argument name="firstCurrency" value="USD"/>
41+
<argument name="secondCurrency" value="PLN"/>
42+
<argument name="rate" value="5"/>
43+
</actionGroup>
44+
45+
<!-- Create Category -->
46+
<createData entity="ApiCategory" stepKey="createCategory"/>
47+
48+
<!-- Create bundle Product -->
49+
<createData entity="SimpleSubCategory" stepKey="createSubCategory"/>
50+
<createData entity="SimpleProduct2" stepKey="simpleProduct1">
51+
<field key="price">100.00</field>
52+
</createData>
53+
<createData entity="SimpleProduct2" stepKey="simpleProduct2">
54+
<field key="price">560.00</field>
55+
</createData>
56+
<createData entity="BundleProductPriceViewRange" stepKey="createBundleProduct">
57+
<requiredEntity createDataKey="createSubCategory"/>
58+
</createData>
59+
<createData entity="DropDownBundleOption" stepKey="createBundleOption1_1">
60+
<requiredEntity createDataKey="createBundleProduct"/>
61+
<field key="required">True</field>
62+
</createData>
63+
<createData entity="ApiBundleLink" stepKey="linkOptionToProduct">
64+
<requiredEntity createDataKey="createBundleProduct"/>
65+
<requiredEntity createDataKey="createBundleOption1_1"/>
66+
<requiredEntity createDataKey="simpleProduct1"/>
67+
</createData>
68+
<createData entity="ApiBundleLink" stepKey="linkOptionToProduct2">
69+
<requiredEntity createDataKey="createBundleProduct"/>
70+
<requiredEntity createDataKey="createBundleOption1_1"/>
71+
<requiredEntity createDataKey="simpleProduct2"/>
72+
</createData>
73+
74+
<!-- Grab bundle option name for Bundle Product -->
75+
<actionGroup ref="NavigateToCreatedProductEditPageActionGroup" stepKey="goToBundleProduct">
76+
<argument name="product" value="$createBundleProduct$"/>
77+
</actionGroup>
78+
<grabTextFrom selector="{{AdminProductFormBundleSection.currentBundleOption}}" stepKey="grabBundleOption"/>
79+
<assertNotEmpty stepKey="assertBundleOptionNotEmpty">
80+
<actualResult type="const">$grabBundleOption</actualResult>
81+
</assertNotEmpty>
82+
83+
<actionGroup ref="AdminClearFiltersActionGroup" stepKey="clearProductGridFilters"/>
84+
85+
<!-- Create Customer Account -->
86+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
87+
88+
<!-- Place order with bundle -->
89+
<actionGroup ref="AdminNavigateToNewOrderPageExistingCustomerActionGroup" stepKey="newOrder">
90+
<argument name="customer" value="$createCustomer$"/>
91+
</actionGroup>
92+
93+
<actionGroup ref="AdminFilterProductInCreateOrderActionGroup" stepKey="filterBundleProduct">
94+
<argument name="productSKU" value="$createBundleProduct.sku$"/>
95+
</actionGroup>
96+
<actionGroup ref="AdminAddToOrderBundleProductActionGroup" stepKey="addBundleProduct">
97+
<argument name="option" value="{$grabBundleOption}"/>
98+
<argument name="selectedProductName" value="$simpleProduct1.name$"/>
99+
<argument name="quantity" value="2"/>
100+
</actionGroup>
101+
102+
<actionGroup ref="FillOrderCustomerInformationActionGroup" stepKey="fillOrder">
103+
<argument name="customer" value="$createCustomer$"/>
104+
<argument name="address" value="US_Address_TX"/>
105+
</actionGroup>
106+
107+
<actionGroup ref="OrderSelectFlatRateShippingActionGroup" stepKey="selectFlatRate"/>
108+
<actionGroup ref="SelectCheckMoneyPaymentMethodActionGroup" stepKey="selectCheckMoneyPayment"/>
109+
</before>
110+
<after>
111+
<deleteData createDataKey="createSubCategory" stepKey="deleteCategory1"/>
112+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
113+
114+
<deleteData createDataKey="simpleProduct1" stepKey="deleteProduct1"/>
115+
<deleteData createDataKey="simpleProduct2" stepKey="deleteProduct2"/>
116+
<deleteData createDataKey="createBundleProduct" stepKey="deleteBundleProduct"/>
117+
118+
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutCustomer" />
119+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
120+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
121+
122+
<magentoCLI command="config:set currency/options/default USD" stepKey="unsetCurrencyDisplay"/>
123+
<magentoCLI command="config:set currency/options/allow EUR,USD" stepKey="unsetCurrencyAllow"/>
124+
</after>
125+
126+
<!-- Submit the Order -->
127+
<actionGroup ref="AdminSubmitOrderActionGroup" stepKey="submitOrder"/>
128+
129+
<grabTextFrom selector="|Order # (\d+)|" stepKey="orderNumber"/>
130+
<grabFromCurrentUrl regex="~/order_id/(\d+)/~" stepKey="orderId"/>
131+
<assertNotEmpty stepKey="assertOrderIdIsNotEmpty">
132+
<actualResult type="const">$orderNumber</actualResult>
133+
</assertNotEmpty>
134+
135+
<!-- Find the Order on frontend > Navigate to: Orders and Returns -->
136+
<amOnPage url="{{StorefrontGuestOrderSearchPage.url}}" stepKey="amOnOrdersAndReturns"/>
137+
<waitForPageLoad stepKey="waiForStorefrontPage"/>
138+
139+
<!-- Fill the form with correspondent Order data -->
140+
<actionGroup ref="StorefrontFillOrdersAndReturnsFormActionGroup" stepKey="fillOrder">
141+
<argument name="orderNumber" value="{$orderNumber}"/>
142+
<argument name="customer" value="$createCustomer$"/>
143+
</actionGroup>
144+
145+
<!-- Click on the "Continue" button -->
146+
<click selector="{{StorefrontGuestOrderSearchSection.continue}}" stepKey="clickContinue"/>
147+
<waitForPageLoad stepKey="waitForPageLoad"/>
148+
149+
<!-- Assert Bundle Options Price -->
150+
<see userInput="PLN 500.00" selector="{{StorefrontOrderDetailsSection.bundleOptionPrice}}" stepKey="seeBundleOptionPrice"/>
151+
152+
<!-- Assert Order Grand Total -->
153+
<see userInput="PLN 1,050.00" selector="{{StorefrontOrderDetailsSection.grandTotalPrice}}" stepKey="assertSalesOrderGrandTotal"/>
154+
</test>
155+
</tests>

0 commit comments

Comments
 (0)