error in SetData method in magento

if you got the problem in setData method in magento. Than follow some step to slove this problem.

Step1:- Check your resource table name in config.xml file,and Clear your cache folder inside /var folder and than check.

Step2:- If step 1 is not working than reindex your project and than check.

Step3:- If step 1 and 2 is not working, than check your table Engine type if it's InnoDB than change it to MyISAM and than check.  
             
Hopefully your problem has been solved.
Note:-  Please take a back up before using this steps.

Clck here To know how to set data through model .

set data through model in magento

if you want to save your data in your custom model through setData(). than follow below process to save your data in custom model.


$values  = array('TABLE_COLUM_NAME_1'=>'TABLE_COLUM_Vaule_1','TABLE_COLUM_NAME_2'=>'TABLE_COLUM_Vaule_2',...);
              
 $tracking = Mage::getModel('YOUR_MODEL_PATH'); // your model object                
 $tracking->setData($values);
 $tracking->save();

Now see your value in your table.
                or
 If you want to show save current value, than use this
 print_r($tracking-getData());

Solve setData error problem in magento Click Here

magento newsletter queue not sending

By default cron is disable .so you need to enable the cron file on your cpanel server. and than you are be able to send the newsletter email in magento . below is the step which tell you how to add cron and solve magento newsletter queue not sending problem.


Step1:- set the cron file on cpanel server.

set this command on your cron file.
php5-cli -f /home/USERNAME/public_html/cron.php

and set the cron time.

Step2:- Change the file in 2 place  By default magento send newsletter subcription mail to 20

reciepient.


/public_html/app/code/core/Mage/Adminhtml/controllers/Newsletter

see this $countOfSubscritions or LINE no. 173 change your reciepient here.
 $countOfSubscritions = 4000; // i set here 4000 reciepient

if you want cron proceed more than 3 quee than change here
$countOfQueue  = 5;
 // i set here 5 Quee proceed



Step3:- see this $countOfSubscritions or LINE no. 62 change your reciepient here.

 $countOfSubscritions = 4000; // i set here 4000 reciepient

and wait for cron execution our newsletter.

custom add newsletter subscribe user in magento

If you want to add programmatically subscriber newsletter user in magento . than do not worry magento blog or magento tutorials will tell you how to add  custom subscriber newsletter user in magento.

Note:- Please take a Data Base Backup before usingthis script.

Step1:- Create a file subscriber.php in root folder.

Step2:- Add below code on subscriber.php file


<?php
require_once("app/Mage.php");
Mage::app();

$subscribers = array('put_your_subscriber_email_1', 'put_your_subscriber_email_2');

foreach ($subscribers as $email) {
  
    Mage::getModel('newsletter/subscriber')->setImportMode(true)->subscribe($email);
// Here we will create subscribe without send confirmation mail to  user


    $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
// Here we reterive genetared subscribe.

  
    $subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
    $subscriber->save(); // Here we saved genetared subscribe.
}
?>


Step3:- clear cache and run this file on your browser
http://yoursite.com/subscribe.php

magento resize product image

magento provide a way to resize the product image . you can simple use product object to resize product image .

<?php

$width = 150;
$height = 100;

 echo Mage::helper('catalog/image')->init($_product, 'image')->resize($width,$height);
// it will give main image name and it resize image 150X100 px.

if you want same height and width image uset this

 echo Mage::helper('catalog/image')->init($_product, 'image')->resize($width);
?>

// image with same height and width.

<img src="<?php echo Mage::helper('catalog/image')->init($_product, 'image')->resize($width);?>"/> // for display image

If you want resize image programmatically or custom see
http://magentoo.blogspot.com/2014/01/magento-resize-category-image.html.

delete all orders and customers magento

I am magento developer and i know when we worked on test site than there is lot of dummy order and customer created on magento website . We used our local DB to live site db when we will go for live magento website. but before we can't delete dummy order or customer record in data base table. now i wrote a very easy script to delete all orders and customers in magento.

One More Important Thing for we don't need to open phpmyadmin for delete all orders and customers in magento

Note :- Please take a Data Base backup before run this script  .

Step1:-  Create a deleteCustomerAndOrder.php file in root folder

Step2:-  paste below code and save the file.


<?php

require_once ("app/Mage.php");
$app = Mage::app('default');

$config  = Mage::getConfig()->getResourceConnectionConfig("default_setup");

$dbinfo = array("host" => $config->host,
            "user" => $config->username,
            "pass" => $config->password,
            "dbname" => $config->dbname
);

