-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3492 from magento-tsg/2.2-develop-pr59
[TSG] Backporting for 2.2 (pr59) (2.2.8)
- Loading branch information
Showing
27 changed files
with
434 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
app/code/Magento/Bundle/Model/Plugin/UpdatePriceInQuoteItemOptions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Bundle\Model\Plugin; | ||
|
||
use Magento\Quote\Model\Quote\Item as OrigQuoteItem; | ||
use Magento\Quote\Model\Quote\Item\AbstractItem; | ||
use Magento\Framework\Serialize\SerializerInterface; | ||
|
||
/** | ||
* Update prices stored in quote item options after calculating quote item's totals. | ||
*/ | ||
class UpdatePriceInQuoteItemOptions | ||
{ | ||
/** | ||
* @var SerializerInterface | ||
*/ | ||
private $serializer; | ||
|
||
/** | ||
* @param SerializerInterface $serializer | ||
*/ | ||
public function __construct(SerializerInterface $serializer) | ||
{ | ||
$this->serializer = $serializer; | ||
} | ||
|
||
/** | ||
* Update price on quote item options level | ||
* | ||
* @param OrigQuoteItem $subject | ||
* @param AbstractItem $result | ||
* @return AbstractItem | ||
* | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function afterCalcRowTotal(OrigQuoteItem $subject, AbstractItem $result): AbstractItem | ||
{ | ||
$bundleAttributes = $result->getProduct()->getCustomOption('bundle_selection_attributes'); | ||
if ($bundleAttributes !== null) { | ||
$actualAmount = $result->getPrice() * $result->getQty(); | ||
$parsedValue = $this->serializer->unserialize($bundleAttributes->getValue()); | ||
if (is_array($parsedValue) && array_key_exists('price', $parsedValue)) { | ||
$parsedValue['price'] = $actualAmount; | ||
} | ||
$bundleAttributes->setValue($this->serializer->serialize($parsedValue)); | ||
} | ||
|
||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
app/code/Magento/Bundle/Test/Mftf/Test/CurrencyChangingBundleProductInCartTest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> | ||
<test name="CurrencyChangingBundleProductInCartTest"> | ||
<annotations> | ||
<features value="Bundle"/> | ||
<stories value="MAGETWO-90381: Bundle product price doubled when switching currency"/> | ||
<title value="Work of currency changing with a bundle product added to the cart"/> | ||
<description value="User should be able change the currency and add one more product in cart and get right price in previous currency"/> | ||
<severity value="MAJOR"/> | ||
<testCaseId value="MAGETWO-96305"/> | ||
<group value="Bundle"/> | ||
</annotations> | ||
<before> | ||
<actionGroup ref="LoginAsAdmin" stepKey="login" /> | ||
<createData entity="CurrencySettingWithEuroAndUSD" stepKey="configureCurrencyOptions"/> | ||
<createData entity="_defaultCategory" stepKey="createPreReqCategory"/> | ||
<createData entity="SimpleProduct" stepKey="createPreReqSimpleProduct1"> | ||
<requiredEntity createDataKey="createPreReqCategory"/> | ||
</createData> | ||
<createData entity="SimpleProduct2" stepKey="createPreReqSimpleProduct2"> | ||
<requiredEntity createDataKey="createPreReqCategory"/> | ||
</createData> | ||
</before> | ||
<after> | ||
<deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/> | ||
<deleteData createDataKey="createPreReqSimpleProduct1" stepKey="deletePreReqSimpleProduct1"/> | ||
<deleteData createDataKey="createPreReqSimpleProduct2" stepKey="deletePreReqSimpleProduct2"/> | ||
<createData entity="DefaultCurrencySetting" stepKey="restoreCurrencyOptions"/> | ||
<!-- Delete the bundled product --> | ||
<actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteProductOnProductsGridPageByName"> | ||
<argument name="product" value="BundleProduct"/> | ||
</actionGroup> | ||
<!--Clear Configs--> | ||
<actionGroup ref="logout" stepKey="logout"/> | ||
</after> | ||
<!-- Navigate to the Products>Inventory>Catalog --> | ||
<!-- Click on "+" dropdown and select Bundle Product type --> | ||
<actionGroup ref="OpenNewBundleProductPage" stepKey="openNewBundleProductPage"/> | ||
<!-- Add Option, a "Radio Buttons" type option --> | ||
<actionGroup ref="CreateBundleProductForTwoSimpleProductsWithRadioTypeOptions" stepKey="addBundleOptionWithTwoProducts2"> | ||
<argument name="bundleProduct" value="BundleProduct"/> | ||
<argument name="simpleProductFirst" value="$$createPreReqSimpleProduct1$$"/> | ||
<argument name="simpleProductSecond" value="$$createPreReqSimpleProduct2$$"/> | ||
</actionGroup> | ||
<!-- Save product --> | ||
<actionGroup ref="SaveProductOnProductPageOnAdmin" stepKey="saveProductOnProductPageOnAdmin"/> | ||
<!-- Go to storefront BundleProduct --> | ||
<amOnPage url="{{StorefrontProductPage.url(BundleProduct.name)}}" stepKey="goToStorefrontProductPage"/> | ||
<waitForPageLoad stepKey="waitForStorefrontProductPage"/> | ||
<actionGroup ref="StoreFrontAddProductToCartFromBundleWithCurrencyActionGroup" stepKey="addProduct1ToCartAndChangeCurrencyToEuro"> | ||
<argument name="product" value="$$createPreReqSimpleProduct1$$"/> | ||
<argument name="currency" value="EUR - Euro"/> | ||
</actionGroup> | ||
<actionGroup ref="StoreFrontAddProductToCartFromBundleWithCurrencyActionGroup" stepKey="addProduct2ToCartAndChangeCurrencyToUSD"> | ||
<argument name="product" value="$$createPreReqSimpleProduct1$$"/> | ||
<argument name="currency" value="USD - US Dollar"/> | ||
</actionGroup> | ||
<click selector="{{StorefrontMinicartSection.showCart}}" stepKey="openMiniCart"/> | ||
<waitForPageLoad stepKey="waitForMiniCart"/> | ||
<see selector="{{StorefrontMinicartSection.miniCartSubtotalField}}" userInput="$4,000.00" stepKey="seeCartSubtotal"/> | ||
</test> | ||
</tests> |
Oops, something went wrong.