Xt_Bestsellers - Version 0.1.0

Version Notes

This is a stable version and recommended to install after taking a db backup.

Download this release

Release Info

Developer Rik Sen
Extension Xt_Bestsellers
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (22) hide show
  1. app/code/community/Xt/Bestsellers/Block/Adminhtml/Bestsellers.php +12 -0
  2. app/code/community/Xt/Bestsellers/Block/Adminhtml/Bestsellers/Edit.php +47 -0
  3. app/code/community/Xt/Bestsellers/Block/Adminhtml/Bestsellers/Edit/Form.php +19 -0
  4. app/code/community/Xt/Bestsellers/Block/Adminhtml/Bestsellers/Edit/Tab/Grid.php +205 -0
  5. app/code/community/Xt/Bestsellers/Block/Adminhtml/Bestsellers/Edit/Tab/Store.php +10 -0
  6. app/code/community/Xt/Bestsellers/Block/Adminhtml/Bestsellers/Edit/Tabs.php +29 -0
  7. app/code/community/Xt/Bestsellers/Block/Adminhtml/Bestsellers/Grid.php +77 -0
  8. app/code/community/Xt/Bestsellers/Helper/Data.php +6 -0
  9. app/code/community/Xt/Bestsellers/Model/Bestsellers.php +19 -0
  10. app/code/community/Xt/Bestsellers/Model/Grid.php +9 -0
  11. app/code/community/Xt/Bestsellers/Model/Mysql4/Bestsellers.php +10 -0
  12. app/code/community/Xt/Bestsellers/Model/Mysql4/Bestsellers/Collection.php +10 -0
  13. app/code/community/Xt/Bestsellers/Model/Mysql4/Grid.php +19 -0
  14. app/code/community/Xt/Bestsellers/Model/Mysql4/Grid/Collection.php +10 -0
  15. app/code/community/Xt/Bestsellers/controllers/Adminhtml/BestsellersController.php +163 -0
  16. app/code/community/Xt/Bestsellers/etc/config.xml +103 -0
  17. app/code/community/Xt/Bestsellers/sql/bestsellers_setup/mysql4-install-0.1.0.php +33 -0
  18. app/design/adminhtml/default/default/layout/bestsellers.xml +31 -0
  19. app/design/adminhtml/default/default/template/bestsellers/stores.phtml +79 -0
  20. app/design/frontend/base/default/template/bestsellers/stores.phtml +79 -0
  21. app/etc/modules/Xt_Bestsellers.xml +9 -0
  22. package.xml +18 -0
