Skip to content

Commit 818f7a8

Browse files
committed
Merge branch 'MAGETWO-93173' into 2.3-develop-pr2
2 parents 6e2b7b1 + be00ccd commit 818f7a8

File tree

2 files changed

+27
-6
lines changed
  • app/code/Magento/CatalogWidget/Model/Rule/Condition
  • dev/tests/integration/testsuite/Magento/CatalogWidget/Model/Rule/Condition

2 files changed

+27
-6
lines changed

app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
namespace Magento\CatalogWidget\Model\Rule\Condition;
1111

12+
use Magento\Catalog\Api\Data\ProductInterface;
1213
use Magento\Catalog\Model\ProductCategoryList;
1314

1415
/**
@@ -77,17 +78,22 @@ public function __construct(
7778
}
7879

7980
/**
80-
* {@inheritdoc}
81+
* @inheritdoc
8182
*/
8283
public function loadAttributeOptions()
8384
{
8485
$productAttributes = $this->_productResource->loadAllAttributes()->getAttributesByCode();
86+
$productAttributes = array_filter(
87+
$productAttributes,
88+
function ($attribute) {
89+
return $attribute->getFrontendLabel() &&
90+
$attribute->getFrontendInput() !== 'text' &&
91+
$attribute->getAttributeCode() !== ProductInterface::STATUS;
92+
}
93+
);
8594

8695
$attributes = [];
8796
foreach ($productAttributes as $attribute) {
88-
if (!$attribute->getFrontendLabel() || $attribute->getFrontendInput() == 'text') {
89-
continue;
90-
}
9197
$attributes[$attribute->getAttributeCode()] = $attribute->getFrontendLabel();
9298
}
9399

dev/tests/integration/testsuite/Magento/CatalogWidget/Model/Rule/Condition/ProductTest.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Magento\CatalogWidget\Model\Rule\Condition;
88

9+
use Magento\Catalog\Api\Data\ProductInterface;
10+
911
class ProductTest extends \PHPUnit\Framework\TestCase
1012
{
1113
/**
@@ -18,6 +20,9 @@ class ProductTest extends \PHPUnit\Framework\TestCase
1820
*/
1921
protected $objectManager;
2022

23+
/**
24+
* @inheritdoc
25+
*/
2126
protected function setUp()
2227
{
2328
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
@@ -28,19 +33,26 @@ protected function setUp()
2833
$this->conditionProduct->setRule($rule);
2934
}
3035

36+
/**
37+
* @return void
38+
*/
3139
public function testLoadAttributeOptions()
3240
{
3341
$this->conditionProduct->loadAttributeOptions();
3442
$options = $this->conditionProduct->getAttributeOption();
35-
$this->assertArrayHasKey('sku', $options);
36-
$this->assertArrayHasKey('attribute_set_id', $options);
43+
$this->assertArrayHasKey(ProductInterface::SKU, $options);
44+
$this->assertArrayHasKey(ProductInterface::ATTRIBUTE_SET_ID, $options);
3745
$this->assertArrayHasKey('category_ids', $options);
46+
$this->assertArrayNotHasKey(ProductInterface::STATUS, $options);
3847
foreach ($options as $code => $label) {
3948
$this->assertNotEmpty($label);
4049
$this->assertNotEmpty($code);
4150
}
4251
}
4352

53+
/**
54+
* @return void
55+
*/
4456
public function testAddGlobalAttributeToCollection()
4557
{
4658
$collection = $this->objectManager->create(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);
@@ -53,6 +65,9 @@ public function testAddGlobalAttributeToCollection()
5365
$this->assertEquals('at_special_price.value', $this->conditionProduct->getMappedSqlField());
5466
}
5567

68+
/**
69+
* @return void
70+
*/
5671
public function testAddNonGlobalAttributeToCollectionNoProducts()
5772
{
5873
$collection = $this->objectManager->create(\Magento\Catalog\Model\ResourceModel\Product\Collection::class);

0 commit comments

Comments
 (0)