Skip to content

Commit 99b758b

Browse files
committed
Merge remote-tracking branch 'tango/MC-37347' into PR-10-14
2 parents ee00b94 + 8cade14 commit 99b758b

File tree

2 files changed

+15
-77
lines changed

2 files changed

+15
-77
lines changed

app/code/Magento/Catalog/Test/Mftf/Test/AdminFilterByNameByStoreViewOnProductGridTest.xml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,39 @@
1515
<title value="Product grid filtering by store view level attribute"/>
1616
<description value="Verify that products grid can be filtered on all store view level by attribute"/>
1717
<severity value="MAJOR"/>
18-
<testCaseId value="MAGETWO-98755"/>
19-
<useCaseId value="MAGETWO-98335"/>
18+
<testCaseId value="MC-28534"/>
19+
<useCaseId value="MC-37347"/>
2020
<group value="catalog"/>
2121
</annotations>
22+
2223
<before>
23-
<createData entity="SimpleProduct2" stepKey="createSimpleProduct"/>
24+
<createData entity="SimpleProduct2" stepKey="createSimpleProduct1"/>
25+
<createData entity="SimpleProduct2" stepKey="createSimpleProduct2"/>
2426
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
2527
</before>
28+
2629
<after>
27-
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
30+
<deleteData createDataKey="createSimpleProduct1" stepKey="deleteSimpleProduct1"/>
31+
<deleteData createDataKey="createSimpleProduct2" stepKey="deleteSimpleProduct2"/>
2832
<actionGroup ref="ClearProductsFilterActionGroup" stepKey="clearProductsFilter"/>
2933
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
3034
</after>
35+
3136
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="goToEditPage">
32-
<argument name="productId" value="$$createSimpleProduct.id$$"/>
37+
<argument name="productId" value="$$createSimpleProduct1.id$$"/>
3338
</actionGroup>
3439
<actionGroup ref="AdminSwitchStoreViewActionGroup" stepKey="switchToDefaultStoreView">
3540
<argument name="storeView" value="_defaultStore.name"/>
3641
</actionGroup>
3742
<scrollToTopOfPage stepKey="scrollToTopOfAdminProductFormSection"/>
3843
<click selector="{{AdminProductFormSection.productNameUseDefault}}" stepKey="uncheckUseDefault"/>
39-
<fillField selector="{{AdminProductFormSection.productName}}" userInput="{{SimpleProduct.name}}" stepKey="fillNewName"/>
44+
<fillField selector="{{AdminProductFormSection.productName}}" userInput="$$createSimpleProduct2.name$$" stepKey="fillNewName"/>
4045
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveSimpleProduct"/>
4146
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="navigateToProductIndex"/>
42-
<actionGroup ref="FilterProductGridByNameActionGroup" stepKey="filterGridByName">
43-
<argument name="product" value="SimpleProduct"/>
47+
<actionGroup ref="FilterProductGridByName2ActionGroup" stepKey="filterGridByName">
48+
<argument name="name" value="$$createSimpleProduct2.name$$"/>
4449
</actionGroup>
45-
<see selector="{{AdminProductGridSection.firstProductRow}}" userInput="{{SimpleProduct2.name}}" stepKey="seeProductNameInGrid"/>
50+
<seeElement selector="{{AdminProductGridSection.productRowBySku('$$createSimpleProduct2.sku$$')}}" stepKey="seeProduct2InGrid"/>
51+
<dontSeeElement selector="{{AdminProductGridSection.productRowBySku('$$createSimpleProduct1.sku$$')}}" stepKey="dontSeeProduct1InGrid"/>
4652
</test>
4753
</tests>

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

Lines changed: 0 additions & 68 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,66 +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-
. ')';
93-
$selectExistsInAllStores = $this->getConnection()->select()->from($tableName);
94-
$this->getSelect()->exists($selectExistsInAllStores, $condition);
95-
}
9628
}

0 commit comments

Comments
 (0)