Archive

Archive for March, 2009

Magento Notes — Magento for B-2-B Web site

March 27th, 2009

<button class=”button” onclick=”setLocation(’<?php echo $this->getAddToCartUrl($_product) ?>’)”><span><?php echo $this->__(’Add to Cart’) ?></span></button>

I have recently been approached to work on a couple catalog-driven web sites for wholesalers and manufacturers, and what I have been presenting to them is simply a customized Magento installation in which 1) the pricing gets stripped out and/or
2) the pricing and the “add to cart” button gets stripped

Some of them also require that site operators approve customers before they can attempt to login; there’s a plugin for this here.

Below is a how-to on how to hide the “add-to-cart” button to non-logged in users.  Users would need to login in order to have a functional shopping cart:

Step 1 - To hide price: open the template file that shows prices: /app/design/frontend/default/[theme]/template/catalog/product/price.phtml and go to line line 30 (below: <?php $_id = $_product->getId() ?>) and add:

<?php if(Mage::getSingleton(’customer/session’)->isLoggedIn()): ?>

and at the very end, add:

<?php endif; /* if ($this->isCustomerLoggedIn()): */ ?>

Step 2 - go to /app/design/frontend/default/default/template/catalog/product/view/addtocart.phtml and add:

<?php if(Mage::getSingleton(’customer/session’)->isLoggedIn()): ?>

after: <?php $_product = $this->getProduct() ?>

and then add:

<?php endif; ?>

before <fieldset class=”add-to-cart-box”>

Step 3 - Remove add to cart buttons from /app/design/frontend/default/default/template/catalog/product/list.phtml

add the same if and endif statement around the following line of code:

<button class=”button” onclick=”setLocation(’<?php echo $this->getAddToCartUrl($_product) ?>’)”><span><?php echo $this->__(’Add to Cart’) ?></span></button>

so that it looks like:

<?php if(Mage::getSingleton(’customer/session’)->isLoggedIn()): ?>
<button class=”button” onclick=”setLocation(’<?php echo $this->getAddToCartUrl($_product) ?>’)”><span><?php echo $this->__(’Add to Cart’) ?></span></button>
<?php endif; ?>

read through the code and you will see 2 instances of the above (one for grid and one for list view)

Step 4 - Do the same as step 3 to file: /app/design/frontend/default/[theme]/template/catalog/product/compare/list.phtml

As I finished this, I found a more detailed wiki post on Magento: http://www.magentocommerce.com/wiki/price_on_application, it’s actually quite a bit more extensive and details on how to add attributes for variations to showing price.

blog posting, e-commerce, magento, technical notes , ,

Uploading mysql database via SSH

March 20th, 2009

I have always uploaded my Magento database via PHPMyAdmin (I know I know, it’s for novices)…but an incident yesterday with SimpleHelix (my current Magento hosting provider) forced me to learn how to import database and use SSH.  The whole incident started two days ago when I tried troubleshooting a new Magento installation, as the installation went through fine, but I kept getting error messages when I tried to view the front-end and when I tried logging into the backend; neither worked.  Tried googling on the web site for the error message (can’t remember what it was), but found no relevant errors…somewhat surprised, so I figure maybe it’s not a Magento issue. Read more…

blog posting, evaluation, technical notes , , , ,

Bloggers’ essential tool — ScreenGrab (Firefox Extension)

March 19th, 2009

After so many blog posts, it has finally hit me that I need a better screen capture tool to do screen captures for web pages.  Did a quick search and I came up with ScreenGrab, it’s definitely the one of the must-haves for bloggers who deals alot with screenshots.  Before I would do a print screen (PrtSc), and the crop the image in Photoshop…NO MORE!

Download ScreenGrab here

Attached image is grabbed using the tool.

blog posting, recommendations ,

Magento Notes — Show thumbnail image without pop-up window

March 19th, 2009

Finding ways to improve on the usability of tickon.com, I have made a small improvement.  I thought it was quite annoying to always have to wait for a new window to open to view the alternate images, so did some googling and found the perfect fix on Magento forum (link to exact post).  This fix simply allows you to click on the thumbnail alternate images and have it be shown in the large image box above.  Without going through the discussion thread…here’s the quick fix:

Locate media.phtml in app/design/frontend/default/themename/template/catalog/product/view, and near line# 59, you should see:

<a href=”#” onclick=”popWin(’<?php echo $this->getGalleryUrl($_image) ?>’, ‘gallery’, ‘width=300,height=300,left=50,top=50,location=no,status=yes,scrollbars=yes,resizable=yes’); return false;”><img src=”<?php echo $this->helper(’catalog/image’)->init($this->getProduct(), ‘thumbnail’, $_image->getFile())->resize(120); ?>” alt=”<?php echo $this->htmlEscape($_image->getLabel()) ?>” title=”<?php echo $this->htmlEscape($_image->getLabel()) ?>” /></a>

change the part in red to the following:

<a href=”<?php echo $this->helper(’catalog/image’)->init($this->getProduct(), ‘image’, $_image->getFile()); ?>” title=”<?php echo $_product->getName();?>” onclick=”$(’image’).src = this.href; return false;”>

