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

Categorized Under: 230 Commented

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.

Disclaimer: The extension is currently under development and you should install it first on test servers – it is in beta state for now.

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, 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');
}

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>

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.

- It will not work with multiple select attributes, it is not a bug

- 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

[sourcecode language='css'][/

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

  1. Todd says:

    Hi I have just uploaded via Magento Connect and it does not seem to be installing. I checked for folders via http://FTP…nothing there. Also there is a comment on Magento conncet saying that there is an error.

    http://www.magentocommerce.com/magento-connect/jimmysp/extension/1901/shop-by-manufacturer-brand-character-etc—attribute-info-pages/reviews#reviews

    Can you confirm if this is a problem please?

    Also is the Flat product/categories bug fixed.

    Thankyou

    • Adi says:

      This is odd.. on my test server it installs and works. Can you install other extensions? Try the manual installation, see above a previous comment.
      The person who commented probably didn’t set the Connect manager to “Beta”!?!
      I cannot reproduce the flat product catalog errors, cannot figure out the problem.
      Regards

  2. joe says:

    Hi,

    .. thx for this great extension. Everything works great (1.7beta & 1.4.1).

    I have one question:

    i’d like to display the logos of (for example) all brands logos in a block on the startpage. I’m trying it for nearly half a day and i’m not sure if if’s possible with dc_catalog.

    If anybody could give me short hint. Otherwise i’ll create a block and just grap the attributes, but i’ll prefer to use the dc_catalog logo function from the backend.

    thx and greetings,
    joe

    • joe says:

      .. ok, got it working ;-) ! i added this to my cms page:

      5
      marken


      5
      marken

      greetings

      • joe says:

        .. ahh, shit. not code allowed.

      • Roman says:

        Hello,
        could you please contact me? I want to know how to build the logos block on homepage.

        (I hope you will get my email from this reply)

        Thank you

        • joe says:

          hi roman,

          sorry, no email reached me. i cannnot post any code here. i try to post it without brackets… So at the beginning and the end of each line add !!!!! i also duplicated the all.phtml and renamed it. so i was able to modify it and put a slider for the logos in the footer.

          By the way, this extension is really great! I’ll be also really happy if u (adi) could insert the multiselect thing. If u finish it, give me u’r donation box link ;-) !

          ====================================================

          to get a list in a box just add this in yout page.xml:

          block type=”dc_catalog/list_all” name=”list_all” before=”-” template=”dc_catalog/list/all(or copy, modify and put namehere).phtml”

          action method=”setColumns”
          value
          5
          value
          action

          action method=”setAttributeCode”
          value
          brands
          value
          action

          block

          greetings,
          joe

  3. Roman says:

    Hello, how can I translate the string “Products by atr_name: value”?

  4. Roman says:

    anyway…. great extension :-) thanks

  5. Jake says:

    Joe… what did you do to the all.phtml file to make the slider? I know it’s pain to post code here but wow.. I would love to have this on my front page!

  6. joe says:

    hi jake,

    sorry, i’m not in the office and have no access to the svn, but this is how i did it:

    - i duplicated the all file and called it slider.phtml (so i included
    a slider.phtml).

    - as a code example i used this one:
    http://flowplayer.org/tools/demos/scrollable/index.html

    Greetings

  7. Haroon says:

    why everything is coming twice, for example all the attributes and their values, any help will be appreciated
    here is teh link
    http://www.readysteadybed.com/characters/

    also spellings are wrong in breadcrum how can i change that

    • Adi says:

      Take a look again in the description.. I think you have multiple shops on the same install and you need to disable the values for your Global shop. You will also find the info for translating the breadcrumbs in the locale files!

      • Haroon says:

        Thanks for your reply adi, i manage to fix the bredcrumb problem but for the multiple attrributes still couldnt fix it, i have only 1 store and products are also not showing up any hint

        Thanks

        • Adi says:

          Is this happening also in the admin grid? I see you have an attribute with logo and another one without logo (Ben10). Have you set them as ‘favorite’ characters?

          • Haroon says:

            yeah in admin i am getting the duplicates, no i havnt setup any favourite but its coming in info-pages grid

          • Adi says:

            Go to Admin->Catalog->Attributes and open the Character attribute. I guess the scope is set to global, so set it to “Website” or “Store view”. Sorry, the other way around… Set it to Global instead!

  8. Haroon says:

    Thanks Adi for your help and suggestion, tried everything anyways am going to uninstall it. Greate extension though keep up the good work

    Thanks

  9. Christian says:

    It seems that it does not work properly in 1.4.1 with grouped products.

    In my config only the grouped products have attributes like manufacturer

    I always get No products found, no matter which manufacturer I choose

  10. Peter says:

    hi, is there any way how can i show info about attribute if i use standard layout navigation and i select (filter) the manufacturer from the list of attributes?

    i was thinking about adding cms block to categories, but i dont know what syntax should i use for {{block…}}

    • Adi says:

      This can be accomplished only if you start hacking the extension code, adding the blocks to the categories won’t do it. But this is the same as viewing the info page and filtering by the attributes, isn’t it?

      • Peter says:

        same but i can’t show different cms page for each manufacturer when i filter products by it, filtering just shows products

  11. Bizen says:

    Hi, in Magento ver. 1.4.0.1 on “Attribute Info Page”, for every manufacturer it shows 2 pages. The same thing on front end

  12. Alvar says:

    Installing it in the magento 1.4.0.0 or upper, the wysiwyg editor is gone. Anyone succeeds in fixing that? I need that badly. Thanks!

    • Alvar, add this just above “_prepareForm” to /app/code/community/DC/Catalog/Block/Admin/Manufacturer/Edit/Form.php

      /**
      * Load Wysiwyg on demand and Prepare layout
      */
      protected function _prepareLayout()
      {
      parent::_prepareLayout();
      if (Mage::getSingleton(‘cms/wysiwyg_config’)->isEnabled()) {
      $this->getLayout()->getBlock(‘head’)->setCanLoadTinyMce(true);
      }
      }

      • alex-s says:

        This solution did not worked for me, but the following code solved problem with wysiwyg editor:

        protected function _prepareLayout()
        {
        // Load Wysiwyg on demand and Prepare layout
        if (Mage::getSingleton(‘cms/wysiwyg_config’)->isEnabled() && ($block = $this->getLayout()->getBlock(‘head’))) {
        $block->setCanLoadTinyMce(true);
        }
        parent::_prepareLayout();
        }

        ————-
        Magento 1.4.0.1

        • Adi says:

          Thanks to @alex-s and @Craig Thompson for the code, I just released a new version which displays the editor and other fixes

  13. Memphis says:

    Salut Adi,
    Am instalat extensia ta si nu imi apare acolo pe pagina din sistem – configuration numai Gender sa selectez, nu-mi apare Brand sau manufactured. Poti sa ma ajuti te rog ? ovidiu pal id de meseenger !
    Mersi

  14. Memphis says:

    Imi apare scuze … nu am fost adaug eu producatori … acuma nu imi apare logo…. ma poti ajuta ? id : ovidiupal

  15. Alvar says:

    In the attributeinfo.phtml, how could I get all the name/url of that attribute? I’d like to make a pager for different values of the attribute. Great thanks!

    • Alvar says:

      For url, I mean url of the attribute info pages.

      • Adi says:

        Use $_attr->getData(‘identifier’) and you have the attribute identifier.
        Or look in the list/all.phtml:
        href=”getUrl(‘/’).$item->getAttributeCode().’/’.$item->getIdentifier(); ?>”

        • Alvar says:

          Yes, I know list/all.phtml lists all the urls. But how could I get all attribute items ($_items = $this->getValuesCollection()->retrieveAll()->getItems()) in attributeinfo.phtml, just like list/all.phtml? SOrry I’m new to magento and I can’t figure out how to access object of another class.

        • Alvar says:

          What I want to know is, in attributeinfo.phtml, how could I get an object of list/all in order to get all attribute values by $_items = $this->getValuesCollection()->retrieveAll()->getItems()?
          Thanks!

          • Adi says:

            I hope I understand this right, try with this code:
            //the attribute value collection
            $valuesCollection = Mage::getModel('dc_catalog/manufacturer')->getCollection();

            //set the store id and the main category from the store
            $valuesCollection
            ->addStoreFilter(Mage::app()->getStore()->getId(), true)
            ->addAttributeCodeFilter($this->getAttributeCode())
            ->addFavoritesFilter() //if you want only favorites
            ->addEnabledFilter();

            and then you can acces the attributes with $valuesCollection->retrieveAll()->getItems()

            Otherwise, you would have to change the Block/AttributeInfo.php file to add some methods which can be then accessed in the template file. Hope this helps.

  16. Victor says:

    i have a problem with my site; after install and configure this module, i can,t see images becouse url is not ok: http://www.localhost.com/magento/media//catalog\attribute\marca_ejemplo.gif

    (you can see “/” added and other bad…

    Any idea?

    thanks and regads.

    • Victor says:

      the problem was the file upload in backend updated a wrong name with that “\”…. i,va updated the correct name with myphpadmin and that,s ok.

      regards.

    • Adi says:

      I just updated the extension to 0.1.8 to fix this. can you take a look if it’s working ok now?

  17. joe says:

    hi adi,

    i just saw that u added the multiselect part and tried it ;-) .

    for grouped products it works fine, but i when i use a simple product with a multiselect attribute i get no products.

    is it a known bug?

    thx joe

    • Adi says:

      No, not yet.. I wrote ‘preparations’ :) In the controller part, the multiple select should build the product listing.
      For example, if you have authors linked to products you can already display server.com/author and server.com/author/author-name.
      I have to make the product page view now, to display the list of authors with links and I will release a new version.

  18. Victor says:

    I’m trying to create a block with all manufacturers to stay on each page of the site and at the moment I can not. In testing, I have built a new block on the page of manufacturers, copy of the block “all.phtml” by another name and I was not shown, only write “all.phtml”. Any ideas?

Leave a Reply