Over a year ago, I released a free Magento Featured Products Widget which groups the featured products by category.  Since releasing it I’ve had a lot of traffic, and a lot of pleasant feedback from users.  Now I’ve finally been able to get round to upgrading the widget to be even better with a lot of rewritten code, testing and few new features too.

New Features

  • Creates featured attribute on installation
  • Displays Review Summary
  • Displays Add to Cart button
  • Shows path to categories when selecting categories in admin (easier to distinguish between different stores with same category names)
  • Caching
  • Code rewrite (better documented and better Magento conventions)
  • Compatibility checked on 1.4.0.0 to 1.6.2.0
  • More flexible styling (font colours are now theme defaults)
  • Included Minimum price for Bundled Products
  • Products only fetched from current store
  • Mixed template is now a lot cleaner

Screenshots

Grouped by category

Configuration Options

Mixed Display

Installation and Documentation

Installation

Copy the app and skin directories into your Magento installation

Usage

CMS Pages

  1. Login to your Magento admin
  2. Go to CMS > Pages
  3. Select the page you want to use
  4. Click the Content tab
  5. In the WYSIWYG Editor, click the Insert Widget button (for me it’s top row, second from the left)
  6. As Widget Type select Cube Websites - Category Featured Products
  7. Configure your Widget using the available options

Frontend Template
Categorised – Displays the products grouped by the category they belong in
Mixed – Displays all the products in a single block with no grouping

Categories (only applies if Categorised Frontend Template is selected)
The categories to select products from

Number of Products
If Categorised – the number of products from each category
If Mixed – the total number of products

Products Per Row
How many products will be displayed on each row in the frontend

Products to Display
Featured – Displays featured products only
All – Displays all available products

Featured Attribute Code (optional)
By default this is cube_category_featured but if you’ve created your own featured attribute code then you can use that instead.

Within your template

  1. Open your favourite text editor
  2. Within find the Layout XML you want to add the block to within the app/design/frontend directory
  3. In your .xml file, add the following in the relevant position
     <block type="categoryfeatured/list" name="featured_products" as="featuredProducts" template="categoryfeatured/block.phtml">
     <action method="setData"><name>categories</name><value>1,2,3,4</value></action>
     <action method="setData"><name>num_products</name><value>4</value></action>
     <action method="setData"><name>products_per_row</name><value>4</value></action>
     <action method="setData"><name>product_type</name><value>featured</value></action>
     <action method="setData"><name>featured_code</name><value>cube_category_featured</value></action>
    </block>

template
categoryfeatured/block.phtml – Displays the products grouped by the category they belong in
categoryfeatured/mixed.phtml – Displays all the products in a single block with no grouping

categories (only applies if categoryfeatured/block.phtml template is selected)
The categories to select products from (comma separated)

num_products
If categoryfeatured/block.phtml – the number of products from each category
If categoryfeatured/mixed.phtml – the total number of products

products_per_row
How many products will be displayed on each row in the frontend

product_type
featured – Displays featured products only
all – Displays all available products

featured_code (optional)
By default this is cube_category_featured but if you’ve created your own featured attribute code then you can use that instead.

If you need to output the block in a certain location of your template, then make sure you include the following in your .phtml file <?php echo $this->getChildHtml('featuredProducts') ?>

Downloads

I’m currently awaiting approval from the Magento Connect site, but I’ve also made this project available free on GitHub.

Download from Magento Connect (awaiting approval)
Download latest version

Download 2.0.1

Fork on GitHub

Feedback and Support

If you have any questions or issues please feel free to post in the comments.

I’ve spent the past few days creating a more up to date version of my Category Featured Product module for Magento.

NOTE: If you just want the solution, skip to the end of this post where I’ve written a quick summary

One of the new features that it has is the ability to display the product review summary, just like you’d get on a category page.

At first I thought it would be quite simple, simply load the product attributes and then call the usual code in the template as follows:

<?php if($_product->getRatingSummary()): ?>
 <?php echo $this->getReviewsSummaryHtml($_product) ?>
 <?php endif; ?>

Unfortunately this piece of code returns nothing and no review summary is displayed.  After a quick var_dump of $_product->getRatingSummary() I noticed that the value being returned was null

Owing to this, I set about trying to find a solution by looking at how the Product List Block works and seeing if I could find anything related in there. Unfortunately there were no clues in there, although I did pick up some other nifty little tricks (will share another day).

After 2 hours searching, I finally managed to find how it’s done…
When the Product List block is about to be rendered, the _beforeToHtml() is run, this in turn dispatches an event:

Mage::dispatchEvent('catalog_block_product_list_collection', array(
 'collection' => $this->_getProductCollection()
 ));

A quick search for catalog_block_product_list_collection in my IDE led me to:
app/code/core/Mage/Review/etc/config.xml
I knew I was about to find the solution as soon as I saw “Review” in the path!

I opened up the file, and found this:

<catalog_block_product_list_collection>
    <observers>
        <review>
            <type>model</type>
            <class>review/observer</class>
           <method>catalogBlockProductCollectionBeforeToHtml</method>
       </review>
    </observers>
</catalog_block_product_list_collection>

I quickly opened up app/code/core/Mage/Review/Model/Observer within which I found the catalogBlockProductCollectionBeforeToHtml method (as mentioned in the XML above).

This method contained the following code:

$productCollection = $observer->getEvent()->getCollection();
if ($productCollection instanceof Varien_Data_Collection) {
    $productCollection->load();
    Mage::getModel('review/review')->appendSummary($productCollection);
}

And obviously this was the solution 😀
I went back to my code and added in the following lines:

$collection->load();
Mage::getModel('review/review')->appendSummary($collection);
return $collection;