$hostname = $dbinfo["host"];
$user = $dbinfo["user"];
$password = $dbinfo["pass"];
$dbname = $dbinfo["dbname"];
$con = mysql_select_db($dbname,mysql_connect($hostname,$user,$password)) ;
$tablePrefix = (string) Mage::getConfig()->getTablePrefix();


// For Delete orders tables

$orderTableName = array (
    'sales_flat_order',
    'sales_flat_order_address',
    'sales_flat_order_grid',
    'sales_flat_order_item',
    'sales_flat_order_status_history',
    'sales_flat_quote',
    'sales_flat_quote_address',
    'sales_flat_quote_address_item',
    'sales_flat_quote_item',
    'sales_flat_quote_item_option',
    'sales_flat_order_payment',
    'sales_flat_quote_payment',
    'sales_flat_shipment',
    'sales_flat_shipment_item',
    'sales_flat_shipment_grid',
    'sales_flat_invoice',
    'sales_flat_invoice_grid',
    'sales_flat_invoice_item',
    'sendfriend_log',
    'tag',
    'tag_relation',
    'tag_summary',
    'wishlist',
    'log_quote',
    'report_event'
    );
mysql_query('SET FOREIGN_KEY_CHECKS=0');
for($ga=0;$ga<=(count($orderTableName)-1);$ga++){

  mysql_query('TRUNCATE  `'.$tablePrefix.$orderTableName[$ga].'`');
  mysql_query('ALTER TABLE  `'.$tablePrefix.$orderTableName[$ga].'` AUTO_INCREMENT=1');


}
// For Delete customer tables

$customerTableName = array (
    'customer_address_entity',
    'customer_address_entity_datetime',
    'customer_address_entity_decimal',
    'customer_address_entity_int',
    'customer_address_entity_text',
    'customer_address_entity_text',
    'customer_address_entity_varchar',
    'customer_entity',
    'customer_entity_datetime',
    'customer_entity_decimal',
    'customer_entity_int',
    'customer_entity_text',
    'customer_entity_varchar',
    'log_customer',
    'log_visitor',
    'log_visitor_info',
    'log_visitor_info',
'eav_entity_store');


for($gau=0;$gau<=(count($customerTableName)-1);$gau++){

  mysql_query('TRUNCATE  `'.$tablePrefix.$customerTableName[$gau].'`');
  mysql_query('ALTER TABLE  `'.$tablePrefix.$customerTableName[$gau].'` AUTO_INCREMENT=1 ');

}

mysql_query('SET FOREIGN_KEY_CHECKS=1');

?>


Step3:- run this script on your browser.
http://yoursiteurl.com/deleteCustomerAndOrder.php

Guys I am always try to learn new things and  post on my blog for our magento developers . Please give me your valuable feedback for encourage me to write more programming solutions.
Thanks
GA





get table prefix in magento

when we will work on Data Base table with custom Query . than it is very important to know what is the table prefix of the magento data base table. This magento blog or magento tutorial will tell you how to get the table Prefix in magento.

In 2 ways you will get data base table prefix.

1) echo $tablePrefix = (string) Mage::getConfig()->getTablePrefix();

2) Go to app/etc/local.xml open local.xml file. and see

                <db>
                <table_prefix><![CDATA['SEE YOUR TABLE PREFIX HERE ']]></table_prefix>
               </db>


get the value of url in magento


If you want to get the value of url in magento or if you want to get parameters id in magento. for front end or backend it works for both conditions.

Get url param vaule for Admin/Backend

This is my dummy url:-
http://magentoo.blogspot.com/index.php/admin/sales_order_invoice/save/order_id/1795/key/b62f67bcaa908cdf54f0d4260d4fa847/
Now if i want fetch the value of url. than i use this method to get the value.
echo $this->getRequest()->getParam('order_id'); // output is 1795


Get url param vaule for Front End

This is my dummy url:-
http://magentoo.blogspot.com/path/action/id/productId/105
echo $this->getRequest()->getParam('productId'); // output is 105

If you want to get All Url Value or Parameter value than use below code.

var_dump($this->getRequest()->getParams());


get all subcategories of parent category magento

By default magento does not provide the subcategory of the parent categories. if you want to show sub categories of parent categories in magento than simple follow below step.


<?php 
$parentCategoryId = 107;
$cat = Mage::getModel('catalog/category')->load($parentCategoryId);
$subcats = $cat->getChildren();

?>

// Get 1 Level sub category of Parent category.

<?php 

foreach(explode(',',$subcats) as $subCatid)
              {
                $_category = Mage::getModel('catalog/category')->load($subCatid);
  if($_category->getIsActive()) {
    echo '<ul><a href="'.$_category->getURL().'" title="View the products for the "'.$_category->getName().'" category">'.$_category->getName().'</a>';
   echo '</ul>';
  }
}

