I'm create new attribute is small image for category.In admin i have save image for category-1 then i get this image in menu category but image exist for all category.Although in admin i just save image for category-1.Same this image red box is category save image in admin.pls see help me. I Will add image in file custom Topmenu.php `
$objectManager = \Magento\Framework\App\objectManager::getInstance();
$cate = $objectManager->get('\Magento\Catalog\Model\Category');
$id = substr($child->getId(),14);
$item = $cate->load($id);
$image = $id !='' ? '<img src="'.$item->getSmallImageUrl().'" width="30" height="30">' :'';
$outermostClassCode = '';
$outermostClass = $menuTree->getOutermostClass();
if ($childLevel == 0 && $outermostClass) {
$outermostClassCode = ' class="' . $outermostClass . '" ';
$child->setClass($outermostClass);
}
if (count($colBrakes) && $colBrakes[$counter]['colbrake']) {
$html .= '</ul></li><li class="column"><ul>';
}
$html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
$html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '>'.$image.'<span>' . $this->escapeHtml(
$child->getName()
) . '</span></a>' . $this->_addSubMenu(
$child,
$childLevel,
$childrenWrapClass,
$limit
) . '</li>';
$itemPosition++;
$counter++;`