Posts

Showing posts from 2010

Avoid duplicate content on Google while your site accessible by both www/non-www URL

Hey Guys, It has been issued about duplicate content as well as has Google Canonical problem when your site accessible both under  your_domain.com and www.your_domain.com. For ex.: www.example.com example.com www.example.com/index.html   The socking fact is that,  these all are different URLs. From the search engine perspective, this can cause bit of an issue. To avoid such problems you can use the following lines in your .htaccess file, For www version of your web:   RewriteEngine on RewriteCond %{HTTP_HOST} !^www.your_domain.com$ RewriteRule ^(.*)$ http://www.your_domain.com/$1 [R=301] For Non-www version of your web: RewriteEngine on RewriteCond %{HTTP_HOST} ^www.your_domain\.com$ [NC] RewriteRule ^(.*)$ http://your_domain.com/$1 [R=301,L] Another Way is : By Canonical Tag: The Canonical Tag look like this: <link rel=”canonical” href=”http://www.example.com”/> You have to simply add this tag inside (HEAD) section and also specify your preferred version of a URL.

Speed up Magento Performance

Below is the list of ways to speed up your Magento site. :) Hosting Environment Ø  Host only those files that you have to use Ø  Go to MySql Admin and select all the tables and repair and then optimize them Ø  Use PHP Accelerator like APC, Zend optimizer , Xcache      APC – http://pecl.php.net/package/APC      Xcache – http://xcache.lighttpd.net/      Note: By default magento stores its cache into file system     You have to add following code into local.xml Path:-../ app/etc/local.xml <global> ……………….. <cache> <backend>apc</backend> <prefix>MAGE_</prefix> </cache> …………………. After saved your changes, remember to refresh cache. Ø  Enable GZIP/DEFLATE compression in .htaccess. Go on this link and enter your magento site address. If it come back with green tick and say http://yoursitename.com is gzipped then skip next step. If not then go on next step. Find following lines in your .htaccess file and replace them with f

Take order amount in 1.3.2.4 but not in 1.4

Hi Buddies, If we make module which perform some action on order place time in magento 1.3.2.4. and now same thing want to upgrade on 1.4. . But what we see, no payment amount, currency are shown. . (this was happening only when we take order amount from the checkout session which work on 1.3 but not on 1.4). It is just because, In magento 1.3.2.4, checkout session was flushed after placing order, but in magento 1.4 version it is flushed on order place time. Don’t be panic, just take amount, currency, or whatever data you need. . take it from the order object. $orderId = Mage::getSingleton(‘checkout/session’)->getLastOrderId(); $order = Mage::getSingleton(‘sales/order’)->load($orderId); //for amount $order->getBaseGrandTotal() Cheers :)

Dont want to merge old carts items with current quote

Hi,guys Here i explain how you can prevent the cart from the old session from merging into the cart of the current session at the point when the customer login. Problem is, that a customer could basically be done shopping, logs in to their account and their cart gets filled with their old “last logged in” cart items as well as the ones they just recently picked. To prevent this from happening, here’s what I did The function loadCustomerQuote() in the observer observes the event customer_login and merges the current session quote with the last login quote object. you can see  loadCustomerQuote() in : Mage_Checkout_Model_Observer. Mage_Checkout_Model_Session. public function loadCustomerQuote() { $customerQuote = Mage::getModel('sales/quote') ->setStoreId(Mage::app()->getStore()->getId()) ->loadByCustomer(Mage::getSingleton('customer/session')->getCustomerId());   if ($this->getQuoteId() != $customerQuote->getId()) { $this->

send mail with attached file

in magento there is no available methods for attach file. once we do it in magento by adding a following code in  mage/core/model/email/template.php at the end of file. public function addAttachment(Zend_Pdf $pdf){         $file = $pdf->render();         $attachment = $this->getMail()->createAttachment($file);         $attachment->type = 'application/pdf';     $attachment->filename = 'yourfile.pdf';     }     but i prefer to use Zend_Mail to send mail with attached file. for this u need to do following. try{             $mail = new Zend_Mail();             $mail->setFrom("fromemail","fromname");             $mail->addTo("toemail","toname");             $mail->setSubject("subject");             $mail->setBodyHtml(" body text"); // here u also use setBodyText options.                     // this is for to set the file format              $content = file_get_content

enabled but dont want to show payment method on frontend checkout

if u wish to do like want to allowed some payment method work on backend but not in frontend. or may be like your payment method enabled but it should not appear on frontend checkout. for ex. in my case : i have one method "PAY By INVOICE". this will available in backend but not for frontend customers. to accomplish this i modified in path:- **/template/checkout/onepage/payment/methods.phtml which contain the following. <div class="payment-methods">     <dl id="checkout-payment-method-load">     <?php foreach ($this->getMethods() as $_method): $_code = $_method->getCode() ?>         <dt>         <?php if( sizeof($this->getMethods()) > 1 ): ?>             <input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->htmlEscape($_method->getTitle()) ?>" clas

Magento - Reset the admin password

Hi, if u getting trouble in login from admin side because of password then no worry u can reset it simply. SELECT * FROM admin_user; above query should retrieve the admin user data. here find the user name name to which u want to reset password. and apply following query UPDATE admin_user SET password=CONCAT(MD5('admin123')) WHERE username='admin'; u can also do this in mysql query browser