Mostviewed_Products - Version 1.0.0

Version Notes

Mos tviewed Products

Download this release

Release Info

Developer Capacity Web Solutions
Extension Mostviewed_Products
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (41) hide show
  1. app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/DefaultDirectCode.php +16 -0
  2. app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/DefaultTemplate.php +16 -0
  3. app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/DefaultXML.php +19 -0
  4. app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed.php +29 -0
  5. app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Edit.php +41 -0
  6. app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Edit/Form.php +24 -0
  7. app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Edit/Tab/Products.php +27 -0
  8. app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Edit/Tabs.php +28 -0
  9. app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Grid.php +178 -0
  10. app/code/community/CapacityWebSolutions/Mostviewed/Block/Mostviewed.php +249 -0
  11. app/code/community/CapacityWebSolutions/Mostviewed/Block/Promo/Widget/Chooser/Sku.php +158 -0
  12. app/code/community/CapacityWebSolutions/Mostviewed/Block/Widget.php +25 -0
  13. app/code/community/CapacityWebSolutions/Mostviewed/Block/Widget/Html/Pager.php +273 -0
  14. app/code/community/CapacityWebSolutions/Mostviewed/Helper/Data.php +17 -0
  15. app/code/community/CapacityWebSolutions/Mostviewed/Model/Mostviewed.php +15 -0
  16. app/code/community/CapacityWebSolutions/Mostviewed/Model/Mysql4/Mostviewed.php +14 -0
  17. app/code/community/CapacityWebSolutions/Mostviewed/Model/Mysql4/Mostviewed/Collection.php +16 -0
  18. app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Category.php +65 -0
  19. app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Chooseproducts.php +1 -0
  20. app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Choosetype.php +1 -0
  21. app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Sortby.php +1 -0
  22. app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Sortorder.php +1 -0
  23. app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Template.php +1 -0
  24. app/code/community/CapacityWebSolutions/Mostviewed/controllers/Adminhtml/MostviewedController.php +219 -0
  25. app/code/community/CapacityWebSolutions/Mostviewed/controllers/Adminhtml/WidgetController.php +33 -0
  26. app/code/community/CapacityWebSolutions/Mostviewed/etc/adminhtml.xml +46 -0
  27. app/code/community/CapacityWebSolutions/Mostviewed/etc/config.xml +126 -0
  28. app/code/community/CapacityWebSolutions/Mostviewed/etc/system.xml +324 -0
  29. app/code/community/CapacityWebSolutions/Mostviewed/etc/widget.xml +195 -0
  30. app/code/community/CapacityWebSolutions/Mostviewed/sql/mostviewed_setup/mysql4-install-1.0.0.php +27 -0
  31. app/design/adminhtml/default/default/layout/mostviewed.xml +17 -0
  32. app/design/adminhtml/default/default/template/mostviewed/product.phtml +48 -0
  33. app/design/frontend/base/default/layout/mostviewed.xml +8 -0
  34. app/design/frontend/base/default/template/mostviewed/column/mostviewed_default_list-default.phtml +40 -0
  35. app/design/frontend/base/default/template/mostviewed/column/mostviewed_default_list.phtml +42 -0
  36. app/design/frontend/base/default/template/mostviewed/mostviewed-grid.phtml +140 -0
  37. app/design/frontend/base/default/template/mostviewed/mostviewed-list.phtml +143 -0
  38. app/etc/modules/CapacityWebSolutions_Mostviewed.xml +9 -0
  39. js/mostviewed/product-selector.js +193 -0
  40. package.xml +18 -0
  41. skin/frontend/base/default/css/mostviewed/mostviewed.css +13 -0
