MageBees_Featured_Products - Version 1.0.0

Version Notes

Featured Products

Download this release

Release Info

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


Version 1.0.0

Files changed (39) hide show
  1. app/code/community/CapacityWebSolutions/Featured/Block/Adminhtml/DefaultDirectCode.php +16 -0
  2. app/code/community/CapacityWebSolutions/Featured/Block/Adminhtml/DefaultTemplate.php +16 -0
  3. app/code/community/CapacityWebSolutions/Featured/Block/Adminhtml/DefaultXML.php +19 -0
  4. app/code/community/CapacityWebSolutions/Featured/Block/Adminhtml/Featured.php +30 -0
  5. app/code/community/CapacityWebSolutions/Featured/Block/Adminhtml/Featured/Edit.php +41 -0
  6. app/code/community/CapacityWebSolutions/Featured/Block/Adminhtml/Featured/Edit/Form.php +24 -0
  7. app/code/community/CapacityWebSolutions/Featured/Block/Adminhtml/Featured/Edit/Tab/Products.php +27 -0
  8. app/code/community/CapacityWebSolutions/Featured/Block/Adminhtml/Featured/Edit/Tabs.php +28 -0
  9. app/code/community/CapacityWebSolutions/Featured/Block/Adminhtml/Featured/Grid.php +182 -0
  10. app/code/community/CapacityWebSolutions/Featured/Block/Featured.php +203 -0
  11. app/code/community/CapacityWebSolutions/Featured/Block/Promo/Widget/Chooser/Sku.php +158 -0
  12. app/code/community/CapacityWebSolutions/Featured/Block/Widget.php +25 -0
  13. app/code/community/CapacityWebSolutions/Featured/Block/Widget/Html/Pager.php +273 -0
  14. app/code/community/CapacityWebSolutions/Featured/Helper/Data.php +17 -0
  15. app/code/community/CapacityWebSolutions/Featured/Model/Featured.php +17 -0
  16. app/code/community/CapacityWebSolutions/Featured/Model/Mysql4/Featured.php +26 -0
  17. app/code/community/CapacityWebSolutions/Featured/Model/Mysql4/Featured/Collection.php +16 -0
  18. app/code/community/CapacityWebSolutions/Featured/Model/System/Config/Source/Category.php +51 -0
  19. app/code/community/CapacityWebSolutions/Featured/Model/System/Config/Source/Choosetype.php +1 -0
  20. app/code/community/CapacityWebSolutions/Featured/Model/System/Config/Source/Sortby.php +1 -0
  21. app/code/community/CapacityWebSolutions/Featured/Model/System/Config/Source/Sortorder.php +1 -0
  22. app/code/community/CapacityWebSolutions/Featured/Model/System/Config/Source/Template.php +1 -0
  23. app/code/community/CapacityWebSolutions/Featured/controllers/Adminhtml/FeaturedController.php +220 -0
  24. app/code/community/CapacityWebSolutions/Featured/controllers/Adminhtml/WidgetController.php +33 -0
  25. app/code/community/CapacityWebSolutions/Featured/etc/adminhtml.xml +46 -0
  26. app/code/community/CapacityWebSolutions/Featured/etc/config.xml +123 -0
  27. app/code/community/CapacityWebSolutions/Featured/etc/system.xml +311 -0
  28. app/code/community/CapacityWebSolutions/Featured/etc/widget.xml +189 -0
  29. app/code/community/CapacityWebSolutions/Featured/sql/featured_setup/mysql4-install-1.0.0.php +27 -0
  30. app/design/adminhtml/default/default/layout/featured.xml +22 -0
  31. app/design/adminhtml/default/default/template/featured/product.phtml +50 -0
  32. app/design/frontend/base/default/layout/featured.xml +8 -0
  33. app/design/frontend/base/default/template/featured/column/featured_default_list.phtml +43 -0
  34. app/design/frontend/base/default/template/featured/featured-grid.phtml +140 -0
  35. app/design/frontend/base/default/template/featured/featured-list.phtml +142 -0
  36. app/etc/modules/CapacityWebSolutions_Featured.xml +9 -0
  37. js/featured/product-selector.js +193 -0
  38. package.xml +18 -0
  39. skin/frontend/base/default/css/featured/featured.css +13 -0
