Skip to content

Commit 0929769

Browse files
committed
ACP2E-3505: Disabled product still appears in related, upsell, crosssell items in grpahQL query
1 parent e696967 commit 0929769

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/RelatedProduct/GetRelatedProductsTest.php

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2019 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -50,6 +50,44 @@ public function testQueryRelatedProducts()
5050
self::assertRelatedProducts($relatedProducts);
5151
}
5252

53+
/**
54+
* @magentoApiDataFixture Magento/Catalog/_files/products_related_disabled.php
55+
* @magentoConfigFixture current_store cataloginventory/options/show_out_of_stock 1
56+
* @magentoConfigFixture current_store catalog/magento_catalogpermissions/enabled 1
57+
* @magentoConfigFixture current_store catalog/magento_catalogpermissions/grant_catalog_category_view 1
58+
* @magentoConfigFixture current_store catalog/magento_catalogpermissions/grant_catalog_product_price 1
59+
* @magentoConfigFixture current_store catalog/magento_catalogpermissions/grant_checkout_items 1
60+
*/
61+
public function testQueryDisableRelatedProductWithShowOutOfStock()
62+
{
63+
$productSku = 'simple_with_cross';
64+
65+
$query = <<<QUERY
66+
{
67+
products(filter: {sku: {eq: "{$productSku}"}})
68+
{
69+
items {
70+
related_products
71+
{
72+
sku
73+
name
74+
url_key
75+
}
76+
}
77+
}
78+
}
79+
QUERY;
80+
$response = $this->graphQlQuery($query);
81+
82+
self::assertArrayHasKey('products', $response);
83+
self::assertArrayHasKey('items', $response['products']);
84+
self::assertCount(1, $response['products']['items']);
85+
self::assertArrayHasKey(0, $response['products']['items']);
86+
self::assertArrayHasKey('related_products', $response['products']['items'][0]);
87+
$relatedProducts = $response['products']['items'][0]['related_products'];
88+
self::assertCount(0, $relatedProducts);
89+
}
90+
5391
/**
5492
* @magentoApiDataFixture Magento/Catalog/_files/products_related_disabled.php
5593
*/

0 commit comments

Comments
 (0)