Skip to content

Commit eea292a

Browse files
authored
Merge pull request #7072 from magento-l3/L3-PR-20210908
L3 pr 20210908
2 parents 84b69d1 + 5ba4af9 commit eea292a

File tree

25 files changed

+784
-167
lines changed

25 files changed

+784
-167
lines changed

app/code/Magento/Captcha/Test/Mftf/Test/StorefrontCaptchaOnCustomerLoginTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<magentoCLI command="config:set {{StorefrontCaptchaOnCustomerLoginConfigData.path}} {{StorefrontCaptchaOnCustomerLoginConfigData.value}}" stepKey="enableCaptchaOnCustomerLogin"/>
2525
<magentoCLI command="config:set {{StorefrontCustomerCaptchaLength3ConfigData.path}} {{StorefrontCustomerCaptchaLength3ConfigData.value}}" stepKey="setCaptchaLength" />
2626
<magentoCLI command="config:set {{StorefrontCustomerCaptchaSymbols1ConfigData.path}} {{StorefrontCustomerCaptchaSymbols1ConfigData.value}}" stepKey="setCaptchaSymbols" />
27+
<magentoCLI command="config:set customer/captcha/failed_attempts_login 3" stepKey="setLoginAttempt"/>
2728
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanInvalidatedCaches">
2829
<argument name="tags" value="config full_page"/>
2930
</actionGroup>

app/code/Magento/CatalogGraphQl/Model/Resolver/Product/PriceRange.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424
class PriceRange implements ResolverInterface
2525
{
26+
private const STORE_FILTER_CACHE_KEY = '_cache_instance_store_filter';
27+
2628
/**
2729
* @var Discount
2830
*/
@@ -62,6 +64,8 @@ public function resolve(
6264
/** @var Product $product */
6365
$product = $value['model'];
6466
$product->unsetData('minimal_price');
67+
// add store filter for the product
68+
$product->setData(self::STORE_FILTER_CACHE_KEY, $store);
6569

6670
if ($context) {
6771
$customerGroupId = $context->getExtensionAttributes()->getCustomerGroupId();

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ class Product extends AbstractEntity
821821
* @throws \Magento\Framework\Exception\FileSystemException
822822
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
823823
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
824+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
824825
*/
825826
public function __construct(
826827
\Magento\Framework\Json\Helper\Data $jsonHelper,
@@ -1344,6 +1345,40 @@ protected function _saveProductAttributes(array $attributesData)
13441345
return $this;
13451346
}
13461347

1348+
/**
1349+
* Get data for updating product-category relations
1350+
*
1351+
* @param array $categoriesData
1352+
* @param string $tableName
1353+
* @return array
1354+
*/
1355+
private function getProductCategoriesDataSave(array $categoriesData, string $tableName): array
1356+
{
1357+
$delProductId = [];
1358+
$categoriesIn = [];
1359+
$minCategoryPosition = [];
1360+
foreach ($categoriesData as $delSku => $categories) {
1361+
$productId = $this->skuProcessor->getNewSku($delSku)['entity_id'];
1362+
$delProductId[] = $productId;
1363+
1364+
foreach (array_keys($categories) as $categoryId) {
1365+
//position new products before existing ones
1366+
if (!isset($minCategoryPosition[$categoryId])) {
1367+
$select = $this->_connection->select()
1368+
->from($tableName, ['position' => new \Zend_Db_Expr('MIN(position)')])
1369+
->where('category_id = ?', $categoryId);
1370+
$minCategoryPosition[$categoryId] = (int)$this->_connection->fetchOne($select);
1371+
}
1372+
$categoriesIn[] = [
1373+
'product_id' => $productId,
1374+
'category_id' => $categoryId,
1375+
'position' => --$minCategoryPosition[$categoryId]
1376+
];
1377+
}
1378+
}
1379+
return [$delProductId, $categoriesIn];
1380+
}
1381+
13471382
/**
13481383
* Save product categories.
13491384
*
@@ -1358,17 +1393,8 @@ protected function _saveProductCategories(array $categoriesData)
13581393
$tableName = $this->_resourceFactory->create()->getProductCategoryTable();
13591394
}
13601395
if ($categoriesData) {
1361-
$categoriesIn = [];
1362-
$delProductId = [];
1363-
1364-
foreach ($categoriesData as $delSku => $categories) {
1365-
$productId = $this->skuProcessor->getNewSku($delSku)['entity_id'];
1366-
$delProductId[] = $productId;
1396+
list($delProductId, $categoriesIn) = $this->getProductCategoriesDataSave($categoriesData, $tableName);
13671397

1368-
foreach (array_keys($categories) as $categoryId) {
1369-
$categoriesIn[] = ['product_id' => $productId, 'category_id' => $categoryId, 'position' => 0];
1370-
}
1371-
}
13721398
if (Import::BEHAVIOR_APPEND != $this->getBehavior()) {
13731399
$this->_connection->delete(
13741400
$tableName,
@@ -3268,7 +3294,7 @@ private function findImageByHash(array $images, string $hash): string
32683294
*/
32693295
private function getProductMediaPath(): string
32703296
{
3271-
return $this->joinFilePaths($this->getMediaBasePath(), 'catalog','product');
3297+
return $this->joinFilePaths($this->getMediaBasePath(), 'catalog', 'product');
32723298
}
32733299

32743300
/**
@@ -3289,7 +3315,7 @@ private function getMediaBasePath(): string
32893315
/**
32903316
* Joins two paths and remove redundant directory separator
32913317
*
3292-
* @param string ...$paths
3318+
* @param array $paths
32933319
* @return string
32943320
*/
32953321
private function joinFilePaths(...$paths): string

0 commit comments

Comments
 (0)