Archive

Archive for the ‘magento’ Category

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 , , ,

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 , ,

Magento Notes - Fix for product category becoming blank

February 25th, 2009

After upgrading from version 1.1.6 to 1.2.1, there has been many issus with files not being updated properly.  The new problem deals with when you are editing a product (Catalog -> Manage Products) and you go to the “Categories” link at the left pane, you may see a screen with title “Product Categories” and nothing else.  Refer to pix.

Another system to this problem is that when you are in the Category Manager and you attempt to expand a parent category, you will just get the spinning wheel..and it would run forever.

the fix for both issues is to replace the “head.phtml” inside: magento/app/design/adminhtml/default/default/template/page

The fix was found here, but under a different topic: http://www.magentocommerce.com/boards/viewthread/27032/P75/#t101188

magento, technical notes , ,

Magento Notes - File access error in admin page (Catalog and Inventory links)

February 25th, 2009

Just upgraded a Magento installation from 1.6.1 to 1.2.1 and ran into some minor issues with file not found error like the following:

Warning: include(Mage/Adminhtml/Model/System/Config/Backend/Catalog/Inventory/Managestock.php) [function.include]: failed to open stream: No such file or directory in /home/noblesg/public_html/shop/app/code/core/Mage/Core/functions.php on line 73
Trace:

After some research on Magento forum…found a solution. It appears to be a common issue with version 1.2.1, the fix for this is fairly simple, just copy the files from:

http://svn.magentocommerce.com/source/branches/1.2-trunk/app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Catalog/Inventory/

if you look carefully the url path will correspond to your file structure in Magento, just copy the files that you are missing by traversing the folder and right-click the file and choose “Save As” and save the file(s) back into your magento folder and you should be ready to go.

For me, I had to recreate the “Catalog” folder and all files within underneath /config/backend/ and also the “Search” folder and all files within underneath Adminhtml/Model/System/Config/Source/Catalog/ to fix the “Catalog” and “Inventory” links in the admin page.

blog posting, magento, technical notes ,

Magento Notes - adding contact form into other CMS created pages

February 24th, 2009

I am just in the process of creating a new form for tickon.com, in which I would allow users to submit their products for evaluation and resell on the web site.  Again, with Magento, this is not something easy, or intuitive to do.  I came across a great read on http://inchoo.net/, giving a tutorial on how to embed the contact form in a CMS-created page.  Basically what you have to do is create a CMS page by going to: CMS -> Manage Pages -> Add New Page and simply embed the following script inside the “Content” text box, and you are ready to rock.

<!– CONTACT FORM –>
{{block type=’core/template’ name=’contactForm’ template=’contacts/form.phtml’}}
<!– END OF CONTACT FORM –>

blog posting, magento, technical notes , ,

Magento Notes - Adding a new page template

February 24th, 2009

In case anybody want to create a new page template to be selectable in the CMS, below are the simple steps to follow:

1. Create a a new phtml file in: app/design/frontend/default/your theme/template/page folder. Easiest way to do this is to copy one of the existing files (1column.phtml, 2columns-left.phtml, 3columns.phtml) that you will want to build on, and rename the new file to your liking.

2. Modify the config.xml in: app/code/core/Mage/Cms/etc, near line 182, you simply copy one of the existing xml block like the following:

<one_column>
<label>1 column</label>
<template>page/1column.phtml</template>
</one_column>

