Skip to content

Commit

Permalink
Merge remote-tracking branch 'magento2/2.4-develop' into unlock-admin…
Browse files Browse the repository at this point in the history
…-user
  • Loading branch information
engcom-Charlie committed Nov 25, 2021
2 parents 5bcc71b + eadd3a9 commit 2dfaa8e
Show file tree
Hide file tree
Showing 76 changed files with 1,253 additions and 469 deletions.
Expand Up @@ -105,7 +105,7 @@ protected function _getIndexableAttributes($multiSelect)
);

if ($multiSelect == true) {
$select->where('ea.backend_type = ?', 'varchar')->where('ea.frontend_input = ?', 'multiselect');
$select->where('ea.backend_type = ?', 'text')->where('ea.frontend_input = ?', 'multiselect');
} else {
$select->where('ea.backend_type = ?', 'int')->where('ea.frontend_input IN( ? )', ['select', 'boolean']);
}
Expand Down Expand Up @@ -303,14 +303,14 @@ protected function _prepareMultiselectIndex($entityIds = null, $attributeId = nu
// prepare get multiselect values query
$productValueExpression = $connection->getCheckSql('pvs.value_id > 0', 'pvs.value', 'pvd.value');
$select = $connection->select()->from(
['pvd' => $this->getTable('catalog_product_entity_varchar')],
['pvd' => $this->getTable('catalog_product_entity_text')],
[]
)->join(
['cs' => $this->getTable('store')],
'',
[]
)->joinLeft(
['pvs' => $this->getTable('catalog_product_entity_varchar')],
['pvs' => $this->getTable('catalog_product_entity_text')],
"pvs.{$productIdField} = pvd.{$productIdField} AND pvs.attribute_id = pvd.attribute_id"
. ' AND pvs.store_id=cs.store_id',
[]
Expand Down
@@ -0,0 +1,102 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Catalog\Setup\Patch\Data;

use Magento\Catalog\Model\Product;
use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;

class UpdateMultiselectAttributesBackendTypes implements DataPatchInterface
{
/**
* @var ModuleDataSetupInterface
*/
private $dataSetup;
/**
* @var EavSetupFactory
*/
private $eavSetupFactory;

/**
* MigrateMultiselectAttributesData constructor.
* @param ModuleDataSetupInterface $dataSetup
* @param EavSetupFactory $eavSetupFactory
*/
public function __construct(
ModuleDataSetupInterface $dataSetup,
EavSetupFactory $eavSetupFactory
) {
$this->dataSetup = $dataSetup;
$this->eavSetupFactory = $eavSetupFactory;
}

/**
* @inheritdoc
*/
public static function getDependencies()
{
return [];
}

/**
* @inheritdoc
*/
public function getAliases()
{
return [];
}

/**
* @inheritdoc
*/
public function apply()
{
$this->dataSetup->startSetup();

$connection = $this->dataSetup->getConnection();
$attributeTable = $connection->getTableName('eav_attribute');
/** @var EavSetup $eavSetup */
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->dataSetup]);
$entityTypeId = $eavSetup->getEntityTypeId(Product::ENTITY);
$attributesToMigrate = $connection->fetchCol(
$connection
->select()
->from($attributeTable, ['attribute_id'])
->where('entity_type_id = ?', $entityTypeId)
->where('backend_type = ?', 'varchar')
->where('frontend_input = ?', 'multiselect')
);

$varcharTable = $connection->getTableName('catalog_product_entity_varchar');
$textTable = $connection->getTableName('catalog_product_entity_text');
$varcharTableDataSql = $connection
->select()
->from($varcharTable)
->where('attribute_id in (?)', $attributesToMigrate);
$dataToMigrate = array_map(static function ($row) {
$row['value_id'] = null;
return $row;
}, $connection->fetchAll($varcharTableDataSql));

foreach (array_chunk($dataToMigrate, 2000) as $dataChunk) {
$connection->insertMultiple($textTable, $dataChunk);
}

$connection->query($connection->deleteFromSelect($varcharTableDataSql, $varcharTable));

foreach ($attributesToMigrate as $attributeId) {
$eavSetup->updateAttribute($entityTypeId, $attributeId, 'backend_type', 'text');
}

$this->dataSetup->endSetup();

return $this;
}
}
Expand Up @@ -33,18 +33,26 @@
<actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/>
<!--Create subcategory under parent category -->
<actionGroup ref="AdminExpandCategoryTreeActionGroup" stepKey="clickOnExpandTree"/>
<click selector="{{AdminCategorySidebarTreeSection.categoryInTree($$createCategory.name$$)}}" stepKey="selectCategory"/>
<waitForPageLoad stepKey="waitForPageToLoad"/>
<actionGroup ref="AdminCategoriesOpenCategoryActionGroup" stepKey="selectCategory">
<argument name="category" value="$$createCategory$$"/>
</actionGroup>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForPageToLoad"/>
<click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategoryButton"/>
<checkOption selector="{{AdminCategoryBasicFieldSection.EnableCategory}}" stepKey="enableCategory"/>
<checkOption selector="{{AdminCategoryBasicFieldSection.IncludeInMenu}}" stepKey="enableIncludeInMenu"/>
<fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{SimpleSubCategory.name}}" stepKey="addSubCategoryName"/>
<actionGroup ref="AdminSaveCategoryActionGroup" stepKey="saveSubCategory"/>
<seeElement selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="seeSuccessMessage"/>
<actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="seeSuccessMessage">
<argument name="message" value="You saved the category."/>
</actionGroup>
<!-- Verify Parent Category and Sub category is not visible in navigation menu -->
<amOnPage url="$$createCategory.custom_attributes[url_key]$$/{{SimpleSubCategory.urlKey}}.html" stepKey="openCategoryStoreFrontPage"/>
<waitForPageLoad stepKey="waitForCategoryStoreFrontPageToLoad"/>
<dontSeeElement selector="{{StorefrontHeaderSection.NavigationCategoryByName($$createCategory.name$$)}}" stepKey="dontSeeCategoryOnStoreNavigationBar"/>
<dontSeeElement selector="{{StorefrontHeaderSection.NavigationCategoryByName(SimpleSubCategory.name)}}" stepKey="dontSeeSubCategoryOnStoreNavigation"/>
<actionGroup ref="StorefrontAssertCategoryNameIsNotShownInMenuActionGroup" stepKey="dontSeeCategoryOnStoreNavigationBar">
<argument name="categoryName" value="$$createCategory.name$$"/>
</actionGroup>
<actionGroup ref="StorefrontAssertCategoryNameIsNotShownInMenuActionGroup" stepKey="dontSeeSubCategoryOnStoreNavigation">
<argument name="categoryName" value="{{SimpleSubCategory.name}}"/>
</actionGroup>
</test>
</tests>
Expand Up @@ -32,18 +32,26 @@
<actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/>
<!--Create subcategory under parent category -->
<actionGroup ref="AdminExpandCategoryTreeActionGroup" stepKey="clickOnExpandTree"/>
<click selector="{{AdminCategorySidebarTreeSection.categoryInTree($$createCategory.name$$)}}" stepKey="selectCategory"/>
<waitForPageLoad stepKey="waitForPageToLoad"/>
<actionGroup ref="AdminCategoriesOpenCategoryActionGroup" stepKey="selectCategory">
<argument name="category" value="$$createCategory$$"/>
</actionGroup>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForPageToLoad"/>
<click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategoryButton"/>
<checkOption selector="{{AdminCategoryBasicFieldSection.EnableCategory}}" stepKey="enableCategory"/>
<checkOption selector="{{AdminCategoryBasicFieldSection.IncludeInMenu}}" stepKey="enableIncludeInMenu"/>
<fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{SimpleSubCategory.name}}" stepKey="addSubCategoryName"/>
<actionGroup ref="AdminSaveCategoryActionGroup" stepKey="saveSubCategory"/>
<seeElement selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="seeSuccessMessage"/>
<actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="seeSuccessMessage">
<argument name="message" value="You saved the category."/>
</actionGroup>
<!-- Verify Parent Category and Sub category is not visible in navigation menu -->
<amOnPage url="$$createCategory.custom_attributes[url_key]$$/{{SimpleSubCategory.urlKey}}.html" stepKey="openCategoryStoreFrontPage"/>
<waitForPageLoad stepKey="waitForCategoryStoreFrontPageToLoad"/>
<dontSeeElement selector="{{StorefrontHeaderSection.NavigationCategoryByName($$createCategory.name$$)}}" stepKey="dontSeeCategoryOnStoreNavigationBar"/>
<dontSeeElement selector="{{StorefrontHeaderSection.NavigationCategoryByName(SimpleSubCategory.name)}}" stepKey="dontSeeSubCategoryOnStoreNavigation"/>
<actionGroup ref="StorefrontAssertCategoryNameIsNotShownInMenuActionGroup" stepKey="dontSeeCategoryOnStoreNavigationBar">
<argument name="categoryName" value="$$createCategory.name$$"/>
</actionGroup>
<actionGroup ref="StorefrontAssertCategoryNameIsNotShownInMenuActionGroup" stepKey="dontSeeSubCategoryOnStoreNavigation">
<argument name="categoryName" value="{{SimpleSubCategory.name}}"/>
</actionGroup>
</test>
</tests>
Expand Up @@ -22,7 +22,7 @@
class Product extends \Magento\Rule\Model\Condition\Product\AbstractProduct
{
/**
* {@inheritdoc}
* @var string
*/
protected $elementName = 'parameters';

Expand All @@ -32,8 +32,6 @@ class Product extends \Magento\Rule\Model\Condition\Product\AbstractProduct
protected $joinedAttributes = [];

/**
* Store manager
*
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $storeManager;
Expand Down Expand Up @@ -182,7 +180,7 @@ protected function addGlobalAttribute(
$linkField = $attribute->getEntity()->getLinkField();

$collection->getSelect()->join(
[$alias => $collection->getTable('catalog_product_entity_varchar')],
[$alias => $collection->getTable($attribute->getBackendTable())],
"($alias.$linkField = e.$linkField) AND ($alias.store_id = $storeId)" .
" AND ($alias.attribute_id = {$attribute->getId()})",
[]
Expand Down
Expand Up @@ -53,11 +53,13 @@
</actionGroup>

<!--Go to Catalog > Categories (choose category where created products)-->
<amOnPage url="{{AdminCategoryPage.url}}" stepKey="onCategoryIndexPage"/>
<waitForPageLoad stepKey="waitForCategoryPageLoadAddProducts" after="onCategoryIndexPage"/>
<click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickExpandAll" after="waitForCategoryPageLoadAddProducts"/>
<click selector="{{AdminCategorySidebarTreeSection.categoryInTree(SimpleSubCategory.name)}}" stepKey="clickCategoryLink"/>
<waitForPageLoad stepKey="waitForCategoryPageLoad"/>
<actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="onCategoryIndexPage"/>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForCategoryPageLoadAddProducts"/>
<actionGroup ref="AdminExpandCategoryTreeActionGroup" stepKey="clickExpandAll"/>
<actionGroup ref="AdminCategoriesOpenCategoryActionGroup" stepKey="clickCategoryLink">
<argument name="category" value="SimpleSubCategory"/>
</actionGroup>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForCategoryPageLoad"/>

<!--Content > Add CMS Block: name saved block-->
<waitForElementVisible selector="{{AdminCategoryContentSection.sectionHeader}}" stepKey="waitForContentSection"/>
Expand All @@ -75,8 +77,10 @@
<actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="seeSuccessMessage"/>

<!--Go to Storefront > category-->
<amOnPage url="$$simplecategory.custom_attributes[url_key]$$.html" stepKey="goToStorefrontCategoryPage"/>
<waitForPageLoad stepKey="waitForStorefrontPageLoaded"/>
<actionGroup ref="StorefrontNavigateCategoryPageActionGroup" stepKey="goToStorefrontCategoryPage">
<argument name="category" value="$$simplecategory$$"/>
</actionGroup>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForStorefrontPageLoaded"/>

<!--Check operators Greater than-->
<dontSeeElement selector="{{InsertWidgetSection.checkElementStorefrontByPrice('10')}}" stepKey="dontSeeElementByPrice20"/>
Expand All @@ -95,8 +99,10 @@
</actionGroup>

<!--Go to Storefront > category-->
<amOnPage url="$$simplecategory.custom_attributes[url_key]$$.html" stepKey="goToStorefrontCategoryPage2"/>
<waitForPageLoad stepKey="waitForStorefrontPageLoaded2"/>
<actionGroup ref="StorefrontNavigateCategoryPageActionGroup" stepKey="goToStorefrontCategoryPage2">
<argument name="category" value="$$simplecategory$$"/>
</actionGroup>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForStorefrontPageLoaded2"/>

<!--Check operators Greater than-->
<seeElement selector="{{InsertWidgetSection.checkElementStorefrontByPrice('10')}}" stepKey="seeElementByPrice20"/>
Expand All @@ -115,8 +121,10 @@
</actionGroup>

<!--Go to Storefront > category-->
<amOnPage url="$$simplecategory.custom_attributes[url_key]$$.html" stepKey="goToStorefrontCategoryPage3"/>
<waitForPageLoad stepKey="waitForStorefrontPageLoaded3"/>
<actionGroup ref="StorefrontNavigateCategoryPageActionGroup" stepKey="goToStorefrontCategoryPage3">
<argument name="category" value="$$simplecategory$$"/>
</actionGroup>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForStorefrontPageLoaded3"/>

<!--Check operators Greater than-->
<dontSeeElement selector="{{InsertWidgetSection.checkElementStorefrontByPrice('10')}}" stepKey="dontSeeElementByPrice20s"/>
Expand All @@ -135,8 +143,10 @@
</actionGroup>

<!--Go to Storefront > category-->
<amOnPage url="$$simplecategory.custom_attributes[url_key]$$.html" stepKey="goToStorefrontCategoryPage4"/>
<waitForPageLoad stepKey="waitForStorefrontPageLoaded4"/>
<actionGroup ref="StorefrontNavigateCategoryPageActionGroup" stepKey="goToStorefrontCategoryPage4">
<argument name="category" value="$$simplecategory$$"/>
</actionGroup>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForStorefrontPageLoaded4"/>

<!--Check operators Greater than-->
<seeElement selector="{{InsertWidgetSection.checkElementStorefrontByPrice('10')}}" stepKey="seeElementByPrice20s"/>
Expand Down
Expand Up @@ -176,6 +176,10 @@ public function savePaymentInformation(
}
$this->limitShippingCarrier($quote);

if (!(int)$quote->getItemsQty()) {
throw new CouldNotSaveException(__('Some of the products are disabled.'));
}

$this->paymentMethodManagement->set($cartId, $paymentMethod);
return true;
}
Expand Down
Expand Up @@ -180,6 +180,7 @@ public function testSavePaymentInformationWithoutBillingAddress()
$paymentMock = $this->getMockForAbstractClass(PaymentInterface::class);
$billingAddressMock = $this->getMockForAbstractClass(AddressInterface::class);
$quoteMock = $this->createMock(Quote::class);
$quoteMock->expects($this->any())->method('getItemsQty')->willReturn(1);

$billingAddressMock->expects($this->once())->method('setEmail')->with($email)->willReturnSelf();

Expand Down Expand Up @@ -210,6 +211,7 @@ public function testSavePaymentInformationAndPlaceOrderWithLocalizedException()

$quoteMock = $this->createMock(Quote::class);
$quoteMock->method('getBillingAddress')->willReturn($billingAddressMock);
$quoteMock->expects($this->any())->method('getItemsQty')->willReturn(1);
$this->cartRepositoryMock->method('getActive')->with($cartId)->willReturn($quoteMock);

$quoteIdMask = $this->getMockBuilder(QuoteIdMask::class)
Expand All @@ -231,6 +233,35 @@ public function testSavePaymentInformationAndPlaceOrderWithLocalizedException()
$this->model->savePaymentInformationAndPlaceOrder($cartId, $email, $paymentMock, $billingAddressMock);
}

public function testSavePaymentInformationAndPlaceOrderWithDisabledProduct()
{
$this->expectException('Magento\Framework\Exception\CouldNotSaveException');
$this->expectExceptionMessage('Some of the products are disabled.');
$cartId = 100;
$email = 'email@magento.com';
$paymentMock = $this->getMockForAbstractClass(PaymentInterface::class);
$billingAddressMock = $this->getMockForAbstractClass(AddressInterface::class);

$quoteMock = $this->createMock(Quote::class);
$quoteMock->method('getBillingAddress')->willReturn($billingAddressMock);
$quoteMock->expects($this->any())->method('getItemsQty')->willReturn(0);
$this->cartRepositoryMock->method('getActive')->with($cartId)->willReturn($quoteMock);

$quoteIdMask = $this->getMockBuilder(QuoteIdMask::class)
->addMethods(['getQuoteId'])
->onlyMethods(['load'])
->disableOriginalConstructor()
->getMock();
$this->quoteIdMaskFactoryMock->method('create')->willReturn($quoteIdMask);
$quoteIdMask->method('load')->with($cartId, 'masked_id')->willReturnSelf();
$quoteIdMask->method('getQuoteId')->willReturn($cartId);

$billingAddressMock->expects($this->once())->method('setEmail')->with($email)->willReturnSelf();

$this->paymentMethodManagementMock->expects($this->never())->method('set')->with($cartId, $paymentMock);
$this->model->savePaymentInformationAndPlaceOrder($cartId, $email, $paymentMock, $billingAddressMock);
}

/**
* @param int $cartId
* @param MockObject $billingAddressMock
Expand Down Expand Up @@ -266,6 +297,9 @@ private function getMockForAssignBillingAddress(
$this->cartRepositoryMock->method('getActive')
->with($cartId)
->willReturn($quote);
$quote->expects($this->any())
->method('getItemsQty')
->willReturn(1);
$quote->expects($this->any())
->method('getBillingAddress')
->willReturn($quoteBillingAddress);
Expand Down
5 changes: 2 additions & 3 deletions app/code/Magento/Customer/Block/Widget/Dob.php
Expand Up @@ -28,8 +28,6 @@ class Dob extends AbstractWidget
const MAX_DATE_RANGE_KEY = 'date_range_max';

/**
* Date inputs
*
* @var array
*/
protected $_dateInputs = [];
Expand Down Expand Up @@ -422,7 +420,8 @@ public function getTranslatedCalendarConfigJson(): string
'monthNamesShort' => array_values(iterator_to_array($monthsData['format']['abbreviated'])),
'dayNames' => array_values(iterator_to_array($daysData['format']['wide'])),
'dayNamesShort' => array_values(iterator_to_array($daysData['format']['abbreviated'])),
'dayNamesMin' => array_values(iterator_to_array($daysData['format']['short'])),
'dayNamesMin' =>
array_values(iterator_to_array(($daysData['format']['short']) ?: $daysData['format']['abbreviated'])),
]
);
}
Expand Down

0 comments on commit 2dfaa8e

Please sign in to comment.