Skip to content

Commit

Permalink
Merge pull request #3876 from magento-arcticfoxes/pr
Browse files Browse the repository at this point in the history
[2.3.1-release] Bug Fixes
  • Loading branch information
joanhe authored Mar 9, 2019
2 parents e22cacb + 184b390 commit 079770a
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,6 @@ protected function modifyPriceData($object, $data)
/** @var \Magento\Catalog\Model\Product $object */
$data = parent::modifyPriceData($object, $data);
$price = $object->getPrice();

$specialPrice = $object->getSpecialPrice();
$specialPriceFromDate = $object->getSpecialFromDate();
$specialPriceToDate = $object->getSpecialToDate();
$today = time();

if ($specialPrice && ($object->getPrice() > $object->getFinalPrice())) {
if ($today >= strtotime($specialPriceFromDate) && $today <= strtotime($specialPriceToDate) ||
$today >= strtotime($specialPriceFromDate) && $specialPriceToDate === null) {
$price = $specialPrice;
}
}

foreach ($data as $key => $tierPrice) {
$percentageValue = $this->getPercentage($tierPrice);
if ($percentageValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,12 @@ public function getFields(array $context = []): array

$groups = $this->groupRepository->getList($searchCriteria)->getItems();
$priceAttribute = $this->attributeAdapterProvider->getByAttributeCode('price');
$ctx = isset($context['websiteId']) ? ['websiteId' => $context['websiteId']] : [];
foreach ($groups as $group) {
$ctx['customerGroupId'] = $group->getId();
$groupPriceKey = $this->fieldNameResolver->getFieldName(
$priceAttribute,
['customerGroupId' => $group->getId(), 'websiteId' => $context['websiteId']]
$ctx
);
$allAttributes[$groupPriceKey] = [
'type' => $this->fieldTypeConverter->convert(FieldTypeConverterInterface::INTERNAL_DATA_TYPE_FLOAT),
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Elasticsearch6/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
<type name="Magento\Search\Model\Search\PageSizeProvider">
<arguments>
<argument name="pageSizeBySearchEngine" xsi:type="array">
<item name="elasticsearch6" xsi:type="number">2147483647</item>
<item name="elasticsearch6" xsi:type="number">10000</item>
</argument>
</arguments>
</type>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ protected function _prepareForm()
$this->_addAttributesToForm($attributes, $fieldset);

$this->_form->addFieldNameSuffix('order[account]');
$storeId = (int)$this->_sessionQuote->getStoreId();
$this->_form->setValues($this->extractValuesFromAttributes($attributes, $storeId));
$this->_form->setValues($this->extractValuesFromAttributes($attributes));

return $this;
}
Expand Down Expand Up @@ -192,37 +191,18 @@ public function getFormValues()
* Extract the form values from attributes.
*
* @param array $attributes
* @param int $storeId
* @return array
*/
private function extractValuesFromAttributes(array $attributes, int $storeId): array
private function extractValuesFromAttributes(array $attributes): array
{
$formValues = $this->getFormValues();
foreach ($attributes as $code => $attribute) {
$defaultValue = $attribute->getDefaultValue();
if (isset($defaultValue) && !isset($formValues[$code])) {
$formValues[$code] = $defaultValue;
}
if ($code === 'group_id' && empty($defaultValue)) {
$formValues[$code] = $this->getDefaultCustomerGroup($storeId);
}
}

return $formValues;
}

/**
* Gets default customer group.
*
* @param int $storeId
* @return string|null
*/
private function getDefaultCustomerGroup(int $storeId): ?string
{
return $this->_scopeConfig->getValue(
'customer/create_account/default_group',
ScopeInterface::SCOPE_STORE,
$storeId
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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="AdminChangeCustomerGroupInNewOrder">
<annotations>
<title value="Customer account group cannot be selected while creating a new customer in order"/>
<stories value="MC-15290: Customer account group cannot be selected while creating a new customer in order"/>
<description value="Customer account group cannot be selected while creating a new customer in order"/>
<severity value="MAJOR"/>
<testCaseId value="MC-15290"/>
<useCaseId value="MC-15289"/>
<group value="sales"/>
</annotations>

<before>
<actionGroup ref="LoginAsAdmin" stepKey="login"/>
</before>
<after>
<actionGroup ref="logout" stepKey="logout"/>
</after>

<actionGroup ref="navigateToNewOrderPageNewCustomerSingleStore" stepKey="openNewOrder"/>
<selectOption selector="{{AdminOrderFormAccountSection.group}}" userInput="Retailer" stepKey="selectCustomerGroup"/>
<waitForPageLoad stepKey="waitForPageLoad"/>
<grabValueFrom selector="{{AdminOrderFormAccountSection.group}}" stepKey="grabGroupValue"/>
<assertEquals stepKey="assertValueIsStillSelected">
<actualResult type="variable">$grabGroupValue</actualResult>
<expectedResult type="string">3</expectedResult>
</assertEquals>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
</arguments>
<amOnPage url="{{AdminSystemStorePage.url}}" stepKey="amOnTheStorePage"/>
<click selector="{{AdminStoresGridSection.resetButton}}" stepKey="clickOnResetButton"/>
<waitForPageLoad stepKey="waitForPageLoadAfterResetButtonClicked" time="10"/>
<fillField userInput="{{websiteName}}" selector="{{AdminStoresGridSection.websiteFilterTextField}}" stepKey="fillSearchWebsiteField"/>
<click selector="{{AdminStoresGridSection.searchButton}}" stepKey="clickSearchButton" />
<waitForPageLoad stepKey="waitForPageLoadAfterSearch" time="10"/>
<see userInput="{{websiteName}}" selector="{{AdminStoresGridSection.websiteNameInFirstRow}}" stepKey="verifyThatCorrectWebsiteFound"/>
<click selector="{{AdminStoresGridSection.websiteNameInFirstRow}}" stepKey="clickEditExistingWebsite"/>

<waitForPageLoad stepKey="waitForPageLoadAfterWebsiteSelected" time="30"/>
<click selector="{{AdminStoresMainActionsSection.deleteButton}}" stepKey="clickDeleteWebsiteButtonOnEditStorePage"/>
<selectOption userInput="No" selector="{{AdminStoresDeleteWebsiteSection.createDbBackup}}" stepKey="setCreateDbBackupToNo"/>
<click selector="{{AdminStoresDeleteWebsiteSection.deleteButton}}" stepKey="clickDeleteButtonOnDeleteWebsitePage"/>
<see selector="{{AdminMessagesSection.successMessage}}" userInput="You deleted the website." stepKey="checkSuccessMessage"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminStoresDeleteWebsiteSection">
<element name="createDbBackup" type="select" selector="#store_create_backup"/>
<element name="deleteButton" type="button" selector="#delete" timeout="30"/>
<element name="deleteButton" type="button" selector="#delete" timeout="120"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_TestSetupDeclarationModule1"/>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="reference_table" disabled="true"/>
</schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_TestSetupDeclarationModule3"/>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,45 @@ public function testInstallationWithDroppingTables()
self::assertEquals($this->getData(), $shardData);
}

/**
* @moduleName Magento_TestSetupDeclarationModule1
* @moduleName Magento_TestSetupDeclarationModule3
*/
public function testInstallationWithDroppingTablesFromSecondaryModule()
{
$modules = [
'Magento_TestSetupDeclarationModule1',
'Magento_TestSetupDeclarationModule3',
];

$this->moduleManager->updateRevision(
'Magento_TestSetupDeclarationModule3',
'drop_table_with_external_dependency',
'db_schema.xml',
'etc'
);

foreach ($modules as $moduleName) {
$this->moduleManager->updateRevision(
$moduleName,
'without_setup_version',
'module.xml',
'etc'
);
}

try {
$this->cliCommand->install($modules);
} catch (\Exception $e) {
$installException = $e->getPrevious();
self::assertSame(1, $installException->getCode());
self::assertContains(
'The reference table named "reference_table" is disabled',
$installException->getMessage()
);
}
}

/**
* @moduleName Magento_TestSetupDeclarationModule1
* @dataProviderFromFile Magento/TestSetupDeclarationModule1/fixture/declarative_installer/rollback.php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,13 @@ private function processConstraints(array $tableData, string $resource, Schema $
if ($constraintData['type'] === 'foreign') {
$constraintData['column'] = $this->getColumnByName($constraintData['column'], $table);
$referenceTableData = $this->tablesData[$constraintData['referenceTable']];

if ($this->isDisabled($referenceTableData)) {
throw new \LogicException(
sprintf('The reference table named "%s" is disabled', $referenceTableData['name'])
);
}

//If we are referenced to the same table we need to specify it
//Get table name from resource connection regarding prefix settings
$refTableName = $this->resourceConnection->getTableName($referenceTableData['name']);
Expand Down

0 comments on commit 079770a

Please sign in to comment.