Tuesday 30 April 2013

language changer in header magento

open your app/design/frontend/package/theam/template/page/html/header.phtml

put this code in your header.phtml
<?php echo $this->getChildHtml('store_language') ?>



open your app/design/frontend/package/theam/layout/xml/page.xml

it will already have code


<block type="page/html_header" name="header" as="header">
                <block type="page/template_links" name="top.links" as="topLinks"/>
                <block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
                <block type="core/text_list" name="top.menu" as="topMenu" translate="label">
                    <label>Navigation Bar</label>
                    <block type="page/html_topmenu" name="catalog.topnav" template="page/html/topmenu.phtml"/>
                </block>
                <block type="page/html_wrapper" name="top.container" as="topContainer" translate="label">
                    <label>Page Header</label>
                    <action method="setElementClass"><value>top-container</value></action>
                </block>
            </block>



make sure code in bold itelic must be at the place




app/design/frontend/package/theam/template/page/switch/language.phtml
file should be on place which will contain code



<?php if(count($this->getStores())>1): ?>
<div class="form-language">
    <label for="select-language"><?php echo $this->__('Your Language:') ?></label>
    <select id="select-language" title="<?php echo $this->__('Your Language') ?>" onchange="window.location.href=this.value">
    <?php foreach ($this->getStores() as $_lang): ?>
        <?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? ' selected="selected"' : '' ?>
        <option value="<?php echo $_lang->getCurrentUrl() ?>"<?php echo $_selected ?>><?php echo $this->htmlEscape($_lang->getName()) ?></option>
    <?php endforeach; ?>
    </select>
</div>
<?php endif; ?>






currency changer in header magento

1-create local.xml file



<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="header">
            <block type="directory/currency" name="custom_currency_selector" template="currency/currency.phtml"/>
        </reference>
    </default>
</layout>

and place it in your   app/design/frontend/package/theam/layout/    folder









currency.phtml  should be in your  app/design/frontend/package/theam/template/currency/


<?php if($this->getCurrencyCount() > 1): ?>
<div class="form-language">
    <label for="custom-currency-selector"><?php echo $this->__('Your Currency:') ?></label>
    <select onchange="window.location.href=this.value" name="custom-currency-selector" id="custom-currency-selector">
        <?php foreach ($this->getCurrencies() as $_code => $_name): ?>
        <option value="<?php echo $this->getSwitchCurrencyUrl($_code)?>"
            <?php if($_code == $this->getCurrentCurrencyCode()): ?>
                selected="SELECTED"
            <?php endif; ?>>
            <?php echo $_code ?>
        </option>
        <?php endforeach; ?>
    </select>
</div>
<?php endif; ?>







header.phtml which path is       app/design/frontend/package/theam/template/page/html/      already contain code  given blow if it is not there then add it in your

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





and last thig go to        admin->system->configuration       select your       current configuration scope
go to      Currency Setup select your allowed currency   and make sure use default should not be checked















Sunday 21 April 2013

change store phone number magento

$Aditya = new Mage_Core_Model_Config();
$stphne = '1234567890';

$Aditya ->saveConfig('general/store_information/phone', $stphne, 'stores', 2);

$Aditya ->saveConfig('general/store_information/phone', 'value', 'scope', STORE_ID);

change store address magento


$Aditya = new Mage_Core_Model_Config();
$stnm = "b-67,okhla, phase1";
$Aditya ->saveConfig('general/store_information/address', $stnm, 'stores', 2);



$Aditya ->saveConfig('general/store_information/address', 'value', 'scope', STORE_ID);

Wednesday 10 April 2013

get order data magento

$orders = Mage::getModel('sales/order')->getCollection();
foreach ($orders as $order){
$order->getIncrementId();
       $order['customer_firstname'];
        $order['customer_lastname'];
       $order['base_subtotal'];
        $order['grand_total'];
        $order['status'];
        $order['created_at'];
        $order['updated_at'];
    }

get Invoice data magento


$orders_invoice = Mage::getModel("sales/order_invoice")->getCollection(); 
      foreach($order_invoice as $val){
           $invoice = $val->getData();
           $order = Mage::getModel('sales/order')->load($invoice["order_id"]);
           $orderdata = $order->getData();
           $totaldue = $orderdata['total_due'];
           $grandtotal = $orderdata['grand_total'];
           $status = ($totaldue == 0) ? 'Paid':'unpaid';
           $order->getStatusLabel();
           $cfirstname = $orderdata['customer_firstname'];
           $clastname = $orderdata['customer_lastname'];
           $increment_id = $orderdata['increment_id'];
    }

Monday 8 April 2013

edit cms page magento

$pageid = 2;
$currentpage = Mage::getModel('cms/page')->load($pageid);

$currentpage->setTitle('pagetitle';
$currentpage->setIdentifier('pageidentifire');
$currentpage->setContent('pagecontant');
$currentpage->setIs_active(1);
        $currentpage->save();