Note that there are some explanatory texts on larger screens.

plurals
  1. POMagento not recognizing custom Topmenu.php
    text
    copied!<p>I have built a custom module to enable changing the Topmenu link text based on a custom attribute in the backend.</p> <p>The module was tested on Magento CE 1.7.02 and works 100%. Now I am testing on Magento EE 1.12.02 and the menu is not recognizing the rewritten Topmenu class (As-in, I can remove everything from the file, and/or mis-spell the class name in the XML and there are no errors, and the site loads fine).</p> <p>Something tells me that Enterprise Edition pulls this menu from a different location than Community Edition, but I cannot find the place.</p> <p>Here is the relevant portion of my config XML:</p> <pre><code>&lt;blocks&gt; &lt;page&gt; &lt;rewrite&gt; &lt;html_topmenu&gt;WorldSynergy_Seoadditions_Block_Html_Topmenu&lt;/html_topmenu&gt; &lt;/rewrite&gt; &lt;/page&gt; &lt;/blocks&gt; </code></pre> <p>And here is the Topmenu.php class:</p> <pre><code>class WorldSynergy_Seoadditions_Block_Html_Topmenu extends Mage_Page_Block_Html_Topmenu { /** * Recursively generates top menu html from data that is specified in $menuTree * * @param Varien_Data_Tree_Node $menuTree * @param string $childrenWrapClass * @return string */ protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass) { $html = ''; $children = $menuTree-&gt;getChildren(); $parentLevel = $menuTree-&gt;getLevel(); $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1; $counter = 1; $childrenCount = $children-&gt;count(); $parentPositionClass = $menuTree-&gt;getPositionClass(); $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-'; foreach ($children as $child) { $child-&gt;setLevel($childLevel); $child-&gt;setIsFirst($counter == 1); $child-&gt;setIsLast($counter == $childrenCount); $child-&gt;setPositionClass($itemPositionClassPrefix . $counter); $outermostClassCode = ''; $outermostClass = $menuTree-&gt;getOutermostClass(); if ($childLevel == 0 &amp;&amp; $outermostClass) { $outermostClassCode = ' class="' . $outermostClass . '" '; $child-&gt;setClass($outermostClass); } $childId = explode( "-" , $child-&gt;getId() ); $childId = $childId[2]; $attrs = Mage::getModel("catalog/category")-&gt;getAttributes(); $altName = $attrs['ws_menutitle']-&gt;getFrontEnd()-&gt;getValue( Mage::getModel("catalog/category")-&gt;load( $childId ) ); if( empty($altName) ){ $altName = $child-&gt;getName(); } $html .= '&lt;li ' . $this-&gt;_getRenderedMenuItemAttributes($child) . '&gt;'; $html .= '&lt;a href="' . $child-&gt;getUrl() . '" ' . $outermostClassCode . '&gt;&lt;span&gt;ABC' . $this-&gt;escapeHtml($altName) . '&lt;/span&gt;&lt;/a&gt;'; if ($child-&gt;hasChildren()) { if (!empty($childrenWrapClass)) { $html .= '&lt;div class="' . $childrenWrapClass . '"&gt;'; } $html .= '&lt;ul class="level' . $childLevel . '"&gt;'; $html .= $this-&gt;_getHtml($child, $childrenWrapClass); $html .= '&lt;/ul&gt;'; if (!empty($childrenWrapClass)) { $html .= '&lt;/div&gt;'; } } $html .= '&lt;/li&gt;'; $counter++; } return $html; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload