File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 77
88namespace Magento \CatalogGraphQl \Model \Resolver \Category \DataProvider ;
99
10+ use Magento \Catalog \Api \Data \CategoryInterface ;
1011use Magento \Catalog \Model \ResourceModel \Category \CollectionFactory ;
1112
1213/**
@@ -46,6 +47,7 @@ public function getData(string $categoryPath): array
4647 $ collection = $ this ->collectionFactory ->create ();
4748 $ collection ->addAttributeToSelect (['name ' , 'url_key ' , 'url_path ' ]);
4849 $ collection ->addAttributeToFilter ('entity_id ' , $ parentCategoryIds );
50+ $ collection ->addAttributeToFilter (CategoryInterface::KEY_IS_ACTIVE , 1 );
4951
5052 foreach ($ collection as $ category ) {
5153 $ breadcrumbsData [] = [
Original file line number Diff line number Diff line change @@ -660,6 +660,45 @@ public function testCategoryImage(?string $imagePrefix)
660660 $ this ->assertEquals ($ expectedImageUrl , $ childCategory ['image ' ]);
661661 }
662662
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+
663702 /**
664703 * @return array
665704 */
You can’t perform that action at this time.
0 commit comments