Monday 22 July 2013

Magneto Get Product Attribute value in cart page

Magneto Get Product Attribute value in cart page


$session= Mage::getSingleton('checkout/session'); 

$items = $session->getQuote()->getAllItems();
 
foreach($items as $item) { 
                              echo 'Product ID: '.$productId = $item->getProductId().'<br>'; 
                              echo 'Product Name: '.$productName = $item->getName().'<br>'; 
                              echo 'Product Sku: '.$productSku = $item->getSku().'<br>'; 
                              echo 'Product Quantity: '.$productQty =$item->getQty().'<br>'; 
                              echo 'Product Price: '.$productPrice = $item->getProduct()->getPrice().'<br>'; 
                              echo 'Attribute name : '.$Attribute = Mage::getModel('catalog/product')->load($productId)->getAttributeText('sttribute_code').'<br>';
                                
                     } 

Magento Get all customer details in cart page


 Magento Get Full Details of customer in cart page


 $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
 $group = Mage::getModel('customer/group')->load($groupId); //Get customer Group name
  $group_name = $group->getCode();

Magneto Get All Coupon code and rule in cart page


 Magento Fetch all coupons id,name,etc..


$rulesCollection = Mage::getModel('salesrule/rule')->getCollection();
print_r($rulesCollection);
                    foreach($rulesCollection as $rule) {
                              echo $coupon = $rule->getName();
                              echo $coupon = $rule->getIsActive();
                           }

Monday 15 July 2013

Show Track your order in frontend - My order page

Display order track in front end My order page and My Dashboard page

Method 1 :

frontend/base/default/template/sales/order/recent.phtml

 foreach ($_orders as $_order): ?>
               <tr>
                    <td><?php echo $_order->getRealOrderId() ?></td>
                    <td><span class="nobr"><?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?></span></td>
                    <td><?php echo $_order->getShippingAddress() ? $this->htmlEscape($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
                    <td><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
                    <td><em><?php echo $_order->getStatusLabel() ?></em></td>
        <td>
        <?php
    if($_order->hasShipments()) {
    $show = true;
    foreach($_order->getTracksCollection() as $k=>$v) {                           
        if($v['carrier_code'] == 'custom' || $v['carrier_code'] == '')
            $show = false;
    }
    if($show) {?>
        <span class="separator2">&nbsp;</span>

        <a class="askTrackBtn" href="javascript:;" onclick="popWin('<?php echo Mage::helper('shipping/data')->getTrackingPopUpUrlByOrderId($_order->getId()) ?>', 'tracking the order', 'scrollbars=yes,width=800,height=600,resizable=yes');return false;"><span><?php echo $this->__('Track Order') ?></span></a>
       <?php
    }
}
?>     </td>
                    <td class="a-center">
                        <span class="nobr">
                        <a href="<?php echo $this->getViewUrl($_order) ?>"><?php echo $this->__('View Order') ?></a>
                        <?php if ($this->helper('sales/reorder')->canReorder($_order)) : ?>
                            <span class="separator">|</span> <a href="<?php echo $this->getReorderUrl($_order) ?>" class="link-reorder"><?php echo $this->__('Reorder') ?></a>
                        <?php endif ?>
                        </span>
                    </td>
                </tr>

            <?php endforeach; ?>




Method 2 :

 foreach ($_orders as $_order): ?>
               <tr>
                    <td><?php echo $_order->getRealOrderId() ?></td>
                    <td><span class="nobr"><?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?></span></td>
                    <td><?php echo $_order->getShippingAddress() ? $this->htmlEscape($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
                    <td><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
                    <td><em><?php echo $_order->getStatusLabel() ?></em></td>
        <td>
        <?php
    $shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')->setOrderFilter($_order)->load();
        foreach ($shipmentCollection as $shipment){
           
            foreach($shipment->getAllTracks() as $tracknum)
            {
                echo $tracknums=$tracknum->getNumber();
        if($_order->getShippingDescription() == "Conway Freight") { ?>
        <a href="https://www.con-way.com/webapp/manifestrpts_p_app/Tracking/TrackingRS.jsp?PRO=<?php echo $tracknums; ?>">   
        <?php } else if ($_order->getShippingDescription() == "Flat Rate - Fixed") { ?>
            <a href="https://www.con-way.com/webapp/manifestrpts_p_app/Tracking/TrackingRS.jsp?PRO=<?php echo $tracknums; ?>">   
        <?php } echo $_order->getShippingDescription(); ?></a>


<?php          }

        }
?>  </td>

                    <td class="a-center">
                        <span class="nobr">
                        <a href="<?php echo $this->getViewUrl($_order) ?>"><?php echo $this->__('View Order') ?></a>
                        <?php if ($this->helper('sales/reorder')->canReorder($_order)) : ?>
                            <span class="separator">|</span> <a href="<?php echo $this->getReorderUrl($_order) ?>" class="link-reorder"><?php echo $this->__('Reorder') ?></a>
                        <?php endif ?>
                        </span>
                    </td>
                </tr>

            <?php endforeach; ?>





--------------------------------------------------------------------------------------------------------------------------------

frontend/base/default/template/sales/order/history.phtml



 <?php foreach ($_orders as $_order): ?>
        <tr>
            <td><?php echo $_order->getRealOrderId() ?></td>
            <td><span class="nobr"><?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?></span></td>
            <td><?php echo $_order->getShippingAddress() ? $this->htmlEscape($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
            <td><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
            <td><em><?php echo $_order->getStatusLabel() ?></em></td>
            <td class="a-center">
        <span class="nobr"><a href="<?php echo $this->getViewUrl($_order) ?>"><?php echo $this->__('View Order') ?></a>
         <?php if ($_order->getTracksCollection()->count()) : ?>
            <span class="separator">|</span> <a href="#" onclick="popWin('<?php echo $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','top=0,left=0,width=800,height=600,resizable=yes,scrollbars=yes'); return false;" title="<?php echo $this->__('Track your order') ?>"><?php echo $this->__('Track your order') ?></a>
        <?php endif; ?>                  

          <?php if ($this->helper('sales/reorder')->canReorder($_order)) : ?>
                    <span class="separator">|</span> <a href="<?php echo $this->getReorderUrl($_order) ?>" class="link-reorder"><?php echo $this->__('Reorder') ?></a>
                <?php endif ?>
                </span>
            </td>
        </tr>
        <?php endforeach; ?>