Skip to content

Commit 3caa171

Browse files
🔃 [EngCom] Public Pull Requests - 2.3-develop Minor Fixes
Accepted Public Pull Requests: - #21476: Fix/issue 21192 (by @DenisSaltanahmedov) - #21503: Remove setting of page title from Form/Register block and add title to customer_account_create layout (by @mfickers) - #20239: Fixed issue #20187 Downloadble Price duplicate issue (by @GovindaSharma) - #21462: URL rewrite fix while product website update using mass action (by @AnshuMishra17) - #17668: Adding property mapper for product eav attribute -> search weight. (by @bartoszkubicki) - #21279: Fixed: #21278, Add sort order on downloadable links (by @maheshWebkul721) - #21170: Fix issue with custom option file uploading (by @nikolaevas) - #20484: Fix performance leak in salesrule collection (by @david-fuehr) - #19637: Fixed Issue #19632 - Backend Marketing Cart Price Rule Label Alignment Issue (by @speedy008) - #18705: Correct child node load when multiple calls to CategoryManagement::ge� (by @pmclain) Fixed GitHub Issues: - #21192: Wrong data of Import status with Add/Update method in Advanced Prices in CSV (reported by @DenisSaltanahmedov) has been fixed in #21476 by @DenisSaltanahmedov in 2.3-develop branch Related commits: 1. 2f1bc31 2. e29807f 3. df93752 - #20187: Downloadable product view layout (reported by @melaxon) has been fixed in #20239 by @GovindaSharma in 2.3-develop branch Related commits: 1. e6f6422 - #21329: URL Rewrites are overwritten (reported by @AnshuMishra17) has been fixed in #21462 by @AnshuMishra17 in 2.3-develop branch Related commits: 1. 7cacec1 - #21278: Sort order missing on Downloadable Product Links and Sample Columns (reported by @maheshWebkul721) has been fixed in #21279 by @maheshWebkul721 in 2.3-develop branch Related commits: 1. c9a9d64 2. 92d2a3c 3. 03f0c3a 4. 81a4de8 - #19117: High Database Load for Sales Rule Validation (reported by @rauberdaniel) has been fixed in #20484 by @david-fuehr in 2.3-develop branch Related commits: 1. 79cefb5 2. 41de8cb 3. fa7fb54 4. 18c8bb5 5. 0319bb0 6. 83e1e84 7. 24e7dd7 8. 91fecf7 9. 5ca9dbd 10. 11e5397 11. e516ebc - #19632: Backend Marketing Cart Price Rule Label Alignment Issue (reported by @speedy008) has been fixed in #19637 by @speedy008 in 2.3-develop branch Related commits: 1. 2e855c4 2. f4de914 - #17297: No children data for \Magento\Catalog\Model\CategoryManagement::getTree($categoryId) after first call. (reported by @j0um) has been fixed in #18705 by @pmclain in 2.3-develop branch Related commits: 1. 0db0e84
2 parents 73b5b92 + 045cfb3 commit 3caa171

File tree

16 files changed

+318
-130
lines changed

16 files changed

+318
-130
lines changed

