Kinetic Pulse
  • Home
  • Services
  • Portfolio
  • Blog
  • Terms
  • Contact

Magento – getting a list of Manufacturers & landing pages

October 11, 2010

Well I”ve bitten the bullet and taken the step from the safety of ZenCart to the brave new world of Magento.
Boy is it complex!? The thing I love about Zen Cart is that you can hack it about to get it to do pretty much what ever you want. Magento seems just too clever for its own good…
Hopefully my attitude will change towards it – esp as I”ve agreed to do our latest ecommerce project in it!

So I”ve managed to set up some products and import some categories – but try to get list of products categorised by manufacturer? That seems a step too far for the basic Magento install, so I have been trawling through forums and blog posts on ways to achieve this. (Another plus to using Zen Cart is that because it has been around for so long the forums are teeming with solutions to most every problem)

My first starting point was to  install the “Landing pages module for Magento” from yoast.com
A nice module that gives you a  great little tool in the form of a CMS block that you can use on your static pages eg:

{{block type="Yoast_Filter/Result" 
name="filter_result"
template="catalog/product/list.phtml"
attribute="manufacturer"
value="24" }}

This will show you all products with a manufacturer id set to 24
(I”ll show you a neat way to find out these ids later – couldn”t see it when I looked in Magentos admin panel for attributes..)
Then I found this post about how to iterate through the list of Manufacturers
http://www.magentocommerce.com/boards/viewthread/19982/

To make this appear on a  static CMS  page:
edit the app\code\core\Mage\Catalog\Block\Product.php


//new LJ 11/10/10
    public function getAllManufacturers()
    {
      $product = Mage::getModel(“catalog/product”);
      $attributes = Mage::getResourceModel(“eav/entity_attribute_collection”)
                  ->setEntityTypeFilter($product->getResource()->getTypeId())
                  ->addFieldToFilter(“attribute_code”, “manufacturer”);
      $attribute = $attributes->getFirstItem()->setEntity($product->getResource());
      $manufacturers = $attribute->getSource()->getAllOptions(false);
      return $manufacturers;
     
     
    }

This will get you an array of the manufacturer names & ids
To make the list appear on a CMS page you will need to create a new .phtml file.
I created mine at app\design\frontend\MY_THEME\default\template\catalog\brand\view_one.phtml

<ul id="manufacturer_list">
    
foreach ($this->
getAllManufacturers() as $manufacturer): ?>
        
<li>echo $manufacturer["label"] ?>li>
    
endforeach; ?>ul>

Then I created a page in the CMS with the following code block:

{{block type=”catalog/product” template=”catalog/brand/view_one.phtml”}}

Et voila – I can see all the manufacturers in a list

But I need more – I need to be able to click on each Manf. name and it take me to a landing page giving some info about the Manf. and listing their products obviously

The Yoast module above claims to be able to dynamically generate the brand pages – however I cannot get this to work on Magento v1.4.1.1
So a more brute force method is required.
I will have to manually create CMS pages for each of my manufacturers, each page having the code snippet above to show all their products.
Not ideal – but we can use some nifty MySQL to make the initial task less daunting.

The insert statement for adding a new Manufactureur Landing page is as follows:

INSERT INTO `cms_page` VALUES (PAGE_ID, “MANUFACTURER_NAME”, “two_columns_right”, “”, “”, “brands/MANUFACTURER_NAME ?>”, “MANUFACTURER_NAME”, “
Info about MANUFACTURER_NAME Brand goes here…
\r\n{{block type=”Yoast_Filter/Result” name=”filter_result”   template=”catalog/product/list.phtml” attribute=”manufacturer”   value=”MANUFACTURER_ID”  }}
“, “2010-10-11 10:34:41”, “2010-10-11 10:35:06”, 1, 0, “”, “”, “”, “”, NULL, NULL);INSERT INTO `cms_page_store` VALUES (PAGE_ID, 0);

(the 2nd insert statement makes the page active on all stores. Note also that I want my landing pages to follow the “two_columns_right” layout which may not hold true for your site)

