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
+