Skip to content

Commit bec723a

Browse files
committed
clean code and compatible m235
1 parent 7d4ec85 commit bec723a

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

Plugin/Controller/Category/View.php

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
namespace Mageplaza\AjaxLayer\Plugin\Controller\Category;
2323

24-
use Magento\Framework\Json\Helper\Data;
2524
use Mageplaza\AjaxLayer\Helper\Data as LayerData;
2625

2726
/**
@@ -30,11 +29,6 @@
3029
*/
3130
class View
3231
{
33-
/**
34-
* @var Data
35-
*/
36-
protected $_jsonHelper;
37-
3832
/**
3933
* @var LayerData
4034
*/
@@ -43,14 +37,11 @@ class View
4337
/**
4438
* View constructor.
4539
*
46-
* @param Data $jsonHelper
4740
* @param LayerData $moduleHelper
4841
*/
4942
public function __construct(
50-
Data $jsonHelper,
5143
LayerData $moduleHelper
5244
) {
53-
$this->_jsonHelper = $jsonHelper;
5445
$this->_moduleHelper = $moduleHelper;
5546
}
5647

@@ -64,18 +55,13 @@ public function afterExecute(\Magento\Catalog\Controller\Category\View $action,
6455
{
6556
if ($this->_moduleHelper->ajaxEnabled() && $action->getRequest()->isAjax()) {
6657
$navigation = $page->getLayout()->getBlock('catalog.leftnav');
67-
$products = $page->getLayout()->getBlock('category.products');
58+
$products = $page->getLayout()->getBlock('category.products');
59+
$result = ['products' => $products->toHtml(), 'navigation' => $navigation->toHtml()];
6860
if ($this->_moduleHelper->getConfigValue('mpquickview/general/enabled')) {
6961
$quickView = $page->getLayout()->getBlock('mpquickview.quickview');
70-
$result = [
71-
'products' => $products->toHtml(),
72-
'navigation' => $navigation->toHtml(),
73-
'quickview' => $quickView->toHtml()
74-
];
75-
} else {
76-
$result = ['products' => $products->toHtml(), 'navigation' => $navigation->toHtml()];
62+
$result['quickview'] = $quickView->toHtml();
7763
}
78-
$action->getResponse()->representJson($this->_jsonHelper->jsonEncode($result));
64+
$action->getResponse()->representJson(LayerData::jsonEncode($result));
7965
} else {
8066
return $page;
8167
}

view/frontend/templates/layer/view.phtml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
?>
2222
<?php if ($block->canShowBlock()) : ?>
2323
<?php
24+
$helper = $this->helper(\Mageplaza\AjaxLayer\Helper\Data::class);
2425
$filters = $block->getFilters();
25-
$layerConfig = $this->helper(\Mageplaza\AjaxLayer\Helper\Data::class)->getLayerConfiguration($filters);
26+
$layerConfig = $helper->getLayerConfiguration($filters);
2627
$filtered = count($block->getLayer()->getState()->getFilters());
2728
?>
2829
<div class="block filter" id="layered-filter-block"
@@ -74,13 +75,15 @@
7475
});
7576
</script>
7677
<?php endif; ?>
78+
<?php if ($helper->ajaxEnabled()) : ?>
7779
<script type="text/x-magento-init">
7880
{
7981
".block-content.filter-content":{
8082
"mpAjax": <?= /** @noEscape */ $layerConfig ?>
8183
}
8284
}
8385
</script>
86+
<?php endif; ?>
8487
</div>
8588
</div>
8689
<?php endif; ?>

0 commit comments

Comments
 (0)