Thursday, 5 April 2012

Magento Syntax error or access violation: 1067 Invalid default value for ‘period‘

When I am trying to install magento I getting error in app/code/core/Mage/SalesRule/sql/salesrule_setup/upgrade- SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'period'. after long time I finding solution for that. Just fire below query in your database and continue setup just remove error link from url. I hope it work for you.
ALTER TABLE `coupon_aggregated` CHANGE COLUMN `period` `period` DATE NOT NULL DEFAULT ‘0000-00-00’ 

Wednesday, 29 February 2012

magento "No shipping information available" in orders

I have problem of shipping description not display in order and order email. After search for that and nothing found and finally i have do that. Its because i have code changed in file app\code\core\Mage\Sales\Model\Quote\Address\Total\Shipping.php in line no 168. i have put something like that.

$shippingDescription = ""; // $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle();

Than I have remove this do as it default see below.

$shippingDescription = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle();

I have do this stuff because i want remove shipping info display in cart page total box where i want only display "Shipping & Handling".

And goto above file around line no 189 and i comment out below code and its hide info of shipping in cart page total box.

//if ($address->getShippingDescription()) {
//      $title .= ' (' . $address->getShippingDescription() . ')';

Friday, 24 February 2012

How To Change Order Status in Magento1.6

I searched all around to find this solution. In Magento Commerce, there is no provision for manually changing order status from the admin panel. I have also try to change in Magento\app\code\core\Mage\Sales\etc\config.xml file but i cant change in magento1.6. so finally i got below solution i hope this work for you.

Open file app\design\adminhtml\default\default\template\sales\order\view\history.phtml in this file.

Also replace the code.

<?php foreach ($this->getStatuses() as $_code=>$_label): ?>
            <?php endforeach; ?>


                $selected = "";
                foreach (Mage::getSingleton('sales/order_config')->getStatuses() as $_code=>$_label): 
                            $selected = 'selected="selected"';
                    echo "";

Its works perfectly for me i hope its work for you.

Monday, 20 February 2012

Magento Fatal error: Call to a member function is Shipping Labels Available() on a non-object

When I click the Ship button, I get this error in the lower right corner, where there should be a button:

Fatal error: Call to a member function isShippingLabelsAvailable() on a non-object in /var/www/limp/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create/Items.php on line 132

Here i got solution for it just replace text shown in below.

change line 1214 of app/code/core/Mage/Sales/Model/Order.php from

$shippingMethod = parent::getShippingMethod(); 


$shippingMethod = $this->getData('shipping_method'); 

I hope this work for you.

Thursday, 16 February 2012

Sort a category and subcategory list array alphabetically in Magento

If you are dealing with magento category i am very sure that you’ll face this problem .Magento category fetching is not an issue its a child play but sorting thse categories is little tricky. see below code for category sort in alphabetic order.
$cats = Mage::getModel('catalog/category')->load(2)->getChildren();
$catIds = explode(',', $cats);

$categories = array();
$subCategories = array();
foreach ($catIds as $catId) {
    $category = Mage::getModel('catalog/category')->load($catId);
    $categories[$category->getName()] = $category->getUrl();

    $subcats = Mage::getModel('catalog/category')->load($catId)->getChildren();
    $subcatIds = explode(',', $subcats);
    if ($subcats) {
        foreach ($subcatIds as $subcatId) {
            $subCategory = Mage::getModel('catalog/category')->load($subcatId);
            $subCategories[$category->getName()][$subCategory->getName()] = $subCategory->getUrl();
        ksort($subCategories[$category->getName()], SORT_STRING);

ksort($categories, SORT_STRING);
    <?php foreach ($categories as $name => $url): ?>
  • <?php echo $name; ?> <?php foreach ($subCategories as $key => $values) { if($name == $key) { echo '"; } } ?>
  • <?php endforeach; ?>

Tuesday, 24 January 2012

Magento An error occurred while saving the URL rewrite

Fix An error occurred while saving the URL rewrite, quick and easy fix for this problem. We always recommend making FULL site backups before commencing. This error normally shows up on a Magento 1.4x installation, the fix we found was to simply to re-index the site: Admin -> System -> Index Management -> Select All and Reindex

The line I commented out to actually get the indexer to work and finish was line 285 in app/code/core/Mage/Catalog/Model/Resource/URL.php

Mage::throwException(Mage::helper('catalog')->__('An error occurred while saving the URL rewrite'));
//Mage::throwException(Mage::helper('catalog')->__('An error occurred while saving the URL rewrite'));
I hope its work for you.