Skip to content

Commit

Permalink
Merge branch '2.4-develop' into save-checkout-address
Browse files Browse the repository at this point in the history
  • Loading branch information
Usik2203 authored Nov 9, 2020
2 parents 8d8a4bf + c644b3d commit 170620e
Show file tree
Hide file tree
Showing 147 changed files with 5,524 additions and 1,152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<section name="AdminHeaderSection">
<element name="pageTitle" type="text" selector=".page-header h1.page-title"/>
<element name="adminUserAccountText" type="text" selector=".page-header .admin-user-account-text" />
<element name="globalSearchInput" type="text" selector="#search-global" />
<element name="globalSearchInputVisible" type="text" selector=".search-global-field._active #search-global" />
<!-- Legacy heading section. Mostly used for admin 404 and 403 pages -->
<element name="pageHeading" type="text" selector=".page-content .page-heading"/>
<!-- Used for page not found error -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<!-- 2. Wait for session to expire. -->
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/>
<wait time="60" stepKey="waitForSessionLifetime"/>
<reloadPage stepKey="reloadPage"/>
<actionGroup ref="ReloadPageActionGroup" stepKey="reloadPage"/>

<!-- 3. Perform asserts. -->
<seeElement selector="{{AdminLoginFormSection.loginBlock}}" stepKey="assertAdminLoginPageIsAvailable"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<argument name="Customer" value="$$createCustomer$$" />
</actionGroup>
<wait time="60" stepKey="waitForCookieLifetime"/>
<reloadPage stepKey="reloadPage"/>
<actionGroup ref="ReloadPageActionGroup" stepKey="reloadPage"/>

<!-- 5. Perform asserts. -->
<seeElement selector="{{StorefrontPanelHeaderSection.customerLoginLink}}" stepKey="assertAuthorizationLinkIsVisibleOnStoreFront"/>
Expand Down
34 changes: 34 additions & 0 deletions app/code/Magento/Backend/Test/Mftf/Test/AdminSearchHotkeyTest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?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="AdminSearchHotkeyTest">
<annotations>
<features value="Backend"/>
<stories value="Search form hotkey in backend"/>
<title value="Admin should be able focus on the search field with a hotkey"/>
<description value="Admin should be able focus on the search field with a hotkey - forwardslash"/>
<severity value="MINOR"/>
<group value="backend"/>
<group value="search"/>
</annotations>
<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/>
</before>
<after>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>

<pressKey selector="body" parameterArray="[/]" stepKey="pressForwardslashKey"/>
<seeElement selector="{{AdminHeaderSection.globalSearchInputVisible}}" stepKey="seeActiveGlobalSearchInput"/>
<seeInField userInput="" selector="{{AdminHeaderSection.globalSearchInput}}" stepKey="seeEmptyGlobalSearchInput"/>
<pressKey selector="{{AdminHeaderSection.globalSearchInput}}" parameterArray="[/]" stepKey="pressForwardslashKeyAgain"/>
<seeInField userInput="/" selector="{{AdminHeaderSection.globalSearchInput}}" stepKey="seeForwardSlashInGlobalSearchInput"/>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.captchaField}}" stepKey="seeCaptchaField"/>
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.captchaImg}}" stepKey="seeCaptchaImage"/>
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.captchaReload}}" stepKey="seeCaptchaReloadButton"/>
<reloadPage stepKey="refreshPage"/>
<waitForPageLoad stepKey="waitForPageLoad2"/>

<actionGroup ref="ReloadPageActionGroup" stepKey="refreshPage"/>
<comment userInput="Replacing reload action and preserve Backward Compatibility" stepKey="waitForPageLoad2" />

<actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickCart2"/>
<click selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="goToCheckout2"/>
<waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.email}}" stepKey="waitEmailFieldVisible2"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private function prepareDefaultData(array $attributeList, string $attributeCode,
// For non-numeric types set the attributeValue to 'false' to trigger their removal from the db
if ($attributeType === 'varchar' || $attributeType === 'text' || $attributeType === 'datetime') {
$attribute->setIsRequired(false);
$productData[$attributeCode] = false;
$productData[$attributeCode] = $attribute->getDefaultValue() ?: false;
} else {
$productData[$attributeCode] = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,30 @@ public function getPositions(int $categoryId): array

return array_flip($connection->fetchCol($select));
}

