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', '.', ',');
 
?>