Skip to content

Commit

Permalink
Merge branch '2.4-develop' into bugfix/issue-12584
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel da Gama committed Jan 22, 2021
2 parents 88ea963 + 00a70ec commit dc3226b
Show file tree
Hide file tree
Showing 183 changed files with 6,316 additions and 648 deletions.
5 changes: 3 additions & 2 deletions .github/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ staleLabel: "stale issue"
# Comment to post when marking as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed after 14 days if no further activity occurs. Thank you
for your contributions.
recent activity. It will be closed after 14 days if no further activity occurs.
Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
Thank you for your contributions!
# Comment to post when removing the stale label.
# unmarkComment: >
# Your comment here.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?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="AwsS3AdminImportSimpleAndConfigurableProductsWithAssignedImagesTest" extends="AdminImportSimpleAndConfigurableProductsWithAssignedImagesTest">
<annotations>
<features value="AwsS3"/>
<stories value="Import Products"/>
<title value="S3 - Import Configurable Product With Simple Child Products With Images"/>
<description value="Imports a .csv file containing a configurable product with 3 child simple products that
have images. Verifies that products are imported successfully and that the images are attached to the
products as expected."/>
<severity value="MAJOR"/>
<group value="importExport"/>
<group value="remote_storage_aws_s3"/>
<skip>
<issueId value="MC-39280"/>
</skip>
</annotations>

<before>
<!-- Enable AWS S3 Remote Storage -->
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.enable_options}}" stepKey="enableRemoteStorage"/>
</before>

<after>
<!-- Disable AWS S3 Remote Storage -->
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage"/>
</after>
</test>
</tests>
39 changes: 27 additions & 12 deletions app/code/Magento/Backend/Controller/Adminhtml/System/Store/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
namespace Magento\Backend\Controller\Adminhtml\System\Store;

use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Store\Model\Group as StoreGroup;
use Magento\Store\Model\Store;
use Magento\Framework\Exception\LocalizedException;

