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

Can we escape from the isolated internet?

June 29, 2011 § Leave a comment

I want to share with you not the code, but to the internet we use everyday.

It may not connect to the world as we imagine. Google, Yahoo and Facebook all these internet grants all control their results. Different people search different things.

We may find things we are looking for among them, but what are the other options?

We have to start questioning ourselves, are we searching or are we being controlled?

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 😛

Doctrine Command Line Tool Error : warning unexpected character in input ‘\’ ascii 92

January 16, 2011 § Leave a comment

warning unexpected character in input ‘\’ ascii 92 will only appear if PHP version is under 5.3

So please do confirm you are under PHP 5.3 environment.

My XAMPP / MAMP is running PHP 5.3 still cannot get this error away

Answer: Because you are still using PHP 5.2, why? It is because Terminal may take its own PHP version instead of your PHP version.

1. Check your phpinfo by creating a testing script

2. In terminal, type ‘php test.php’, it should show PHP version from the top

3. If it is 5.2, then please type “export PATH=/Applications/XAMPP/xamppfiles/bin/php:$PATH”
“export PATH=/Applications/XAMPP/xamppfiles/bin:$PATH”
(using XAMPP as example)

After these steps should ensure you got the right environment to work on. Cheers~

Special Characters in email subject – PHP

December 6, 2010 § Leave a comment

I am sure there is a lot of articles talking about how to handle special character in email subject.

Lately, I need to add French word like “è” such special character in the email subject.

So I googled it, generally there are few things to look at.

1. Use “=?UTF-8?B?”.base64_encode($your_subject).”?=”

2. Make sure your source is UTF-8, such as your script, your database source

3. Use UTF-8 encoding email library such as Swiftmailer , this is the rock star in open source email, unbeatable.

And that’s all about it.

Oh you can also use it in the `From Name` like Josè <> !

Uploadify HTTP Error 412

November 3, 2010 § 2 Comments

Few days ago I encounter the HTTP error 412.

It’s so weird that I uploaded few JPG files without error, except one which is JPG as well.

After I exported to PNG , it works again.

Got tips from a friend as following.

This is caused by mod_security, which is used for blocking spam , but sometimes it got triggered by accident.

For quick and dirty fix, you could  edit your .htaccess. and add following

SecFilterEngine Off
SecFilterScanPOST Off

And if you are interested about the issue, you could look at following link

In summary, the mod_security will determine if the request is spam by looking at the URI / POST.

For URI like “-poker” or “-sex”, mod_security will be triggered and blocked visiter to execute such action.

In long one, one should not disable the mod_security as it provides minimal protection from spam. Starting looking at the URI or POST that might trigger the mod_security and add following lines.

In our case

SecFilterEngine On
SecFilterSelective "POST_PAYLOAD" "KEY WORD" "allow,nolog"

replacing the keyword with the one you think may trigger the mod_security. I think this is a better practice at last.