Skip to content

Commit df9055d

Browse files
MAGETWO-65657: Block "Recently Viewed Products" fatals on category scheduled updates preview
- Fixed merge conflict
2 parents 95f3797 + 99b6f8c commit df9055d

File tree

3 files changed

+215
-128
lines changed

3 files changed

+215
-128
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,55 +1842,12 @@ protected function _productLimitationJoinStore()
18421842
$this->getSelect()->columns('visibility', 'cat_index');
18431843
}
18441844

1845-
$fromPart = $this->getSelect()->getPart(\Magento\Framework\DB\Select::FROM);
1846-
if (!isset($fromPart['store_index'])) {
1847-
$this->getSelect()->joinLeft(
1848-
['store_index' => $this->getTable('store')],
1849-
'store_index.store_id = ' . $filters['store_table'] . '.store_id',
1850-
[]
1851-
);
1852-
}
1853-
if (!isset($fromPart['store_group_index'])) {
1854-
$this->getSelect()->joinLeft(
1855-
['store_group_index' => $this->getTable('store_group')],
1856-
'store_index.group_id = store_group_index.group_id',
1857-
[]
1858-
);
1859-
}
1860-
if (!isset($fromPart['store_cat_index'])) {
1861-
$this->getSelect()->joinLeft(
1862-
['store_cat_index' => $this->categoryProductIndexerFrontend->getMainTable()],
1863-
join(
1864-
' AND ',
1865-
[
1866-
'store_cat_index.product_id = e.entity_id',
1867-
'store_cat_index.store_id = ' . $filters['store_table'] . '.store_id',
1868-
'store_cat_index.category_id=store_group_index.root_category_id'
1869-
]
1870-
),
1871-
['store_visibility' => 'visibility']
1872-
);
1873-
}
18741845
// Avoid column duplication problems
18751846
$this->_resourceHelper->prepareColumnsList($this->getSelect());
18761847

1877-
$whereCond = join(
1878-
' OR ',
1879-
[
1880-
$this->getConnection()->quoteInto('cat_index.visibility IN(?)', $filters['visibility']),
1881-
$this->getConnection()->quoteInto('store_cat_index.visibility IN(?)', $filters['visibility'])
1882-
]
1883-
);
1884-
1848+
$whereCond = $this->getConnection()->quoteInto('cat_index.visibility IN(?)', $filters['visibility']);
18851849
$wherePart = $this->getSelect()->getPart(\Magento\Framework\DB\Select::WHERE);
1886-
$hasCond = false;
1887-
foreach ($wherePart as $cond) {
1888-
if ($cond == '(' . $whereCond . ')') {
1889-
$hasCond = true;
1890-
}
1891-
}
1892-
1893-
if (!$hasCond) {
1850+
if (array_search('(' . $whereCond . ')', $wherePart) === false) {
18941851
$this->getSelect()->where($whereCond);
18951852
}
18961853

dev/tests/integration/framework/Magento/TestFramework/ObjectManager.php

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
/**
3-
* Test object manager
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
8-
96
namespace Magento\TestFramework;
107

8+
/**
9+
* ObjectManager for integration test framework.
10+
*/
1111
class ObjectManager extends \Magento\Framework\App\ObjectManager
1212
{
1313
/**
@@ -35,7 +35,7 @@ class ObjectManager extends \Magento\Framework\App\ObjectManager
3535
];
3636

3737
/**
38-
* Clear InstanceManager cache
38+
* Clear InstanceManager cache.
3939
*
4040
* @return \Magento\TestFramework\ObjectManager
4141
*/
@@ -59,33 +59,52 @@ public function clearCache()
5959
}
6060
$this->_sharedInstances = $sharedInstances;
6161
$this->_config->clean();
62+
$this->clearMappedTableNames();
6263

6364
return $this;
6465
}
6566

6667
/**
67-
* Add shared instance
68+
* Clear mapped table names list.
69+
*
70+
* @return void
71+
*/
72+
private function clearMappedTableNames()
73+
{
74+
$resourceConnection = $this->get(\Magento\Framework\App\ResourceConnection::class);
75+
if ($resourceConnection) {
76+
$reflection = new \ReflectionClass($resourceConnection);
77+
$dataProperty = $reflection->getProperty('mappedTableNames');
78+
$dataProperty->setAccessible(true);
79+
$dataProperty->setValue($resourceConnection, null);
80+
}
81+
}
82+
83+
/**
84+
* Add shared instance.
6885
*
6986
* @param mixed $instance
7087
* @param string $className
88+
* @return void
7189
*/
7290
public function addSharedInstance($instance, $className)
7391
{
7492
$this->_sharedInstances[$className] = $instance;
7593
}
7694

7795
/**
78-
* Remove shared instance
96+
* Remove shared instance.
7997
*
8098
* @param string $className
99+
* @return void
81100
*/
82101
public function removeSharedInstance($className)
83102
{
84103
unset($this->_sharedInstances[$className]);
85104
}
86105

87106
/**
88-
* Set objectManager
107+
* Set objectManager.
89108
*
90109
* @param \Magento\Framework\ObjectManagerInterface $objectManager
91110
* @return \Magento\Framework\ObjectManagerInterface

0 commit comments

Comments
 (0)