Archive

Archive for the ‘magento’ Category

Magento Notes — Bulk update of Product tax class

July 26th, 2010

Just as we are ready to go live on one of my client’s web site, we started to test the tax rules just to make sure that taxes would apply properly.  To our surprise, it DIDN’T!

After verifying the tax classes and customer groups, I got lucky by noticing that for some odd reason, all of my products had their tax class set to NONE instead of TAXABLE GOODS, WTF!! Since there were over 3000 products, I figure using the admin page to do a bulk update of the attribute will one way or another just time out.

After some digging, I have found a way to directly modify the tax class field in phpmyadmin, below is the script that I used to make this sweeping change.  Seems to work, but just make sure a backup is done before running this:

UPDATE `catalog_product_entity_int` SET `value` = ‘2′ WHERE `catalog_product_entity_int`.`attribute_id` =81;

Attribute_ID 81 is the tax class flag for the products. Whereas value of 2 indicates “Taxable Goods”, if you want to set as downloadable goods, this is set to “4″

blog posting, magento , ,

Magento Notes - Add gift wrap service at checkout

July 8th, 2010

Searched high and low for a way to add gift-wrap service, and came across an excellent solution on the Magento forum. Here’s the link:

http://www.magentocommerce.com/boards/viewthread/176424/P0/

blog posting, magento, wordpress ,

Magento Notes — Customizing the RSS Feed that Magento Outputs

November 11th, 2009

One of the marketing strategy employed by many e-commerce sits is to provide product feeds (RSS) to have them be displayed in an affiliate or partner blog or content-driven web sites.  I’ve recently came across this need to do just that and what I have found is that the default Magento RSS feed is clunky and display the entire product description as part of the feed items.  The way to customize the output is go to into the following file (NOTE: this workaround requires modify Magento core file, which may become a hassle and you update your Magento installation):

\app\code\core\Mage\Rss\Block\Catalog\

under the above folder, you will see different files (category.php, new.php, tag.php, etc.) each file controls the output of each type of RSS feed Magento has built in by default. So if you want to modify the RSS feed format for your products in a certain category you would modify the category.php file. For me, i was looking at syndicating my new products, so I modified new.php file.

When opening up the new.php file, scroll down to approximately line 99-104, under the public function addNewItemXmlCallback($args) is where the RSS feed content is formatted, so you can simply move around the html table and or select to replace the product description with the short description, etc.  For me, I simply removed the long description and kept the pricing, product image and the product title. Below is my revised output code snippet:

$description = ‘<table><tr>’.
‘<td><a href=”‘.$product->getProductUrl().’”><img src=”‘. $this->helper(’catalog/image’)->init($product, ‘thumbnail’)->resize(75, 75) .’” border=”0″ align=”left” height=”75″ width=”75″></a><br>Price:’.Mage::helper(’core’)->currency($product->getPrice()).
($product->getPrice() != $final_price  ? ‘ Special Price:’. Mage::helper(’core’)->currency($final_price) : ”).
‘</td>’.
‘</tr></table>’;

and the output looks like the following when it gets syndicated to a content driven site, you see the RSS feed of the products at the right side of the screen:

http://links.chosen29.com - this is a PLIGG-driven bookmarking web site similar to Digg.com

http://links.chosen29.com - this is a PLIGG-driven bookmarking web site similar to Digg.com

The RSS feed from Magento is fed through Google’s Feedburner and then syndicated thereafter, primarily for the purpose of better exposure and trackability.

Lastly, here’s a shameless plug, please visit my new web site at Chosen29.com

blog posting, e-commerce, magento ,

Magento Notes — Add Address Field to Customer Export

October 2nd, 2009

Recently came across something weird when a client asked how come when they are in the admin interface: Customers -> Manage Customers, and then they click on “Export to CSV” the Address field isn’t export.  I don’t understand the logic of why the address is omitted.

Funny thing is that the fix to include the Address field isn’t straightforward and NOBODY ran into this problem, as there were no postings on Magento forum nor google search…I was surprised.  Anyways, what happens when users click on “Export to CSV” is essentially what you see in the grid below it is what gets exported, so the fix is to include the Address field in grid.  The file to modify is a core file, so you would have to update this when you do a Magento upgrade. Here’s the path to the file:

app/code/core/Mage/Adminhtml/Block/Customer/grid.php

Near line 45 you will find the below block of code, you will add the line that is in bold:

protected function _prepareCollection()
{
$collection = Mage::getResourceModel(’customer/customer_collection’)
->addNameToSelect()
->addAttributeToSelect(’email’)
->addAttributeToSelect(’created_at’)
->addAttributeToSelect(’group_id’)
->joinAttribute(’billing_street’, ‘customer_address/street’, ‘default_billing’, null, ‘left’)
->joinAttribute(’billing_postcode’, ‘customer_address/postcode’, ‘default_billing’, null, ‘left’)
->joinAttribute(’billing_city’, ‘customer_address/city’, ‘default_billing’, null, ‘left’)
->joinAttribute(’billing_telephone’, ‘customer_address/telephone’, ‘default_billing’, null, ‘left’)
->joinAttribute(’billing_region’, ‘customer_address/region’, ‘default_billing’, null, ‘left’)
->joinAttribute(’billing_country_id’, ‘customer_address/country_id’, ‘default_billing’, null, ‘left’);

$this->setCollection($collection);

return parent::_prepareCollection();
}