and rename the label to your liking (this name will be how you reference the template in the CMS, and then modify the phtml file name.  For my example below is my revised xml block:

<one_column_splash>
<label>1 column w splash</label>
<template>page/1column_splash.phtml</template>
</one_column_splash>

3. Make sure you refresh your cache, and go back into CMS and in the design section of the page, you will see the new template name in the drop down menu.

Text in green are what I have modified.  Hope people find this helpful.

The know-how for this post is obtained from Magento forum at: http://www.magentocommerce.com/boards/viewthread/1406/, and has been personally verified that it works very well. Thanks Chinesedream for the wonderful fix.

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

Give your products more exposure on Google Base

February 17th, 2009

Just spent 2 days to get my products on Tickon.com listed in Googlebase.  By having the products listed in googlebase, you can get additional exposure on Google’s database, as well as more opportunities for Google crawlers to find your products and link to your site. 

Since Tickon.com is still running on an older version of Magento (still need to find time to upgrade, but I am afraid of the upgrade process due to bad past experiences), the tutorial here from Magento didn’t really help. But if you are on 1.1.7, you should check out the video! They have added extra menu options in the admin page to facilitate this.

So without the automated features to export from magento and into googlebase, the process becomes a manual process of exporting out a .txt file and uploading it into googlebase.  To export, you can use this workaround that I found on the Magento forum; thanks Turbo1.  Simply download the gbase.php file (or view the script below), modify the path to where you want to save the file (for me, i saved it to /var/export), and simply drop the file into the Magento root folder and then access the file like this: http://www.tickon.com/gbase.php, and this would create the required .txt file into the /var/export folder.

Now that you have the file, you can simply create a datafeed in googlebase and upload the txt file.  without this gbase.php file, using the default Export Magento module would be difficult, but not impossible!

Have fun.  My next task…feeding the products into Feedburner.

<?php
define(’SAVE_FEED_LOCATION’,'var/export/google_base_feed.txt’);//you can set a new folder and file if you want, don’t forget to chmod the folder to 777

// make sure we don’t time out
set_time_limit(0);

require_once ‘app/Mage.php’;
Mage::app(’default’);

try{
$handle = fopen(SAVE_FEED_LOCATION, ‘w’);

$heading = array(’id’,'title’,'description’,'link’,'image_link’,'price’,'brand’,'product_type’);
$feed_line=implode(”\t”, $heading).”\r\n”;
fwrite($handle, $feed_line);

//———————- GET THE PRODUCTS
$products = Mage::getModel(’catalog/product’)->getCollection();
$products->addAttributeToFilter(’status’, 1);//enabled
$products->addAttributeToFilter(’visibility’, 4);//catalog, search
$products->addAttributeToSelect(’*');
$prodIds=$products->getAllIds();

//echo ‘Product filter: ‘.memory_get_usage(false).’<br>’;
//flush();

$product = Mage::getModel(’catalog/product’);

foreach($prodIds as $productId) {
//echo ‘. ‘;
//flush();
//echo ‘Loop start: ‘.memory_get_usage(false).’<br>’;
//flush();

//$product = Mage::getModel(’catalog/product’);
$product->load($productId);

$product_data = array();
$product_data['sku']=$product->getSku();
$product_data['title']=$product->getName();
$product_data['description']=$product->getDescription();
$product_data['link']=$product->getProductUrl();
$product_data['image_link']=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).’catalog/product’.$product->getImage();
$product_data['price']=$product->getPrice();
$product_data['brand']=$product->getResource()->getAttribute(’manufacturer’)->getFrontend()->getValue($product);
$product_data['product_type']=”;

//echo ‘Product load: ‘.memory_get_usage(false).’<br>’;
//flush();

//get the product categories
foreach($product->getCategoryIds() as $_categoryId){
$category = Mage::getModel(’catalog/category’)->load($_categoryId);
$product_data['product_type'].=$category->getName().’, ‘;
}
$product_data['product_type']=rtrim($product_data['product_type'],’, ‘);

//echo ‘Category load: ‘.(memory_get_usage(false)).’<br>’;

//sanitize data
foreach($product_data as $k=>$val){
$bad=array(’”‘,”\r\n”,”\n”,”\r”,”\t”);
$good=array(”",” “,” “,” “,”");
$product_data[$k] = ‘”‘.str_replace($bad,$good,$val).’”‘;
}

$feed_line = implode(”\t”, $product_data).”\r\n”;
fwrite($handle, $feed_line);
fflush($handle);

//echo ‘Loop end: ‘.memory_get_usage(false).’<br>’;
//flush();
}

//———————- WRITE THE FEED
fclose($handle);

}
catch(Exception $e){
die($e->getMessage());
}

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