search
top

Get customer order count in Magento

Hello All, I am writing here a script snippet for getting the orders count for given customer < ?php $customer_id = 5; $_orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id',$customer_id); $_orderCnt = $_orders->count(); //orders count echo 'Customer with ID '.$customer_id.' has '.$_orderCnt.' orders'; ?>
read more

Customer Groups in Magento

Hello All, I am writing here a script for displaying a select box of customers group. There exists a Helper file for Customer at app/code/core/Mage/Customer/Helper/Data.php . We need to extend this class for using the default function Create a sample module inside local I have used the Namespace ‘Decryptweb’ for my custom module. For custom module you need to add a file in etc/modules/Decryptweb_Customer.xml The...
read more

Get customer loggedin status in Magento

Hello All, I am writing here a simple but important script for checking whether any customer is logged in or not in Magento site’s frontend <?php $customer_status = Mage::getSingleton('customer/session')->isLoggedIn(); //1 if any cutomer is logged in ?> Hope this is useful .
read more

Customer Model Magento

While working in Magento, you might have seen that there are various model defined like sales,catalog etc. I am writing here a script for working with customer model. <?php $customerModel = Mage::getModel('customer/customer'); //get customer model $customerCollection = $customerModel->getCollection(); $customers = array(); $i = 0; foreach ($customerCollection as $customer) { $customer...
read more

top