?>

// Get 2 Level sub category of Parent sub category

<?php 
foreach(explode(',',$subcats) as $subCatid)
{
  $_category = Mage::getModel('catalog/category')->load($subCatid);
  if($_category->getIsActive()) {
    echo '<ul><a href="'.$_category->getURL().'" title="View the products for the "'.$_category->getName().'" category">'.$_category->getName().'</a>';
    $sub_cat = Mage::getModel('catalog/category')->load($_category->getId());
    $sub_subcats = $sub_cat->getChildren();
    foreach(explode(',',$sub_subcats) as $sub_subCatid)
    {
          $_sub_category = Mage::getModel('catalog/category')->load($sub_subCatid);
          if($_sub_category->getIsActive()) {
              echo '<li class="sub_cat"><a href="'.$_sub_category->getURL().'" title="View the products for the "'.$_sub_category->getName().'" category">'.$_sub_category->getName().'</a></li>';

 }
     }
     echo '</ul>';
  }
}
?>

// Get 3 Level sub sub category of Parent sub sub category

<?php 
foreach(explode(',',$subcats) as $subCatid)
{
  $_category = Mage::getModel('catalog/category')->load($subCatid);
  if($_category->getIsActive()) {
    echo '<ul><a href="'.$_category->getURL().'" title="View the products for the "'.$_category->getName().'" category">'.$_category->getName().'</a>';
    $sub_cat = Mage::getModel('catalog/category')->load($_category->getId());
    $sub_subcats = $sub_cat->getChildren();
    foreach(explode(',',$sub_subcats) as $sub_subCatid)
    {
          $_sub_category = Mage::getModel('catalog/category')->load($sub_subCatid);
          if($_sub_category->getIsActive()) {
              echo '<li class="sub_cat"><a href="'.$_sub_category->getURL().'" title="View the products for the "'.$_sub_category->getName().'" category">'.$_sub_category->getName().'</a></li>';
              $sub_sub_cat = Mage::getModel('catalog/category')->load($sub_subCatid);
              $sub_sub_subcats = $sub_sub_cat->getChildren();
              foreach(explode(',',$sub_sub_subcats) as $sub_sub_subCatid)
              {
                $_sub_sub_category = Mage::getModel('catalog/category')->load($sub_sub_subCatid);
                if($_sub_sub_category->getIsActive()) {
                    echo '<li class="sub_cat"><a href="'.$_sub_sub_category->getURL().'" title="View the products for the "'.$_sub_sub_category->getName().'" category">'.$_sub_sub_category->getName().'</a></li>';
                }
              }
           }
     }
     echo '</ul>';
  }
}

?>



If you want 4th, 5th,.... or n level category and so on sub categories than simple add this script.
Note:- For n level category please use recursion


<?php 

 // $sub_subCatid this is sub category id . means if you want 4 level than it will take 3 level subcategory Id.

 $sub_sub_cat = Mage::getModel('catalog/category')->load($sub_subCatid);
              $sub_sub_subcats = $sub_sub_cat->getChildren();
              foreach(explode(',',$sub_sub_subcats) as $sub_sub_subCatid)
              {
                $_sub_sub_category = Mage::getModel('catalog/category')->load($sub_sub_subCatid);
                if($_sub_sub_category->getIsActive()) {
                    echo '<li class="sub_cat"><a href="'.$_sub_sub_category->getURL().'" title="View the products for the "'.$_sub_sub_category->getName().'" category">'.$_sub_sub_category->getName().'</a></li>';
                }
              }

?>




get last insert id in magento

In magento you can find last insert id by the following methods .
try below method to find the last insert id in magento.

If you use magento save method than try this to get the last inssert id.

$order->save();
Afetr save method use getId method to get the last insert id in magento 
echo $order->getId(); 


//For custom connection use 
$db_write = Mage::getSingleton('core/resource')->getConnection('core_write');
$sqlQuery = "SELECT * FROM TABLE_NAME ";
$db_write ->query($sqlQuery);
echo $lastInsertId  = $db_write ->fetchOne('SELECT last_insert_id()'); 
                              OR

echo $db_write ->lastInsertId(); // you may also try this.

magento how to select insert update and delete data

It is every important post because if we work on our custom module or extension than each time we need to communicate with our data base table.
If you want custom change on your Data base table in easy way than this post is helpful for you.