/**
* Get category product minimum position
*
* @param int $categoryId
* @return int
*/
public function getMinPosition(int $categoryId): int
{
$connection = $this->getConnection();

$select = $connection->select()->from(
['cpe' => $this->getTable('catalog_product_entity')],
['position' => new \Zend_Db_Expr('MIN(position)')]
)->joinLeft(
['ccp' => $this->getTable('catalog_category_product')],
'ccp.product_id=cpe.entity_id'
)->where(
'ccp.category_id = ?',
$categoryId
)->order(
'ccp.product_id ' . \Magento\Framework\DB\Select::SQL_DESC
);

return (int)$connection->fetchOne($select);
}
}
6 changes: 4 additions & 2 deletions app/code/Magento/Catalog/Model/CategoryLinkManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Model;

/**
* Class CategoryLinkManagement
* Represents Category Product Link Management class
*/
class CategoryLinkManagement implements \Magento\Catalog\Api\CategoryLinkManagementInterface
{
Expand Down Expand Up @@ -56,7 +57,7 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getAssignedProducts($categoryId)
{
Expand All @@ -65,6 +66,7 @@ public function getAssignedProducts($categoryId)
/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $products */
$products = $category->getProductCollection();
$products->addFieldToSelect('position');
$products->groupByAttribute($products->getProductEntityMetadata()->getIdentifierField());

/** @var \Magento\Catalog\Api\Data\CategoryProductLinkInterface[] $links */
$links = [];
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/Model/Product/Authorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function authorizeSavingOf(ProductInterface $product): void
if (!$savedProduct->getSku()) {
throw NoSuchEntityException::singleField('id', $product->getId());
}
$oldData = $product->getOrigData();
$oldData = $savedProduct->getData();
}
}
if ($this->hasProductChanged($product, $oldData)) {
Expand Down
40 changes: 40 additions & 0 deletions app/code/Magento/Catalog/Model/Product/Option/Type/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public function validateUserValue($values)
$dateValid = true;
if ($this->_dateExists()) {
if ($this->useCalendar()) {
if (is_array($value) && $this->checkDateWithoutJSCalendar($value)) {
$value['date'] = sprintf("%s/%s/%s", $value['day'], $value['month'], $value['year']);
}
/* Fixed validation if the date was not saved correctly after re-saved the order
for example: "09\/24\/2020,2020-09-24 00:00:00" */
if (is_string($value) && preg_match('/^\d{1,4}.+\d{1,4}.+\d{1,4},+(\w|\W)*$/', $value)) {
Expand All @@ -81,6 +84,9 @@ public function validateUserValue($values)
}
$dateValid = isset($value['date']) && preg_match('/^\d{1,4}.+\d{1,4}.+\d{1,4}$/', $value['date']);
} else {
if (is_array($value)) {
$value = $this->prepareDateByDateInternal($value);
}
$dateValid = isset(
$value['day']
) && isset(
Expand Down Expand Up @@ -411,4 +417,38 @@ protected function _timeExists()
]
);
}

/**
* Check is date without JS Calendar
*
* @param array $value
*
* @return bool
*/
private function checkDateWithoutJSCalendar(array $value): bool
{
return empty($value['date'])
&& !empty($value['day'])
&& !empty($value['month'])
&& !empty($value['year']);
}

/**
* Prepare date by date internal
*
* @param array $value
* @return array
*/
private function prepareDateByDateInternal(array $value): array
{
if (!empty($value['date']) && !empty($value['date_internal'])) {
$formatDate = explode(' ', $value['date_internal']);
$date = explode('-', $formatDate[0]);
$value['year'] = $date[0];
$value['month'] = $date[1];
$value['day'] = $date[2];
}

return $value;
}
}
3 changes: 2 additions & 1 deletion app/code/Magento/Catalog/Model/Product/Type/AbstractType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Model\Product\Type;

Expand Down Expand Up @@ -620,7 +621,7 @@ protected function _prepareOptions(\Magento\Framework\DataObject $buyRequest, $p
}
}
if (count($results) > 0) {
throw new LocalizedException(__(implode("\n", $results)));
throw new LocalizedException(__(implode("\n", array_unique($results))));
}
}

Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Catalog/Model/ResourceModel/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Magento\Catalog\Model\ResourceModel;

