Adding a teaser to an Ubercart catalog

I needed to format the Ubercart catalog differently from how it is in the default distribution.  Specifically, I wanted to include the product description teaser in the catalog listings.  I found two possibilities:

I found a blog post at http://www.sevenshadow.com/blog/ubercart-customize-datagrid that described how to add a field for a short description.  That was a start.

I found a patch posted on Ubercart: http://www.ubercart.org/contrib/10983 to add a teaser to the catalog.  It would probably have worked, but it required a patch to Ubercart.

In looking through the patch and the blog entry, it occurred to me that I might be able to combine these approaches.  I followed step 3 of the blog and created an override in the template.php file for the theme_uc_catalog_product_grid function.  Then I added a different line of code, guessing that the Ubercart people would have included access to the product's teaser in their $product array.  the line I added was:

$product_table .= '<span class="catalog-grid-teaser">'. $product->teaser .'</span>';

just after:

$product_table .= '<span class="catalog-grid-image">'. $imagelink .'</span>';

And voila, I had the product's description teaser in my catalog entry!  Now I had to do some additional work in my style.css file to change how the catalog entry was styled, and I had my teaser as part of the catalog entries.

X
Loading