Get simple product id from Configurable Product in Wishlist Cart

Hey Guys,

Today i am going to give the code to get the choosed simple product id from configurable product in Wishlist.

$item object should be instance of this class Mage_Wishlist_Model_Item


Thank you.


Multi Email Validation Class for Magento Prototype JS

Hi All,

Today i am going give the multi email validation class added to the form in magento prototype js. Some of the email fields need multi email features, But they dont know how to validate the multi email address using prototype javascript. Here is the code, Add it to any one of the js or customized js. Then put this “validate-multi-email” class to input fields like other validation classes.

* Add Multi email validation to Default Prototype Validator Class
* return bool
Validation.add('validate-multi-email','Please enter a valid email address. For example',function(emails){
emails = emails.split(',');
for(var i = 0;i<emails.length;i++){
if( Validation.get('validate-email').test(emails[i]) == false){
return false;
return true;

I hope some one can get this thing.

Thank you.

How to assign bundle items to the bundle product programmatically

Today I am going to explain about the Magento Bundle Option, selection and Items with Bundle Product. Some of the guys know about the all types for products in magento. But I will list it out.

1. Simple
2. Virtual
3. Configurable
4. Grouped
5. Bundle
6. Downloadable
Bundle Product can allow simple and virtual product types only. I will show you how the code looks.
Create bundle option programmatically
$bundle – Object instance of Bundle Product

$optionModel =
->setParentId($bundle -> getId())

Store ID should be current store id.

Create bundle selection programmatically.

$values = array(
'option_id' => $ optionModel -> getOptionId(),
'parent_product_id' => $bundle -> getId(),
'product_id' => $curProduct -> getId(),
'position' => 0,
'is_default' => 0,
'selection_price_type' => 0,
'selection_price_value' => 0.0000,
'selection_qty' => 1.0000,
'selection_can_change_qty' => 1

$curProduct – Object instance of simple product or virtual product.

Mage::getModel('bundle/selection') -> setStoreId($curProduct -> getStoreId()) -> setData($values) -> save();

You can use this code with the Model and Controllers. Especially for the Magento Observers Methods.

I hope it helps some of the Magento Developers.

Comments Welcome.

Thanks Guys. Magento Rocks.

Programmatically Add Magento Admin User Roles and Resources

Hi all again,

Today i would like to share, how to add magento admin user roles and resources using code.

/* 4 Roles Creation Default*/
$roles = array('User Role 1','User Role 2','User Role 3','User Role 4');
$roleIds = array();
$resources = explode(',', '__root__,admin/sales,admin/sales/order,admin/sales/order/actions,admin/sales/order/actions/hold,admin/sales/order/actions/creditmemo,admin/sales/order/actions/unhold,admin/sales/order/actions/ship,admin/sales/order/actions/comment,admin/sales/order/actions/invoice,admin/sales/order/actions/capture,admin/sales/order/actions/email,admin/sales/order/actions/view,admin/sales/order/actions/reorder,admin/sales/order/actions/edit,admin/sales/order/actions/review_payment,admin/sales/order/actions/cancel,admin/sales/order/actions/create,admin/dashboard,admin/catalog,admin/catalog/products,admin/cms,admin/cms/page,admin/cms/page/save,admin/system,admin/system/acl,admin/system/acl/users');
foreach($roles as $role){
$col = Mage::getModel('admin/role')->setRoleName($role)->setRoleType('G')->setTreeLevel(1)->save();
if( in_array($role, $enabledRoles) )
$roleIds[] = $col->getRoleId();
$rules = Mage::getModel('admin/rules')->setRoleId($col->getRoleId())->setResources($resources);
$rules = Mage::getModel('admin/resource_rules')->saveRel($rules);

We are created a new user roles(User Role 1, User Role 2, User Role 3 and User Role 4). Then we have to update the Role Resources. I have checked with Magento Version

You can get the Resources list in the backend of the magento roles area.

If any suggestions welcome with comments area below.

Thank you.