You should be able to modify it a bit more if you want the image to update on mouseover.

blog posting, e-commerce, magento, technical notes , ,

Magento web site showcase

March 19th, 2009

Just came across this blog post on SimpleHelix’s blog referencing a UK-based web site: http://www.magentoshowcase.co.uk/, after browsing the web site, all I can say is “WOW”, amazing what some people can do to make Magento look so beautiful.

Now only if they can list the designer responsible for each of the site listed, then that would be even better :-)

blog posting, magento, templates , , ,

Wordpress Notes — Going live from local development environment

March 17th, 2009

As I launch more wordpress web sites, I am realizing that there are inherent issues with how Wordpress saves the posts…it always uses absolute path for URL links.  This creates problem for me as in my scenario, all of my local development have a url path of http://localhost:8080/sitename, so when I moved the blog to production and assign it a valid domain name like http://blog.52my.info, all the existing post links and image links would still be referring to the local computer for images and posts! This is TRICKY, as you won’t noticed this problem, because more than likely YOU ARE browsing the site that you have uploaded using the same computer where the dev blog was hosted, and you would see all images load up properly b/c they are stored on your local computer.  But when you go to another computer, you will see all the missing posts and images, etc.

The fix for this is to run several SQL scripts in which it would do a find and replace for all data in the mysql tables and rename them to the proper domain name url. I found this information from this great post here. But the long and short of it is run the following scrips:

1. update the wp_options table:

UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';

2. Update wp_posts

UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com','http://www.new-domain.com');

3. Update post contents in which there are links within post content to the blog itself:

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');

blog posting, technical notes, wordpress , ,

Magento Notes — Fix for adding contact form in CMS pages

March 16th, 2009

This is a follow-up post on a fix that I had suggested about adding a contact us form through the CMS admin tool here.  What I found out was that the form post back left out the action parameter…when you do a view source.  So essentially the form gets filled out but doesn’t get sent to the site owner.

I found this out on my own tickon.com web site’s submit a product page.  Below is the fix for this:

Go into: app/design/frontend/default/blue/template/contacts and modify the form.phtml.  On (or around) line# 32, replace:

<form action=”<?php echo $this->getFormAction(); ?>” id=”contactForm” method=”post”>

with

<form action=”<?php echo Mage::getUrl(); ?>contacts/index/post/” id=”contactForm” method=”post”>

and you should be ready to go.

e-commerce, magento, technical notes , ,

Magento Notes — Cleanly delete ALL products from your Magento database

March 12th, 2009

Having been working on a Magento web site for an auto-parts manufacturer, so you can easily imagine how many SKUs I have to deal with in the database…THOUSANDS!!  I have been struggling with the import process that comes with Magento…biggest lingering problem is that I can’t get the import service to work on production server even though it works perfectly fine on my local laptop.

While testng the importing process (meaning continously importing and reimporting), I also find that there isn’t an easy way to remove data cleanly from the database..so did some googling and found the following thread on Magento web site here. The short version is to go into mysql admin, for me it’s phpmyadmin, and run the following sql script:

TRUNCATE TABLE `catalog_product_bundle_option`;
TRUNCATE TABLE `catalog_product_bundle_option_value`;
TRUNCATE TABLE `catalog_product_bundle_selection`;
TRUNCATE TABLE `catalog_product_entity_datetime`;
TRUNCATE TABLE `catalog_product_entity_decimal`;
TRUNCATE TABLE `catalog_product_entity_gallery`;
TRUNCATE TABLE `catalog_product_entity_int`;
TRUNCATE TABLE `catalog_product_entity_media_gallery`;
TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
TRUNCATE TABLE `catalog_product_entity_text`;
TRUNCATE TABLE `catalog_product_entity_tier_price`;
TRUNCATE TABLE `catalog_product_entity_varchar`;
TRUNCATE TABLE `catalog_product_link`;
TRUNCATE TABLE `catalog_product_link_attribute`;
TRUNCATE TABLE `catalog_product_link_attribute_decimal`;
TRUNCATE TABLE `catalog_product_link_attribute_int`;
TRUNCATE TABLE `catalog_product_link_attribute_varchar`;
TRUNCATE TABLE `catalog_product_link_type`;
TRUNCATE TABLE `catalog_product_option`;
TRUNCATE TABLE `catalog_product_option_price`;
TRUNCATE TABLE `catalog_product_option_title`;
TRUNCATE TABLE `catalog_product_option_type_price`;
TRUNCATE TABLE `catalog_product_option_type_title`;
TRUNCATE TABLE `catalog_product_option_type_value`;
TRUNCATE TABLE `catalog_product_super_attribute`;
TRUNCATE TABLE `catalog_product_super_attribute_label`;
TRUNCATE TABLE `catalog_product_super_attribute_pricing`;
TRUNCATE TABLE `catalog_product_super_link`;
TRUNCATE TABLE `catalog_product_enabled_index`;
TRUNCATE TABLE `catalog_product_website`;
TRUNCATE TABLE `catalog_product_entity`;
TRUNCATE TABLE `cataloginventory_stock`;
TRUNCATE TABLE `cataloginventory_stock_item`;
TRUNCATE TABLE `cataloginventory_stock_status`;
insert  into `catalog_product_link_type`(`link_type_id`,`code`) values (1,‘relation’),(2,‘bundle’),(3,’super’),(4,‘up_sell’),(5,‘cross_sell’);
insert  into `catalog_product_link_attribute`(`product_link_attribute_id`,`link_type_id`,`product_link_attribute_code`,`data_type`) values (1,2,‘qty’,‘decimal’),(2,1,‘position’,‘int’),(3,4,‘position’,‘int’),(4,5,‘position’,‘int’),(6,1,‘qty’,‘decimal’),(7,3,‘position’,‘int’),(8,3,‘qty’,‘decimal’);
insert  into `cataloginventory_stock`(`stock_id`,`stock_name`) values (1,‘Default’);

