Skip to content

Commit 9bfd3d4

Browse files
MC-19916: Attribute not showing on layered navigation if no value set for "All Store Views"
1 parent c2634a5 commit 9bfd3d4

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

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

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

8+
use Magento\Framework\Exception\NoSuchEntityException;
89
use Magento\TestFramework\Helper\Bootstrap;
910
use Magento\Eav\Api\AttributeRepositoryInterface;
1011
use Magento\Catalog\Api\ProductRepositoryInterface;
@@ -22,20 +23,22 @@
2223
$registry->register('isSecureArea', true);
2324

2425
$eavConfig = $objectManager->get(EavConfig::class);
25-
$attributesToDelete = ['dropdown_without_default'];
26+
$eavConfig->clear();
2627
/** @var AttributeRepositoryInterface $attributeRepository */
2728
$attributeRepository = $objectManager->get(AttributeRepositoryInterface::class);
28-
/** @var AttributeInterface $attribute */
29-
$attribute = $attributeRepository->get(ProductAttributeInterface::ENTITY_TYPE_CODE, 'dropdown_without_default');
30-
$attributeRepository->delete($attribute);
31-
$eavConfig->clear();
32-
3329
/** @var ProductRepositoryInterface $productRepository */
3430
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
35-
/** @var ProductInterface $product */
36-
$product = $productRepository->get('test_attribute_dropdown_without_default');
37-
if ($product->getId()) {
31+
try {
32+
/** @var AttributeInterface $attribute */
33+
$attribute = $attributeRepository->get(ProductAttributeInterface::ENTITY_TYPE_CODE, 'dropdown_without_default');
34+
$attributeRepository->delete($attribute);
35+
} catch (NoSuchEntityException $e) {
36+
}
37+
try {
38+
/** @var ProductInterface $product */
39+
$product = $productRepository->get('test_attribute_dropdown_without_default');
3840
$productRepository->delete($product);
41+
} catch (NoSuchEntityException $e) {
3942
}
4043
$objectManager->get(ProductEav::class)->executeRow($product->getId());
4144

0 commit comments

Comments
 (0)