Skip to content

Commit 0cc7d3d

Browse files
MC-30722: Layered Navigation with default product attribute "Price"
1 parent 16a5930 commit 0cc7d3d

File tree

3 files changed

+47
-17
lines changed

3 files changed

+47
-17
lines changed

dev/tests/integration/testsuite/Magento/Catalog/_files/category_with_three_products.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,24 @@
55
*/
66
declare(strict_types=1);
77

8-
use Magento\Catalog\Api\CategoryLinkManagementInterface;
9-
use Magento\TestFramework\Helper\Bootstrap;
8+
use Magento\Catalog\Model\Product\Visibility;
9+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
10+
use Magento\Catalog\Model\Product\Type;
11+
use Magento\Store\Model\Store;
1012

1113
require __DIR__ . '/category_with_different_price_products.php';
12-
require __DIR__ . '/second_product_simple.php';
1314

14-
$objectManager = Bootstrap::getObjectManager();
15-
/** @var CategoryLinkManagementInterface $categoryLinkManagement */
16-
$categoryLinkManagement = $objectManager->get(CategoryLinkManagementInterface::class);
17-
$categoryLinkManagement->assignProductToCategories('simple2', [$category->getId()]);
15+
$product = $productFactory->create();
16+
$product->setTypeId(Type::TYPE_SIMPLE)
17+
->setAttributeSetId(4)
18+
->setStoreId(Store::DEFAULT_STORE_ID)
19+
->setWebsiteIds([1])
20+
->setName('Simple Product2')
21+
->setSku('simple1002')
22+
->setPrice(10)
23+
->setWeight(1)
24+
->setStockData(['use_config_manage_stock' => 0])
25+
->setCategoryIds([$category->getId()])
26+
->setVisibility(Visibility::VISIBILITY_BOTH)
27+
->setStatus(Status::STATUS_ENABLED);
28+
$productRepository->save($product);

dev/tests/integration/testsuite/Magento/Catalog/_files/category_with_three_products_rollback.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,24 @@
55
*/
66
declare(strict_types=1);
77

8-
require __DIR__ . '/second_product_simple_rollback.php';
8+
use Magento\Catalog\Api\ProductRepositoryInterface;
9+
use Magento\Framework\Exception\NoSuchEntityException;
10+
use Magento\Framework\Registry;
11+
use Magento\TestFramework\Helper\Bootstrap;
12+
13+
$objectManager = Bootstrap::getObjectManager();
14+
$registry = $objectManager->get(Registry::class);
15+
$registry->unregister('isSecureArea');
16+
$registry->register('isSecureArea', true);
17+
18+
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
19+
try {
20+
$productRepository->deleteById('simple1002');
21+
} catch (NoSuchEntityException $e) {
22+
//Already deleted.
23+
}
24+
25+
$registry->unregister('isSecureArea');
26+
$registry->register('isSecureArea', false);
27+
928
require __DIR__ . '/category_with_different_price_products_rollback.php';

