Wednesday, June 1, 2011

Most Importants Links of Magento:

Most Importants Links of Magento:




Customer Activation:


Brief Description

This small extension makes it impossible for a customer to log in to magento until the account has been activated in the adminhtml interfac


URL: https://www.magentocommerce.com/magento-connect/vinai/extension/489/customer-activation





Custom Module With Custom Database Table


Thanks to member Danieln for creating this PHP script to automatically create a base module given a Namespace and Module.


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



skip shipping method from onepage checkout :=>In Magento

skip shipping method from onepage checkout :=>In Magento

step 1: app/code/core/Mage/Checkout/Block/Onepage/Onepage.php

change the line
$stepCodes = array('billing', 'shipping', 'shipping_method', 'payment', 'review');
with
$stepCodes = array('billing', 'payment', 'review');

step2 : app/code/core/mage/checkout/controller/Onepagecontrollers.php

protected $_sectionUpdateFunctions = array(
'payment-method' => '_getPaymentMethodsHtml',
'shpping-method' => '_getShippingMeghtoHtml',
'review' => '_getReviewHtml',
);

to

protected $_sectionUpdateFunctions = array(
'payment-method' => '_getPaymentMethodsHtml',
'review' => '_getReviewHtml',
);


Step 3. In same page

------------------------Change this code--------------------------
public function saveBillingAction()
{
if ($this->_expireAjax()) {
return;
}
if ($this->getRequest()->isPost()) {
$postData = $this->getRequest()->getPost('billing', array());
$data = $this->_filterPostData($postData);
$customerAddressId = $this->getRequest()->getPost('billing_address_id', false);

if (isset($data['email'])) {
$data['email'] = trim($data['email']);
}
$result = $this->getOnepage()->saveBilling($data, $customerAddressId);

if (!isset($result['error'])) {
/* check quote for virtual */
if ($this->getOnepage()->getQuote()->isVirtual()) {
$result['goto_section'] = 'payment';
$result['update_section'] = array(
'name' => 'payment-method',
'html' => $this->_getPaymentMethodsHtml()
);
} elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
$result['goto_section'] = 'shipping_method';
$result['update_section'] = array(
'name' => 'shipping-method',
'html' => $this->_getShippingMethodsHtml()
);

$result['allow_sections'] = array('shipping');
$result['duplicateBillingInfo'] = 'true';
} else {
$result['goto_section'] = 'shipping';
}
}

$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
-----------------------With-----------------------
public function saveBillingAction()
{
if ($this->_expireAjax()) {
return;
}
if ($this->getRequest()->isPost()) {
$postData = $this->getRequest()->getPost('billing', array());
$data = $this->_filterPostData($postData);
$customerAddressId = $this->getRequest()->getPost('billing_address_id', false);

if (isset($data['email'])) {
$data['email'] = trim($data['email']);
}
$result = $this->getOnepage()->saveBilling($data, $customerAddressId);

if (!isset($result['error'])) {
/* check quote for virtual */
if ($this->getOnepage()->getQuote()->isVirtual()) {
$result['goto_section'] = 'payment';
$result['update_section'] = array(
'name' => 'payment-method',
'html' => $this->_getPaymentMethodsHtml()
);
} else {
$result['goto_section'] = 'payment';
}
}

$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}



Step 4. app/code/core/Mage/Sales/Model/Service/Quote.php

-------------------------Change this code ----------------
protected function _validate()
{
$helper = Mage::helper('sales');
if (!$this->getQuote()->isVirtual()) {
$address = $this->getQuote()->getShippingAddress();
$addressValidation = $address->validate();
if ($addressValidation !== true) {
Mage::throwException(
$helper->__('Please check shipping address information. %s', implode(' ', $addressValidation))
);
}
$method= $address->getShippingMethod();
$rate = $address->getShippingRateByCode($method);*/
if (!$this->getQuote()->isVirtual() && (!$method || !$rate)) {
Mage::throwException($helper->__('Please specify a shipping method.'));
}
}


---------------------------With------------------------
protected function _validate()
{
$helper = Mage::helper('sales');
if (!$this->getQuote()->isVirtual()) {
$address = $this->getQuote()->getShippingAddress();
$addressValidation = $address->validate();
}



Step: 5. app/design/frontend/base/default/template/checkout/onepage/billing.phtml

remove the code of radio button : line no 173

Step: 6. app/design/frontend/base/default/template/checkout/onepage/progress.phtml
remove the code for hide shipping method block: Your Checkout Progress

Step: 7.

Change Order tamplate which you have created
OR
Change from here:
app/locale/en_US/template/email/sales/order_new.html

Remove following code:















Shipping Information: Shipping Method:

{{var order.getShippingAddress().format('html')}}
 
 
{{var order.getShippingDescription()}}
 


>>>>>>>>>>>>>>>>>>OR<<<<<<<<<<<<<<<<<<<<<<<<<
Refer Following url:
http://www.magentocommerce.com/boards/viewthread/76049/


Thanks

Issue: Mail is not going in Correct Format when you use different OS.

Problem: Mail is not going in Correct Format when you use different OS.
Solution:


if (strtoupper(substr(PHP_OS,0,3)=='WIN')) {
$eol="\r\n";
} elseif (strtoupper(substr(PHP_OS,0,3)=='MAC')) {
$eol="\r";
} else {
$eol="\n";
}
# Common Headers
$headers .= 'From: Jonny '.$eol;
$headers .= 'Reply-To: Jonny '.$eol;
$headers .= 'Return-Path: Jonny '.$eol; // these two to set reply address
$headers .= "Message-ID:<".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol;


OR
Please refer this url:
http://php.net/manual/en/ref.mail.php


$headers = "From: {$email}";

Thursday, January 20, 2011

Connecting to a Remote Oracle Database with PHP and the Oracle Instant Client

Connecting to a remote Oracle database via PHP on Windows is relatively straightforward. Keep in mind I'm stating that after having gone through the process a couple of times.

First off, you'll need to download the Oracle Instant Client. I downloaded it directly from this page after agreeing to some licensing mumbo jumbo. I went with the Instant Client Package - Basic Lite package since I wasn't interested in non-English error messages and the like. I'd also recommend downloading Instant Client Package - SQL*Plus from that same location, because it's a good way to do a sanity check before you move on to the PHP-specific stuff.

Once you've downloaded those packages, unzip them both to the same directory. I chose C:\Program Files\Oracle Instant Client, so I'll be referring to that location for the remainder of these instructions. When you're done, you should\ have a series of .dll files and a few others, along with the SQL*Plus executable, sqlplus.exe. Next thing you'll want to do is create a new file in that same directory named tnsnames.ora. This is an important configuration file that allows you to create kind of a local reference to a remote Oracle database server. Paste the following into that new file:

RDF = (DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = REMOTESERVER)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = LOCALNAME)
)
)

Where REMOTESERVER is the name of the remote server that has Oracle running on it and LOCALNAME is the local name by which you wish to refer to the connection with that server.

This is where the sanity check with SQL*Plus comes in. Open up a Windows command prompt and change to the directory where you unzipped all your Oracle Instant Client files (e.g. C:\Program Files\Oracle Instant Client). From there, run the following command to test your setup so far:

sqlplus username/password@LOCALNAME

Where username is a user account with access to the remote Oracle server, password is the password for that user account, and LOCALNAME is, you guessed it, the local name by which you've chosen to refer to the connection with the remote server. If you're presented with an SQL> prompt at this point, you're good to go, knowing that your Oracle connection is in a good state and you're ready to move on to the PHP setup.

To get your PHP scripts talking to the remote Oracle server, you'll use the oci_connect() function. Before you can do that, though, you'll need to enable support for the oci8 module. To do this, open up your php.ini file and uncomment (remove the leading semicolon from) the line that reads:

;extension=php_oci8.dll

Once you've done that, you'll need to update your computer's environment variables. First, modify your PATH environment variable so that it has a reference to C:\Program Files\Oracle Instant Client. Then, create a new environment variable named TNS_ADMIN that points to the same directory. This environment variable ensures that PHP will be able to find your tnsnames.ora file when it tries to connect via oci_connect(), so it's important. Once you've set these environment variables correctly, it's probably a good idea to restart the machine your web server is running on. I had to do this before the changes would register (you can easily check your path if you make a call to phpinfo() from a script). However, it might be possible to only restart Apache (or whatever web server you're running), so you might give that a shot first just to see if you're lucky.

At this point, you should be ready to start connecting to the remote Oracle server from your PHP scripts. To make sure, you can run the following script, keeping in mind that the settings should match what you've set in the steps above:

// try connecting to the database
$conn = oci_connect('username', 'password', 'LOCALNAME');

// check for any errors
if (!$conn)
{
$e = oci_error();
print htmlentities($e['message']);
exit;
}

// else there weren't any errors
else
{
echo 'I am an Oracle mack daddy.';
}

This is all off the top of my head after going through this process a couple times. If your mileage varies and you think I missed something, be sure to leave a comment and I'll see if I can't correct any mistakes.