Saturday, August 27, 2011

How to get the customer login, logout, register and checkout url?

Mage::getUrl('customer/account/login'); //login url 
Mage::getUrl('customer/account/logout'); //logout url
Mage::getUrl('customer/account'); //My Account url
Mage::getUrl('customer/account/create'); // Register url
Mage::getUrl('checkout/cart'); //Checkout url

Friday, August 26, 2011

Magento Pagination Without Toolbar?

Add the below code to your end of "template/catalog/product/list.phtml" file.
<?php 
   // manually get the toolbar block so we can do the page navigation
   $toolbar = $this->getToolbarBlock();
   $toolbar->setCollection($_productCollection);
   if($toolbar->getCollection()->getSize() > 0):
      echo $toolbar->getPagerHtml(); //Pager
      echo $toolbar->__('Items %s to %s of %s total', $toolbar->getFirstNum(), $toolbar->getLastNum(), $toolbar->getTotalNum());
   endif;
?>
Thats it. It will work perfectly.

Tuesday, August 23, 2011

How to show total shopping cart price in Header Magento?

Edit the template\page\html\header.phtml file and add the below code to display total number of items and price in header.

<?php
$count = $this->helper('checkout/cart')->getSummaryCount();  //get total items in cart
  $total = $this->helper('checkout/cart')->getQuote()->getGrandTotal(); //get total price
  if($count==0)
  {
    echo $this->__('Items: %s',$count);
  }
  if($count==1)
  {
    echo $this->__(' Item: %s',$count);
  }
  if($count>1)
  {
    echo $this->__(' Items: %s',$count);
  }
  echo $this->__(' Total: %s', $this->helper('core')->formatPrice($total, false));
?>

How to move Cart from Right Sidebar to Header in Magento?

Find the below line in your page.xml file.
 //Near line 70
Add the below code inside to that block

Your new code will look like this

        
        
        
            
        
        
            
            top-container
        
	//new block 
	

Finally Add the below code in your "\template\page\html\header.phtml" file.
//place this where ever you want the cart to show up.
<?php echo $this->getChildHtml('topcart'); ?> 
Thats it. You can see the cart sidebar in your header section.

How to remove wishlist link url from top links in magento?

Comment the below line in your wishlist.xml file.

          
            wishlist_link

How to add customer register link to the top links in magento?

Add the below line in your customer.xml file.

	   Register11

Monday, August 22, 2011

Custom 'Sort by' drop-down menu options Lowest price, Higest price, Name A-Z, Name Z-A, Newest to Oldest & Oldest to Newest in magento

Edit "template/catalog/product/list/toolbar.phtml"
Original code:
<div class="sort-by">
            <label><?php echo $this->__('Sort By') ?></label>
            <select onchange="setLocation(this.value)">
            <?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
                <option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif; ?>>
                    <?php echo $this->__($_order) ?>
                </option>
            <?php endforeach; ?>
            </select>
            <?php if($this->getCurrentDirection() == 'desc'): ?>
                <a href="<?php echo $this->getOrderUrl(null, 'asc') ?>" title="<?php echo $this->__('Set Ascending Direction') ?>"><img src="<?php echo $this->getSkinUrl('images/i_desc_arrow.gif') ?>" alt="<?php echo $this->__('Set Ascending Direction') ?>" class="v-middle" /></a>
            <?php else: ?>
                <a href="<?php echo $this->getOrderUrl(null, 'desc') ?>" title="<?php echo $this->__('Set Descending Direction') ?>"><img src="<?php echo $this->getSkinUrl('images/i_asc_arrow.gif') ?>" alt="<?php echo $this->__('Set Descending Direction') ?>" class="v-middle" /></a>
            <?php endif; ?>
</div> 
Replace with:
<fieldset class="sort-by">
        <label><?php echo $this->__('Sort by') ?></label>
        <select onchange="setLocation(this.value)">
            <option value="<?php echo $this->getOrderUrl('position', 'asc') ?>"<?php if($this->isOrderCurrent('position') && $this->getCurrentDirection() == 'asc'): ?> selected="selected"<?php endif; ?>>
                Featured
            </option>
            <option value="<?php echo $this->getOrderUrl('price', 'asc') ?>"<?php if($this->isOrderCurrent('price') && $this->getCurrentDirection() == 'asc'): ?> selected="selected"<?php endif; ?>>
                Lowest Price
            </option>
            <option value="<?php echo $this->getOrderUrl('price', 'desc') ?>"<?php if($this->isOrderCurrent('price') && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>>
                Highest Price
            </option>
            <option value="<?php echo $this->getOrderUrl('name', 'asc') ?>"<?php if($this->isOrderCurrent('name') && $this->getCurrentDirection() == 'asc'): ?> selected="selected"<?php endif; ?>>
                Name A-Z
            </option>
            <option value="<?php echo $this->getOrderUrl('name', 'desc') ?>"<?php if($this->isOrderCurrent('name') && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>>
                Name Z-A
            </option>
            <option value="<?php echo $this->getOrderUrl('entity_id', 'desc') ?>"<?php if($this->isOrderCurrent('entity_id') && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>>
                Newest to Oldest
            </option>
            <option value="<?php echo $this->getOrderUrl('entity_id', 'asc') ?>"<?php if($this->isOrderCurrent('entity_id') && $this->getCurrentDirection() == 'asc'): ?> selected="selected"<?php endif; ?>>
                Oldest to Newest
            </option>
        </select>
</fieldset>