app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ protected function saveAndReplaceAdvancedPrices()
408408
} elseif (\Magento\ImportExport\Model\Import::BEHAVIOR_APPEND == $behavior) {
409409
$this->processCountExistingPrices($tierPrices, self::TABLE_TIER_PRICE)
410410
->processCountNewPrices($tierPrices);
411+
411412
$this->saveProductPrices($tierPrices, self::TABLE_TIER_PRICE);
412413
if ($listSku) {
413414
$this->setUpdatedAt($listSku);
@@ -562,11 +563,14 @@ protected function processCountExistingPrices($prices, $table)
562563

563564
$tableName = $this->_resourceFactory->create()->getTable($table);
564565
$productEntityLinkField = $this->getProductEntityLinkField();
565-
$existingPrices = $this->_connection->fetchAssoc(
566+
$existingPrices = $this->_connection->fetchAll(
566567
$this->_connection->select()->from(
567568
$tableName,
568-
['value_id', $productEntityLinkField, 'all_groups', 'customer_group_id']
569-
)->where($productEntityLinkField . ' IN (?)', $existProductIds)
569+
[$productEntityLinkField, 'all_groups', 'customer_group_id', 'qty']
570+
)->where(
571+
$productEntityLinkField . ' IN (?)',
572+
$existProductIds
573+
)
570574
);
571575
foreach ($existingPrices as $existingPrice) {
572576
foreach ($prices as $sku => $skuPrices) {
@@ -591,8 +595,10 @@ protected function incrementCounterUpdated($prices, $existingPrice)
591595
foreach ($prices as $price) {
592596
if ($existingPrice['all_groups'] == $price['all_groups']
593597
&& $existingPrice['customer_group_id'] == $price['customer_group_id']
598+
&& (int) $existingPrice['qty'] === (int) $price['qty']
594599
) {
595600
$this->countItemsUpdated++;
601+
continue;
596602
}
597603
}
598604
}

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ public function testProcessCountExistingPrices(
921921
);
922922
$dbSelectMock = $this->createMock(\Magento\Framework\DB\Select::class);
923923
$this->connection->expects($this->once())
924-
->method('fetchAssoc')
924+
->method('fetchAll')
925925
->willReturn($existingPrices);
926926
$this->connection->expects($this->once())
927927
->method('select')
@@ -930,7 +930,7 @@ public function testProcessCountExistingPrices(
930930
->method('from')
931931
->with(
932932
self::TABLE_NAME,
933-
['value_id', self::LINK_FIELD, 'all_groups', 'customer_group_id']
933+
[self::LINK_FIELD, 'all_groups', 'customer_group_id', 'qty']
934934
)->willReturnSelf();
935935
$this->advancedPricing->expects($this->once())
936936
->method('retrieveOldSkus')

app/code/Magento/Catalog/Model/Category/Tree.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,40 @@ class Tree
3232
*/
3333
protected $treeFactory;
3434

35+
/**
36+
* @var \Magento\Catalog\Model\ResourceModel\Category\TreeFactory
37+
*/
38+
private $treeResourceFactory;
39+
3540
/**
3641
* @param \Magento\Catalog\Model\ResourceModel\Category\Tree $categoryTree
3742
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
3843
* @param \Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection
3944
* @param \Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory $treeFactory
45+
* @param \Magento\Catalog\Model\ResourceModel\Category\TreeFactory|null $treeResourceFactory
4046
*/
4147
public function __construct(
4248
\Magento\Catalog\Model\ResourceModel\Category\Tree $categoryTree,
4349
\Magento\Store\Model\StoreManagerInterface $storeManager,
4450
\Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection,
45-
\Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory $treeFactory
51+
\Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory $treeFactory,
52+
\Magento\Catalog\Model\ResourceModel\Category\TreeFactory $treeResourceFactory = null
4653
) {
4754
$this->categoryTree = $categoryTree;
4855
$this->storeManager = $storeManager;
4956
$this->categoryCollection = $categoryCollection;
5057
$this->treeFactory = $treeFactory;
58+
$this->treeResourceFactory = $treeResourceFactory ?? \Magento\Framework\App\ObjectManager::getInstance()
59+
->get(\Magento\Catalog\Model\ResourceModel\Category\TreeFactory::class);
5160
}
5261

5362
/**
63+
* Get root node by category.
64+
*
5465
* @param \Magento\Catalog\Model\Category|null $category
5566
* @return Node|null
67+
* @throws \Magento\Framework\Exception\LocalizedException
68+
* @throws \Magento\Framework\Exception\NoSuchEntityException
5669
*/
5770
public function getRootNode($category = null)
5871
{
@@ -71,21 +84,30 @@ public function getRootNode($category = null)
7184
}
7285

7386
/**
87+
* Get node by category.
88+
*
7489
* @param \Magento\Catalog\Model\Category $category
7590
* @return Node
91+
* @throws \Magento\Framework\Exception\LocalizedException
92+
* @throws \Magento\Framework\Exception\NoSuchEntityException
7693
*/
7794
protected function getNode(\Magento\Catalog\Model\Category $category)
7895
{
7996
$nodeId = $category->getId();
80-
$node = $this->categoryTree->loadNode($nodeId);
97+
$categoryTree = $this->treeResourceFactory->create();
98+
$node = $categoryTree->loadNode($nodeId);
8199
$node->loadChildren();
82100
$this->prepareCollection();
83101
$this->categoryTree->addCollectionData($this->categoryCollection);
84102
return $node;
85103
}
86104

87105
/**
106+
* Prepare category collection.
107+
*
88108
* @return void
109+
* @throws \Magento\Framework\Exception\LocalizedException
110+
* @throws \Magento\Framework\Exception\NoSuchEntityException
89111
*/
90112
protected function prepareCollection()
91113
{
@@ -104,6 +126,8 @@ protected function prepareCollection()
104126
}
105127

106128
/**
129+
* Get tree by node.
130+
*
107131
* @param \Magento\Framework\Data\Tree\Node $node
108132
* @param int $depth
109133
* @param int $currentLevel
@@ -127,6 +151,8 @@ public function getTree($node, $depth = null, $currentLevel = 0)
127151
}
128152

129153
/**
154+
* Get node children.
155+
*
130156
* @param \Magento\Framework\Data\Tree\Node $node
131157
* @param int $depth
132158
* @param int $currentLevel

app/code/Magento/Catalog/Test/Unit/Model/Category/TreeTest.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ class TreeTest extends \PHPUnit\Framework\TestCase
4343
*/
4444
protected $node;
4545

46+
/**
47+
* @var \Magento\Catalog\Model\ResourceModel\Category\TreeFactory
48+
*/
49+
private $treeResourceFactoryMock;
50+
4651
protected function setUp()
4752
{
4853
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -59,6 +64,12 @@ protected function setUp()
5964
\Magento\Store\Model\StoreManagerInterface::class
6065
)->disableOriginalConstructor()->getMock();
6166

67+
$this->treeResourceFactoryMock = $this->createMock(
68+
\Magento\Catalog\Model\ResourceModel\Category\TreeFactory::class
69+
);
70+
$this->treeResourceFactoryMock->method('create')
71+
->willReturn($this->categoryTreeMock);
72+
6273
$methods = ['create'];
6374
$this->treeFactoryMock =
6475
$this->createPartialMock(\Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory::class, $methods);
@@ -70,7 +81,8 @@ protected function setUp()
7081
'categoryCollection' => $this->categoryCollection,
7182
'categoryTree' => $this->categoryTreeMock,
7283
'storeManager' => $this->storeManagerMock,
73-
'treeFactory' => $this->treeFactoryMock
84+
'treeFactory' => $this->treeFactoryMock,
85+
'treeResourceFactory' => $this->treeResourceFactoryMock,
7486
]
7587
);
7688
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* Copyright © Magento, Inc. All rights reserved.
6+
* See COPYING.txt for license details.
7+
*/
8+
9+
namespace Magento\CatalogSearch\Model\ResourceModel\Setup;
10+
11+
use Magento\Eav\Model\Entity\Setup\PropertyMapperAbstract;
12+
13+
/**
14+
* Class PropertyMapper
15+
*
16+
* @package Magento\CatalogSearch\Model\ResourceModel\Setup
17+
*/
18+
class PropertyMapper extends PropertyMapperAbstract
19+
{
20+
/**
21+
* Map input attribute properties to storage representation
22+
*
23+
* @param array $input
24+
* @param int $entityTypeId
25+
* @return array
26+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
27+
*/
28+
public function map(array $input, $entityTypeId): array
29+
{
30+
return [
31+
'search_weight' => $this->_getValue($input, 'search_weight', 1),
32+
];
33+
}
34+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* Copyright © Magento, Inc. All rights reserved.
6+
* See COPYING.txt for license details.
7+
*/
8+
9+
namespace Magento\CatalogSearch\Test\Unit\Model\ResourceModel\Setup;
10+
11+
use Magento\CatalogSearch\Model\ResourceModel\Setup\PropertyMapper;
12+
use PHPUnit\Framework\TestCase;
13+
14+
/**
15+
* Class PropertyMapperTest
16+
*
17+
* @package Magento\CatalogSearch\Test\Unit\Model\ResourceModel\Setup
18+
*/
19+
class PropertyMapperTest extends TestCase
20+
{
21+
/**
22+
* @var PropertyMapper
23+
*/
24+
private $propertyMapper;
25+
26+
/**
27+
* @return void
28+
*/
29+
protected function setUp(): void
30+
{
31+
$this->propertyMapper = new PropertyMapper();
32+
}
33+
34+
/**
35+
* @return array
36+
*/
37+
public function caseProvider(): array
38+
{
39+
return [
40+
[
41+
['search_weight' => 9, 'something_other' => '3'],
42+
['search_weight' => 9]
43+
],
44+
[
45+
['something' => 3],
46+
['search_weight' => 1]
47+
]
48+
];
49+
}
50+
51+
/**
52+
* @dataProvider caseProvider
53+
*
54+
* @test
55+
*
56+
* @param array $input
57+
* @param array $result
58+
* @return void
59+
*/
60+
public function testMapCorrectlyMapsValue(array $input, array $result): void
61+
{
62+
//Second parameter doesn't matter as it is not used
63+
$this->assertSame($result, $this->propertyMapper->map($input, 4));
64+
}
65+
}

app/code/Magento/CatalogSearch/etc/di.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,4 +364,11 @@
364364
<type name="Magento\Config\Model\Config">
365365
<plugin name="config_enable_eav_indexer" type="Magento\CatalogSearch\Plugin\EnableEavIndexer" />
366366
</type>
367+
<type name="Magento\Eav\Model\Entity\Setup\PropertyMapper\Composite">
368+
<arguments>
369+
<argument name="propertyMappers" xsi:type="array">
370+
<item name="catalog_search" xsi:type="string">Magento\CatalogSearch\Model\ResourceModel\Setup\PropertyMapper</item>
371+
</argument>
372+
</arguments>
373+
</type>
367374
</config>

app/code/Magento/CatalogUrlRewrite/Observer/ProductToWebsiteChangeObserver.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
use Magento\Store\Model\Store;
1414
use Magento\UrlRewrite\Model\UrlPersistInterface;
1515
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
16+
use Magento\Store\Api\StoreWebsiteRelationInterface;
17+
use Magento\Framework\App\ObjectManager;
1618

1719
/**
1820
* Observer to assign the products to website
@@ -39,22 +41,31 @@ class ProductToWebsiteChangeObserver implements ObserverInterface
3941
*/
4042
protected $request;
4143

44+
/**
45+
* @var StoreWebsiteRelationInterface
46+
*/
47+
private $storeWebsiteRelation;
48+
4249
/**
4350
* @param ProductUrlRewriteGenerator $productUrlRewriteGenerator
4451
* @param UrlPersistInterface $urlPersist
4552
* @param ProductRepositoryInterface $productRepository
4653
* @param RequestInterface $request
54+
* @param StoreWebsiteRelationInterface $storeWebsiteRelation
4755
*/
4856
public function __construct(
4957
ProductUrlRewriteGenerator $productUrlRewriteGenerator,
5058
UrlPersistInterface $urlPersist,
5159
ProductRepositoryInterface $productRepository,
52-
RequestInterface $request
60+
RequestInterface $request,
61+
StoreWebsiteRelationInterface $storeWebsiteRelation = null
5362
) {
5463
$this->productUrlRewriteGenerator = $productUrlRewriteGenerator;
5564
$this->urlPersist = $urlPersist;
5665
$this->productRepository = $productRepository;
5766
$this->request = $request;
67+
$this->storeWebsiteRelation = $storeWebsiteRelation ?:
68+
ObjectManager::getInstance()->get(StoreWebsiteRelationInterface::class);
5869
}
5970

6071
/**
@@ -73,10 +84,17 @@ public function execute(\Magento\Framework\Event\Observer $observer)
7384
);
7485

7586
if (!empty($this->productUrlRewriteGenerator->generate($product))) {
76-
$this->urlPersist->deleteByData([
77-
UrlRewrite::ENTITY_ID => $product->getId(),
78-
UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
79-
]);
87+
if ($this->request->getParam('remove_website_ids')) {
88+
foreach ($this->request->getParam('remove_website_ids') as $webId) {
89+
foreach ($this->storeWebsiteRelation->getStoreByWebsiteId($webId) as $storeId) {
90+
$this->urlPersist->deleteByData([
91+
UrlRewrite::ENTITY_ID => $product->getId(),
92+
UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
93+
UrlRewrite::STORE_ID => $storeId
94+
]);
95+
}
96+
}
97+
}
8098
if ($product->getVisibility() != Visibility::VISIBILITY_NOT_VISIBLE) {
8199
$this->urlPersist->replace($this->productUrlRewriteGenerator->generate($product));
82100
}

app/code/Magento/Customer/Block/Form/Register.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,6 @@ public function getConfig($path)
8686
return $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
8787
}
8888

89-
/**
90-
* Prepare layout
91-
*
92-
* @return $this
93-
*/
94-
protected function _prepareLayout()
95-
{
96-
$this->pageConfig->getTitle()->set(__('Create New Customer Account'));
97-
return parent::_prepareLayout();
98-
}
99-
10089
/**
10190
* Retrieve form posting url
10291
*

app/code/Magento/Customer/view/frontend/layout/customer_account_create.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
*/
77
-->
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
9+
<head>
10+
<title>Create New Customer Account</title>
11+
</head>
912
<body>
1013
<referenceBlock name="head.components">
1114
<block class="Magento\Framework\View\Element\Js\Components" name="customer_account_create_head_components" template="Magento_Customer::js/components.phtml"/>

0 commit comments

Comments
 (0)