app/code/community/CapacityWebSolutions/Featured/Block/Adminhtml/DefaultDirectCode.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Featured_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("featured/featured")->toHtml(); ?&gt;</span></div>';
14
+ }
15
+
16
+ }
app/code/community/CapacityWebSolutions/Featured/Block/Adminhtml/DefaultTemplate.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Featured_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="featured/featured" name="featured"}}</span></div>';
14
+ }
15
+
16
+ }
app/code/community/CapacityWebSolutions/Featured/Block/Adminhtml/DefaultXML.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Featured_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="featured/featured" name="featured"/&gt;</br>&lt;/reference&gt;</span>
15
+ </div>';
16
+
17
+ }
18
+
19
+ }
app/code/community/CapacityWebSolutions/Featured/Block/Adminhtml/Featured.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Featured_Block_Adminhtml_Featured extends Mage_Adminhtml_Block_Widget_Grid_Container
9
+ {
10
+ public function __construct()
11
+ {
12
+ $this->_controller = 'adminhtml_featured';
13
+ $this->_blockGroup = 'featured';
14
+ $this->_headerText = Mage::helper('featured')->__('Manage Featured Products');
15
+ $this->_addButtonLabel = Mage::helper('featured')->__('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
+
30
+ }
app/code/community/CapacityWebSolutions/Featured/Block/Adminhtml/Featured/Edit.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Featured_Block_Adminhtml_Featured_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
9
+ {
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+ $this->_objectId = 'id';
14
+ $this->_blockGroup = 'featured';
15
+ $this->_controller = 'adminhtml_featured';
16
+ $this->_updateButton('save', 'label','Save');
17
+ $this->_updateButton('delete','label','Delete');
18
+ $this->_addButton('save_and_continue', array(
19
+ 'label' => Mage::helper('featured')->__('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('featured_edit');
31
+ }
32
+
33
+ public function getHeaderText()
34
+ {
35
+ if( Mage::registry('featured_data') && Mage::registry('featured_data')->getFeaturedId() ) {
36
+ return Mage::helper('featured')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('featured_data')->getSku()));
37
+ } else {
38
+ return Mage::helper('featured')->__('Select Products');
39
+ }
40
+ }
41
+ }
app/code/community/CapacityWebSolutions/Featured/Block/Adminhtml/Featured/Edit/Form.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Featured_Block_Adminhtml_Featured_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/Featured/Block/Adminhtml/Featured/Edit/Tab/Products.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Featured_Block_Adminhtml_Featured_Edit_Tab_Products extends Mage_Adminhtml_Block_Widget_Form
9
+ {
10
+ public function __construct() {
11
+ parent::__construct();
12
+ $this->setTemplate('featured/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('featured/featured')->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/Featured/Block/Adminhtml/Featured/Edit/Tabs.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Featured_Block_Adminhtml_Featured_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
9
+ {
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+ $this->setId('featured_tabs');
14
+ $this->setDestElementId('edit_form');
15
+ $this->setTitle('Featured Information');
16
+ }
17
+
18
+ protected function _beforeToHtml()
19
+ {
20
+ $this->addTab('product_section', array(
21
+ 'label' => Mage::helper('featured')->__('Products'),
22
+ 'title' => Mage::helper('featured')->__('Products'),
23
+ 'content' => $this->getLayout()->createBlock('featured/adminhtml_featured_edit_tab_products')->toHtml(),
24
+ ));
25
+
26
+ return parent::_beforeToHtml();
27
+ }
28
+ }
app/code/community/CapacityWebSolutions/Featured/Block/Adminhtml/Featured/Grid.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Featured_Block_Adminhtml_Featured_Grid extends Mage_Adminhtml_Block_Widget_Grid
9
+ {
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+ $this->setId('featuredGrid');
14
+ //$this->setDefaultSort('featured_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('featured_id', array(
88
+ 'header' => Mage::helper('featured')->__('ID'),
89
+ 'align' => 'right',
90
+ 'width' => '50px',
91
+ 'index' => 'bestseller_id',
92
+ ));
93
+ */
94
+ $this->addColumn('entity_id',
95
+ array(
96
+ 'header'=> Mage::helper('catalog')->__('ID'),
97
+ 'width' => '50px',
98
+ 'type' => 'number',
99
+ 'index' => 'entity_id',
100
+ ));
101
+ $this->addColumn('name',
102
+ array(
103
+ 'header'=> Mage::helper('catalog')->__('Name'),
104
+ 'index' => 'name',
105
+ ));
106
+
107
+ $store = $this->_getStore();
108
+ if ($store->getId()) {
109
+ $this->addColumn('custom_name',
110
+ array(
111
+ 'header'=> Mage::helper('catalog')->__('Name in %s', $store->getName()),
112
+ 'index' => 'custom_name',
113
+ ));
114
+ }
115
+
116
+ $this->addColumn('type',
117
+ array(
118
+ 'header'=> Mage::helper('catalog')->__('Type'),
119
+ 'width' => '100px',
120
+ 'index' => 'type_id',
121
+ 'type' => 'options',
122
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
123
+ ));
124
+
125
+ $this->addColumn('sku',
126
+ array(
127
+ 'header'=> Mage::helper('catalog')->__('SKU'),
128
+ 'width' => '80px',
129
+ 'index' => 'sku',
130
+ ));
131
+
132
+ $store = $this->_getStore();
133
+ $this->addColumn('price',
134
+ array(
135
+ 'header'=> Mage::helper('catalog')->__('Price'),
136
+ 'type' => 'price',
137
+ 'currency_code' => $store->getBaseCurrency()->getCode(),
138
+ 'index' => 'price',
139
+ ));
140
+
141
+ return parent::_prepareColumns();
142
+ }
143
+
144
+ public function getSkusArr($element){
145
+ return $element['sku'];
146
+ }
147
+
148
+ public function getProductSkus(){
149
+ $store_id = Mage::app()->getRequest()->getParam('store',0);
150
+
151
+ $featuredCollection = Mage::getModel('featured/featured')->getCollection()->addFieldToFilter('store_id', array(array('finset' => $store_id)));
152
+ $product_skus=array_map(array($this,"getSkusArr"), $featuredCollection->getData());
153
+ return $product_skus;
154
+ }
155
+
156
+ //public function getRowUrl($row)
157
+ //{
158
+ //return $this->getUrl('*/*/edit', array('id' => $row->getId()));
159
+ //}
160
+
161
+ protected function _prepareMassaction()
162
+ {
163
+ $store_id = Mage::app()->getRequest()->getParam('store',0);
164
+ $this->setMassactionIdField('featured_id');
165
+ $url = $this->getUrl('*/*/massDelete',array('store'=>$store_id));
166
+ $this->getMassactionBlock()->setFormFieldName('featured');
167
+
168
+ $this->getMassactionBlock()->addItem('delete', array(
169
+ 'label' => Mage::helper('featured')->__('Delete'),
170
+ 'url' => $url,
171
+ 'confirm' => Mage::helper('featured')->__('Are you sure?')
172
+ ));
173
+
174
+ return $this;
175
+ }
176
+
177
+ public function getGridUrl()
178
+ {
179
+ return $this->getUrl('*/*/grid', array('_current'=>true));
180
+ }
181
+
182
+ }
app/code/community/CapacityWebSolutions/Featured/Block/Featured.php ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Featured Products.
4
+ @copyright : Copyright (c) 2015 Capacity Web Solutions.
5
+ ( http://www.capacitywebsolutions.com )
6
+ @author : Capacity Web Solutions Pvt. Ltd.
7
+ @support : magento@capacitywebsolutions.com
8
+ ***************************************************************************/
9
+
10
+ class CapacityWebSolutions_Featured_Block_Featured extends Mage_Catalog_Block_Product_Abstract
11
+ {
12
+ /**
13
+ * Name of request parameter for page number value
14
+ */
15
+ const PAGE_VAR_NAME = 'np';
16
+
17
+ public function __construct() {
18
+ parent::_construct();
19
+ $this->addColumnCountLayoutDepend('empty', 6)
20
+ ->addColumnCountLayoutDepend('one_column', 5)
21
+ ->addColumnCountLayoutDepend('two_columns_left', 4)
22
+ ->addColumnCountLayoutDepend('two_columns_right', 4)
23
+ ->addColumnCountLayoutDepend('three_columns', 3);
24
+
25
+ $this->setStoreId(Mage::app()->getStore()->getId());
26
+
27
+ //General Settings
28
+ $this->setEnabled((bool)Mage::getStoreConfig("featured/general/enabled"));
29
+ $this->setDisplayHeading((bool)Mage::getStoreConfig("featured/general/display_heading"));
30
+ $this->setHeading(Mage::getStoreConfig("featured/general/heading"));
31
+ $this->setChooseProducts(Mage::getStoreConfig("featured/general/choose_products"));
32
+ $this->setDisplayBy(Mage::getStoreConfig("featured/general/display_by"));
33
+ $this->setCategories(Mage::getStoreConfig("featured/general/categories"));
34
+ $this->setSortBy(Mage::getStoreConfig("featured/general/sort_by"));
35
+ $this->setSortOrder(Mage::getStoreConfig("featured/general/sort_order"));
36
+ $this->setProductsPrice((bool)Mage::getStoreConfig("featured/general/products_price"));
37
+ $this->setReview((bool)Mage::getStoreConfig("featured/general/review"));
38
+ $this->setShortDesc((bool)Mage::getStoreConfig("featured/general/short_desc"));
39
+ $this->setDescLimit((int)Mage::getStoreConfig("featured/general/desc_limit"));
40
+ $this->setAddToCart((bool)Mage::getStoreConfig("featured/general/add_to_cart"));
41
+ $this->setAddToWishlist((bool)Mage::getStoreConfig("featured/general/add_to_wishlist"));
42
+ $this->setAddToCompare((bool)Mage::getStoreConfig("featured/general/add_to_compare"));
43
+ $this->setOutOfStock((bool)Mage::getStoreConfig("featured/general/out_of_stock"));
44
+ $this->setIsResponsive((bool)Mage::getStoreConfig('featured/general/isresponsive'));
45
+
46
+ //Template Settings
47
+ $this->setCustomTemplate(Mage::getStoreConfig("featured/template/select_template"));
48
+ $this->setProductsCount((int)Mage::getStoreConfig("featured/template/number_of_items"));
49
+ $this->setShowPager((bool)Mage::getStoreConfig("featured/template/show_pager"));
50
+ $this->setProductsPerPage((int)Mage::getStoreConfig("featured/template/products_per_page"));
51
+ $this->setHeight((int)Mage::getStoreConfig("featured/template/thumbnail_height"));
52
+ $this->setWidth((int)Mage::getStoreConfig("featured/template/thumbnail_width"));
53
+ }
54
+
55
+ public function setWidgetOptions(){
56
+ //General Settings
57
+ $this->setDisplayHeading((bool)$this->getWdDisplayHeading());
58
+ $this->setHeading($this->getWdHeading());
59
+ $this->setChooseProducts($this->getWdChooseProducts());
60
+ $this->setDisplayBy((int)$this->getWdDisplayBy());
61
+ $this->setCategories($this->getWdCategories());
62
+ $this->setSortBy($this->getWdSortBy());
63
+ $this->setSortOrder($this->getWdSortOrder());
64
+ $this->setProductsPrice((bool)$this->getWdProductsPrice());
65
+ $this->setReview((bool)$this->getWdReview());
66
+ $this->setShortDesc((bool)$this->getWdShortDesc());
67
+ $this->setDescLimit((int)$this->getWdDescLimit());
68
+ $this->setAddToCart((bool)$this->getWdAddToCart());
69
+ $this->setAddToWishlist((bool)$this->getWdAddToWishlist());
70
+ $this->setAddToCompare((bool)$this->getWdAddToCompare());
71
+ $this->setOutOfStock((bool)$this->getWdOutOfStock());
72
+
73
+ //Template Settings
74
+ $this->setProductsCount((int)$this->getWdNumberOfItems());
75
+ $this->setShowPager((bool)$this->getWdShowPager());
76
+ $this->setProductsPerPage((int)$this->getWdProductsPerPage());
77
+ $this->setHeight((int)$this->getWdThumbnailHeight());
78
+ $this->setWidth((int)$this->getWdThumbnailWidth());
79
+ }
80
+
81
+ protected function _getProductCollection() {
82
+ $collection = $this->_getFeaturedProductsCollection();
83
+ $storeId = Mage::app()->getStore()->getId();
84
+ $collection ->addMinimalPrice()
85
+ ->addFinalPrice()
86
+ ->setStore($storeId)
87
+ ->addStoreFilter($storeId)
88
+ ->setPageSize($this->getProductsCount())
89
+ ->setCurPage(1)
90
+ ;
91
+
92
+ //Display out of stock products
93
+ if(!$this->getOutOfStock()){
94
+ Mage::getSingleton('cataloginventory/stock')
95
+ ->addInStockFilterToCollection($collection);
96
+ }
97
+
98
+ //Display By Category
99
+ if($this->getDisplayBy()==2){
100
+ $categorytable = Mage::getSingleton('core/resource')->getTableName('catalog_category_product');
101
+ $collection->getSelect()
102
+ ->joinLeft(array('at_category_id' => $categorytable),'e.entity_id = at_category_id.product_id','at_category_id.category_id')
103
+ ->group('e.entity_id')
104
+ ->where("at_category_id.category_id IN (".$this->getCategories().")")
105
+ ;
106
+ }
107
+
108
+ //Set Sort Order
109
+ if($this->getSortOrder()=='rand'){
110
+ $collection->getSelect()->order('rand()');
111
+ }else{
112
+ $collection->addAttributeToSort($this->getSortBy(), $this->getSortOrder());
113
+ }
114
+
115
+ return $collection;
116
+ }
117
+
118
+ /**
119
+ * Prepare collection with featured products
120
+ *
121
+ * @return Mage_Core_Block_Abstract
122
+ */
123
+ protected function _beforeToHtml(){
124
+ if($this->getType()=="featured/widget")
125
+ {
126
+ $this->setWidgetOptions();
127
+ }
128
+ $this->setProductCollection($this->_getProductCollection());
129
+ }
130
+
131
+ protected function _getFeaturedProductsCollection(){
132
+ /** @var $collection Mage_Catalog_Model_Resource_Product_Collection */
133
+ $collection = Mage::getResourceModel('catalog/product_collection');
134
+ $collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
135
+
136
+ $collection = $this->_addProductAttributesAndPrices($collection)
137
+ ->addAttributeToFilter('sku', array('in' => $this->getSkus()));
138
+ return $collection;
139
+ }
140
+
141
+ public function getSkusArr($element){
142
+ return $element['sku'];
143
+ }
144
+
145
+ public function getSkus(){
146
+ //$store_id = Mage::app()->getRequest()->getParam('store',0);
147
+ $store_id = $this->getStoreId();
148
+ $featuredCollection = Mage::getModel('featured/featured')->getCollection()->addFieldToFilter('store_id', array(array('finset' => $store_id)));
149
+ $product_skus=array_map(array($this,"getSkusArr"), $featuredCollection->getData());
150
+ return $product_skus;
151
+ }
152
+
153
+ public function limit_word($text, $limit) {
154
+ if (str_word_count($text, 0) > $limit) {
155
+ $words = str_word_count($text, 2);
156
+ $pos = array_keys($words);
157
+ $text = substr($text, 0, $pos[$limit]) . '...';
158
+ }
159
+ return $text;
160
+ }
161
+
162
+ public function _toHtml(){
163
+ if (!$this->getEnabled()) {
164
+ return '';
165
+ }
166
+ if(!$this->getTemplate()){
167
+ if($this->getCustomTemplate()==2){
168
+ $this->setTemplate('featured/featured-list.phtml');
169
+ }else{
170
+ $this->setTemplate('featured/featured-grid.phtml');
171
+ }
172
+ }
173
+ return parent::_toHtml();
174
+ }
175
+
176
+ /**
177
+ * Render pagination HTML
178
+ *
179
+ * @return string
180
+ */
181
+ public function getPagerHtml()
182
+ {
183
+ if ($this->getShowPager()) {
184
+ if (!$this->_pager) {
185
+ $this->_pager = $this->getLayout()
186
+ ->createBlock('featured/widget_html_pager', 'widget.featured.product.list.pager');
187
+
188
+ $this->_pager->setUseContainer(true)
189
+ ->setShowAmounts(true)
190
+ ->setShowPerPage(false)
191
+ ->setPageVarName(self::PAGE_VAR_NAME)
192
+ ->setLimit($this->getProductsPerPage())
193
+ ->setTotalLimit($this->getProductsCount())
194
+ ->setCollection($this->getProductCollection());
195
+ }
196
+ if ($this->_pager instanceof Mage_Core_Block_Abstract) {
197
+ return $this->_pager->toHtml();
198
+ }
199
+ }
200
+ return '';
201
+ }
202
+
203
+ }
app/code/community/CapacityWebSolutions/Featured/Block/Promo/Widget/Chooser/Sku.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Featured_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/Featured/Block/Widget.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Featured_Block_Widget extends CapacityWebSolutions_Featured_Block_Featured // 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/Featured/Block/Widget/Html/Pager.php ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Featured_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/Featured/Helper/Data.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Featured_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/Featured/Model/Featured.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Featured_Model_Featured extends Mage_Core_Model_Abstract
9
+ {
10
+ public function _construct()
11
+ {
12
+ parent::_construct();
13
+ $this->_init('featured/featured');
14
+ }
15
+
16
+
17
+ }
app/code/community/CapacityWebSolutions/Featured/Model/Mysql4/Featured.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Featured_Model_Mysql4_Featured extends Mage_Core_Model_Mysql4_Abstract
9
+ {
10
+ public function _construct()
11
+ {
12
+ $this->_init('featured/featured', 'featured_id');
13
+ }
14
+
15
+ /* protected function _beforeSave(Mage_Core_Model_Abstract $object)
16
+ {
17
+ parent::_beforeSave($object);
18
+ echo "<pre>";
19
+ print_r(get_class_methods($object));
20
+ print_r($object->getData());
21
+ exit;
22
+
23
+
24
+ return $this;
25
+ } */
26
+ }
app/code/community/CapacityWebSolutions/Featured/Model/Mysql4/Featured/Collection.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Featured_Model_Mysql4_Featured_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
9
+ {
10
+ public function _construct()
11
+ {
12
+ parent::_construct();
13
+ $this->_init('featured/featured');
14
+ }
15
+
16
+ }
app/code/community/CapacityWebSolutions/Featured/Model/System/Config/Source/Category.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Featured_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
+ $collection = Mage::getModel('catalog/category')->getCollection()
40
+ ->addAttributeToSelect('name')
41
+ ->addAttributeToSelect('is_active');
42
+
43
+ $tree->addCollectionData($collection, true);
44
+
45
+ $values['---'] = array(
46
+ 'value' => '',
47
+ 'label' => '',
48
+ );
49
+ return $this->buildCategoriesMultiselectValues($root, $values);
50
+ }
51
+ }
app/code/community/CapacityWebSolutions/Featured/Model/System/Config/Source/Choosetype.php ADDED
@@ -0,0 +1 @@
 
