Skip to content

Commit a44be9d

Browse files
committed
MAGETWO-65657: Block "Recently Viewed Products" fatals on category scheduled updates preview
1 parent 59e8864 commit a44be9d

File tree

2 files changed

+17
-45
lines changed

2 files changed

+17
-45
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
@@ -1818,55 +1818,12 @@ protected function _productLimitationJoinStore()
18181818
$this->getSelect()->columns('visibility', 'cat_index');
18191819
}
18201820

1821-
$fromPart = $this->getSelect()->getPart(\Magento\Framework\DB\Select::FROM);
1822-
if (!isset($fromPart['store_index'])) {
1823-
$this->getSelect()->joinLeft(
1824-
['store_index' => $this->getTable('store')],
1825-
'store_index.store_id = ' . $filters['store_table'] . '.store_id',
1826-
[]
1827-
);
1828-
}
1829-
if (!isset($fromPart['store_group_index'])) {
1830-
$this->getSelect()->joinLeft(
1831-
['store_group_index' => $this->getTable('store_group')],
1832-
'store_index.group_id = store_group_index.group_id',
1833-
[]
1834-
);
1835-
}
1836-
if (!isset($fromPart['store_cat_index'])) {
1837-
$this->getSelect()->joinLeft(
1838-
['store_cat_index' => $this->getTable('catalog_category_product_index')],
1839-
join(
1840-
' AND ',
1841-
[
1842-
'store_cat_index.product_id = e.entity_id',
1843-
'store_cat_index.store_id = ' . $filters['store_table'] . '.store_id',
1844-
'store_cat_index.category_id=store_group_index.root_category_id'
1845-
]
1846-
),
1847-
['store_visibility' => 'visibility']
1848-
);
1849-
}
18501821
// Avoid column duplication problems
18511822
$this->_resourceHelper->prepareColumnsList($this->getSelect());
18521823

1853-
$whereCond = join(
1854-
' OR ',
1855-
[
1856-
$this->getConnection()->quoteInto('cat_index.visibility IN(?)', $filters['visibility']),
1857-
$this->getConnection()->quoteInto('store_cat_index.visibility IN(?)', $filters['visibility'])
1858-
]
1859-
);
1860-
1824+
$whereCond = $this->getConnection()->quoteInto('cat_index.visibility IN(?)', $filters['visibility']);
18611825
$wherePart = $this->getSelect()->getPart(\Magento\Framework\DB\Select::WHERE);
1862-
$hasCond = false;
1863-
foreach ($wherePart as $cond) {
1864-
if ($cond == '(' . $whereCond . ')') {
1865-
$hasCond = true;
1866-
}
1867-
}
1868-
1869-
if (!$hasCond) {
1826+
if (array_search('(' . $whereCond . ')', $wherePart) === false) {
18701827
$this->getSelect()->where($whereCond);
18711828
}
18721829

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,25 @@ public function clearCache()
5959
}
6060
$this->_sharedInstances = $sharedInstances;
6161
$this->_config->clean();
62+
$this->clearMappedTableNames();
6263

6364
return $this;
6465
}
6566

67+
/**
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+
$reflection = new \ReflectionClass($resourceConnection);
76+
$dataProperty = $reflection->getProperty('mappedTableNames');
77+
$dataProperty->setAccessible(true);
78+
$dataProperty->setValue($resourceConnection, null);
79+
}
80+
6681
/**
6782
* Add shared instance
6883
*

0 commit comments

Comments
 (0)