File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed
dev/tests/integration/testsuite/Magento/Catalog/Block/Product Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -136,7 +136,14 @@ public function getLayer()
136136 */
137137 public function getLoadedProductCollection ()
138138 {
139- return $ this ->_getProductCollection ();
139+ $ collection = $ this ->_getProductCollection ();
140+
141+ $ categoryId = $ this ->getLayer ()->getCurrentCategory ()->getId ();
142+ foreach ($ collection as $ product ) {
143+ $ product ->setData ('category_id ' , $ categoryId );
144+ }
145+
146+ return $ collection ;
140147 }
141148
142149 /**
Original file line number Diff line number Diff line change @@ -725,9 +725,14 @@ public function getIdBySku($sku)
725725 */
726726 public function getCategoryId ()
727727 {
728+ if ($ this ->hasData ('category_id ' )) {
729+ return $ this ->getData ('category_id ' );
730+ }
728731 $ category = $ this ->_registry ->registry ('current_category ' );
729- if ($ category && in_array ($ category ->getId (), $ this ->getCategoryIds ())) {
730- return $ category ->getId ();
732+ $ categoryId = $ category ? $ category ->getId () : null ;
733+ if ($ categoryId && in_array ($ categoryId , $ this ->getCategoryIds ())) {
734+ $ this ->setData ('category_id ' , $ categoryId );
735+ return $ categoryId ;
731736 }
732737 return false ;
733738 }
Original file line number Diff line number Diff line change @@ -92,8 +92,10 @@ public function testGetAdditionalHtml()
9292
9393 public function testSetCollection ()
9494 {
95- $ this ->_block ->setCollection ('test ' );
96- $ this ->assertEquals ('test ' , $ this ->_block ->getLoadedProductCollection ());
95+ $ collection = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()
96+ ->create (\Magento \Framework \Data \Collection::class);
97+ $ this ->_block ->setCollection ($ collection );
98+ $ this ->assertEquals ($ collection , $ this ->_block ->getLoadedProductCollection ());
9799 }
98100
99101 public function testGetPriceBlockTemplate ()
You can’t perform that action at this time.
0 commit comments