init
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Force the catalog top navigation to use the Esun mega menu template.
|
||||
*/
|
||||
namespace Esun\MegaMenu\Plugin;
|
||||
|
||||
use Esun\MegaMenu\ViewModel\MegaMenuData;
|
||||
use Magento\Theme\Block\Html\Topmenu;
|
||||
|
||||
class TopmenuTemplatePlugin
|
||||
{
|
||||
private $megaMenuData;
|
||||
|
||||
public function __construct(MegaMenuData $megaMenuData)
|
||||
{
|
||||
$this->megaMenuData = $megaMenuData;
|
||||
}
|
||||
|
||||
public function beforeToHtml(Topmenu $subject): void
|
||||
{
|
||||
if ($subject->getNameInLayout() !== 'catalog.topnav') {
|
||||
return;
|
||||
}
|
||||
|
||||
$subject->setData('view_model', $this->megaMenuData);
|
||||
$subject->setTemplate('Esun_MegaMenu::html/topmenu.phtml');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user