我正在尝试将自定义菜单链接添加到我的magento网站。我只设法添加了顶层,但不知道如何添加下拉菜单(嵌套的子项)。
public function beforeGetHtml(
\Magento\Theme\Block\Html\Topmenu $subject,
$outermostClass = '',
$childrenWrapClass = '',
$limit = 0
) {
// Add custom page in menu
$node = $this->nodeFactory->create(
[
'data' => [
'name' => __('Custom menu'),
'id' => 'customMenu',
'url' => $this->_urlBuilder->getUrl(null, ['_direct' =>'custommenu']),
'has_active' => false,
'is_active' => false
],
'idField' => 'id',
'tree' => $subject->getMenu()->getTree()
]
);
$subject->getMenu()->addChild($node);
}