Monday, 30 November 2009

Manufacturers Landing Page in Zen Cart

I can't believe it hasn't been done yet - that there isn't a mod out there to add a nice landing page for each manufacturer that you get to from clicking the Manufacturer from the sidebox on a Zen Cart site.
But try as hard as I could I couldn't find that functionality anywahere - not hidden in the code of Zen Cart or in the forums.
So I thought I'd have a bash at it myself.
Warning the code is very basic - probably lots of room for improvement but for now it seems to be working.

1) Make sure that one or more of the Manufacturers in the Zen Cart Admin has an image associated with it (in my case the image needs to be no wider than 590px or it breaks the design)
2) We are going to be using the Manufacturer URL as the Description field - hey I don't want to be messing round with the databaase and the 255 chars we can add here will be good as a brief description for the Manufacturer

3) Edit the tpl_index_product_list.php (in templates) and at around line 18 add the following (inside php braces)

if (isset($_GET['manufacturers_id'])) {
$manufacturer_info_sidebox_query = "select m.manufacturers_id, m.manufacturers_name, m.manufacturers_image, mi.manufacturers_url
from " . TABLE_MANUFACTURERS . " m
left join " . TABLE_MANUFACTURERS_INFO . " mi
on (m.manufacturers_id = mi.manufacturers_id
and mi.languages_id = '" . (int)$_SESSION['languages_id'] . "')


where m.manufacturers_id = " . (int)$_GET['manufacturers_id'] ;

$manufacturer_info_sidebox = $db->Execute($manufacturer_info_sidebox_query);

if ($manufacturer_info_sidebox->RecordCount() > 0) {

$content = "";

if (zen_not_null($manufacturer_info_sidebox->fields['manufacturers_image']))
$content .= '<div class="centeredContent manufacturerHead">' . zen_image(DIR_WS_IMAGES . $manufacturer_info_sidebox->fields['manufacturers_image'], $manufacturer_info_sidebox->fields['manufacturers_name']) . '</div>';
;
if (zen_not_null($manufacturer_info_sidebox->fields['manufacturers_url']))
//$content .= '<li><a href="' . zen_href_link(FILENAME_REDIRECT, 'action=manufacturer&manufacturers_id=' . $manufacturer_info_sidebox->fields['manufacturers_id']) . '" target="_blank">' . sprintf(BOX_MANUFACTURER_INFO_HOMEPAGE, $manufacturer_info_sidebox->fields['manufacturers_name']) . '</a></li>' . "\n" ;
$content .= '<p class="manufacturersLanding">'.$manufacturer_info_sidebox->fields['manufacturers_url'].'</p>' . "\n" ;

echo $content;
}
}

Save & Upload this.
What you should find now is that when you go to a page with a manufacturers_id query string it will look in the db to see if there is an associated image and or url (in this case description) and display that

As a final touch you may want to update the Manufacturers page in the Admin section so that the label Manufacturers Url is changed to Description - and that a textarea box is shown rather than the small input field

1) Edit the file admin/manufacturers.php
2) At about line 255 replace this line

$manufacturer_inputs_string .= '
' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . zen_draw_input_field('manufacturers_url[' . $languages[$i]['id'] . ']', '', zen_set_field_length(TABLE_MANUFACTURERS_INFO, 'manufacturers_url') );

with this line

$manufacturer_inputs_string .= '
' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . zen_draw_textarea_field('manufacturers_url[' . $languages[$i]['id'] . ']', 'soft', '50', '6','');

3) Just below that replace

$contents[] = array('text' => '
' . TEXT_MANUFACTURERS_URL . $manufacturer_inputs_string);

with

$contents[] = array('text' => '
Manufacturers Description (max 255 chars)'. $manufacturer_inputs_string);
}

4)A bit further down (line 290 ish) replace

$manufacturer_inputs_string .= '
' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . zen_draw_input_field('manufacturers_url[' . $languages[$i]['id'] . ']', zen_get_manufacturer_url($mInfo->manufacturers_id, $languages[$i]['id']), zen_set_field_length(TABLE_MANUFACTURERS_INFO, 'manufacturers_url'));

with

