Magento: Shop by manufacturer/brand/character/etc – Attribute Info Pages

Categorized Under: 357 Commented

Update 14.10.2010: A new release is out, and now is marked as stable, with these known issues:
- Configurable products with associated simple items that use the same attribute are not shown
- make this work on flat catalogs (If there is anybody with experience in dealing with the Magento collection – programatically – please take a look, maybe you have the solution – this project will see very little resources from me from now on)

This extension allows shop owners to define additional information for attributes which are defined in their catalog. It displays pages with a logo, an external link, an HTML description and the product listing for the specified attribute: be it manufacturer, brand, character, artist, supplier, or even color… whatever you define. It works for drop down and multiple select attributes.

Examples with  this extension:


Installation instructions:

Install this from Magento Connect: change your Magento Connect Manager preferences to allow for beta state extensions, use the magento-community/DC_Catalog extension key and install the extension. Remember to refresh cache, log-out and login again (just the usual stuff :) that can save some frustration).

After install, go to System->Configuration and look for the Attribute Info Pages tab under Catalog. This extension operates globally, so the configuration tab will not be visible in stores/websites config. Here select the attributes that you want pages for (eg.  manufacturer, brand, etc). Now you have the module setup and can make the desired changes in the templates. For full control over the pages, go to CMS->Attribute Info Pages.

If you have custom made templates, you should copy the files from /app/design/frontend/default/dc_catalog to your template folder.

To display the attributes in the product view page, open the file /app/design/frontend/default/[theme name]/template/catalog/product/view.phtml and add this code somewhere (preferrably after the code for the product name):

if($_product->getData('manufacturer') > 0) {
echo $this->getChildHtml('attributes.manufacturer');
}

Optional, to display the attributes in the category listing, open the file /app/design/frontend/default/[theme name]/template/catalog/product/list.phtml and add this code somewhere in the for loop (preferrably after the code for the product price):

if($_product->getData('manufacturer') > 0) {
if ($block = $this->getLayout()->getBlock('attributes.manufacturer')) {
echo $block->setProduct($_product)->toHtml();
}
}

Be carefull that the product variable may be different, depending on the template designer. The stock template uses the $_product variable, but you might find $product, $prod, $p, etc. and be sure to change the variable, if necessary, in the code snippets above.

Similar syntax should be used for other attributes: they must by defined as blocks in /[template_folder]/layout/dc_catalog.xml (I hope the comments and structure are self-explanatory):

<block type="dc_catalog/product_attributes"
name="attributes.manufacturer" as="attributes.manufacturer"
template="dc_catalog/product/view/attribute.phtml">
<action method="setAttributeCode"><value>manufacturer</value></action> <!-- process this attribute_code -->
<action method="setImageOnly"><value>0</value></action> <!-- if true doesn't show if there is no image uploaded -->
<action method="setTextOnly"><value>0</value></action> <!-- if true shows only text, no matter if there is a logo -->
<action method="setImgResizeTo"><value>0</value></action> <!-- eg. 75x60 or 75x or x60 - resize image to be maximum [width]x[height] -->
<action method="setImgAlign"><value>right</value></action>
<action method="setBannerResizeTo"><value>0</value></action> <!-- eg. 75x60 or 75x or x60 - resize banner to be maximum [width]x[height] -->
<action method="setBannerAlign"><value>block</value></action>
</block>

You can alter the layout for the category listing with parameters like above or by copying the /app/design/frontend/default/[theme name]/template/dc_catalog/product/view/attribute.phtml to a new file and changing in the layout/dc_catalog.xml the reference to the new file, for example:

<catalog_category_layered>
<reference name="category.products"><block type="dc_catalog/product_attributes"
name="attributes.manufacturer" as="attributes.manufacturer"
template="dc_catalog/product/view/attribute-category.phtml">
................
</block>

In the product page you can display a banner instead of the logo of the manufacturer (optional). When editing the attribute info, just add the banner in the “Product Page Information” tab. If there is no banner uploaded, the logo will be displayed. By default, the banner will be displayed as a block. The “all manufacturers” page and the detail page will display only the logo.

