Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.3-develop Minor Fixes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
magento-engcom-team authored Mar 8, 2019
2 parents 73b5b92 + 045cfb3 commit 3caa171
Show file tree
Hide file tree
Showing 16 changed files with 318 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ protected function saveAndReplaceAdvancedPrices()
} elseif (\Magento\ImportExport\Model\Import::BEHAVIOR_APPEND == $behavior) {
$this->processCountExistingPrices($tierPrices, self::TABLE_TIER_PRICE)
->processCountNewPrices($tierPrices);

$this->saveProductPrices($tierPrices, self::TABLE_TIER_PRICE);
if ($listSku) {
$this->setUpdatedAt($listSku);
Expand Down Expand Up @@ -562,11 +563,14 @@ protected function processCountExistingPrices($prices, $table)

$tableName = $this->_resourceFactory->create()->getTable($table);
$productEntityLinkField = $this->getProductEntityLinkField();
$existingPrices = $this->_connection->fetchAssoc(
$existingPrices = $this->_connection->fetchAll(
$this->_connection->select()->from(
$tableName,
['value_id', $productEntityLinkField, 'all_groups', 'customer_group_id']
)->where($productEntityLinkField . ' IN (?)', $existProductIds)
[$productEntityLinkField, 'all_groups', 'customer_group_id', 'qty']
)->where(
$productEntityLinkField . ' IN (?)',
$existProductIds
)
);
foreach ($existingPrices as $existingPrice) {
foreach ($prices as $sku => $skuPrices) {
Expand All @@ -591,8 +595,10 @@ protected function incrementCounterUpdated($prices, $existingPrice)
foreach ($prices as $price) {
if ($existingPrice['all_groups'] == $price['all_groups']
&& $existingPrice['customer_group_id'] == $price['customer_group_id']
&& (int) $existingPrice['qty'] === (int) $price['qty']
) {
$this->countItemsUpdated++;
continue;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ public function testProcessCountExistingPrices(
);
$dbSelectMock = $this->createMock(\Magento\Framework\DB\Select::class);
$this->connection->expects($this->once())
->method('fetchAssoc')
->method('fetchAll')
->willReturn($existingPrices);
$this->connection->expects($this->once())
->method('select')
Expand All @@ -930,7 +930,7 @@ public function testProcessCountExistingPrices(
->method('from')
->with(
self::TABLE_NAME,
['value_id', self::LINK_FIELD, 'all_groups', 'customer_group_id']
[self::LINK_FIELD, 'all_groups', 'customer_group_id', 'qty']
)->willReturnSelf();
$this->advancedPricing->expects($this->once())
->method('retrieveOldSkus')
Expand Down
30 changes: 28 additions & 2 deletions app/code/Magento/Catalog/Model/Category/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,40 @@ class Tree
*/
protected $treeFactory;

/**
* @var \Magento\Catalog\Model\ResourceModel\Category\TreeFactory
*/
private $treeResourceFactory;

/**
* @param \Magento\Catalog\Model\ResourceModel\Category\Tree $categoryTree
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection
* @param \Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory $treeFactory
* @param \Magento\Catalog\Model\ResourceModel\Category\TreeFactory|null $treeResourceFactory
*/
public function __construct(
\Magento\Catalog\Model\ResourceModel\Category\Tree $categoryTree,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection,
\Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory $treeFactory
\Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory $treeFactory,
\Magento\Catalog\Model\ResourceModel\Category\TreeFactory $treeResourceFactory = null
) {
$this->categoryTree = $categoryTree;
$this->storeManager = $storeManager;
$this->categoryCollection = $categoryCollection;
$this->treeFactory = $treeFactory;
$this->treeResourceFactory = $treeResourceFactory ?? \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Catalog\Model\ResourceModel\Category\TreeFactory::class);
}

/**
* Get root node by category.
*
* @param \Magento\Catalog\Model\Category|null $category
* @return Node|null
* @throws \Magento\Framework\Exception\LocalizedException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function getRootNode($category = null)
{
Expand All @@ -71,21 +84,30 @@ public function getRootNode($category = null)
}

/**
* Get node by category.
*
* @param \Magento\Catalog\Model\Category $category
* @return Node
* @throws \Magento\Framework\Exception\LocalizedException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
protected function getNode(\Magento\Catalog\Model\Category $category)
{
$nodeId = $category->getId();
$node = $this->categoryTree->loadNode($nodeId);
$categoryTree = $this->treeResourceFactory->create();
$node = $categoryTree->loadNode($nodeId);
$node->loadChildren();
$this->prepareCollection();
$this->categoryTree->addCollectionData($this->categoryCollection);
return $node;
}

/**
* Prepare category collection.
*
* @return void
* @throws \Magento\Framework\Exception\LocalizedException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
protected function prepareCollection()
{
Expand All @@ -104,6 +126,8 @@ protected function prepareCollection()
}

/**
* Get tree by node.
*
* @param \Magento\Framework\Data\Tree\Node $node
* @param int $depth
* @param int $currentLevel
Expand All @@ -127,6 +151,8 @@ public function getTree($node, $depth = null, $currentLevel = 0)
}

/**
* Get node children.
*
* @param \Magento\Framework\Data\Tree\Node $node
* @param int $depth
* @param int $currentLevel
Expand Down
14 changes: 13 additions & 1 deletion app/code/Magento/Catalog/Test/Unit/Model/Category/TreeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class TreeTest extends \PHPUnit\Framework\TestCase
*/
protected $node;

/**
* @var \Magento\Catalog\Model\ResourceModel\Category\TreeFactory
*/
private $treeResourceFactoryMock;

protected function setUp()
{
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
Expand All @@ -59,6 +64,12 @@ protected function setUp()
\Magento\Store\Model\StoreManagerInterface::class
)->disableOriginalConstructor()->getMock();

$this->treeResourceFactoryMock = $this->createMock(
\Magento\Catalog\Model\ResourceModel\Category\TreeFactory::class
);
$this->treeResourceFactoryMock->method('create')
->willReturn($this->categoryTreeMock);

$methods = ['create'];
$this->treeFactoryMock =
$this->createPartialMock(\Magento\Catalog\Api\Data\CategoryTreeInterfaceFactory::class, $methods);
Expand All @@ -70,7 +81,8 @@ protected function setUp()
'categoryCollection' => $this->categoryCollection,
'categoryTree' => $this->categoryTreeMock,
'storeManager' => $this->storeManagerMock,
'treeFactory' => $this->treeFactoryMock
'treeFactory' => $this->treeFactoryMock,
'treeResourceFactory' => $this->treeResourceFactoryMock,
]
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\CatalogSearch\Model\ResourceModel\Setup;

use Magento\Eav\Model\Entity\Setup\PropertyMapperAbstract;

/**
* Class PropertyMapper
*
* @package Magento\CatalogSearch\Model\ResourceModel\Setup
*/
class PropertyMapper extends PropertyMapperAbstract
{
/**
* Map input attribute properties to storage representation
*
* @param array $input
* @param int $entityTypeId
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function map(array $input, $entityTypeId): array
{
return [
'search_weight' => $this->_getValue($input, 'search_weight', 1),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
declare(strict_types=1);

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\CatalogSearch\Test\Unit\Model\ResourceModel\Setup;

use Magento\CatalogSearch\Model\ResourceModel\Setup\PropertyMapper;
use PHPUnit\Framework\TestCase;

/**
* Class PropertyMapperTest
*
* @package Magento\CatalogSearch\Test\Unit\Model\ResourceModel\Setup
*/
class PropertyMapperTest extends TestCase
{
/**
* @var PropertyMapper
*/
private $propertyMapper;

/**
* @return void
*/
protected function setUp(): void
{
$this->propertyMapper = new PropertyMapper();
}

/**
* @return array
*/
public function caseProvider(): array
{
return [
[
['search_weight' => 9, 'something_other' => '3'],
['search_weight' => 9]
],
[
['something' => 3],
['search_weight' => 1]
]
];
}

/**
* @dataProvider caseProvider
*
* @test
*
* @param array $input
* @param array $result
* @return void
*/
public function testMapCorrectlyMapsValue(array $input, array $result): void
{
//Second parameter doesn't matter as it is not used
$this->assertSame($result, $this->propertyMapper->map($input, 4));
}
}
7 changes: 7 additions & 0 deletions app/code/Magento/CatalogSearch/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,11 @@
<type name="Magento\Config\Model\Config">
<plugin name="config_enable_eav_indexer" type="Magento\CatalogSearch\Plugin\EnableEavIndexer" />
</type>
<type name="Magento\Eav\Model\Entity\Setup\PropertyMapper\Composite">
<arguments>
<argument name="propertyMappers" xsi:type="array">
<item name="catalog_search" xsi:type="string">Magento\CatalogSearch\Model\ResourceModel\Setup\PropertyMapper</item>
</argument>
</arguments>
</type>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use Magento\Store\Model\Store;
use Magento\UrlRewrite\Model\UrlPersistInterface;
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
use Magento\Store\Api\StoreWebsiteRelationInterface;
use Magento\Framework\App\ObjectManager;

/**
* Observer to assign the products to website
Expand All @@ -39,22 +41,31 @@ class ProductToWebsiteChangeObserver implements ObserverInterface
*/
protected $request;

/**
* @var StoreWebsiteRelationInterface
*/
private $storeWebsiteRelation;

/**
* @param ProductUrlRewriteGenerator $productUrlRewriteGenerator
* @param UrlPersistInterface $urlPersist
* @param ProductRepositoryInterface $productRepository
* @param RequestInterface $request
* @param StoreWebsiteRelationInterface $storeWebsiteRelation
*/
public function __construct(
ProductUrlRewriteGenerator $productUrlRewriteGenerator,
UrlPersistInterface $urlPersist,
ProductRepositoryInterface $productRepository,
RequestInterface $request
RequestInterface $request,
StoreWebsiteRelationInterface $storeWebsiteRelation = null
) {
$this->productUrlRewriteGenerator = $productUrlRewriteGenerator;
$this->urlPersist = $urlPersist;
$this->productRepository = $productRepository;
$this->request = $request;
$this->storeWebsiteRelation = $storeWebsiteRelation ?:
ObjectManager::getInstance()->get(StoreWebsiteRelationInterface::class);
}

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

if (!empty($this->productUrlRewriteGenerator->generate($product))) {
$this->urlPersist->deleteByData([
UrlRewrite::ENTITY_ID => $product->getId(),
UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
]);
if ($this->request->getParam('remove_website_ids')) {
foreach ($this->request->getParam('remove_website_ids') as $webId) {
foreach ($this->storeWebsiteRelation->getStoreByWebsiteId($webId) as $storeId) {
$this->urlPersist->deleteByData([
UrlRewrite::ENTITY_ID => $product->getId(),
UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
UrlRewrite::STORE_ID => $storeId
]);
}
}
}
if ($product->getVisibility() != Visibility::VISIBILITY_NOT_VISIBLE) {
$this->urlPersist->replace($this->productUrlRewriteGenerator->generate($product));
}
Expand Down
11 changes: 0 additions & 11 deletions app/code/Magento/Customer/Block/Form/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,6 @@ public function getConfig($path)
return $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
}

/**
* Prepare layout
*
* @return $this
*/
protected function _prepareLayout()
{
$this->pageConfig->getTitle()->set(__('Create New Customer Account'));
return parent::_prepareLayout();
}

/**
* Retrieve form posting url
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<title>Create New Customer Account</title>
</head>
<body>
<referenceBlock name="head.components">
<block class="Magento\Framework\View\Element\Js\Components" name="customer_account_create_head_components" template="Magento_Customer::js/components.phtml"/>
Expand Down
Loading

0 comments on commit 3caa171

Please sign in to comment.