Virtina_Cartcleaner - Version 0.0.1

Version Notes

Virtina creates an extension for Magento which clears the products from customer's cart via admin. The extension provides an easy way to clear the cart items which have been in the cart of customer's for long time. By using this extension
admin can clear all cart items added by the users by clicking "Clear All Cart" Button. “Clear Guest Cart” Button removes all products from guest’s cart. We have also another option to clear the cart items of selected customers. Extension will only
have backend settings.

Download this release

Release Info

Developer Virtina
Extension Virtina_Cartcleaner
Version 0.0.1
Comparing to
See all releases


Version 0.0.1

app/code/community/Virtina/Cartcleaner/Block/Adminhtml/Cartcleaner.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Virtina
5
+ * @package Virtina_Cartcleaner
6
+ * @copyright Copyright (c) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Virtina_Cartcleaner_Block_Adminhtml_Cartcleaner extends Mage_Adminhtml_Block_Widget_Grid_Container
11
+ {
12
+ public function __construct()
13
+ {
14
+ $this->_controller = 'adminhtml_cartcleaner';
15
+ $this->_blockGroup = 'cartcleaner';
16
+ $this->_headerText = Mage::helper('cartcleaner')->__('Shopping Cart');
17
+
18
+ $this->_addButton('cartcleaner_controller', array(
19
+ 'label' => $this->__('Clear All Cart'),
20
+ 'onclick' => "setLocation('".$this->getUrl('*/*/clearall')."')",
21
+ ));
22
+
23
+ $this->_addButton('cartcleaner_guest', array(
24
+ 'label' => $this->__('Clear Guest Cart'),
25
+ 'onclick' => "setLocation('".$this->getUrl('*/*/clearguest')."')",
26
+ ));
27
+
28
+ parent::__construct();
29
+ $this->_removeButton('add');
30
+ }
31
+ }
app/code/community/Virtina/Cartcleaner/Block/Adminhtml/Cartcleaner/Grid.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Virtina
5
+ * @package Virtina_Cartcleaner
6
+ * @copyright Copyright (c) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Virtina_Cartcleaner_Block_Adminhtml_Cartcleaner_Grid extends Mage_Adminhtml_Block_Widget_Grid
11
+ {
12
+ public function __construct()
13
+ {
14
+ parent::__construct();
15
+ $this->setId('cartcleanerGrid');
16
+ $this->setDefaultSort('cartcleaner_id');
17
+ $this->setDefaultDir('ASC');
18
+ $this->setSaveParametersInSession(true);
19
+ }
20
+
21
+ protected function _prepareCollection()
22
+ {
23
+
24
+ $collection = Mage::getModel('checkout/cart')->getQuote()
25
+ ->getCollection()
26
+ ->addFieldToFilter('items_count',array('gt' => 0))
27
+ ->addFieldToFilter('customer_id',array('gt' => 0));
28
+ $this->setCollection($collection);
29
+ return parent::_prepareCollection();
30
+ }
31
+
32
+ protected function _prepareColumns()
33
+ {
34
+ $this->addColumn('customer_firstname', array(
35
+ 'header' => Mage::helper('cartcleaner')->__('Name'),
36
+ 'align' => 'left',
37
+ 'width' => '100px',
38
+ 'index' => 'customer_firstname',
39
+ 'renderer' => new Virtina_Cartcleaner_Block_Adminhtml_Renderer_CustomerName(),
40
+
41
+ ));
42
+
43
+ $this->addColumn('customer_email', array(
44
+ 'header' => Mage::helper('cartcleaner')->__('Email'),
45
+ 'align' =>'right',
46
+ 'width' => '50px',
47
+ 'index' => 'customer_email',
48
+
49
+ ));
50
+
51
+ $this->addColumn('items_count', array(
52
+ 'header' => Mage::helper('cartcleaner')->__('Items Count'),
53
+ 'align' => 'left',
54
+ 'width' => '120px',
55
+ 'default' => '--',
56
+ 'index' => 'items_count',
57
+
58
+ ));
59
+
60
+ $this->addColumn('created_at', array(
61
+ 'header' => Mage::helper('cartcleaner')->__('Date'),
62
+ 'align' => 'left',
63
+ 'width' => '120px',
64
+ 'default' => '--',
65
+ 'sortable' => true,
66
+ 'index' => 'created_at',
67
+
68
+ ));
69
+
70
+ $this->addColumn('Clear',
71
+ array(
72
+ 'header' => Mage::helper('cartcleaner')->__('Clear'),
73
+ 'width' => '50px',
74
+ 'type' => 'action',
75
+ 'getter' => 'getId',
76
+ 'actions' => array(
77
+ array(
78
+ 'caption' => Mage::helper('cartcleaner')->__('Clear'),
79
+ 'url' => array(
80
+ 'base'=>'*/*/clear',
81
+ 'params'=>array('store'=>$this->getRequest()->getParam('store'))
82
+ ),
83
+ 'field' => 'id'
84
+ )
85
+ ),
86
+ 'filter' => false,
87
+ 'sortable' => false,
88
+ 'index' => 'stores',
89
+ ));
90
+
91
+ return parent::_prepareColumns();
92
+ }
93
+
94
+ protected function _prepareMassaction()
95
+ {
96
+ $this->setMassactionIdField('entity_id');
97
+ $this->getMassactionBlock()->setFormFieldName('quoteId');
98
+ $this->getMassactionBlock()->addItem('clear', array(
99
+ 'label' => Mage::helper('cartcleaner')->__('Clear'),
100
+ 'url' => $this->getUrl('*/*/massDelete'),
101
+ 'confirm' => Mage::helper('cartcleaner')->__('Are you sure?')
102
+ ));
103
+ return $this;
104
+ }
105
+
106
+ public function getRowUrl($row)
107
+ {
108
+ return false;
109
+ }
110
+
111
+ }
app/code/community/Virtina/Cartcleaner/Block/Adminhtml/Renderer/CustomerName.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Virtina
5
+ * @package Virtina_Cartcleaner
6
+ * @copyright Copyright (c) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class Virtina_Cartcleaner_Block_Adminhtml_Renderer_CustomerName extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
10
+ {
11
+ # To merge customer's first name and last name in a single admin grid field
12
+ public function render(Varien_Object $row) {
13
+ if ($row->getData('customer_firstname') != NULL || $row->getData('customer_lastname') != NULL) {
14
+ $firstName = $row->getData('customer_firstname');
15
+ $lastName = $row->getData('customer_lastname');
16
+
17
+ if ($lastName != NULL){
18
+ return $firstName . ' ' . $lastName;
19
+ }else {
20
+ return $firstName;
21
+ }
22
+
23
+ } else {
24
+ return Mage::helper('cartcleaner')->__('NO NAME ASSIGNED');
25
+ }
26
+
27
+ }
28
+
29
+ }
30
+ ?>
app/code/community/Virtina/Cartcleaner/Helper/Data.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Virtina
5
+ * @package Virtina_Cartcleaner
6
+ * @copyright Copyright (c) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Virtina_Cartcleaner_Helper_Data extends Mage_Core_Helper_Abstract {
11
+
12
+ }
app/code/community/Virtina/Cartcleaner/controllers/Adminhtml/CartcleanerController.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Virtina
5
+ * @package Virtina_Cartcleaner
6
+ * @copyright Copyright (c) 2015-2016 Virtina. (http://www.virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ class Virtina_Cartcleaner_Adminhtml_CartcleanerController extends Mage_Adminhtml_Controller_action
11
+ {
12
+ protected function _initAction()
13
+ {
14
+ $this->loadLayout()
15
+ ->_setActiveMenu('cartcleaner/items')
16
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Cart Manager'), Mage::helper('adminhtml')->__('Cart Manager'));
17
+ return $this;
18
+
19
+ }
20
+
21
+ public function indexAction() {
22
+
23
+ $this->_initAction();
24
+ $this->renderLayout();
25
+ }
26
+
27
+
28
+ # clear cart of a specific customer
29
+ public function clearAction()
30
+ {
31
+ if( $this->getRequest()->getParam('id') > 0 ) {
32
+ try {
33
+ $idval = $this->getRequest()->getParam('id');
34
+
35
+ $quoteItems = Mage::getModel('checkout/cart')->getQuote()
36
+ ->getCollection()
37
+ ->addFieldToFilter('entity_id',$idval);
38
+ $quoteItems->walk("delete");
39
+
40
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Cart was successfully cleared.'));
41
+ $this->_redirect('*/*/');
42
+ } catch (Exception $e) {
43
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
44
+ }
45
+ }
46
+ $this->_redirect('*/*/');
47
+ }
48
+
49
+ # clearing all carts
50
+ public function clearallAction()
51
+ {
52
+ try {
53
+ $quoteCollection = Mage::getModel('sales/quote')
54
+ ->getCollection();
55
+ foreach ($quoteCollection as $item) {
56
+ $item->delete();
57
+ }
58
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Successfully cleared all Items.'));
59
+ } catch (Exception $e) {
60
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
61
+ }
62
+ $this->_redirect('*/*/');
63
+ }
64
+
65
+
66
+ # clearing all Guest cart
67
+ public function clearguestAction()
68
+ {
69
+ try {
70
+ $quoteCollection = Mage::getModel('sales/quote')
71
+ ->getCollection()
72
+ ->addFieldToFilter('customer_id', array('null' => true));
73
+ foreach ($quoteCollection as $item) {
74
+ $item->delete();
75
+ }
76
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__("Cleared all Guest Cart's."));
77
+ } catch (Exception $e) {
78
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
79
+ }
80
+ $this->_redirect('*/*/');
81
+ }
82
+
83
+
84
+ # clearing selected customer's cart
85
+ public function massDeleteAction()
86
+ {
87
+ $ids = $this->getRequest()->getParam('quoteId');
88
+ if(!is_array($ids)) {
89
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select Item(s)'));
90
+ } else {
91
+ try {
92
+ foreach ($ids as $id) {
93
+ $banners = Mage::getModel('sales/quote')->getCollection()->addFieldToFilter('entity_id',$id);
94
+ $banners->walk("delete");
95
+ }
96
+ Mage::getSingleton('adminhtml/session')->addSuccess(
97
+ Mage::helper('adminhtml')->__(
98
+ 'Total of %d record(s) were successfully deleted', count($ids)
99
+ )
100
+ );
101
+ } catch (Exception $e) {
102
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
103
+ }
104
+ }
105
+ $this->_redirect('*/*/index');
106
+ }
107
+
108
+ # Permission Allowed
109
+ protected function _isAllowed(){
110
+ return true;
111
+ }
112
+
113
+ }
app/code/community/Virtina/Cartcleaner/etc/adminhtml.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ * Virtina
4
+ * @package Virtina_Cartcleaner
5
+ * @copyright Copyright (c) 2015-2016 Virtina. (http://www.virtina.com)
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ -->
8
+ <config>
9
+ <acl>
10
+ <resources>
11
+ <admin>
12
+ <children>
13
+ <system>
14
+ <children>
15
+ <config>
16
+ <children>
17
+ <cartcleaner translate="title" module="cartcleaner">
18
+ <title>Shopping Cart Cleaner</title>
19
+ </cartcleaner>
20
+ </children>
21
+ </config>
22
+ </children>
23
+ </system>
24
+ </children>
25
+ </admin>
26
+ </resources>
27
+ </acl>
28
+ </config>
app/code/community/Virtina/Cartcleaner/etc/config.xml ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ * Virtina
4
+ * @package Virtina_Cartcleaner
5
+ * @copyright Copyright (c) 2015-2016 Virtina. (http://www.virtina.com)
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ -->
8
+ <config>
9
+ <modules>
10
+ <Virtina_Cartcleaner>
11
+ <version>0.0.1</version>
12
+ </Virtina_Cartcleaner>
13
+ </modules>
14
+ <admin>
15
+ <routers>
16
+ <adminhtml>
17
+ <args>
18
+ <modules>
19
+ <Virtina_Cartcleaner after="Mage_Adminhtml">Virtina_Cartcleaner_Adminhtml</Virtina_Cartcleaner>
20
+ </modules>
21
+ </args>
22
+ </adminhtml>
23
+ </routers>
24
+ </admin>
25
+ <adminhtml>
26
+ <menu>
27
+ <cartcleaner module="cartcleaner">
28
+ <title>Cart Cleaner</title>
29
+ <sort_order>70</sort_order>
30
+ <action>adminhtml/cartcleaner</action>
31
+ </cartcleaner>
32
+ </menu>
33
+ <acl>
34
+ <resources>
35
+ <all>
36
+ <title>Allow Everything</title>
37
+ </all>
38
+ <admin>
39
+ <children>
40
+ <cartcleaner module="cartcleaner">
41
+ <title>Cart Cleaner</title>
42
+ <sort_order>85</sort_order>
43
+ </cartcleaner>
44
+ </children>
45
+ </admin>
46
+ </resources>
47
+ </acl>
48
+ <layout>
49
+ <updates>
50
+ <cartcleaner>
51
+ <file>cartcleaner.xml</file>
52
+ </cartcleaner>
53
+ </updates>
54
+ </layout>
55
+ </adminhtml>
56
+ <global>
57
+ <models>
58
+ <cartcleaner>
59
+ <class>Virtina_Cartcleaner_Model</class>
60
+ </cartcleaner>
61
+ </models>
62
+ <blocks>
63
+ <cartcleaner>
64
+ <class>Virtina_Cartcleaner_Block</class>
65
+ </cartcleaner>
66
+ </blocks>
67
+ <helpers>
68
+ <cartcleaner>
69
+ <class>Virtina_Cartcleaner_Helper</class>
70
+ </cartcleaner>
71
+ </helpers>
72
+ </global>
73
+ </config>
app/design/adminhtml/default/default/layout/cartcleaner.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ * Virtina
5
+ * @package Virtina_Cartcleaner
6
+ * @copyright Copyright (c) 2015-2016 Virtina. (http://www.Virtina.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ -->
9
+
10
+ <layout version="0.1.0">
11
+ <adminhtml_cartcleaner_index>
12
+ <reference name="content">
13
+ <block type="cartcleaner/adminhtml_cartcleaner" name="cartcleaner" />
14
+ </reference>
15
+ </adminhtml_cartcleaner_index>
16
+ </layout>
app/etc/modules/Virtina_Cartcleaner.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ * Virtina
4
+ * @package Virtina_Cartcleaner
5
+ * @copyright Copyright (c) 2015-2016 Virtina. (http://www.Virtina.com)
6
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
+ -->
8
+ <config>
9
+ <modules>
10
+ <Virtina_Cartcleaner>
11
+ <active>true</active>
12
+ <codePool>community</codePool>
13
+ </Virtina_Cartcleaner>
14
+ </modules>
15
+ </config>
package.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Virtina_Cartcleaner</name>
4
+ <version>0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Virtina creates an extension for Magento which clears the products from customer's cart via admin.</summary>
10
+ <description>Virtina creates an extension for Magento which clears the products from customer's cart via admin. The extension provides an easy way to clear the cart items which have been in the cart of customer's for long time. By using this extension&#xD;
11
+ admin can clear all cart items added by the users by clicking "Clear All Cart" Button. &#x201C;Clear Guest Cart&#x201D; Button removes all products from guest&#x2019;s cart. We have also another option to clear the cart items of selected customers. Extension will only&#xD;
12
+ have backend settings.</description>
13
+ <notes>Virtina creates an extension for Magento which clears the products from customer's cart via admin. The extension provides an easy way to clear the cart items which have been in the cart of customer's for long time. By using this extension&#xD;
14
+ admin can clear all cart items added by the users by clicking "Clear All Cart" Button. &#x201C;Clear Guest Cart&#x201D; Button removes all products from guest&#x2019;s cart. We have also another option to clear the cart items of selected customers. Extension will only&#xD;
15
+ have backend settings.</notes>
16
+ <authors><author><name>Virtina</name><user>Virtina</user><email>developer@virtina.com</email></author></authors>
17
+ <date>2016-08-01</date>
18
+ <time>10:05:38</time>
19
+ <contents><target name="magecommunity"><dir name="Virtina"><dir name="Cartcleaner"><dir name="Block"><dir name="Adminhtml"><dir name="Cartcleaner"><file name="Grid.php" hash="b5e445da081a284f8937c316b58ee8c4"/></dir><file name="Cartcleaner.php" hash="ec532e3c0717cf44bdf0095cbd5e1b3e"/><dir name="Renderer"><file name="CustomerName.php" hash="bc8e70bb20e48f2b511daa46085fd193"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="c4206bc78cc1d0cd2232b24c53964095"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="CartcleanerController.php" hash="a91f0127fea8f220f0edb80219963c42"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="e179be990e73428e32694c62eb00ad27"/><file name="config.xml" hash="0c9a76ecf9f911ab6a06e6855d13b565"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Virtina_Cartcleaner.xml" hash="82a314fcc9998599cd77375e4dc20dd5"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="cartcleaner.xml" hash="e44eeb4c49d6bd208e3fb524efaa78b3"/></dir></dir></dir></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
22
+ </package>