Friday, 26 July 2013

How to remove index.php from Any URLs in Magento

find below line in .htaccess
  # These lines rewrite /index.php/admin to /admin.
     RewriteCond %{REQUEST_URI} ^/index.php/admin.*$
     RewriteRule ^index.php/admin(.*) /admin$1 [R]
  
follow below code for remove index.php
 example1= www.domain.com/index.php/affiliate/
   # These lines rewrite /index.php/affiliate to /affiliate.
     RewriteCond %{REQUEST_URI} ^/index.php/affiliate.*$
     RewriteRule ^index.php/affiliate(.*) /affiliate$1 [R]

      example2
    # These lines rewrite /index.php/articles to /admin.
     RewriteCond %{REQUEST_URI} ^/index.php/articles.*$
     RewriteRule ^index.php/articles(.*) /articles$1 [R]
   

Thursday, 27 June 2013

How to display the product price with tax in product list/view page.

Follow the steps to achieve this.
1. Sign in to Magento Admin Panel
2. Go to System > Configuration
3. Click on ‘Tax’ listed under Sales
4. Go to ‘Calculation’ and set ‘tax based on’ to ‘Shipping Origin’
5. Go to ‘Display’ and set ‘Display Cart/Order Prices’ to ‘including and excluding tax’
6. Go to ‘Display’ and set ‘Display Product Prices’ to ‘including and excluding tax’
7. Save the Configuration

Wednesday, 5 June 2013

Magento - remove trailing slash from urls

Open app\code\core\Mage\Core\Block/Abstract.php and find the getUrl() method, it should just be one line of code that returns the requested URL:


return $this->_getUrlModel()->getUrl($route, $params);
Replace that line with the following:


$return_url = $this->_getUrlModel()->getUrl($route, $params);
if ($return_url != $this->getBaseUrl() && substr($return_url, -1) == '/' && !Mage::getSingleton('admin/session')->isLoggedIn()):
    return substr($return_url, 0, -1);
else:
    return $return_url;
endif;

Monday, 25 February 2013

Magento - Editing phtml Files in Dreamweaver

Its only recently that we came across a post which has now brought me a lot of joy to our lives and made it a lot easier on the eyes. Natively dreamweaver does not recognise phtml files and so you end up living in a black and white world, which is ok except you feel like you've been living in a 1950's sid com for the last few years. However help is finally at hand and now you can finally see phtml files for what they really are and we're going to show you how to achieve the same.
First of all since we're all on PC's, the fix described is only for windows based computers. But if you do need a fix for windows you can find the fix here.
  • Step One
Documents and Settings > [user] > Application Data > Adobe Dreamweaver > Configuration > extensions.txt
Change the top line and add the PHTML
HTM,HTML,SHTM,SHTML, ... ,TXT,PHP,PHP3,PHP4,PHP5,PHTML,JSP,WML,TPL, ... ,MASTER:All Documents
And then change the third line down to look like
PHP,PHP3,PHP4,PHP5,TPL,PHTML:PHP Files
  • Step Two
Program Files > Adobe > Dreamweaver [Your Version] > configuration > Extensions.txt
Change the top line and add the PHTML
HTM,HTML,SHTM,SHTML, ... ,TXT,PHP,PHP3,PHP4,PHP5,PHTML,JSP,WML,TPL, ... ,MASTER:All Documents
And then change the third line down to look like
PHP,PHP3,PHP4,PHP5,TPL,PHTML:PHP Files
  • Step Three
Program Files > Adobe > Dreamweaver [Your Version] > configuration > DocumentTypes > MMDocumentTypes.xml
Go to line 75 and change it so it looks like below
<documenttype id="PHP_MySQL" servermodel="PHP MySQL" internaltype="Dynamic" winfileextension="php,php3,php4,phtml,php5,<strong>phtml</strong>"<br />macfileextension="php,php3,php4,phtml,php5,<strong>phtml</strong>" file="Default.php" writebyteordermark="false">; </documenttype>

Wednesday, 13 February 2013

Add increment decrement Qty in Cart Magento


app\design\frontend\default\your theme\template\catalog\product\view\addtocart.phtm
<?php $_product = $this->getProduct(); ?>
<?php $buttonTitle = $this->__('Add to Cart'); ?>
<?php if($_product->isSaleable()): ?>

<?php if(!$_product->isGrouped()): ?>

<ul>
<li> <a href="javascript:void(0)" onclick="decrementQty('qty');"><img src="<?php echo $this->getSkinUrl('images')?>/plus-icon-1.jpg" alt="" border="0" /></a></li>
<li class="back"><input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" /></li>
<li><a href="javascript:void(0);" onclick="incrementQty('qty');"><img src="<?php echo $this->getSkinUrl('images')?>/plus-icon-2.jpg" alt="" border="0"/></a></li>
</ul>

<?php endif; ?>
<button type="button" title="<?php echo $buttonTitle ?>" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
<?php echo $this->getChildHtml('', true, true) ?>

<?php endif; ?>
<script type="text/javascript">
//<![CDATA[
function decrementQty(id) {
var val = parseInt($(id).getValue());
if(val != 1)
document.getElementById(id).value = val - 1;
}
function incrementQty(id) {
var val = parseInt($(id).getValue());
document.getElementById(id).value = val + 1;
}
//]]>
</script>

Add Order Status to Last 5 Orders on Magento Admin Dashboard

Standard Grid
Modified Grid
First of all, and this is a must when modifying any core files, create a local copy of the following file:
Copy app/code/core/Mage/Adminhtml/Block/Dashboard/Orders/Grid.php
To app/code/local/Mage/Adminhtml/Block/Dashboard/Orders/Grid.php
Open your local copy of Grid.php and around line 114 add the following:
$this->addColumn('status', array(
'header' => Mage::helper('sales')->__('Status'),
'index' => 'status',
'type'  => 'options',
'width' => '70px',
'sortable'  => false,
'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
));
Save and upload the local copy and you should now have a column called Status in your Last 5 Orders.

Tuesday, 12 February 2013

how to show particular category product wirh paging in cms page in magento

<reference name="content">
    <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
        <action method="setCategoryId"><category_id>35</category_id></action>
        <action method="setColumnCount"><columns>5</columns></action>
        <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
            <block type="page/html_pager" name="product_list_toolbar_pager"/>
        </block>
        <action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
        <action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
        <action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
        <action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
        <action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
        <action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
    </block>
</reference>

Monday, 11 February 2013

Get Product URL with categroy path

    
         $_categories = $product->getCategoryCollection();
               $_category = null;
               foreach($_categories as $_cat){
                   if(is_null($_category) || $_cat->getLevel() > $_category->getLevel()){
                       $_category    = $_cat;
                   }
               }
                   $url123= str_replace('.html','',$_category->getUrl());
                   $_itemUrl = (!is_null($_category)) ? $url123.'/'.basename($product->getProductUrl()) : $product->getProductUrl();
           
           

Friday, 8 February 2013

Magento get product price

<?php
 
// assuming that you have known product object, $_product
 
//get product price snippet
echo $this->getPriceHtml($_product, true);
 
//get $_product price
echo $_product->getPrice();
echo number_format($_product->getPrice(), '2', '.', ',');
 
//get $_product special price
echo $_product->getSpecialPrice();
echo number_format($_product->getSpecialPrice(), '2', '.', ',');
 
//get $_product final price
echo $_prodcut->getFinalPrice();
echo number_format($_product->getFinalPrice(), '2', '.', ',');
 
//get $_product Msrp
echo $_product->getMsrp();
echo number_format($_product->getMsrp(), '2', '.', ',');
 
?>