Monday, May 23, 2011

Get category URL from the URL rewrites

$urlKey =  Mage::getModel('core/url_rewrite')->loadByIdPath('category/3')->getRequestPath();
$url = Mage::getUrl('', array('_direct' => $urlKey)); 

Saturday, May 21, 2011

Call to undefined method Mage_Eav_Model_Mysql4_Entity_Attribute_Collection::addVisibleFilter()

Change
$collection = Mage::getResourceModel('eav/entity_attribute_collection')
            ->setEntityTypeFilter( Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId() )
            ->addVisibleFilter();
to
 $collection = Mage::getResourceModel('eav/entity_attribute_collection')

            ->setEntityTypeFilter( Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId() )

            ->addFilter("is_visible", 1);

Friday, May 20, 2011

Dashboard is blank in magento admin panel after upgrading

ERROR: "SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘created_at’ in ‘field list’"

This may happen version compatible problem. Uninstall SQLi_dashboard or another module which is modify dashboard.

Wednesday, May 18, 2011

Get Customer Shipping/Billing Address

$customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultShipping();
if ($customerAddressId){
       $address = Mage::getModel('customer/address')->load($customerAddressId);
}
else
{
 $address = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress();
}

Thursday, May 12, 2011

Frontend blank after upgrading magento

Last day I tried to upgrade my magento version 1.3.3 to 1.5.X. I did upgrade successfully my backend was working fine. But my frontend was empty. It shows blank page. I stuck up with this issue. After a day spend i went to index.php page and enabled
ini_set('display_errors', 1);
Then I cleared the cache it shows few errors. I resolved all the issues and now my frontend works fine.

Call to a member function toHtml() upgrade problem

The error usually looks like this -

Fatal error: Call to a member function toHtml() on a non-object in \app\code\core\Mage\Core\Model\Layout.php on line 529

Navigate to the page.xml page
\app\design\frontend\default\themename\layout\page.xml

Find the line 


Replace with

Wednesday, May 11, 2011

PEAR ERROR: install failed

Login via ssh and try following comments.
    ./pear mage-setup .
    ./pear install magento-core/Mage_All_Latest
    ./pear upgrade-all
Look here