-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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 #8311 from magento-l3/PR-05242023
L3- PR 05242023
- Loading branch information
Showing
34 changed files
with
905 additions
and
80 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
102 changes: 102 additions & 0 deletions
102
app/code/Magento/Bundle/Test/Mftf/Test/AdminAddDecimalDefaultToBundleItemsTest.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,102 @@ | ||
<?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="AdminAddDecimalDefaultToBundleItemsTest"> | ||
<annotations> | ||
<features value="Bundle"/> | ||
<stories value="Create/Edit bundle product in Admin"/> | ||
<title value="Admin should be able to set decimal default to bundle item when item allows it"/> | ||
<description value="Admin should be able to set decimal default value to new bundle option"/> | ||
<severity value="AVERAGE"/> | ||
<testCaseId value="AC-8646"/> | ||
<useCaseId value="ACP2E-1799"/> | ||
<group value="Bundle"/> | ||
</annotations> | ||
<before> | ||
<createData entity="_defaultCategory" stepKey="createPreReqCategory"/> | ||
<createData entity="SimpleProduct2" stepKey="simpleProduct1"/> | ||
<createData entity="SimpleProduct2" stepKey="simpleProduct2"/> | ||
<actionGroup stepKey="loginToAdminPanel" ref="AdminLoginActionGroup"/> | ||
</before> | ||
<after> | ||
<deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/> | ||
<deleteData createDataKey="simpleProduct1" stepKey="deleteSimpleProduct1"/> | ||
<deleteData createDataKey="simpleProduct2" stepKey="deleteSimpleProduct2"/> | ||
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="navigateToProductIndex"/> | ||
<actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="clearFilters"/> | ||
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> | ||
</after> | ||
|
||
<!-- Open simpleProduct1 in Admin --> | ||
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="filterSimpleProduct1"> | ||
<argument name="product" value="SimpleProduct2"/> | ||
</actionGroup> | ||
<click selector="{{AdminProductGridSection.productGridNameProduct('$$simpleProduct1.name$$')}}" stepKey="clickOpenProductForEdit"/> | ||
<waitForPageLoad time="30" stepKey="waitForProductEditOpen"/> | ||
<!-- Open *Advanced Inventory* pop-up (Click on *Advanced Inventory* link). Set *Qty Uses Decimals* to *Yes*. Click on button *Done* --> | ||
<actionGroup ref="AdminClickOnAdvancedInventoryLinkActionGroup" stepKey="clickOnAdvancedInventoryLink"/> | ||
<actionGroup ref="AdminSetQtyUsesDecimalsConfigActionGroup" stepKey="setQtyUsesDecimalsConfig"> | ||
<argument name="value" value="Yes"/> | ||
</actionGroup> | ||
<actionGroup ref="AdminSubmitAdvancedInventoryFormActionGroup" stepKey="clickOnDoneButton"/> | ||
<actionGroup ref="AdminProductFormSaveActionGroup" stepKey="clickOnSaveButton"/> | ||
|
||
<!-- Create new Bundle product --> | ||
<actionGroup ref="AdminOpenCreateBundleProductPageActionGroup" stepKey="goToBundleProductCreationPage"/> | ||
<actionGroup ref="AdminClickAddOptionOnBundleProductEditPageActionGroup" stepKey="clickAddOption1"/> | ||
<actionGroup ref="AdminFillBundleOptionTitleActionGroup" stepKey="fillOptionTitle"> | ||
<argument name="optionTitle" value="{{BundleProduct.optionTitle1}}"/> | ||
</actionGroup> | ||
<actionGroup ref="AdminFillBundleOptionTypeActionGroup" stepKey="selectInputType"/> | ||
|
||
<actionGroup ref="AdminClickAddProductToOptionByOptionIndexActionGroup" stepKey="clickAddProductsToOption"/> | ||
<actionGroup ref="FilterProductGridBySkuActionGroup" stepKey="filterBundleProductOptions"> | ||
<argument name="product" value="$$simpleProduct1$$"/> | ||
</actionGroup> | ||
<actionGroup ref="AdminCheckFirstCheckboxInAddProductsToOptionPanelGridActionGroup" stepKey="selectFirstGridRow"/> | ||
<actionGroup ref="FilterProductGridBySkuActionGroup" stepKey="filterBundleProductOptions2"> | ||
<argument name="product" value="$$simpleProduct2$$"/> | ||
</actionGroup> | ||
<actionGroup ref="AdminCheckFirstCheckboxInAddProductsToOptionPanelGridActionGroup" stepKey="selectFirstGridRow2"/> | ||
<actionGroup ref="AdminClickAddSelectedProductsOnAddProductsToOptionPanelActionGroup" stepKey="clickAddSelectedBundleProducts"/> | ||
|
||
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" stepKey="grabbedFirstBundleOptionQuantity"/> | ||
<assertEquals stepKey="assertFirstBundleOptionDefaultQuantity"> | ||
<expectedResult type="string">1</expectedResult> | ||
<actualResult type="string">$grabbedFirstBundleOptionQuantity</actualResult> | ||
</assertEquals> | ||
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" stepKey="grabbedSecondBundleOptionQuantity"/> | ||
<assertEquals stepKey="assertSecondBundleOptionDefaultQuantity"> | ||
<expectedResult type="string">1</expectedResult> | ||
<actualResult type="string">$grabbedSecondBundleOptionQuantity</actualResult> | ||
</assertEquals> | ||
|
||
<!-- Fill first selection with decimal value --> | ||
<actionGroup ref="AdminFillBundleItemQtyActionGroup" stepKey="fillProduct1DefaultQty"> | ||
<argument name="optionIndex" value="0"/> | ||
<argument name="productIndex" value="0"/> | ||
<argument name="qty" value="2.56"/> | ||
</actionGroup> | ||
|
||
<!-- Check there is no error message for the slection with allowed decimal value --> | ||
<dontSee selector="{{AdminProductFormBundleSection.fieldError('uid')}}" userInput="Please enter a valid number in this field." stepKey="doNotSeeErrorMessageForProduct1"/> | ||
|
||
<!-- Fill second selection with decimal value --> | ||
<actionGroup ref="AdminFillBundleItemQtyActionGroup" stepKey="fillProduct2DefaultQty"> | ||
<argument name="optionIndex" value="0"/> | ||
<argument name="productIndex" value="1"/> | ||
<argument name="qty" value="2.56"/> | ||
</actionGroup> | ||
|
||
<!-- Check there is an error message for the slection with not allowed decimal value --> | ||
<see selector="{{AdminProductFormBundleSection.fieldError('uid')}}" userInput="Please enter a valid number in this field." stepKey="seeErrorMessageForProduct2"/> | ||
|
||
</test> | ||
</tests> |
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
76 changes: 76 additions & 0 deletions
76
...agento/Bundle/Ui/DataProvider/Product/Form/Modifier/AddSelectionQtyTypeToProductsData.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,76 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Bundle\Ui\DataProvider\Product\Form\Modifier; | ||
|
||
use Magento\Framework\App\ObjectManager; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\Ui\DataProvider\Modifier\ModifierInterface; | ||
use Magento\CatalogInventory\Model\StockRegistryPreloader; | ||
|
||
/** | ||
* Affects Qty field for newly added selection | ||
*/ | ||
class AddSelectionQtyTypeToProductsData implements ModifierInterface | ||
{ | ||
/** | ||
* @var StockRegistryPreloader | ||
*/ | ||
private StockRegistryPreloader $stockRegistryPreloader; | ||
|
||
/** | ||
* Initializes dependencies | ||
* | ||
* @param StockRegistryPreloader $stockRegistryPreloader | ||
*/ | ||
public function __construct(StockRegistryPreloader $stockRegistryPreloader) | ||
{ | ||
$this->stockRegistryPreloader = $stockRegistryPreloader; | ||
} | ||
|
||
/** | ||
* Modify Meta | ||
* | ||
* @param array $meta | ||
* @return array | ||
*/ | ||
public function modifyMeta(array $meta) | ||
{ | ||
return $meta; | ||
} | ||
|
||
/** | ||
* Modify Data - checks if new selection can have decimal quantity | ||
* | ||
* @param array $data | ||
* @return array | ||
* @throws NoSuchEntityException | ||
*/ | ||
public function modifyData(array $data): array | ||
{ | ||
$productIds = array_column($data['items'], 'entity_id'); | ||
|
||
$stockItems = []; | ||
if ($productIds) { | ||
$stockItems = $this->stockRegistryPreloader->preloadStockItems($productIds); | ||
} | ||
|
||
$isQtyDecimals = []; | ||
foreach ($stockItems as $stockItem) { | ||
$isQtyDecimals[$stockItem->getProductId()] = $stockItem->getIsQtyDecimal(); | ||
} | ||
|
||
foreach ($data['items'] as &$item) { | ||
if (isset($isQtyDecimals[$item['entity_id']])) { | ||
$item['selection_qty_is_integer'] = !$isQtyDecimals[$item['entity_id']]; | ||
} | ||
} | ||
|
||
return $data; | ||
} | ||
} |
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
Oops, something went wrong.