Add image in category menu before category-name Magento 2How Display Category name in magento menu in two lines?Show a Category in Left-Side Menu Only?Have category page main menu based on current categoryAdd custom menu in existing(Catalog) menu magento 2side menu left in category and subcategoryMagento 2: How to add fontawesome icons for each category top-menu item?Navigation Menu ImageMagento 2 : Show Icons for Each Category in Mega MenuDisplay sub category image in top menu - Magento2Add image to new backend top menu

In Japanese, what’s the difference between “Tonari ni” (となりに) and “Tsugi” (つぎ)? When would you use one over the other?

What do three bars across the stem of a note mean?

Theorems that impeded progress

How is it possible to have an ability score that is less than 3?

Collect Fourier series terms

Test whether all array elements are factors of a number

Why was the small council so happy for Tyrion to become the Master of Coin?

Is it unprofessional to ask if a job posting on GlassDoor is real?

Can a Warlock become Neutral Good?

Voyeurism but not really

Font hinting is lost in Chrome-like browsers (for some languages )

US citizen flying to France today and my passport expires in less than 2 months

I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine

What is the word for reserving something for yourself before others do?

Pattern match does not work in bash script

Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)

Watching something be written to a file live with tail

Why doesn't H₄O²⁺ exist?

Mage Armor with Defense fighting style (for Adventurers League bladeslinger)

How to find program name(s) of an installed package?

"You are your self first supporter", a more proper way to say it

What are these boxed doors outside store fronts in New York?

Finding angle with pure Geometry.

can i play a electric guitar through a bass amp?



Add image in category menu before category-name Magento 2


How Display Category name in magento menu in two lines?Show a Category in Left-Side Menu Only?Have category page main menu based on current categoryAdd custom menu in existing(Catalog) menu magento 2side menu left in category and subcategoryMagento 2: How to add fontawesome icons for each category top-menu item?Navigation Menu ImageMagento 2 : Show Icons for Each Category in Mega MenuDisplay sub category image in top menu - Magento2Add image to new backend top menu






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















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 = MagentoFrameworkAppobjectManager::getInstance();
$cate = $objectManager->get('MagentoCatalogModelCategory');
$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++;`


enter image description here










share|improve this question






















  • Is it solve your problem ?

    – user51361
    Apr 17 '17 at 12:24

















4















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 = MagentoFrameworkAppobjectManager::getInstance();
$cate = $objectManager->get('MagentoCatalogModelCategory');
$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++;`


enter image description here










share|improve this question






















  • Is it solve your problem ?

    – user51361
    Apr 17 '17 at 12:24













4












4








4








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 = MagentoFrameworkAppobjectManager::getInstance();
$cate = $objectManager->get('MagentoCatalogModelCategory');
$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++;`


enter image description here










share|improve this question














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 = MagentoFrameworkAppobjectManager::getInstance();
$cate = $objectManager->get('MagentoCatalogModelCategory');
$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++;`


enter image description here







magento2 category menu






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Aug 21 '16 at 4:49









SimpleSimple

117149




117149












  • Is it solve your problem ?

    – user51361
    Apr 17 '17 at 12:24

















  • Is it solve your problem ?

    – user51361
    Apr 17 '17 at 12:24
















Is it solve your problem ?

– user51361
Apr 17 '17 at 12:24





Is it solve your problem ?

– user51361
Apr 17 '17 at 12:24










1 Answer
1






active

oldest

votes


















0














Replace



$image = $id !='' ? '<img src="'.$item->getSmallImageUrl().'" width="30" height="30">' :''; 


with



 $image = $id !='' ? '<img src="'.$item->getImageUrl().'" width="30" height="30">' :'';





share|improve this answer










New contributor




Amber Sabre is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "479"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f132319%2fadd-image-in-category-menu-before-category-name-magento-2%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Replace



    $image = $id !='' ? '<img src="'.$item->getSmallImageUrl().'" width="30" height="30">' :''; 


    with



     $image = $id !='' ? '<img src="'.$item->getImageUrl().'" width="30" height="30">' :'';





    share|improve this answer










    New contributor




    Amber Sabre is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.
























      0














      Replace



      $image = $id !='' ? '<img src="'.$item->getSmallImageUrl().'" width="30" height="30">' :''; 


      with



       $image = $id !='' ? '<img src="'.$item->getImageUrl().'" width="30" height="30">' :'';





      share|improve this answer










      New contributor




      Amber Sabre is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















        0












        0








        0







        Replace



        $image = $id !='' ? '<img src="'.$item->getSmallImageUrl().'" width="30" height="30">' :''; 


        with



         $image = $id !='' ? '<img src="'.$item->getImageUrl().'" width="30" height="30">' :'';





        share|improve this answer










        New contributor




        Amber Sabre is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.










        Replace



        $image = $id !='' ? '<img src="'.$item->getSmallImageUrl().'" width="30" height="30">' :''; 


        with



         $image = $id !='' ? '<img src="'.$item->getImageUrl().'" width="30" height="30">' :'';






        share|improve this answer










        New contributor




        Amber Sabre is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer








        edited Apr 3 at 21:15









        Ansuman

        486




        486






        New contributor




        Amber Sabre is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered Apr 3 at 15:47









        Amber SabreAmber Sabre

        11




        11




        New contributor




        Amber Sabre is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        Amber Sabre is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        Amber Sabre is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f132319%2fadd-image-in-category-menu-before-category-name-magento-2%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Bulk add to cart function issuecart vs. mini cart issue … rwd themeRedirect Add to cart button to cart pageAdd to cart issue - Magento 2.1The requested Payment Method is not available When creating an orderM2: reason add-to-cart might not function in production modeAdd to cart issue in some android devicesMagento 2 - custom price can not add to subtotal and grand total after add to cartAdd to cart codeIssue with my cart module on pdp and cart pages, just keeps spinningBulk price and quantity update using rest api

            Magento2 - How to hide price filter only in specific categories?Multiselect price filter attribute in layered navigationhide only some categories from layered navigation in magentoRemove Price Filter on certain categoriescustomize layered price filter?Hide Price for a particular customer groupPrice filter in layered navigation not working correctly with price including tax in magento 2.2.3Magento 2 how to hide attribute at Layered navigation?Magento 2. how to hide price only for specific categoriesMagento 2 How can I hide the price and total from cart and checkout summary?Magento2: Can we add navigation layered filter like price filter for other attribute?