0
  Extension Name : Featured Products
1
  Extension URL : http://www.magebees.com/magento-featured-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 : Featured Products
3
  Extension URL : http://www.magebees.com/magento-featured-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/Featured/Model/System/Config/Source/Sortby.php ADDED
@@ -0,0 +1 @@
 
0
  Extension Name : Featured Products
1
  Extension URL : http://www.magebees.com/magento-featured-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 : Featured Products
3
  Extension URL : http://www.magebees.com/magento-featured-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/Featured/Model/System/Config/Source/Sortorder.php ADDED
@@ -0,0 +1 @@
 
0
  Extension Name : Featured Products
1
  Extension URL : http://www.magebees.com/magento-featured-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 : Featured Products
3
  Extension URL : http://www.magebees.com/magento-featured-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/Featured/Model/System/Config/Source/Template.php ADDED
@@ -0,0 +1 @@
 
0
  Extension Name : Featured Products
1
  Extension URL : http://www.magebees.com/magento-featured-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 : Featured Products
3
  Extension URL : http://www.magebees.com/magento-featured-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/Featured/controllers/Adminhtml/FeaturedController.php ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Featured_Adminhtml_FeaturedController 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('featured/featured')->load($id);
28
+
29
+ if ($model->getFeaturedId() || $id == 0) {
30
+
31
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
32
+ if (!empty($data)) {
33
+ $model->setData($data);
34
+ }
35
+
36
+ Mage::register('featured_data', $model);
37
+
38
+ $this->loadLayout();
39
+ $this->_setActiveMenu('cws');
40
+
41
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Featured Products'), Mage::helper('adminhtml')->__('Featured Products'));
42
+
43
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
44
+
45
+ $this->_addContent($this->getLayout()->createBlock('featured/adminhtml_featured_edit'))
46
+ ->_addLeft($this->getLayout()->createBlock('featured/adminhtml_featured_edit_tabs'));
47
+
48
+ $this->renderLayout();
49
+ } else {
50
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('featured')->__('Featured 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('featured/featured')->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
+ $featured = Mage::getModel('featured/featured')->load($sku,'sku');
85
+
86
+ if(!$store_id){//for all store views
87
+ $featured->delete();
88
+ }else{
89
+ $new_store_ids_arr = array();
90
+ $old_store_ids = $featured->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
+ $featured->delete();
98
+ }else{
99
+ $featured->setData('sku',$sku);
100
+ $featured->setData('store_id',$new_store_ids);
101
+ $featured->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('featured')->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('featured/featured')->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('featured/featured')->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('featured')->__('Featured 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('featured')->__('Unable to find Featured Products to save'));
160
+ $this->_redirect('*/*/');
161
+ }
162
+
163
+ public function massDeleteAction() {
164
+ $featured_ids = $this->getRequest()->getParam('featured');
165
+ $store_id = $this->getRequest()->getParam('store');
166
+ $skus_for_remove_arr = array();
167
+
168
+ if(!is_array($featured_ids)) {
169
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
170
+ } else {
171
+ try {
172
+ foreach($featured_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
+ $featured = Mage::getModel('featured/featured')->load($sku,'sku');
177
+ if($featured->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
+ $featured->delete();
184
+ }else{
185
+ $new_store_ids_arr = array();
186
+ $old_store_ids = $featured->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
+
193
+ $featured->delete();
194
+ }else{
195
+ $featured->setData('sku',$sku);
196
+ $featured->setData('store_id',$new_store_ids);
197
+ $featured->save();
198
+ }
199
+ }
200
+ }
201
+ Mage::getSingleton('adminhtml/session')->addSuccess(
202
+ Mage::helper('adminhtml')->__(
203
+ 'Total of %d record(s) were successfully deleted.', count($featured_ids)
204
+ )
205
+ );
206
+ } catch (Exception $e) {
207
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
208
+ }
209
+ }
210
+ $this->_redirectReferer();
211
+ }
212
+
213
+ public function gridAction() {
214
+ $this->loadLayout();
215
+ $this->getResponse()->setBody(
216
+ $this->getLayout()->createBlock('featured/adminhtml_featured_grid')->toHtml()
217
+ );
218
+ }
219
+
220
+ }
app/code/community/CapacityWebSolutions/Featured/controllers/Adminhtml/WidgetController.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Featured_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
+ 'featured/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/Featured/etc/adminhtml.xml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <cws module="featured">
5
+ <title>MageBees</title>
6
+ <sort_order>70</sort_order>
7
+ <children>
8
+ <featured module="featured">
9
+ <title>Featured Products</title>
10
+ <sort_order>70</sort_order>
11
+ <children>
12
+ <groups module="featured">
13
+ <title>Manage Featured Products</title>
14
+ <sort_order>10</sort_order>
15
+ <action>adminhtml/featured</action>
16
+ </groups>
17
+ <settings>
18
+ <title>Settings</title>
19
+ <sort_order>20</sort_order>
20
+ <action>adminhtml/system_config/edit/section/featured</action>
21
+ </settings>
22
+ </children>
23
+ </featured>
24
+ </children>
25
+ </cws>
26
+ </menu>
27
+ <acl>
28
+ <resources>
29
+ <admin>
30
+ <children>
31
+ <system>
32
+ <children>
33
+ <config>
34
+ <children>
35
+ <featured>
36
+ <title>MageBees Featured Products Section</title>
37
+ </featured>
38
+ </children>
39
+ </config>
40
+ </children>
41
+ </system>
42
+ </children>
43
+ </admin>
44
+ </resources>
45
+ </acl>
46
+ </config>
app/code/community/CapacityWebSolutions/Featured/etc/config.xml ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <CapacityWebSolutions_Featured>
5
+ <version>1.0.0</version>
6
+ </CapacityWebSolutions_Featured>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <featured>
11
+ <class>CapacityWebSolutions_Featured_Model</class>
12
+ <resourceModel>featured_mysql4</resourceModel>
13
+ </featured>
14
+ <featured_mysql4>
15
+ <class>CapacityWebSolutions_Featured_Model_Mysql4</class>
16
+ <entities>
17
+ <featured>
18
+ <table>cws_featured_products</table>
19
+ </featured>
20
+ </entities>
21
+ </featured_mysql4>
22
+ </models>
23
+ <resources>
24
+ <featured_setup>
25
+ <setup>
26
+ <module>CapacityWebSolutions_Featured</module>
27
+ </setup>
28
+ <connection>
29
+ <use>core_setup</use>
30
+ </connection>
31
+ </featured_setup>
32
+ <featured_write>
33
+ <connection>
34
+ <use>core_write</use>
35
+ </connection>
36
+ </featured_write>
37
+ <featured_read>
38
+ <connection>
39
+ <use>core_read</use>
40
+ </connection>
41
+ </featured_read>
42
+ </resources>
43
+ <blocks>
44
+ <featured>
45
+ <class>CapacityWebSolutions_Featured_Block</class>
46
+ </featured>
47
+ </blocks>
48
+ <helpers>
49
+ <featured>
50
+ <class>CapacityWebSolutions_Featured_Helper</class>
51
+ </featured>
52
+ </helpers>
53
+ </global>
54
+ <frontend>
55
+ <routers>
56
+ <featured>
57
+ <use>standard</use>
58
+ <args>
59
+ <module>CapacityWebSolutions_Featured</module>
60
+ <frontName>featured</frontName>
61
+ </args>
62
+ </featured>
63
+ </routers>
64
+ <layout>
65
+ <updates>
66
+ <featured>
67
+ <file>featured.xml</file>
68
+ </featured>
69
+ </updates>
70
+ </layout>
71
+ </frontend>
72
+
73
+ <admin>
74
+ <routers>
75
+ <adminhtml>
76
+ <args>
77
+ <modules>
78
+ <featured before="Mage_Adminhtml">CapacityWebSolutions_Featured_Adminhtml</featured>
79
+ </modules>
80
+ </args>
81
+ </adminhtml>
82
+ </routers>
83
+ </admin>
84
+
85
+ <adminhtml>
86
+ <layout>
87
+ <updates>
88
+ <featured>
89
+ <file>featured.xml</file>
90
+ </featured>
91
+ </updates>
92
+ </layout>
93
+ </adminhtml>
94
+
95
+ <default> <!-- Default text value set from admin-->
96
+ <featured>
97
+ <general>
98
+ <enabled>1</enabled>
99
+ <display_heading>1</display_heading>
100
+ <heading>FEATURED PRODUCTS</heading>
101
+ <display_by>1</display_by>
102
+ <sort_by>name</sort_by>
103
+ <sort_order>asc</sort_order>
104
+ <products_price>1</products_price>
105
+ <review>0</review>
106
+ <short_desc>0</short_desc>
107
+ <desc_limit>10</desc_limit>
108
+ <add_to_cart>1</add_to_cart>
109
+ <add_to_wishlist>0</add_to_wishlist>
110
+ <add_to_compare>0</add_to_compare>
111
+ <out_of_stock>0</out_of_stock>
112
+ </general>
113
+ <template>
114
+ <select_template>1</select_template>
115
+ <number_of_items>10</number_of_items>
116
+ <show_pager>0</show_pager>
117
+ <products_per_page>5</products_per_page>
118
+ <thumbnail_height>135</thumbnail_height>
119
+ <thumbnail_width>135</thumbnail_width>
120
+ </template>
121
+ </featured>
122
+ </default>
123
+ </config>
app/code/community/CapacityWebSolutions/Featured/etc/system.xml ADDED
@@ -0,0 +1,311 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <featured translate="label">
11
+ <class>separator-top</class>
12
+ <label>Featured 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_Featured_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_Featured_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_Featured_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 Featured 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
+ <display_by>
106
+ <label>Select Featured Products Type</label>
107
+ <comment><![CDATA[You can display all products or display by categories.]]></comment>
108
+ <source_model>featured/system_config_source_choosetype</source_model>
109
+ <frontend_type>select</frontend_type>
110
+ <sort_order>35</sort_order>
111
+ <show_in_default>1</show_in_default>
112
+ <show_in_website>1</show_in_website>
113
+ <show_in_store>1</show_in_store>
114
+ </display_by>
115
+ <categories translate="label">
116
+ <label>Categories</label>
117
+ <frontend_type>multiselect</frontend_type>
118
+ <source_model>featured/system_config_source_category</source_model>
119
+ <sort_order>40</sort_order>
120
+ <show_in_default>1</show_in_default>
121
+ <show_in_website>0</show_in_website>
122
+ <show_in_store>0</show_in_store>
123
+ <depends>
124
+ <display_by>2</display_by>
125
+ </depends>
126
+ <validate>required-entry</validate>
127
+ </categories>
128
+ <sort_by>
129
+ <label>Sort By</label>
130
+ <comment><![CDATA[Set attribute that is initially used to sort the featured products list.
131
+ ]]></comment>
132
+ <source_model>featured/system_config_source_sortby</source_model>
133
+ <frontend_type>select</frontend_type>
134
+ <sort_order>43</sort_order>
135
+ <show_in_default>1</show_in_default>
136
+ <show_in_website>1</show_in_website>
137
+ <show_in_store>1</show_in_store>
138
+ </sort_by>
139
+ <sort_order>
140
+ <label>Sort Order</label>
141
+ <comment><![CDATA[If you select "Random" then Sort By atrributes is not applicable.]]></comment>
142
+ <source_model>featured/system_config_source_sortorder</source_model>
143
+ <frontend_type>select</frontend_type>
144
+ <sort_order>44</sort_order>
145
+ <show_in_default>1</show_in_default>
146
+ <show_in_website>1</show_in_website>
147
+ <show_in_store>1</show_in_store>
148
+ </sort_order>
149
+ <products_price translate="label">
150
+ <label>Show Products Price</label>
151
+ <comment><![CDATA[Select Yes for display the Products' Price on frontend.]]></comment>
152
+ <source_model>adminhtml/system_config_source_yesno</source_model>
153
+ <frontend_type>select</frontend_type>
154
+ <sort_order>45</sort_order>
155
+ <show_in_default>1</show_in_default>
156
+ <show_in_website>1</show_in_website>
157
+ <show_in_store>1</show_in_store>
158
+ </products_price>
159
+ <review translate="label">
160
+ <label>Show Ratings</label>
161
+ <comment><![CDATA[Select Yes for display the Ratings on frontend.]]></comment>
162
+ <source_model>adminhtml/system_config_source_yesno</source_model>
163
+ <frontend_type>select</frontend_type>
164
+ <sort_order>50</sort_order>
165
+ <show_in_default>1</show_in_default>
166
+ <show_in_website>1</show_in_website>
167
+ <show_in_store>1</show_in_store>
168
+ </review>
169
+ <short_desc translate="label">
170
+ <label>Show Short Description</label>
171
+ <comment><![CDATA[Select Yes for display the Short Description on frontend.]]></comment>
172
+ <source_model>adminhtml/system_config_source_yesno</source_model>
173
+ <frontend_type>select</frontend_type>
174
+ <sort_order>55</sort_order>
175
+ <show_in_default>1</show_in_default>
176
+ <show_in_website>1</show_in_website>
177
+ <show_in_store>1</show_in_store>
178
+ </short_desc>
179
+ <desc_limit translate="label">
180
+ <label>Short Description Word Limit</label>
181
+ <comment><![CDATA[Set number of words display on frontend.]]></comment>
182
+ <frontend_type>text</frontend_type>
183
+ <sort_order>60</sort_order>
184
+ <show_in_default>1</show_in_default>
185
+ <show_in_website>1</show_in_website>
186
+ <show_in_store>1</show_in_store>
187
+ <depends>
188
+ <short_desc>1</short_desc>
189
+ </depends>
190
+ <validate>required-entry</validate>
191
+ </desc_limit>
192
+ <add_to_cart translate="label">
193
+ <label>Add to Cart</label>
194
+ <comment><![CDATA[Select Yes for display the "Add to Cart" button on frontend.]]></comment>
195
+ <source_model>adminhtml/system_config_source_yesno</source_model>
196
+ <frontend_type>select</frontend_type>
197
+ <sort_order>65</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
+ </add_to_cart>
202
+ <add_to_wishlist translate="label">
203
+ <label>Add to Wishlist</label>
204
+ <comment><![CDATA[Select Yes for display the "Add to Wishlist" link on frontend.]]></comment>
205
+ <frontend_type>select</frontend_type>
206
+ <source_model>adminhtml/system_config_source_yesno</source_model>
207
+ <sort_order>70</sort_order>
208
+ <show_in_default>1</show_in_default>
209
+ <show_in_website>1</show_in_website>
210
+ <show_in_store>1</show_in_store>
211
+ </add_to_wishlist>
212
+ <add_to_compare translate="label">
213
+ <label>Add to Compare</label>
214
+ <comment><![CDATA[Select Yes for display the "Add to Compare" link on frontend.]]></comment>
215
+ <source_model>adminhtml/system_config_source_yesno</source_model>
216
+ <frontend_type>select</frontend_type>
217
+ <sort_order>75</sort_order>
218
+ <show_in_default>1</show_in_default>
219
+ <show_in_website>1</show_in_website>
220
+ <show_in_store>1</show_in_store>
221
+ </add_to_compare>
222
+ <out_of_stock translate="label">
223
+ <label>Display out of stock items</label>
224
+ <comment><![CDATA[Select Yes for display the out of stock items on frontend.]]></comment>
225
+ <source_model>adminhtml/system_config_source_yesno</source_model>
226
+ <frontend_type>select</frontend_type>
227
+ <sort_order>80</sort_order>
228
+ <show_in_default>1</show_in_default>
229
+ <show_in_website>1</show_in_website>
230
+ <show_in_store>1</show_in_store>
231
+ </out_of_stock>
232
+ </fields>
233
+ </general>
234
+ <template>
235
+ <label>Template Settings</label>
236
+ <frontend_type>text</frontend_type>
237
+ <sort_order>40</sort_order>
238
+ <show_in_default>1</show_in_default>
239
+ <show_in_website>1</show_in_website>
240
+ <show_in_store>1</show_in_store>
241
+ <fields>
242
+ <select_template>
243
+ <label>Template</label>
244
+ <comment><![CDATA[Select template for featured products list.
245
+ ]]></comment>
246
+ <source_model>featured/system_config_source_template</source_model>
247
+ <frontend_type>select</frontend_type>
248
+ <sort_order>5</sort_order>
249
+ <show_in_default>1</show_in_default>
250
+ <show_in_website>1</show_in_website>
251
+ <show_in_store>1</show_in_store>
252
+ </select_template>
253
+ <number_of_items translate="label comment">
254
+ <label>Number of Products to Display</label>
255
+ <comment><![CDATA[Show number of featured products in main block.]]></comment>
256
+ <frontend_type>text</frontend_type>
257
+ <sort_order>10</sort_order>
258
+ <show_in_default>1</show_in_default>
259
+ <show_in_website>1</show_in_website>
260
+ <show_in_store>1</show_in_store>
261
+ <validate>required-entry</validate>
262
+ </number_of_items>
263
+ <show_pager translate="label comment">
264
+ <label>Display Page Control</label>
265
+ <comment><![CDATA[Show pagination and total number of items.]]></comment>
266
+ <source_model>adminhtml/system_config_source_yesno</source_model>
267
+ <frontend_type>select</frontend_type>
268
+ <sort_order>15</sort_order>
269
+ <show_in_default>1</show_in_default>
270
+ <show_in_website>1</show_in_website>
271
+ <show_in_store>1</show_in_store>
272
+ </show_pager>
273
+ <products_per_page translate="label comment">
274
+ <label>Number of Products per Page</label>
275
+ <comment><![CDATA[Show number of products per page.]]></comment>
276
+ <frontend_type>text</frontend_type>
277
+ <sort_order>20</sort_order>
278
+ <show_in_default>1</show_in_default>
279
+ <show_in_website>1</show_in_website>
280
+ <show_in_store>1</show_in_store>
281
+ <depends>
282
+ <show_pager>1</show_pager>
283
+ </depends>
284
+ <validate>required-entry</validate>
285
+ </products_per_page>
286
+ <thumbnail_height translate="label">
287
+ <label>Thumbnail Width</label>
288
+ <comment><![CDATA[Default Thumbnail Width: 135px]]></comment>
289
+ <frontend_type>text</frontend_type>
290
+ <sort_order>25</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
+ <validate>required-entry</validate>
295
+ </thumbnail_height>
296
+ <thumbnail_width translate="label">
297
+ <label>Thumbnail Height </label>
298
+ <comment><![CDATA[Default Thumbnail Height: 135px]]></comment>
299
+ <frontend_type>text</frontend_type>
300
+ <sort_order>30</sort_order>
301
+ <show_in_default>1</show_in_default>
302
+ <show_in_website>1</show_in_website>
303
+ <show_in_store>1</show_in_store>
304
+ <validate>required-entry</validate>
305
+ </thumbnail_width>
306
+ </fields>
307
+ </template>
308
+ </groups>
309
+ </featured>
310
+ </sections>
311
+ </config>
app/code/community/CapacityWebSolutions/Featured/etc/widget.xml ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <widgets>
3
+ <featured type="featured/widget">
4
+ <name>MageBees:Featured Products Widget</name>
5
+ <parameters>
6
+ <template>
7
+ <values>
8
+ <list_default translate="label">
9
+ <value>featured/column/featured_default_list.phtml</value>
10
+ <label>Featured 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>Featured Products</value>
50
+ <depends>
51
+ <wd_display_heading><value>1</value></wd_display_heading>
52
+ </depends>
53
+ </wd_heading>
54
+ <wd_display_by>
55
+ <visible>1</visible>
56
+ <label>Select Featured Products Type</label>
57
+ <source_model>featured/system_config_source_choosetype</source_model>
58
+ <type>select</type>
59
+ </wd_display_by>
60
+ <wd_categories translate="label">
61
+ <required>1</required>
62
+ <visible>1</visible>
63
+ <label>Categories</label>
64
+ <type>multiselect</type>
65
+ <source_model>featured/system_config_source_category</source_model>
66
+ <depends>
67
+ <wd_display_by><value>2</value></wd_display_by>
68
+ </depends>
69
+ </wd_categories>
70
+ <wd_sort_by>
71
+ <visible>1</visible>
72
+ <label>Sort By</label>
73
+ <source_model>featured/system_config_source_sortby</source_model>
74
+ <type>select</type>
75
+ </wd_sort_by>
76
+ <wd_sort_order>
77
+ <visible>1</visible>
78
+ <label>Sort Order</label>
79
+ <source_model>featured/system_config_source_sortorder</source_model>
80
+ <type>select</type>
81
+ </wd_sort_order>
82
+ <wd_products_price translate="label">
83
+ <visible>1</visible>
84
+ <label>Show Products Price</label>
85
+ <source_model>adminhtml/system_config_source_yesno</source_model>
86
+ <type>select</type>
87
+ </wd_products_price>
88
+ <wd_review translate="label">
89
+ <visible>1</visible>
90
+ <label>Show Ratings</label>
91
+ <source_model>adminhtml/system_config_source_yesno</source_model>
92
+ <type>select</type>
93
+ </wd_review>
94
+ <wd_short_desc translate="label">
95
+ <visible>1</visible>
96
+ <label>Show Short Description</label>
97
+ <source_model>adminhtml/system_config_source_yesno</source_model>
98
+ <type>select</type>
99
+ </wd_short_desc>
100
+ <wd_desc_limit translate="label">
101
+ <required>1</required>
102
+ <visible>1</visible>
103
+ <label>Short Description Word Limit</label>
104
+ <type>text</type>
105
+ <depends>
106
+ <wd_short_desc><value>1</value></wd_short_desc>
107
+ </depends>
108
+ <value>10</value>
109
+ </wd_desc_limit>
110
+ <wd_add_to_cart translate="label">
111
+ <visible>1</visible>
112
+ <label>Add to Cart</label>
113
+ <source_model>adminhtml/system_config_source_yesno</source_model>
114
+ <type>select</type>
115
+ </wd_add_to_cart>
116
+ <wd_add_to_wishlist translate="label">
117
+ <visible>1</visible>
118
+ <label>Add to Wishlist</label>
119
+ <type>select</type>
120
+ <source_model>adminhtml/system_config_source_yesno</source_model>
121
+ </wd_add_to_wishlist>
122
+ <wd_add_to_compare translate="label">
123
+ <visible>1</visible>
124
+ <label>Add to Compare</label>
125
+ <source_model>adminhtml/system_config_source_yesno</source_model>
126
+ <type>select</type>
127
+ </wd_add_to_compare>
128
+ <wd_out_of_stock translate="label">
129
+ <visible>1</visible>
130
+ <label>Display Out of Stock Products</label>
131
+ <source_model>adminhtml/system_config_source_yesno</source_model>
132
+ <type>select</type>
133
+ </wd_out_of_stock>
134
+ <wd_number_of_items translate="label comment">
135
+ <required>1</required>
136
+ <visible>1</visible>
137
+ <label>Number of Products to Display</label>
138
+ <type>text</type>
139
+ <value>10</value>
140
+ </wd_number_of_items>
141
+ <wd_show_pager translate="label comment">
142
+ <visible>1</visible>
143
+ <label>Display Page Control</label>
144
+ <source_model>adminhtml/system_config_source_yesno</source_model>
145
+ <type>select</type>
146
+ </wd_show_pager>
147
+ <wd_products_per_page translate="label comment">
148
+ <required>1</required>
149
+ <visible>1</visible>
150
+ <label>Number of Products per Page</label>
151
+ <type>text</type>
152
+ <depends>
153
+ <wd_show_pager><value>1</value></wd_show_pager>
154
+ </depends>
155
+ <value>5</value>
156
+ </wd_products_per_page>
157
+ <wd_thumbnail_height translate="label">
158
+ <required>1</required>
159
+ <visible>1</visible>
160
+ <label>Thumbnail Width</label>
161
+ <type>text</type>
162
+ <value>50</value>
163
+ </wd_thumbnail_height>
164
+ <wd_thumbnail_width translate="label">
165
+ <required>1</required>
166
+ <visible>1</visible>
167
+ <label>Thumbnail Height </label>
168
+ <type>text</type>
169
+ <value>50</value>
170
+ </wd_thumbnail_width>
171
+ <template>
172
+ <visible>1</visible>
173
+ <label>Template</label>
174
+ <type>select</type>
175
+ <value>featured/featured-grid.phtml</value>
176
+ <values>
177
+ <grid_template translate="label">
178
+ <value>featured/featured-grid.phtml</value>
179
+ <label>Grid Template</label>
180
+ </grid_template>
181
+ <list_template translate="label">
182
+ <value>featured/featured-list.phtml</value>
183
+ <label>List Template</label>
184
+ </list_template>
185
+ </values>
186
+ </template>
187
+ </parameters>
188
+ </featured>
189
+ </widgets>
app/code/community/CapacityWebSolutions/Featured/sql/featured_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_featured_products')."` (
10
+ `featured_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
11
+ `sku` varchar(64) NOT NULL,
12
+ `store_id` text NOT NULL,
13
+ PRIMARY KEY (`featured_id`),
14
+ KEY `IDX_FEATURED_PRODUCT_SKU` (`sku`)
15
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
16
+
17
+ ALTER TABLE `".$this->getTable('cws_featured_products')."`
18
+ ADD CONSTRAINT `FK_FEATURED_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 ('featured/featured','1');
24
+ ");
25
+ }
26
+
27
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/featured.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <adminhtml_featured_index>
4
+ <reference name="content">
5
+ <!--<block type="adminhtml/store_switcher" name="store_switcher" as="store_switcher">
6
+ <action method="setUseConfirm">
7
+ <params>1</params>
8
+ </action>
9
+ </block>-->
10
+ <!--<block type="featured/adminhtml_featured" name="store_switcher" template="featured/store.phtml" />-->
11
+ <block type="featured/adminhtml_featured" name="featured" ></block>
12
+ </reference>
13
+ </adminhtml_featured_index>
14
+ <adminhtml_featured_edit>
15
+ <reference name="head">
16
+ <action method="addJs"><script>featured/product-selector.js</script></action>
17
+ </reference>
18
+ <reference name="left">
19
+ <block type="adminhtml/store_switcher" name="store_switcher" before="-"></block>
20
+ </reference>
21
+ </adminhtml_featured_edit>
22
+ </layout>
app/design/adminhtml/default/default/template/featured/product.phtml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-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('featured')->__('Manually Products') ?></h4>
25
+
26
+ </div>
27
+ <fieldset id="product_fieldset">
28
+
29
+ <ul>
30
+ <li>
31
+ <span class="product-param">
32
+ <label for="product_sku"><?php echo Mage::helper('featured')->__('Select Featured Product SKUs') ?></label>
33
+ <a class="label" href="javascript:void(0)"><?php if($this->getSkusString()) { echo $this->getSkusString(); } else { echo Mage::helper('featured')->__('Click Here To Add Products'); } ?></a>
34
+ <span class="element">
35
+ <input id="product_sku" class="input-text element-value-changer" type="text" value="<?php echo $this->getSkusString() ?>" name="product_sku">
36
+ <a class="product-chooser-trigger" href="javascript:void(0)">
37
+ <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('featured')->__('Open Chooser') ?>" />
38
+ </a>
39
+ </span>
40
+ </span>
41
+ <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)); ?>">
42
+ </div>
43
+ </li>
44
+ </ul>
45
+ </fieldset>
46
+ </div>
47
+
48
+ <script type="text/javascript">
49
+ 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())) ?>');
50
+ </script>
app/design/frontend/base/default/layout/featured.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="featured/general/enabled"><type>skin_css</type><name>css/featured/featured.css</name><params/></action>
6
+ </reference>
7
+ </default>
8
+ </layout>
app/design/frontend/base/default/template/featured/column/featured_default_list.phtml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ ?>
9
+ <?php
10
+ if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
11
+ <div class="widget widget-new-products">
12
+ <div class="block block-products">
13
+ <?php if($this->getDisplayHeading()): ?>
14
+ <div class="block-title">
15
+ <strong><span><?php echo $this->__($this->getHeading()) ?></span></strong>
16
+ </div>
17
+ <?php endif; ?>
18
+ <div class="block-content">
19
+ <?php echo $this->getPagerHtml() ?>
20
+ <?php $suffix = $this->getNameInLayout(); ?>
21
+ <ol class="mini-products-list" id="widget-new-products-<?php echo $suffix; ?>">
22
+ <?php foreach ($_products->getItems() as $_product): ?>
23
+ <li class="item">
24
+ <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>
25
+ <div class="product-details">
26
+ <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>
27
+ <?php /* Removing this functionality from RWD
28
+ <?php echo $this->getPriceHtml($_product, true, '-widget-new-'.$suffix) ?>
29
+ <?php if ($_product->getIsSalable()): ?>
30
+ <a href="<?php echo $this->getAddToCartUrl($_product) ?>" class="link-cart"><?php echo $this->__('Add to Cart') ?></a>
31
+ <?php else: ?>
32
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
33
+ <?php endif; ?>
34
+ */ ?>
35
+ </div>
36
+ </li>
37
+ <?php endforeach; ?>
38
+ </ol>
39
+ <script type="text/javascript">decorateList('widget-new-products-<?php echo $suffix; ?>', 'none-recursive')</script>
40
+ </div>
41
+ </div>
42
+ </div>
43
+ <?php endif; ?>
app/design/frontend/base/default/template/featured/featured-grid.phtml ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ ?>
9
+
10
+ <?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
11
+
12
+ <div class="featuredProducts default">
13
+ <?php if($this->getDisplayHeading()): ?>
14
+ <div class="title"><h2><?php echo $this->__($this->getHeading()) ?></h2></div>
15
+ <?php endif; ?>
16
+ <?php echo $this->getPagerHtml() ?>
17
+ <?php $_columnCount = $this->getColumnCount();
18
+ $i=0;
19
+ ?>
20
+ <?php if(!$this->getIsResponsive()): ?>
21
+ <?php //for default theme(Non Responsive theme) ?>
22
+ <?php foreach ($_products->getItems() as $_product): ?>
23
+ <?php if ($i++%$_columnCount==0): ?>
24
+ <ul class="products-grid default">
25
+ <?php endif ?>
26
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
27
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image">
28
+ <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) ?>" />
29
+ </a>
30
+ <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>
31
+ <?php if($this->getReview()): ?>
32
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
33
+ <?php endif; ?>
34
+ <?php if($this->getProductsPrice()): ?>
35
+ <?php echo $this->getPriceHtml($_product, true, '-widget-new-grid') ?>
36
+ <?php endif; ?>
37
+ <?php if($this->getShortDesc()): ?>
38
+ <div class="desc std">
39
+ <?php
40
+ $short_desc = $this->htmlEscape($_product->getShortDescription());
41
+ echo $this->limit_word($short_desc,$this->getDescLimit());
42
+ ?>
43
+ </div>
44
+ <?php endif; ?>
45
+ <div class="actions" style="display:block">
46
+ <?php if($this->getAddToCart()): ?>
47
+ <?php if ($_product->isSaleable()): ?>
48
+ <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>
49
+ <?php else: ?>
50
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
51
+ <?php endif; ?>
52
+ <?php endif; ?>
53
+ <?php if($this->getAddToWishlist() || $this->getAddToCompare()): ?>
54
+ <ul class="add-to-links">
55
+ <?php if($this->getAddToWishlist()): ?>
56
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
57
+ <li><a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
58
+ <?php endif; ?>
59
+ <?php endif; ?>
60
+ <?php if($this->getAddToCompare()): ?>
61
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
62
+ <li>
63
+ <?php if($this->getAddToWishlist()): ?>
64
+ <span class="separator">|</span>
65
+ <?php endif; ?>
66
+ <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
67
+ <?php endif; ?>
68
+ <?php endif; ?>
69
+ </ul>
70
+ <?php endif; ?>
71
+ </div>
72
+ </li>
73
+ <?php if ($i%$_columnCount==0 || $i==count($_products)): ?>
74
+ </ul>
75
+ <?php endif ?>
76
+ <?php endforeach; ?>
77
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
78
+
79
+ <?php else: ?>
80
+ <?php //for responsive theme ?>
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">
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/featured/featured-list.phtml ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : Featured Products
4
+ Extension URL : http://www.magebees.com/magento-featured-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="featuredProducts">
11
+ <?php if($this->getDisplayHeading()): ?>
12
+ <div class="title">
13
+ <h2><?php echo $this->__($this->getHeading()) ?></h2>
14
+ </div>
15
+ <?php endif; ?>
16
+ <?php echo $this->getPagerHtml() ?>
17
+ <?php if(!$this->getIsResponsive()): ?>
18
+ <?php //for default theme(Non Responsive theme) ?>
19
+ <ul class="products-list default">
20
+ <?php $i=0; foreach ($_products->getItems() as $_product): ?>
21
+ <li class="item<?php echo (++$i == count($_products))?' last':''; ?>">
22
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image">
23
+ <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) ?>" />
24
+ </a>
25
+ <div class="product-shop">
26
+ <div class="f-fix">
27
+ <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>
28
+ <?php if($this->getReview()): ?>
29
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
30
+ <?php endif; ?>
31
+ <?php if($this->getProductsPrice()): ?>
32
+ <?php echo $this->getPriceHtml($_product, true, '-widget-new-list') ?>
33
+ <?php endif; ?>
34
+
35
+ <?php if($this->getAddToCart()): ?>
36
+ <?php if ($_product->isSaleable()): ?>
37
+ <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>
38
+ <?php else: ?>
39
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
40
+ <?php endif; ?>
41
+ <?php endif; ?>
42
+
43
+ <?php if($this->getShortDesc()): ?>
44
+ <div class="desc std">
45
+ <?php
46
+ $short_desc = $this->htmlEscape($_product->getShortDescription());
47
+ echo $this->limit_word($short_desc,$this->getDescLimit());
48
+ ?>
49
+ </div>
50
+ <?php endif; ?>
51
+ <?php if($this->getAddToWishlist() || $this->getAddToCompare()): ?>
52
+ <ul class="add-to-links">
53
+ <?php if($this->getAddToWishlist()): ?>
54
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
55
+ <li><a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
56
+ <?php endif; ?>
57
+ <?php endif; ?>
58
+ <?php if($this->getAddToCompare()): ?>
59
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
60
+ <li>
61
+ <?php if($this->getAddToWishlist()): ?>
62
+ <span class="separator">|</span>
63
+ <?php endif; ?>
64
+ <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
65
+ <?php endif; ?>
66
+ <?php endif; ?>
67
+ </ul>
68
+ <?php endif; ?>
69
+ </div>
70
+ </div>
71
+ </li>
72
+ <?php endforeach; ?>
73
+ </ul>
74
+ <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
75
+ <?php else: ?>
76
+ <?php //for Responsive theme ?>
77
+ <ul class="products-list rwd">
78
+ <?php $i=0; foreach ($_products->getItems() as $_product): ?>
79
+ <li class="item<?php echo (++$i == count($_products))?' last':''; ?>">
80
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image">
81
+ <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) ?>" />
82
+ </a>
83
+ <div class="product-shop">
84
+ <div class="f-fix">
85
+ <div class="product-primary">
86
+ <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>
87
+ <?php if($this->getReview()): ?>
88
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
89
+ <?php endif; ?>
90
+ </div>
91
+ <div class="product-secondary">
92
+ <?php if($this->getProductsPrice()): ?>
93
+ <?php echo $this->getPriceHtml($_product, true, '-widget-new-list') ?>
94
+ <?php endif; ?>
95
+ </div>
96
+ <div class="product-secondary">
97
+ <?php if($this->getAddToCart()): ?>
98
+ <?php if($_product->isSaleable()): ?>
99
+ <button class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')">
100
+ <span><?php echo $this->__('Add to Cart') ?></span>
101
+ </button>
102
+ <?php elseif($_product->isSaleable()): ?>
103
+ <button class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')">
104
+ <span><?php echo $this->__('View Details')?></span>
105
+ </button>
106
+ <?php else: ?>
107
+ <span class="out-of-stock">
108
+ <?php echo $this->__('Out of stock') ?>
109
+ </span>
110
+ <?php endif; ?>
111
+ <?php endif; ?>
112
+ <?php if($this->getAddToWishlist() || $this->getAddToCompare()): ?>
113
+ <ul class="add-to-links">
114
+ <?php if($this->getAddToWishlist()): ?>
115
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
116
+ <li><a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
117
+ <?php endif; ?>
118
+ <?php endif; ?>
119
+ <?php if($this->getAddToCompare()): ?>
120
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
121
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
122
+ <?php endif; ?>
123
+ <?php endif; ?>
124
+ </ul>
125
+ <?php endif; ?>
126
+ </div>
127
+ <?php if($this->getShortDesc()): ?>
128
+ <div class="desc std">
129
+ <?php
130
+ $short_desc = $this->htmlEscape($_product->getShortDescription());
131
+ echo $this->limit_word($short_desc,$this->getDescLimit());
132
+ ?>
133
+ </div>
134
+ <?php endif; ?>
135
+ </div>
136
+ </div>
137
+ </li>
138
+ <?php endforeach; ?>
139
+ </ul>
140
+ <?php endif; ?>
141
+ </div>
142
+ <?php endif; ?>
app/etc/modules/CapacityWebSolutions_Featured.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <CapacityWebSolutions_Featured>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </CapacityWebSolutions_Featured>
8
+ </modules>
9
+ </config>
js/featured/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>MageBees_Featured_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 display featured products.</summary>
10
+ <description>Display selected products on front end as a Featured Products with different options. Using widget user can display featured products block with it's options.</description>
11
+ <notes>Featured Products</notes>
12
+ <authors><author><name>Capacity Web Solutions</name><user>capacitywebsolutions</user><email>magento@capacitywebsolutions.com</email></author></authors>
13
+ <date>2016-04-07</date>
14
+ <time>07:52:07</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="CapacityWebSolutions_Featured.xml" hash="82e9b56df2cc1ad58400644416ad667c"/></dir></target><target name="magecommunity"><dir name="CapacityWebSolutions"><dir name="Featured"><dir name="Block"><dir name="Adminhtml"><file name="DefaultDirectCode.php" hash="365c517ed05c9c2ea5121313d3aaf8dd"/><file name="DefaultTemplate.php" hash="8bae5448603570bb82a401d4da4db05b"/><file name="DefaultXML.php" hash="d12ab8455c7956752d11a945734598f7"/><dir name="Featured"><dir name="Edit"><file name="Form.php" hash="79a5ebf4779639aad368e66c71a618d7"/><dir name="Tab"><file name="Products.php" hash="7f3dfc8bbb18d0c7bb0617c24bc9b969"/></dir><file name="Tabs.php" hash="87f43cb15c86b60c253fae527c17e890"/></dir><file name="Edit.php" hash="400e55400df83d06582ba814a4a6ee77"/><file name="Grid.php" hash="6cefc3ebf9e7f36c345399b641988fa9"/></dir><file name="Featured.php" hash="f4536f51d7e76cd10f1e91a9d823a2bc"/></dir><file name="Featured.php" hash="0a820dd3b78552a7a5eac5f2985fabc1"/><dir name="Promo"><dir name="Widget"><dir name="Chooser"><file name="Sku.php" hash="c138832f4c15379a71313b221e88efba"/></dir></dir></dir><dir name="Widget"><dir name="Html"><file name="Pager.php" hash="3f94ed88e040c7ea91e9421bfc5180eb"/></dir></dir><file name="Widget.php" hash="65fdaac9db085796cb36a2b93cd546f8"/></dir><dir name="Helper"><file name="Data.php" hash="62da019efdfe21ba8bcaabd5d50465ab"/></dir><dir name="Model"><file name="Featured.php" hash="124bceaa68a64b4795523d4a9e451d83"/><dir name="Mysql4"><dir name="Featured"><file name="Collection.php" hash="a92629e34da777ea2c17c4f83ab60d95"/></dir><file name="Featured.php" hash="3ab9c26fdbf2d1bec514fcbc851a14d0"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Category.php" hash="89e7d3dc7fe02dabcb56bfbb9924ddc6"/><file name="Choosetype.php" hash="17ab705b39f7189fc29386aae9f4951a"/><file name="Sortby.php" hash="d5d709ffa7a23df3a5dcccf3d979d212"/><file name="Sortorder.php" hash="bbbe872149abfeb6814929d892453d81"/><file name="Template.php" hash="ffa1dc17f7d34940916bd4e3e7ee5ebb"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="FeaturedController.php" hash="9bea2bfd6ce6496c117d5854e96b922c"/><file name="WidgetController.php" hash="629ec929a50d051654f75e6538ffda29"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="8269fddf3364cde301c5281488e543a4"/><file name="config.xml" hash="816cc7540a089df49cae2e34a36e658b"/><file name="system.xml" hash="fefebc270cfda29fa003fb65cff362ae"/><file name="widget.xml" hash="d20615ddb5814e6bc23a5558e3da4949"/></dir><dir name="sql"><dir name="featured_setup"><file name="mysql4-install-1.0.0.php" hash="a3b2d1a0e77d1f5de05df1535ba13eeb"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="featured.xml" hash="670dea54f5a56c7f63890edd3b0678cb"/></dir><dir name="template"><dir name="featured"><file name="product.phtml" hash="23ab4606cb355f622609ab7bd3e11776"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="featured.xml" hash="65940aea59c4f3e65d92c8da9a0f6bfe"/></dir><dir name="template"><dir name="featured"><dir name="column"><file name="featured_default_list.phtml" hash="7fdb0d150b8917205443b9d5b7621631"/></dir><file name="featured-grid.phtml" hash="57f52545035a3868443eae2cfbab4e97"/><file name="featured-list.phtml" hash="26dc0ad9f37ab40ef94c991d262bbb26"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="featured"><file name="featured.css" hash="a3e087f39095ce97df73ae2b6d542c76"/></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="featured"><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/featured/featured.css ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .featuredProducts { margin-bottom:30px; }
2
+ .featuredProducts ul, .featuredProducts ul ul, .featuredProducts ol, .featuredProducts ul.products-grid, .featuredProducts ul.products-list { list-style:none; margin:0; padding:0;}
3
+ .featuredProducts ul li, .featuredProducts .pager .pages ol li { margin-left:0; }
4
+
5
+ .featuredProducts .pager { float:none; border-bottom:1px dotted #ddd; border-top:1px dotted #ddd; padding:10px 10px 5px; margin-bottom:20px; }
6
+
7
+ .featuredProducts .title h2 { font-weight:600; margin:10px 0; }
8
+
9
+ .featuredProducts .products-grid .price-box p { margin-bottom:0; }
10
+ .featuredProducts ul.products-list.rwd .price-box p { display:inline-block; margin:0 0 0 15px; }
11
+ .featuredProducts ul.products-list.default .price-box p { margin:0 0 3px; }
12
+
13
+ .default ul ul.add-to-links { margin-top:5px; }