File tree 3 files changed +19
-5
lines changed
dev/tests/integration/testsuite/Magento/Catalog/Block/Product
3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -136,7 +136,14 @@ public function getLayer()
136
136
*/
137
137
public function getLoadedProductCollection ()
138
138
{
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 ;
140
147
}
141
148
142
149
/**
Original file line number Diff line number Diff line change @@ -725,9 +725,14 @@ public function getIdBySku($sku)
725
725
*/
726
726
public function getCategoryId ()
727
727
{
728
+ if ($ this ->hasData ('category_id ' )) {
729
+ return $ this ->getData ('category_id ' );
730
+ }
728
731
$ 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 ;
731
736
}
732
737
return false ;
733
738
}
Original file line number Diff line number Diff line change @@ -92,8 +92,10 @@ public function testGetAdditionalHtml()
92
92
93
93
public function testSetCollection ()
94
94
{
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 ());
97
99
}
98
100
99
101
public function testGetPriceBlockTemplate ()
You can’t perform that action at this time.
0 commit comments