File tree 2 files changed +41
-0
lines changed
app/code/Magento/CatalogGraphQl/Model/Resolver/Category/DataProvider
dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 7
7
8
8
namespace Magento \CatalogGraphQl \Model \Resolver \Category \DataProvider ;
9
9
10
+ use Magento \Catalog \Api \Data \CategoryInterface ;
10
11
use Magento \Catalog \Model \ResourceModel \Category \CollectionFactory ;
11
12
12
13
/**
@@ -46,6 +47,7 @@ public function getData(string $categoryPath): array
46
47
$ collection = $ this ->collectionFactory ->create ();
47
48
$ collection ->addAttributeToSelect (['name ' , 'url_key ' , 'url_path ' ]);
48
49
$ collection ->addAttributeToFilter ('entity_id ' , $ parentCategoryIds );
50
+ $ collection ->addAttributeToFilter (CategoryInterface::KEY_IS_ACTIVE , 1 );
49
51
50
52
foreach ($ collection as $ category ) {
51
53
$ breadcrumbsData [] = [
Original file line number Diff line number Diff line change @@ -660,6 +660,45 @@ public function testCategoryImage(?string $imagePrefix)
660
660
$ this ->assertEquals ($ expectedImageUrl , $ childCategory ['image ' ]);
661
661
}
662
662
663
+ /**
664
+ * Testing breadcrumbs that shouldn't include disabled parent categories
665
+ *
666
+ * @magentoApiDataFixture Magento/Catalog/_files/categories.php
667
+ */
668
+ public function testBreadCrumbsWithDisabledParentCategory ()
669
+ {
670
+ $ parentCategoryId = 4 ;
671
+ $ childCategoryId = 5 ;
672
+ $ category = $ this ->categoryRepository ->get ($ parentCategoryId );
673
+ $ category ->setIsActive (false );
674
+ $ this ->categoryRepository ->save ($ category );
675
+
676
+ $ query = <<<QUERY
677
+ {
678
+ category(id: {$ childCategoryId }) {
679
+ name
680
+ breadcrumbs {
681
+ category_id
682
+ category_name
683
+ }
684
+ }
685
+ }
686
+ QUERY ;
687
+ $ response = $ this ->graphQlQuery ($ query );
688
+ $ expectedResponse = [
689
+ 'category ' => [
690
+ 'name ' => 'Category 1.1.1 ' ,
691
+ 'breadcrumbs ' => [
692
+ [
693
+ 'category_id ' => 3 ,
694
+ 'category_name ' => "Category 1 " ,
695
+ ]
696
+ ]
697
+ ]
698
+ ];
699
+ $ this ->assertEquals ($ expectedResponse , $ response );
700
+ }
701
+
663
702
/**
664
703
* @return array
665
704
*/
You can’t perform that action at this time.
0 commit comments