//For Select Query
$db_read = Mage::getSingleton('core/resource')->getConnection('core_read');
$tablePrefix = (string) Mage::getConfig()->getTablePrefix();

$sql = 'SELECT COLUMN_NAME FROM `' . $tablePrefix . 'TABLE_NAME`';

$data = $db_read->fetchAllRow($sql); // fetch All row in a table
$data = $db_read->fetchRow($sql); // fetch single row in a table
 print_r($data);  // to see the output of table


// For Insert Query.
 $db_write1 = Mage::getSingleton('core/resource')->getConnection('core_write');
        $tablePrefix = (string) Mage::getConfig()->getTablePrefix();

        $sql = 'INSERT INTO `' . $tablePrefix . 'TABLE_NAME`
VALUES ('COLUMN1_VALUE', 'COLUMN1_VALUE ')';
        $db_write1->query($sql);  


// For Delete Query
 $sql2 = 'DELETE FROM `' . $tablePrefix . 'TABLE_NAME` WHERE TABLE_COLUMN=COLUMN_VALUE';
 $db_write1->query($sql2);        
             

// For Update Query
 $updateQue = 'UPDATE `' . $tablePrefix . 'TABLE_NAME` SET TABLE_COLUMN1=COLUMN_VALUE1, TABLE_COLUMN2=COLUMN_VALUE2 WHERE TABLE_COLUMN=COLUMN_VALUE';
 $db_write1->query($updateQue);


Do you want custom data base connection in magento see here
              

shipping order tracking table name in magento.

If you want to add programmatically order tracking number in magento than you need to use below code.

$orderId = '100001780';
$order1 = Mage::getModel('sales/order')->load($orderId );

$incrementId = $order1->getIncrementId();
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);

if($order->canShip())
{
$itemQty =  $order->getItemsCollection()->count();
$ship = Mage::getModel('sales/service_order', $order)->prepareShipment($itemQty);
$ship = new Mage_Sales_Model_Order_Shipment_Api();
$shipmentId = $ship->create($incrementId);
}

$shipment_collection = Mage::getResourceModel('sales/order_shipment_collection');
$shipment_collection->addAttributeToFilter('order_id', $orderId );

foreach($shipment_collection as $sc) {
    $shipment = Mage::getModel('sales/order_shipment');
    $shipment->load($sc->getId());
    if($shipment->getId() != '') {
        $track = Mage::getModel('sales/order_shipment_track')
                 ->setShipment($shipment)
                 ->setData('title', $type)
                 ->setData('number', $code)
                 ->setData('carrier_code', 'custom')
                 ->setData('order_id', $shipment->getData('order_id'))
                 ->save();
        }
}


For add programatically order tracking number you also need this requirement.
Order Id,
Customer Id
Shipping Address Id
Billing Address Id
Store Id.

you can get all the requirement info for order tracking table here

programmatically reindex magento

If you want to reindex your magento index management programmatically than simple follow below step.

















                                                               

For Product Attributes 
$reindex = Mage::getModel('index/process')->load(1);
$reindex ->reindexAll();

For Product Prices 
$reindex = Mage::getModel('index/process')->load(2);
$reindex ->reindexAll();

For Catalog URL Rewrites                     
$reindex = Mage::getModel('index/process')->load(3);
$reindex ->reindexAll();

For Product Flat Data
$reindex = Mage::getModel('index/process')->load(4);

$reindex ->reindexAll();

For Category Flat Data  
$reindex = Mage::getModel('index/process')->load(5);
$reindex ->reindexAll();

For Category Products
$reindex = Mage::getModel('index/process')->load(6);
$reindex ->reindexAll();

For Catalog Search Index  
$reindex = Mage::getModel('index/process')->load(7);

$reindex ->reindexAll();

For Stock Status 
$reindex = Mage::getModel('index/process')->load(8);
$reindex ->reindexAll();

For Tag Aggregation Data
$reindex = Mage::getModel('index/process')->load(9);
$reindex ->reindexAll();

             OR

if you want all index than use below code.

for ($ga = 1; $ga <= 9; $ga++) {
    $reindex = Mage::getModel('index/process')->load($ga);
    $reindex ->reindexAll();
}

Magento checkout page redirect to cart after filling information in magento.

I f you getting this kind of error in your magento checkout pages than the problem is on your onepagecontroller.php file


Step1:- open your onepagecontroller.php file

Path:- /app/code/core/Mage/Checkout/controllers/onepagecontroller.php

and than go to line No. 194 or search progressAction method

you see this :- 
 public function progressAction()
    {
        if ($this->_expireAjax()) {
            return;
        }
        $this->loadLayout(false);
        $this->renderLayout();
    }