use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\Data\CategoryInterface;
use Magento\Catalog\Model\Indexer\Category\Product\Processor;
use Magento\Catalog\Setup\CategorySetup;
use Magento\Framework\App\ObjectManager;
Expand Down Expand Up @@ -1172,11 +1172,11 @@ public function getCategoryWithChildren(int $categoryId): array
return [];
}

$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
$linkField = $this->metadataPool->getMetadata(CategoryInterface::class)->getLinkField();
$select = $connection->select()
->from(
['cce' => $this->getTable('catalog_category_entity')],
[$linkField, 'parent_id', 'path']
[$linkField, 'entity_id', 'parent_id', 'path']
)->join(
['cce_int' => $this->getTable('catalog_category_entity_int')],
'cce.' . $linkField . ' = cce_int.' . $linkField,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Magento\Catalog\Model\ResourceModel\Product;

use Magento\Catalog\Api\Data\CategoryInterface;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer;
use Magento\Catalog\Model\Indexer\Product\Price\PriceTableResolver;
Expand Down Expand Up @@ -2130,16 +2131,17 @@ private function getChildrenCategories(int $categoryId): array

$firstCategory = array_shift($categories);
if ($firstCategory['is_anchor'] == 1) {
$linkField = $this->getProductEntityMetadata()->getLinkField();
$anchorCategory[] = (int)$firstCategory[$linkField];
//category hierarchy can not be modified by staging updates
$entityField = $this->metadataPool->getMetadata(CategoryInterface::class)->getIdentifierField();
$anchorCategory[] = (int)$firstCategory[$entityField];
foreach ($categories as $category) {
if (in_array($category['parent_id'], $categoryIds)
&& in_array($category['parent_id'], $anchorCategory)) {
$categoryIds[] = (int)$category[$linkField];
$categoryIds[] = (int)$category[$entityField];
// Storefront approach is to treat non-anchor children of anchor category as anchors.
// Adding their's IDs to $anchorCategory for consistency.
// Adding theirs IDs to $anchorCategory for consistency.
if ($category['is_anchor'] == 1 || in_array($category['parent_id'], $anchorCategory)) {
$anchorCategory[] = (int)$category[$linkField];
$anchorCategory[] = (int)$category[$entityField];
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@
*/
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{
/**
* Name prefix of events that are dispatched by model
*
* @var string
*/
protected $_eventPrefix = 'catalog_product_option_value_collection';

/**
* Name of event parameter
*
* @var string
*/
protected $_eventObject = 'product_option_value_collection';

/**
* Resource initialization
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<magentoCLI command="cron:run" stepKey="runCron"/>

<!-- 5. Open category A on Storefront again -->
<reloadPage stepKey="reloadCategoryA"/>
<actionGroup ref="ReloadPageActionGroup" stepKey="reloadCategoryA"/>

<!-- Category A displays product A1 now -->
<see userInput="$$createCategoryA.name$$" selector="{{StorefrontCategoryMainSection.CategoryTitle}}" stepKey="seeTitleCategoryA1"/>
Expand Down Expand Up @@ -126,7 +126,7 @@
<magentoCLI command="cron:run" stepKey="runCron1"/>

<!-- 9. Open category A on Storefront again -->
<reloadPage stepKey="refreshCategoryAPage"/>
<actionGroup ref="ReloadPageActionGroup" stepKey="refreshCategoryAPage"/>

<!-- Category A is empty now -->
<see userInput="$$createCategoryA.name$$" selector="{{StorefrontCategoryMainSection.CategoryTitle}}" stepKey="seeOnPageCategoryAName"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@

<!-- Assert single row - no hover state -->
<createData entity="ApiCategoryA" stepKey="createFirstCategoryBlank"/>
<reloadPage stepKey="refreshPage"/>
<waitForPageLoad stepKey="waitForBlankSingleRowAppear"/>

<actionGroup ref="ReloadPageActionGroup" stepKey="refreshPage"/>
<comment userInput="Replacing reload action and preserve Backward Compatibility" stepKey="waitForBlankSingleRowAppear"/>

<moveMouseOver selector="{{StorefrontHeaderSection.NavigationCategoryByName($$createFirstCategoryBlank.name$$)}}" stepKey="hoverFirstCategoryBlank"/>
<dontSeeElement selector="{{StorefrontNavigationMenuSection.subItemLevelHover('level0')}}" stepKey="assertNoHoverState"/>

Expand Down Expand Up @@ -87,8 +89,9 @@
</createData>

<!-- Several rows. Hover on category without children -->
<reloadPage stepKey="reloadPage"/>
<waitForPageLoad stepKey="waitForBlankSeveralRowsAppear"/>
<actionGroup ref="ReloadPageActionGroup" stepKey="reloadPage"/>
<comment userInput="Replacing reload action and preserve Backward Compatibility" stepKey="waitForBlankSeveralRowsAppear"/>

<moveMouseOver selector="{{StorefrontHeaderSection.NavigationCategoryByName($$createCategoryWithoutChildrenBlank.name$$)}}" stepKey="hoverCategoryWithoutChildren"/>
<dontSeeElement selector="{{StorefrontNavigationMenuSection.itemByNameAndLevel($$createCategoryWithoutChildrenBlank.name$$, 'level0')}}" stepKey="dontSeeChildrenInCategory"/>

Expand Down Expand Up @@ -167,8 +170,9 @@
<createData entity="ApiCategory" stepKey="createFourthCategoryLuma"/>

<!-- Single row. No hover state -->
<reloadPage stepKey="reload"/>
<waitForPageLoad stepKey="waitForLumaSingleRowAppear"/>
<actionGroup ref="ReloadPageActionGroup" stepKey="reload"/>
<comment userInput="Replacing reload action and preserve Backward Compatibility" stepKey="waitForLumaSingleRowAppear"/>

<dontSeeElement selector="{{StorefrontNavigationMenuSection.itemByNameAndLevel($$createFirstCategoryLuma.name$$, 'level0')}}" stepKey="noHoverStateInFirstCategory"/>
<dontSeeElement selector="{{StorefrontNavigationMenuSection.itemByNameAndLevel($$createSecondCategoryLuma.name$$, 'level0')}}" stepKey="noHoverStateInSecondCategory"/>
<dontSeeElement selector="{{StorefrontNavigationMenuSection.itemByNameAndLevel($$createThirdCategoryLuma.name$$, 'level0')}}" stepKey="noHoverStateThirdCategory"/>
Expand Down Expand Up @@ -203,8 +207,9 @@
<createData entity="ApiCategory" stepKey="createEighthCategoryLuma"/>

<!-- Several rows. Hover on Category without children -->
<reloadPage stepKey="refresh"/>
<waitForPageLoad stepKey="waitForLumaSeveralRowsAppear"/>
<actionGroup ref="ReloadPageActionGroup" stepKey="refresh"/>
<comment userInput="Replacing reload action and preserve Backward Compatibility" stepKey="waitForLumaSeveralRowsAppear"/>

<moveMouseOver selector="{{StorefrontHeaderSection.NavigationCategoryByName($$createFifthCategoryLuma.name$$)}}" stepKey="hoverOnCategoryWithoutChildren"/>
<dontSeeElement selector="{{StorefrontNavigationMenuSection.itemByNameAndLevel($$createFifthCategoryLuma.name$$, 'level0')}}" stepKey="dontSeeSubcategoriesInCategory"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Magento\Catalog\Model\CategoryRepository;
use Magento\Catalog\Model\ResourceModel\Product;
use Magento\Catalog\Model\ResourceModel\Product\Collection;
use Magento\Framework\DataObject;
use Magento\Framework\Indexer\IndexerRegistry;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -85,7 +86,11 @@ public function testGetAssignedProducts()
$categoryMock->expects($this->once())->method('getProductCollection')->willReturn($productsMock);
$categoryMock->expects($this->once())->method('getId')->willReturn($categoryId);
$productsMock->expects($this->once())->method('addFieldToSelect')->with('position')->willReturnSelf();
$productsMock->expects($this->once())->method('groupByAttribute')->with('entity_id')->willReturnSelf();
$productsMock->expects($this->once())->method('getItems')->willReturn($items);
$productsMock->expects($this->once())
->method('getProductEntityMetadata')
->willReturn(new DataObject(['identifier_field' => 'entity_id']));
$this->productLinkFactoryMock->expects($this->once())->method('create')->willReturn($categoryProductLinkMock);
$categoryProductLinkMock->expects($this->once())
->method('setSku')
Expand Down
Loading

0 comments on commit 170620e

Please sign in to comment.