@@ -1818,55 +1818,12 @@ protected function _productLimitationJoinStore()
1818
1818
$ this ->getSelect ()->columns ('visibility ' , 'cat_index ' );
1819
1819
}
1820
1820
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
- }
1850
1821
// Avoid column duplication problems
1851
1822
$ this ->_resourceHelper ->prepareColumnsList ($ this ->getSelect ());
1852
1823
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 ' ]);
1861
1825
$ 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 ) {
1870
1827
$ this ->getSelect ()->where ($ whereCond );
1871
1828
}
1872
1829
0 commit comments