now replace this method to below.

public function progressAction()
    {
       
        $prevStep = $this->getRequest()->getParam('prevStep', false); 
        if ($this->_expireAjax() || !$prevStep) {
            return null;
        }

        $layout = $this->getLayout();
        $update = $layout->getUpdate();
        /* Load the block belonging to the current step*/
        $update->load('checkout_onepage_progress_' . $prevStep);
        $layout->generateXml();
        $layout->generateBlocks();
        $output = $layout->getOutput();
        $this->getResponse()->setBody($output);
        return $output;
    }


Difference between getSingleton and getModel in magento.

It's very important question for interview in magento what is the Difference between getSingleton and getModel in magento.

Mage::getSingleton() will first check if the same class instance exists or not in the memory. If the instance exists then it will return the same object from the memory. and if not than it will create a new instance of the class.
Mage::getSingleton() is faster than Mage::getModel().

example:- $product1 = Mage::getSingleton('catalog/product');

Mage::getModel() will create a new instance of an object each time even such object exists in configuration.

getModel will always return a new instance of the requested model every time.
example:- $product1 = Mage::getSingleton('catalog/product');

how to get module path in magento?


Guys It easy very important to know how to retrieve custom extension or module path in magento. if we know that than we can easily access any module folder path like Helper, controllers, sql , Block ,etc path and it's help us to develop any module.


// Get module etc file path.
Mage::getModuleDir(‘etc’, ‘NameSpace_ModuleName’); // NameSpace_ModuleName => Mage_Core

// Get module sql file path.
Mage::getModuleDir(‘sql’, ‘NameSpace_ModuleName’);

// Get module controllers file path.
Mage::getModuleDir(‘controllers’, ‘NameSpace_ModuleName’);

// Get module Model file path.
Mage::getModuleDir('Model', ‘NameSpace_ModuleName’);

// Get module Block file path.
Mage::getModuleDir('Block', ‘NameSpace_ModuleName’);

// Get module Helper file path.
Mage::getModuleDir('Helper', ‘NameSpace_ModuleName’);

Here Mage::getModuleDir method allows you to get directory path information.

how to set get and unset custom session variable value in Magento.

it is very easy to set get and unset your custom session value in magento.

<?php

// For Set custom session in Magento 
$setSessionVariable =  Mage::getSingleton('core/session')->setYoursessionname('you session value');

// For Get custom session in Magento 
echo $getSessionVariable =  Mage::getSingleton('core/session')->getYoursessionname();

// For Unset custom session value in Magento 
  Mage::getSingleton('core/session')->unsYoursessionname();

 ?>

Magento order status does not show

If you don't find the order status inside Admin >> Sales >> Orders than simple open you phpmyadmin and paste below script on sql user interface.


Step1:- First check if  "sales_order_status" table is empty than paste the below script ....

 INSERT INTO `sales_order_status` (`status`, `label`) VALUES ('canceled', 'Canceled'),
('closed', 'Closed'),
('complete', 'Complete'),
('fraud', 'Suspected Fraud'),
('holded', 'On Hold'),
('payment_review', 'Payment Review'),
('pending', 'Pending'),
('pending_payment', 'Pending Payment'),
('pending_paypal', 'Pending PayPal'),
('processing', 'Processing');

Step2:- It's not necessary but  if  "sales_order_status_state" table is empty than paste the below script ....

INSERT INTO `sales_order_status_state` (`status`, `state`, `is_default`) VALUES
('canceled', 'canceled', 1),
('closed', 'closed', 1),
('complete', 'complete', 1),
('fraud', 'payment_review', 0),
('holded', 'holded', 1),
('payment_review', 'payment_review', 1),
('pending', 'new', 1),
('pending_payment', 'pending_payment', 1),
('processing', 'processing', 1);

Get ship/billing country name from country id magento


<?php 


$countryId = 'SG';                               
echo $countryName = Mage::getModel('directory/country')->load($countryId )->getName(); 

 // output Singapore

 ?>

How to change programmatically order status and add comment in history in magento?

programmatically change order status and add comment in history in magento

<?php

 $orderId = 100000821; // you're order Id
$order = Mage::getModel('sales/order')->load(orderId );
$order->addStatusToHistory($order->getStatus(), 'Put your comment here', false);
                     OR
$order->addStatusToHistory('complete', 'Put your comment here', false);
/* 1st parameter is status,
2nd is comments,
3rd is notified customer. */

$order->save();

Note:- if you want to display status on front end than change this

 $order->addStatusToHistory($order->getStatus(), 'Put your comment here', false)->setIsVisibleOnFront(1); // customer can see new status
