Skip to content

Commit 241f07b

Browse files
author
Roman Lytvynenko
committed
MC-29166: CatalogWidget products list doesn't work with anchor category
1 parent 8ea9ae4 commit 241f07b

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

dev/tests/integration/testsuite/Magento/CatalogWidget/Block/Product/ProductListTest.php

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -91,50 +91,6 @@ public function testCreateCollection()
9191
);
9292
}
9393

94-
/**
95-
* Make sure CatalogWidget would display anchor category products recursively from children categories.
96-
*
97-
* 1. Create an anchor root category and a sub category inside it
98-
* 2. Create 2 new products and assign them to the sub categories
99-
* 3. Create product list widget condition to display products from the anchor root category
100-
* 4. Load collection for product list widget and make sure that number of loaded products is correct
101-
*
102-
* @magentoDbIsolation disabled
103-
* @magentoDataFixture Magento/Catalog/_files/product_in_multiple_categories.php
104-
*/
105-
public function testCreateAnchorCollection()
106-
{
107-
// Reindex EAV attributes to enable products filtration by created multiselect attribute
108-
/** @var Processor $eavIndexerProcessor */
109-
$eavIndexerProcessor = $this->objectManager->get(
110-
Processor::class
111-
);
112-
$eavIndexerProcessor->reindexAll();
113-
114-
$this->categoryCollection->addNameToResult()->load();
115-
$rootCategoryId = $this
116-
->categoryCollection
117-
->getItemByColumnValue('name', 'Default Category')
118-
->getId();
119-
120-
$encodedConditions = '^[`1`:^[`type`:`Magento||CatalogWidget||Model||Rule||Condition||Combine`,
121-
`aggregator`:`all`,`value`:`1`,`new_child`:``^],
122-
`1--1`:^[`type`:`Magento||CatalogWidget||Model||Rule||Condition||Product`,
123-
`attribute`:`category_ids`,
124-
`operator`:`==`,`value`:`' . $rootCategoryId . '`^]^]';
125-
126-
$this->block->setData('conditions_encoded', $encodedConditions);
127-
128-
$productCollection = $this->block->createCollection();
129-
$productCollection->load();
130-
131-
$this->assertEquals(
132-
2,
133-
$productCollection->count(),
134-
"Anchor root category does not contain products of it's children."
135-
);
136-
}
137-
13894
/**
13995
* Test product list widget can process condition with dropdown type of attribute
14096
*
@@ -256,4 +212,48 @@ public function testProductListWithDateAttribute()
256212
"Product collection was not filtered according to the widget condition."
257213
);
258214
}
215+
216+
/**
217+
* Make sure CatalogWidget would display anchor category products recursively from children categories.
218+
*
219+
* 1. Create an anchor root category and a sub category inside it
220+
* 2. Create 2 new products and assign them to the sub categories
221+
* 3. Create product list widget condition to display products from the anchor root category
222+
* 4. Load collection for product list widget and make sure that number of loaded products is correct
223+
*
224+
* @magentoDbIsolation disabled
225+
* @magentoDataFixture Magento/Catalog/_files/product_in_multiple_categories.php
226+
*/
227+
public function testCreateAnchorCollection()
228+
{
229+
// Reindex EAV attributes to enable products filtration by created multiselect attribute
230+
/** @var Processor $eavIndexerProcessor */
231+
$eavIndexerProcessor = $this->objectManager->get(
232+
Processor::class
233+
);
234+
$eavIndexerProcessor->reindexAll();
235+
236+
$this->categoryCollection->addNameToResult()->load();
237+
$rootCategoryId = $this
238+
->categoryCollection
239+
->getItemByColumnValue('name', 'Default Category')
240+
->getId();
241+
242+
$encodedConditions = '^[`1`:^[`type`:`Magento||CatalogWidget||Model||Rule||Condition||Combine`,
243+
`aggregator`:`all`,`value`:`1`,`new_child`:``^],
244+
`1--1`:^[`type`:`Magento||CatalogWidget||Model||Rule||Condition||Product`,
245+
`attribute`:`category_ids`,
246+
`operator`:`==`,`value`:`' . $rootCategoryId . '`^]^]';
247+
248+
$this->block->setData('conditions_encoded', $encodedConditions);
249+
250+
$productCollection = $this->block->createCollection();
251+
$productCollection->load();
252+
253+
$this->assertEquals(
254+
2,
255+
$productCollection->count(),
256+
"Anchor root category does not contain products of it's children."
257+
);
258+
}
259259
}

0 commit comments

Comments
 (0)