Skip to content

Commit aa1ea5f

Browse files
authored
fix(layered-nav): Fix MetaRobotsPlugin calling getLayout() on invalid result type
Resolved an error where MetaRobotsPlugin was calling getLayout() on result objects that don't implement this method. Added defensive checks to verify layout object exists before attempting to access blocks. Error fixed: "Call to undefined method Magento\Framework\Controller\Result\Forward\Interceptor::getLayout()"
1 parent 878c2b2 commit aa1ea5f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Plugin/MetaRobotsPlugin.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,23 @@ private function isCustomEntityPage(): bool
8080
$controllerName = $this->request->getControllerName();
8181
return $moduleName === 'custom_entity' && $controllerName === 'set';
8282
}
83-
83+
8484
/**
8585
* Check if filters are applied to the current page
8686
*
87+
* @param ResultInterface $resultPage
8788
* @return bool
8889
*/
8990
private function hasAppliedFilters($resultPage): bool
9091
{
91-
$state = $resultPage->getLayout()->getBlock('set.layer.state');
92+
$layout = $resultPage->getLayout();
93+
if (!$layout) {
94+
return false;
95+
}
96+
$state = $layout->getBlock('set.layer.state');
9297
if ($state && $state->getActiveFilters()) {
9398
return true;
9499
}
95100
return false;
96101
}
97-
}
102+
}

0 commit comments

Comments
 (0)