?>


Do you want programmatically complete and ship order in magento?


Magento programmatically complete and ship order .


// For both order complete and ship 

<?php $orderId = 100000821; // you're order Id
gaOrderCompShip($orderId); // define function

  function gaOrderCompShip($orderId){   // function definition
        $email = true;
        $trackingNum = '';
        $carrier = 'custom';
        $includeComment = false;
        $comment = "Order Completed And Shipped";

        $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);

     
        $convertor = Mage::getModel('sales/convert_order');
        $shipment = $convertor->toShipment($order);

        foreach ($order->getAllItems() as $orderItem) {
         
            if (!$orderItem->getQtyToShip()) {
                continue;
            }
            if ($orderItem->getIsVirtual()) {
                continue;
            }
            $item = $convertor->itemToShipmentItem($orderItem);
            $qty = $orderItem->getQtyToShip();
            $item->setQty($qty);
            $shipment->addItem($item);
        }

        $carrierTitle = NULL;

        if ($carrier == 'custom') {
            $carrierTitle = 'courier Service name';
        }
        $data = array();
        $data['carrier_code'] = $carrier;
        $data['title'] = $carrierTitle;
        $data['number'] = $trackingNum;

        $track = Mage::getModel('sales/order_shipment_track')->addData($data);
        $shipment->addTrack($track);

        $shipment->register();
        $shipment->addComment($comment, $email && $includeComment);
        $shipment->setEmailSent(true);
        $shipment->getOrder()->setIsInProcess(true);

        $transactionSave = Mage::getModel('core/resource_transaction')
            ->addObject($shipment)
            ->addObject($shipment->getOrder())
            ->save();

        $shipment->sendEmail($email, ($includeComment ? $comment : ''));
        $order->setStatus('Complete');
        $order->addStatusToHistory($order->getStatus(), $comment, false);
     
        $shipment->save();
} ?>


do you want change programmatically order status and add comment in history in magento?




how to add multiple currency in magento ?

If you think show multiple currency in magento is difficult task. than you're wrong thinking . follow below step and see multiple currency works..

GO to Admin >> System >> Configuration >> Currency Setup (click left tab) and select multiple currency in "Allowed Currencies" using ctrl key and save this setting.










Now Go to  System >> Manage Currency >> Rates and fill custom price on text or if you want market price than click on Import button only and save


Is it possible to create a promo code specifically for certain products in magento?

Yes, you can create a promo code specifically for certain products in magento.

Login in Backend >> Promotions -> Shopping Cart Price Rules >> Press "Add New Rule" button and fill out all info.






















Now click on left "condition" Tab and than select "product attribute combination" After that select "SKU" on dropdown








Now fill out all left tab and Save the rule. and check it on frontend for particular product.
NOTE:- if you can't find SKU on drop down than follow below step to see the SKU on product attribute combination 
Go to Catalog >> Attributes >> click Manage Attribute >> search sku on Attribute code and click on it .  than find "Use for Promo Rule Conditions" and set this YES

how to get store config value in Magento?


<?php echo Mage::getStoreConfig('isis/isis_order_setting/enable_isis'); ?>

In 2 ways you can find the path of store config value .

1) open Database and see the "core_config_data" table and see the "path" column. find you're module here. and use path value.

2)  open System.xml file and find section, groups and fields values.
you can find this file on app/code/<pool>(community,local,core)/Namespace/Model Name/etc/system.xml
 this is my system.xml file path app/code/local/Magentoo/Isis/etc/system.xml

Below is our dummy system.xml file
<config>
   <sections>
      <isis translate="label">
<groups>
            <isis_order_setting translate="label">
  <fields>
                  <enable_isis translate="label comment">
 </enable_isis>
</fields>
           </isis_order_setting>
         </groups>
     </isis>
  </sections>
</config>

Magento System requirement before install.

When ever you think to install a new Magento eCommerce cms in you're localhost. please check you're system meet below requirement .

PHP:- 5.0 Above version support

enable this things on you're php ini file before install :

    PDO_MySQL  
    mcrypt
    hash
    GD
    DOM
    icony
    curl
    Safe_mode    off
    Memory_limit preferably 512MB

MySQL:- CE (all versions): MySQL 4.1.20 or newer
OS:- Linux x86, x86-64
Web Server(Apache):- Apache 2.0.x or Above
Browsers Support:- Google Chrome 7 version and above
Mozilla Firefox 3.5 version and above
Apple Safari 5 version and above
Mac only
IE-7 or above version

Hosting:-
php5 or above
override options for .htaccess file

