Wednesday, 11 March 2015

How to add Indian States in Magento?

In this tutorial, we will see how to add states of any country in Magento.


All states value are stored in two main table: directory_country_region and 
directory_country_region_name.

So Please Follow the following steps:


1. open phpmyadmin
2. select your database
3. open 'directory_country_region' table
4. click on sql and paste following code:



INSERT INTO `directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES
(485, 'IN', 'ANDRA', 'Andra Pradesh'),
(486, 'IN', 'ARUNA', 'Arunachal Pradesh'),
(487, 'IN', 'ASSAM', 'Assam'),
(488, 'IN', 'BIHAR', 'Bihar'),
(489, 'IN', 'CHAND', 'Chandigarh'),
(490, 'IN', 'CHHAT', 'Chhattisgarh'),
(491, 'IN', 'DADAR', 'Dadar and Nagar Haveli'),
(492, 'IN', 'DAMAN', 'Daman and Diu'),
(493, 'IN', 'DELHI', 'Delhi'),
(494, 'IN', 'GOA', 'Goa'),
(495, 'IN', 'GUJAR', 'Gujarat'),
(496, 'IN', 'HARYA', 'Haryana'),
(497, 'IN', 'HP', 'Himachal Pradesh'),
(498, 'IN', 'JK', 'Jammu and Kashmir'),
(499, 'IN', 'JHARK', 'Jharkhand'),
(500, 'IN', 'KARNA', 'Karnataka'),
(501, 'IN', 'KERAL', 'Kerala'),
(502, 'IN', 'LAKSH', 'Lakshadeep'),
(503, 'IN', 'MP', 'Madya Pradesh'),
(504, 'IN', 'MAHAR', 'Maharashtra'),
(505, 'IN', 'MANIP', 'Manipur'),
(506, 'IN', 'MEGHA', 'Meghalaya'),
(507, 'IN', 'MIZOR', 'Mizoram'),
(508, 'IN', 'NAGAL', 'Nagaland'),
(510, 'IN', 'ORISS', 'Orissa'),
(511, 'IN', 'PONDI', 'Pondicherry'),
(512, 'IN', 'PUNJA', 'Punjab'),
(513, 'IN', 'RAJAS', 'Rajasthan'),
(514, 'IN', 'SIKKI', 'Sikkim'),
(515, 'IN', 'TAMIL', 'Tamil Nadu'),
(516, 'IN', 'TELANGANA', 'Telangana'),
(517, 'IN', 'TAMIL', 'Tripura'),
(518, 'IN', 'UP', 'Uttar Pradesh'),
(519, 'IN', 'UTTAR', 'Uttaranchal'),
(520, 'IN', 'WB', 'West Bengal');


And press 'Go' Button in right bottom.

Now check dropdown list, all states of India are displaying.

You can add any states of any Country. Follow the above steps.




Thursday, 8 January 2015

Magento: Back Button On Product Detail Page

"/app/design/frontend/default/default/template/catalog/product/view.phtml"
path for view.phtml can be diffrent for diffrent magento themes.

and put this code


<?php if ($_category = $_product->getCategory()): ?>

<div class="back-button">
    <button onclick="history.back();" class="button" title="<?php echo $this->__('Back') ?>" type="button">
        <span>
            <span>
<?php echo $this->__('Back') ?></span>
        </span>
    </button>
</div>
<?php endif; ?>

Magento: “Continue Shopping” button redirect to the last product's category page

It is working fine.

<?php
    $lastProductAddedToCartId = Mage::getSingleton('checkout/session')->getLastAddedProductId();
    if($lastProductAddedToCartId) {
        $productCategoryIdsArray = Mage::getModel('catalog/product')->load($lastProductAddedToCartId)->getCategoryIds();
        $continueShoppingCategoryUrl = Mage::getModel('catalog/category')->load($productCategoryIdsArray[0])->getUrl();
    }
?>
<button type="button" title="Continue Shopping" class="button" onclick="setLocation('<?php echo (isset($continueShoppingCategoryUrl)) ? $continueShoppingCategoryUrl : $this->getContinueShoppingUrl(); ?>')"><span><span>Continue Shopping</span></span></button>

Wednesday, 7 January 2015

Magento: Home Page condition

<?  $action = Mage::app()->getFrontController()->getAction()->getFullActionName();

if($action=='cms_index_index'){

    echo "Here Your custom code";

?>

 

<!-- or here you can write your custom code -->

    <?php echo $this->getChildHtml('breadcrumbs')  ?>

<?php  }  ?>