-2

I am trying to add a listing of brands inside each category drop down list from the main menu. I believe this would be considered as a 'mega menu'.

For example - if i hover over a main category it will not only show sub categories in the drop down menu, but also all the different brands inside this category.

The brands are set up in two ways:

  1. All products have an attribute 'brand'. Therefore we could try to get all the products inside the category and display a list of all the brands associated with the products in this category. This would need to incorporate layered navigation so that when that menu item is selected, it will show a filter of items from that category AND that brand attribute.

  2. I think this method would be easier - Each brand already has it's own category created as well, and each product is in both the main category, as well as it's relevant brand category. This was originally done so we could show a big listing of all brands. Is there function in Magento inside the navigation loop to get 'other chosen categories'? E.g. If an item is in Category A, the drop down list shows all sub-categories, but also any other related top level categories which are selected on the products.

I have tried various solutions which involved modifying Navigation.php (magento 1.6) but I could only get it to display ALL brands in the shop, not just brands inside a particular category. See code below:

// Navigation.php code
// render children
    $htmlChildren = '';
    $j = 0;
    foreach ($activeChildren as $child) {
    $htmlChildren .= $this->_renderCategoryMenuItemHtml(
    $child,
    ($level + 1),
    ($j == $activeChildrenCount - 1),
    ($j == 0),
    false,
    $outermostItemClass,
    $childrenWrapClass,
    $noEventAttributes
    );
    $j++;
    }
    if (!empty($htmlChildren)) {
    if ($childrenWrapClass) {
    $html[] = '<div class="' . $childrenWrapClass . '">';
    }
    $html[] = '<ul class="level' . $level . '">';
    $html[] = $htmlChildren;

    // My modifications start here

    $product = Mage::getModel('catalog/product');
    $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
    ->setEntityTypeFilter($product->getResource()->getTypeId())
    ->addFieldToFilter('attribute_code', 'brands');
    $attribute = $attributes->getFirstItem()->setEntity($product->getResource());
    $manufacturers = $attribute->getSource()->getAllOptions(false);
    $html[] = '<ol id="nav-drop-brands">';
    foreach ($manufacturers as $manufacturer) {
    $html[] = '<li><a href="http://www.domain.com/catalogsearch/advanced/result?manufacturer[]=';
    $html[] = $manufacturer['value'];
    $html[] = '">';
    $html[] = $manufacturer['label'];
    $html[] = '</a></li>';
    }
    $html[] = '</ol>';

    // end of my modifications 

    $html[] = '</ul>';
    if ($childrenWrapClass) {
    $html[] = '</div>';
    }
    }

    $html[] = '</li>';

    $html = implode("\n", $html);
    return $html;
    }
ronnz
  • 167
  • 2
  • 11

1 Answers1

-1

You can go by this :
Add category
Then add sub category
Then add sub-sub category
(This will be your all brands name,which is nothing but category only)

To retrieve these categories you can visit this link.

Hope this help you .

Community
  • 1
  • 1
Nikhil_K_R
  • 2,383
  • 5
  • 27
  • 51
  • Hi Nikhil - thanks a lot for your answer. Currently the brands are already set up in two ways (I have updated my question above to give you more informations). I don't think we would be able to set them all up and aply them as sub-sub categories as the store already has 1000+ items. – ronnz Dec 24 '12 at 12:17
  • this is a bad solution! you should use manufacturer attribute and use that to create a menu. see this: http://www.magentocommerce.com/wiki/5_-_modules_and_development/navigation/add_dropdown_list_of_manufactures_or_another_attribute – karantan Jul 03 '14 at 07:41
  • @karantan after adding menu what will be next step .. ? – Nikhil_K_R Jul 06 '14 at 06:57