Skip to content

Commit 9341053

Browse files
committed
BUG#AC-434[Integration] Magento\Catalog\Block\Product\ListProduct\SortingTest failure on 2.4-develop - issue fixed
1 parent 28c1f28 commit 9341053

File tree

2 files changed

+73
-4
lines changed

2 files changed

+73
-4
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ListProduct/SortingTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ private function updateCategorySortBy(
392392
/**
393393
* Test product list ordered by price with out-of-stock configurable product options with elasticsearch engine
394394
*
395-
* @magentoDataFixture Magento/Catalog/_files/products_with_not_empty_layered_navigation_attribute.php
395+
* @magentoDataFixture Magento/Catalog/_files/products_with_not_empty_layered_navigation_attributes.php
396396
* @magentoDataFixture Magento/Framework/Search/_files/product_configurable_with_out-of-stock_child.php
397397
* @magentoConfigFixture current_store cataloginventory/options/show_out_of_stock 1
398398
* @magentoConfigFixture default/catalog/search/engine elasticsearch7
@@ -407,14 +407,13 @@ public function testProductListOutOfStockSortOrderWithElasticsearch(
407407
string $direction,
408408
array $expected
409409
): void {
410-
$this->markTestSkipped('MC-40449: ListProduct\SortingTest failure on 2.4-develop');
411410
$this->assertProductListSortOrderWithConfig($sortBy, $direction, $expected);
412411
}
413412

414413
/**
415414
* Test product list ordered by price with out-of-stock configurable product options with mysql search engine
416415
*
417-
* @magentoDataFixture Magento/Catalog/_files/products_with_not_empty_layered_navigation_attribute.php
416+
* @magentoDataFixture Magento/Catalog/_files/products_with_not_empty_layered_navigation_attributes.php
418417
* @magentoDataFixture Magento/Framework/Search/_files/product_configurable_with_out-of-stock_child.php
419418
* @magentoConfigFixture current_store cataloginventory/options/show_out_of_stock 1
420419
* @magentoConfigFixture default/catalog/search/engine mysql
@@ -429,7 +428,6 @@ public function testProductListOutOfStockSortOrderWithMysql(
429428
string $direction,
430429
array $expected
431430
): void {
432-
$this->markTestSkipped('MC-40449: ListProduct\SortingTest failure on 2.4-develop');
433431
$this->assertProductListSortOrderWithConfig($sortBy, $direction, $expected);
434432
}
435433

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Catalog\Api\CategoryRepositoryInterface;
9+
use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
10+
use Magento\Catalog\Api\ProductRepositoryInterface;
11+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
12+
use Magento\Store\Model\Store;
13+
use Magento\Store\Model\StoreManagerInterface;
14+
use Magento\TestFramework\Catalog\Model\GetCategoryByName;
15+
use Magento\TestFramework\Helper\Bootstrap;
16+
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
17+
18+
Resolver::getInstance()->requireDataFixture(
19+
'Magento/Catalog/_files/products_with_layered_navigation_attribute.php'
20+
);
21+
22+
$objectManager = Bootstrap::getObjectManager();
23+
/** @var StoreManagerInterface $storeManager */
24+
$storeManager = $objectManager->get(StoreManagerInterface::class);
25+
/** @var ProductAttributeRepositoryInterface $attributeRepository */
26+
$attributeRepository = $objectManager->create(ProductAttributeRepositoryInterface::class);
27+
/** @var ProductRepositoryInterface $productRepository */
28+
$productRepository = $objectManager->create(ProductRepositoryInterface::class);
29+
/** @var CategoryRepositoryInterface $categoryRepository */
30+
$categoryRepository = $objectManager->create(CategoryRepositoryInterface::class);
31+
/** @var GetCategoryByName $getCategoryByName */
32+
$getCategoryByName = $objectManager->create(GetCategoryByName::class);
33+
$category = $getCategoryByName->execute('Category 1');
34+
$attribute = $attributeRepository->get('test_configurable');
35+
36+
$firstProduct = $productRepository->get('simple1');
37+
$firstProduct->setData('test_configurable', $attribute->getSource()->getOptionId('Option 1'));
38+
$firstProduct->setStockData(
39+
[
40+
'qty' => 0,
41+
]
42+
);
43+
$productRepository->save($firstProduct);
44+
45+
$secondProduct = $productRepository->get('simple2');
46+
$secondProduct->setData('test_configurable', $attribute->getSource()->getOptionId('Option 2'));
47+
$secondProduct->setStockData(
48+
[
49+
'qty' => 0,
50+
]
51+
);
52+
$productRepository->save($secondProduct);
53+
54+
$thirdProduct = $productRepository->get('simple3');
55+
$thirdProduct->setData('test_configurable', $attribute->getSource()->getOptionId('Option 2'));
56+
$thirdProduct->setStockData(
57+
[
58+
'qty' => 0,
59+
]
60+
);
61+
$thirdProduct->setStatus(Status::STATUS_ENABLED);
62+
$productRepository->save($thirdProduct);
63+
64+
$oldStoreId = $storeManager->getStore()->getId();
65+
$storeManager->setCurrentStore(Store::DEFAULT_STORE_ID);
66+
$category->addData(['available_sort_by' => 'position,name,price,test_configurable']);
67+
try {
68+
$categoryRepository->save($category);
69+
} finally {
70+
$storeManager->setCurrentStore($oldStoreId);
71+
}

0 commit comments

Comments
 (0)