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 😛

Where Am I?

You are currently viewing the archives for June, 2011 at Nick Wan L.K..