If you want to uninstall this template, remove DC_Catalog.xml from /app/etc/modules, delete the catalog_attribute_page table from the database, clear the cache and logout.

NOTE: The product listing is based on the layered navigation collections/models. The collection is initialized with the root category of the current store, so make sure the root categories of your stores are ‘Anchors’!

Using this extension in a multi store setup

When you define attribute labels for each store on your attributes, the “All store views” label will appear in the pages list, duplicating the store attribute. Here is an example with Aiwa from the attribute editor and the info pages table:

To keep things simple, use a hyphen (-) in front of the “All store views” label (or any other label that you want to disable) and the script will filter it out (I know it’s more of a hack, but it’s simple, like I said).

This allows you to filter out manufacturers in different store views that you don’t want to display, but you have to always write the labels of the attributes in the sites where you want them displayed. Here is what I mean:

Store view 1 has manufacturers: LG, Sony, Samsung, HP, JVC, Panasonic, Acco, Aiwa
Store view 2 has manufacturers: Yamaha, Philips
Store view 3 has manufacturers: BlackBerry, Nokia
All the labels for the “All store views” attribute will no longer be displayed in the Attribute info pages. Another cool thing is that you can add for example Philips to Store view 1 and define a different info or logo for it in that store view than in Store view 2. If you have the same manufacturer in all three store views, then you can use only the General one (without the hyphen, of course), but all views will have the same info and logo.

Having trouble with this extension?

- Remember to set “anchor” for root categories

- You should be familiar with the templates in Magento and know where to find the product display template. If you don’t have a product/view.phtml file, search for it in /app/design/frontend/base and use it in your template folder.

- If you get a lot of  pages with “There are no products matching the selection” or missing products in the filter, there might be something wrong with the attributes in your database. It’s hard to check, because you have to check directly in the database, and the Magento tables are extremely normalized. The simple explanation is that attributes are stored as text values while this script filters for integer values when searching for manufacturers (I found this while working on the Magento sample database). You could also come across this if you have migrated from older versions or from faulty imports. If you care to look in the database, look for values in the catalog_product_entity_varchar table (should have been in the catalog_product_entity_int table). To fix, you should edit the products, remove the manufacturer attribute, and then assign it again, and it should appear in the filters.

Developer notes:

The code is heavily based on the CMS Page module. Upon installation, the extension installs a new router which checks for attribute_code’s (the ones selected in the config section) in the url, and then for an identifier (if one is saved in the attribute pages table) or tries to match one of the existing attribute values to the rest of the url.

The attribute info pages in admin are displayed with a right join to the attributes tables, so if you haven’t created an attribute page yet, you still view all the attribute values that can be processed and are available in the frontend. As MySQL doesn’t support full joins, in time you could find orphan attribute pages  (not linked to an attribute value – maybe you deleted a value). These orphan pages will be visible in some future version, and you will be able to delete them.

This extension is released without any guarantees, as-is, under the OSL License, so you can use it whatever way you like it. The author will not be held responsible for any damages caused by installing this extension. We recommend making backups to the database/files prior to installing it. Still, we would like to know if you use it or like it, so please drop us a comment below with your opinion, suggestions or other ideas.

Tested in Magento 1.3.2.3 – 1.4.0.1

2dos:
– display the full layer navigation when viewing an attribute page
– image/logo resize in product page
- include in sitemaps
- show all values for an attribute (eg. all manufacturers page)
- blocks with popular attribute values (eg popular brands)
- disable some of the values (eg. do not show manufacturer xyz)
- other ideas/wanting to help? – let us know in the comments or the extension discussion area

