Magento: One Page Checkout Order Review

Post Recently Updated, Use Following URL: https://7design.studio/blog/magento-order-review-update/

During Magento One Page Checkout, i used to display order details(subtotal,tax,shipping,grand total ) at Payment Information section. Use checkout session, to retrieve order data.

//Order Totals
$orderDetails = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object
$subtotal = $orderDetails["subtotal"]->getValue(); //Subtotal value
$shippingAmount = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getShippingAmount() //Shipping Amount
$taxAmount =Mage::helper('checkout')->getQuote()->getShippingAddress()->getData('tax_amount') //Tax Amount
if(isset($orderDetails['discount']) && $orderDetails['discount']->getValue()) {
 $discount = $orderDetails['discount']->getValue(); //Discount value if applied
}
$grandtotal = $orderDetails["grand_total"]->getValue(); //Grand Total

Post Recently Updated, Use Following URL: https://7design.studio/blog/magento-order-review-update/

Advertisements

Magento: Add Column at Sales Orders Grid

Post Recently Updated, Use Following URL: https://7design.studio/blog/add-custom-column-in-sales-order-grid-in-magento/

Order Mode

Magento admin orders custom field. For example, add custom field into grid as Order Type (Virtual Order Or Shipping Order).

File Path: app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php

protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());

//New Lines
$resource = Mage::getSingleton('core/resource');
$orderReference = $resource->getTableName('sales/order');
$collection->getSelect()->join(array('so' => $orderReference),'main_table.entity_id = so.entity_id',array(''))
->columns('(CASE WHEN so.is_virtual = 1 THEN "Virtual Order" ELSE "Shipping Order" END) AS order_mode');
//END

$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
//Place code where you need to show field
$this->addColumn('status_type', array(
'header' => Mage::helper('sales')->__('Order Mode'),
'index' => 'order_mode',
'type' => 'text',
'width' => '70px',
'filter' => false,
'sortable' => false,
));
}

While searching sales orders list, you are getting error as “Integrity constraint violation: 1052 Column ‘increment_id’ in where clause is ambiguous”. To resolve those errors add “filter_index” at required add column function. Use below code for increment id error, do same for “created_at”,”grand_total”,..

$this->addColumn('real_order_id', array(
    'header'=> Mage::helper('sales')->__('Order #'),
    'width' => '80px',
    'type'  => 'text',
    'index' => 'increment_id',
    'filter_index'=>'main_table.increment_id',
));

Post Recently Updated, Use Following URL: https://7design.studio/blog/add-custom-column-in-sales-order-grid-in-magento/

Magento: Change Theme Using Controller

We can change the theme using magento controller by adding below code before $this->loadLayout(); , $this->renderLayout(); . Theme update reflects only on the specific controller.

public function indexAction()
{
/* Begin - Design Package */
Mage::getSingleton('core/design_package')
                    ->setPackageName($package) // $package = base, default, {{custom_package}}, ...
                    ->setTheme($theme); //  $theme = iphone, default, {{custom_theme}}, ...
/* End */ $this->loadLayout(); $this->renderLayout(); }

Magento: Export Category List as CSV Format

Post Recently Updated, Use following URL: https://7design.studio/blog/export-magento-categories-to-csv/

Using the below code, you can export magneto category list as CSV format. Place the code in your root directory, and the exported file will be saved on  var/export directory.  So the CSV format includes

"Root Category Id", "Category Id", "Category Name", "Category URL", "Category Image", "Category Page Title", "Category Meta Keywords", "Category Mate Description","Category Is Active"
require_once 'app/Mage.php';
Mage::app();
$mageCategory = Mage::getModel ( 'catalog/category');
$categoryTree = $mageCategory->getTreeModel();
$categoryTree->load();
$categoryListIds = $categoryTree->getCollection()->getAllIds();
if ($categoryListIds) {
    $outputFileDir = "var/export/categories-detail.csv";
    $writeFile = fopen($outputFileDir, 'w');
    foreach ($categoryListIds as $categoryListId) {
        $categoryModel = $mageCategory->load($categoryListId);
        $parentCategoryId = $categoryModel->getParentId();
        $categoryId = $categoryModel->getId();
        $categoryName = $categoryModel->getName();
        $categoryUrl = $categoryModel->getUrl();
        $categoryImage = $categoryModel->getImage();
        $categoryPageTitle = $categoryModel->getMetaTitle();
        $categoryPageKeywords = $categoryModel->getMetaKeywords();
        $categoryPageDescription = $categoryModel->getMetaDescription();
        $categoryActive = $categoryModel->getIsActive();
        $collection = $mageCategory->getProductCollection();
        $data = array($parentCategoryId, $categoryId, $categoryName, $categoryUrl, $categoryImage, $categoryPageTitle, $categoryPageKeywords, $categoryPageDescription, $categoryActive);
        fputcsv($writeFile, $data);
        $i++;
    }
}
fclose($write);

Post Recently Updated, Use following URL: https://7design.studio/blog/export-magento-categories-to-csv/