Skip to content

Commit

Permalink
Merge branch '2.4-develop-mainline' into upd-with-AdminOpenCMSPagesGr…
Browse files Browse the repository at this point in the history
…idActionGroup

# Conflicts:
#	app/code/Magento/Catalog/Test/Mftf/Test/AdminRequiredFieldsHaveRequiredFieldIndicatorTest.xml
#	app/code/Magento/Cms/Test/Mftf/Test/VerifyTinyMCEv4IsNativeWYSIWYGOnCMSPageTest.xml
#	app/code/Magento/Widget/Test/Mftf/Test/NewProductsListWidgetTest.xml
  • Loading branch information
engcom-Foxtrot committed Jan 15, 2021
2 parents 7aa992a + 3fef6d1 commit c375046
Show file tree
Hide file tree
Showing 191 changed files with 4,562 additions and 689 deletions.
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
Loading

0 comments on commit c375046

Please sign in to comment.