Skip to content

Commit e5ce8b3

Browse files
author
Vadim Zubovich
committed
MAGNSWTCH-139: Added Details renderer support for Search results pages
1 parent c2a2f84 commit e5ce8b3

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

app/code/Magento/Catalog/Block/Product/AbstractProduct.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -607,11 +607,12 @@ public function isRedirectToCartEnabled()
607607
*/
608608
public function getProductDetailsHtml(\Magento\Catalog\Model\Product $product)
609609
{
610-
$renderer = $this
611-
->getDetailsRenderer($product->getTypeId())
612-
->setProduct($product);
613-
614-
return $renderer->toHtml();
610+
$renderer = $this->getDetailsRenderer($product->getTypeId());
611+
if ($renderer) {
612+
$renderer->setProduct($product);
613+
return $renderer->toHtml();
614+
}
615+
return '';
615616
}
616617

617618
/**
@@ -624,10 +625,10 @@ public function getDetailsRenderer($type = null)
624625
$type = 'default';
625626
}
626627
$rendererList = $this->getDetailsRendererList();
627-
if (!$rendererList) {
628-
throw new \RuntimeException('Details renderer list for block "' . $this->getNameInLayout() . '" is not defined');
628+
if ($rendererList) {
629+
return $rendererList->getRenderer($type, 'default');
629630
}
630-
return $rendererList->getRenderer($type, 'default');
631+
return null;
631632
}
632633

633634
/**

app/code/Magento/CatalogSearch/view/frontend/layout/catalogsearch_advanced_result.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
<action method="setToolbarBlockName">
2323
<argument name="name" xsi:type="string">product_list_toolbar</argument>
2424
</action>
25+
<block class="Magento\Framework\View\Element\RendererList" name="category.product.type.details.renderers" as="details.renderers">
26+
<block class="Magento\Framework\View\Element\Template" as="default"/>
27+
</block>
2528
</block>
2629
<action method="setListOrders"/>
2730
<action method="setListModes"/>

app/code/Magento/CatalogSearch/view/frontend/layout/catalogsearch_result_index.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
<action method="setToolbarBlockName">
2424
<argument name="name" xsi:type="string">product_list_toolbar</argument>
2525
</action>
26+
<block class="Magento\Framework\View\Element\RendererList" name="category.product.type.details.renderers" as="details.renderers">
27+
<block class="Magento\Framework\View\Element\Template" as="default"/>
28+
</block>
2629
</block>
2730
<action method="setListOrders"/>
2831
<action method="setListModes"/>

0 commit comments

Comments
 (0)