Then near line 103 add a the code below in bold:

$this->addColumn(’Telephone’, array(
‘header’    => Mage::helper(’customer’)->__(’Telephone’),
‘width’     => ‘100′,
‘index’     => ‘billing_telephone’
));
$this->addColumn(’billing_address’, array(
‘header’    => Mage::helper(’customer’)->__(’Address’),
‘width’     => ‘150′,
‘index’     => ‘billing_street’
));

Now you should see Address field displayed in the grid and when export is clicked it would export the field accordingly.

magento, technical notes

Magento Notes — Adding Company Name, Address, Phone in Registration Form

August 26th, 2009

This is a simple yet practical fix that, for some reason, Magento never got around to enabling upto Magento Version 1.3.2.3.

Basically by default the Magento registration form only requires you to enter First Name, Last Name, Email and VAT/Tax Number, but that in a real world scenario is not practical and not enough for business owners to follow up on.  Base on looking into the code here: app/design/frontend/default/blue/template/customer/form/register.phtml, we know Magento has every intention of adding additional fields, just they haven’t been enabled.

By following the fix here, you can reveal the additional fields. Essentially you just have to comment out a IF-Then statement to reveal the proper form fields. Below is the result:

blog posting, magento, technical notes , , , ,

Tickon.com for Sale

July 28th, 2009

We are selling our e-commerce web site: www.tickon.com.

Why are we selling? Becuase we have more projects to work on, and we simply don’t have time to operate the business side of the e-commerce site, and that includes marketing the site, fulfilling orders, finding new products, and most importantly — providing excellent customer service.

How much are you selling for? Make your best offer and we will consider every bid.  We just want the site to be in good hands; someone willing to put in the effort to market the site.

What’s included? We will include the domain name, help you move to your desired web hosting company? or we will host it for you for a small monthly fee. You will also have the code (the site runs on Magento 1.2.1), and the existing database, and you will be hooked up with the product supplier for future order fulfilment (they are a great supplier to work with!!).

For more information email me at jerry at casualcommerce dot com

blog posting, e-commerce, magento , , ,

Magento Notes — Default sorting is not logical

May 19th, 2009

Now that I have my e-commerce site, tickon.com, running for a while (3-months), I am back at it adding more products to link to my affiliate partners (this is a new experiment on this web site).

As I started to add new products, I noticed that newest items are added to the last page of the category that it was assigned to…not a very smart implementatio in my opinon. Did some googling and found a fix here:

http://www.magentocommerce.com/boards/viewthread/1176/

Essentially what needs to be done is to fix the file: app/code/core/Mage/Catalog/Block/Product/List/toolbar.php

near line 47, I changed the original code to the following:

$this->_availableOrder = array(
‘entity_id’ => $this->__(’Newest’),
‘name’      => $this->__(’Name’),
‘price’     => $this->__(’Price’)
);

The first item listed will be the default sort filter, the default was “best value”…which didn’t make a lot of sense to me.

Second item to fix up is in the same file, but you go to line 108 (approx.) and modify the highlighted part as below:

public function getCurrentDirection()
{
if ($dir = (string) $this->getRequest()->getParam($this->getDirectionVarName())) {
$dir = strtolower($dir);
if (in_array($dir, array(’asc’, ‘desc’))) {
return $dir;
}
}
return ‘desc‘;

default is asc, but you need to change it to descending so that it sorts from newest id first.

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

Magento Notes — How to reference custom product attributes

April 6th, 2009

One thing that I find very useful as I start to seriously customize the product details page for my B2B client is the ability to create custom attributes.  But it took me forever to figure out how to call them from the view.phtml which is the file you are most likely gonna be modifying as well as list.phtml, both located in: app\design\frontend\default\blue\template\catalog\product

If you have created a custom attribute of type dropdown list or other multi-select list, you will reference the attribute using:

<?php echo $_product->getAttributeText(’attribute_code‘) ?>

where the attribute_code is what you have setup in the admin interface when creating this custom attribute. For textboxes and text area data types, you will call these a little differently using:

<?php echo $_product->getAttributeName() ?>

where getAttributeName is a variable of “get” + “attribute_code” where if you have underscores (_) or dashes (-), they are removed, and each word’s first character is capitalized.  So for example, if you have an attribue code called: shirt_size, your call would be:

<?php echo $_product->getShirtSize() ?>

Note that it is case-sensitive.

The link here has additional information on this topic.

magento, technical notes ,

Magento 1.3 Release

April 1st, 2009

Came across the news release on Magento’s blog with the release of Magento 1.3 Download here

One of the most coveted feature is now available: Customer Upload of Files.  I can see many uses for this feature, and I will definitely take advantage of this feature in my next project. But I won’t actually touch 1.3 for awhile, or atleast after I hear other people’s feedback on this update.

blog posting, e-commerce, magento, news ,

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