Thứ Ba, 30 tháng 11, 2010

How to merge all css files in magneto

If you wish to merge your all css file in magento you can do that by your magento Admin Panel. Log in to your magento admin panel the go to System->Congiguration. From the Current Configuration Scope: Select your Store view then click on Developer tab.Now click on Css Settings Tab .From the Merge CSS Files Drop down select yes to merge your css. Default No is selected . Now clear your browser cache and also refresh your magento cache.You all css file is merged Now.


Merge Css in Magento

How to redirect a page to a new page using javascript

To redirect a page we can use Javascript.



<script>

window.location.href="http://www.yourdomainname.com";

</script>

How to get Customer group id in magento


while i was working on one magento site one of my client wants to show a page only for wholesale customer.I knew How to assign customer group in magento But didn't know how to check it.I had to make this condition on Aw_blog module page, I opened that module and wrote the Following code and worked correctly.



First I check whether a Customer logged in or not ,then I fetch the value of customer group id to know in which cutomer group visited this page.In my website Wholesale customer Id was 2.


<?php

$login = Mage::getSingleton( 'customer/session' )->isLoggedIn(); //Check if User is Logged In

if($login)

{

$groupId = Mage::getSingleton('customer/session')->getCustomerGroupId(); //Get Customers Group ID

if($groupId == 2) //My wholesale customer id was 2 So I checked for 2. You can check according to your requirement

{

echo 'You are a wholesale Customer';

}

}

?>

Magento 1.4.1.1 checkout problem

Magento 1.4.1.1 checkout problem with custom theme in magento 1.4.1.1 after selecting the payment method continue button doesnot work and onepage checkout become freezed.


If you are using Magento 1.4.1 or just upgraded any of your old Magento sites to the latest Magento version, then you may be getting a very weird error on your checkout page, that the checkout CONTINUE button on payment screen, either on Authorize.net or PayPal , just doesnt work.


The cause of this error is, Magento Team has introduced a new javascript file, which validates the credit card numbers, etc on the payment screen.


So, if you are using the default theme, then you should not get this problem.


But if you are using any custom theme, then you have to do some changes on your files.


Few symptoms of this problem is, you will see such errors,

Please verify the card with the issuer bank


or

Unable to initialize Express Checkout review.


or

CONTINUE button on Credit Card Form doesnt work.


I will give the instructions in details below, how to fix this issue :


Just add this js in your page.xml:


find <action method="addJs"><script>lib/ccard.js</script></action> under <block type="page/html_head" name="head" as="head">

replace it with

<action method="addJs"><script>prototype/prototype.js</script></action>

<action method="addJs" ifconfig="dev/js/deprecation"><script>prototype/deprecation.js</script></action>

<action method="addJs"><script>lib/ccard.js</script></action>


find <action method="addJs"><script>lib/ccard.js</script></action> under


<block type="page/html" name="root" output="toHtml" template="page/print.phtml">



<block type="page/html_head" name="head" as="head">


replace it with

<action method="addJs"><script>prototype/prototype.js</script></action>

<action method="addJs"><script>mage/translate.js</script></action>

<action method="addJs"><script>lib/ccard.js</script></action>


This must solve your complete problem .

But in case, its still not working, then here is another fix, which I got from another member from a forum,


I was experiencing the same issue: Nothing happens when you enter the credit card information and hit continue. After investigating with Firebug, it seemed that the method verifyCreditCard was not defined in validation.js.


You can fix this by pasting the following javascript code into validation.js under js->prototype in root folder:


/ Credit Card Validation Javascript

// copyright 12th May 2003, by Stephen Chapman, Felgall Pty Ltd



// You have permission to copy and use this javascript provided that

// the content of the script is not changed in any way.



function validateCreditCard(s) {

// remove non-numerics

var v = "0123456789";

var w = "";

for (i=0; i < s.length; i++) {

x = s.charAt(i);

if (v.indexOf(x,0) != -1)

w += x;

}

// validate number

j = w.length / 2;

k = Math.floor(j);

m = Math.ceil(j) - k;

c = 0;

for (i=0; i<k; i++) {

a = w.charAt(i*2+m) * 2;

c += a > 9 ? Math.floor(a/10 + a%10;) : a;

}

for (i=0; i<k+m; i++) c += w.charAt(i*2+1-m) * 1;

return (c%10; == 0);

}


Now you have to disable Mage_Centinel from backend system->configuration->advanced to make it work in mozilla and firefox.

But it will work on IE without disabling centinel module.

Thứ Hai, 29 tháng 11, 2010

How to redirect from one controller to product page in magento

While I was working on a module , it was required to redirect to a particular page,I tried to using header('lcoation')... .But it was not worked,So I searched in net How to redirect from a controller to product page, No solution Found .i tried myself and got a solution ,Which I am posting here.


In my controller i was sending the product Id and After doing some work I need to redirect to that product page.


I got this solution and worked.



$productId=$this->getRequest()->getParam('productId');

$obj = Mage::getModel('catalog/product');

$_product = $obj->load($productId);

$prdurl=$_product->getProductUrl();

$url=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);

$_prdurl=explode($url,$prdurl);

$this->_redirect($_prdurl[1]);

How to Create Custom login Session in magento

If you are trying to make a custom login module in magento then Magento have a default functionality to make a Custom login session,Which destroy automattically after some time, if you will be Inactive for a moment.


Here I am showing you How to set login session value and How to get login session value.



$username=$this->getRequest()->getParam('username');

$password=$this->getRequest()->getParam('password');

$sql='select * from `tablename` where `username`= "'.$username.'" and `password`="'.$password.'" ';

$read = Mage::getSingleton('core/resource')->getConnection('core_read');

$row = $read->fetchAll($sql);

if($row)

{

Mage::getSingleton('core/session')->setlogin($row[0]['username']);

$this->_redirect('customer/account/index/');

}


Now You have Logged in to your account. If you want to retrive login Session value then you need to write the following code



$login = Mage::getSingleton('core/session')->getlogin();

if($login)

{

$this->loadLayout();

$this->renderLayout();

}

Thứ Sáu, 26 tháng 11, 2010

How to and Where to change default welcome message text in Magento

It's very simple go to admin panel of your site then go to system->config. Then click on Design tab from the left sidebar. now click on the Header tab .


Here you can Change your default welcome message in magento. You also able to change your Logo Image Alternet text. Logo Source file also.