$manufacturer_inputs_string .= '
' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . zen_draw_textarea_field('manufacturers_url[' . $languages[$i]['id'] . ']', 'soft', '50', '6', zen_get_manufacturer_url($mInfo->manufacturers_id, $languages[$i]['id']));
}

5) And just below that replace

$contents[] = array('text' => '
' . TEXT_MANUFACTURERS_URL . $manufacturer_inputs_string);

with this

$contents[] = array('text' => '
Manufacturers Description (max 255 chars)'. $manufacturer_inputs_string);

There you have it a simple way of creating a Manufacturer's Landing Page in Zen Cart!

See it in action here:
Billabong Landing Page on SurfsideOnline

Comments, suggestions, improvements always welcome though!

Friday, 20 November 2009

Installing Simple SEO URL module for ZenCart

Well I've finally done it - installed the Simple SEO URL module for Zen Cart!

And I thought I'd better document it here before I forget the steps I've done and need to do it again for another cart.

I had avoided doing on previous carts as its a bit fiddly to set up and if you get it wrong it completely breaks your cart (those unhelpful Internal Server Error 500 messages!) But its SO useful for SEO that I thought it worth persevering.
So here goes:

1) Download module from http://wiki.rubikintegration.com/zencart/modules/ssu/installation (or search on ZenCart's Modules page)
NOTE: For PHP4 installs the latest stable release is 2.9 - not 3.x

2) Download & install the Zen Cart Module Manager from here (http://code.google.com/p/zencart-module-manager/downloads/list) (Before installing the above module, ok?!) Update: June 2010 - the only module manager I can g et to work with ZenCart 1.3.9d is Module Manager rev16 (the latest one doesn't want to play ball)

3) Ensure Module Manager is installed by going to Admin > Tools > Module Manager
4) Now upload the files for the SEO module then install by going to Admin > Extras > Simple SEO URL Manager

NOTE: this is NOT enabled yet just installed.

Look at your .htaccess file - VERY IMPORTANTLY make sure that the Rewrite Base line reflects the site you're on - if the shop is in a subdirectory change the name here - if its in the root is should just be /

5)Upload the .htaccess file
6)To enable the module go to Admin > Configuration > Simple SEO URL and the last setting is "Set SSU status" - which defaults to false. Change it to true - and have a look at the live site.
If its working, well done - go have a celebratory cup of coffee!
If you get 500 errors, double and triple check your .htaccess file.
Still not working? Try reuploading your SEO mod files again and re-do steps 3 onwards

There's help online in this thread here:
http://www.zen-cart.com/forum/showthread.php?t=86353

I have noticed a performance drop but will persevere with it as I think it does mean the customer will see far nicer URLs

Let me know how you get on!

UPDATE: As is the zooms on additional product images stop working - all you have to do is go to Configuration > Simple SEO URL and in the field called Exclude List add "popup_image_additional"

Thursday, 19 November 2009

Managing New Items on a Zen Cart

The New Products view can be a mixed blessing in Zen Cart.
Of course you want to showcase new items to your customers - but what exactly defines "new"?
There are a few places to set this up in Zen Cart

1)The default ordering for products in the New Products list is set in Configuration > New Listing > Default Sort Order to Newest Products first
(but this can be changed to other sort orders)

2) The window of "new-ness" so to speak is defined in
Configuration > Maximum Values > New Product Listing Limited to.....

Products can be deemed to be new from 7 days old, a month old, 120 days old or always

*Beware however if you are using a batch upload facility to import new products (such as EasyPopulate) as I have found that it sometimes doesn't add a timestamp to the products. This gives distinctly odd results in the New Items page. This should be able to be resolved by adding the column 'v_date_added' to the batch import and hardcoding the product added date that way

Sunday, 15 November 2009

How to show number of items in shopping cart in Zen Cart

Here's a useful snippet of code if you need to show just the total of items in a Zen Cart shopping cart.


echo "Items in cart: ". $_SESSION['cart']->count_contents();


I'm using it in a discrete header including a link to the shopping cart page.
I think it looks cleaner than the default Zen Cart shopping cart side box.

(I'll add link to the live shopping site - when I've finished it. Watch this space!)