After refreshing the page, I was seeing all the product reviews and it was a big win all round. It’s been quite a journey finding the solution, but as is usually the case with such mighty investigations, the sense of elation upon discovery can only be compared to that experienced when finding money under the sofa cushions.

Summary

For those who don’t want to read the entire post (I’m not one to judge and call lazy) here’s a quick summary of the solution:

In your template put (use whatever variable name you assign to your product):

<?php if($_product->getRatingSummary()): ?>
 <?php echo $this->getReviewsSummaryHtml($_product) ?>
 <?php endif; ?>

After filtering your collection, just about it’s going to be passed to the view run the following:

$collection->load();
Mage::getModel('review/review')->appendSummary($collection);
return $collection;

Hope this helps!

UPDATE 4 FEBRUARY 2012: An updated version  of this widget is now available here

Today I launched my first Magento widget.

Features

  1. Group by category.  Using this widget, you can specify the categories to display products from, and on the frontend you’ll be able to see the products grouped by those categories.
    This is a lot more useful to customers, plus provides more flexibility to you as a store owner – you could even show featured products for each category at the top of that category’s page.
  2. It’s free.  Need I say more?
  3. Feedback is welcome! This isn’t a one-hit-wonder. I will attempt to actively develop and add features to it according to user requests.
  4. Random products too.  It’s not only a featured products widget, if you prefer it can select any random product from a category (if specified), or from all your categories

Options

Name Options Description
Frontend Template Categorised, Mixed Categories displays products grouped by category, Mixed displays all products in a single grid
Categories All active store categories Choose the categories from which products are selected. Only used for the “Categorised” Frontend Template. Has no effect on “Mixed”
Products Per Category Any number (default 3) The number of products to select from each category. Only used for the “Categorised” Frontend Template. Has no effect on “Mixed”
Products per row Any number (default 3) The number of products to display per row on the frontend.
Products to Display Featured, All Featured selects products only with the featured attribute, All selects all active products
Featured Attribute Code None. cube_category_featured by default To use Featured Products, create an Attribute (Catalog->Attributes->Manage Attributes) with a Yes/No input type. Enter the Attribute Code into this Featured Attribute Code field. Set this field to Yes for each featured product.

Download

I’ve submitted the extension to MagentoConnect and will post the URL as soon as it’s live.
For now you can download it using the links below:

Zip file (upload all contents to server): download
Pear package: download

Screenshots

 

All products, Mixed mode

All products, Grouped by Category

Admin Configuration Screen

 

License

Basically, you can use this extension for free on your store.  You can include it with your Magento themes and templates (as I’m about to with my next template).

The only thing I ask is that you give credit where credit is due.

Enjoy!

UPDATE 4 FEBRUARY 2012: An updated version  of this widget is now available here

I just started writing a custom Magento widget for an upcoming Magento Template following the tutorial in the Magento knowledgebase.

As one of the options for the widget I needed a custom value provider, so decided to use the instructions provided to specify a source model using the source_model parameter.

However, by using the given format the widget options just wouldn’t load in the admin area.

<source_model>widgettwo/services</source_model>

I couldn’t easily find any results by searching Google for help, so after spending a bit of time with trial and error I found the solution to this problem. Instead of using the module/model structure, you actually need to provide the class name of your model e.g.:

<source_model>Cube_CategoryFeatured_Model_Categories</source_model>

After updating my widget.xml file to use the new source model parameter everything worked smoothly.

The widget I’m creating will be included in the next commercial Magento template, and I’ll also make it available on Magento Connect for free of charge!

Many of you may be aware that HostGator did not support InnoDB, and therefore the newer versions of Magento did not install on their servers.  As our hosting uses HostGators servers, we were unable to host Magento sites for you.

However, this morning we have received confirmation, that:

13 May 2009, InnoDB will be supported by HostGator

From that date Cube Websites will become an official Magento web host, and we will be introducing a new web hosting package simply for Magento!

Magento Discovered!

Magento Discovered!

First of all, to get an idea of what this article is about, check out our Magento Demo Store.  Done that?  Let’s carry on…

E-Commerce has been a big part of the web industry for a long time now.  We’ve been having request to build online shops and stores ever since we started building websites (when we were called Finless Fish).

At the time we used to make what now seems very primitive shopping carts and there wasn’t a lot of functionality to offer.

Later on OSCommerce entered the scene, which we built several sites using.  OSCommerce was a shopping cart ‘software’ which you can simply download and install on your hosting.  Once installed, we’d do the configuration, and build a decent design for it.

Though this was the best product of it’s kind, we can hardly say it was easy to develop and design for.

Later, Zen Cart emerged, which was a heavily modified OSCommerce, but introduced plenty of new features – still, designing for it wasn’t the easiest task, and development was very slow.

Now, 2008, Magento is discovered!

When we first heard of Magento, we went straight to their site, clicked the Demo page and thought ‘WOW.
First impression was the looks, and as a free default design, it’s the best we’ve seen on any e-commerce software.

After that, we had a look around, looked at the technical features and were really impressed by it all.
It offers a great navigation, layered browsing (shop by price, brand etc), integrates with Royal Mail nicely and loads more besides.

Then the real test came when it was time to build our next E-Commerce website.  We made a nice looking design and had a go at converting it into a Magento skin.
The process was so easy, it’s really quite unbelievable.  The whole process took less than half the time it took is with OSCommerce and Zen Cart.

After everything, it’s safe to say that Magento is by far the best e-commerce product we’ve come across.  We’ll be using that for future websites.
Customers should also remember, half the creation time means we can offer these kinds of websites at lower prices now.

Prices for a fully customised Magento store start at £100.
Once again, the link for the demo store is: Demo Store