app/code/community/Xt/Bestsellers/Block/Adminhtml/Bestsellers.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Xt_Bestsellers_Block_Adminhtml_Bestsellers extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_bestsellers';
7
+ $this->_blockGroup = 'bestsellers';
8
+ $this->_headerText = Mage::helper('bestsellers')->__('Item Manager');
9
+ $this->_addButtonLabel = Mage::helper('bestsellers')->__('Add Item');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/community/Xt/Bestsellers/Block/Adminhtml/Bestsellers/Edit.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Xt_Bestsellers_Block_Adminhtml_Bestsellers_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'id';
10
+ $this->_blockGroup = 'bestsellers';
11
+ $this->_controller = 'adminhtml_bestsellers';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('bestsellers')->__('Save Item'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('bestsellers')->__('Delete Item'));
15
+
16
+ $this->_addButton('saveandcontinue', array(
17
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
18
+ 'onclick' => 'saveAndContinueEdit()',
19
+ 'class' => 'save',
20
+ ), -100);
21
+
22
+ $this->_formScripts[] = "
23
+ function toggleEditor() {
24
+ if (tinyMCE.getInstanceById('bestsellers_content') == null) {
25
+ tinyMCE.execCommand('mceAddControl', false, 'bestsellers_content');
26
+ } else {
27
+ tinyMCE.execCommand('mceRemoveControl', false, 'bestsellers_content');
28
+ }
29
+ }
30
+
31
+ function saveAndContinueEdit(){
32
+ editForm.submit($('edit_form').action+'back/edit/');
33
+ }
34
+ ";
35
+ $this->_removeButton('save');
36
+ $this->_removeButton('delete');
37
+ }
38
+
39
+ public function getHeaderText()
40
+ {
41
+ if( Mage::registry('bestsellers_data') && Mage::registry('bestsellers_data')->getId() ) {
42
+ return Mage::helper('bestsellers')->__('Manage Bestsellers Products');
43
+ } else {
44
+ return Mage::helper('bestsellers')->__('Manage Bestsellers Products');
45
+ }
46
+ }
47
+ }
app/code/community/Xt/Bestsellers/Block/Adminhtml/Bestsellers/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Xt_Bestsellers_Block_Adminhtml_Bestsellers_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/community/Xt/Bestsellers/Block/Adminhtml/Bestsellers/Edit/Tab/Grid.php ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Xt_Bestsellers_Block_Adminhtml_Bestsellers_Edit_Tab_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId('upsellGrid');
8
+ $this->setUseAjax(true); // Using ajax grid is important
9
+ $this->setDefaultSort('entity_id');
10
+ $this->setDefaultFilter(array('in_products'=>1)); // By default we have added a filter for the rows, that in_products value to be 1
11
+ $this->setDefaultDir('ASC');
12
+ $this->setDefaultLimit(200);
13
+ $this->setSaveParametersInSession(false); //Dont save paramters in session or else it creates problems
14
+ }
15
+
16
+ protected function _prepareCollection()
17
+ {
18
+ $storeId = Mage::getSingleton('adminhtml/session')->getData('bestsellers_store_id');
19
+ $collection = Mage::getModel('catalog/product')->getCollection()
20
+ ->addAttributeToSelect('name')
21
+ ->addAttributeToSelect('sku')
22
+ ->addAttributeToSelect('price')
23
+ ->addAttributeToSelect('status')
24
+ ->addAttributeToSelect('visibility')
25
+ //->addStoreFilter($storeId)
26
+ ->joinField('position',
27
+ 'bestsellers/grid',
28
+ 'position',
29
+ 'product_id=entity_id',
30
+ '{{table}}.store_id ='.$storeId,
31
+ 'left')
32
+ ->addAttributeToFilter('type_id', array('eq' => 'simple'))
33
+ ->addFieldToFilter('status',Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
34
+ ->addAttributeToFilter('visibility', array('neq' => 1));
35
+ $this->setCollection($collection);
36
+
37
+ // return parent::_prepareCollection();
38
+
39
+ parent::_prepareCollection();
40
+ $this->getCollection()->addWebsiteNamesToResult();
41
+ return $this;
42
+ }
43
+
44
+ protected function _addColumnFilterToCollection($column)
45
+ {
46
+ // Set custom filter for in product flag
47
+ if ($column->getId() == 'in_products') {
48
+ $ids = $this->_getSelectedCustomers();
49
+ if (empty($ids)) {
50
+ $ids = 0;
51
+ }
52
+ if ($column->getFilter()->getValue()) {
53
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$ids));
54
+ } else {
55
+ if($productIds) {
56
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$ids));
57
+ }
58
+ }
59
+ }
60
+ else if ($this->getCollection()) {
61
+ if ($column->getId() == 'websites') {
62
+ $this->getCollection()->joinField('websites',
63
+ 'catalog/product_website',
64
+ 'website_id',
65
+ 'product_id=entity_id',
66
+ null,
67
+ 'left');
68
+ }
69
+ return parent::_addColumnFilterToCollection($column);
70
+ }
71
+ else {
72
+ parent::_addColumnFilterToCollection($column);
73
+ }
74
+ return $this;
75
+ }
76
+
77
+ protected function _prepareColumns()
78
+ {
79
+
80
+ $this->addColumn('in_products', array(
81
+ 'header_css_class' => 'a-center',
82
+ 'type' => 'checkbox',
83
+ 'name' => 'customer',
84
+ 'values' => $this->_getSelectedCustomers(),
85
+ 'align' => 'center',
86
+ 'index' => 'entity_id'
87
+ ));
88
+
89
+ $this->addColumn('id', array(
90
+ 'header' => Mage::helper('bestsellers')->__('Product Id'),
91
+ 'sortable' => true,
92
+ 'width' => '60px',
93
+ 'index' => 'entity_id'
94
+ ));
95
+
96
+ $this->addColumn('name', array(
97
+ 'header' => Mage::helper('bestsellers')->__('Name'),
98
+ 'index' => 'name'
99
+ ));
100
+ $this->addColumn('sku', array(
101
+ 'header' => Mage::helper('bestsellers')->__('SKU'),
102
+ 'width' => '120px',
103
+ 'index' => 'sku'
104
+ ));
105
+
106
+ $this->addColumn('type', array(
107
+ 'header' => Mage::helper('bestsellers')->__('Type'),
108
+ 'width' => 100,
109
+ 'index' => 'type_id',
110
+ 'type' => 'options',
111
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
112
+ ));
113
+
114
+ $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
115
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
116
+ ->load()
117
+ ->toOptionHash();
118
+
119
+ $this->addColumn('set_name', array(
120
+ 'header' => Mage::helper('bestsellers')->__('Attrib. Set Name'),
121
+ 'width' => 130,
122
+ 'index' => 'attribute_set_id',
123
+ 'type' => 'options',
124
+ 'options' => $sets,
125
+ ));
126
+
127
+ $this->addColumn('status', array(
128
+ 'header' => Mage::helper('bestsellers')->__('Status'),
129
+ 'width' => 90,
130
+ 'index' => 'status',
131
+ 'type' => 'options',
132
+ 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
133
+ ));
134
+
135
+ $this->addColumn('visibility', array(
136
+ 'header' => Mage::helper('bestsellers')->__('Visibility'),
137
+ 'width' => 90,
138
+ 'index' => 'visibility',
139
+ 'type' => 'options',
140
+ 'options' => Mage::getSingleton('catalog/product_visibility')->getOptionArray(),
141
+ ));
142
+
143
+ $this->addColumn('price', array(
144
+ 'header' => Mage::helper('bestsellers')->__('Price'),
145
+ 'type' => 'currency',
146
+ 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
147
+ 'index' => 'price'
148
+ ));
149
+
150
+ if (!Mage::app()->isSingleStoreMode()) {
151
+ $this->addColumn('websites',
152
+ array(
153
+ 'header'=> Mage::helper('bestsellers')->__('Websites'),
154
+ 'width' => '100px',
155
+ 'sortable' => false,
156
+ 'index' => 'websites',
157
+ 'type' => 'options',
158
+ 'options' => Mage::getModel('core/website')->getCollection()->toOptionHash(),
159
+ ));
160
+ }
161
+
162
+ $this->addColumn('position', array(
163
+ 'header' => Mage::helper('bestsellers')->__('Position'),
164
+ 'name' => 'position',
165
+ 'width' => 60,
166
+ 'type' => 'number',
167
+ 'validate_class' => 'validate-number',
168
+ 'index' => 'position',
169
+ 'editable' => true,
170
+ 'edit_only' => true
171
+ ));
172
+
173
+ return parent::_prepareColumns();
174
+ }
175
+
176
+ protected function _getSelectedCustomers() // Used in grid to return selected customers values.
177
+ {
178
+ $customers = array_keys($this->getSelectedCustomers());
179
+ return $customers;
180
+ }
181
+
182
+ public function getGridUrl()
183
+ {
184
+ return $this->_getData('grid_url') ? $this->_getData('grid_url') : $this->getUrl('*/*/upsellgrid', array('_current'=>true));
185
+ }
186
+ public function getSelectedCustomers()
187
+ {
188
+ // Customer Data
189
+ $storeId = Mage::getSingleton('adminhtml/session')->getData('bestsellers_store_id');
190
+ $tm_id = 1;
191
+ if(!isset($tm_id)) {
192
+ $tm_id = 0;
193
+ }
194
+ $collection = Mage::getModel('bestsellers/grid')->getCollection();
195
+ $collection->addFieldToFilter('store_id',$storeId);
196
+ $collection->addFieldToFilter('bestsellers_id',$tm_id);
197
+ $custIds = array();
198
+ foreach($collection as $obj){
199
+ $custIds[$obj->getProductId()] = array('position'=>$obj->getPosition());
200
+ }
201
+ return $custIds;
202
+ }
203
+
204
+
205
+ }
app/code/community/Xt/Bestsellers/Block/Adminhtml/Bestsellers/Edit/Tab/Store.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Xt_Bestsellers_Block_Adminhtml_Bestsellers_Edit_Tab_Store extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setTemplate('bestsellers/stores.phtml');
8
+ }
9
+
10
+ }
app/code/community/Xt/Bestsellers/Block/Adminhtml/Bestsellers/Edit/Tabs.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Xt_Bestsellers_Block_Adminhtml_Bestsellers_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('bestsellers_tabs');
9
+ $this->setDestElementId('edit_form');
10
+ $this->setTitle(Mage::helper('bestsellers')->__('Item Information'));
11
+ }
12
+
13
+ protected function _beforeToHtml()
14
+ {
15
+ $this->addTab('store_section', array(
16
+ 'label' => Mage::helper('bestsellers')->__('Select Stores'),
17
+ 'title' => Mage::helper('bestsellers')->__('Select Stores'),
18
+ 'content' => $this->getLayout()->createBlock('bestsellers/adminhtml_bestsellers_edit_tab_store')->toHtml(),
19
+ ));
20
+ $this->addTab('grid_section', array(
21
+ 'label' => Mage::helper('bestsellers')->__('Bestsellers Products'),
22
+ 'title' => Mage::helper('bestsellers')->__('Bestsellers Products'),
23
+ 'url' => $this->getUrl('*/*/grid', array('_current' => true)),
24
+ 'class' => 'ajax',
25
+ ));
26
+
27
+ return parent::_beforeToHtml();
28
+ }
29
+ }
app/code/community/Xt/Bestsellers/Block/Adminhtml/Bestsellers/Grid.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Xt_Bestsellers_Block_Adminhtml_Bestsellers_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('bestsellersGrid');
9
+ $this->setDefaultSort('bestsellers_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('bestsellers/bestsellers')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('bestsellers_id', array(
24
+ 'header' => Mage::helper('bestsellers')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'bestsellers_id',
28
+ ));
29
+
30
+ $this->addColumn('title', array(
31
+ 'header' => Mage::helper('bestsellers')->__('Title'),
32
+ 'align' =>'left',
33
+ 'index' => 'title',
34
+ ));
35
+
36
+ $this->addColumn('action',
37
+ array(
38
+ 'header' => Mage::helper('bestsellers')->__('Action'),
39
+ 'width' => '100',
40
+ 'type' => 'action',
41
+ 'getter' => 'getId',
42
+ 'actions' => array(
43
+ array(
44
+ 'caption' => Mage::helper('bestsellers')->__('Edit'),
45
+ 'url' => array('base'=> '*/*/edit'),
46
+ 'field' => 'id'
47
+ )
48
+ ),
49
+ 'filter' => false,
50
+ 'sortable' => false,
51
+ 'index' => 'stores',
52
+ 'is_system' => true,
53
+ ));
54
+
55
+ return parent::_prepareColumns();
56
+ }
57
+
58
+ protected function _prepareMassaction()
59
+ {
60
+ $this->setMassactionIdField('bestsellers_id');
61
+ $this->getMassactionBlock()->setFormFieldName('bestsellers');
62
+
63
+ $this->getMassactionBlock()->addItem('delete', array(
64
+ 'label' => Mage::helper('bestsellers')->__('Delete'),
65
+ 'url' => $this->getUrl('*/*/massDelete'),
66
+ 'confirm' => Mage::helper('bestsellers')->__('Are you sure?')
67
+ ));
68
+
69
+ return $this;
70
+ }
71
+
72
+ public function getRowUrl($row)
73
+ {
74
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
75
+ }
76
+
77
+ }
app/code/community/Xt/Bestsellers/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Xt_Bestsellers_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/community/Xt/Bestsellers/Model/Bestsellers.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Xt_Bestsellers_Model_Bestsellers extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('bestsellers/bestsellers');
9
+ }
10
+ public function getproids()
11
+ {
12
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
13
+ $result = $connection->query("select * from grid_bestsellers order by position");
14
+ while ($row = $result->fetch() ) {
15
+ $ids[]=$row['product_id'];
16
+ }
17
+ return $ids;
18
+ }
19
+ }
app/code/community/Xt/Bestsellers/Model/Grid.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Xt_Bestsellers_Model_Grid extends Mage_Core_Model_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('bestsellers/grid');
8
+ }
9
+ }
app/code/community/Xt/Bestsellers/Model/Mysql4/Bestsellers.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Xt_Bestsellers_Model_Mysql4_Bestsellers extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the manager_id refers to the key field in your database table.
8
+ $this->_init('bestsellers/bestsellers', 'bestsellers_id');
9
+ }
10
+ }
app/code/community/Xt/Bestsellers/Model/Mysql4/Bestsellers/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Xt_Bestsellers_Model_Mysql4_Bestsellers_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('bestsellers/bestsellers');
9
+ }
10
+ }
app/code/community/Xt/Bestsellers/Model/Mysql4/Grid.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Xt_Bestsellers_Model_Mysql4_Grid extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the bestsellers_id refers to the key field in your database table.
8
+ $this->_init('bestsellers/grid', 'id');
9
+ }
10
+ public function addGridPosition($collection,$bestsellers_id){
11
+ $table2 = $this->getMainTable();
12
+ $cond = $this->_getWriteAdapter()->quoteInto('e.entity_id = t2.product_id','');
13
+ $where = $this->_getWriteAdapter()->quoteInto('t2.bestsellers_id = ? OR ', $bestsellers_id).
14
+ $this->_getWriteAdapter()->quoteInto('isnull(t2.bestsellers_id)','');
15
+ $collection->getSelect()->joinLeft(array('t2'=>$table2), $cond)->where($where);
16
+
17
+ //echo $collection->getSelect();die;
18
+ }
19
+ }
app/code/community/Xt/Bestsellers/Model/Mysql4/Grid/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Xt_Bestsellers_Model_Mysql4_Grid_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('bestsellers/grid');
9
+ }
10
+ }
app/code/community/Xt/Bestsellers/controllers/Adminhtml/BestsellersController.php ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Xt_Bestsellers_Adminhtml_BestsellersController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ public function gridAction(){
7
+ $this->loadLayout();
8
+ $this->getLayout()->getBlock('customer.grid');
9
+ $this->renderLayout();
10
+ }
11
+
12
+ public function upsellgridAction(){
13
+ $this->loadLayout();
14
+ $this->getLayout()->getBlock('customer.grid');
15
+ $this->renderLayout();
16
+ }
17
+
18
+
19
+ protected function _initAction() {
20
+ $this->loadLayout()
21
+ ->_setActiveMenu('bestsellers/items')
22
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Bestsellers'), Mage::helper('adminhtml')->__('Item Manager'));
23
+
24
+ return $this;
25
+ }
26
+
27
+ public function indexAction() {
28
+ $this->_initAction()
29
+ ->renderLayout();
30
+ }
31
+
32
+ public function editAction() {
33
+ $id = $this->getRequest()->getParam('id');
34
+ $model = Mage::getModel('bestsellers/bestsellers')->load($id);
35
+
36
+ if ($model->getId() || $id == 0) {
37
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
38
+ if (!empty($data)) {
39
+ $model->setData($data);
40
+ }
41
+
42
+ Mage::register('bestsellers_data', $model);
43
+
44
+ $this->loadLayout();
45
+ $this->_setActiveMenu('bestsellers/items');
46
+
47
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
48
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
49
+
50
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
51
+
52
+ $this->_addContent($this->getLayout()->createBlock('bestsellers/adminhtml_bestsellers_edit'))
53
+ ->_addLeft($this->getLayout()->createBlock('bestsellers/adminhtml_bestsellers_edit_tabs'));
54
+
55
+ $this->renderLayout();
56
+ } else {
57
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('bestsellers')->__('Item does not exist'));
58
+ $this->_redirect('*/*/edit', array('id' => 1));
59
+ }
60
+ }
61
+
62
+ public function newAction() {
63
+ $this->_forward('edit');
64
+ }
65
+
66
+ public function saveAction() {
67
+ if ($data = $this->getRequest()->getPost()) {
68
+
69
+ /*$model = Mage::getModel('bestsellers/bestsellers');
70
+ $model->setData($data)
71
+ ->setId($this->getRequest()->getParam('id'));*/
72
+
73
+ try {
74
+
75
+ //$model->save();
76
+ $bestsellers_id = 1;
77
+ if(isset($data['links'])){
78
+ $customers = Mage::helper('adminhtml/js')->decodeGridSerializedInput($data['links']['customers']); //Save the array to your database
79
+
80
+ $collection = Mage::getModel('bestsellers/grid')->getCollection();
81
+ $collection->addFieldToFilter('bestsellers_id',$bestsellers_id);
82
+ $collection->addFieldToFilter('store_id',$data['store_id']);
83
+ foreach($collection as $obj){
84
+ $obj->delete();
85
+ }
86
+
87
+ foreach($customers as $key => $value){
88
+ $model2 = Mage::getModel('bestsellers/grid');
89
+ $model2->setBestsellersId($bestsellers_id);
90
+ $model2->setProductId($key);
91
+ $model2->setPosition($value['position']);
92
+ $model2->setStoreId($data['store_id']);
93
+ $model2->save();
94
+ }
95
+ }
96
+
97
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('bestsellers')->__('Item was successfully saved'));
98
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
99
+
100
+ //if ($this->getRequest()->getParam('back')) {
101
+ //$this->_redirect('*/*/edit', array('id' => $model->getId()));
102
+ //return;
103
+ //}
104
+
105
+ $this->_redirect('*/*/edit', array('id' => 1));
106
+ return;
107
+ } catch (Exception $e) {
108
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
109
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
110
+ $this->_redirect('*/*/edit', array('id' => 1));
111
+ return;
112
+ }
113
+ }
114
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('bestsellers')->__('Unable to find item to save'));
115
+ $this->_redirect('*/*/edit', array('id' => 1));
116
+ }
117
+
118
+ public function deleteAction() {
119
+ if( $this->getRequest()->getParam('id') > 0 ) {
120
+ try {
121
+ $model = Mage::getModel('bestsellers/bestsellers');
122
+
123
+ $model->setId($this->getRequest()->getParam('id'))
124
+ ->delete();
125
+
126
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
127
+ $this->_redirect('*/*/');
128
+ } catch (Exception $e) {
129
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
130
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
131
+ }
132
+ }
133
+ $this->_redirect('*/*/');
134
+ }
135
+
136
+ public function massDeleteAction() {
137
+ $bestsellersIds = $this->getRequest()->getParam('bestsellers');
138
+ if(!is_array($bestsellersIds)) {
139
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
140
+ } else {
141
+ try {
142
+ foreach ($bestsellersIds as $bestsellersId) {
143
+ $bestsellers = Mage::getModel('bestsellers/bestsellers')->load($bestsellersId);
144
+ $bestsellers->delete();
145
+ }
146
+ Mage::getSingleton('adminhtml/session')->addSuccess(
147
+ Mage::helper('adminhtml')->__(
148
+ 'Total of %d record(s) were successfully deleted', count($bestsellersIds)
149
+ )
150
+ );
151
+ } catch (Exception $e) {
152
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
153
+ }
154
+ }
155
+ $this->_redirect('*/*/index');
156
+ }
157
+
158
+ public function setregisterAction() {
159
+ $store_id = $this->getRequest()->getParam('store_id');
160
+ Mage::getSingleton('adminhtml/session')->setData('bestsellers_store_id',$store_id);
161
+ }
162
+
163
+ }
app/code/community/Xt/Bestsellers/etc/config.xml ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Xt_Bestsellers>
5
+ <version>0.1.0</version>
6
+ </Xt_Bestsellers>
7
+ </modules>
8
+ <admin>
9
+ <routers>
10
+ <bestsellers>
11
+ <use>admin</use>
12
+ <args>
13
+ <module>Xt_Bestsellers</module>
14
+ <frontName>bestsellers</frontName>
15
+ </args>
16
+ </bestsellers>
17
+ </routers>
18
+ </admin>
19
+ <adminhtml>
20
+ <menu>
21
+ <catalog>
22
+ <children>
23
+ <bestsellers module="bestsellers">
24
+ <title>Manage Bestsellers Products</title>
25
+ <sort_order>3</sort_order>
26
+ <action>bestsellers/adminhtml_bestsellers/new</action>
27
+ </bestsellers>
28
+ </children>
29
+ </catalog>
30
+ </menu>
31
+ <acl>
32
+ <resources>
33
+ <all>
34
+ <title>Allow Everything</title>
35
+ </all>
36
+ <admin>
37
+ <children>
38
+ <Xt_Bestsellers>
39
+ <title>Bestsellers Module</title>
40
+ <sort_order>10</sort_order>
41
+ </Xt_Bestsellers>
42
+ </children>
43
+ </admin>
44
+ </resources>
45
+ </acl>
46
+ <layout>
47
+ <updates>
48
+ <bestsellers>
49
+ <file>bestsellers.xml</file>
50
+ </bestsellers>
51
+ </updates>
52
+ </layout>
53
+ </adminhtml>
54
+ <global>
55
+ <models>
56
+ <bestsellers>
57
+ <class>Xt_Bestsellers_Model</class>
58
+ <resourceModel>bestsellers_mysql4</resourceModel>
59
+ </bestsellers>
60
+ <bestsellers_mysql4>
61
+ <class>Xt_Bestsellers_Model_Mysql4</class>
62
+ <entities>
63
+ <bestsellers>
64
+ <table>customer_bestsellers</table>
65
+ </bestsellers>
66
+ <grid>
67
+ <table>grid_bestsellers</table>
68
+ </grid>
69
+ </entities>
70
+ </bestsellers_mysql4>
71
+ </models>
72
+ <resources>
73
+ <bestsellers_setup>
74
+ <setup>
75
+ <module>Xt_Bestsellers</module>
76
+ </setup>
77
+ <connection>
78
+ <use>core_setup</use>
79
+ </connection>
80
+ </bestsellers_setup>
81
+ <bestsellers_write>
82
+ <connection>
83
+ <use>core_write</use>
84
+ </connection>
85
+ </bestsellers_write>
86
+ <bestsellers_read>
87
+ <connection>
88
+ <use>core_read</use>
89
+ </connection>
90
+ </bestsellers_read>
91
+ </resources>
92
+ <blocks>
93
+ <bestsellers>
94
+ <class>Xt_Bestsellers_Block</class>
95
+ </bestsellers>
96
+ </blocks>
97
+ <helpers>
98
+ <bestsellers>
99
+ <class>Xt_Bestsellers_Helper</class>
100
+ </bestsellers>
101
+ </helpers>
102
+ </global>
103
+ </config>
app/code/community/Xt/Bestsellers/sql/bestsellers_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ DROP TABLE IF EXISTS {$this->getTable('customer_bestsellers')};
10
+ CREATE TABLE {$this->getTable('customer_bestsellers')} (
11
+ `bestsellers_id` int(11) NOT NULL default 0,
12
+ `title` varchar(255) NOT NULL default '',
13
+ PRIMARY KEY (`bestsellers_id`)
14
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
15
+
16
+ DROP TABLE IF EXISTS {$this->getTable('grid_bestsellers')};
17
+ CREATE TABLE {$this->getTable('grid_bestsellers')} (
18
+ `id` int(11) unsigned NOT NULL auto_increment,
19
+ `bestsellers_id` int(11) NOT NULL ,
20
+ `product_id` int(11) NOT NULL ,
21
+ `position` int(11) NOT NULL default 0,
22
+ `store_id` smallint(6) NOT NULL default '1',
23
+ PRIMARY KEY (`id`)
24
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
25
+
26
+ ");
27
+
28
+ $installer->run("
29
+ INSERT INTO `{$installer->getTable('customer_bestsellers')}`
30
+ (`bestsellers_id`, `title`) values (1,'Generic Bestsellers Products');
31
+ ");
32
+
33
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/bestsellers.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <bestsellers_adminhtml_bestsellers_index>
4
+ <reference name="content">
5
+ <block type="bestsellers/adminhtml_bestsellers" name="bestsellers" />
6
+ </reference>
7
+ </bestsellers_adminhtml_bestsellers_index>
8
+ <bestsellers_adminhtml_bestsellers_grid>
9
+ <block type="core/text_list" name="root" output="toHtml">
10
+ <block type="bestsellers/adminhtml_bestsellers_edit_tab_grid" name="customer.grid"/>
11
+ <block type="adminhtml/widget_grid_serializer" name="grid_serializer">
12
+ <reference name="grid_serializer">
13
+ <action method="initSerializerBlock">
14
+ <grid_block_name>customer.grid</grid_block_name>
15
+ <data_callback>getSelectedCustomers</data_callback>
16
+ <hidden_input_name>links[customers]</hidden_input_name>
17
+ <reload_param_name>customers</reload_param_name>
18
+ </action>
19
+ <action method="addColumnInputName">
20
+ <input_name>position</input_name>
21
+ </action>
22
+ </reference>
23
+ </block>
24
+ </block>
25
+ </bestsellers_adminhtml_bestsellers_grid>
26
+ <bestsellers_adminhtml_bestsellers_upsellgrid>
27
+ <block type="core/text_list" name="root" output="toHtml">
28
+ <block type="bestsellers/adminhtml_bestsellers_edit_tab_grid" name="customer.grid"/>
29
+ </block>
30
+ </bestsellers_adminhtml_bestsellers_upsellgrid>
31
+ </layout>
app/design/adminhtml/default/default/template/bestsellers/stores.phtml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package default_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <div class="entry-edit">
28
+ <div class="entry-edit-head">
29
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('bestsellers')->__('Select Stores (Please choose a store view to add items)') ?></h4>
30
+ </div>
31
+ <?php $_switcherBlock = new Mage_Adminhtml_Block_Store_Switcher() ;?>
32
+ <?php if ($websites = $_switcherBlock->getWebsites()): ?>
33
+ <p class="switcher"><label for="store_switcher"><?php echo $this->__('Choose Store View') ?>:</label>
34
+ <select name="store_id" id="store_switcher" onchange="setRegister(this.value)">
35
+ <?php if ($_switcherBlock->hasDefaultOption()): ?>
36
+ <option value=""><?php echo $_switcherBlock->getDefaultStoreName() ?></option>
37
+ <?php endif; ?>
38
+ <?php foreach ($websites as $website): ?>
39
+ <?php $showWebsite=false; ?>
40
+ <?php foreach ($website->getGroups() as $group): ?>
41
+ <?php $showGroup=false; ?>
42
+ <?php foreach ($_switcherBlock->getStores($group) as $store): ?>
43
+ <?php if ($showWebsite == false): ?>
44
+ <?php $showWebsite = true; ?>
45
+ <optgroup label="<?php echo $website->getName() ?>"></optgroup>
46
+ <?php endif; ?>
47
+ <?php if ($showGroup == false): ?>
48
+ <?php $showGroup = true; ?>
49
+ <optgroup label="&nbsp;&nbsp;&nbsp;<?php echo $group->getName() ?>">
50
+ <?php endif; ?>
51
+ <option value="<?php echo $store->getId() ?>"<?php if($store->getId() == Mage::getSingleton('adminhtml/session')->getData('bestsellers_store_id')): ?> selected="selected"<?php endif; ?>>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $store->getName() ?></option>
52
+ <?php endforeach; ?>
53
+ <?php if ($showGroup): ?>
54
+ </optgroup>
55
+ <?php endif; ?>
56
+ <?php endforeach; ?>
57
+ <?php endforeach; ?>
58
+ </select>
59
+ </p>
60
+
61
+ <?php endif; ?>
62
+
63
+ <script type="text/javascript">
64
+
65
+ function setRegister(id){
66
+ new Ajax.Request('<?php echo $this->getUrl('bestsellers/adminhtml_bestsellers/setregister')?>',
67
+ {
68
+ method:'get',
69
+ parameters: {store_id:id},
70
+ onSuccess: function(transport){
71
+ var response = transport.responseText || "no response text";
72
+ window.location.reload();
73
+ },
74
+ onFailure: function(){ alert('Something went wrong...') }
75
+
76
+ });
77
+ }
78
+ </script>
79
+
app/design/frontend/base/default/template/bestsellers/stores.phtml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package default_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <div class="entry-edit">
28
+ <div class="entry-edit-head">
29
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('bestsellers')->__('Select Stores (Please choose a store view to add items)') ?></h4>
30
+ </div>
31
+ <?php $_switcherBlock = new Mage_Adminhtml_Block_Store_Switcher() ;?>
32
+ <?php if ($websites = $_switcherBlock->getWebsites()): ?>
33
+ <p class="switcher"><label for="store_switcher"><?php echo $this->__('Choose Store View') ?>:</label>
34
+ <select name="store_id" id="store_switcher" onchange="setRegister(this.value)">
35
+ <?php if ($_switcherBlock->hasDefaultOption()): ?>
36
+ <option value=""><?php echo $_switcherBlock->getDefaultStoreName() ?></option>
37
+ <?php endif; ?>
38
+ <?php foreach ($websites as $website): ?>
39
+ <?php $showWebsite=false; ?>
40
+ <?php foreach ($website->getGroups() as $group): ?>
41
+ <?php $showGroup=false; ?>
42
+ <?php foreach ($_switcherBlock->getStores($group) as $store): ?>
43
+ <?php if ($showWebsite == false): ?>
44
+ <?php $showWebsite = true; ?>
45
+ <optgroup label="<?php echo $website->getName() ?>"></optgroup>
46
+ <?php endif; ?>
47
+ <?php if ($showGroup == false): ?>
48
+ <?php $showGroup = true; ?>
49
+ <optgroup label="&nbsp;&nbsp;&nbsp;<?php echo $group->getName() ?>">
50
+ <?php endif; ?>
51
+ <option value="<?php echo $store->getId() ?>"<?php if($store->getId() == Mage::getSingleton('adminhtml/session')->getData('bestsellers_store_id')): ?> selected="selected"<?php endif; ?>>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $store->getName() ?></option>
52
+ <?php endforeach; ?>
53
+ <?php if ($showGroup): ?>
54
+ </optgroup>
55
+ <?php endif; ?>
56
+ <?php endforeach; ?>
57
+ <?php endforeach; ?>
58
+ </select>
59
+ </p>
60
+
61
+ <?php endif; ?>
62
+
63
+ <script type="text/javascript">
64
+
65
+ function setRegister(id){
66
+ new Ajax.Request('<?php echo $this->getUrl('bestsellers/adminhtml_bestsellers/setregister')?>',
67
+ {
68
+ method:'get',
69
+ parameters: {store_id:id},
70
+ onSuccess: function(transport){
71
+ var response = transport.responseText || "no response text";
72
+ window.location.reload();
73
+ },
74
+ onFailure: function(){ alert('Something went wrong...') }
75
+
76
+ });
77
+ }
78
+ </script>
79
+
app/etc/modules/Xt_Bestsellers.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Xt_Bestsellers>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Xt_Bestsellers>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Xt_Bestsellers</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Ability to assign store specific bestseller/featured product.</summary>
10
+ <description>This module will allow the E-Commerce administrator to choose store specific different bestseller or featured product and can show those products on home page or any specific CMS page for individual store.</description>
11
+ <notes>This is a stable version and recommended to install after taking a db backup.</notes>
12
+ <authors><author><name>Rik Sen</name><user>pmgr</user><email>pm@hire-developer.co.uk</email></author></authors>
13
+ <date>2012-12-18</date>
14
+ <time>12:51:18</time>
15
+ <contents><target name="magecommunity"><dir name="Xt"><dir name="Bestsellers"><dir name="Block"><dir name="Adminhtml"><dir name="Bestsellers"><dir name="Edit"><file name="Form.php" hash="8441eded8c2dedf5112d88329f113d50"/><dir name="Tab"><file name="Grid.php" hash="9eed27e93c0cce31e1ee547a28975dc7"/><file name="Store.php" hash="baf54a4860572343874d635741e86618"/></dir><file name="Tabs.php" hash="cdb36833b1c5ae5da3bb8405b2819e06"/></dir><file name="Edit.php" hash="dde9725fd67adb4c7f334659d0562183"/><file name="Grid.php" hash="6158f6fe20a32cd788f90f3dc22db0a6"/></dir><file name="Bestsellers.php" hash="128949e8b2aa091f6917416a6c3c8885"/></dir></dir><dir name="Helper"><file name="Data.php" hash="1658725b23f0b49629f0f440359fbf56"/></dir><dir name="Model"><file name="Bestsellers.php" hash="62db608e99b4925ccd6a7cdaaeb21d27"/><file name="Grid.php" hash="b93593e31f585f99e5840f0f4016dc58"/><dir name="Mysql4"><dir name="Bestsellers"><file name="Collection.php" hash="36c670f05d3f93bc396ce01792d54e39"/></dir><file name="Bestsellers.php" hash="14423f5fd70528bf15a581ed1c3d7349"/><dir name="Grid"><file name="Collection.php" hash="0db66b29ae77945aaef1a572f34d84dc"/></dir><file name="Grid.php" hash="9f148584990c0474a039a7b42f06e6b7"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="BestsellersController.php" hash="c128fe1fd18668ff91abb2272df0eb99"/></dir></dir><dir name="etc"><file name="config.xml" hash="30523f422a8be60ad3c7d22ce4a0d295"/></dir><dir name="sql"><dir name="bestsellers_setup"><file name="mysql4-install-0.1.0.php" hash="dde03e0ca03d1cc54081d5361902a500"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Xt_Bestsellers.xml" hash="ebb637084f8709bc35dfe981d144c402"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="bestsellers.xml" hash="a8426d83498a9853d3ff3f3e5d8df540"/></dir><dir name="template"><dir name="bestsellers"><file name="stores.phtml" hash="6606b32bed9f6d2fe0bd6a1c4703b237"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="bestsellers"><file name="stores.phtml" hash="6606b32bed9f6d2fe0bd6a1c4703b237"/></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>