/**
* Class Save
Expand All @@ -33,6 +36,17 @@ private function processWebsiteSave($postData)
$websiteModel->setId(null);
}

$groupModel = $this->_objectManager->create(StoreGroup::class);
$groupModel->load($websiteModel->getDefaultGroupId());
$storeModel = $this->_objectManager->create(Store::class);
$storeModel->load($groupModel->getDefaultStoreId());

if ($websiteModel->getIsDefault() && !$storeModel->isActive()) {
throw new LocalizedException(
__('Please enable your Store View before using this Web Site as Default')
);
}

$websiteModel->save();
$this->messageManager->addSuccessMessage(__('You saved the website.'));

Expand All @@ -43,13 +57,13 @@ private function processWebsiteSave($postData)
* Process Store model save
*
* @param array $postData
* @throws \Magento\Framework\Exception\LocalizedException
* @throws LocalizedException
* @return array
*/
private function processStoreSave($postData)
{
/** @var \Magento\Store\Model\Store $storeModel */
$storeModel = $this->_objectManager->create(\Magento\Store\Model\Store::class);
/** @var Store $storeModel */
$storeModel = $this->_objectManager->create(Store::class);
$postData['store']['name'] = $this->filterManager->removeTags($postData['store']['name']);
if ($postData['store']['store_id']) {
$storeModel->load($postData['store']['store_id']);
Expand All @@ -59,13 +73,13 @@ private function processStoreSave($postData)
$storeModel->setId(null);
}
$groupModel = $this->_objectManager->create(
\Magento\Store\Model\Group::class
StoreGroup::class
)->load(
$storeModel->getGroupId()
);
$storeModel->setWebsiteId($groupModel->getWebsiteId());
if (!$storeModel->isActive() && $storeModel->isDefault()) {
throw new \Magento\Framework\Exception\LocalizedException(
throw new LocalizedException(
__('The default store cannot be disabled')
);
}
Expand All @@ -79,14 +93,14 @@ private function processStoreSave($postData)
* Process StoreGroup model save
*
* @param array $postData
* @throws \Magento\Framework\Exception\LocalizedException
* @throws LocalizedException
* @return array
*/
private function processGroupSave($postData)
{
$postData['group']['name'] = $this->filterManager->removeTags($postData['group']['name']);
/** @var \Magento\Store\Model\Group $groupModel */
$groupModel = $this->_objectManager->create(\Magento\Store\Model\Group::class);
/** @var StoreGroup $groupModel */
$groupModel = $this->_objectManager->create(StoreGroup::class);
if ($postData['group']['group_id']) {
$groupModel->load($postData['group']['group_id']);
}
Expand All @@ -95,10 +109,11 @@ private function processGroupSave($postData)
$groupModel->setId(null);
}
if (!$this->isSelectedDefaultStoreActive($postData, $groupModel)) {
throw new \Magento\Framework\Exception\LocalizedException(
throw new LocalizedException(
__('An inactive store view cannot be saved as default store view')
);
}

$groupModel->save();
$this->messageManager->addSuccessMessage(__('You saved the store.'));

Expand Down Expand Up @@ -135,7 +150,7 @@ public function execute()
}
$redirectResult->setPath('adminhtml/*/');
return $redirectResult;
} catch (\Magento\Framework\Exception\LocalizedException $e) {
} catch (LocalizedException $e) {
$this->messageManager->addErrorMessage($e->getMessage());
$this->_getSession()->setPostData($postData);
} catch (\Exception $e) {
Expand All @@ -156,10 +171,10 @@ public function execute()
* Verify if selected default store is active
*
* @param array $postData
* @param \Magento\Store\Model\Group $groupModel
* @param StoreGroup $groupModel
* @return bool
*/
private function isSelectedDefaultStoreActive(array $postData, \Magento\Store\Model\Group $groupModel)
private function isSelectedDefaultStoreActive(array $postData, StoreGroup $groupModel)
{
if (!empty($postData['group']['default_store_id'])) {
$defaultStoreId = $postData['group']['default_store_id'];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminClearGridFiltersActionGroup">
<annotations>
<description>Click the Clear filters on the grid.</description>
</annotations>

<click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters"/>
<waitForPageLoad stepKey="waitForPageLoaded"/>
</actionGroup>
</actionGroups>
1 change: 1 addition & 0 deletions app/code/Magento/Backend/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ System,System
"All Stores","All Stores"
"You saved the website.","You saved the website."
"The default store cannot be disabled","The default store cannot be disabled"
"Please enable your Store View before using this Web Site as Default","Please enable your Store View before using this Web Site as Default"
"You saved the store view.","You saved the store view."
"An inactive store view cannot be saved as default store view","An inactive store view cannot be saved as default store view"
"You saved the store.","You saved the store."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,6 @@ public function getJsonConfig()
$configValue = $preConfiguredValues->getData('bundle_option/' . $optionId);
if ($configValue) {
$defaultValues[$optionId] = $configValue;
$configQty = $preConfiguredValues->getData('bundle_option_qty/' . $optionId);
if ($configQty) {
$options[$optionId]['selections'][$configValue]['qty'] = $configQty;
}
}
$options = $this->processOptions($optionId, $options, $preConfiguredValues);
}
Expand Down
10 changes: 6 additions & 4 deletions app/code/Magento/Bundle/Model/CartItemProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritDoc
*/
public function convertToBuyRequest(CartItemInterface $cartItem)
{
Expand All @@ -73,7 +73,7 @@ public function convertToBuyRequest(CartItemInterface $cartItem)
}

/**
* {@inheritdoc}
* @inheritDoc
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function processOptions(CartItemInterface $cartItem)
Expand All @@ -84,19 +84,21 @@ public function processOptions(CartItemInterface $cartItem)
$productOptions = [];
$bundleOptions = $cartItem->getBuyRequest()->getBundleOption();
$bundleOptionsQty = $cartItem->getBuyRequest()->getBundleOptionQty();
$bundleOptionsQty = is_array($bundleOptionsQty) ? $bundleOptionsQty : [];
if (is_array($bundleOptions)) {
foreach ($bundleOptions as $optionId => $optionSelections) {
if (empty($optionSelections)) {
continue;
}
$optionSelections = is_array($optionSelections) ? $optionSelections : [$optionSelections];
$optionQty = isset($bundleOptionsQty[$optionId]) ? $bundleOptionsQty[$optionId] : 1;

/** @var \Magento\Bundle\Api\Data\BundleOptionInterface $productOption */
$productOption = $this->bundleOptionFactory->create();
$productOption->setOptionId($optionId);
$productOption->setOptionSelections($optionSelections);
$productOption->setOptionQty($optionQty);
if (isset($bundleOptionsQty[$optionId])) {
$productOption->setOptionQty($bundleOptionsQty[$optionId]);
}
$productOptions[] = $productOption;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminToggleSwitchDynamicPriceOnProductEditPageActionGroup">
<waitForElementVisible selector="{{AdminProductFormBundleSection.dynamicPriceToggle}}" stepKey="waitForToggleDynamicPrice"/>
<checkOption selector="{{AdminProductFormBundleSection.dynamicPriceToggle}}" stepKey="switchDynamicPriceToggle"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<!-- Test XML Example -->
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminBundleProductPriceValidationErrorDisappearedAfterSwitchToDynamicPriceTest">
<annotations>
<features value="Bundle"/>
<stories value="Create/Edit bundle product in Admin"/>
<title value="Assert error message for price field"/>
<description value="Verify error message for price field is not visible when toggle Dynamic Price is disabled"/>
<severity value="MAJOR"/>
<testCaseId value="MC-40309"/>
<useCaseId value="MC-30152"/>
<group value="bundle"/>
</annotations>

<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
</before>
<after>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
</after>

<actionGroup ref="AdminOpenNewProductFormPageActionGroup" stepKey="openNewBundleProductPage">
<argument name="productType" value="bundle"/>
</actionGroup>
<actionGroup ref="AdminToggleSwitchDynamicPriceOnProductEditPageActionGroup" stepKey="disableDynamicPrice"/>
<actionGroup ref="AdminFillProductPriceFieldAndPressEnterOnProductEditPageActionGroup" stepKey="fillProductPriceField">
<argument name="price" value="test"/>
</actionGroup>
<actionGroup ref="AssertAdminValidationErrorAppearedForPriceFieldOnProductEditPageActionGroup" stepKey="assertVisibleError">
<argument name="errorMessage" value="Please enter a number 0 or greater in this field."/>
</actionGroup>
<actionGroup ref="AdminToggleSwitchDynamicPriceOnProductEditPageActionGroup" stepKey="enableDynamicPrice"/>
<actionGroup ref="AssertAdminNoValidationErrorForPriceFieldOnProductEditPageActionGroup" stepKey="assertNotVisibleError"/>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ public function testGetJsonConfigFixedPriceBundleNoOption()

public function testGetJsonConfigFixedPriceBundle()
{
$optionId = 1;
$optionQty = 2;
$baseAmount = 123;
$basePriceValue = 123123;
$selections = [
Expand All @@ -230,7 +232,6 @@ public function testGetJsonConfigFixedPriceBundle()
true
)
];

$bundleProductPrice = $this->getMockBuilder(Price::class)
->disableOriginalConstructor()
->setMethods(['getLowestPrice'])
Expand All @@ -246,10 +247,8 @@ public function testGetJsonConfigFixedPriceBundle()
$this->bundleProductPriceFactory->expects($this->once())
->method('create')
->willReturn($bundleProductPrice);
$options = [$this->createOption($optionId, 'Title `1', $selections)];

$options = [
$this->createOption(1, 'Title `1', $selections),
];
$finalPriceMock = $this->getPriceMock(
[
'getPriceWithoutOption' => new DataObject(
Expand Down Expand Up @@ -289,7 +288,10 @@ public function testGetJsonConfigFixedPriceBundle()
$preconfiguredValues = new DataObject(
[
'bundle_option' => [
1 => 123123111,
$optionId => [123123111],
],
'bundle_option_qty' => [
$optionId => $optionQty,
],
]
);
Expand All @@ -306,7 +308,8 @@ public function testGetJsonConfigFixedPriceBundle()
$this->assertEquals(110, $jsonConfig['prices']['oldPrice']['amount']);
$this->assertEquals(100, $jsonConfig['prices']['basePrice']['amount']);
$this->assertEquals(100, $jsonConfig['prices']['finalPrice']['amount']);
$this->assertEquals([1], $jsonConfig['positions']);
$this->assertEquals([$optionId], $jsonConfig['positions']);
$this->assertEquals($optionQty, $jsonConfig['options'][$optionId]['selections'][1123]['qty']);
}

/**
Expand Down
Loading

0 comments on commit dc3226b

Please sign in to comment.