Tuesday 26 April 2011

How to troubleshoot problems while installing Magento1.5 in localhost



Invalid Base url ( Please enter a valid URL. Protocol is required (http://, https:// or ftp://):



To accept your localhost as url by modifying the validation.js file which is present in the magento installation directory at js\prototype\validation.js

Go to line No:500 

['validate-url', 'Please enter a valid URL. Protocol is required (http://, https:// or ftp://)', function (v) {

return Validation.get('IsEmpty').test(v) || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
}],

I remove all the regular expressions present and simply return true.

Replace this below code:

['validate-url', 'Please enter a valid URL. http:// is required', function (v) {
return true;
}],

How to duplicating money order payment method module in Magneto1.5



 Duplicate it as follows (checkmo to checkmonew):


Step 1 : mage/payment/block/forms + info : duplicate checkmo.php to checkmonew.php (rename inside checkmo to checkmonew)


Step 2 : mage/payment/etc/config.xml + system.xml : duplicate the checkmo parts (and rename it to checkmonew)


Step 3 : mage/payment/model/method : duplicate checkmo.php to checkmonew.php (rename inside checkmo to checkmonew)


Step 4 : design/adminhtml/default/default/template/payment/form + info : duplicate checkmo.php to checkmonew.php (rename inside checkmo to checkmonew)


Step 5 : design/frontend/base/default/template/payment/form + info : duplicate checkmo.php to checkmonew.php (rename inside checkmo to checkmonew)

Please follow this above step surely you can find in my cart page and my order page(invoice)


How to Limit the Number of Crosssell Items in Cart (Magneto)


Hi friends,

The limit is hardcoded in app/code/core/Mage/Checkout/Block/Cart/Crossell.php



class Mage_Checkout_Block_Cart_Crosssell extends Mage_Catalog_Block_Product_Abstract
{
    
protected $_maxItemCount 4;

    public function 
getItems()
    
{
...

How to connect database and fetch values to print in phtml page

To connect database and fetch values from tables in magento.

<?php
 $write = Mage::getSingleton('core/resource')->getConnection('core_write');
 $readresult= $write->query("SELECT fieldname FROM tablename" );
 while ($row = $readresult->fetch() )
 {
 $temp[] = $row['feildname'];
 }
?>

<?php
print_r($temp);
?>

Proper method to provide path for image in cms page

<a href="{{store direct_url='anylink'}}"><img src="{{media url="/imagename.jpg"}}" alt="" align="center" /></a>

How to call magento modules in cms page

To call some module like


  • New product 
  • Special Product
  • Best selling product
  • Related Product 
  • Search box
  • Advanced search



Any own module can call using block type in CMS page

{{block type="core/template" template="catalogsearch/form.mini.phtml"}}