Version Notes
Initial Version shows the inactive customers for fixed time period (3 months).
Download this release
Release Info
| Developer | Ramesh Pushparaj |
| Extension | Mydons_Customerorders |
| Version | 0.1.0 |
| Comparing to | |
| See all releases | |
Version 0.1.0
- app/code/community/Mydons/Customerorders/Block/Adminhtml/Customerorders.php +13 -0
- app/code/community/Mydons/Customerorders/Block/Adminhtml/Customerorders/Grid.php +84 -0
- app/code/community/Mydons/Customerorders/Block/Customerorders.php +10 -0
- app/code/community/Mydons/Customerorders/Helper/Data.php +6 -0
- app/code/community/Mydons/Customerorders/controllers/Adminhtml/CustomerordersController.php +52 -0
- app/code/community/Mydons/Customerorders/etc/config.xml +69 -0
- app/design/adminhtml/default/default/layout/customerorders.xml +8 -0
- app/etc/modules/Mydons_Customerorders.xml +9 -0
- package.xml +20 -0
app/code/community/Mydons/Customerorders/Block/Adminhtml/Customerorders.php
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Mydons_Customerorders_Block_Adminhtml_Customerorders extends Mage_Adminhtml_Block_Widget_Grid_Container
|
| 3 |
+
{
|
| 4 |
+
public function __construct()
|
| 5 |
+
{
|
| 6 |
+
$this->_controller = 'adminhtml_customerorders';
|
| 7 |
+
$this->_blockGroup = 'customerorders';
|
| 8 |
+
$this->_headerText = Mage::helper('customerorders')->__('Inactive Customers (No Orders Placed Since Past Three months)');
|
| 9 |
+
$this->_addButtonLabel = Mage::helper('customerorders')->__('Add Item');
|
| 10 |
+
parent::__construct();
|
| 11 |
+
$this->_removeButton('add');
|
| 12 |
+
}
|
| 13 |
+
}
|
app/code/community/Mydons/Customerorders/Block/Adminhtml/Customerorders/Grid.php
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Mydons_Customerorders_Block_Adminhtml_Customerorders_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
| 4 |
+
|
| 5 |
+
public function __construct() {
|
| 6 |
+
parent::__construct();
|
| 7 |
+
$this->setId('customerordersGrid');
|
| 8 |
+
$this->setDefaultSort('customerorders_id');
|
| 9 |
+
$this->setDefaultDir('ASC');
|
| 10 |
+
$this->setSaveParametersInSession(true);
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
protected function _prepareCollection() {
|
| 14 |
+
$todaysDate = date('Y-m-d H:i:s', strtotime(Mage::app()->getLocale()->date()));
|
| 15 |
+
$fromDate = date('Y-m-d H:i:s', strtotime('-90 days', strtotime(Mage::app()->getLocale()->date())));
|
| 16 |
+
|
| 17 |
+
$orderedCustomers = Mage::getModel('sales/order')->getCollection()
|
| 18 |
+
->addAttributeToSelect("customer_id")
|
| 19 |
+
->addAttributeToFilter("customer_id", array('neq' => NULL))
|
| 20 |
+
->addAttributeToFilter('created_at', array('from' => $fromDate, 'to' => $todaysDate));
|
| 21 |
+
|
| 22 |
+
if($orderedCustomers->getSize()) {
|
| 23 |
+
|
| 24 |
+
$orderedCustomerIds = array();
|
| 25 |
+
|
| 26 |
+
foreach ($orderedCustomers as $orderedCustomer) {
|
| 27 |
+
$orderedCustomerIds[$orderedCustomer->customer_id] = $orderedCustomer->customer_id;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
$collection = Mage::getModel("customer/customer")->getCollection()
|
| 31 |
+
->addAttributeToFilter("entity_id", array('nin' => array($orderedCustomerIds)));
|
| 32 |
+
$sql = 'SELECT MAX(o.created_at)'
|
| 33 |
+
. ' FROM ' . Mage::getSingleton('core/resource')->getTableName('sales/order') . ' AS o'
|
| 34 |
+
. ' WHERE o.customer_id = e.entity_id ';
|
| 35 |
+
$expr = new Zend_Db_Expr('(' . $sql . ')');
|
| 36 |
+
|
| 37 |
+
$collection->getSelect()->from(null, array('last_order_date' => $expr));
|
| 38 |
+
}
|
| 39 |
+
else {
|
| 40 |
+
$collection = Mage::getModel("customer/customer")->getCollection()
|
| 41 |
+
->addAttributeToFilter("entity_id", array('nin' => array()));
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
$this->setCollection($collection);
|
| 45 |
+
return parent::_prepareCollection();
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
protected function _prepareColumns() {
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
$this->addColumn('entity_id', array(
|
| 52 |
+
'header' => Mage::helper('customerorders')->__('Customer Id'),
|
| 53 |
+
'align' => 'left',
|
| 54 |
+
'index' => 'entity_id',
|
| 55 |
+
'type' => 'number',
|
| 56 |
+
'default' => '--'
|
| 57 |
+
));
|
| 58 |
+
|
| 59 |
+
$this->addColumn('email', array(
|
| 60 |
+
'header' => Mage::helper('customerorders')->__('Customer Email'),
|
| 61 |
+
'align' => 'left',
|
| 62 |
+
'index' => 'email',
|
| 63 |
+
'default' => '--'
|
| 64 |
+
));
|
| 65 |
+
|
| 66 |
+
$this->addColumn('last_order_date', array(
|
| 67 |
+
'header' => Mage::helper('customerorders')->__('Last Purchased On'),
|
| 68 |
+
'align' =>'left',
|
| 69 |
+
'index' => 'last_order_date',
|
| 70 |
+
'type' => 'datetime',
|
| 71 |
+
'default' => '--',
|
| 72 |
+
'filter' => false
|
| 73 |
+
));
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('customerorders')->__('CSV'));
|
| 77 |
+
$this->addExportType('*/*/exportXml', Mage::helper('customerorders')->__('XML'));
|
| 78 |
+
|
| 79 |
+
return parent::_prepareColumns();
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
}
|
app/code/community/Mydons/Customerorders/Block/Customerorders.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Mydons_Customerorders_Block_Customerorders extends Mage_Core_Block_Template
|
| 3 |
+
{
|
| 4 |
+
public function _prepareLayout()
|
| 5 |
+
{
|
| 6 |
+
return parent::_prepareLayout();
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
}
|
app/code/community/Mydons/Customerorders/Helper/Data.php
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Mydons_Customerorders_Helper_Data extends Mage_Core_Helper_Abstract
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
}
|
app/code/community/Mydons/Customerorders/controllers/Adminhtml/CustomerordersController.php
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Mydons_Customerorders_Adminhtml_CustomerordersController extends Mage_Adminhtml_Controller_action
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
protected function _initAction() {
|
| 7 |
+
$this->loadLayout()
|
| 8 |
+
->_setActiveMenu('customerorders/items')
|
| 9 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
| 10 |
+
|
| 11 |
+
return $this;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
public function indexAction() {
|
| 15 |
+
|
| 16 |
+
//exit("customerorders");
|
| 17 |
+
$this->_initAction()
|
| 18 |
+
->renderLayout();
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
public function exportCsvAction() {
|
| 22 |
+
$fileName = 'customerorders.csv';
|
| 23 |
+
$content = $this->getLayout()->createBlock('customerorders/adminhtml_customerorders_grid')
|
| 24 |
+
->getCsv();
|
| 25 |
+
|
| 26 |
+
$this->_sendUploadResponse($fileName, $content);
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
public function exportXmlAction() {
|
| 30 |
+
$fileName = 'customerorders.xml';
|
| 31 |
+
$content = $this->getLayout()->createBlock('customerorders/adminhtml_customerorders_grid')
|
| 32 |
+
->getXml();
|
| 33 |
+
|
| 34 |
+
$this->_sendUploadResponse($fileName, $content);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
protected function _sendUploadResponse($fileName, $content, $contentType = 'application/octet-stream') {
|
| 38 |
+
$response = $this->getResponse();
|
| 39 |
+
$response->setHeader('HTTP/1.1 200 OK', '');
|
| 40 |
+
$response->setHeader('Pragma', 'public', true);
|
| 41 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
| 42 |
+
$response->setHeader('Content-Disposition', 'attachment; filename=' . $fileName);
|
| 43 |
+
$response->setHeader('Last-Modified', date('r'));
|
| 44 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
| 45 |
+
$response->setHeader('Content-Length', strlen($content));
|
| 46 |
+
$response->setHeader('Content-type', $contentType);
|
| 47 |
+
$response->setBody($content);
|
| 48 |
+
$response->sendResponse();
|
| 49 |
+
die;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
}
|
app/code/community/Mydons/Customerorders/etc/config.xml
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Mydons_Customerorders>
|
| 5 |
+
<version>0.1.0</version>
|
| 6 |
+
</Mydons_Customerorders>
|
| 7 |
+
</modules>
|
| 8 |
+
<admin>
|
| 9 |
+
<routers>
|
| 10 |
+
<customerorders>
|
| 11 |
+
<use>admin</use>
|
| 12 |
+
<args>
|
| 13 |
+
<module>Mydons_Customerorders</module>
|
| 14 |
+
<frontName>customerorders</frontName>
|
| 15 |
+
</args>
|
| 16 |
+
</customerorders>
|
| 17 |
+
</routers>
|
| 18 |
+
</admin>
|
| 19 |
+
<adminhtml>
|
| 20 |
+
<menu>
|
| 21 |
+
<report>
|
| 22 |
+
<children>
|
| 23 |
+
<customerorders module="customerorders">
|
| 24 |
+
<title>Inactive Customers</title>
|
| 25 |
+
<action>customerorders/adminhtml_customerorders</action>
|
| 26 |
+
</customerorders>
|
| 27 |
+
</children>
|
| 28 |
+
</report>
|
| 29 |
+
</menu>
|
| 30 |
+
<acl>
|
| 31 |
+
<resources>
|
| 32 |
+
<all>
|
| 33 |
+
<title>Allow Everything</title>
|
| 34 |
+
</all>
|
| 35 |
+
<admin>
|
| 36 |
+
<children>
|
| 37 |
+
<report>
|
| 38 |
+
<children>
|
| 39 |
+
<customerorders translate="title" module="customerorders">
|
| 40 |
+
<title>Inactive Customers</title>
|
| 41 |
+
<action>customerorders/adminhtml_customerorders</action>
|
| 42 |
+
</customerorders>
|
| 43 |
+
</children>
|
| 44 |
+
</report>
|
| 45 |
+
</children>
|
| 46 |
+
</admin>
|
| 47 |
+
</resources>
|
| 48 |
+
</acl>
|
| 49 |
+
<layout>
|
| 50 |
+
<updates>
|
| 51 |
+
<customerorders>
|
| 52 |
+
<file>customerorders.xml</file>
|
| 53 |
+
</customerorders>
|
| 54 |
+
</updates>
|
| 55 |
+
</layout>
|
| 56 |
+
</adminhtml>
|
| 57 |
+
<global>
|
| 58 |
+
<blocks>
|
| 59 |
+
<customerorders>
|
| 60 |
+
<class>Mydons_Customerorders_Block</class>
|
| 61 |
+
</customerorders>
|
| 62 |
+
</blocks>
|
| 63 |
+
<helpers>
|
| 64 |
+
<customerorders>
|
| 65 |
+
<class>Mydons_Customerorders_Helper</class>
|
| 66 |
+
</customerorders>
|
| 67 |
+
</helpers>
|
| 68 |
+
</global>
|
| 69 |
+
</config>
|
app/design/adminhtml/default/default/layout/customerorders.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<layout version="0.1.0">
|
| 3 |
+
<customerorders_adminhtml_customerorders_index>
|
| 4 |
+
<reference name="content">
|
| 5 |
+
<block type="customerorders/adminhtml_customerorders" name="customerorders" />
|
| 6 |
+
</reference>
|
| 7 |
+
</customerorders_adminhtml_customerorders_index>
|
| 8 |
+
</layout>
|
app/etc/modules/Mydons_Customerorders.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Mydons_Customerorders>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
</Mydons_Customerorders>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Mydons_Customerorders</name>
|
| 4 |
+
<version>0.1.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license>OSL v3.0</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>A custom report extension which shows the list of customers not placed any order for the past three months</summary>
|
| 10 |
+
<description>A custom report extension which shows the list of customers not placed any order for the past three months
|
| 11 |
+

|
| 12 |
+
Useful for finding out the Inactive Customers in the website</description>
|
| 13 |
+
<notes>Initial Version shows the inactive customers for fixed time period (3 months). </notes>
|
| 14 |
+
<authors><author><name>Ramesh Pushparaj</name><user>mydonsdev</user><email>ramesh.vlb08@gmail.com</email></author></authors>
|
| 15 |
+
<date>2015-04-02</date>
|
| 16 |
+
<time>11:18:27</time>
|
| 17 |
+
<contents><target name="magecommunity"><dir name="Mydons"><dir name="Customerorders"><dir name="Block"><dir name="Adminhtml"><dir name="Customerorders"><file name="Grid.php" hash="f609e2e531664a3fb3d5ff0bd8dedd05"/></dir><file name="Customerorders.php" hash="a969767537778382ef08c8fb133304e0"/></dir><file name="Customerorders.php" hash="c33a3a0a14dc4ec34fe057f7e63066cf"/></dir><dir name="Helper"><file name="Data.php" hash="6e5d3f39cd3e8b6dd8b2a18713a3086a"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="CustomerordersController.php" hash="f374d5340b0abbd0fcaf8cf33589c51f"/></dir></dir><dir name="etc"><file name="config.xml" hash="e08e7c8b2a6df0c61317fe1fff445035"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mydons_Customerorders.xml" hash="67a990ab86259af9adae1e4a28ef29d7"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="customerorders.xml" hash="c3c7c9699726b2d2357a2134a754b449"/></dir></dir></dir></dir></target></contents>
|
| 18 |
+
<compatible/>
|
| 19 |
+
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
| 20 |
+
</package>
|