Update Log:
03.09.2009 – initial release v0.1.0
06.09.2009 – v0.1.1 updated blocks, templates
10.09.2009 – v0.1.2 changed to beta, problems with the magento connect upload process
22.09.2009 – v0.1.3 added prefix to tables, logo resize
11.03.2010 – v0.1.6 fixes, Magento 1.3 and 1.4 compatibility. The root category selection is now applied on the layer object, not the product collection so hopefully the bug with persistent layers across attributes is fixed
17.03.2010 – v0.1.7 hacking the multi store setup with attribute names, added the banner display in product view pages
25.08.2010 – v0.1.8 fixed windows uploading logos, the wysiwyg editor in magento 1.4, display the description only on the first page with products, preparations for products with multiple select attributes
23.09.2010 – v0.1.9 added multiple select attributes display in product pages, added display of attributes in category listing, removed “Preview” in admin
14.10.2010 – v.0.2.0 added smarter layered navigation (drill down in categories until there are more categories visible, hides current attribute in filters), new field for page title, display the store attribute label in breadcrumbs and other fixes
17.10.2010 – v.0.2.1 small typo fixed

[sourcecode language='css'][/

357 Responses to “Magento: Shop by manufacturer/brand/character/etc – Attribute Info Pages”

  1. Karlo says:

    hi adi,

    great extension! i’m trying to implement your code from all.phtml to display in a custom CMS block but it’s throwing an error:

    Fatal error: Call to a member function retrieveAll()

    can you help please? thanks!

  2. Nafnaf1000 says:

    Hello.

    Very nice add on. Thank you so much. I am wondering is there is a way to only show manufacture the have Active items? This will help me as i have 300 Different manufacturers on my website but only 5 or 10 have active items associated to it.

    • Adi says:

      Unfortunately, the manufacturers should be manually disabled (add a hiphen ‘-’ in front of the name). Or you can think of this as a little SEO spam :)

      • Nafnaf1000 says:

        Adi. Thanks for your reply.

        I do not have a problem with the SEO Spam :)

        I just dont want to spam my users….

  3. Nafnaf1000 says:

    Adi.

    I was wanting to make a Manufacturer Contact page. Is there a option to add phone numbers ??? like Main Phone, Ra Phone ect…..maybe 4 different phone options?

    Thanks.

    • Nafnaf1000 says:

      I know this is relay dome but, how do I set a block on the home page of just Manufacturer.

      I have already “Shop By Category ” and I need another block for “Shop By Manufacturer”

      Thanks so much

      • Adi says:

        Have a look in the layout/dc_catalog.xml, the last block is a block that displays a block with manufacturers, like in the last picture from above. You would have to inject that block in the home layout in admin->CMS->edit your home page.

        • Nafnaf1000 says:

          thanks so much. I seem to be getting this error..

          Fatal error: Call to a member function getData() on a non-object in /public_html/app/design/frontend/default/default/template/dc_catalog/product/view/attribute.phtml on line 13
          .

          I have this in CMS page.

          manufacturer
          75×40
          none

          • Jake says:

            Add this to the custom design area of your home page
            reference name=”content”
            block type=”dc_catalog/list_all” name=”list_all” after=”-” template=”dc_catalog/list/favorites.phtml”
            action method=”setAttributeCode”>manufacturer</action
            /block
            /reference

          • Jake says:

            You will need to use “” at the beginning and end of each line I just didn’t post it because I didn’t know if this form would allow it.

          • Jake says:

            Yeah I didn’t think so:) You will need to use greater than and less than symbols at the beginning and end of each line. You may also want to edit the favorites.phtml file and change to number of columns to what you want

    • Adi says:

      You would have to add new fields to the database and the admin form. You can duplicate the URL field instances (or another field) and rename it for your needs. And then you can display them in the templates. Or you can add them as text in the description field.

  4. doo says:

    very nice extension. But the brand image always align right,even though set it to div style=”width:330px;”. I can’t find the css code “product-attribute-image”, where is it? pls help.

  5. Sean Molin says:

    How do you remove the “Favorite Manufacturers” block on the left column layout?

    • Adi says:

      From the layout xml file, there is a block definition for the left column block type=”dc_catalog/list_favorites” name=”list_favs_block”, just delete or comment that section, refresh cache, and should be gone.

  6. andy says:

    All i can see in the Attribute Info Pages under Attribute Selection is None and Gender. Even though i have defined ‘Brand’ in catalog > manage attributes

  7. Hi
    I was experieincing problem in getting this show but have now go a developer to assist. But the developer is telling me that there is a problem with the software. All i want is for the brands to be displayed on the home page. If you look at my site the devloper has done a link but i notice that some of the when you click the link no products are displaying and i have products. what i would like is for the brands as they are in this links http://www.beautyindulgence.co.uk/manufacturer/manufacturer/ to be displayed on the home page with the logo because all these links are working

    • Adi says:

      There are some limitations to using this code, please look above in the posting and make sure you setup your shop as described. I also notice in some links there is /manufacturer/manufacturer/[manufacturer code] which i think it is wrong.

  8. MrP says:

    Does it work with Magento 1.4.2?
    I’ve just installed the extension on my site, but under Attributes Info Pages I only see attributes which use dropdown selection (I don’t need for them, since they already have layered navigation).
    TIA

    • MrP says:

      Ok, I’ve seen the comment above.
      Since it needs a dropdown selection to work, I don’t think it’s the extension I’m looking for.
      TIA

  9. Sean Molin says:

    Is there any way to get this to be able to use Text Field attributes? If I have an archive of HUNDREDS of books, I don’t want to have to put every single author in a drop down… but I want people to be able to go to a page to see all books by a particular author.

    • Sean Molin says:

      My temporary work around is that I have the artist name as a link that goes to the search page with that artist as the query (plus another keyword so I can be sure to filter out anything I don’t want included, e.g. Jimi Hendrix guitar tab books… I don’t want guitars and pedals related to Jimi to show up. Just books.

      But it’s not nearly as elegant as an attribute landing page.

      • MrP says:

        I need the exactly same thing.
        I can’t think to setup a dropdown selection list for all authors.
        I’m working in your same direction (using search as link), but i hope there is something better.

  10. varty says:

    It’s a very useful addon. But why the CSS can not be use in the manufacturer descrption? the code for example , I just want to insert a image on top of the page. pls help!

  11. handbags says:

    it is great extension, it is working well in 1.4.1.1.

    but now when I upgrade to 1.4.2, no result at filter page, how can I solve it? thank you..

  12. raqy says:

    Hi Adi,
    Thanks for much for this extension. i have tested it before, but it was still immature. now it is much better.

    Still, i am detecting minor issues:

    here one i detected and corrected:
    the Banner for product page was not uploaded as banner. instead – it uploaded as image:
    cause: there was a mistake in \DC\Catalog\Model\Mysql4\manufacturer.php, line 89 it was written ‘image’ instead of ‘banner’ – that’s why it uploaded for image field.

    i have other issue i’m dealing with:
    the text for product page (defined in Admin under the Banner), although uploaded to DB, is not shown in product page (banner is now showing)… did i miss something with settings? – when i set textonly=1 it shows Atrribute name&value – which is OK, but didn’t understand what to do to make the text for product page show

    pls help…

    (have more minor issues, but will write later)

    • Adi says:

      Thanks for reporting, unfortunately I have other projects right now and don’t plan on updating this extension any more. When I find some time, I will probably upload a new one with your fixes.
      For the second issue, I don’t remember exactly what’s the field for, but if you need it you should use it in your template as you use other fields. Just display the description value.

  13. kremil says:

    I installed this module thanks for great application before. but “There are no products matching the selection.” when i clicked manufacture and the short information Image wont create thumbnail. best regards..

    ananto mazoerkam

  14. abase says:

    I have installed the extension and it works fine!
    Is it possible to change the part of the URL (manufacturer)
    Is it hard coded?

  15. vignesh says:

    Hi.. please help me..

    After install this module

    When i go to the menu CMS->Attribute Info Pages

    i got this following error.

    Warning: include(Mage/Page/Model/Source/Layout.php) [function.include]: failed to open stream: No such file or directory in /var/www/caxid/app/code/core/Mage/Core/functions.php on line 70
    Trace:
    #0 /var/www/caxid/app/code/core/Mage/Core/functions.php(70): mageCoreErrorHandler(2, ‘include(Mage/Pa…’, ‘/var/www/caxid/…’, 70, Array)
    #1 /var/www/caxid/app/code/core/Mage/Core/functions.php(70): __autoload()
    #2 [internal function]: __autoload(‘Mage_Page_Model…’)
    #3 /var/www/caxid/app/code/core/Mage/Core/Model/Config.php(966): class_exists(‘Mage_Page_Model…’)
    #4 /var/www/caxid/app/Mage.php(317): Mage_Core_Model_Config->getModelInstance(‘page/source_lay…’, Array)
    #5 /var/www/caxid/app/Mage.php(331): Mage::getModel(‘page/source_lay…’, Array)
    #6 /var/www/caxid/app/code/community/DC/Catalog/Block/Admin/Manufacturer/Grid.php(101): Mage::getSingleton(‘page/source_lay…’)
    #7 /var/www/caxid/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php(463): DC_Catalog_Block_Admin_Manufacturer_Grid->_prepareColumns()
    #8 /var/www/caxid/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php(471): Mage_Adminhtml_Block_Widget_Grid->_prepareGrid()
    #9 /var/www/caxid/app/code/core/Mage/Core/Block/Abstract.php(642): Mage_Adminhtml_Block_Widget_Grid->_beforeToHtml()
    #10 /var/www/caxid/app/code/core/Mage/Core/Block/Abstract.php(503): Mage_Core_Block_Abstract->toHtml()
    #11 /var/www/caxid/app/code/core/Mage/Core/Block/Abstract.php(454): Mage_Core_Block_Abstract->_getChildHtml(‘grid’, true)
    #12 /var/www/caxid/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php(72): Mage_Core_Block_Abstract->getChildHtml(‘grid’)
    #13 /var/www/caxid/app/design/adminhtml/default/default/template/widget/grid/container.phtml(36): Mage_Adminhtml_Block_Widget_Grid_Container->getGridHtml()
    #14 /var/www/caxid/app/code/core/Mage/Core/Block/Template.php(144): include(‘/var/www/caxid/…’)
    #15 /var/www/caxid/app/code/core/Mage/Core/Block/Template.php(176): Mage_Core_Block_Template->fetchView(‘adminhtml/defau…’)
    #16 /var/www/caxid/app/code/core/Mage/Core/Block/Template.php(193): Mage_Core_Block_Template->renderView()
    #17 /var/www/caxid/app/code/core/Mage/Core/Block/Abstract.php(643): Mage_Core_Block_Template->_toHtml()
    #18 /var/www/caxid/app/code/core/Mage/Core/Block/Text/List.php(43): Mage_Core_Block_Abstract->toHtml()
    #19 /var/www/caxid/app/code/core/Mage/Core/Block/Abstract.php(643): Mage_Core_Block_Text_List->_toHtml()
    #20 /var/www/caxid/app/code/core/Mage/Core/Block/Abstract.php(503): Mage_Core_Block_Abstract->toHtml()
    #21 /var/www/caxid/app/code/core/Mage/Core/Block/Abstract.php(454): Mage_Core_Block_Abstract->_getChildHtml(‘content’, true)
    #22 /var/www/caxid/app/design/adminhtml/default/default/template/page.phtml(73): Mage_Core_Block_Abstract->getChildHtml(‘content’)
    #23 /var/www/caxid/app/code/core/Mage/Core/Block/Template.php(144): include(‘/var/www/caxid/…’)
    #24 /var/www/caxid/app/code/core/Mage/Core/Block/Template.php(176): Mage_Core_Block_Template->fetchView(‘adminhtml/defau…’)
    #25 /var/www/caxid/app/code/core/Mage/Core/Block/Template.php(193): Mage_Core_Block_Template->renderView()
    #26 /var/www/caxid/app/code/core/Mage/Core/Block/Abstract.php(643): Mage_Core_Block_Template->_toHtml()
    #27 /var/www/caxid/app/code/core/Mage/Core/Model/Layout.php(526): Mage_Core_Block_Abstract->toHtml()
    #28 /var/www/caxid/app/code/core/Mage/Core/Controller/Varien/Action.php(339): Mage_Core_Model_Layout->getOutput()
    #29 /var/www/caxid/app/code/community/DC/Catalog/controllers/Admin/ManufacturerController.php(45): Mage_Core_Controller_Varien_Action->renderLayout()
    #30 /var/www/caxid/app/code/core/Mage/Core/Controller/Varien/Action.php(367): DC_Catalog_Admin_ManufacturerController->indexAction()
    #31 /var/www/caxid/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(247): Mage_Core_Controller_Varien_Action->dispatch(‘index’)
    #32 /var/www/caxid/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
    #33 /var/www/caxid/app/Mage.php(457): Mage_Core_Controller_Varien_Front->dispatch()
    #34 /var/www/caxid/index.php(60): Mage::run()
    #35 {main}

  16. vignesh says:

    I used this module in Magento version 1.3.1

    Help me. i am waiting for your response.

  17. Abase says:

    I have installed your extension without trouble ;-)

    But witch code is necessary on the info attribute pages to show the products of the specific manufacturer?
    Thanks for any help!

  18. Abase says:

    okay I found the answer :-)
    I forgot to mark the root category as anchor!

  19. Abase says:

    ..in the Attribute Info pages the word “manufacturer” (attribute name) is part of the url. Is it possible to change that?

  20. HotCustard says:

    Anyone had any joy with this in 1.5 beta?

  21. HotCustard says:

    Got it all working on 1.5 beta 1, I had not copied the layout file into my theme. Works great, and a great help with SEO. Well done.

  22. Jyr says:

    How can i get attributecode and identifier in product page?

  23. Rene says:

    Hello…

    I want to show a link to the manufacturers webpage on my product view.
    How can I handle this ?

    I’ve added the code from your example:

    if($_product->getData(‘manufacturer’) > 0) {
    echo $this->getChildHtml(‘attributes.manufacturer’);
    }

    This show my an Link to the attribute info page, the image is also not visible. In the code i see there is an tag witth an empty src attribute. In the admin i store an image, url and Name.

    How can i read out only the external link ?
    Or maybe the Logo ?

    Thank you for helping…

    Regards
    Rene

    • Adi says:

      You should modify the file /app/design/frontend/default/default/template/dc_catalog/product/view/attribute.phtml. I cannot test right now, but $_attr->getExternalUrl() in this file should give you the external url and the label should be $_attr->getExternalUrlLabel().

  24. Jeff says:

    Hi Adi,

    Thanks for the extension. I just installed it and having a weird issue. When I open System > Configuration > Catalog > Attribute Info Pages then I only see two options,

    none
    Gender

    to make for page activation. I think there should we brand, manufacturer and other important attributes but they are not coming in my computer.

    I have installed other extensions too so is this causing? I want to create Manufacturer page so I searched and installed this.

    Can you please tell me the update to do or other solution?

    Jeff

  25. Visudox says:

    Hi Adi,

    thank you for your effort in creating this extension.

    i exactly have the same problem like JEFF. No attributes are showing,
    just “none”, “gender” and one self added for configurable products,
    but about 20 attributes missing at System -> Config -> Attributes pages. These attributes are “global”.

    Categories are set as anchors, DC-folder copied to my theme folder,
    cashes, indexes all renewed.

    Tried everything, could not fix it.

    Any clues greatly appreciated.

    Yours, Visudox

  26. Nidhi says:

    Hello, its great extention, i am try to get all manufacturer logo on home page, will you tell me how i can get all logos on home page?

    Thank you

  27. MO says:

    Hey,
    can you tell me how I can access the sth. like the manufacturer-code from within my list.phtml?

    I want to alter my listing layout depending on what manufacturer page is shown, so I need sth. like if ($manufacturer == ‘foo’) in that template and $attribute_code = $this->getDataOr(‘attribute_code’, ‘manufacturer’); just returns NULL.

  28. Dave says:

    Hi Adi,

    Is there a way to change the ‘sort by’ on a manufacture page?
    Im able to change it from ‘asc’ to ‘desc’ but need to sort by attribute. Changing the default in config doesn’t seem to make a difference.

    Thanx
    Dave

  29. Neethi says:

    HI,. I get this error when I tried to click
    CMS->Attributes info pages

    “There has been an error processing your request
    Exception printing is disabled by default for security reasons.

    Error log record number: 1541106454″

    And there is no Manage Attributes Info Pages under catalog..

    I’m new to magento.. any help please..

Leave a Reply