dev/tests/integration/testsuite/Magento/LayeredNavigation/Block/Navigation/Category/PriceFilterTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function getFiltersDataProvider(): array
6767
return [
6868
'auto_calculation_variation_with_small_price_difference' => [
6969
'config' => ['catalog/layered_navigation/price_range_calculation' => 'auto'],
70-
'products_data' => ['simple1000' => 10.00, 'simple1001' => 20.00, 'simple2' => 50.00],
70+
'products_data' => ['simple1000' => 10.00, 'simple1001' => 20.00, 'simple1002' => 50.00],
7171
'expectation' => [
7272
['label' => '$10.00 - $19.99', 'value' => '10-20', 'count' => 1],
7373
['label' => '$20.00 - $29.99', 'value' => '20-30', 'count' => 1],
@@ -76,15 +76,15 @@ public function getFiltersDataProvider(): array
7676
],
7777
'auto_calculation_variation_with_big_price_difference' => [
7878
'config' => ['catalog/layered_navigation/price_range_calculation' => 'auto'],
79-
'products_data' => ['simple1000' => 10.00, 'simple1001' => 20.00, 'simple2' => 300.00],
79+
'products_data' => ['simple1000' => 10.00, 'simple1001' => 20.00, 'simple1002' => 300.00],
8080
'expectation' => [
8181
['label' => '$0.00 - $99.99', 'value' => '-100', 'count' => 2],
8282
['label' => '$300.00 and above', 'value' => '300-', 'count' => 1],
8383
],
8484
],
8585
'auto_calculation_variation_with_fixed_price_step' => [
8686
'config' => ['catalog/layered_navigation/price_range_calculation' => 'auto'],
87-
'products_data' => ['simple1000' => 300.00, 'simple1001' => 400.00, 'simple2' => 500.00],
87+
'products_data' => ['simple1000' => 300.00, 'simple1001' => 400.00, 'simple1002' => 500.00],
8888
'expectation' => [
8989
['label' => '$300.00 - $399.99', 'value' => '300-400', 'count' => 1],
9090
['label' => '$400.00 - $499.99', 'value' => '400-500', 'count' => 1],
@@ -96,7 +96,7 @@ public function getFiltersDataProvider(): array
9696
'catalog/layered_navigation/price_range_calculation' => 'improved',
9797
'catalog/layered_navigation/interval_division_limit' => 3,
9898
],
99-
'products_data' => ['simple1000' => 10.00, 'simple1001' => 20.00, 'simple2' => 50.00],
99+
'products_data' => ['simple1000' => 10.00, 'simple1001' => 20.00, 'simple1002' => 50.00],
100100
'expectation' => [
101101
['label' => '$0.00 - $49.99', 'value' => '-50', 'count' => 2],
102102
['label' => '$50.00 and above', 'value' => '50-', 'count' => 1],
@@ -107,7 +107,7 @@ public function getFiltersDataProvider(): array
107107
'catalog/layered_navigation/price_range_calculation' => 'improved',
108108
'catalog/layered_navigation/interval_division_limit' => 3,
109109
],
110-
'products_data' => ['simple1000' => 10.00, 'simple1001' => 20.00, 'simple2' => 300.00],
110+
'products_data' => ['simple1000' => 10.00, 'simple1001' => 20.00, 'simple1002' => 300.00],
111111
'expectation' => [
112112
['label' => '$0.00 - $299.99', 'value' => '-300', 'count' => 2.0],
113113
['label' => '$300.00 and above', 'value' => '300-', 'count' => 1.0],
@@ -118,7 +118,7 @@ public function getFiltersDataProvider(): array
118118
'catalog/layered_navigation/price_range_calculation' => 'manual',
119119
'catalog/layered_navigation/price_range_step' => 200,
120120
],
121-
'products_data' => ['simple1000' => 300.00, 'simple1001' => 300.00, 'simple2' => 500.00],
121+
'products_data' => ['simple1000' => 300.00, 'simple1001' => 300.00, 'simple1002' => 500.00],
122122
'expectation' => [
123123
['label' => '$200.00 - $399.99', 'value' => '200-400', 'count' => 2],
124124
['label' => '$400.00 and above', 'value' => '400-', 'count' => 1],
@@ -129,7 +129,7 @@ public function getFiltersDataProvider(): array
129129
'catalog/layered_navigation/price_range_calculation' => 'manual',
130130
'catalog/layered_navigation/price_range_step' => 10,
131131
],
132-
'products_data' => ['simple1000' => 300.00, 'simple1001' => 300.00, 'simple2' => 500.00],
132+
'products_data' => ['simple1000' => 300.00, 'simple1001' => 300.00, 'simple1002' => 500.00],
133133
'expectation' => [
134134
['label' => '$300.00 - $309.99', 'value' => '300-310', 'count' => 2],
135135
['label' => '$500.00 and above', 'value' => '500-', 'count' => 1],
@@ -141,7 +141,7 @@ public function getFiltersDataProvider(): array
141141
'catalog/layered_navigation/price_range_step' => 10,
142142
'catalog/layered_navigation/price_range_max_intervals' => 10,
143143
],
144-
'products_data' => ['simple1000' => 10.00, 'simple1001' => 20.00, 'simple2' => 30.00],
144+
'products_data' => ['simple1000' => 10.00, 'simple1001' => 20.00, 'simple1002' => 30.00],
145145
'expectation' => [
146146
['label' => '$10.00 - $19.99', 'value' => '10-20', 'count' => 1],
147147
['label' => '$20.00 - $29.99', 'value' => '20-30', 'count' => 1],
@@ -154,7 +154,7 @@ public function getFiltersDataProvider(): array
154154
'catalog/layered_navigation/price_range_step' => 10,
155155
'catalog/layered_navigation/price_range_max_intervals' => 2,
156156
],
157-
'products_data' => ['simple1000' => 10.00, 'simple1001' => 20.00, 'simple2' => 30.00],
157+
'products_data' => ['simple1000' => 10.00, 'simple1001' => 20.00, 'simple1002' => 30.00],
158158
'expectation' => [
159159
['label' => '$10.00 - $19.99', 'value' => '10-20', 'count' => 1],
160160
['label' => '$20.00 and above', 'value' => '20-', 'count' => 2],

0 commit comments

Comments
 (0)