Magento: How to enable Magento translation API when using it out of Magento?

November 29, 2012 § Leave a comment

Simple as it can be.


Magento , How to make Optional Zip Code works again in checkout!

November 16, 2012 § Leave a comment

Edit the checkout.xml in the layout folder.
Within the tag, add following code which supposed to be there…

        <reference name="head">
            <block type="core/template" name="optional_zip_countries" as="optional_zip_countries" template="directory/js/optional_zip_countries.phtml" />

Magento: How to Get Quote when Admin Manually Creating Order

October 17, 2011 § 1 Comment

In the frontend store, we normally use


But in the admin panel, if you ever want to access the quote that is created by admin you can use


Magento Deadly Loop

October 16, 2011 § 6 Comments

In Magento, you may see this

Fatal error: Allowedmemory size of 33554432 bytes exhausted (tried to allocate 363 bytes) in....

So it means that you are in a loop, or not enough memory to run the magento.

In my case, I was customizing Magento in a great extend , such as product price calculation and shopping process. Everything is going fine when the currency stays the same, but if you switch currency you will get into a dead loop.

When touching price calculation , you always come across Quote Item Abstract class. However, I oversaw the fact that the class already get the method to get the quote, which I instead use


So it ends up looping over and over again, taking me using log function to track where it is.

Question is therefore raised, why would the Mage::getModel(‘core/session’)->getQuote() will only looping when switching currency? Need to investigate.

Magento & WordPress further thought about integration

October 15, 2011 § Leave a comment

We got no problem here

I think Magento is one of the top e-commerece open source software in the neighborhood. And I always like to move WordPress to be his/her neighbor.

Although they are from different background and code base. Some always manage to getting them to work together, such as integrating Magento’s Code into WordPress one.

Perfect Integration so far, only if you use wordpress for limted usage , such as blogging in e-commerce site.

It’s hard for a client

EI normally provide e-commerce site with full CMS suport, but when it comes to complicated html structured page, it becomes a headache for letting client to edit.

Think about all the CSS, DIVS, Class , ID, do you really want your client to touch that? I dont think it is a good idea.

Let Magento handle Shop stuff, WordPress got your static pages

How do we do that since you cannot put two system into one folder? I manage to make it work in htaccess method.

Step 1. Create a page in WordPress

Step 2. Create a rewrite rule for that particular page in Magento’s htaccess.

Step 3. View it now!

Good Stuff

1. As we know wordpress can be a powerful CMS with it’s clean workflow, Custom Post Type, Custom fields you name it.


1. Potentially affect the SEO searching?

2. Need to create rewrite rule whenever there is changes in pages (Will find a way to accomplish that, maybe making use of magento URL rewrite, a new plugin to WordPress I guess)

3. Two access point both in magento & wordpress, e.g. /about-us and /wordpress/about-us

Magento: How to update configuable attribute by javascript?

June 27, 2011 § 12 Comments

Recently, I am in the case that need to update the configurable attribute/ super attribute by scripting.

Although magento is using prototype.js, but I prefer to work on JQuery :p, but the theory should be the same.
So I got a configurable product, and I would like to have thumbnail image for each associated products. Moreover, clicking the thumbnail should change the color and pricing as well!

This apply to Single/Multiple Configurable Attribute(s) Update


                jQuery('#associated-list a').click(function()
                        // Implement your image swapping here
                        // Please note that your A tag should contain attribute value as well, so we can do a search value and select it in the dropdown
                        // In my case, I have following HTML structure as example <a href="#"><img id="" src="'associated.jpg/" alt="" /></a>

By using the value passed by the A tag , we can select the right one in the dropdown.

                        /* Update Attribute */

		        jQuery('#attribute124 option[value="'+jQuery(this).attr('opt')+'"]').attr('selected','selected');   //selected the matched option

So let’s say attribute124 is your super attribute for the product, let’s locate the element first. However, please note that we will do it in prototype namespace instead of JQuery or native JS referencing.

                        var element=$('attribute124');   //Your super attribute id

Finally call the script below to let Magento Js lib to handle it. What it does is reloading all attribute option and reload the price, so it pretty much does everything.

                        spConfig.configureElement(element);  //This is the one!

I am sure you still a lot to go, so let’s roll!

Magento : Adding Custom Attribute to your Customers!

June 1, 2011 § 13 Comments

There are couple resources you need to go through,

  1. Magento Wiki : Custom Account/Registration Fields (2010-JUNE-25)
  2. Fontis : Know More About Your Customers – Adding Custom Signup Attributes ( 2009-JUN-15)
  3. Stackover : Can no longer add registration fields in Magento (2010- DEC-28)

but the resource is so scattered, so I decided to gather the info here.

First of all, following people shall take the credit : Chris Woodard, AlexSz, phlux0r, bolasevich, Denis Margetic , Brian Wozeniak

So let’s get started, first of all,  backup your database first. Secondly, view the Magento Wiki : Custom Account/Registration Fields – the original post to get the first impression. I would recommend the Fontis : Know More About Your Customers – Adding Custom Signup Attributes as it suggested a non-core modification method to tackle the issue, and a clearer article structure as well.

Please following Fontis : Know More About Your Customers – Adding Custom Signup Attributes until step 4 finished.

For Step 5 we would modify the code a bit to make it magento 1.5 compatible.

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('customer', 'flavour', array(
	'label'		=> 'Ice Cream Flavour',
	'type'		=> 'varchar',
	'input'		=> 'text',
	'visible'	=> true,
	'required'	=> true,
	'position'	=> 1,
/* From Stackover*/
$eavConfig = Mage::getSingleton('eav/config');
$attribute = $eavConfig->getAttribute('customer', 'flavour');
$attribute->setData('used_in_forms', array('adminhtml_customer','customer_account_create','customer_account_edit'));  //enable all action
//$attribute->setData('used_in_forms', array('adminhtml_customer'));  //to make the attribute can be created in backend only
//$attribute->setData('used_in_forms', array('customer_account_create')); //to make the attribute can be created in registration only
//$attribute->setData('used_in_forms', array('customer_account_edit')); // to make the attribute can be edited in the frontend only


Not sure if we can call setData for the attribute in a single go, but it illustrates the idea

After that follow the rest of the steps is fine.

Database Hack

If you already went through the articles before coming to this one. You can always use the database style to sort things out.

From Brian Wozeniak :

Magento 1.5 got a new table called  customer_form_attribute that other articles didnt cover.

INSERT INTO `database`.`customer_form_attribute` (`form_code`, `attribute_id`) VALUES ('adminhtml_customer', 'YOUR_ATTRIBUTE_ID');
INSERT INTO `database`.`customer_form_attribute` (`form_code`, `attribute_id`) VALUES ('customer_account_create', 'YOUR_ATTRIBUTE_ID');
INSERT INTO `database`.`customer_form_attribute` (`form_code`, `attribute_id`) VALUES ('customer_account_edit', 'YOUR_ATTRIBUTE_ID');

It should save some times 😛

Where Am I?

You are currently browsing entries tagged with magento at Nick Wan L.K..