Magento: [SOLVED] Mage_Eav_Model_Entity_Abstract setConnection() must be an instance of Zend_Db_Adapter_Abstract, string given

I got this error while I was installing a third party Magento module. Actually, the module was tested for higher Magento version than 1.4 and I had to install that module on Magento version 1.4. Cause: In older Magento versions, setConnection() function of Mage_Eav_Model_Entity_Abstract class expects the parameters only on Zend_Db_Adapter_Abstract type. Whereas, in newer … Read more

Magento: Clear / Delete Shopping Cart Items of Single or All Customers

Here is the code to delete all shopping cart items of currently logged in single customer: $cart = Mage::getSingleton('checkout/cart'); $quoteItems = Mage::getSingleton('checkout/session') ->getQuote() ->getItemsCollection(); foreach( $quoteItems as $item ){ $cart->removeItem( $item->getId() ); } $cart->save(); If you want to clear all shopping cart items of all customers then you can use the following code: $quoteCollection = … Read more

Magento: Check if a module is installed, enabled or active

Here is a quick code to check if a Magento module is installed, enabled or active. The functions isModuleEnabled and isModuleOutputEnabled are present in Mage_Core_Helper_Abstract class. $moduleName = 'Mage_Core'; // edit to your required module name if (Mage::helper('core')->isModuleEnabled($moduleName)) { echo "Module is enabled."; } else { echo "Module is disabled."; } You can also check … Read more

Magento: Show CMS Static Block on only one specified Category page

Sometimes we might need to show a single static block in one or few specified categories only, rather than showing the static block on all pages. The layout XML code below helps to achieve the above requirement. It will show the static block ‘my-sidebar-1′ on right sidebar of category with id ’10’. Similarly, static block … Read more

Magento: Orders made using Paypal are not dispalyed in Customer’s ‘My Orders’ section

Problem: I placed an order in Magento using Paypal payment method. Everything went fine. I was able to pay through Paypal. However, when I login to the shop as a customer, I see that ‘My Orders‘ section is empty. I could not find information of the order I recently placed. Cause: Your order status might … Read more

Magento: Create your own custom Event Observer

Event-Observer methodology is a very helpful way for customizing Magento. It’s an alternative to overriding Magento core classes/methods. Magento has raised event at many useful places. However, there can be a situation where there is no event present in any particular method/function and we want an event to be raised there. Moreover, some events that … Read more

Magento: Get Sales Quote & Order in both Frontend and Admin

Here is a code snippet to get sales quote and order data in both admin and frontend in Magento. Get Sales Quote in Frontend Mage::getSingleton('checkout/session')->getQuote(); Get Sales Quote in Admin $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote(); Get Latest Order in Frontend $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); Get Latest Order in Admin $order = Mage::getModel('sales/order')->getCollection() ->setOrder('created_at','DESC') ->setPageSize(1) ->setCurPage(1) … Read more