Skip to content

Commit 74d6fb2

Browse files
committed
MAGE-1104 Simplify display mode check to avoid object casting
1 parent 3bfcfc3 commit 74d6fb2

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

Observer/AddAlgoliaAssetsObserver.php

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,31 +53,13 @@ public function execute(Observer $observer): void
5353
}
5454
}
5555

56-
/**
57-
* Repository does not guarantee this underlying model but only the interface
58-
* but getDisplayMode is only available on model
59-
*
60-
* @throws AlgoliaException
61-
*/
62-
public function getCategory(): Category
63-
{
64-
$category = $this->category->get();
65-
if (!$category instanceof Category) {
66-
throw new AlgoliaException("Unexpected category object encountered.");
67-
}
68-
return $category;
69-
}
70-
71-
/**
72-
* @throws AlgoliaException
73-
*/
7456
private function loadPreventBackendRenderingHandle(Layout $layout, int $storeId): void
7557
{
7658
if (!$this->config->preventBackendRendering($storeId)) {
77-
return;
78-
}
59+
return;
60+
}
7961

80-
$category = $this->getCategory();
62+
$category = $this->category->get();
8163

8264
if (!$category->getId()) {
8365
return;
@@ -88,7 +70,8 @@ private function loadPreventBackendRenderingHandle(Layout $layout, int $storeId)
8870
}
8971

9072
$displayMode = $this->config->getBackendRenderingDisplayMode($storeId);
91-
if ($displayMode === 'only_products' && $category->getDisplayMode() === 'PAGE') {
73+
if ($displayMode === 'only_products'
74+
&& $category->getData('display_mode') === \Magento\Catalog\Model\Category::DM_PAGE) {
9275
return;
9376
}
9477

0 commit comments

Comments
 (0)