Skip to content

Commit 7a662f5

Browse files
committed
MC-37347: [OnPrem] Catalog Products Filter in 2.3.3 not working correctly
1 parent 79ca62b commit 7a662f5

File tree

1 file changed

+0
-70
lines changed

1 file changed

+0
-70
lines changed

app/code/Magento/Catalog/Ui/DataProvider/Product/ProductCollection.php

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,10 @@
55
*/
66
namespace Magento\Catalog\Ui\DataProvider\Product;
77

8-
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
9-
use Magento\Framework\Exception\LocalizedException;
10-
use Magento\Eav\Model\Entity\Attribute\AttributeInterface;
11-
128
/**
139
* Collection which is used for rendering product list in the backend.
1410
*
1511
* Used for product grid and customizes behavior of the default Product collection for grid needs.
16-
*
17-
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1812
*/
1913
class ProductCollection extends \Magento\Catalog\Model\ResourceModel\Product\Collection
2014
{
@@ -31,68 +25,4 @@ protected function _productLimitationJoinPrice()
3125
$this->_productLimitationFilters->setUsePriceIndex(false);
3226
return $this->_productLimitationPrice(true);
3327
}
34-
35-
/**
36-
* Add attribute filter to collection
37-
*
38-
* @param AttributeInterface|integer|string|array $attribute
39-
* @param null|string|array $condition
40-
* @param string $joinType
41-
* @return $this
42-
* @throws LocalizedException
43-
*/
44-
public function addAttributeToFilter($attribute, $condition = null, $joinType = 'inner')
45-
{
46-
$storeId = (int)$this->getStoreId();
47-
if ($attribute === 'is_saleable'
48-
|| is_array($attribute)
49-
|| $storeId !== $this->getDefaultStoreId()
50-
) {
51-
return parent::addAttributeToFilter($attribute, $condition, $joinType);
52-
}
53-
54-
if ($attribute instanceof AttributeInterface) {
55-
$attributeModel = $attribute;
56-
} else {
57-
$attributeModel = $this->getEntity()->getAttribute($attribute);
58-
if ($attributeModel === false) {
59-
throw new LocalizedException(
60-
__('Invalid attribute identifier for filter (%1)', get_class($attribute))
61-
);
62-
}
63-
}
64-
65-
if ($attributeModel->isScopeGlobal() || $attributeModel->getBackend()->isStatic()) {
66-
return parent::addAttributeToFilter($attribute, $condition, $joinType);
67-
}
68-
69-
$this->addAttributeToFilterAllStores($attributeModel, $condition);
70-
71-
return $this;
72-
}
73-
74-
/**
75-
* Add attribute to filter by all stores
76-
*
77-
* @param Attribute $attributeModel
78-
* @param array $condition
79-
* @return void
80-
*/
81-
private function addAttributeToFilterAllStores(Attribute $attributeModel, array $condition): void
82-
{
83-
$tableName = $this->getTable($attributeModel->getBackendTable());
84-
$entity = $this->getEntity();
85-
$fKey = 'e.' . $this->getEntityPkName($entity);
86-
$pKey = $tableName . '.' . $this->getEntityPkName($entity);
87-
$attributeId = $attributeModel->getAttributeId();
88-
$condition = "({$pKey} = {$fKey}) AND ("
89-
. $this->_getConditionSql("{$tableName}.value", $condition)
90-
. ') AND ('
91-
. $this->_getConditionSql("{$tableName}.attribute_id", $attributeId)
92-
. ') AND ('
93-
. $this->_getConditionSql("{$tableName}.store_id", $this->getDefaultStoreId())
94-
. ')';
95-
$selectExistsInAllStores = $this->getConnection()->select()->from($tableName);
96-
$this->getSelect()->exists($selectExistsInAllStores, $condition);
97-
}
9828
}

0 commit comments

Comments
 (0)