You can use the test CMS Except Mon best-horoscope.com afternoon, when your luck might falter. page you created above to generate these INSERT Statements for you (or generate just a list of ids & value pairs as I mentioend above)
Just edit app\design\frontend\MY_THEME\default\template\catalog\brand\view_one.phtml to say this:
 
        <?php
        //before running this find the last ID inserted into the CMS and make this one larger
        $i=14;
        foreach ($this->getAllManufacturers() as $manufacturer): ?>

            
            INSERT INTO `cms_page` VALUES (<?=$i?>, “<?php echo $manufacturer[“label”] ?>”, “two_columns_right”, “”, “”, “brands/<?php echo $manufacturer[“label”] ?>”, “<?php echo $manufacturer[“label”] ?>”, “<p>Info about <?php echo $manufacturer[“label”] ?> Brand goes here…</p>\r\n<p>{{block type=”Yoast_Filter/Result” name=”filter_result”   template=”catalog/product/list.phtml” attribute=”manufacturer”   value=”<?php echo $manufacturer[“value”] ?>”  }}</p>”, “2010-10-11 10:34:41”, “2010-10-11 10:35:06”, 1, 0, “”, “”, “”, “”, NULL, NULL);
            <br />

INSERT INTO `cms_page_store` VALUES (<?=$i?>, 0);

            <br />
            
        <?php $i ;
        endforeach; ?>
When you view the page you should see some nice rows of MySQL which you can copy & paste into phpAdmin (or whichever MySQL administrator you are using)

Now how to add the navigation to go to these landing pages?

You need to move (or copy) the function getAllManufacturers() from the app\code\core\Mage\Catalog\Block\Product.php code to the app\code\core\Mage\Catalog\Block\Navigation.php block
Edit the navigation file: app\design\frontend\YOURTEMPLATE\default\tempate\catalog\navigation\top.phtml

and include the following code where you want your Manufacturers drop down to be

<li class=”level0 nav-1 level-top first parent”>
            <a class=”level-top” href=”http://www.blogger.com/post-create.g?blogID=2874821183756499009#”>
            <span>Brands</span>
            </a>
            <ul class=”level0″ id=”manufacturer_list”>
                getAllManufacturers() as $manufacturer): ?>
                   
<li class=”level1″ id=”<?php echo $manufacturer[“value”] ?>”><a href=”http://www.blogger.com//brands/“></a></li>
               
            </ul>
        </li>

Tada – you shoudl have a drop down navigation list similar to teh dropdown Categories list!

I can think of a few things to improve this.
1) Not having to manually create teh CMS pages woudl be nice (but the client does need to add her own descriptions for each Brand so I guess that is inevitable – if a highly manual task)
2) There is no way of hiding certaing Manufacturers if for eaxmple there are no products in stock

Any feedback/input from other Magento developers out tehre woudl be appreciated! I”ll post a link to this site when it finally goes live!

Share

Facebook Google+ Twitter Pinterest Email
  1. ecommerce web design says

    January 21, 2011 at 12:33 pm

    It' really superb blog with full of wonderful articles.Thanks

  2. calgary web design says

    June 17, 2011 at 10:10 am

    Magento has very good API but I want to see some more improvements of Magento pretty soon.

Back to Blog

Testimonials

I like it.  I like it a lot !!!

 You have interpreted what I wanted to achieve perfectly considering what you have to play with i.e not redoing the whole thing in the process.

Fiona Simmons-MooreSouth Gloucestershire Parents & Carers
Absolutely fantastically professional web developer – I would highly recommend!!! Thank you so much Kinetic Pulse!
Tania MarstonDoris Designs
Amazing and brilliant, Kinetic Pulse have lifted a dream to reality, Highly recommended and great if you are total novice, they know their stuff…Thanks again
Annie LindridgeSalt Yourself Out
Thank you for all of your hard work its looks fab and I am over the moon with it!
Amanda MercerAmanda Mercer Ceramics
It’s been fab working with you – we love the site and certainly going to recommend you!
James DaviesThirty Eight Degrees North
Thank you guys so much for all that you’ve done helping us to create a really awesome website!! We get such great feedback – everyone loves it & we couldn’t be prouder! Look forward to working with you again soon!
Wild Thyme PlantsWild Thyme Plants
Thanks so much for all your work on this, really appreciated. It’s come on in leaps and bounds since you took over.
Pete KewRedwood Strip Curtains

Copyright 2025 Kinetic Pulse