For more details visit:-
http://magento.com/resources/system-requirements

Magento Improved horizontal checkout css steps

If you want to change Magento  default vertically checkout step to Magento horizontal checkout step
. than don't worry simple follow below step.

Step1:- open you're styles.css file
Path:- skin\frontend\default\<theme name>\css\styles.css

Step2:- At the end of file paste the below code

/*********  Start Magento Improved horizontal One Page Checkout css **********/

.block-progress .block-title { background:none; margin:0 0 34px; padding:0; }
.checkout-onepage-index .col-main { padding:0; border:0; }
.checkout-onepage-index .page-title { padding-right:40px; width:auto; }
.checkout-onepage-index .page-title h1 { background:none; padding:0; }

.opc { position:relative; overflow:hidden; height:970px; padding-top:20px; text-align:center; border:1px solid #BBAFA0; background:#F9F3E3; }
.opc .buttons-set { margin:15px 0 0; opacity:1!important; }
.opc .buttons-set p.required { margin:0; padding:0 0 10px; }
.opc .buttons-set .back-link { display:none; }
.opc .buttons-set .please-wait { position:absolute; z-index:99; top:30%; left:50%; margin:-80px 0 0 -146px; border:5px solid #f3b66f; font-size:12px; background:#fff; padding:30px; white-space:nowrap; border:1px solid #c0c0c0; -moz-border-radius:6px; -webkit-border-radius:6px; border-radius:6px; -moz-box-shadow:1px 1px 2px rgba(0,0,0,0.2); -webkit-box-shadow:0 0 50px rgba(0,0,0,0.2); box-shadow:0 0 50px rgba(0,0,0,0.2); }
.opc .buttons-set a { color:#214D90; }
.opc .ul { list-style:disc outside; padding-left:18px; }
.opc li.section { display:inline; }
.opc .step-title,.opc .allow .step-title { border:1px solid #F9F3E3; height:69px }
.opc .step { padding:30px 20px; position:absolute; border:0; top:110px; left:0; z-index:1; background:#FBFAF6; width:605px; height:900px; border-bottom:1px dotted #ccc; border:none; width:643px; text-align:left; border-top:1px solid #BBAFA0; }
.opc .step-title .number,.opc .allow .step-title .number,.opc .active .step-title .number { float:none; display:block; margin:0 auto; margin-bottom:10px; }
.opc .step-title { position:relative; float:left; text-align:center; padding:15px 11px 0; margin-left:-1px; background:none; }
.opc .step-title a { display:none; }
.opc .step-title .number { background:#ccc; color:#fff; width:30px; height:30px; line-height:30px; -moz-border-radius:20px; -webkit-border-radius:20px; border-radius:20px; margin-bottom:10px; padding:0; border:0; }
.opc .step-title h2 { font-size:12px; color:#bbb; clear:both; }
.opc .allow .step-title { cursor:pointer; background:none; }
.opc .allow .step-title .number { background:#000; color:#fff; }
.opc .allow .step-title h2 { color:#000; }
.opc .active .step-title { color:#ef0606; cursor:default; border:1px solid #BBAFA0; border-bottom:1px solid #FBFAF6; z-index:2; background:#FBFAF6 url(../images/bkg_checkout.gif) 0 0 repeat-x; }
.opc .active .step-title .number { background:#F18200; border-color:#fff; color:#fff; }
.opc .active .step-title h2 { color:#F18200; }
.opc .step-title h2,.opc .allow .step-title h2,.opc .active .step-title h2 { width:100%; text-align:center; }
.opc .step-title { width:16%; }
.opc .form-list .field,.opc .form-list .wide { }
.opc .form-list li fieldset { margin-bottom:40px; }
.opc .form-list label { float:left; width:220px; text-align:right; padding:4px 0 0; }
.opc .form-list label.required em { float:none; position:relative; right:4px; }
.opc .form-list li.fields { margin:0; }
.opc .form-list div.fields { width:100%; overflow:hidden; margin:0 0 8px; }
.opc .form-list .wide,.opc .form-list li.fields .field { width:645px; margin:0 0 8px; }
.opc .form-list li.wide .input-box,.opc .form-list .input-box { clear:none; float:right; margin-right:140px; width:260px; }
.opc .form-list li.wide select { width:390px; }
.opc .form-list li.wide input.input-text { width:254px; }
.opc .form-list .control input { margin:8px 0 0 25px; }
.opc .form-list li.control label { float:left; }
.opc form .form-list li.wide { margin-bottom:8px; }
.opc form .address-select { margin:8px 0 40px; }

.opc:first-of-type .step{-webkit-transition: all 0.5s ease-in-out;-moz-transition: all 0.5s ease-in-out;-o-transition: all 0.5s ease-in-out;-webkit-transition: all 0.5s ease-in-out;transition: all 0.5s ease-in-out;}
.opc:first-of-type .step[style*='display:none;'],
.opc:first-of-type .step[style*='display: none;']{display:block !important;}
.opc:first-of-type .section .step{left: 100%;}
.opc:first-of-type .allow .step{left: -100%;}
.opc:first-of-type .active .step{left:0;}
.opc:first-of-type li:last-child .step-title a{width:50%}
.opc:first-of-type li:first-child .step-title a{width:50%;left:50%}

#opc-login p.required { display:none; }
#opc-login h3 { margin-bottom:18px; }
#opc-login .col-2 { float:left; }
#opc-login .col-2 form fieldset h4 { display:none; }
#opc-login .col-2 { display:block; width:300px; }
#opc-login .col-2 fieldset { width:300px; }
#opc-login .col-2 .input-box { width:188px; margin:0; float:left; }
#opc-login .col-2 .input-text { width:182px; }
#opc-login .col-2 .form-list label { text-align:left; }
#opc-login .col-2 .form-list label { width:110px; }
#opc-login .form-list li.control label { float:none; }
#opc-login .form-list li.control input { margin:0 8px 0 0; }
#opc-login .col-1 { float:right; }
#opc-login .col-1 { width:290px; }
#opc-login .col-1 h4,#opc-login .col-1 .ul { display:none; }
#checkout-step-review.step { width:645px; }

#opc-review .step { padding:30px 20px; border-top:1px solid #BBAFA0; }
#opc-review .product-name { font-weight:bold; color:#0a263c; }
#opc-review .item-options { margin:5px 0 0; }
#opc-review .buttons-set { padding:20px 0; border:0; }
#opc-review .buttons-set p { margin:0; line-height:40px; }
#opc-review .buttons-set .please-wait { height:40px; line-height:40px; }
#opc-shipping_method .buttons-set { border-top:1px solid #E4E4E4; }

/*********  End Magento Improved horizontal One Page Checkout css **********/

Step3:- Save this file and delete cache folder inside var/ directory. Now see you're checkout step.


Remove Html tags in magento

If you want to remove <br/> tags from product description page .
than Goto

/app/design/frontend/base/default/template/catalog/product/view/description.phtml
copy description file in you're local theme (template).
app/design/frontend/default/<theme name>/template/catalog/product/view/description.phtml
open local folder description.phtml file and delete "nl2br" tag .

<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), nl2br($this->getProduct()->getDescription()), 'description') ?>

After Remove nl2br tag . the code is

<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $this->getProduct()->getDescription(), 'description') ?> 

If you want to remove html tag form other place than use this
strip_tags()          // for PHP
$this->stripTags // For Magento

Get order payment method info in magento?.

<?php
$orderId = '10000015';
$order = Mage::getModel('sales/order')->load($orderId);
// For getting Order Payment Info.

echo '<pre>';
      print_r($order->getPayment());
//  Show current order payment instance.

 print_r($order->getPayment()->getMethodInstance());
//  Show current order payment method instance.

 print_r($order->getPayment()->getMethodInstance()->getTitle());
//  Show current order payment Title only.

      echo '</pre>';

?>


Magento resize category image

<?php
               $_file_name = $cat->getThumbnail(); // Here $cat is category data array                
$_media_dir = Mage::getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS;
                $cache_dir = $_media_dir . 'resize' . DS; // Here i create a resize folder. for upload new category image
                       
if (file_exists($cache_dir . $_file_name)) {
                             $catImg =Mage::getBaseUrl('media') .  'catalog' . DS . 'category' . DS . 'resize' . DS . $_file_name;
                         } elseif (file_exists($_media_dir . $_file_name)) {
                             if (!is_dir($cache_dir)) {
                                 mkdir($cache_dir);
                             }

                             $_image = new Varien_Image($_media_dir . $_file_name);
                             $_image->constrainOnly(true);
                             $_image->keepAspectRatio(false);
                             $_image->keepFrame(false);
                             $_image->keepTransparency(true);
                             $_image->resize(224, 174); // change image height, width
                             $_image->save($cache_dir . $_file_name);
                             $catImg = Mage::getBaseUrl('media') . 'catalog' . DS . 'category' . DS . 'resize' . DS . $_file_name;
                         }
 echo  $catImg ; // display resize category thumbnail imagename
 ?>

<img src="<?php echo $catImg;  ?>"  />