Someone suggested to just run “TRUNCATE TABLE `catalog_product_entity`”, but that appears to be an incomplete solution that would leave too much orphaned data behind.

Another script below can be used to wipe out all categories:

TRUNCATE TABLE `catalog_category_entity`;
TRUNCATE TABLE `catalog_category_entity_datetime`;
TRUNCATE TABLE `catalog_category_entity_decimal`;
TRUNCATE TABLE `catalog_category_entity_int`;
TRUNCATE TABLE `catalog_category_entity_text`;
TRUNCATE TABLE `catalog_category_entity_varchar`;
TRUNCATE TABLE `catalog_category_product`;
TRUNCATE TABLE `catalog_category_product_index`;

insert  into `catalog_category_entity`(`entity_id`,`entity_type_id`,`attribute_set_id`,`parent_id`,`created_at`,`updated_at`,`path`,`position`,`level`,`children_count`) values (1,3,0,0,‘0000-00-00 00:00:00′,‘2009-02-20 00:25:34′,‘1′,1,0,1),(2,3,3,0,‘2009-02-20 00:25:34′,‘2009-02-20 00:25:34′,‘1/2′,1,1,0);
insert  into `catalog_category_entity_int`(`value_id`,`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`) values (1,3,32,0,2,1),(2,3,32,1,2,1);
insert  into `catalog_category_entity_varchar`(`value_id`,`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`) values (1,3,31,0,1,‘Root Catalog’),(2,3,33,0,1,‘root-catalog’),(3,3,31,0,2,‘Default Category’),(4,3,39,0,2,‘PRODUCTS’),(5,3,33,0,2,‘default-category’);

magento, technical notes , ,

Magento notes — Add social bookmarking to your e-commerce site

March 9th, 2009

Now that tickon.com has been running for about a month, the real challenge is how to promote this web site.  This appears to be the most common question that I get nowaday.  Many potential clients have asked me the same question…and honestly, aside from the generic SEO techniques that every SEO firm uses, how else can you drive traffic to your site?

Here’s one strategy: I am exploring the possibility of having existing users on tickon.com do the promotion for me by making it easy for them to bookmark my site and add my web site information to any of the popular social bookmarking and networking sites out there.

here’s how I did it…sign up for a FREE AddThis account, and add the javascript that was provided into the following Magento page: app/design/frontend/default/your theme/template/catalog/product/view/addto.phtml

I simply added a new <ul></ul> below the existing links for “add to wishlist” and “add to compare”, below is the code:

<ul class=”add-to-box”>
<li><br>
<!– AddThis Button BEGIN –>
<script type=”text/javascript”>var addthis_pub=”youraddthisaccount”;</script>
<a href=”http://www.addthis.com/bookmark.php?v=20″ onmouseover=”return addthis_open(this, ”, ‘[URL]‘, ‘[TITLE]‘)” onmouseout=”addthis_close()” onclick=”return addthis_sendto()”><img src=”http://s7.addthis.com/static/btn/lg-share-en.gif” width=”125″ height=”16″ alt=”Bookmark and Share” style=”border:0″/></a><script type=”text/javascript” src=”http://s7.addthis.com/js/200/addthis_widget.js”></script>
<!– AddThis Button END –>
</li>
</ul>

the code is added right below the closing

on line 37

I will be posting the effectiveness of adding this social bookmarking widget once I gather enough stats from tickon.com.

blog posting, e-commerce, magento, technical notes , ,

Free Wi-Fi access at Starbucks

March 4th, 2009

Since Starbucks is kind of like my second office, and I do a lot of work and client meetings there.  Again Casual Commerce stands for casual meetings with clients over a cup of coffee.  Quite often clients are surprised when I tell them that I can use Starbucks’ wireless access to get online for free, and they want to know how to do this.  It’s actually quite simple, all you need is a starbucks card, which is free, but you just have to load money into it and buy coffee with it, and you use the PIN number in the back of the card to sign up for an account with AT&T to get a login/pswd.

For some reason, Starbucks’ web site makes this information hard to find, so here it is:

https://secure.sbc.com/sblp_index.adp

Get a card, have a cup of coffee, and get online.

blog posting, recommendations , ,