app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/DefaultDirectCode.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Block_Adminhtml_DefaultDirectCode
9
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
10
+ {
11
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
12
+ {
13
+ return '<div style="background:#efefef;border:1px solid #d8d8d8;padding:10px;margin-bottom:10px;"><span>&lt?php echo $this->getLayout()->createBlock("mostviewed/mostviewed")->toHtml(); ?&gt;</span></div>';
14
+ }
15
+
16
+ }
app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/DefaultTemplate.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Block_Adminhtml_DefaultTemplate
9
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
10
+ {
11
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
12
+ {
13
+ return '<div style="background:#efefef;border:1px solid #d8d8d8;padding:10px;margin-bottom:10px; "><span>{{block type="mostviewed/mostviewed" name="mostviewed"}}</span></div>';
14
+ }
15
+
16
+ }
app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/DefaultXML.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Block_Adminhtml_DefaultXML
9
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
10
+ {
11
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
12
+ {
13
+ return '<div style="background:#efefef;border:1px solid #d8d8d8;padding:10px;margin-bottom:10px;">
14
+ <span>&lt;reference name="content"&gt; </br>&lt;block type="mostviewed/mostviewed" name="mostviewed"/&gt;</br>&lt;/reference&gt;</span>
15
+ </div>';
16
+
17
+ }
18
+
19
+ }
app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Block_Adminhtml_Mostviewed extends Mage_Adminhtml_Block_Widget_Grid_Container
9
+ {
10
+ public function __construct()
11
+ {
12
+ $this->_controller = 'adminhtml_mostviewed';
13
+ $this->_blockGroup = 'mostviewed';
14
+ $this->_headerText = Mage::helper('mostviewed')->__('Manage Most Viewed Products');
15
+ $this->_addButtonLabel = Mage::helper('mostviewed')->__('Select Products');
16
+ parent::__construct();
17
+ }
18
+
19
+ protected function _prepareLayout() {
20
+ $this->setChild('store_switcher', $this->getLayout()->createBlock('adminhtml/store_switcher', 'store_switcher')->setUseConfirm(false)
21
+ );
22
+ return parent::_prepareLayout();
23
+ }
24
+
25
+ public function getGridHtml() {
26
+
27
+ return $this->getChildHtml('store_switcher') . $this->getChildHtml('grid');
28
+ }
29
+ }
app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Edit.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Block_Adminhtml_Mostviewed_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
9
+ {
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+ $this->_objectId = 'id';
14
+ $this->_blockGroup = 'mostviewed';
15
+ $this->_controller = 'adminhtml_mostviewed';
16
+ $this->_updateButton('save', 'label','Save');
17
+ $this->_updateButton('delete','label','Delete');
18
+ $this->_addButton('save_and_continue', array(
19
+ 'label' => Mage::helper('mostviewed')->__('Save And Continue Edit'),
20
+ 'onclick' => 'saveAndContinueEdit()',
21
+ 'class' => 'save'
22
+ ), -100);
23
+
24
+ $this->_formScripts[] = "
25
+ function saveAndContinueEdit(){
26
+ editForm.submit($('edit_form').action + 'back/edit/');
27
+ }
28
+
29
+ ";
30
+ $this->setId('mostviewed_edit');
31
+ }
32
+
33
+ public function getHeaderText()
34
+ {
35
+ if( Mage::registry('mostviewed_data') && Mage::registry('mostviewed_data')->getNewproductsId() ) {
36
+ return Mage::helper('mostviewed')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('mostviewed_data')->getSku()));
37
+ } else {
38
+ return Mage::helper('mostviewed')->__('Select Products');
39
+ }
40
+ }
41
+ }
app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Edit/Form.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Block_Adminhtml_Mostviewed_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
9
+ {
10
+ protected function _prepareForm()
11
+ {
12
+ $form = new Varien_Data_Form(
13
+ array(
14
+ 'id'=>'edit_form',
15
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
16
+ 'method'=>'post',
17
+ 'enctype' => 'multipart/form-data'
18
+ )
19
+ );
20
+ $form->setUseContainer(true);
21
+ $this->setForm($form);
22
+ return parent::_prepareForm();
23
+ }
24
+ }
app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Edit/Tab/Products.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Block_Adminhtml_Mostviewed_Edit_Tab_Products extends Mage_Adminhtml_Block_Widget_Form
9
+ {
10
+ public function __construct() {
11
+ parent::__construct();
12
+ $this->setTemplate('mostviewed/product.phtml');
13
+ }
14
+
15
+ public function getSkusArr($element){
16
+ return $element['sku'];
17
+ }
18
+
19
+ public function getSkusString() {
20
+ $store_id = Mage::app()->getRequest()->getParam('store',0);
21
+ $featuredCollection = Mage::getModel('mostviewed/mostviewed')->getCollection()->addFieldToFilter('store_id', array(array('finset' => $store_id)));
22
+ $product_skus_arr = array_map(array($this,"getSkusArr"), $featuredCollection->getData());
23
+ $product_skus = implode(", ",$product_skus_arr);
24
+ return $product_skus;
25
+ }
26
+
27
+ }
app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Edit/Tabs.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Block_Adminhtml_Mostviewed_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
9
+ {
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+ $this->setId('mostviewed_tabs');
14
+ $this->setDestElementId('edit_form');
15
+ $this->setTitle('Mostviewed Information');
16
+ }
17
+
18
+ protected function _beforeToHtml()
19
+ {
20
+ $this->addTab('product_section', array(
21
+ 'label' => Mage::helper('mostviewed')->__('Products'),
22
+ 'title' => Mage::helper('mostviewed')->__('Products'),
23
+ 'content' => $this->getLayout()->createBlock('mostviewed/adminhtml_mostviewed_edit_tab_products')->toHtml(),
24
+ ));
25
+
26
+ return parent::_beforeToHtml();
27
+ }
28
+ }
app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Grid.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Block_Adminhtml_Mostviewed_Grid extends Mage_Adminhtml_Block_Widget_Grid
9
+ {
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+ $this->setId('mostviewedGrid');
14
+ //$this->setDefaultSort('mostviewed_id');
15
+ $this->setDefaultSort('entity_id');
16
+ $this->setDefaultDir('ASC');
17
+ $this->setSaveParametersInSession(true);
18
+ $this->setUseAjax(true);
19
+ }
20
+
21
+ protected function _getStore()
22
+ {
23
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
24
+ return Mage::app()->getStore($storeId);
25
+ }
26
+
27
+
28
+ protected function _prepareCollection()
29
+ {
30
+ $store = $this->_getStore();
31
+ $product_skus = $this->getProductSkus();
32
+ $collection = Mage::getModel('catalog/product')->getCollection()
33
+ ->addAttributeToSelect('sku')
34
+ ->addAttributeToSelect('name')
35
+ ->addAttributeToSelect('attribute_set_id')
36
+ ->addAttributeToSelect('type_id')
37
+ ->addAttributeToFilter('sku', array('in' => $product_skus));
38
+ $adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
39
+ $collection->addStoreFilter($store);
40
+ $collection->joinAttribute(
41
+ 'name',
42
+ 'catalog_product/name',
43
+ 'entity_id',
44
+ null,
45
+ 'inner',
46
+ $adminStore
47
+ );
48
+ $collection->joinAttribute(
49
+ 'custom_name',
50
+ 'catalog_product/name',
51
+ 'entity_id',
52
+ null,
53
+ 'inner',
54
+ $store->getId()
55
+ );
56
+ $collection->joinAttribute(
57
+ 'status',
58
+ 'catalog_product/status',
59
+ 'entity_id',
60
+ null,
61
+ 'inner',
62
+ $store->getId()
63
+ );
64
+ $collection->joinAttribute(
65
+ 'visibility',
66
+ 'catalog_product/visibility',
67
+ 'entity_id',
68
+ null,
69
+ 'inner',
70
+ $store->getId()
71
+ );
72
+ $collection->joinAttribute(
73
+ 'price',
74
+ 'catalog_product/price',
75
+ 'entity_id',
76
+ null,
77
+ 'left',
78
+ $store->getId()
79
+ );
80
+
81
+ $this->setCollection($collection);
82
+ return parent::_prepareCollection();
83
+ }
84
+
85
+ protected function _prepareColumns()
86
+ {
87
+ $this->addColumn('entity_id',
88
+ array(
89
+ 'header'=> Mage::helper('catalog')->__('ID'),
90
+ 'width' => '50px',
91
+ 'type' => 'number',
92
+ 'index' => 'entity_id',
93
+ ));
94
+ $this->addColumn('name',
95
+ array(
96
+ 'header'=> Mage::helper('catalog')->__('Name'),
97
+ 'index' => 'name',
98
+ ));
99
+
100
+ $store = $this->_getStore();
101
+ if ($store->getId()) {
102
+ $this->addColumn('custom_name',
103
+ array(
104
+ 'header'=> Mage::helper('catalog')->__('Name in %s', $store->getName()),
105
+ 'index' => 'custom_name',
106
+ ));
107
+ }
108
+
109
+ $this->addColumn('type',
110
+ array(
111
+ 'header'=> Mage::helper('catalog')->__('Type'),
112
+ 'width' => '100px',
113
+ 'index' => 'type_id',
114
+ 'type' => 'options',
115
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
116
+ ));
117
+
118
+ $this->addColumn('sku',
119
+ array(
120
+ 'header'=> Mage::helper('catalog')->__('SKU'),
121
+ 'width' => '80px',
122
+ 'index' => 'sku',
123
+ ));
124
+
125
+ $store = $this->_getStore();
126
+ $this->addColumn('price',
127
+ array(
128
+ 'header'=> Mage::helper('catalog')->__('Price'),
129
+ 'type' => 'price',
130
+ 'currency_code' => $store->getBaseCurrency()->getCode(),
131
+ 'index' => 'price',
132
+ ));
133
+
134
+ return parent::_prepareColumns();
135
+ }
136
+
137
+
138
+
139
+ public function getSkusArr($element){
140
+ return $element['sku'];
141
+ }
142
+
143
+ public function getProductSkus(){
144
+ $store_id = Mage::app()->getRequest()->getParam('store',0);
145
+
146
+ $featuredCollection = Mage::getModel('mostviewed/mostviewed')->getCollection()->addFieldToFilter('store_id', array(array('finset' => $store_id)));
147
+ $product_skus=array_map(array($this,"getSkusArr"), $featuredCollection->getData());
148
+ return $product_skus;
149
+ }
150
+
151
+ //public function getRowUrl($row)
152
+ //{
153
+ //return $this->getUrl('*/*/edit', array('id' => $row->getId()));
154
+ //}
155
+
156
+ protected function _prepareMassaction()
157
+ {
158
+ $store_id = Mage::app()->getRequest()->getParam('store',0);
159
+ $url = $this->getUrl('*/*/massDelete',array('store'=>$store_id));
160
+
161
+ $this->setMassactionIdField('mostviewed_id');
162
+ $this->getMassactionBlock()->setFormFieldName('mostviewed');
163
+
164
+ $this->getMassactionBlock()->addItem('delete', array(
165
+ 'label' => Mage::helper('mostviewed')->__('Delete'),
166
+ 'url' => $url,
167
+ 'confirm' => Mage::helper('mostviewed')->__('Are you sure?')
168
+ ));
169
+
170
+ return $this;
171
+ }
172
+
173
+ public function getGridUrl()
174
+ {
175
+ return $this->getUrl('*/*/grid', array('_current'=>true));
176
+ }
177
+
178
+ }
app/code/community/CapacityWebSolutions/Mostviewed/Block/Mostviewed.php ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Block_Mostviewed extends Mage_Catalog_Block_Product_Abstract
9
+ {
10
+ /**
11
+ * Name of request parameter for page number value
12
+ */
13
+ const PAGE_VAR_NAME = 'np';
14
+
15
+ public function __construct() {
16
+ parent::_construct();
17
+ $this->addColumnCountLayoutDepend('empty', 6)
18
+ ->addColumnCountLayoutDepend('one_column', 5)
19
+ ->addColumnCountLayoutDepend('two_columns_left', 4)
20
+ ->addColumnCountLayoutDepend('two_columns_right', 4)
21
+ ->addColumnCountLayoutDepend('three_columns', 3);
22
+
23
+ $this->setStoreId(Mage::app()->getStore()->getId());
24
+
25
+ //General Settings
26
+ $this->setEnabled((bool)Mage::getStoreConfig("mostviewed/general/enabled"));
27
+ $this->setDisplayHeading((bool)Mage::getStoreConfig("mostviewed/general/display_heading"));
28
+ $this->setHeading(Mage::getStoreConfig("mostviewed/general/heading"));
29
+ $this->setChooseProducts(Mage::getStoreConfig("mostviewed/general/choose_products"));
30
+ $this->setDisplayBy(Mage::getStoreConfig("mostviewed/general/display_by"));
31
+ $this->setCategories(Mage::getStoreConfig("mostviewed/general/categories"));
32
+ $this->setSortBy(Mage::getStoreConfig("mostviewed/general/sort_by"));
33
+ $this->setSortOrder(Mage::getStoreConfig("mostviewed/general/sort_order"));
34
+ $this->setProductsPrice((bool)Mage::getStoreConfig("mostviewed/general/products_price"));
35
+ $this->setReview((bool)Mage::getStoreConfig("mostviewed/general/review"));
36
+ $this->setShortDesc((bool)Mage::getStoreConfig("mostviewed/general/short_desc"));
37
+ $this->setDescLimit((int)Mage::getStoreConfig("mostviewed/general/desc_limit"));
38
+ $this->setAddToCart((bool)Mage::getStoreConfig("mostviewed/general/add_to_cart"));
39
+ $this->setAddToWishlist((bool)Mage::getStoreConfig("mostviewed/general/add_to_wishlist"));
40
+ $this->setAddToCompare((bool)Mage::getStoreConfig("mostviewed/general/add_to_compare"));
41
+ $this->setOutOfStock((bool)Mage::getStoreConfig("mostviewed/general/out_of_stock"));
42
+ $this->setIsResponsive((bool)Mage::getStoreConfig('mostviewed/general/isresponsive'));
43
+
44
+ //Template Settings
45
+ $this->setCustomTemplate(Mage::getStoreConfig("mostviewed/template/select_template"));
46
+ $this->setProductsCount((int)Mage::getStoreConfig("mostviewed/template/number_of_items"));
47
+ $this->setShowPager((bool)Mage::getStoreConfig("mostviewed/template/show_pager"));
48
+ $this->setProductsPerPage((int)Mage::getStoreConfig("mostviewed/template/products_per_page"));
49
+ $this->setHeight((int)Mage::getStoreConfig("mostviewed/template/thumbnail_height"));
50
+ $this->setWidth((int)Mage::getStoreConfig("mostviewed/template/thumbnail_width"));
51
+ }
52
+
53
+ public function setWidgetOptions(){
54
+ //General Settings
55
+ $this->setDisplayHeading((bool)$this->getWdDisplayHeading());
56
+ $this->setHeading($this->getWdHeading());
57
+ $this->setChooseProducts($this->getWdChooseProducts());
58
+ $this->setDisplayBy((int)$this->getWdDisplayBy());
59
+ $this->setCategories($this->getWdCategories());
60
+ $this->setSortBy($this->getWdSortBy());
61
+ $this->setSortOrder($this->getWdSortOrder());
62
+ $this->setProductsPrice((bool)$this->getWdProductsPrice());
63
+ $this->setReview((bool)$this->getWdReview());
64
+ $this->setShortDesc((bool)$this->getWdShortDesc());
65
+ $this->setDescLimit((int)$this->getWdDescLimit());
66
+ $this->setAddToCart((bool)$this->getWdAddToCart());
67
+ $this->setAddToWishlist((bool)$this->getWdAddToWishlist());
68
+ $this->setAddToCompare((bool)$this->getWdAddToCompare());
69
+ $this->setOutOfStock((bool)$this->getWdOutOfStock());
70
+
71
+ //Template Settings
72
+ $this->setProductsCount((int)$this->getWdNumberOfItems());
73
+ $this->setShowPager((bool)$this->getWdShowPager());
74
+ $this->setProductsPerPage((int)$this->getWdProductsPerPage());
75
+ $this->setHeight((int)$this->getWdThumbnailHeight());
76
+ $this->setWidth((int)$this->getWdThumbnailWidth());
77
+ }
78
+
79
+ public function getIdsArr($element){
80
+ return $element['entity_id'];
81
+ }
82
+
83
+ protected function _getProductCollection() {
84
+ switch ($this->getChooseProducts()) {
85
+ case 1: //Auto
86
+ $collection = $this->_getAutoProductCollection();
87
+ break;
88
+ case 2: //Manually
89
+ $collection = $this->_getManuallyAddedProductsCollection();
90
+ break;
91
+ case 3: //Both
92
+ $collection1 = $this->_getAutoProductCollection();
93
+ $collection2 = $this->_getManuallyAddedProductsCollection();
94
+ $ids=array_map(array($this,"getIdsArr"), $collection1->getData());//for magento1.4
95
+ $merged_ids = array_unique(array_merge($ids, $collection2->getAllIds()));
96
+
97
+ $collection = Mage::getResourceModel('catalog/product_collection')
98
+ ->addFieldToFilter('entity_id', array('in' => $merged_ids))
99
+ ->addAttributeToSelect('*');
100
+ break;
101
+ default:
102
+ $collection = $this->_getAutoProductCollection();
103
+ break;
104
+ }
105
+
106
+ $storeId = Mage::app()->getStore()->getId();
107
+
108
+ $collection ->addMinimalPrice()
109
+ ->addFinalPrice()
110
+ ->setStore($storeId)
111
+ ->addStoreFilter($storeId)
112
+ ->setPageSize($this->getProductsCount())
113
+ ->setCurPage(1)
114
+ ;
115
+
116
+ //Display out of stock products
117
+ if(!$this->getOutOfStock()){
118
+ Mage::getSingleton('cataloginventory/stock')
119
+ ->addInStockFilterToCollection($collection);
120
+ }
121
+
122
+ //Display By Category
123
+ if($this->getDisplayBy()==2)
124
+ {
125
+ $categorytable = Mage::getSingleton('core/resource')->getTableName('catalog_category_product');
126
+ $collection->getSelect()
127
+ ->joinLeft(array('at_category_id' => $categorytable),'e.entity_id = at_category_id.product_id','at_category_id.category_id')
128
+ ->group('e.entity_id')
129
+ ->where("at_category_id.category_id IN (".$this->getCategories().")")
130
+ ;
131
+ }
132
+
133
+ //Set Sort Order
134
+ if($this->getSortOrder()=='rand'){
135
+ $collection->getSelect()->order('rand()');
136
+ }else{
137
+ $collection->addAttributeToSort($this->getSortBy(), $this->getSortOrder());
138
+ }
139
+
140
+ return $collection;
141
+ }
142
+
143
+ /**
144
+ * Prepare collection with new products
145
+ *
146
+ * @return Mage_Core_Block_Abstract
147
+ */
148
+ protected function _beforeToHtml(){
149
+ if($this->getType()=="mostviewed/widget")
150
+ {
151
+ $this->setWidgetOptions();
152
+ }
153
+ $this->setProductCollection($this->_getProductCollection());
154
+ }
155
+
156
+ //Get most viewed products collection
157
+ protected function _getAutoProductCollection(){
158
+ $storeId = Mage::app()->getStore()->getId();
159
+ /* $collection = Mage::getResourceModel('reports/product_collection')
160
+ ->addAttributeToSelect('*')
161
+ ->addViewsCount()
162
+ ->setStoreId($storeId)
163
+ ->addStoreFilter($storeId); */
164
+ $collection = Mage::getResourceModel('reports/product_collection')
165
+ // ->addOrderedQty()
166
+ ->addAttributeToSelect('*')
167
+ ->addViewsCount()
168
+ ->setStoreId($storeId)
169
+ ->addStoreFilter($storeId)
170
+ ;
171
+
172
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
173
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
174
+ $collection->getSelect()->where('cat_index.store_id ='.$storeId);
175
+ return $collection;
176
+ }
177
+
178
+ protected function _getManuallyAddedProductsCollection(){
179
+ /** @var $collection Mage_Catalog_Model_Resource_Product_Collection */
180
+ $collection = Mage::getResourceModel('catalog/product_collection');
181
+ $collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
182
+
183
+ $collection = $this->_addProductAttributesAndPrices($collection)
184
+ ->addAttributeToFilter('sku', array('in' => $this->getSkus()));
185
+ return $collection;
186
+ }
187
+
188
+ public function getSkusArr($element){
189
+ return $element['sku'];
190
+ }
191
+
192
+ public function getSkus(){
193
+ $store_id = $this->getStoreId();
194
+ $featuredCollection = Mage::getModel('mostviewed/mostviewed')->getCollection()->addFieldToFilter('store_id', array(array('finset' => $store_id)));
195
+ $product_skus=array_map(array($this,"getSkusArr"), $featuredCollection->getData());
196
+ return $product_skus;
197
+ }
198
+
199
+ public function limit_word($text, $limit) {
200
+ if (str_word_count($text, 0) > $limit) {
201
+ $words = str_word_count($text, 2);
202
+ $pos = array_keys($words);
203
+ $text = substr($text, 0, $pos[$limit]) . '...';
204
+ }
205
+ return $text;
206
+ }
207
+
208
+ public function _toHtml(){
209
+ if (!$this->getEnabled()) {
210
+ return '';
211
+ }
212
+ if(!$this->getTemplate()){
213
+ if($this->getCustomTemplate()==2){
214
+ $this->setTemplate('mostviewed/mostviewed-list.phtml');
215
+ }else{
216
+ $this->setTemplate('mostviewed/mostviewed-grid.phtml');
217
+ }
218
+ }
219
+ return parent::_toHtml();
220
+ }
221
+
222
+ /**
223
+ * Render pagination HTML
224
+ *
225
+ * @return string
226
+ */
227
+ public function getPagerHtml()
228
+ {
229
+ if ($this->getShowPager()) {
230
+ if (!$this->_pager) {
231
+ $this->_pager = $this->getLayout()
232
+ ->createBlock('mostviewed/widget_html_pager', 'widget.mostviewed.product.list.pager');
233
+
234
+ $this->_pager->setUseContainer(true)
235
+ ->setShowAmounts(true)
236
+ ->setShowPerPage(false)
237
+ ->setPageVarName(self::PAGE_VAR_NAME)
238
+ ->setLimit($this->getProductsPerPage())
239
+ ->setTotalLimit($this->getProductsCount())
240
+ ->setCollection($this->getProductCollection());
241
+ }
242
+ if ($this->_pager instanceof Mage_Core_Block_Abstract) {
243
+ return $this->_pager->toHtml();
244
+ }
245
+ }
246
+ return '';
247
+ }
248
+
249
+ }
app/code/community/CapacityWebSolutions/Mostviewed/Block/Promo/Widget/Chooser/Sku.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Block_Promo_Widget_Chooser_Sku extends Mage_Adminhtml_Block_Widget_Grid
9
+ {
10
+
11
+ public function __construct($arguments=array())
12
+ {
13
+ parent::__construct($arguments);
14
+
15
+ if ($this->getRequest()->getParam('current_grid_id')) {
16
+ $this->setId($this->getRequest()->getParam('current_grid_id'));
17
+ } else {
18
+ $this->setId('skuChooserGrid_'.$this->getId());
19
+ }
20
+
21
+ $form = $this->getJsFormObject();
22
+ $this->setRowClickCallback("$form.chooserGridRowClick.bind($form)");
23
+ $this->setCheckboxCheckCallback("$form.chooserGridCheckboxCheck.bind($form)");
24
+ $this->setRowInitCallback("$form.chooserGridRowInit.bind($form)");
25
+ $this->setDefaultSort('sku');
26
+ $this->setUseAjax(true);
27
+ if ($this->getRequest()->getParam('collapse')) {
28
+ $this->setIsCollapsed(true);
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Retrieve quote store object
34
+ * @return Mage_Core_Model_Store
35
+ */
36
+ public function getStore()
37
+ {
38
+ return Mage::app()->getStore();
39
+ }
40
+
41
+ protected function _addColumnFilterToCollection($column)
42
+ {
43
+ // Set custom filter for in product flag
44
+ if ($column->getId() == 'in_products') {
45
+ $selected = $this->_getSelectedProducts();
46
+ if (empty($selected)) {
47
+ $selected = '';
48
+ }
49
+ if ($column->getFilter()->getValue()) {
50
+ $this->getCollection()->addFieldToFilter('sku', array('in'=>$selected));
51
+ } else {
52
+ $this->getCollection()->addFieldToFilter('sku', array('nin'=>$selected));
53
+ }
54
+ } else {
55
+ parent::_addColumnFilterToCollection($column);
56
+ }
57
+ return $this;
58
+ }
59
+
60
+ /**
61
+ * Prepare Catalog Product Collection for attribute SKU in Promo Conditions SKU chooser
62
+ *
63
+ * @return Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku
64
+ */
65
+ protected function _prepareCollection()
66
+ {
67
+ $store_id = Mage::app()->getRequest()->getParam('store',0);
68
+ $collection = Mage::getResourceModel('catalog/product_collection')
69
+ //->setStoreId(0)
70
+ ->setStoreId($store_id)
71
+ ->addStoreFilter()
72
+ ->addAttributeToSelect('name', 'type_id', 'attribute_set_id');
73
+
74
+ $this->setCollection($collection);
75
+
76
+ return parent::_prepareCollection();
77
+ }
78
+
79
+ /**
80
+ * Define Cooser Grid Columns and filters
81
+ *
82
+ * @return Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku
83
+ */
84
+ protected function _prepareColumns()
85
+ {
86
+ $this->addColumn('in_products', array(
87
+ 'header_css_class' => 'a-center',
88
+ 'type' => 'checkbox',
89
+ 'name' => 'in_products',
90
+ 'values' => $this->_getSelectedProducts(),
91
+ 'align' => 'center',
92
+ 'index' => 'sku',
93
+ 'use_index' => true,
94
+ ));
95
+
96
+ $this->addColumn('entity_id', array(
97
+ 'header' => Mage::helper('sales')->__('ID'),
98
+ 'sortable' => true,
99
+ 'width' => '60px',
100
+ 'index' => 'entity_id'
101
+ ));
102
+
103
+ $this->addColumn('type',
104
+ array(
105
+ 'header'=> Mage::helper('catalog')->__('Type'),
106
+ 'width' => '60px',
107
+ 'index' => 'type_id',
108
+ 'type' => 'options',
109
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
110
+ ));
111
+
112
+ $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
113
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
114
+ ->load()
115
+ ->toOptionHash();
116
+
117
+ $this->addColumn('set_name',
118
+ array(
119
+ 'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
120
+ 'width' => '100px',
121
+ 'index' => 'attribute_set_id',
122
+ 'type' => 'options',
123
+ 'options' => $sets,
124
+ ));
125
+
126
+ $this->addColumn('chooser_sku', array(
127
+ 'header' => Mage::helper('sales')->__('SKU'),
128
+ 'name' => 'chooser_sku',
129
+ 'width' => '80px',
130
+ 'index' => 'sku'
131
+ ));
132
+ $this->addColumn('chooser_name', array(
133
+ 'header' => Mage::helper('sales')->__('Product Name'),
134
+ 'name' => 'chooser_name',
135
+ 'index' => 'name'
136
+ ));
137
+
138
+ return parent::_prepareColumns();
139
+ }
140
+
141
+ public function getGridUrl()
142
+ {
143
+ return $this->getUrl('*/*/chooser', array(
144
+ '_current' => true,
145
+ 'current_grid_id' => $this->getId(),
146
+ 'collapse' => null
147
+ ));
148
+ }
149
+
150
+ protected function _getSelectedProducts()
151
+ {
152
+ $products = $this->getRequest()->getPost('selected', array());
153
+
154
+ return $products;
155
+ }
156
+
157
+ }
158
+
app/code/community/CapacityWebSolutions/Mostviewed/Block/Widget.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Block_Widget extends CapacityWebSolutions_Mostviewed_Block_Mostviewed // Mage_Core_Block_Template
9
+ implements Mage_Widget_Block_Interface
10
+ {
11
+ public function addData(array $arr){
12
+ $this->_data = array_merge($this->_data, $arr);
13
+ }
14
+
15
+ public function setData($key, $value = null){
16
+ $this->_data[$key] = $value;
17
+ }
18
+
19
+ public function _toHtml(){
20
+ if($this->getData('template')){
21
+ $this->setTemplate($this->getData('template'));
22
+ }
23
+ return parent::_toHtml();
24
+ }
25
+ }
app/code/community/CapacityWebSolutions/Mostviewed/Block/Widget/Html/Pager.php ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Block_Widget_Html_Pager extends Mage_Page_Block_Html_Pager
9
+ {
10
+ /**
11
+ * Collection size
12
+ *
13
+ * Size of collection which may has a manual limitation
14
+ *
15
+ * @var int
16
+ */
17
+ protected $_collectionSize;
18
+
19
+ /**
20
+ * Current page
21
+ *
22
+ * @var int
23
+ */
24
+ protected $_currentPage;
25
+
26
+ /**
27
+ * Last page
28
+ *
29
+ * @var int
30
+ */
31
+ protected $_lastPage;
32
+
33
+ /**
34
+ * Return collection size
35
+ *
36
+ * It may be limited by manual
37
+ *
38
+ * @return int
39
+ */
40
+ public function getCollectionSize()
41
+ {
42
+ if (null === $this->_collectionSize) {
43
+ $this->_collectionSize = $this->getCollection()->getSize();
44
+ if ($this->getTotalLimit() && $this->_collectionSize > $this->getTotalLimit()) {
45
+ $this->_collectionSize = $this->getTotalLimit();
46
+ }
47
+ }
48
+ return $this->_collectionSize;
49
+ }
50
+
51
+ /**
52
+ * Return number of current page
53
+ *
54
+ * If current page is grate then total count of page current page will be equals total count of page
55
+ *
56
+ * @return int
57
+ */
58
+ public function getCurrentPage()
59
+ {
60
+ if (null === $this->_currentPage) {
61
+ $page = abs((int)$this->getRequest()->getParam($this->getPageVarName()));
62
+ if ($page > $this->getLastPageNum()) {
63
+ $this->_currentPage = $this->getLastPageNum();
64
+ } elseif ($page > 0) {
65
+ $this->_currentPage = $page;
66
+ } else {
67
+ $this->_currentPage = 1;
68
+ }
69
+ }
70
+ return $this->_currentPage;
71
+ }
72
+
73
+ /**
74
+ * Return items count per page
75
+ *
76
+ * @return int
77
+ */
78
+ public function getLimit()
79
+ {
80
+ if ($this->_limit > 0) {
81
+ return $this->_limit;
82
+ }
83
+ $limit = $this->getRequest()->getParam($this->getLimitVarName());
84
+ $limits = $this->getAvailableLimit();
85
+ if ($limit && isset($limits[$limit])) {
86
+ return $limit;
87
+ }
88
+ $limits = array_keys($limits);
89
+ return current($limits);
90
+ }
91
+
92
+ /**
93
+ * Connect collection to paging
94
+ *
95
+ * @param Mage_Core_Model_Resource_Db_Collection_Abstract $collection
96
+ * @return Mage_Catalog_Block_Product_Widget_Html_Pager
97
+ */
98
+ public function setCollection($collection)
99
+ {
100
+ $this->_collection = $collection;
101
+ $this->_collection->setPageSize(null)->setCurPage(null);
102
+
103
+ $collectionOffset = $this->getFirstNum() - 1;
104
+ $collectionLimit = $collectionOffset + $this->getLimit() > $this->getTotalNum()
105
+ ? $this->getTotalNum() - $collectionOffset
106
+ : $this->getLimit();
107
+
108
+ $this->_collection->getSelect()->limit($collectionLimit, $collectionOffset);
109
+ $this->_setFrameInitialized(false);
110
+ return $this;
111
+ }
112
+
113
+ /**
114
+ * Return position number in collection for first item on current page
115
+ *
116
+ * @return int
117
+ */
118
+ public function getFirstNum()
119
+ {
120
+ return $this->getLimit() * ($this->getCurrentPage() - 1) + 1;
121
+ }
122
+
123
+ /**
124
+ * Return position number in collection for last item on current page
125
+ *
126
+ * @return int
127
+ */
128
+ public function getLastNum()
129
+ {
130
+ $collection = $this->getCollection();
131
+ return $this->getLimit() * ($this->getCurrentPage() - 1) + $collection->count();
132
+ }
133
+
134
+ /**
135
+ * Return total number of collection
136
+ *
137
+ * It may be limited by manual
138
+ *
139
+ * @return int
140
+ */
141
+ public function getTotalNum()
142
+ {
143
+ return $this->getCollectionSize();
144
+ }
145
+
146
+ /**
147
+ * Return number of last page
148
+ *
149
+ * @return bool
150
+ */
151
+ public function getLastPageNum()
152
+ {
153
+ if (null === $this->_lastPage) {
154
+ $this->_lastPage = ceil($this->getCollectionSize() / $this->getLimit());
155
+ if ($this->_lastPage <= 0) {
156
+ $this->_lastPage = 1;
157
+ }
158
+ }
159
+ return $this->_lastPage;
160
+ }
161
+
162
+ /**
163
+ * Checks if current page is the first page
164
+ *
165
+ * @return bool
166
+ */
167
+ public function isFirstPage()
168
+ {
169
+ return $this->getCurrentPage() == 1;
170
+ }
171
+
172
+ /**
173
+ * Checks if current page is the last page
174
+ *
175
+ * @return bool
176
+ */
177
+ public function isLastPage()
178
+ {
179
+ return $this->getCurrentPage() >= $this->getLastPageNum();
180
+ }
181
+
182
+ /**
183
+ * Return array of pages
184
+ *
185
+ * @return array
186
+ */
187
+ public function getPages()
188
+ {
189
+ $pages = array();
190
+ if ($this->getLastPageNum() <= $this->_displayPages) {
191
+ $pages = range(1, $this->getLastPageNum());
192
+ } else {
193
+ $half = ceil($this->_displayPages / 2);
194
+ if ($this->getCurrentPage() >= $half && $this->getCurrentPage() <= $this->getLastPageNum() - $half) {
195
+ $start = ($this->getCurrentPage() - $half) + 1;
196
+ $finish = ($start + $this->_displayPages) - 1;
197
+ } elseif ($this->getCurrentPage() < $half) {
198
+ $start = 1;
199
+ $finish = $this->_displayPages;
200
+ } elseif ($this->getCurrentPage() > ($this->getLastPageNum() - $half)) {
201
+ $finish = $this->getLastPageNum();
202
+ $start = $finish - $this->_displayPages + 1;
203
+ }
204
+ $pages = range($start, $finish);
205
+ }
206
+ return $pages;
207
+ }
208
+
209
+ /**
210
+ * Retrieve url for previous page
211
+ *
212
+ * @return string
213
+ */
214
+ public function getPreviousPageUrl()
215
+ {
216
+ return $this->getPageUrl($this->getCurrentPage() - 1);
217
+ }
218
+
219
+ /**
220
+ * Retrieve url for next page
221
+ *
222
+ * @return string
223
+ */
224
+ public function getNextPageUrl()
225
+ {
226
+ return $this->getPageUrl($this->getCurrentPage() + 1);
227
+ }
228
+
229
+ /**
230
+ * Retrieve url for last page
231
+ *
232
+ * @return string
233
+ */
234
+ public function getLastPageUrl()
235
+ {
236
+ return $this->getPageUrl($this->getLastPageNum());
237
+ }
238
+
239
+ /**
240
+ * Initialize frame data, such as frame start, frame start etc.
241
+ *
242
+ * @return Mage_Catalog_Block_Product_Widget_Html_Pager
243
+ */
244
+ protected function _initFrame()
245
+ {
246
+ if (!$this->isFrameInitialized()) {
247
+ $start = 0;
248
+ $end = 0;
249
+
250
+ if ($this->getLastPageNum() <= $this->getFrameLength()) {
251
+ $start = 1;
252
+ $end = $this->getLastPageNum();
253
+ } else {
254
+ $half = ceil($this->getFrameLength() / 2);
255
+ if ($this->getCurrentPage() >= $half && $this->getCurrentPage() <= $this->getLastPageNum() - $half) {
256
+ $start = ($this->getCurrentPage() - $half) + 1;
257
+ $end = ($start + $this->getFrameLength()) - 1;
258
+ } elseif ($this->getCurrentPage() < $half) {
259
+ $start = 1;
260
+ $end = $this->getFrameLength();
261
+ } elseif ($this->getCurrentPage() > ($this->getLastPageNum() - $half)) {
262
+ $end = $this->getLastPageNum();
263
+ $start = $end - $this->getFrameLength() + 1;
264
+ }
265
+ }
266
+ $this->_frameStart = $start;
267
+ $this->_frameEnd = $end;
268
+ $this->_setFrameInitialized(true);
269
+ }
270
+
271
+ return $this;
272
+ }
273
+ }
app/code/community/CapacityWebSolutions/Mostviewed/Helper/Data.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Helper_Data extends Mage_Core_Helper_Abstract
9
+ {
10
+ public function getStoreViewIds(){
11
+ $allStores = Mage::app()->getStores();
12
+ foreach ($allStores as $_eachStoreId => $val){
13
+ $store_ids[] = Mage::app()->getStore($_eachStoreId)->getId();
14
+ }
15
+ return $store_ids;
16
+ }
17
+ }
app/code/community/CapacityWebSolutions/Mostviewed/Model/Mostviewed.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Model_Mostviewed extends Mage_Core_Model_Abstract
9
+ {
10
+ public function _construct()
11
+ {
12
+ parent::_construct();
13
+ $this->_init('mostviewed/mostviewed');
14
+ }
15
+ }
app/code/community/CapacityWebSolutions/Mostviewed/Model/Mysql4/Mostviewed.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Model_Mysql4_Mostviewed extends Mage_Core_Model_Mysql4_Abstract
9
+ {
10
+ public function _construct()
11
+ {
12
+ $this->_init('mostviewed/mostviewed', 'mostviewed_id');
13
+ }
14
+ }
app/code/community/CapacityWebSolutions/Mostviewed/Model/Mysql4/Mostviewed/Collection.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Model_Mysql4_Mostviewed_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
9
+ {
10
+ public function _construct()
11
+ {
12
+ parent::_construct();
13
+ $this->_init('mostviewed/mostviewed');
14
+ }
15
+
16
+ }
app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Category.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Model_System_Config_Source_Category
9
+ {
10
+ public function buildCategoriesMultiselectValues(Varien_Data_Tree_Node $node, $values, $level = 0)
11
+ {
12
+ $nonEscapableNbspChar = html_entity_decode('&#160;', ENT_NOQUOTES, 'UTF-8');
13
+
14
+ $level++;
15
+ if ($level > 2) {
16
+ $values[$node->getId()]['value'] = $node->getId();
17
+ $values[$node->getId()]['label'] = str_repeat($nonEscapableNbspChar, ($level - 3) * 5).$node->getName();
18
+ }
19
+
20
+ foreach ($node->getChildren() as $child) {
21
+ $values = $this->buildCategoriesMultiselectValues($child, $values, $level);
22
+ }
23
+
24
+ return $values;
25
+ }
26
+
27
+ public function toOptionArray()
28
+ {
29
+ $tree = Mage::getResourceSingleton('catalog/category_tree')->load();
30
+
31
+ $parentId = 1;
32
+
33
+ $root = $tree->getNodeById($parentId);
34
+
35
+ if($root && $root->getId() == 1) {
36
+ $root->setName(Mage::helper('catalog')->__('Root'));
37
+ }
38
+
39
+ $storeCode = Mage::app()->getRequest()->getParam('store',0);
40
+ $store_id = Mage::getModel('core/store')->load($storeCode, 'code')->getId();
41
+
42
+ $rootCategoryId = Mage::app()->getStore($store_id)->getRootCategoryId();
43
+
44
+ $category_model = Mage::getModel('catalog/category'); //get category model
45
+ $_category = $category_model->load($rootCategoryId );
46
+ $all_child_categories = $category_model->getResource()->getAllChildren($_category);
47
+
48
+ $collection = Mage::getModel('catalog/category')->getCollection()
49
+ ->addAttributeToSelect('name')
50
+ ->addAttributeToSelect('is_active');
51
+
52
+ if($storeCode){
53
+ $collection->addFieldToFilter('entity_id', array(array('in'=> $all_child_categories)));
54
+ }
55
+
56
+
57
+ $tree->addCollectionData($collection, true);
58
+
59
+ $values['---'] = array(
60
+ 'value' => '',
61
+ 'label' => '',
62
+ );
63
+ return $this->buildCategoriesMultiselectValues($root, $values);
64
+ }
65
+ }
app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Chooseproducts.php ADDED
@@ -0,0 +1 @@
 
0
  Extension Name : Mostviewed Products
1
  Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
2
  Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
3
  Support Email : support@magebees.com
4
  ***************************************************************************/
5
  {
6
  }
1
+ <?php
2
  Extension Name : Mostviewed Products
3
  Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
4
  Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
5
  Support Email : support@magebees.com
6
  ***************************************************************************/
7
  {
8
  }
app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Choosetype.php ADDED
@@ -0,0 +1 @@
 
0
  Extension Name : Mostviewed Products
1
  Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
2
  Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
3
  Support Email : support@magebees.com
4
  ***************************************************************************/
5
  {
6
  }
1
+ <?php
2
  Extension Name : Mostviewed Products
3
  Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
4
  Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
5
  Support Email : support@magebees.com
6
  ***************************************************************************/
7
  {
8
  }
app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Sortby.php ADDED
@@ -0,0 +1 @@
 
0
  Extension Name : Mostviewed Products
1
  Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
2
  Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
3
  Support Email : support@magebees.com
4
  ***************************************************************************/
5
  {
6
  }
1
+ <?php
2
  Extension Name : Mostviewed Products
3
  Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
4
  Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
5
  Support Email : support@magebees.com
6
  ***************************************************************************/
7
  {
8
  }
app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Sortorder.php ADDED
@@ -0,0 +1 @@
 
0
  Extension Name : Mostviewed Products
1
  Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
2
  Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
3
  Support Email : support@magebees.com
4
  ***************************************************************************/
5
  {
6
  }
1
+ <?php
2
  Extension Name : Mostviewed Products
3
  Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
4
  Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
5
  Support Email : support@magebees.com
6
  ***************************************************************************/
7
  {
8
  }
app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Template.php ADDED
@@ -0,0 +1 @@
 
0
  Extension Name : Mostviewed Products
1
  Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
2
  Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
3
  Support Email : support@magebees.com
4
  ***************************************************************************/
5
  {
6
  }
1
+ <?php
2
  Extension Name : Mostviewed Products
3
  Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
4
  Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
5
  Support Email : support@magebees.com
6
  ***************************************************************************/
7
  {
8
  }
app/code/community/CapacityWebSolutions/Mostviewed/controllers/Adminhtml/MostviewedController.php ADDED
@@ -0,0 +1,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Adminhtml_MostviewedController extends Mage_Adminhtml_Controller_Action {
9
+
10
+ protected function _initAction() {
11
+ $this->loadLayout()
12
+ ->_setActiveMenu('cws');
13
+ return $this;
14
+ }
15
+
16
+ public function indexAction() {
17
+ $this->_initAction()
18
+ ->renderLayout();
19
+ }
20
+
21
+ public function newAction() {
22
+ $this->_forward('edit');
23
+ }
24
+
25
+ public function editAction() {
26
+ $id = $this->getRequest()->getParam('id');
27
+ $model = Mage::getModel('mostviewed/mostviewed')->load($id);
28
+
29
+ if ($model->getMostviewedId() || $id == 0) {
30
+
31
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
32
+ if (!empty($data)) {
33
+ $model->setData($data);
34
+ }
35
+
36
+ Mage::register('mostviewed_data', $model);
37
+
38
+ $this->loadLayout();
39
+ $this->_setActiveMenu('cws');
40
+
41
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Mostviewed Products'), Mage::helper('adminhtml')->__('mostviewed Products'));
42
+
43
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
44
+
45
+ $this->_addContent($this->getLayout()->createBlock('mostviewed/adminhtml_mostviewed_edit'))
46
+ ->_addLeft($this->getLayout()->createBlock('mostviewed/adminhtml_mostviewed_edit_tabs'));
47
+
48
+ $this->renderLayout();
49
+ } else {
50
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('mostviewed')->__('Mostviewed Products does not exist'));
51
+ $this->_redirect('*/*/');
52
+ }
53
+ }
54
+
55
+ public function getSkusArr($element){
56
+ return $element['sku'];
57
+ }
58
+
59
+ public function getProductSkus($store_id=0){
60
+ $featuredCollection = Mage::getModel('mostviewed/mostviewed')->getCollection()->addFieldToFilter('store_id', array(array('finset' => $store_id)));
61
+ $product_skus=array_map(array($this,"getSkusArr"), $featuredCollection->getData());
62
+ return $product_skus;
63
+ }
64
+
65
+ public function saveAction() {
66
+ if ($data = $this->getRequest()->getPost()) {
67
+ $id = $this->getRequest()->getParam('id');
68
+ $store_id = $data['store_id'];
69
+ $product_skus = array();
70
+ if (isset($data['product_sku'])) {
71
+ $product_skus = explode(', ',$data['product_sku']);
72
+ }
73
+
74
+ try {
75
+ $store_ids_arr = array();
76
+
77
+ //if uncheck product sku
78
+ $old_skus_arr = $this->getProductSkus($store_id);
79
+ $sku_for_remove_arr = array();
80
+ $sku_for_remove_arr = array_diff($old_skus_arr,$product_skus);
81
+ if($sku_for_remove_arr){
82
+
83
+ foreach ($sku_for_remove_arr as $sku) {
84
+ $mostviewed = Mage::getModel('mostviewed/mostviewed')->load($sku,'sku');
85
+
86
+ if(!$store_id){//for all store views
87
+ $mostviewed->delete();
88
+ }else{
89
+ $new_store_ids_arr = array();
90
+ $old_store_ids = $mostviewed->getData('store_id');
91
+ $old_store_ids_arr = explode(",",$old_store_ids);
92
+ $new_store_ids_arr = array_diff($old_store_ids_arr,array($store_id));
93
+ $new_store_ids = implode(",",$new_store_ids_arr);
94
+
95
+ if(count($new_store_ids_arr)==1){
96
+
97
+ $mostviewed->delete();
98
+ }else{
99
+ $mostviewed->setData('sku',$sku);
100
+ $mostviewed->setData('store_id',$new_store_ids);
101
+ $mostviewed->save();
102
+ }
103
+ }
104
+ }
105
+ }
106
+ if(!empty($data['product_sku'])){
107
+ if(!$store_id){//for save sku all store views
108
+ $store_ids_arr = Mage::helper('mostviewed')->getStoreViewIds();//get all storeview ids;
109
+ array_push($store_ids_arr,0);
110
+ $store_ids = implode(",",$store_ids_arr);
111
+ foreach($product_skus as $sku){
112
+ if(!in_array($sku,$old_skus_arr)){
113
+ $model = Mage::getModel('mostviewed/mostviewed')->load($sku,'sku');
114
+ $model->setData('sku',$sku);
115
+ $model->setData('store_id',$store_ids);
116
+ $model->save();
117
+ }
118
+ }
119
+ }else{//for specific storeview
120
+ $store_ids_arr[] = $store_id;
121
+ array_push($store_ids_arr,0);
122
+ foreach($product_skus as $sku){
123
+ $model = Mage::getModel('mostviewed/mostviewed')->load($sku,'sku');
124
+ if($model->getId()){//sku exist
125
+ $old_store_ids = $model->getData('store_id');
126
+ $old_store_ids_arr = explode(",",$old_store_ids);
127
+ $new_store_ids_arr = array_unique(array_merge($old_store_ids_arr,$store_ids_arr));
128
+ $new_store_ids = implode(",",$new_store_ids_arr);
129
+ $model->setData('sku',$sku);
130
+ $model->setData('store_id',$new_store_ids);
131
+ $model->save();
132
+ }else{
133
+ $store_ids = implode(",",$store_ids_arr);
134
+ $model->setData('sku',$sku);
135
+ $model->setData('store_id',$store_ids);
136
+ $model->save();
137
+ }
138
+ }
139
+ }
140
+ }
141
+
142
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('mostviewed')->__('Mostviewed Products was successfully saved'));
143
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
144
+
145
+ if ($this->getRequest()->getParam('back')) {
146
+ //$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
147
+ $this->_redirectReferer();
148
+ return;
149
+ }
150
+ $this->_redirect('*/*/');
151
+ return;
152
+ } catch (Exception $e) {
153
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
154
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
155
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
156
+ return;
157
+ }
158
+ }
159
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('mostviewed')->__('Unable to find Mostviewed Products to save'));
160
+ $this->_redirect('*/*/');
161
+ }
162
+
163
+ public function massDeleteAction() {
164
+ $mostviewed_ids = $this->getRequest()->getParam('mostviewed');
165
+ $store_id = $this->getRequest()->getParam('store');
166
+ $skus_for_remove_arr = array();
167
+
168
+ if(!is_array($mostviewed_ids)) {
169
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
170
+ } else {
171
+ try {
172
+ foreach($mostviewed_ids as $id){
173
+ $skus_for_remove_arr[$id] = Mage::getModel('catalog/product')->load($id)->getSku();
174
+ }
175
+ foreach ($skus_for_remove_arr as $sku) {
176
+ $mostviewed = Mage::getModel('mostviewed/mostviewed')->load($sku,'sku');
177
+ if($mostviewed->isEmpty() && $store_id!=0){
178
+ Mage::getSingleton('adminhtml/session')->addError("Cannot delete. Please switch to All Store Views.");
179
+ $this->_redirectReferer();
180
+ return;
181
+ }
182
+ if(!$store_id){//for all store views
183
+ $mostviewed->delete();
184
+ }else{
185
+ $new_store_ids_arr = array();
186
+ $old_store_ids = $mostviewed->getData('store_id');
187
+ $old_store_ids_arr = explode(",",$old_store_ids);
188
+ $new_store_ids_arr = array_diff($old_store_ids_arr,array($store_id));
189
+ $new_store_ids = implode(",",$new_store_ids_arr);
190
+
191
+ if(count($new_store_ids_arr)==1){
192
+ $mostviewed->delete();
193
+ }else{
194
+ $mostviewed->setData('sku',$sku);
195
+ $mostviewed->setData('store_id',$new_store_ids);
196
+ $mostviewed->save();
197
+ }
198
+ }
199
+ }
200
+ Mage::getSingleton('adminhtml/session')->addSuccess(
201
+ Mage::helper('adminhtml')->__(
202
+ 'Total of %d record(s) were successfully deleted.', count($mostviewed_ids)
203
+ )
204
+ );
205
+ } catch (Exception $e) {
206
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
207
+ }
208
+ }
209
+ $this->_redirectReferer();
210
+ }
211
+
212
+ public function gridAction() {
213
+ $this->loadLayout();
214
+ $this->getResponse()->setBody(
215
+ $this->getLayout()->createBlock('mostviewed/adminhtml_mostviewed_grid')->toHtml()
216
+ );
217
+ }
218
+
219
+ }
app/code/community/CapacityWebSolutions/Mostviewed/controllers/Adminhtml/WidgetController.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Mostviewed_Adminhtml_WidgetController extends Mage_Adminhtml_Controller_Action
9
+ {
10
+ /**
11
+ * Prepare block for chooser
12
+ *
13
+ * @return void
14
+ */
15
+ public function chooserAction()
16
+ {
17
+ $request = $this->getRequest();
18
+ $block = $this->getLayout()->createBlock(
19
+ 'mostviewed/promo_widget_chooser_sku', 'promo_widget_chooser_sku',array('js_form_object' => $request->getParam('form'),
20
+ ));
21
+
22
+ if ($block) {
23
+ $this->getResponse()->setBody($block->toHtml());
24
+ }
25
+ }
26
+
27
+ protected function _isAllowed()
28
+ {
29
+ return Mage::getSingleton('admin/session')->isAllowed('cws');
30
+ }
31
+
32
+
33
+ }
app/code/community/CapacityWebSolutions/Mostviewed/etc/adminhtml.xml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <cws module="mostviewed">
5
+ <title>MageBees</title>
6
+ <sort_order>70</sort_order>
7
+ <children>
8
+ <mostviewed module="mostviewed">
9
+ <title>Most Viewed Products</title>
10
+ <sort_order>70</sort_order>
11
+ <children>
12
+ <groups module="mostviewed">
13
+ <title>Manage Most Viewed Products</title>
14
+ <sort_order>10</sort_order>
15
+ <action>adminhtml/mostviewed</action>
16
+ </groups>
17
+ <settings>
18
+ <title>Settings</title>
19
+ <sort_order>20</sort_order>
20
+ <action>adminhtml/system_config/edit/section/mostviewed</action>
21
+ </settings>
22
+ </children>
23
+ </mostviewed>
24
+ </children>
25
+ </cws>
26
+ </menu>
27
+ <acl>
28
+ <resources>
29
+ <admin>
30
+ <children>
31
+ <system>
32
+ <children>
33
+ <config>
34
+ <children>
35
+ <mostviewed>
36
+ <title>Most Viewed Products Section</title>
37
+ </mostviewed>
38
+ </children>
39
+ </config>
40
+ </children>
41
+ </system>
42
+ </children>
43
+ </admin>
44
+ </resources>
45
+ </acl>
46
+ </config>
app/code/community/CapacityWebSolutions/Mostviewed/etc/config.xml ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <CapacityWebSolutions_Mostviewed>
5
+ <version>1.0.0</version>
6
+ </CapacityWebSolutions_Mostviewed>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <mostviewed>
11
+ <class>CapacityWebSolutions_Mostviewed_Model</class>
12
+ <resourceModel>mostviewed_mysql4</resourceModel>
13
+ </mostviewed>
14
+ <mostviewed_mysql4>
15
+ <class>CapacityWebSolutions_Mostviewed_Model_Mysql4</class>
16
+ <entities>
17
+ <mostviewed>
18
+ <table>cws_mostviewed</table>
19
+ </mostviewed>
20
+ </entities>
21
+ </mostviewed_mysql4>
22
+ </models>
23
+ <resources>
24
+ <mostviewed_setup>
25
+ <setup>
26
+ <module>CapacityWebSolutions_Mostviewed</module>
27
+ </setup>
28
+ <connection>
29
+ <use>core_setup</use>
30
+ </connection>
31
+ </mostviewed_setup>
32
+ <mostviewed_write>
33
+ <connection>
34
+ <use>core_write</use>
35
+ </connection>
36
+ </mostviewed_write>
37
+ <mostviewed_read>
38
+ <connection>
39
+ <use>core_read</use>
40
+ </connection>
41
+ </mostviewed_read>
42
+ </resources>
43
+ <blocks>
44
+ <mostviewed>
45
+ <class>CapacityWebSolutions_Mostviewed_Block</class>
46
+ </mostviewed>
47
+ </blocks>
48
+ <helpers>
49
+ <mostviewed>
50
+ <class>CapacityWebSolutions_Mostviewed_Helper</class>
51
+ </mostviewed>
52
+ </helpers>
53
+ </global>
54
+ <frontend>
55
+ <routers>
56
+ <mostviewed>
57
+ <use>standard</use>
58
+ <args>
59
+ <module>CapacityWebSolutions_Mostviewed</module>
60
+ <frontName>mostviewed</frontName>
61
+ </args>
62
+ </mostviewed>
63
+ </routers>
64
+ <layout>
65
+ <updates>
66
+ <mostviewed>
67
+ <file>mostviewed.xml</file>
68
+ </mostviewed>
69
+ </updates>
70
+ </layout>
71
+ </frontend>
72
+
73
+ <admin>
74
+ <routers>
75
+ <adminhtml>
76
+ <args>
77
+ <modules>
78
+ <mostviewed before="Mage_Adminhtml">CapacityWebSolutions_Mostviewed_Adminhtml</mostviewed>
79
+ </modules>
80
+ </args>
81
+ </adminhtml>
82
+ </routers>
83
+ </admin>
84
+
85
+ <adminhtml>
86
+
87
+ <layout>
88
+ <updates>
89
+ <mostviewed>
90
+ <file>mostviewed.xml</file>
91
+ </mostviewed>
92
+ </updates>
93
+ </layout>
94
+
95
+ </adminhtml>
96
+ <default> <!-- Default text value set from admin-->
97
+ <mostviewed>
98
+ <general>
99
+ <enabled>1</enabled>
100
+ <isresponsive>1</isresponsive>
101
+ <display_heading>1</display_heading>
102
+ <heading>MOST VIEWED PRODUCTS</heading>
103
+ <choose_products>1</choose_products>
104
+ <display_by>1</display_by>
105
+ <sort_by>name</sort_by>
106
+ <sort_order>asc</sort_order>
107
+ <products_price>1</products_price>
108
+ <review>0</review>
109
+ <short_desc>0</short_desc>
110
+ <desc_limit>10</desc_limit>
111
+ <add_to_cart>1</add_to_cart>
112
+ <add_to_wishlist>0</add_to_wishlist>
113
+ <add_to_compare>0</add_to_compare>
114
+ <out_of_stock>0</out_of_stock>
115
+ </general>
116
+ <template>
117
+ <select_template>1</select_template>
118
+ <number_of_items>10</number_of_items>
119
+ <show_pager>0</show_pager>
120
+ <products_per_page>5</products_per_page>
121
+ <thumbnail_height>135</thumbnail_height>
122
+ <thumbnail_width>135</thumbnail_width>
123
+ </template>
124
+ </mostviewed>
125
+ </default>
126
+ </config>
app/code/community/CapacityWebSolutions/Mostviewed/etc/system.xml ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <cws>
5
+ <label>MageBees</label>
6
+ <sort_order>100</sort_order>
7
+ </cws>
8
+ </tabs>
9
+ <sections>
10
+ <mostviewed translate="label">
11
+ <class>separator-top</class>
12
+ <label>Most Viewed Products</label>
13
+ <tab>cws</tab>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>40</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <groups>
20
+ <code translate="label">
21
+ <label>Code</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>5</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <fields>
28
+ <xml translate="label comment">
29
+ <comment><![CDATA[]]></comment>
30
+ <label>XML Tag Representation</label>
31
+ <frontend_type>text</frontend_type>
32
+ <frontend_model>CapacityWebSolutions_Mostviewed_Block_Adminhtml_DefaultXML</frontend_model>
33
+ <sort_order>1</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ </xml>
36
+ <templated translate="label comment">
37
+ <comment><![CDATA[]]></comment>
38
+ <label>Template Tag Representation</label>
39
+ <frontend_type>text</frontend_type>
40
+ <frontend_model>CapacityWebSolutions_Mostviewed_Block_Adminhtml_DefaultTemplate</frontend_model>
41
+ <sort_order>2</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ </templated>
44
+ <direct translate="label comment">
45
+ <comment><![CDATA[]]></comment>
46
+ <label>Call Via Frontend Template File</label>
47
+ <frontend_type>text</frontend_type>
48
+ <frontend_model>CapacityWebSolutions_Mostviewed_Block_Adminhtml_DefaultDirectCode</frontend_model>
49
+ <sort_order>3</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ </direct>
52
+ </fields>
53
+ </code>
54
+ <general translate="label">
55
+ <label>General</label>
56
+ <frontend_type>text</frontend_type>
57
+ <sort_order>10</sort_order>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>1</show_in_store>
61
+ <fields>
62
+ <enabled translate="label">
63
+ <label>Enabled</label>
64
+ <comment><![CDATA[Select Yes for display the Mostviewed Products on frontend.]]></comment>
65
+ <source_model>adminhtml/system_config_source_yesno</source_model>
66
+ <frontend_type>select</frontend_type>
67
+ <sort_order>0</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ </enabled>
72
+ <isresponsive translate="label">
73
+ <label>Is Responsive Theme</label>
74
+ <comment><![CDATA[Select Yes for display Responsive Theme Template.]]></comment>
75
+ <source_model>adminhtml/system_config_source_yesno</source_model>
76
+ <frontend_type>select</frontend_type>
77
+ <sort_order>1</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>1</show_in_website>
80
+ <show_in_store>1</show_in_store>
81
+ </isresponsive>
82
+ <display_heading translate="label">
83
+ <label>Display Heading</label>
84
+ <comment><![CDATA[Select Yes for display page heading.]]></comment>
85
+ <source_model>adminhtml/system_config_source_yesno</source_model>
86
+ <frontend_type>select</frontend_type>
87
+ <sort_order>5</sort_order>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>1</show_in_store>
91
+ </display_heading>
92
+ <heading translate="label">
93
+ <label>Heading</label>
94
+ <comment><![CDATA[Set page heading.]]></comment>
95
+ <frontend_type>text</frontend_type>
96
+ <sort_order>10</sort_order>
97
+ <show_in_default>1</show_in_default>
98
+ <show_in_website>1</show_in_website>
99
+ <show_in_store>1</show_in_store>
100
+ <depends>
101
+ <display_heading>1</display_heading>
102
+ </depends>
103
+ <validate>required-entry</validate>
104
+ </heading>
105
+ <choose_products translate="label">
106
+ <label>Most Viewed Products</label>
107
+ <comment><![CDATA[Auto >> Show system generated products.<br>
108
+ Manually >> Show manually added products.<br>
109
+ Both >> Show both system generated and manually added products.]]>
110
+ </comment>
111
+ <source_model>mostviewed/system_config_source_chooseproducts</source_model>
112
+ <frontend_type>select</frontend_type>
113
+ <sort_order>15</sort_order>
114
+ <show_in_default>1</show_in_default>
115
+ <show_in_website>1</show_in_website>
116
+ <show_in_store>1</show_in_store>
117
+ </choose_products>
118
+ <display_by>
119
+ <label>Select Most Viewed Products Type</label>
120
+ <comment><![CDATA[You can display all products or display by categories.]]></comment>
121
+ <source_model>mostviewed/system_config_source_choosetype</source_model>
122
+ <frontend_type>select</frontend_type>
123
+ <sort_order>35</sort_order>
124
+ <show_in_default>1</show_in_default>
125
+ <show_in_website>1</show_in_website>
126
+ <show_in_store>1</show_in_store>
127
+ </display_by>
128
+ <categories translate="label">
129
+ <label>Categories</label>
130
+ <frontend_type>multiselect</frontend_type>
131
+ <source_model>mostviewed/system_config_source_category</source_model>
132
+ <sort_order>40</sort_order>
133
+ <show_in_default>1</show_in_default>
134
+ <show_in_website>1</show_in_website>
135
+ <show_in_store>1</show_in_store>
136
+ <depends>
137
+ <display_by>2</display_by>
138
+ </depends>
139
+ <validate>required-entry</validate>
140
+ </categories>
141
+ <sort_by>
142
+ <label>Sort By</label>
143
+ <comment><![CDATA[Set attribute that is initially used to sort the mostviewed products list.
144
+ ]]></comment>
145
+ <source_model>mostviewed/system_config_source_sortby</source_model>
146
+ <frontend_type>select</frontend_type>
147
+ <sort_order>43</sort_order>
148
+ <show_in_default>1</show_in_default>
149
+ <show_in_website>1</show_in_website>
150
+ <show_in_store>1</show_in_store>
151
+ </sort_by>
152
+ <sort_order>
153
+ <label>Sort Order</label>
154
+ <comment><![CDATA[If you select "Random" then Sort By atrributes is not applicable.]]></comment>
155
+ <source_model>mostviewed/system_config_source_sortorder</source_model>
156
+ <frontend_type>select</frontend_type>
157
+ <sort_order>44</sort_order>
158
+ <show_in_default>1</show_in_default>
159
+ <show_in_website>1</show_in_website>
160
+ <show_in_store>1</show_in_store>
161
+ </sort_order>
162
+ <products_price translate="label">
163
+ <label>Show Products Price</label>
164
+ <comment><![CDATA[Select Yes for display the Products' Price on frontend.]]></comment>
165
+ <source_model>adminhtml/system_config_source_yesno</source_model>
166
+ <frontend_type>select</frontend_type>
167
+ <sort_order>45</sort_order>
168
+ <show_in_default>1</show_in_default>
169
+ <show_in_website>1</show_in_website>
170
+ <show_in_store>1</show_in_store>
171
+ </products_price>
172
+
173
+ <review translate="label">
174
+ <label>Show Ratings</label>
175
+ <comment><![CDATA[Select Yes for display the Ratings on frontend.]]></comment>
176
+ <source_model>adminhtml/system_config_source_yesno</source_model>
177
+ <frontend_type>select</frontend_type>
178
+ <sort_order>50</sort_order>
179
+ <show_in_default>1</show_in_default>
180
+ <show_in_website>1</show_in_website>
181
+ <show_in_store>1</show_in_store>
182
+ </review>
183
+ <short_desc translate="label">
184
+ <label>Show Short Description</label>
185
+ <comment><![CDATA[Select Yes for display the Short Description on frontend.]]></comment>
186
+ <source_model>adminhtml/system_config_source_yesno</source_model>
187
+ <frontend_type>select</frontend_type>
188
+ <sort_order>55</sort_order>
189
+ <show_in_default>1</show_in_default>
190
+ <show_in_website>1</show_in_website>
191
+ <show_in_store>1</show_in_store>
192
+ </short_desc>
193
+ <desc_limit translate="label">
194
+ <label>Short Description Word Limit</label>
195
+ <comment><![CDATA[Set number of words display on frontend.]]></comment>
196
+ <frontend_type>text</frontend_type>
197
+ <sort_order>60</sort_order>
198
+ <show_in_default>1</show_in_default>
199
+ <show_in_website>1</show_in_website>
200
+ <show_in_store>1</show_in_store>
201
+ <depends>
202
+ <short_desc>1</short_desc>
203
+ </depends>
204
+ <validate>required-entry</validate>
205
+ </desc_limit>
206
+ <add_to_cart translate="label">
207
+ <label>Add to Cart</label>
208
+ <comment><![CDATA[Select Yes for display the "Add to Cart" button on frontend.]]></comment>
209
+ <source_model>adminhtml/system_config_source_yesno</source_model>
210
+ <frontend_type>select</frontend_type>
211
+ <sort_order>65</sort_order>
212
+ <show_in_default>1</show_in_default>
213
+ <show_in_website>1</show_in_website>
214
+ <show_in_store>1</show_in_store>
215
+ </add_to_cart>
216
+ <add_to_wishlist translate="label">
217
+ <label>Add to Wishlist</label>
218
+ <comment><![CDATA[Select Yes for display the "Add to Wishlist" link on frontend.]]></comment>
219
+ <frontend_type>select</frontend_type>
220
+ <source_model>adminhtml/system_config_source_yesno</source_model>
221
+ <sort_order>70</sort_order>
222
+ <show_in_default>1</show_in_default>
223
+ <show_in_website>1</show_in_website>
224
+ <show_in_store>1</show_in_store>
225
+ </add_to_wishlist>
226
+ <add_to_compare translate="label">
227
+ <label>Add to Compare</label>
228
+ <comment><![CDATA[Select Yes for display the "Add to Compare" link on frontend.]]></comment>
229
+ <source_model>adminhtml/system_config_source_yesno</source_model>
230
+ <frontend_type>select</frontend_type>
231
+ <sort_order>75</sort_order>
232
+ <show_in_default>1</show_in_default>
233
+ <show_in_website>1</show_in_website>
234
+ <show_in_store>1</show_in_store>
235
+ </add_to_compare>
236
+ <out_of_stock translate="label">
237
+ <label>Display out of stock items</label>
238
+ <comment><![CDATA[Select Yes for display the out of stock items on frontend.]]></comment>
239
+ <source_model>adminhtml/system_config_source_yesno</source_model>
240
+ <frontend_type>select</frontend_type>
241
+ <sort_order>80</sort_order>
242
+ <show_in_default>1</show_in_default>
243
+ <show_in_website>1</show_in_website>
244
+ <show_in_store>1</show_in_store>
245
+ </out_of_stock>
246
+ </fields>
247
+ </general>
248
+ <template>
249
+ <label>Template Settings</label>
250
+ <frontend_type>text</frontend_type>
251
+ <sort_order>40</sort_order>
252
+ <show_in_default>1</show_in_default>
253
+ <show_in_website>1</show_in_website>
254
+ <show_in_store>1</show_in_store>
255
+ <fields>
256
+ <select_template>
257
+ <label>Template</label>
258
+ <comment><![CDATA[Select template for mostviewed products list.]]></comment>
259
+ <source_model>mostviewed/system_config_source_template</source_model>
260
+ <frontend_type>select</frontend_type>
261
+ <sort_order>5</sort_order>
262
+ <show_in_default>1</show_in_default>
263
+ <show_in_website>1</show_in_website>
264
+ <show_in_store>1</show_in_store>
265
+ </select_template>
266
+ <number_of_items translate="label comment">
267
+ <label>Number of Products to Display</label>
268
+ <comment><![CDATA[Show Number of new products in main block.]]></comment>
269
+ <frontend_type>text</frontend_type>
270
+ <sort_order>10</sort_order>
271
+ <show_in_default>1</show_in_default>
272
+ <show_in_website>1</show_in_website>
273
+ <show_in_store>1</show_in_store>
274
+ <validate>required-entry</validate>
275
+ </number_of_items>
276
+ <show_pager translate="label comment">
277
+ <label>Display Page Control</label>
278
+ <comment><![CDATA[Show pagination and total number of items.]]></comment>
279
+ <source_model>adminhtml/system_config_source_yesno</source_model>
280
+ <frontend_type>select</frontend_type>
281
+ <sort_order>15</sort_order>
282
+ <show_in_default>1</show_in_default>
283
+ <show_in_website>1</show_in_website>
284
+ <show_in_store>1</show_in_store>
285
+ </show_pager>
286
+ <products_per_page translate="label comment">
287
+ <label>Number of Products per Page</label>
288
+ <comment><![CDATA[Show number of products per page.]]></comment>
289
+ <frontend_type>text</frontend_type>
290
+ <sort_order>20</sort_order>
291
+ <show_in_default>1</show_in_default>
292
+ <show_in_website>1</show_in_website>
293
+ <show_in_store>1</show_in_store>
294
+ <depends>
295
+ <show_pager>1</show_pager>
296
+ </depends>
297
+ <validate>required-entry</validate>
298
+ </products_per_page>
299
+ <thumbnail_height translate="label">
300
+ <label>Thumbnail Width</label>
301
+ <comment><![CDATA[Default Thumbnail Width: 135px]]></comment>
302
+ <frontend_type>text</frontend_type>
303
+ <sort_order>25</sort_order>
304
+ <show_in_default>1</show_in_default>
305
+ <show_in_website>1</show_in_website>
306
+ <show_in_store>1</show_in_store>
307
+ <validate>required-entry</validate>
308
+ </thumbnail_height>
309
+ <thumbnail_width translate="label">
310
+ <label>Thumbnail Height </label>
311
+ <comment><![CDATA[Default Thumbnail Height: 135px]]></comment>
312
+ <frontend_type>text</frontend_type>
313
+ <sort_order>30</sort_order>
314
+ <show_in_default>1</show_in_default>
315
+ <show_in_website>1</show_in_website>
316
+ <show_in_store>1</show_in_store>
317
+ <validate>required-entry</validate>
318
+ </thumbnail_width>
319
+ </fields>
320
+ </template>
321
+ </groups>
322
+ </mostviewed>
323
+ </sections>
324
+ </config>
app/code/community/CapacityWebSolutions/Mostviewed/etc/widget.xml ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <widgets>
3
+ <mostviewed type="mostviewed/widget">
4
+ <name>MageBees:Most Viewed Products Widget</name>
5
+ <parameters>
6
+ <template>
7
+ <values>
8
+ <list_default translate="label">
9
+ <value>mostviewed/column/mostviewed_default_list.phtml</value>
10
+ <label>Most Viewed Products Images and Names Template</label>
11
+ </list_default>
12
+ </values>
13
+ </template>
14
+ </parameters>
15
+ <supported_blocks>
16
+ <left_column>
17
+ <block_name>left</block_name>
18
+ <template>
19
+ <default>list_default</default>
20
+ </template>
21
+ </left_column>
22
+ <main_content>
23
+ <block_name>content</block_name>
24
+ <template>
25
+ <grid>grid_template</grid>
26
+ <list>list_template</list>
27
+ </template>
28
+ </main_content>
29
+ <right_column>
30
+ <block_name>right</block_name>
31
+ <template>
32
+ <default>list_default</default>
33
+ </template>
34
+ </right_column>
35
+ </supported_blocks>
36
+ <parameters>
37
+ <wd_display_heading translate="label">
38
+ <visible>1</visible>
39
+ <label>Display Heading</label>
40
+ <source_model>adminhtml/system_config_source_yesno</source_model>
41
+ <type>select</type>
42
+ <value>1</value>
43
+ </wd_display_heading>
44
+ <wd_heading translate="label">
45
+ <required>1</required>
46
+ <visible>1</visible>
47
+ <label>Heading</label>
48
+ <type>text</type>
49
+ <value>Most Viewed Products</value>
50
+ <depends>
51
+ <wd_display_heading><value>1</value></wd_display_heading>
52
+ </depends>
53
+ </wd_heading>
54
+ <wd_choose_products translate="label">
55
+ <visible>1</visible>
56
+ <label>Most Viewed Products</label>
57
+ <source_model>mostviewed/system_config_source_chooseproducts</source_model>
58
+ <type>select</type>
59
+ </wd_choose_products>
60
+ <wd_display_by>
61
+ <visible>1</visible>
62
+ <label>Select Most Viewed Products Type</label>
63
+ <source_model>mostviewed/system_config_source_choosetype</source_model>
64
+ <type>select</type>
65
+ </wd_display_by>
66
+ <wd_categories translate="label">
67
+ <required>1</required>
68
+ <visible>1</visible>
69
+ <label>Categories</label>
70
+ <type>multiselect</type>
71
+ <source_model>mostviewed/system_config_source_category</source_model>
72
+ <depends>
73
+ <wd_display_by><value>2</value></wd_display_by>
74
+ </depends>
75
+ </wd_categories>
76
+ <wd_sort_by>
77
+ <visible>1</visible>
78
+ <label>Sort By</label>
79
+ <source_model>mostviewed/system_config_source_sortby</source_model>
80
+ <type>select</type>
81
+ </wd_sort_by>
82
+ <wd_sort_order>
83
+ <visible>1</visible>
84
+ <label>Sort Order</label>
85
+ <source_model>mostviewed/system_config_source_sortorder</source_model>
86
+ <type>select</type>
87
+ </wd_sort_order>
88
+ <wd_products_price translate="label">
89
+ <visible>1</visible>
90
+ <label>Show Products Price</label>
91
+ <source_model>adminhtml/system_config_source_yesno</source_model>
92
+ <type>select</type>
93
+ </wd_products_price>
94
+ <wd_review translate="label">
95
+ <visible>1</visible>
96
+ <label>Show Ratings</label>
97
+ <source_model>adminhtml/system_config_source_yesno</source_model>
98
+ <type>select</type>
99
+ </wd_review>
100
+ <wd_short_desc translate="label">
101
+ <visible>1</visible>
102
+ <label>Show Short Description</label>
103
+ <source_model>adminhtml/system_config_source_yesno</source_model>
104
+ <type>select</type>
105
+ </wd_short_desc>
106
+ <wd_desc_limit translate="label">
107
+ <required>1</required>
108
+ <visible>1</visible>
109
+ <label>Short Description Word Limit</label>
110
+ <type>text</type>
111
+ <depends>
112
+ <wd_short_desc><value>1</value></wd_short_desc>
113
+ </depends>
114
+ <value>10</value>
115
+ </wd_desc_limit>
116
+ <wd_add_to_cart translate="label">
117
+ <visible>1</visible>
118
+ <label>Add to Cart</label>
119
+ <source_model>adminhtml/system_config_source_yesno</source_model>
120
+ <type>select</type>
121
+ </wd_add_to_cart>
122
+ <wd_add_to_wishlist translate="label">
123
+ <visible>1</visible>
124
+ <label>Add to Wishlist</label>
125
+ <type>select</type>
126
+ <source_model>adminhtml/system_config_source_yesno</source_model>
127
+ </wd_add_to_wishlist>
128
+ <wd_add_to_compare translate="label">
129
+ <visible>1</visible>
130
+ <label>Add to Compare</label>
131
+ <source_model>adminhtml/system_config_source_yesno</source_model>
132
+ <type>select</type>
133
+ </wd_add_to_compare>
134
+ <wd_out_of_stock translate="label">
135
+ <visible>1</visible>
136
+ <label>Display Out of Stock Products</label>
137
+ <source_model>adminhtml/system_config_source_yesno</source_model>
138
+ <type>select</type>
139
+ </wd_out_of_stock>
140
+ <wd_number_of_items translate="label comment">
141
+ <required>1</required>
142
+ <visible>1</visible>
143
+ <label>Number of Products to Display</label>
144
+ <type>text</type>
145
+ <value>10</value>
146
+ </wd_number_of_items>
147
+ <wd_show_pager translate="label comment">
148
+ <visible>1</visible>
149
+ <label>Display Page Control</label>
150
+ <source_model>adminhtml/system_config_source_yesno</source_model>
151
+ <type>select</type>
152
+ </wd_show_pager>
153
+ <wd_products_per_page translate="label comment">
154
+ <required>1</required>
155
+ <visible>1</visible>
156
+ <label>Number of Products per Page</label>
157
+ <type>text</type>
158
+ <depends>
159
+ <wd_show_pager><value>1</value></wd_show_pager>
160
+ </depends>
161
+ <value>5</value>
162
+ </wd_products_per_page>
163
+ <wd_thumbnail_height translate="label">
164
+ <required>1</required>
165
+ <visible>1</visible>
166
+ <label>Thumbnail Width</label>
167
+ <type>text</type>
168
+ <value>50</value>
169
+ </wd_thumbnail_height>
170
+ <wd_thumbnail_width translate="label">
171
+ <required>1</required>
172
+ <visible>1</visible>
173
+ <label>Thumbnail Height </label>
174
+ <type>text</type>
175
+ <value>50</value>
176
+ </wd_thumbnail_width>
177
+ <template>
178
+ <visible>1</visible>
179
+ <label>Template</label>
180
+ <type>select</type>
181
+ <value>mostviewed/mostviewed-grid.phtml</value>
182
+ <values>
183
+ <grid_template translate="label">
184
+ <value>mostviewed/mostviewed-grid.phtml</value>
185
+ <label>Grid Template</label>
186
+ </grid_template>
187
+ <list_template translate="label">
188
+ <value>mostviewed/mostviewed-list.phtml</value>
189
+ <label>List Template</label>
190
+ </list_template>
191
+ </values>
192
+ </template>
193
+ </parameters>
194
+ </mostviewed>
195
+ </widgets>
app/code/community/CapacityWebSolutions/Mostviewed/sql/mostviewed_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ CREATE TABLE IF NOT EXISTS `".$this->getTable('cws_mostviewed')."` (
10
+ `mostviewed_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
11
+ `sku` varchar(64) NOT NULL,
12
+ `store_id` text NOT NULL,
13
+ PRIMARY KEY (`mostviewed_id`),
14
+ KEY `IDX_MOSTVIEWED_PRODUCT_SKU` (`sku`)
15
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
16
+
17
+ ALTER TABLE `".$this->getTable('cws_mostviewed')."`
18
+ ADD CONSTRAINT `FK_MOSTVIEWED_PRODUCT_SKU` FOREIGN KEY (`sku`) REFERENCES `".$this->getTable('catalog_product_entity')."` (`sku`) ON DELETE CASCADE ON UPDATE CASCADE;
19
+ ");
20
+
21
+ if(in_array($this->getTable('permission_block'),$installer->getConnection()->listTables())){
22
+ $installer->run("
23
+ INSERT INTO {$this->getTable('permission_block')} (block_name,is_allowed) values ('mostviewed/mostviewed','1');
24
+ ");
25
+ }
26
+
27
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/mostviewed.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <adminhtml_mostviewed_index>
4
+ <reference name="content">
5
+ <block type="mostviewed/adminhtml_mostviewed" name="mostviewed" />
6
+ </reference>
7
+ </adminhtml_mostviewed_index>
8
+ <adminhtml_mostviewed_edit>
9
+ <reference name="head">
10
+ <action method="addJs"><script>mostviewed/product-selector.js</script></action>
11
+ </reference>
12
+ <reference name="left">
13
+ <block type="adminhtml/store_switcher" name="store_switcher" before="-"></block>
14
+
15
+ </reference>
16
+ </adminhtml_mostviewed_edit>
17
+ </layout>
app/design/adminhtml/default/default/template/mostviewed/product.phtml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ ?>
9
+ <style>
10
+ .product-param label { padding-right: 10px; }
11
+ .product-param .label { color: black; font-weight: bold; }
12
+ .product-param .label:hover { color: blue; font-weight: bold; }
13
+ .product-param .element { display: none; }
14
+ .product-param input, .product-param select { min-width: 350px; width: auto !important; }
15
+ .product-param-edit .label { display: none; }
16
+ .product-param-edit .element { display: inline; }
17
+ .product-chooser { border: 1px solid #CCC; display: none; margin: 10px 0; padding: 5px; }
18
+ .display-default {display: inline;}
19
+ </style>
20
+ <?php $store_id = Mage::app()->getRequest()->getParam('store',0);?>
21
+ <input type="hidden" name="store_id" id="store_id" value="<?php echo $store_id ?>">
22
+ <div class="entry-edit">
23
+ <div class="entry-edit-head">
24
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('mostviewed')->__('Manually Products') ?></h4>
25
+ </div>
26
+ <fieldset id="product_fieldset">
27
+ <ul>
28
+ <li>
29
+ <span class="product-param">
30
+ <label for="product_sku"><?php echo Mage::helper('mostviewed')->__('Select Mostviewed Product SKUs') ?></label>
31
+ <a class="label" href="javascript:void(0)"><?php if($this->getSkusString()) { echo $this->getSkusString(); } else { echo Mage::helper('mostviewed')->__('Click Here To Add Products'); } ?></a>
32
+ <span class="element">
33
+ <input id="product_sku" class="input-text element-value-changer" type="text" value="<?php echo $this->getSkusString() ?>" name="product_sku">
34
+ <a class="product-chooser-trigger" href="javascript:void(0)">
35
+ <img id="chooser" src="<?php echo Mage::getDesign()->getSkinUrl('images/rule_chooser_trigger.gif') ?>" alt="" class="v-middle product-chooser-trigger" title="<?php echo Mage::helper('mostviewed')->__('Open Chooser') ?>" />
36
+ </a>
37
+ </span>
38
+ </span>
39
+ <div id="product-grid" class="product-chooser" url="<?php echo Mage::getUrl('adminhtml/widget/chooser/attribute/sku/form/rule_conditions_fieldset', array('_secure' => Mage::app()->getStore()->isAdminUrlSecure(),'store'=>$store_id)); ?>">
40
+ </div>
41
+ </li>
42
+ </ul>
43
+ </fieldset>
44
+ </div>
45
+
46
+ <script type="text/javascript">
47
+ var rule_conditions_fieldset = new VarienRulesForm('product_fieldset', '<?php echo Mage::getUrl('/admin/promo_catalog/newConditionHtml/form/rule_conditions_fieldset/', array('_secure' => Mage::app()->getStore()->isAdminUrlSecure())) ?>');
48
+ </script>
app/design/frontend/base/default/layout/mostviewed.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addItem" ifconfig="mostviewed/general/enabled"><type>skin_css</type><name>css/mostviewed/mostviewed.css</name><params/></action>
6
+ </reference>
7
+ </default>
8
+ </layout>
app/design/frontend/base/default/template/mostviewed/column/mostviewed_default_list-default.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ ?>
9
+ <?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
10
+ <div class="widget widget-new-products">
11
+ <div class="block block-products">
12
+ <?php if($this->getDisplayHeading()): ?>
13
+ <div class="block-title">
14
+ <strong><span><?php echo $this->__($this->getHeading()) ?></span></strong>
15
+ </div>
16
+ <?php endif; ?>
17
+ <div class="block-content">
18
+ <?php echo $this->getPagerHtml() ?>
19
+ <?php $suffix = $this->getNameInLayout(); ?>
20
+ <ol class="mini-products-list" id="widget-new-products-<?php echo $suffix; ?>">
21
+ <?php foreach ($_products->getItems() as $_product): ?>
22
+ <li class="item">
23
+ <a class="product-image" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize($this->getWidth(),$this->getHeight()) ?>" width="<?php echo $this->getWidth() ?>" height="<?php echo $this->getHeight() ?>" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" /></a>
24
+ <div class="product-details">
25
+ <p class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>)"><?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName() , 'name') ?></a></p>
26
+ <?php echo $this->getPriceHtml($_product, true, '-widget-new-'.$suffix) ?>
27
+ <?php if ($_product->getIsSalable()): ?>
28
+ <a href="<?php echo $this->getAddToCartUrl($_product) ?>" class="link-cart"><?php echo $this->__('Add to Cart') ?></a>
29
+ <?php else: ?>
30
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
31
+ <?php endif; ?>
32
+ </div>
33
+ </li>
34
+ <?php endforeach; ?>
35
+ </ol>
36
+ <script type="text/javascript">decorateList('widget-new-products-<?php echo $suffix; ?>', 'none-recursive')</script>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ <?php endif; ?>
app/design/frontend/base/default/template/mostviewed/column/mostviewed_default_list.phtml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ ?>
9
+ <?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
10
+ <div class="widget widget-new-products">
11
+ <div class="block block-products">
12
+ <?php if($this->getDisplayHeading()): ?>
13
+ <div class="block-title">
14
+ <strong><span><?php echo $this->__($this->getHeading()) ?></span></strong>
15
+ </div>
16
+ <?php endif; ?>
17
+ <div class="block-content">
18
+ <?php echo $this->getPagerHtml() ?>
19
+ <?php $suffix = $this->getNameInLayout(); ?>
20
+ <ol class="mini-products-list" id="widget-new-products-<?php echo $suffix; ?>">
21
+ <?php foreach ($_products->getItems() as $_product): ?>
22
+ <li class="item">
23
+ <a class="product-image" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize($this->getWidth(),$this->getHeight()) ?>" width="<?php echo $this->getWidth() ?>" height="<?php echo $this->getHeight() ?>" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" /></a>
24
+ <div class="product-details">
25
+ <p class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>)"><?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName() , 'name') ?></a></p>
26
+ <?php /* Removing this functionality from RWD
27
+ <?php echo $this->getPriceHtml($_product, true, '-widget-new-'.$suffix) ?>
28
+ <?php if ($_product->getIsSalable()): ?>
29
+ <a href="<?php echo $this->getAddToCartUrl($_product) ?>" class="link-cart"><?php echo $this->__('Add to Cart') ?></a>
30
+ <?php else: ?>
31
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
32
+ <?php endif; ?>
33
+ */ ?>
34
+ </div>
35
+ </li>
36
+ <?php endforeach; ?>
37
+ </ol>
38
+ <script type="text/javascript">decorateList('widget-new-products-<?php echo $suffix; ?>', 'none-recursive')</script>
39
+ </div>
40
+ </div>
41
+ </div>
42
+ <?php endif; ?>
app/design/frontend/base/default/template/mostviewed/mostviewed-grid.phtml ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ ?>
9
+ <?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
10
+ <div class="mostViewed">
11
+ <?php if($this->getDisplayHeading()): ?>
12
+ <div class="title">
13
+ <h2><?php echo $this->__($this->getHeading()) ?></h2>
14
+ </div>
15
+ <?php endif; ?>
16
+
17
+ <?php if(!$this->getIsResponsive()): ?>
18
+ <?php //for default theme(Non Responsive theme) ?>
19
+ <?php echo $this->getPagerHtml() ?>
20
+ <?php $_columnCount = $this->getColumnCount(); ?>
21
+ <?php $i=0; foreach ($_products->getItems() as $_product): ?>
22
+ <?php if ($i++%$_columnCount==0): ?>
23
+ <ul class="products-grid ">
24
+ <?php endif ?>
25
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
26
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image">
27
+ <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($this->getWidth(),$this->getHeight()) ?>" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" />
28
+ </a>
29
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>)"><?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName() , 'name') ?></a></h2>
30
+ <?php if($this->getReview()): ?>
31
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
32
+ <?php endif; ?>
33
+ <?php if($this->getProductsPrice()): ?>
34
+ <?php echo $this->getPriceHtml($_product, true, '-widget-new-grid') ?>
35
+ <?php endif; ?>
36
+ <?php if($this->getShortDesc()): ?>
37
+ <div class="desc std">
38
+ <?php
39
+ $short_desc = $this->htmlEscape($_product->getShortDescription());
40
+ echo $this->limit_word($short_desc,$this->getDescLimit());
41
+ ?>
42
+ </div>
43
+ <?php endif; ?>
44
+ <div class="actions" style="display:block">
45
+ <?php if($this->getAddToCart()): ?>
46
+ <?php if ($_product->isSaleable()): ?>
47
+ <button type="button" title="<?php echo Mage::helper('core')->htmlEscape($this->__('Add to Cart')) ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
48
+ <?php else: ?>
49
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
50
+ <?php endif; ?>
51
+ <?php endif; ?>
52
+ <?php if($this->getAddToWishlist() || $this->getAddToCompare()): ?>
53
+ <ul class="add-to-links">
54
+ <?php if($this->getAddToWishlist()): ?>
55
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
56
+ <li><a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
57
+ <?php endif; ?>
58
+ <?php endif; ?>
59
+ <?php if($this->getAddToCompare()): ?>
60
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
61
+ <li>
62
+ <?php if($this->getAddToWishlist()): ?>
63
+ <span class="separator">|</span>
64
+ <?php endif; ?>
65
+ <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
66
+ <?php endif; ?>
67
+ <?php endif; ?>
68
+ </ul>
69
+ <?php endif; ?>
70
+ </div>
71
+ </li>
72
+ <?php if ($i%$_columnCount==0 || $i==count($_products)): ?>
73
+ </ul>
74
+ <?php endif ?>
75
+ <?php endforeach; ?>
76
+ <?php else: ?>
77
+ <?php //for responsive theme ?>
78
+ <?php echo $this->getPagerHtml() ?>
79
+ <?php $_columnCount = $this->getColumnCount(); ?>
80
+ <?php $i=0; ?>
81
+ <ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col rwd">
82
+ <?php foreach ($_products->getItems() as $_product): ?>
83
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
84
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image">
85
+ <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($this->getWidth(),$this->getHeight()) ?>" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" />
86
+ </a>
87
+ <div class="product-info">
88
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName() , 'name') ?></a></h2>
89
+ <?php if($this->getProductsPrice()): ?>
90
+ <?php echo $this->getPriceHtml($_product, true, '-widget-new-grid') ?>
91
+ <?php endif; ?>
92
+ <?php if($this->getReview()): ?>
93
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
94
+ <?php endif; ?>
95
+ <?php if($this->getShortDesc()): ?>
96
+ <div class="desc std">
97
+ <?php
98
+ $short_desc = $this->htmlEscape($_product->getShortDescription());
99
+ echo $this->limit_word($short_desc,$this->getDescLimit());
100
+ ?>
101
+ </div>
102
+ <?php endif; ?>
103
+ <div class="actions" style="display:block !important">
104
+ <?php if($this->getAddToCart()): ?>
105
+ <?php if($_product->isSaleable()): ?>
106
+ <button class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')">
107
+ <span><?php echo $this->__('Add to Cart') ?></span>
108
+ </button>
109
+ <?php elseif($_product->isSaleable()): ?>
110
+ <button class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')">
111
+ <span><?php echo $this->__('View Details')?></span>
112
+ </button>
113
+ <?php else: ?>
114
+ <span class="out-of-stock">
115
+ <?php echo $this->__('Out of stock') ?>
116
+ </span>
117
+ <?php endif; ?>
118
+ <?php endif; ?>
119
+ <?php if($this->getAddToWishlist() || $this->getAddToCompare()): ?>
120
+ <ul class="add-to-links">
121
+ <?php if($this->getAddToWishlist()): ?>
122
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
123
+ <li><a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
124
+ <?php endif; ?>
125
+ <?php endif; ?>
126
+ <?php if($this->getAddToCompare()): ?>
127
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
128
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
129
+ <?php endif; ?>
130
+ <?php endif; ?>
131
+ </ul>
132
+ <?php endif; ?>
133
+ </div>
134
+ </div>
135
+ </li>
136
+ <?php endforeach; ?>
137
+ </ul>
138
+ <?php endif; ?>
139
+ </div>
140
+ <?php endif; ?>
app/design/frontend/base/default/template/mostviewed/mostviewed-list.phtml ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Mostviewed Products
4
+ Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ ?>
9
+ <?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
10
+ <div class="mostViewed">
11
+ <?php if($this->getDisplayHeading()): ?>
12
+ <div class="title">
13
+ <h2><?php echo $this->__($this->getHeading()) ?></h2>
14
+ </div>
15
+ <?php endif; ?>
16
+
17
+ <?php if(!$this->getIsResponsive()): ?>
18
+ <?php //for default theme(Non Responsive theme) ?>
19
+ <?php echo $this->getPagerHtml() ?>
20
+ <ul class="products-list default">
21
+ <?php $i=0; foreach ($_products->getItems() as $_product): ?>
22
+ <li class="item<?php echo (++$i == count($_products))?' last':''; ?>">
23
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image">
24
+ <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize( $this->getWidth(),$this->getHeight() ) ?>" width="<?php echo $this->getWidth() ?>" height="<?php echo $this->getHeight() ?>" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" />
25
+ </a>
26
+ <div class="product-shop">
27
+ <div class="f-fix">
28
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>)"><?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName() , 'name') ?></a></h2>
29
+ <?php if($this->getReview()): ?>
30
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
31
+ <?php endif; ?>
32
+ <?php if($this->getProductsPrice()): ?>
33
+ <?php echo $this->getPriceHtml($_product, true, '-widget-new-list') ?>
34
+ <?php endif; ?>
35
+
36
+ <?php if($this->getAddToCart()): ?>
37
+ <?php if ($_product->isSaleable()): ?>
38
+ <p><button type="button" title="<?php echo Mage::helper('core')->htmlEscape($this->__('Add to Cart')) ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
39
+ <?php else: ?>
40
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
41
+ <?php endif; ?>
42
+ <?php endif; ?>
43
+
44
+ <?php if($this->getShortDesc()): ?>
45
+ <div class="desc std">
46
+ <?php
47
+ $short_desc = $this->htmlEscape($_product->getShortDescription());
48
+ echo $this->limit_word($short_desc,$this->getDescLimit());
49
+ ?>
50
+ </div>
51
+ <?php endif; ?>
52
+ <?php if($this->getAddToWishlist() || $this->getAddToCompare()): ?>
53
+ <ul class="add-to-links">
54
+ <?php if($this->getAddToWishlist()): ?>
55
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
56
+ <li><a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
57
+ <?php endif; ?>
58
+ <?php endif; ?>
59
+ <?php if($this->getAddToCompare()): ?>
60
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
61
+ <li>
62
+ <?php if($this->getAddToWishlist()): ?>
63
+ <span class="separator">|</span>
64
+ <?php endif; ?>
65
+ <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
66
+ <?php endif; ?>
67
+ <?php endif; ?>
68
+ </ul>
69
+ <?php endif; ?>
70
+ </div>
71
+ </div>
72
+ </li>
73
+ <?php endforeach; ?>
74
+ </ul>
75
+ <?php else: ?>
76
+ <?php //for responsive theme ?>
77
+ <?php echo $this->getPagerHtml() ?>
78
+ <ul class="products-list rwd">
79
+ <?php $i=0; foreach ($_products->getItems() as $_product): ?>
80
+ <li class="item<?php echo (++$i == count($_products))?' last':''; ?>">
81
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image">
82
+ <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($this->getWidth(),$this->getHeight()) ?>" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" />
83
+ </a>
84
+ <div class="product-shop">
85
+ <div class="f-fix">
86
+ <div class="product-primary">
87
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>)"><?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName() , 'name') ?></a></h2>
88
+ <?php if($this->getReview()): ?>
89
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
90
+ <?php endif; ?>
91
+ </div>
92
+ <div class="product-secondary">
93
+ <?php if($this->getProductsPrice()): ?>
94
+ <?php echo $this->getPriceHtml($_product, true, '-widget-new-list') ?>
95
+ <?php endif; ?>
96
+ </div>
97
+ <div class="product-secondary">
98
+ <?php if($this->getAddToCart()): ?>
99
+ <?php if($_product->isSaleable()): ?>
100
+ <button class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')">
101
+ <span><?php echo $this->__('Add to Cart') ?></span>
102
+ </button>
103
+ <?php elseif($_product->isSaleable()): ?>
104
+ <button class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')">
105
+ <span><?php echo $this->__('View Details')?></span>
106
+ </button>
107
+ <?php else: ?>
108
+ <span class="out-of-stock">
109
+ <?php echo $this->__('Out of stock') ?>
110
+ </span>
111
+ <?php endif; ?>
112
+ <?php endif; ?>
113
+ <?php if($this->getAddToWishlist() || $this->getAddToCompare()): ?>
114
+ <ul class="add-to-links">
115
+ <?php if($this->getAddToWishlist()): ?>
116
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
117
+ <li><a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
118
+ <?php endif; ?>
119
+ <?php endif; ?>
120
+ <?php if($this->getAddToCompare()): ?>
121
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
122
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
123
+ <?php endif; ?>
124
+ <?php endif; ?>
125
+ </ul>
126
+ <?php endif; ?>
127
+ </div>
128
+ <?php if($this->getShortDesc()): ?>
129
+ <div class="desc std">
130
+ <?php
131
+ $short_desc = $this->htmlEscape($_product->getShortDescription());
132
+ echo $this->limit_word($short_desc,$this->getDescLimit());
133
+ ?>
134
+ </div>
135
+ <?php endif; ?>
136
+ </div>
137
+ </div>
138
+ </li>
139
+ <?php endforeach; ?>
140
+ </ul>
141
+ <?php endif; ?>
142
+ </div>
143
+ <?php endif; ?>
app/etc/modules/CapacityWebSolutions_Mostviewed.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <CapacityWebSolutions_Mostviewed>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </CapacityWebSolutions_Mostviewed>
8
+ </modules>
9
+ </config>
js/mostviewed/product-selector.js ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var VarienRulesForm = new Class.create();
2
+ VarienRulesForm.prototype = {
3
+ initialize : function(parent, newChildUrl){
4
+ this.parent = $(parent);
5
+ this.newChildUrl = newChildUrl;
6
+ this.shownElement = null;
7
+ this.updateElement = null;
8
+ this.chooserSelectedItems = $H({});
9
+
10
+ var elems = this.parent.getElementsByClassName('product-param');
11
+ for (var i=0; i<elems.length; i++) {
12
+ this.initParam(elems[i]);
13
+ }
14
+
15
+ var elems = this.parent.getElementsByClassName('product-param');
16
+ for (var i=0; i<elems.length; i++) {
17
+ var container = elems[i];
18
+ }
19
+ },
20
+
21
+ initParam: function (container) {
22
+ container.rulesObject = this;
23
+ var label = Element.down(container, '.label');
24
+ if (label) {
25
+ Event.observe(label, 'click', this.showParamInputField.bind(this, container));
26
+ }
27
+ var elem = Element.down(container, '.element');
28
+ if (elem) {
29
+ var trig = elem.down('.product-chooser-trigger');
30
+ if (trig) {
31
+ Event.observe(trig, 'click', this.toggleChooser.bind(this, container));
32
+ }
33
+ }
34
+ },
35
+
36
+ showChooserElement: function (chooser) {
37
+ this.chooserSelectedItems = $H({});
38
+ var values = this.updateElement.value.split(','), s = '';
39
+ for (i=0; i<values.length; i++) {
40
+ s = values[i].strip();
41
+ if (s!='') {
42
+ this.chooserSelectedItems.set(s,1);
43
+ }
44
+ }
45
+ new Ajax.Request(chooser.getAttribute('url'), {
46
+ evalScripts: true,
47
+ parameters: {'form_key': FORM_KEY, 'selected[]':this.chooserSelectedItems.keys() },
48
+ onSuccess: function(transport) {
49
+ if (this._processSuccess(transport)) {
50
+ $(chooser).update(transport.responseText);
51
+ this.showChooserLoaded(chooser, transport);
52
+ }
53
+ }.bind(this),
54
+ onFailure: this._processFailure.bind(this)
55
+ });
56
+ },
57
+
58
+ showChooserLoaded: function(chooser, transport) {
59
+ chooser.style.display = 'block';
60
+ },
61
+
62
+ showChooser: function (container, event) {
63
+ var chooser = container.up('li');
64
+ if (!chooser) {
65
+ return;
66
+ }
67
+ chooser = chooser.down('.product-chooser');
68
+ if (!chooser) {
69
+ return;
70
+ }
71
+ this.showChooserElement(chooser);
72
+ },
73
+
74
+ hideChooser: function (container, event) {
75
+ var chooser = container.up('li');
76
+ if (!chooser) {
77
+ return;
78
+ }
79
+ chooser = chooser.down('.product-chooser');
80
+ if (!chooser) {
81
+ return;
82
+ }
83
+ chooser.style.display = 'none';
84
+ },
85
+
86
+ toggleChooser: function (container, event) {
87
+ var chooser = container.up('li').down('.product-chooser');
88
+ if (!chooser) {
89
+ return;
90
+ }
91
+ if (chooser.style.display=='block') {
92
+ chooser.style.display = 'none';
93
+ this.cleanChooser(container, event);
94
+ } else {
95
+ this.showChooserElement(chooser);
96
+ }
97
+ },
98
+
99
+ cleanChooser: function (container, event) {
100
+ var chooser = container.up('li').down('.product-chooser');
101
+ if (!chooser) {
102
+ return;
103
+ }
104
+ chooser.innerHTML = '';
105
+ },
106
+
107
+ showParamInputField: function (container, event) {
108
+ if (this.shownElement) {
109
+ this.hideParamInputField(this.shownElement, event);
110
+ }
111
+
112
+ Element.addClassName(container, 'product-param-edit');
113
+ var elemContainer = Element.down(container, '.element');
114
+
115
+ var elem = Element.down(elemContainer, 'input.input-text');
116
+ if (elem) {
117
+ elem.focus();
118
+ this.updateElement = elem;
119
+ }
120
+
121
+ var elem = Element.down(elemContainer, '.element-value-changer');
122
+ if (elem) {
123
+ elem.focus();
124
+ }
125
+
126
+ this.shownElement = container;
127
+ },
128
+
129
+ hideParamInputField: function (container, event) {
130
+ Element.removeClassName(container, 'product-param-edit');
131
+ var label = Element.down(container, '.label'), elem;
132
+
133
+ elem = Element.down(container, '.element-value-changer');
134
+ if (elem.value) {
135
+ this.addRuleNewChild(elem);
136
+ }
137
+ elem.value = '';
138
+
139
+ this.hideChooser(container, event);
140
+ this.updateElement = null;
141
+
142
+ this.shownElement = null;
143
+ },
144
+
145
+ _processSuccess : function(transport) {
146
+ if (transport.responseText.isJSON()) {
147
+ var response = transport.responseText.evalJSON()
148
+ if (response.error) {
149
+ alert(response.message);
150
+ }
151
+ if(response.ajaxExpired && response.ajaxRedirect) {
152
+ setLocation(response.ajaxRedirect);
153
+ }
154
+ return false;
155
+ }
156
+ return true;
157
+ },
158
+
159
+ _processFailure : function(transport) {
160
+ location.href = BASE_URL;
161
+ },
162
+
163
+ chooserGridRowInit: function (grid, row) {
164
+ if (!grid.reloadParams) {
165
+ grid.reloadParams = {'selected[]':this.chooserSelectedItems.keys()};
166
+ }
167
+ },
168
+
169
+ chooserGridRowClick: function (grid, event) {
170
+ var trElement = Event.findElement(event, 'tr');
171
+ var isInput = Event.element(event).tagName == 'INPUT';
172
+ if (trElement) {
173
+ var checkbox = Element.select(trElement, 'input');
174
+ if (checkbox[0]) {
175
+ var checked = isInput ? checkbox[0].checked : !checkbox[0].checked;
176
+ grid.setCheckboxChecked(checkbox[0], checked);
177
+ }
178
+ }
179
+ },
180
+
181
+ chooserGridCheckboxCheck: function (grid, element, checked) {
182
+ if (checked) {
183
+ if (!element.up('th')) {
184
+ this.chooserSelectedItems.set(element.value,1);
185
+ }
186
+ } else {
187
+ this.chooserSelectedItems.unset(element.value);
188
+ }
189
+ grid.reloadParams = {'selected[]':this.chooserSelectedItems.keys()};
190
+ this.updateElement.value = this.chooserSelectedItems.keys().join(', ');
191
+ }
192
+
193
+ };
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Mostviewed_Products</name>
4
+ <version>1.0.0</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>This extension is for list most viewed products.</summary>
10
+ <description>List mostly viewed products by customers on front end also display selected products as a most viewed with different options.</description>
11
+ <notes>Mos tviewed Products</notes>
12
+ <authors><author><name>Capacity Web Solutions</name><user>capacitywebsolutions</user><email>magento@capacitywebsolutions.com</email></author></authors>
13
+ <date>2016-02-26</date>
14
+ <time>10:12:32</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="CapacityWebSolutions_Mostviewed.xml" hash="26f06543c8f772c2a7c3ad7b83546047"/></dir></target><target name="magecommunity"><dir name="CapacityWebSolutions"><dir name="Mostviewed"><dir name="Block"><dir name="Adminhtml"><file name="DefaultDirectCode.php" hash="7aa329117be955eff075f08545bf853b"/><file name="DefaultTemplate.php" hash="1dc16be26bf0a1c4b4316adc7173518c"/><file name="DefaultXML.php" hash="faabad47b61316ab7f001f6f626857af"/><dir name="Mostviewed"><dir name="Edit"><file name="Form.php" hash="981f40614db3263b8482fc2cef181178"/><dir name="Tab"><file name="Products.php" hash="10bdf59fc60b1c095d62cd74bdec712a"/></dir><file name="Tabs.php" hash="56ab3c01540ce195cdb2f19c3faf91a3"/></dir><file name="Edit.php" hash="7f08f357623f22a6751ab1b7913b8ae8"/><file name="Grid.php" hash="02d45b76c286e909a12b74b34c7d947b"/></dir><file name="Mostviewed.php" hash="901285d55a392473be7f9dd11abeff8b"/></dir><file name="Mostviewed.php" hash="44396f7f9d4c93546985c6210cdaeed0"/><dir name="Promo"><dir name="Widget"><dir name="Chooser"><file name="Sku.php" hash="36a861784b2b98f5e02b2ce864122627"/></dir></dir></dir><dir name="Widget"><dir name="Html"><file name="Pager.php" hash="11f4bd330bfb0e07d7d72b1738cc67b8"/></dir></dir><file name="Widget.php" hash="ba4a419835ef5704a5d5aedabcba80cc"/></dir><dir name="Helper"><file name="Data.php" hash="37b08d1aead500f27d0a53e2165b7bfc"/></dir><dir name="Model"><file name="Mostviewed.php" hash="057b74311f61b8e97407d67ce4fa7d65"/><dir name="Mysql4"><dir name="Mostviewed"><file name="Collection.php" hash="ae2d9e242b36ee87d1eb5a3ba7d5a1a8"/></dir><file name="Mostviewed.php" hash="eff0f3022a0a925ec7683ebdffa1f6f2"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Category.php" hash="5dabe0845a777c5ad32fd73346ea5d8e"/><file name="Chooseproducts.php" hash="dfd7251dfaeeaa6b12c8783ada8c9a2d"/><file name="Choosetype.php" hash="b905f2c1ffb0be9c693c442d6bf58515"/><file name="Sortby.php" hash="c42aede6757c7c081b4bc87e3b30f465"/><file name="Sortorder.php" hash="8c287ddd925f760f11d1369c6a88ead2"/><file name="Template.php" hash="9da3040040ba45c47c3d82eb526ed911"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="MostviewedController.php" hash="dc7493f30b0cb5fee7f78e86734c12ff"/><file name="WidgetController.php" hash="62f0c7bdf48b25d753a97d8fa7a2b7a7"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="865243525921adf9e94126eb2d01506a"/><file name="config.xml" hash="4aa72a2edc5003cea508c379bf5cf2ca"/><file name="system.xml" hash="31aa1811609e894a949ba80954167320"/><file name="widget.xml" hash="00229ea6b55c3d5a087677b993e4b0f4"/></dir><dir name="sql"><dir name="mostviewed_setup"><file name="mysql4-install-1.0.0.php" hash="187d743d41ca22734ab4698fa35d4a59"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="mostviewed.xml" hash="722bbfa0fb28acb00b5c1a10f34d7ce7"/></dir><dir name="template"><dir name="mostviewed"><dir name="column"><file name="mostviewed_default_list-default.phtml" hash="cc4f0a07bd5d3f9fef963d00caff8d23"/><file name="mostviewed_default_list.phtml" hash="ac5ab48c421d2268bca1dc0abbae4a6f"/></dir><file name="mostviewed-grid.phtml" hash="6d969e21e75ae7365c9075744e7e1789"/><file name="mostviewed-list.phtml" hash="207fa0ce21e9270cc798d049900c4c00"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="mostviewed.xml" hash="3f06159a0daff802f0d59d97cf833191"/></dir><dir name="template"><dir name="mostviewed"><file name="product.phtml" hash="853a1e0cf5bc12bf8af5ed06bee8a318"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="mostviewed"><file name="mostviewed.css" hash="df4bf3891f3d527fa07132a4c6f9d166"/></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="mostviewed"><file name="product-selector.js" hash="18edba645290825072641d0c032b0a0f"/></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.0.0</min><max>7.0.3</max></php></required></dependencies>
18
+ </package>
skin/frontend/base/default/css/mostviewed/mostviewed.css ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .mostViewed { margin-bottom:30px; }
2
+ .mostViewed ul, .mostViewed ul ul, .mostViewed ol, .mostViewed ul.products-grid, .mostViewed ul.products-list { list-style:none; margin:0; padding:0; }
3
+ .mostViewed ul li, .mostViewed .pager .pages ol li { margin-left:0; }
4
+
5
+ .mostViewed .pager { float:none; border-bottom:1px dotted #ddd; border-top:1px dotted #ddd; padding:10px 10px 5px; margin-bottom:20px; }
6
+
7
+ .mostViewed .title h2 { font-weight:600; margin:10px 0; }
8
+
9
+ .mostViewed .products-grid .price-box p { margin-bottom:0; }
10
+ .mostViewed ul.products-list.rwd .price-box p { display:inline-block; margin:0 0 0 15px; }
11
+ .mostViewed ul.products-list.default .price-box p { margin:0 0 3px; }
12
+
13
+ .default ul ul.add-to-links { margin-top:5px; }