MageBees_New_Products - Version 1.0.0

Version Notes

New Products

Download this release

Release Info

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


Version 1.0.0

Files changed (40) hide show
  1. app/code/community/CapacityWebSolutions/Newproducts/Block/Adminhtml/DefaultDirectCode.php +16 -0
  2. app/code/community/CapacityWebSolutions/Newproducts/Block/Adminhtml/DefaultTemplate.php +16 -0
  3. app/code/community/CapacityWebSolutions/Newproducts/Block/Adminhtml/DefaultXML.php +19 -0
  4. app/code/community/CapacityWebSolutions/Newproducts/Block/Adminhtml/Newproducts.php +29 -0
  5. app/code/community/CapacityWebSolutions/Newproducts/Block/Adminhtml/Newproducts/Edit.php +41 -0
  6. app/code/community/CapacityWebSolutions/Newproducts/Block/Adminhtml/Newproducts/Edit/Form.php +24 -0
  7. app/code/community/CapacityWebSolutions/Newproducts/Block/Adminhtml/Newproducts/Edit/Tab/Products.php +26 -0
  8. app/code/community/CapacityWebSolutions/Newproducts/Block/Adminhtml/Newproducts/Edit/Tabs.php +28 -0
  9. app/code/community/CapacityWebSolutions/Newproducts/Block/Adminhtml/Newproducts/Grid.php +184 -0
  10. app/code/community/CapacityWebSolutions/Newproducts/Block/Newproducts.php +294 -0
  11. app/code/community/CapacityWebSolutions/Newproducts/Block/Promo/Widget/Chooser/Sku.php +158 -0
  12. app/code/community/CapacityWebSolutions/Newproducts/Block/Widget.php +25 -0
  13. app/code/community/CapacityWebSolutions/Newproducts/Block/Widget/Html/Pager.php +273 -0
  14. app/code/community/CapacityWebSolutions/Newproducts/Helper/Data.php +17 -0
  15. app/code/community/CapacityWebSolutions/Newproducts/Model/Mysql4/Newproducts.php +14 -0
  16. app/code/community/CapacityWebSolutions/Newproducts/Model/Mysql4/Newproducts/Collection.php +16 -0
  17. app/code/community/CapacityWebSolutions/Newproducts/Model/Newproducts.php +15 -0
  18. app/code/community/CapacityWebSolutions/Newproducts/Model/System/Config/Source/Category.php +64 -0
  19. app/code/community/CapacityWebSolutions/Newproducts/Model/System/Config/Source/Chooseproducts.php +1 -0
  20. app/code/community/CapacityWebSolutions/Newproducts/Model/System/Config/Source/Choosetype.php +1 -0
  21. app/code/community/CapacityWebSolutions/Newproducts/Model/System/Config/Source/Sortby.php +1 -0
  22. app/code/community/CapacityWebSolutions/Newproducts/Model/System/Config/Source/Sortorder.php +1 -0
  23. app/code/community/CapacityWebSolutions/Newproducts/Model/System/Config/Source/Template.php +1 -0
  24. app/code/community/CapacityWebSolutions/Newproducts/controllers/Adminhtml/NewproductsController.php +266 -0
  25. app/code/community/CapacityWebSolutions/Newproducts/controllers/Adminhtml/WidgetController.php +34 -0
  26. app/code/community/CapacityWebSolutions/Newproducts/etc/adminhtml.xml +46 -0
  27. app/code/community/CapacityWebSolutions/Newproducts/etc/config.xml +126 -0
  28. app/code/community/CapacityWebSolutions/Newproducts/etc/system.xml +350 -0
  29. app/code/community/CapacityWebSolutions/Newproducts/etc/widget.xml +212 -0
  30. app/code/community/CapacityWebSolutions/Newproducts/sql/newproducts_setup/mysql4-install-1.0.0.php +27 -0
  31. app/design/adminhtml/default/default/layout/newproducts.xml +16 -0
  32. app/design/adminhtml/default/default/template/newproducts/product.phtml +49 -0
  33. app/design/frontend/base/default/layout/newproducts.xml +8 -0
  34. app/design/frontend/base/default/template/newproducts/column/newproducts_default_list.phtml +42 -0
  35. app/design/frontend/base/default/template/newproducts/newproducts-grid.phtml +139 -0
  36. app/design/frontend/base/default/template/newproducts/newproducts-list.phtml +143 -0
  37. app/etc/modules/CapacityWebSolutions_Newproducts.xml +9 -0
  38. js/newproducts/product-selector.js +193 -0
  39. package.xml +18 -0
  40. skin/frontend/base/default/css/newproducts/newproducts.css +13 -0
app/code/community/CapacityWebSolutions/Newproducts/Block/Adminhtml/DefaultDirectCode.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Newproducts_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("newproducts/newproducts")->toHtml(); ?&gt;</span></div>';
14
+ }
15
+
16
+ }
app/code/community/CapacityWebSolutions/Newproducts/Block/Adminhtml/DefaultTemplate.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Newproducts_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="newproducts/newproducts" name="newproducts"}}</span></div>';
14
+ }
15
+
16
+ }
app/code/community/CapacityWebSolutions/Newproducts/Block/Adminhtml/DefaultXML.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Newproducts_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="newproducts/newproducts" name="newproducts"/&gt;</br>&lt;/reference&gt;</span>
15
+ </div>';
16
+
17
+ }
18
+
19
+ }
app/code/community/CapacityWebSolutions/Newproducts/Block/Adminhtml/Newproducts.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Newproducts_Block_Adminhtml_Newproducts extends Mage_Adminhtml_Block_Widget_Grid_Container
9
+ {
10
+ public function __construct()
11
+ {
12
+ $this->_controller = 'adminhtml_newproducts';
13
+ $this->_blockGroup = 'newproducts';
14
+ $this->_headerText = Mage::helper('newproducts')->__('Manage New Products');
15
+ $this->_addButtonLabel = Mage::helper('newproducts')->__('Select Products');
16
+ parent::__construct();
17
+ }
18
+
19
+ protected function _prepareLayout() {
20
+ $this->setChild('store_switcher', $this->getLayout()->createBlock('adminhtml/store_switcher', 'store_switcher')->setUseConfirm(false)
21
+ );
22
+ return parent::_prepareLayout();
23
+ }
24
+
25
+ public function getGridHtml() {
26
+
27
+ return $this->getChildHtml('store_switcher') . $this->getChildHtml('grid');
28
+ }
29
+ }
app/code/community/CapacityWebSolutions/Newproducts/Block/Adminhtml/Newproducts/Edit.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Newproducts_Block_Adminhtml_Newproducts_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
9
+ {
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+ $this->_objectId = 'id';
14
+ $this->_blockGroup = 'newproducts';
15
+ $this->_controller = 'adminhtml_newproducts';
16
+ $this->_updateButton('save', 'label','Save');
17
+ $this->_updateButton('delete','label','Delete');
18
+ $this->_addButton('save_and_continue', array(
19
+ 'label' => Mage::helper('newproducts')->__('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('newproducts_edit');
31
+ }
32
+
33
+ public function getHeaderText()
34
+ {
35
+ if( Mage::registry('newproducts_data') && Mage::registry('newproducts_data')->getNewproductsId() ) {
36
+ return Mage::helper('newproducts')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('newproducts_data')->getSku()));
37
+ } else {
38
+ return Mage::helper('newproducts')->__('Select Products');
39
+ }
40
+ }
41
+ }
app/code/community/CapacityWebSolutions/Newproducts/Block/Adminhtml/Newproducts/Edit/Form.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Newproducts_Block_Adminhtml_Newproducts_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/Newproducts/Block/Adminhtml/Newproducts/Edit/Tab/Products.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Newproducts_Block_Adminhtml_Newproducts_Edit_Tab_Products extends Mage_Adminhtml_Block_Widget_Form
9
+ {
10
+ public function __construct() {
11
+ parent::__construct();
12
+ $this->setTemplate('newproducts/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('newproducts/newproducts')->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
+ }
app/code/community/CapacityWebSolutions/Newproducts/Block/Adminhtml/Newproducts/Edit/Tabs.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Newproducts_Block_Adminhtml_Newproducts_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
9
+ {
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+ $this->setId('newproducts_tabs');
14
+ $this->setDestElementId('edit_form');
15
+ $this->setTitle('Newproducts Information');
16
+ }
17
+
18
+ protected function _beforeToHtml()
19
+ {
20
+ $this->addTab('product_section', array(
21
+ 'label' => Mage::helper('newproducts')->__('Products'),
22
+ 'title' => Mage::helper('newproducts')->__('Products'),
23
+ 'content' => $this->getLayout()->createBlock('newproducts/adminhtml_newproducts_edit_tab_products')->toHtml(),
24
+ ));
25
+
26
+ return parent::_beforeToHtml();
27
+ }
28
+ }
app/code/community/CapacityWebSolutions/Newproducts/Block/Adminhtml/Newproducts/Grid.php ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Newproducts_Block_Adminhtml_Newproducts_Grid extends Mage_Adminhtml_Block_Widget_Grid
9
+ {
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+ $this->setId('newproductsGrid');
14
+ //$this->setDefaultSort('newproducts_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('newproducts_id', array(
88
+ 'header' => Mage::helper('newproducts')->__('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('newproducts/newproducts')->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
+
157
+ //public function getRowUrl($row)
158
+ //{
159
+ //return $this->getUrl('*/*/edit', array('id' => $row->getId()));
160
+ //}
161
+
162
+ protected function _prepareMassaction()
163
+ {
164
+ $store_id = Mage::app()->getRequest()->getParam('store',0);
165
+ $url = $this->getUrl('*/*/massDelete',array('store'=>$store_id));
166
+
167
+ $this->setMassactionIdField('newproducts_id');
168
+ $this->getMassactionBlock()->setFormFieldName('newproducts');
169
+
170
+ $this->getMassactionBlock()->addItem('delete', array(
171
+ 'label' => Mage::helper('newproducts')->__('Delete'),
172
+ 'url' => $url,
173
+ 'confirm' => Mage::helper('newproducts')->__('Are you sure?')
174
+ ));
175
+
176
+ return $this;
177
+ }
178
+
179
+ public function getGridUrl()
180
+ {
181
+ return $this->getUrl('*/*/grid', array('_current'=>true));
182
+ }
183
+
184
+ }
app/code/community/CapacityWebSolutions/Newproducts/Block/Newproducts.php ADDED
@@ -0,0 +1,294 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Newproducts_Block_Newproducts extends Mage_Catalog_Block_Product_New //Mage_Catalog_Block_Product_Abstract
9
+ {
10
+ /**
11
+ * Name of request parameter for page number value
12
+ */
13
+ const PAGE_VAR_NAME = 'np';
14
+
15
+ public function __construct() {
16
+ parent::_construct();
17
+ $this->addColumnCountLayoutDepend('empty', 6)
18
+ ->addColumnCountLayoutDepend('one_column', 5)
19
+ ->addColumnCountLayoutDepend('two_columns_left', 4)
20
+ ->addColumnCountLayoutDepend('two_columns_right', 4)
21
+ ->addColumnCountLayoutDepend('three_columns', 3);
22
+
23
+ $this->setStoreId(Mage::app()->getStore()->getId());
24
+
25
+ //General Settings
26
+ $this->setEnabled((bool)Mage::getStoreConfig("newproducts/general/enabled"));
27
+ $this->setDisplayHeading((bool)Mage::getStoreConfig("newproducts/general/display_heading"));
28
+ $this->setHeading(Mage::getStoreConfig("newproducts/general/heading"));
29
+ $this->setChooseProducts(Mage::getStoreConfig("newproducts/general/choose_products"));
30
+ $this->setChooseType((bool)Mage::getStoreConfig("newproducts/general/choose_type"));
31
+ $this->setDays((int)Mage::getStoreConfig("newproducts/general/new_days"));
32
+ $this->setDisplayBy(Mage::getStoreConfig("newproducts/general/display_by"));
33
+ $this->setCategories(Mage::getStoreConfig("newproducts/general/categories"));
34
+ $this->setSortBy(Mage::getStoreConfig("newproducts/general/sort_by"));
35
+ $this->setSortOrder(Mage::getStoreConfig("newproducts/general/sort_order"));
36
+
37
+ $this->setProductsPrice((bool)Mage::getStoreConfig("newproducts/general/products_price"));
38
+ $this->setReview((bool)Mage::getStoreConfig("newproducts/general/review"));
39
+ $this->setShortDesc((bool)Mage::getStoreConfig("newproducts/general/short_desc"));
40
+ $this->setDescLimit((int)Mage::getStoreConfig("newproducts/general/desc_limit"));
41
+ $this->setAddToCart((bool)Mage::getStoreConfig("newproducts/general/add_to_cart"));
42
+ $this->setAddToWishlist((bool)Mage::getStoreConfig("newproducts/general/add_to_wishlist"));
43
+ $this->setAddToCompare((bool)Mage::getStoreConfig("newproducts/general/add_to_compare"));
44
+ $this->setOutOfStock((bool)Mage::getStoreConfig("newproducts/general/out_of_stock"));
45
+ $this->setIsResponsive((bool)Mage::getStoreConfig('newproducts/general/isresponsive'));
46
+
47
+ //Template Settings
48
+ $this->setCustomTemplate(Mage::getStoreConfig("newproducts/template/select_template"));
49
+ $this->setProductsCount((int)Mage::getStoreConfig("newproducts/template/number_of_items"));
50
+ $this->setShowPager((bool)Mage::getStoreConfig("newproducts/template/show_pager"));
51
+ $this->setProductsPerPage((int)Mage::getStoreConfig("newproducts/template/products_per_page"));
52
+ $this->setHeight((int)Mage::getStoreConfig("newproducts/template/thumbnail_height"));
53
+ $this->setWidth((int)Mage::getStoreConfig("newproducts/template/thumbnail_width"));
54
+ }
55
+
56
+ public function setWidgetOptions(){
57
+ //General Settings
58
+ $this->setDisplayHeading((bool)$this->getWdDisplayHeading());
59
+ $this->setHeading($this->getWdHeading());
60
+ $this->setChooseProducts($this->getWdChooseProducts());
61
+ $this->setChooseType($this->getWdChooseType());
62
+ $this->setDays((int)$this->getWdNewDays());
63
+ $this->setDisplayBy((int)$this->getWdDisplayBy());
64
+ $this->setCategories($this->getWdCategories());
65
+ $this->setSortBy($this->getWdSortBy());
66
+ $this->setSortOrder($this->getWdSortOrder());
67
+ $this->setProductsPrice((bool)$this->getWdProductsPrice());
68
+ $this->setReview((bool)$this->getWdReview());
69
+ $this->setShortDesc((bool)$this->getWdShortDesc());
70
+ $this->setDescLimit((int)$this->getWdDescLimit());
71
+ $this->setAddToCart((bool)$this->getWdAddToCart());
72
+ $this->setAddToWishlist((bool)$this->getWdAddToWishlist());
73
+ $this->setAddToCompare((bool)$this->getWdAddToCompare());
74
+ $this->setOutOfStock((bool)$this->getWdOutOfStock());
75
+
76
+ //Template Settings
77
+ $this->setProductsCount((int)$this->getWdNumberOfItems());
78
+ $this->setShowPager((bool)$this->getWdShowPager());
79
+ $this->setProductsPerPage((int)$this->getWdProductsPerPage());
80
+ $this->setHeight((int)$this->getWdThumbnailHeight());
81
+ $this->setWidth((int)$this->getWdThumbnailWidth());
82
+ }
83
+
84
+ protected function _getProductCollection() {
85
+ switch ($this->getChooseProducts()) {
86
+ case 1: //Auto
87
+ if($this->getChooseType()){
88
+ //$collection = parent::_getProductCollection();
89
+ $collection = $this->_getAutoProductCollection();
90
+ }else{
91
+ $collection = $this->_getProductsCollectionByCreatedDate();
92
+ }
93
+ break;
94
+ case 2: //Manually
95
+ $collection = $this->_getManuallyAddedProductsCollection();
96
+ break;
97
+ case 3: //Both
98
+ if($this->getChooseType()){
99
+ $collection1 = $this->_getAutoProductCollection();
100
+ }else{
101
+ $collection1 = $this->_getProductsCollectionByCreatedDate();
102
+ }
103
+ $collection2 = $this->_getManuallyAddedProductsCollection();
104
+
105
+ $merged_ids = array_unique(array_merge($collection1->getAllIds(), $collection2->getAllIds()));
106
+
107
+ $collection = Mage::getResourceModel('catalog/product_collection')
108
+ ->addFieldToFilter('entity_id', array('in' => $merged_ids))
109
+ ->addAttributeToSelect('*');
110
+ break;
111
+ default:
112
+ $collection = $this->_getAutoProductCollection();
113
+ break;
114
+ }
115
+
116
+ $storeId = Mage::app()->getStore()->getId();
117
+
118
+ $collection ->addMinimalPrice()
119
+ ->addFinalPrice()
120
+ ->setStore($storeId)
121
+ ->addStoreFilter($storeId)
122
+ ->setPageSize($this->getProductsCount())
123
+ ->setCurPage(1)
124
+ ;
125
+
126
+ //Display out of stock products
127
+ if(!$this->getOutOfStock()){
128
+ Mage::getSingleton('cataloginventory/stock')
129
+ ->addInStockFilterToCollection($collection);
130
+ }
131
+
132
+ //Display By Category
133
+ if($this->getDisplayBy()==2)
134
+ {
135
+ $categorytable = Mage::getSingleton('core/resource')->getTableName('catalog_category_product');
136
+ $collection->getSelect()
137
+ ->joinLeft(array('at_category_id' => $categorytable),'e.entity_id = at_category_id.product_id','at_category_id.category_id')
138
+ ->group('e.entity_id')
139
+ ->where("at_category_id.category_id IN (".$this->getCategories().")")
140
+ ;
141
+ }
142
+
143
+ //Set Sort Order
144
+ if($this->getSortOrder()=='rand'){
145
+ $collection->getSelect()->order('rand()');
146
+ }else{
147
+ $collection->addAttributeToSort($this->getSortBy(), $this->getSortOrder());
148
+ }
149
+
150
+ return $collection;
151
+ }
152
+
153
+ /**
154
+ * Prepare collection with new products
155
+ *
156
+ * @return Mage_Core_Block_Abstract
157
+ */
158
+ protected function _beforeToHtml(){
159
+ if($this->getType()=="newproducts/widget")
160
+ {
161
+ $this->setWidgetOptions();
162
+ }
163
+ $this->setProductCollection($this->_getProductCollection());
164
+ }
165
+
166
+ //Get new products collection as per new from and new to date
167
+ protected function _getAutoProductCollection(){
168
+ $todayStartOfDayDate = Mage::app()->getLocale()->date()
169
+ ->setTime('00:00:00')
170
+ ->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
171
+
172
+ $todayEndOfDayDate = Mage::app()->getLocale()->date()
173
+ ->setTime('23:59:59')
174
+ ->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
175
+
176
+ /** @var $collection Mage_Catalog_Model_Resource_Product_Collection */
177
+ $collection = Mage::getResourceModel('catalog/product_collection');
178
+ $collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
179
+
180
+
181
+ $collection = $this->_addProductAttributesAndPrices($collection)
182
+ ->addStoreFilter()
183
+ ->addAttributeToFilter('news_from_date', array('or'=> array(
184
+ 0 => array('date' => true, 'to' => $todayEndOfDayDate),
185
+ 1 => array('is' => new Zend_Db_Expr('null')))
186
+ ), 'left')
187
+ ->addAttributeToFilter('news_to_date', array('or'=> array(
188
+ 0 => array('date' => true, 'from' => $todayStartOfDayDate),
189
+ 1 => array('is' => new Zend_Db_Expr('null')))
190
+ ), 'left')
191
+ ->addAttributeToFilter(
192
+ array(
193
+ array('attribute' => 'news_from_date', 'is'=>new Zend_Db_Expr('not null')),
194
+ array('attribute' => 'news_to_date', 'is'=>new Zend_Db_Expr('not null'))
195
+ )
196
+ )
197
+ ->addAttributeToSort('news_from_date', 'desc')
198
+ ;
199
+
200
+ return $collection;
201
+ }
202
+
203
+ protected function _getManuallyAddedProductsCollection(){
204
+ /** @var $collection Mage_Catalog_Model_Resource_Product_Collection */
205
+ $collection = Mage::getResourceModel('catalog/product_collection');
206
+ $collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
207
+
208
+ $collection = $this->_addProductAttributesAndPrices($collection)
209
+ ->addAttributeToFilter('sku', array('in' => $this->getSkus()));
210
+ return $collection;
211
+ }
212
+
213
+ protected function _getProductsCollectionByCreatedDate()
214
+ {
215
+ $days = $this->getDays();
216
+ //$to = date('Y-m-d', $time);
217
+ //$time = Mage::getModel('core/date')->timestamp(time());
218
+
219
+ $to = Mage::getSingleton('core/date')->gmtDate();
220
+ $time = strtotime(Mage::getSingleton('core/date')->gmtDate());
221
+ $lastTime = $time - (60*60*24*$days);
222
+ $from = date('Y-m-d H:i:s', $lastTime);
223
+
224
+ $collection = Mage::getResourceModel('catalog/product_collection');
225
+ $collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
226
+ $collection = $this->_addProductAttributesAndPrices($collection);
227
+ $collection->addAttributeToSelect('*')
228
+ ->addAttributeToSort('created_at', 'desc')
229
+ ->addAttributeToFilter('created_at', array('from' => $from, 'to' => $to));
230
+ return $collection;
231
+ }
232
+
233
+ public function getSkusArr($element){
234
+ return $element['sku'];
235
+ }
236
+
237
+ public function getSkus(){
238
+ $store_id = $this->getStoreId();
239
+ $newproductsCollection = Mage::getModel('newproducts/newproducts')->getCollection()->addFieldToFilter('store_id', array(array('finset' => $store_id)));
240
+ $product_skus=array_map(array($this,"getSkusArr"), $newproductsCollection->getData());
241
+ return $product_skus;
242
+ }
243
+
244
+ public function limit_word($text, $limit) {
245
+ if (str_word_count($text, 0) > $limit) {
246
+ $words = str_word_count($text, 2);
247
+ $pos = array_keys($words);
248
+ $text = substr($text, 0, $pos[$limit]) . '...';
249
+ }
250
+ return $text;
251
+ }
252
+
253
+ public function _toHtml(){
254
+ if (!$this->getEnabled()) {
255
+ return '';
256
+ }
257
+ if(!$this->getTemplate()){
258
+ if($this->getCustomTemplate()==2){
259
+ $this->setTemplate('newproducts/newproducts-list.phtml');
260
+ }else{
261
+ $this->setTemplate('newproducts/newproducts-grid.phtml');
262
+ }
263
+ }
264
+ return parent::_toHtml();
265
+ }
266
+
267
+ /**
268
+ * Render pagination HTML
269
+ *
270
+ * @return string
271
+ */
272
+ public function getPagerHtml()
273
+ {
274
+ if ($this->getShowPager()) {
275
+ if (!$this->_pager) {
276
+ $this->_pager = $this->getLayout()
277
+ ->createBlock('newproducts/widget_html_pager', 'widget.new.product.list.pager');
278
+
279
+ $this->_pager->setUseContainer(true)
280
+ ->setShowAmounts(true)
281
+ ->setShowPerPage(false)
282
+ ->setPageVarName(self::PAGE_VAR_NAME)
283
+ ->setLimit($this->getProductsPerPage())
284
+ ->setTotalLimit($this->getProductsCount())
285
+ ->setCollection($this->getProductCollection());
286
+ }
287
+ if ($this->_pager instanceof Mage_Core_Block_Abstract) {
288
+ return $this->_pager->toHtml();
289
+ }
290
+ }
291
+ return '';
292
+ }
293
+
294
+ }
app/code/community/CapacityWebSolutions/Newproducts/Block/Promo/Widget/Chooser/Sku.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Newproducts_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/Newproducts/Block/Widget.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Newproducts_Block_Widget extends CapacityWebSolutions_Newproducts_Block_Newproducts // 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/Newproducts/Block/Widget/Html/Pager.php ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Newproducts_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/Newproducts/Helper/Data.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Newproducts_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/Newproducts/Model/Mysql4/Newproducts.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Newproducts_Model_Mysql4_Newproducts extends Mage_Core_Model_Mysql4_Abstract
9
+ {
10
+ public function _construct()
11
+ {
12
+ $this->_init('newproducts/newproducts', 'newproducts_id');
13
+ }
14
+ }
app/code/community/CapacityWebSolutions/Newproducts/Model/Mysql4/Newproducts/Collection.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_newproducts_Model_Mysql4_newproducts_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
9
+ {
10
+ public function _construct()
11
+ {
12
+ parent::_construct();
13
+ $this->_init('newproducts/newproducts');
14
+ }
15
+
16
+ }
app/code/community/CapacityWebSolutions/Newproducts/Model/Newproducts.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Newproducts_Model_Newproducts extends Mage_Core_Model_Abstract
9
+ {
10
+ public function _construct()
11
+ {
12
+ parent::_construct();
13
+ $this->_init('newproducts/newproducts');
14
+ }
15
+ }
app/code/community/CapacityWebSolutions/Newproducts/Model/System/Config/Source/Category.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ class CapacityWebSolutions_Newproducts_Model_System_Config_Source_Category
9
+ {
10
+ public function buildCategoriesMultiselectValues(Varien_Data_Tree_Node $node, $values, $level = 0)
11
+ {
12
+ $nonEscapableNbspChar = html_entity_decode('&#160;', ENT_NOQUOTES, 'UTF-8');
13
+
14
+ $level++;
15
+ if ($level > 2) {
16
+ $values[$node->getId()]['value'] = $node->getId();
17
+ $values[$node->getId()]['label'] = str_repeat($nonEscapableNbspChar, ($level - 3) * 5).$node->getName();
18
+ }
19
+
20
+ foreach ($node->getChildren() as $child) {
21
+ $values = $this->buildCategoriesMultiselectValues($child, $values, $level);
22
+ }
23
+
24
+ return $values;
25
+ }
26
+
27
+ public function toOptionArray()
28
+ {
29
+ $tree = Mage::getResourceSingleton('catalog/category_tree')->load();
30
+
31
+ $parentId = 1;
32
+
33
+ $root = $tree->getNodeById($parentId);
34
+
35
+ if($root && $root->getId() == 1) {
36
+ $root->setName(Mage::helper('catalog')->__('Root'));
37
+ }
38
+
39
+ $storeCode = Mage::app()->getRequest()->getParam('store',0);
40
+ $store_id = Mage::getModel('core/store')->load($storeCode, 'code')->getId();
41
+
42
+ $rootCategoryId = Mage::app()->getStore($store_id)->getRootCategoryId();
43
+
44
+ $category_model = Mage::getModel('catalog/category'); //get category model
45
+ $_category = $category_model->load($rootCategoryId );
46
+ $all_child_categories = $category_model->getResource()->getAllChildren($_category);
47
+
48
+ $collection = Mage::getModel('catalog/category')->getCollection()
49
+ ->addAttributeToSelect('name')
50
+ ->addAttributeToSelect('is_active');
51
+
52
+ if($storeCode){
53
+ $collection->addFieldToFilter('entity_id', array(array('in'=> $all_child_categories)));
54
+ }
55
+
56
+ $tree->addCollectionData($collection, true);
57
+
58
+ $values['---'] = array(
59
+ 'value' => '',
60
+ 'label' => '',
61
+ );
62
+ return $this->buildCategoriesMultiselectValues($root, $values);
63
+ }
64
+ }
app/code/community/CapacityWebSolutions/Newproducts/Model/System/Config/Source/Chooseproducts.php ADDED
@@ -0,0 +1 @@
 
0
  Extension Name : New Products
1
  Extension URL : http://www.magebees.com/magento-new-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 : New Products
3
  Extension URL : http://www.magebees.com/magento-new-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/Newproducts/Model/System/Config/Source/Choosetype.php ADDED
@@ -0,0 +1 @@
 
0
  Extension Name : New Products
1
  Extension URL : http://www.magebees.com/magento-new-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 : New Products
3
  Extension URL : http://www.magebees.com/magento-new-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/Newproducts/Model/System/Config/Source/Sortby.php ADDED
@@ -0,0 +1 @@
 
0
  Extension Name : New Products
1
  Extension URL : http://www.magebees.com/magento-new-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 : New Products
3
  Extension URL : http://www.magebees.com/magento-new-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/Newproducts/Model/System/Config/Source/Sortorder.php ADDED
@@ -0,0 +1 @@
 
0
  Extension Name : New Products
1
  Extension URL : http://www.magebees.com/magento-new-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 : New Products
3
  Extension URL : http://www.magebees.com/magento-new-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/Newproducts/Model/System/Config/Source/Template.php ADDED
@@ -0,0 +1 @@
 
0
  Extension Name : New Products
1
  Extension URL : http://www.magebees.com/magento-new-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 : New Products
3
  Extension URL : http://www.magebees.com/magento-new-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/Newproducts/controllers/Adminhtml/NewproductsController.php ADDED
@@ -0,0 +1,266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : New 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_Newproducts_Adminhtml_NewproductsController extends Mage_Adminhtml_Controller_Action {
11
+
12
+ protected function _initAction() {
13
+ $this->loadLayout()
14
+ ->_setActiveMenu('cws');
15
+ return $this;
16
+ }
17
+
18
+ public function indexAction() {
19
+ $this->_initAction()
20
+ ->renderLayout();
21
+ }
22
+
23
+ public function newAction() {
24
+ $this->_forward('edit');
25
+ }
26
+
27
+ public function editAction() {
28
+ $id = $this->getRequest()->getParam('id');
29
+ $model = Mage::getModel('newproducts/newproducts')->load($id);
30
+
31
+ if ($model->getMostviewedId() || $id == 0) {
32
+
33
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
34
+ if (!empty($data)) {
35
+ $model->setData($data);
36
+ }
37
+
38
+ Mage::register('newproducts_data', $model);
39
+
40
+ $this->loadLayout();
41
+ $this->_setActiveMenu('cws');
42
+
43
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('New Products'), Mage::helper('adminhtml')->__('New Products'));
44
+
45
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
46
+
47
+ $this->_addContent($this->getLayout()->createBlock('newproducts/adminhtml_newproducts_edit'))
48
+ ->_addLeft($this->getLayout()->createBlock('newproducts/adminhtml_newproducts_edit_tabs'));
49
+
50
+ $this->renderLayout();
51
+ } else {
52
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('newproducts')->__('New Products does not exist'));
53
+ $this->_redirect('*/*/');
54
+ }
55
+ }
56
+
57
+ public function getSkusArr($element){
58
+ return $element['sku'];
59
+ }
60
+
61
+ public function getProductSkus($store_id=0){
62
+ $featuredCollection = Mage::getModel('newproducts/newproducts')->getCollection()->addFieldToFilter('store_id', array(array('finset' => $store_id)));
63
+ $product_skus=array_map(array($this,"getSkusArr"), $featuredCollection->getData());
64
+ return $product_skus;
65
+ }
66
+
67
+ public function saveAction() {
68
+ if ($data = $this->getRequest()->getPost()) {
69
+ $id = $this->getRequest()->getParam('id');
70
+ $store_id = $data['store_id'];
71
+ $product_skus = array();
72
+ if (isset($data['product_sku'])) {
73
+ $product_skus = explode(', ',$data['product_sku']);
74
+ }
75
+
76
+ try {
77
+ $store_ids_arr = array();
78
+
79
+ //if uncheck product sku
80
+ $old_skus_arr = $this->getProductSkus($store_id);
81
+ $sku_for_remove_arr = array();
82
+ $sku_for_remove_arr = array_diff($old_skus_arr,$product_skus);
83
+ if($sku_for_remove_arr){
84
+
85
+ foreach ($sku_for_remove_arr as $sku) {
86
+ $newproducts = Mage::getModel('newproducts/newproducts')->load($sku,'sku');
87
+
88
+ if(!$store_id){//for all store views
89
+ $newproducts->delete();
90
+ }else{
91
+ $new_store_ids_arr = array();
92
+ $old_store_ids = $newproducts->getData('store_id');
93
+ $old_store_ids_arr = explode(",",$old_store_ids);
94
+ $new_store_ids_arr = array_diff($old_store_ids_arr,array($store_id));
95
+ $new_store_ids = implode(",",$new_store_ids_arr);
96
+
97
+ if(count($new_store_ids_arr)==1){
98
+
99
+ $newproducts->delete();
100
+ }else{
101
+ $newproducts->setData('sku',$sku);
102
+ $newproducts->setData('store_id',$new_store_ids);
103
+ $newproducts->save();
104
+ }
105
+ }
106
+ }
107
+ }
108
+ if(!empty($data['product_sku'])){
109
+ if(!$store_id){//for save sku all store views
110
+ $store_ids_arr = Mage::helper('newproducts')->getStoreViewIds();//get all storeview ids;
111
+ array_push($store_ids_arr,0);
112
+ $store_ids = implode(",",$store_ids_arr);
113
+ foreach($product_skus as $sku){
114
+ if(!in_array($sku,$old_skus_arr)){
115
+ $model = Mage::getModel('newproducts/newproducts')->load($sku,'sku');
116
+ $model->setData('sku',$sku);
117
+ $model->setData('store_id',$store_ids);
118
+ $model->save();
119
+ }
120
+ }
121
+ }else{//for specific storeview
122
+ $store_ids_arr[] = $store_id;
123
+ array_push($store_ids_arr,0);
124
+ foreach($product_skus as $sku){
125
+ $model = Mage::getModel('newproducts/newproducts')->load($sku,'sku');
126
+ if($model->getId()){//sku exist
127
+ $old_store_ids = $model->getData('store_id');
128
+ $old_store_ids_arr = explode(",",$old_store_ids);
129
+ $new_store_ids_arr = array_unique(array_merge($old_store_ids_arr,$store_ids_arr));
130
+ $new_store_ids = implode(",",$new_store_ids_arr);
131
+ $model->setData('sku',$sku);
132
+ $model->setData('store_id',$new_store_ids);
133
+ $model->save();
134
+ }else{
135
+ $store_ids = implode(",",$store_ids_arr);
136
+ $model->setData('sku',$sku);
137
+ $model->setData('store_id',$store_ids);
138
+ $model->save();
139
+ }
140
+ }
141
+ }
142
+ }
143
+
144
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('newproducts')->__('New Products was successfully saved'));
145
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
146
+
147
+ if ($this->getRequest()->getParam('back')) {
148
+ //$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
149
+ $this->_redirectReferer();
150
+ return;
151
+ }
152
+ $this->_redirect('*/*/');
153
+ return;
154
+ } catch (Exception $e) {
155
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
156
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
157
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
158
+ return;
159
+ }
160
+ }
161
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('newproducts')->__('Unable to find New Products to save'));
162
+ $this->_redirect('*/*/');
163
+ }
164
+
165
+ public function massDeleteAction() {
166
+ $newproducts_ids = $this->getRequest()->getParam('newproducts');
167
+ $store_id = $this->getRequest()->getParam('store');
168
+ $skus_for_remove_arr = array();
169
+
170
+ if(!is_array($newproducts_ids)) {
171
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
172
+ } else {
173
+ try {
174
+ foreach($newproducts_ids as $id){
175
+ $skus_for_remove_arr[$id] = Mage::getModel('catalog/product')->load($id)->getSku();
176
+ }
177
+ foreach ($skus_for_remove_arr as $sku) {
178
+ $newproducts = Mage::getModel('newproducts/newproducts')->load($sku,'sku');
179
+ if($newproducts->isEmpty() && $store_id!=0){
180
+ Mage::getSingleton('adminhtml/session')->addError("Cannot delete. Please switch to All Store Views.");
181
+ $this->_redirectReferer();
182
+ return;
183
+ }
184
+ if(!$store_id){//for all store views
185
+ $newproducts->delete();
186
+ }else{
187
+ $new_store_ids_arr = array();
188
+ $old_store_ids = $newproducts->getData('store_id');
189
+ $old_store_ids_arr = explode(",",$old_store_ids);
190
+ $new_store_ids_arr = array_diff($old_store_ids_arr,array($store_id));
191
+ $new_store_ids = implode(",",$new_store_ids_arr);
192
+
193
+ if(count($new_store_ids_arr)==1){
194
+
195
+ $newproducts->delete();
196
+ }else{
197
+ $newproducts->setData('sku',$sku);
198
+ $newproducts->setData('store_id',$new_store_ids);
199
+ $newproducts->save();
200
+ }
201
+ }
202
+ }
203
+ Mage::getSingleton('adminhtml/session')->addSuccess(
204
+ Mage::helper('adminhtml')->__(
205
+ 'Total of %d record(s) were successfully deleted.', count($newproducts_ids)
206
+ )
207
+ );
208
+ } catch (Exception $e) {
209
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
210
+ }
211
+ }
212
+ $this->_redirectReferer();
213
+ }
214
+
215
+ public function massDelete2Action() {
216
+ $newproducts_ids = $this->getRequest()->getParam('newproducts');
217
+ $store_id = $this->getRequest()->getParam('store');
218
+ $new_ids = array();
219
+ $new_skus = array();
220
+
221
+ if(!is_array($newproducts_ids)) {
222
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
223
+ } else {
224
+ try {
225
+ foreach ($newproducts_ids as $newproducts_id) {
226
+ $newproducts = Mage::getModel('newproducts/newproducts')->load($store_id,'store_id');
227
+ if($newproducts->isEmpty() && $store_id!=0){
228
+ Mage::getSingleton('adminhtml/session')->addError("Cannot delete. Please switch to All Store Views.");
229
+ $this->_redirectReferer();
230
+ return;
231
+ }
232
+ $product_ids = explode(', ',$newproducts->getProductId());
233
+
234
+ $new_ids = array_diff($product_ids,$newproducts_ids);
235
+ foreach($new_ids as $id){
236
+ $new_skus[$id] = Mage::getModel('catalog/product')->load($id)->getSku();
237
+ }
238
+ $ids = implode(", ",$new_ids);
239
+ $skus = implode(", ",$new_skus);
240
+
241
+ $mostviewed->setData('sku',$skus);
242
+ $mostviewed->setData('product_id',$ids);
243
+ $mostviewed->save();
244
+ // $mostviewed->delete();
245
+ }
246
+ Mage::getSingleton('adminhtml/session')->addSuccess(
247
+ Mage::helper('adminhtml')->__(
248
+ 'Total of %d record(s) were successfully deleted.', count($newproducts_ids)
249
+ )
250
+ );
251
+ } catch (Exception $e) {
252
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
253
+ }
254
+ }
255
+ $this->_redirectReferer();
256
+ }
257
+
258
+ public function gridAction()
259
+ {
260
+ $this->loadLayout();
261
+ $this->getResponse()->setBody(
262
+ $this->getLayout()->createBlock('newproducts/adminhtml_newproducts_grid')->toHtml()
263
+ );
264
+ }
265
+
266
+ }
app/code/community/CapacityWebSolutions/Newproducts/controllers/Adminhtml/WidgetController.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : New 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
+ class CapacityWebSolutions_Newproducts_Adminhtml_WidgetController extends Mage_Adminhtml_Controller_Action
10
+ {
11
+ /**
12
+ * Prepare block for chooser
13
+ *
14
+ * @return void
15
+ */
16
+ public function chooserAction()
17
+ {
18
+ $request = $this->getRequest();
19
+ $block = $this->getLayout()->createBlock(
20
+ 'newproducts/promo_widget_chooser_sku', 'promo_widget_chooser_sku',array('js_form_object' => $request->getParam('form'),
21
+ ));
22
+
23
+ if ($block) {
24
+ $this->getResponse()->setBody($block->toHtml());
25
+ }
26
+ }
27
+
28
+ protected function _isAllowed()
29
+ {
30
+ return Mage::getSingleton('admin/session')->isAllowed('cws');
31
+ }
32
+
33
+
34
+ }
app/code/community/CapacityWebSolutions/Newproducts/etc/adminhtml.xml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <cws module="newproducts">
5
+ <title>MageBees</title>
6
+ <sort_order>70</sort_order>
7
+ <children>
8
+ <newproducts module="newproducts">
9
+ <title>New Products</title>
10
+ <sort_order>70</sort_order>
11
+ <children>
12
+ <groups module="newproducts">
13
+ <title>Manage New Products</title>
14
+ <sort_order>10</sort_order>
15
+ <action>adminhtml/newproducts</action>
16
+ </groups>
17
+ <settings>
18
+ <title>Settings</title>
19
+ <sort_order>20</sort_order>
20
+ <action>adminhtml/system_config/edit/section/newproducts</action>
21
+ </settings>
22
+ </children>
23
+ </newproducts>
24
+ </children>
25
+ </cws>
26
+ </menu>
27
+ <acl>
28
+ <resources>
29
+ <admin>
30
+ <children>
31
+ <system>
32
+ <children>
33
+ <config>
34
+ <children>
35
+ <newproducts>
36
+ <title>New Products Section</title>
37
+ </newproducts>
38
+ </children>
39
+ </config>
40
+ </children>
41
+ </system>
42
+ </children>
43
+ </admin>
44
+ </resources>
45
+ </acl>
46
+ </config>
app/code/community/CapacityWebSolutions/Newproducts/etc/config.xml ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <CapacityWebSolutions_Newproducts>
5
+ <version>1.0.0</version>
6
+ </CapacityWebSolutions_Newproducts>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <newproducts>
11
+ <class>CapacityWebSolutions_Newproducts_Model</class>
12
+ <resourceModel>newproducts_mysql4</resourceModel>
13
+ </newproducts>
14
+ <newproducts_mysql4>
15
+ <class>CapacityWebSolutions_Newproducts_Model_Mysql4</class>
16
+ <entities>
17
+ <newproducts>
18
+ <table>cws_newproducts</table>
19
+ </newproducts>
20
+ </entities>
21
+ </newproducts_mysql4>
22
+ </models>
23
+ <resources>
24
+ <newproducts_setup>
25
+ <setup>
26
+ <module>CapacityWebSolutions_Newproducts</module>
27
+ </setup>
28
+ <connection>
29
+ <use>core_setup</use>
30
+ </connection>
31
+ </newproducts_setup>
32
+ <newproducts_write>
33
+ <connection>
34
+ <use>core_write</use>
35
+ </connection>
36
+ </newproducts_write>
37
+ <newproducts_read>
38
+ <connection>
39
+ <use>core_read</use>
40
+ </connection>
41
+ </newproducts_read>
42
+ </resources>
43
+ <blocks>
44
+ <newproducts>
45
+ <class>CapacityWebSolutions_Newproducts_Block</class>
46
+ </newproducts>
47
+ </blocks>
48
+ <helpers>
49
+ <newproducts>
50
+ <class>CapacityWebSolutions_Newproducts_Helper</class>
51
+ </newproducts>
52
+ </helpers>
53
+ </global>
54
+ <frontend>
55
+ <routers>
56
+ <newproducts>
57
+ <use>standard</use>
58
+ <args>
59
+ <module>CapacityWebSolutions_Newproducts</module>
60
+ <frontName>newproducts</frontName>
61
+ </args>
62
+ </newproducts>
63
+ </routers>
64
+ <layout>
65
+ <updates>
66
+ <newproducts>
67
+ <file>newproducts.xml</file>
68
+ </newproducts>
69
+ </updates>
70
+ </layout>
71
+ </frontend>
72
+
73
+ <admin>
74
+ <routers>
75
+ <adminhtml>
76
+ <args>
77
+ <modules>
78
+ <newproducts before="Mage_Adminhtml">CapacityWebSolutions_Newproducts_Adminhtml</newproducts>
79
+ </modules>
80
+ </args>
81
+ </adminhtml>
82
+ </routers>
83
+ </admin>
84
+
85
+ <adminhtml>
86
+ <layout>
87
+ <updates>
88
+ <newproducts>
89
+ <file>newproducts.xml</file>
90
+ </newproducts>
91
+ </updates>
92
+ </layout>
93
+ </adminhtml>
94
+ <default> <!-- Default text value set from admin-->
95
+ <newproducts>
96
+ <general>
97
+ <enabled>1</enabled>
98
+ <isresponsive>1</isresponsive>
99
+ <display_heading>1</display_heading>
100
+ <heading>NEW PRODUCTS</heading>
101
+ <choose_products>1</choose_products>
102
+ <choose_type>1</choose_type>
103
+ <new_days>10</new_days>
104
+ <display_by>1</display_by>
105
+ <sort_by>name</sort_by>
106
+ <sort_order>asc</sort_order>
107
+ <products_price>1</products_price>
108
+ <review>0</review>
109
+ <short_desc>0</short_desc>
110
+ <desc_limit>10</desc_limit>
111
+ <add_to_cart>1</add_to_cart>
112
+ <add_to_wishlist>0</add_to_wishlist>
113
+ <add_to_compare>0</add_to_compare>
114
+ <out_of_stock>0</out_of_stock>
115
+ </general>
116
+ <template>
117
+ <select_template>1</select_template>
118
+ <number_of_items>10</number_of_items>
119
+ <show_pager>0</show_pager>
120
+ <products_per_page>5</products_per_page>
121
+ <thumbnail_height>135</thumbnail_height>
122
+ <thumbnail_width>135</thumbnail_width>
123
+ </template>
124
+ </newproducts>
125
+ </default>
126
+ </config>
app/code/community/CapacityWebSolutions/Newproducts/etc/system.xml ADDED
@@ -0,0 +1,350 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <newproducts translate="label">
11
+ <class>separator-top</class>
12
+ <label>New 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_Newproducts_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_Newproducts_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_Newproducts_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 New Products on frontend.]]></comment>
65
+ <source_model>adminhtml/system_config_source_yesno</source_model>
66
+ <frontend_type>select</frontend_type>
67
+ <sort_order>0</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ </enabled>
72
+ <isresponsive translate="label">
73
+ <label>Is Responsive Theme</label>
74
+ <comment><![CDATA[Select Yes for display Responsive Theme Template.]]></comment>
75
+ <source_model>adminhtml/system_config_source_yesno</source_model>
76
+ <frontend_type>select</frontend_type>
77
+ <sort_order>1</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>1</show_in_website>
80
+ <show_in_store>1</show_in_store>
81
+ </isresponsive>
82
+ <display_heading translate="label">
83
+ <label>Display Heading</label>
84
+ <comment><![CDATA[Select Yes for display page heading.]]></comment>
85
+ <source_model>adminhtml/system_config_source_yesno</source_model>
86
+ <frontend_type>select</frontend_type>
87
+ <sort_order>5</sort_order>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>1</show_in_store>
91
+ </display_heading>
92
+ <heading translate="label">
93
+ <label>Heading</label>
94
+ <comment><![CDATA[Set page heading.]]></comment>
95
+ <frontend_type>text</frontend_type>
96
+ <sort_order>10</sort_order>
97
+ <show_in_default>1</show_in_default>
98
+ <show_in_website>1</show_in_website>
99
+ <show_in_store>1</show_in_store>
100
+ <depends>
101
+ <display_heading>1</display_heading>
102
+ </depends>
103
+ <validate>required-entry</validate>
104
+ </heading>
105
+ <choose_products translate="label">
106
+ <label>New Products</label>
107
+ <comment><![CDATA[Auto >> Show system generated products.<br>
108
+ Manually >> Show manually added products.<br>
109
+ Both >> Show both system generated and manually added products.]]>
110
+ </comment>
111
+ <source_model>newproducts/system_config_source_chooseproducts</source_model>
112
+ <frontend_type>select</frontend_type>
113
+ <sort_order>15</sort_order>
114
+ <show_in_default>1</show_in_default>
115
+ <show_in_website>1</show_in_website>
116
+ <show_in_store>1</show_in_store>
117
+ </choose_products>
118
+
119
+ <choose_type>
120
+ <label>Use 'New from Date' and 'New to Date'</label>
121
+ <comment><![CDATA[Applied only if "New Products" field is set to "Auto" or "Both".]]>
122
+ </comment>
123
+ <source_model>adminhtml/system_config_source_yesno</source_model>
124
+ <frontend_type>select</frontend_type>
125
+ <sort_order>25</sort_order>
126
+ <show_in_default>1</show_in_default>
127
+ <show_in_website>1</show_in_website>
128
+ <show_in_store>1</show_in_store>
129
+ </choose_type>
130
+ <new_days>
131
+ <label>Product is new threshold</label>
132
+ <comment><![CDATA[Used Product Creation Date.<br>
133
+ Default days for new products: 10 days.]]></comment>
134
+ <frontend_type>text</frontend_type>
135
+ <sort_order>30</sort_order>
136
+ <show_in_default>1</show_in_default>
137
+ <show_in_website>1</show_in_website>
138
+ <show_in_store>1</show_in_store>
139
+ <depends>
140
+ <choose_type>0</choose_type>
141
+ </depends>
142
+ <validate>required-entry</validate>
143
+ </new_days>
144
+ <display_by>
145
+ <label>Select New Products Type</label>
146
+ <comment><![CDATA[You can display all products or display by categories.]]></comment>
147
+ <source_model>newproducts/system_config_source_choosetype</source_model>
148
+ <frontend_type>select</frontend_type>
149
+ <sort_order>35</sort_order>
150
+ <show_in_default>1</show_in_default>
151
+ <show_in_website>1</show_in_website>
152
+ <show_in_store>1</show_in_store>
153
+ </display_by>
154
+ <categories translate="label">
155
+ <label>Categories</label>
156
+ <frontend_type>multiselect</frontend_type>
157
+ <source_model>newproducts/system_config_source_category</source_model>
158
+ <sort_order>40</sort_order>
159
+ <show_in_default>1</show_in_default>
160
+ <show_in_website>1</show_in_website>
161
+ <show_in_store>1</show_in_store>
162
+ <depends>
163
+ <display_by>2</display_by>
164
+ </depends>
165
+ <validate>required-entry</validate>
166
+ </categories>
167
+ <sort_by>
168
+ <label>Sort By</label>
169
+ <comment><![CDATA[Set attribute that is initially used to sort the new products list.
170
+ ]]></comment>
171
+ <source_model>newproducts/system_config_source_sortby</source_model>
172
+ <frontend_type>select</frontend_type>
173
+ <sort_order>43</sort_order>
174
+ <show_in_default>1</show_in_default>
175
+ <show_in_website>1</show_in_website>
176
+ <show_in_store>1</show_in_store>
177
+ </sort_by>
178
+ <sort_order>
179
+ <label>Sort Order</label>
180
+ <comment><![CDATA[If you select "Random" then Sort By atrributes is not applicable.]]></comment>
181
+ <source_model>newproducts/system_config_source_sortorder</source_model>
182
+ <frontend_type>select</frontend_type>
183
+ <sort_order>44</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
+ </sort_order>
188
+ <products_price translate="label">
189
+ <label>Show Products Price</label>
190
+ <comment><![CDATA[Select Yes for display the Products' Price on frontend.]]></comment>
191
+ <source_model>adminhtml/system_config_source_yesno</source_model>
192
+ <frontend_type>select</frontend_type>
193
+ <sort_order>45</sort_order>
194
+ <show_in_default>1</show_in_default>
195
+ <show_in_website>1</show_in_website>
196
+ <show_in_store>1</show_in_store>
197
+ </products_price>
198
+
199
+ <review translate="label">
200
+ <label>Show Ratings</label>
201
+ <comment><![CDATA[Select Yes for display the Ratings on frontend.]]></comment>
202
+ <source_model>adminhtml/system_config_source_yesno</source_model>
203
+ <frontend_type>select</frontend_type>
204
+ <sort_order>50</sort_order>
205
+ <show_in_default>1</show_in_default>
206
+ <show_in_website>1</show_in_website>
207
+ <show_in_store>1</show_in_store>
208
+ </review>
209
+ <short_desc translate="label">
210
+ <label>Show Short Description</label>
211
+ <comment><![CDATA[Select Yes for display the Short Description on frontend.]]></comment>
212
+ <source_model>adminhtml/system_config_source_yesno</source_model>
213
+ <frontend_type>select</frontend_type>
214
+ <sort_order>55</sort_order>
215
+ <show_in_default>1</show_in_default>
216
+ <show_in_website>1</show_in_website>
217
+ <show_in_store>1</show_in_store>
218
+ </short_desc>
219
+ <desc_limit translate="label">
220
+ <label>Short Description Word Limit</label>
221
+ <comment><![CDATA[Set number of words display on frontend.]]></comment>
222
+ <frontend_type>text</frontend_type>
223
+ <sort_order>60</sort_order>
224
+ <show_in_default>1</show_in_default>
225
+ <show_in_website>1</show_in_website>
226
+ <show_in_store>1</show_in_store>
227
+ <depends>
228
+ <short_desc>1</short_desc>
229
+ </depends>
230
+ <validate>required-entry</validate>
231
+ </desc_limit>
232
+ <add_to_cart translate="label">
233
+ <label>Add to Cart</label>
234
+ <comment><![CDATA[Select Yes for display the "Add to Cart" button on frontend.]]></comment>
235
+ <source_model>adminhtml/system_config_source_yesno</source_model>
236
+ <frontend_type>select</frontend_type>
237
+ <sort_order>65</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
+ </add_to_cart>
242
+ <add_to_wishlist translate="label">
243
+ <label>Add to Wishlist</label>
244
+ <comment><![CDATA[Select Yes for display the "Add to Wishlist" link on frontend.]]></comment>
245
+ <frontend_type>select</frontend_type>
246
+ <source_model>adminhtml/system_config_source_yesno</source_model>
247
+ <sort_order>70</sort_order>
248
+ <show_in_default>1</show_in_default>
249
+ <show_in_website>1</show_in_website>
250
+ <show_in_store>1</show_in_store>
251
+ </add_to_wishlist>
252
+ <add_to_compare translate="label">
253
+ <label>Add to Compare</label>
254
+ <comment><![CDATA[Select Yes for display the "Add to Compare" link on frontend.]]></comment>
255
+ <source_model>adminhtml/system_config_source_yesno</source_model>
256
+ <frontend_type>select</frontend_type>
257
+ <sort_order>75</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
+ </add_to_compare>
262
+ <out_of_stock translate="label">
263
+ <label>Display out of stock items</label>
264
+ <comment><![CDATA[Select Yes for display the out of stock items on frontend.]]></comment>
265
+ <source_model>adminhtml/system_config_source_yesno</source_model>
266
+ <frontend_type>select</frontend_type>
267
+ <sort_order>80</sort_order>
268
+ <show_in_default>1</show_in_default>
269
+ <show_in_website>1</show_in_website>
270
+ <show_in_store>1</show_in_store>
271
+ </out_of_stock>
272
+ </fields>
273
+ </general>
274
+ <template>
275
+ <label>Template Settings</label>
276
+ <frontend_type>text</frontend_type>
277
+ <sort_order>40</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
+ <fields>
282
+ <select_template>
283
+ <label>Template</label>
284
+ <comment><![CDATA[Select template for new products list.]]></comment>
285
+ <source_model>newproducts/system_config_source_template</source_model>
286
+ <frontend_type>select</frontend_type>
287
+ <sort_order>5</sort_order>
288
+ <show_in_default>1</show_in_default>
289
+ <show_in_website>1</show_in_website>
290
+ <show_in_store>1</show_in_store>
291
+ </select_template>
292
+ <number_of_items translate="label comment">
293
+ <label>Number of Products to Display</label>
294
+ <comment><![CDATA[Show Number of new products in main block.]]></comment>
295
+ <frontend_type>text</frontend_type>
296
+ <sort_order>10</sort_order>
297
+ <show_in_default>1</show_in_default>
298
+ <show_in_website>1</show_in_website>
299
+ <show_in_store>1</show_in_store>
300
+ <validate>required-entry</validate>
301
+ </number_of_items>
302
+ <show_pager translate="label comment">
303
+ <label>Display Page Control</label>
304
+ <comment><![CDATA[Show pagination and total number of items.]]></comment>
305
+ <source_model>adminhtml/system_config_source_yesno</source_model>
306
+ <frontend_type>select</frontend_type>
307
+ <sort_order>15</sort_order>
308
+ <show_in_default>1</show_in_default>
309
+ <show_in_website>1</show_in_website>
310
+ <show_in_store>1</show_in_store>
311
+ </show_pager>
312
+ <products_per_page translate="label comment">
313
+ <label>Number of Products per Page</label>
314
+ <comment><![CDATA[Show number of products per page.]]></comment>
315
+ <frontend_type>text</frontend_type>
316
+ <sort_order>20</sort_order>
317
+ <show_in_default>1</show_in_default>
318
+ <show_in_website>1</show_in_website>
319
+ <show_in_store>1</show_in_store>
320
+ <depends>
321
+ <show_pager>1</show_pager>
322
+ </depends>
323
+ <validate>required-entry</validate>
324
+ </products_per_page>
325
+ <thumbnail_height translate="label">
326
+ <label>Thumbnail Width</label>
327
+ <comment><![CDATA[Default Thumbnail Width: 135px]]></comment>
328
+ <frontend_type>text</frontend_type>
329
+ <sort_order>25</sort_order>
330
+ <show_in_default>1</show_in_default>
331
+ <show_in_website>1</show_in_website>
332
+ <show_in_store>1</show_in_store>
333
+ <validate>required-entry</validate>
334
+ </thumbnail_height>
335
+ <thumbnail_width translate="label">
336
+ <label>Thumbnail Height </label>
337
+ <comment><![CDATA[Default Thumbnail Height: 135px]]></comment>
338
+ <frontend_type>text</frontend_type>
339
+ <sort_order>30</sort_order>
340
+ <show_in_default>1</show_in_default>
341
+ <show_in_website>1</show_in_website>
342
+ <show_in_store>1</show_in_store>
343
+ <validate>required-entry</validate>
344
+ </thumbnail_width>
345
+ </fields>
346
+ </template>
347
+ </groups>
348
+ </newproducts>
349
+ </sections>
350
+ </config>
app/code/community/CapacityWebSolutions/Newproducts/etc/widget.xml ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <widgets>
3
+ <newproducts type="newproducts/widget">
4
+ <name>MageBees:New Products Widget</name>
5
+ <parameters>
6
+ <template>
7
+ <values>
8
+ <list_default translate="label">
9
+ <value>newproducts/column/newproducts_default_list.phtml</value>
10
+ <label>New 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>New Products</value>
50
+ <depends>
51
+ <wd_display_heading><value>1</value></wd_display_heading>
52
+ </depends>
53
+ </wd_heading>
54
+ <wd_choose_products translate="label">
55
+ <visible>1</visible>
56
+ <label>New Products</label>
57
+ <source_model>newproducts/system_config_source_chooseproducts</source_model>
58
+ <type>select</type>
59
+ </wd_choose_products>
60
+ <wd_choose_type>
61
+ <visible>1</visible>
62
+ <label>Use 'New from Date' and 'New to Date'</label>
63
+ <source_model>adminhtml/system_config_source_yesno</source_model>
64
+ <type>select</type>
65
+ <value>1</value>
66
+ </wd_choose_type>
67
+ <wd_new_days>
68
+ <required>1</required>
69
+ <visible>1</visible>
70
+ <label>Product is new threshold</label>
71
+ <type>text</type>
72
+ <value>10</value>
73
+ <depends>
74
+ <wd_choose_type><value>0</value></wd_choose_type>
75
+ </depends>
76
+ </wd_new_days>
77
+ <wd_display_by>
78
+ <visible>1</visible>
79
+ <label>Select New Products Type</label>
80
+ <source_model>newproducts/system_config_source_choosetype</source_model>
81
+ <type>select</type>
82
+ </wd_display_by>
83
+ <wd_categories translate="label">
84
+ <required>1</required>
85
+ <visible>1</visible>
86
+ <label>Categories</label>
87
+ <type>multiselect</type>
88
+ <source_model>newproducts/system_config_source_category</source_model>
89
+ <depends>
90
+ <wd_display_by><value>2</value></wd_display_by>
91
+ </depends>
92
+ </wd_categories>
93
+ <wd_sort_by>
94
+ <visible>1</visible>
95
+ <label>Sort By</label>
96
+ <source_model>newproducts/system_config_source_sortby</source_model>
97
+ <type>select</type>
98
+ </wd_sort_by>
99
+ <wd_sort_order>
100
+ <visible>1</visible>
101
+ <label>Sort Order</label>
102
+ <source_model>newproducts/system_config_source_sortorder</source_model>
103
+ <type>select</type>
104
+ </wd_sort_order>
105
+ <wd_products_price translate="label">
106
+ <visible>1</visible>
107
+ <label>Show Products Price</label>
108
+ <source_model>adminhtml/system_config_source_yesno</source_model>
109
+ <type>select</type>
110
+ </wd_products_price>
111
+ <wd_review translate="label">
112
+ <visible>1</visible>
113
+ <label>Show Ratings</label>
114
+ <source_model>adminhtml/system_config_source_yesno</source_model>
115
+ <type>select</type>
116
+ </wd_review>
117
+ <wd_short_desc translate="label">
118
+ <visible>1</visible>
119
+ <label>Show Short Description</label>
120
+ <source_model>adminhtml/system_config_source_yesno</source_model>
121
+ <type>select</type>
122
+ </wd_short_desc>
123
+ <wd_desc_limit translate="label">
124
+ <required>1</required>
125
+ <visible>1</visible>
126
+ <label>Short Description Word Limit</label>
127
+ <type>text</type>
128
+ <depends>
129
+ <wd_short_desc><value>1</value></wd_short_desc>
130
+ </depends>
131
+ <value>10</value>
132
+ </wd_desc_limit>
133
+ <wd_add_to_cart translate="label">
134
+ <visible>1</visible>
135
+ <label>Add to Cart</label>
136
+ <source_model>adminhtml/system_config_source_yesno</source_model>
137
+ <type>select</type>
138
+ </wd_add_to_cart>
139
+ <wd_add_to_wishlist translate="label">
140
+ <visible>1</visible>
141
+ <label>Add to Wishlist</label>
142
+ <type>select</type>
143
+ <source_model>adminhtml/system_config_source_yesno</source_model>
144
+ </wd_add_to_wishlist>
145
+ <wd_add_to_compare translate="label">
146
+ <visible>1</visible>
147
+ <label>Add to Compare</label>
148
+ <source_model>adminhtml/system_config_source_yesno</source_model>
149
+ <type>select</type>
150
+ </wd_add_to_compare>
151
+ <wd_out_of_stock translate="label">
152
+ <visible>1</visible>
153
+ <label>Display Out of Stock Products</label>
154
+ <source_model>adminhtml/system_config_source_yesno</source_model>
155
+ <type>select</type>
156
+ </wd_out_of_stock>
157
+ <wd_number_of_items translate="label comment">
158
+ <required>1</required>
159
+ <visible>1</visible>
160
+ <label>Number of Products to Display</label>
161
+ <type>text</type>
162
+ <value>10</value>
163
+ </wd_number_of_items>
164
+ <wd_show_pager translate="label comment">
165
+ <visible>1</visible>
166
+ <label>Display Page Control</label>
167
+ <source_model>adminhtml/system_config_source_yesno</source_model>
168
+ <type>select</type>
169
+ </wd_show_pager>
170
+ <wd_products_per_page translate="label comment">
171
+ <required>1</required>
172
+ <visible>1</visible>
173
+ <label>Number of Products per Page</label>
174
+ <type>text</type>
175
+ <depends>
176
+ <wd_show_pager><value>1</value></wd_show_pager>
177
+ </depends>
178
+ <value>5</value>
179
+ </wd_products_per_page>
180
+ <wd_thumbnail_height translate="label">
181
+ <required>1</required>
182
+ <visible>1</visible>
183
+ <label>Thumbnail Width</label>
184
+ <type>text</type>
185
+ <value>50</value>
186
+ </wd_thumbnail_height>
187
+ <wd_thumbnail_width translate="label">
188
+ <required>1</required>
189
+ <visible>1</visible>
190
+ <label>Thumbnail Height </label>
191
+ <type>text</type>
192
+ <value>50</value>
193
+ </wd_thumbnail_width>
194
+ <template>
195
+ <visible>1</visible>
196
+ <label>Template</label>
197
+ <type>select</type>
198
+ <value>newproducts/newproducts-grid.phtml</value>
199
+ <values>
200
+ <grid_template translate="label">
201
+ <value>newproducts/newproducts-grid.phtml</value>
202
+ <label>Grid Template</label>
203
+ </grid_template>
204
+ <list_template translate="label">
205
+ <value>newproducts/newproducts-list.phtml</value>
206
+ <label>List Template</label>
207
+ </list_template>
208
+ </values>
209
+ </template>
210
+ </parameters>
211
+ </newproducts>
212
+ </widgets>
app/code/community/CapacityWebSolutions/Newproducts/sql/newproducts_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_newproducts')."` (
10
+ `newproducts_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
11
+ `sku` varchar(64) NOT NULL,
12
+ `store_id` text NOT NULL,
13
+ PRIMARY KEY (`newproducts_id`),
14
+ KEY `IDX_NEWPRODUCTS_PRODUCT_SKU` (`sku`)
15
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
16
+
17
+ ALTER TABLE `".$this->getTable('cws_newproducts')."`
18
+ ADD CONSTRAINT `FK_NEWPRODUCTS_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 ('newproducts/newproducts','1');
24
+ ");
25
+ }
26
+
27
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/newproducts.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <adminhtml_newproducts_index>
4
+ <reference name="content">
5
+ <block type="newproducts/adminhtml_newproducts" name="newproducts" />
6
+ </reference>
7
+ </adminhtml_newproducts_index>
8
+ <adminhtml_newproducts_edit>
9
+ <reference name="head">
10
+ <action method="addJs"><script>newproducts/product-selector.js</script></action>
11
+ </reference>
12
+ <reference name="left">
13
+ <block type="adminhtml/store_switcher" name="store_switcher" before="-"></block>
14
+ </reference>
15
+ </adminhtml_newproducts_edit>
16
+ </layout>
app/design/adminhtml/default/default/template/newproducts/product.phtml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-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('newproducts')->__('Manually Products') ?></h4>
25
+
26
+ </div>
27
+ <fieldset id="product_fieldset">
28
+ <ul>
29
+ <li>
30
+ <span class="product-param">
31
+ <label for="product_sku"><?php echo Mage::helper('newproducts')->__('Select New Product SKUs') ?></label>
32
+ <a class="label" href="javascript:void(0)"><?php if($this->getSkusString()) { echo $this->getSkusString(); } else { echo Mage::helper('newproducts')->__('Click Here To Add Products'); } ?></a>
33
+ <span class="element">
34
+ <input id="product_sku" class="input-text element-value-changer" type="text" value="<?php echo $this->getSkusString() ?>" name="product_sku">
35
+ <a class="product-chooser-trigger" href="javascript:void(0)">
36
+ <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('newproducts')->__('Open Chooser') ?>" />
37
+ </a>
38
+ </span>
39
+ </span>
40
+ <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)); ?>">
41
+ </div>
42
+ </li>
43
+ </ul>
44
+ </fieldset>
45
+ </div>
46
+
47
+ <script type="text/javascript">
48
+ 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())) ?>');
49
+ </script>
app/design/frontend/base/default/layout/newproducts.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="newproducts/general/enabled"><type>skin_css</type><name>css/newproducts/newproducts.css</name><params/></action>
6
+ </reference>
7
+ </default>
8
+ </layout>
app/design/frontend/base/default/template/newproducts/column/newproducts_default_list.phtml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-products-extension.html
5
+ Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
6
+ Support Email : support@magebees.com
7
+ ***************************************************************************/
8
+ ?>
9
+ <?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
10
+ <div class="widget widget-new-products">
11
+ <div class="block block-products">
12
+ <?php if($this->getDisplayHeading()): ?>
13
+ <div class="block-title">
14
+ <strong><span><?php echo $this->__($this->getHeading()) ?></span></strong>
15
+ </div>
16
+ <?php endif; ?>
17
+ <div class="block-content">
18
+ <?php echo $this->getPagerHtml() ?>
19
+ <?php $suffix = $this->getNameInLayout(); ?>
20
+ <ol class="mini-products-list" id="widget-new-products-<?php echo $suffix; ?>">
21
+ <?php foreach ($_products->getItems() as $_product): ?>
22
+ <li class="item">
23
+ <a class="product-image" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize($this->getWidth(),$this->getHeight()) ?>" width="<?php echo $this->getWidth() ?>" height="<?php echo $this->getHeight() ?>" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" /></a>
24
+ <div class="product-details">
25
+ <p class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>)"><?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName() , 'name') ?></a></p>
26
+ <?php /* Removing this functionality from RWD
27
+ <?php echo $this->getPriceHtml($_product, true, '-widget-new-'.$suffix) ?>
28
+ <?php if ($_product->getIsSalable()): ?>
29
+ <a href="<?php echo $this->getAddToCartUrl($_product) ?>" class="link-cart"><?php echo $this->__('Add to Cart') ?></a>
30
+ <?php else: ?>
31
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
32
+ <?php endif; ?>
33
+ */ ?>
34
+ </div>
35
+ </li>
36
+ <?php endforeach; ?>
37
+ </ol>
38
+ <script type="text/javascript">decorateList('widget-new-products-<?php echo $suffix; ?>', 'none-recursive')</script>
39
+ </div>
40
+ </div>
41
+ </div>
42
+ <?php endif; ?>
app/design/frontend/base/default/template/newproducts/newproducts-grid.phtml ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-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="newProducts">
11
+ <?php if($this->getDisplayHeading()): ?>
12
+ <div class="title"><h2><?php echo $this->__($this->getHeading()) ?></h2></div>
13
+ <?php endif; ?>
14
+
15
+ <?php if(!$this->getIsResponsive()): ?>
16
+ <?php //for default theme(Non Responsive theme) ?>
17
+ <?php echo $this->getPagerHtml() ?>
18
+ <?php $_columnCount = $this->getColumnCount(); ?>
19
+ <?php $i=0; foreach ($_products->getItems() as $_product): ?>
20
+ <?php if ($i++%$_columnCount==0): ?>
21
+ <ul class="products-grid ">
22
+ <?php endif ?>
23
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
24
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image">
25
+ <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) ?>" />
26
+ </a>
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-grid') ?>
33
+ <?php endif; ?>
34
+ <?php if($this->getShortDesc()): ?>
35
+ <div class="desc std">
36
+ <?php
37
+ $short_desc = $this->htmlEscape($_product->getShortDescription());
38
+ echo $this->limit_word($short_desc,$this->getDescLimit());
39
+ ?>
40
+ </div>
41
+ <?php endif; ?>
42
+ <div class="actions" style="display:block">
43
+ <?php if($this->getAddToCart()): ?>
44
+ <?php if ($_product->isSaleable()): ?>
45
+ <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>
46
+ <?php else: ?>
47
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
48
+ <?php endif; ?>
49
+ <?php endif; ?>
50
+ <?php if($this->getAddToWishlist() || $this->getAddToCompare()): ?>
51
+ <ul class="add-to-links">
52
+ <?php if($this->getAddToWishlist()): ?>
53
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
54
+ <li><a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
55
+ <?php endif; ?>
56
+ <?php endif; ?>
57
+ <?php if($this->getAddToCompare()): ?>
58
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
59
+ <li>
60
+ <?php if($this->getAddToWishlist()): ?>
61
+ <span class="separator">|</span>
62
+ <?php endif; ?>
63
+ <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
64
+ <?php endif; ?>
65
+ <?php endif; ?>
66
+ </ul>
67
+ <?php endif; ?>
68
+ </div>
69
+ </li>
70
+ <?php if ($i%$_columnCount==0 || $i==count($_products)): ?>
71
+ </ul>
72
+ <?php endif ?>
73
+ <?php endforeach; ?>
74
+
75
+ <?php else: ?>
76
+ <?php //for responsive theme ?>
77
+ <?php echo $this->getPagerHtml() ?>
78
+ <?php $_columnCount = $this->getColumnCount(); ?>
79
+ <?php $i=0; ?>
80
+ <ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col rwd">
81
+ <?php foreach ($_products->getItems() as $_product): ?>
82
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
83
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image">
84
+ <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) ?>" />
85
+ </a>
86
+ <div class="product-info">
87
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName() , 'name') ?></a></h2>
88
+ <?php if($this->getProductsPrice()): ?>
89
+ <?php echo $this->getPriceHtml($_product, true, '-widget-new-grid') ?>
90
+ <?php endif; ?>
91
+ <?php if($this->getReview()): ?>
92
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
93
+ <?php endif; ?>
94
+ <?php if($this->getShortDesc()): ?>
95
+ <div class="desc std">
96
+ <?php
97
+ $short_desc = $this->htmlEscape($_product->getShortDescription());
98
+ echo $this->limit_word($short_desc,$this->getDescLimit());
99
+ ?>
100
+ </div>
101
+ <?php endif; ?>
102
+ <div class="actions" style="display:block !important">
103
+ <?php if($this->getAddToCart()): ?>
104
+ <?php if($_product->isSaleable()): ?>
105
+ <button class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')">
106
+ <span><?php echo $this->__('Add to Cart') ?></span>
107
+ </button>
108
+ <?php elseif($_product->isSaleable()): ?>
109
+ <button class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')">
110
+ <span><?php echo $this->__('View Details')?></span>
111
+ </button>
112
+ <?php else: ?>
113
+ <span class="out-of-stock">
114
+ <?php echo $this->__('Out of stock') ?>
115
+ </span>
116
+ <?php endif; ?>
117
+ <?php endif; ?>
118
+ <?php if($this->getAddToWishlist() || $this->getAddToCompare()): ?>
119
+ <ul class="add-to-links">
120
+ <?php if($this->getAddToWishlist()): ?>
121
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
122
+ <li><a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
123
+ <?php endif; ?>
124
+ <?php endif; ?>
125
+ <?php if($this->getAddToCompare()): ?>
126
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
127
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
128
+ <?php endif; ?>
129
+ <?php endif; ?>
130
+ </ul>
131
+ <?php endif; ?>
132
+ </div>
133
+ </div>
134
+ </li>
135
+ <?php endforeach; ?>
136
+ </ul>
137
+ <?php endif; ?>
138
+ </div>
139
+ <?php endif; ?>
app/design/frontend/base/default/template/newproducts/newproducts-list.phtml ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ Extension Name : New Products
4
+ Extension URL : http://www.magebees.com/magento-new-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="newProducts">
11
+ <?php if($this->getDisplayHeading()): ?>
12
+ <div class="title"><h2><?php echo $this->__($this->getHeading()) ?></h2></div>
13
+ <?php endif; ?>
14
+
15
+ <?php if(!$this->getIsResponsive()): ?>
16
+ <?php //for default theme(Non Responsive theme) ?>
17
+ <?php echo $this->getPagerHtml() ?>
18
+ <ul class="products-list default">
19
+ <?php $i=0; foreach ($_products->getItems() as $_product): ?>
20
+ <li class="item<?php echo (++$i == count($_products))?' last':''; ?>">
21
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image">
22
+ <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) ?>" />
23
+ </a>
24
+ <div class="product-shop">
25
+ <div class="f-fix">
26
+ <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>
27
+ <?php if($this->getReview()): ?>
28
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
29
+ <?php endif; ?>
30
+ <?php if($this->getProductsPrice()): ?>
31
+ <?php echo $this->getPriceHtml($_product, true, '-widget-new-list') ?>
32
+ <?php endif; ?>
33
+
34
+ <?php if($this->getAddToCart()): ?>
35
+ <?php if ($_product->isSaleable()): ?>
36
+ <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>
37
+ <?php else: ?>
38
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
39
+ <?php endif; ?>
40
+ <?php endif; ?>
41
+
42
+ <?php if($this->getShortDesc()): ?>
43
+ <div class="desc std">
44
+ <?php
45
+ $short_desc = $this->htmlEscape($_product->getShortDescription());
46
+ echo $this->limit_word($short_desc,$this->getDescLimit());
47
+ ?>
48
+ </div>
49
+ <?php endif; ?>
50
+ <?php if($this->getAddToWishlist() || $this->getAddToCompare()): ?>
51
+ <ul class="add-to-links">
52
+ <?php if($this->getAddToWishlist()): ?>
53
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
54
+ <li><a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
55
+ <?php endif; ?>
56
+ <?php endif; ?>
57
+ <?php if($this->getAddToCompare()): ?>
58
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
59
+ <li>
60
+ <?php if($this->getAddToWishlist()): ?>
61
+ <span class="separator">|</span>
62
+ <?php endif; ?>
63
+ <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
64
+ <?php endif; ?>
65
+ <?php endif; ?>
66
+ </ul>
67
+ <?php endif; ?>
68
+ </div>
69
+ </div>
70
+ </li>
71
+ <?php endforeach; ?>
72
+ </ul>
73
+ <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
74
+
75
+ <?php else: ?>
76
+ <?php //for responsive theme ?>
77
+ <?php echo $this->getPagerHtml() ?>
78
+ <ul class="products-list rwd">
79
+ <?php $i=0; foreach ($_products->getItems() as $_product): ?>
80
+ <li class="item<?php echo (++$i == count($_products))?' last':''; ?>">
81
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image">
82
+ <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($this->getWidth(),$this->getHeight()) ?>" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" />
83
+ </a>
84
+ <div class="product-shop">
85
+ <div class="f-fix">
86
+ <div class="product-primary">
87
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>)"><?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName() , 'name') ?></a></h2>
88
+ <?php if($this->getReview()): ?>
89
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
90
+ <?php endif; ?>
91
+ </div>
92
+ <div class="product-secondary">
93
+ <?php if($this->getProductsPrice()): ?>
94
+ <?php echo $this->getPriceHtml($_product, true, '-widget-new-list') ?>
95
+ <?php endif; ?>
96
+ </div>
97
+ <div class="product-secondary">
98
+ <?php if($this->getAddToCart()): ?>
99
+ <?php if($_product->isSaleable()): ?>
100
+ <button class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')">
101
+ <span><?php echo $this->__('Add to Cart') ?></span>
102
+ </button>
103
+ <?php elseif($_product->isSaleable()): ?>
104
+ <button class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')">
105
+ <span><?php echo $this->__('View Details')?></span>
106
+ </button>
107
+ <?php else: ?>
108
+ <span class="out-of-stock">
109
+ <?php echo $this->__('Out of stock') ?>
110
+ </span>
111
+ <?php endif; ?>
112
+ <?php endif; ?>
113
+ <?php if($this->getAddToWishlist() || $this->getAddToCompare()): ?>
114
+ <ul class="add-to-links">
115
+ <?php if($this->getAddToWishlist()): ?>
116
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
117
+ <li><a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
118
+ <?php endif; ?>
119
+ <?php endif; ?>
120
+ <?php if($this->getAddToCompare()): ?>
121
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
122
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
123
+ <?php endif; ?>
124
+ <?php endif; ?>
125
+ </ul>
126
+ <?php endif; ?>
127
+ </div>
128
+ <?php if($this->getShortDesc()): ?>
129
+ <div class="desc std">
130
+ <?php
131
+ $short_desc = $this->htmlEscape($_product->getShortDescription());
132
+ echo $this->limit_word($short_desc,$this->getDescLimit());
133
+ ?>
134
+ </div>
135
+ <?php endif; ?>
136
+ </div>
137
+ </div>
138
+ </li>
139
+ <?php endforeach; ?>
140
+ </ul>
141
+ <?php endif; ?>
142
+ </div>
143
+ <?php endif; ?>
app/etc/modules/CapacityWebSolutions_Newproducts.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <CapacityWebSolutions_Newproducts>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </CapacityWebSolutions_Newproducts>
8
+ </modules>
9
+ </config>
js/newproducts/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_New_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 new products.</summary>
10
+ <description>List Products which are set as a new product from the catalog product and option for display by product's creation date with different options and widget.</description>
11
+ <notes>New 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>11:26:30</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="CapacityWebSolutions_Newproducts.xml" hash="926a0274e875b325650a1624333b4229"/></dir></target><target name="magecommunity"><dir name="CapacityWebSolutions"><dir name="Newproducts"><dir name="Block"><dir name="Adminhtml"><file name="DefaultDirectCode.php" hash="2318f4f93d4bd13e00b4a6c42f888e2d"/><file name="DefaultTemplate.php" hash="d2e9058ce5641d9046a02f402d9d7ddb"/><file name="DefaultXML.php" hash="0f70303596eaa29008dc6f84249ee966"/><dir name="Newproducts"><dir name="Edit"><file name="Form.php" hash="273ae852e7d86d59375f90eacc911a82"/><dir name="Tab"><file name="Products.php" hash="13c8ea36d9a58da693a89564ace4d0cd"/></dir><file name="Tabs.php" hash="858ba5988949b20efd698f4367e27363"/></dir><file name="Edit.php" hash="53fd144fa40ee509a53120319adaaa62"/><file name="Grid.php" hash="794ec77f060ba2219336259ceae0a306"/></dir><file name="Newproducts.php" hash="b323b5f5c53e0f369efae500c4bd97d8"/></dir><file name="Newproducts.php" hash="9b0d3bff4393cdad22dafdca479fba9a"/><dir name="Promo"><dir name="Widget"><dir name="Chooser"><file name="Sku.php" hash="9ae589e00db8a5a98bd64cce448a991c"/></dir></dir></dir><dir name="Widget"><dir name="Html"><file name="Pager.php" hash="84bc39e6ecf80b29bfb16990907ab8ed"/></dir></dir><file name="Widget.php" hash="21e93a1234f8fbae03fd31d182250b21"/></dir><dir name="Helper"><file name="Data.php" hash="3a183e3fca2f3a4b6bd1abdcdc717954"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Newproducts"><file name="Collection.php" hash="550ceccdb1e07397c1977f566ae27e83"/></dir><file name="Newproducts.php" hash="40f0ebac0b386b758a978eb82f9081f4"/></dir><file name="Newproducts.php" hash="fc3fbee4b0da554701c94f4069033087"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Category.php" hash="aa2824b5d70975b2351a798c064c735a"/><file name="Chooseproducts.php" hash="9141a7efa1712fd3b1968ffbccd30243"/><file name="Choosetype.php" hash="f446d8316cc4d94425ab38f15a4a490a"/><file name="Sortby.php" hash="6960aac89e2ecdb23afe2532b9c7c9df"/><file name="Sortorder.php" hash="7c46def60df91ac42fca26495a2ac8f9"/><file name="Template.php" hash="b6477b1b62412ca5344a19697d9bdc80"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="NewproductsController.php" hash="e3c97462f1212ffbcea4a014dc49ea82"/><file name="WidgetController.php" hash="ff42137aa6e0f849e95fe95fbeb35f88"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="1590671e4b001b7bc7b46159790a22a1"/><file name="config.xml" hash="f721f528c368c7478845133ef8243f4d"/><file name="system.xml" hash="afa2ce5db840fe3622894100ccd82b3d"/><file name="widget.xml" hash="748e5a494869181de28615888b9d92a5"/></dir><dir name="sql"><dir name="newproducts_setup"><file name="mysql4-install-1.0.0.php" hash="7e6481fa0359538e6e7e545644378c3f"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="newproducts.xml" hash="b5d6867ae4414380984be3edb5cf6cc4"/></dir><dir name="template"><dir name="newproducts"><dir name="column"><file name="newproducts_default_list.phtml" hash="ce63693aeb23497631de66fb3e4ee1e2"/></dir><file name="newproducts-grid.phtml" hash="5512ac873b15b360e8724bfc5d8d2321"/><file name="newproducts-list.phtml" hash="e903170e7b8aa4c000be63b5c72139a5"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="newproducts.xml" hash="8f576a1164cc1be5e03daec50cb872e5"/></dir><dir name="template"><dir name="newproducts"><file name="product.phtml" hash="d7d43d9cf962d51850d79fe022ad6e1f"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="newproducts"><file name="newproducts.css" hash="1e3caadce17340183a4faa384bcc63c4"/></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="newproducts"><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/newproducts/newproducts.css ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .newProducts { margin-bottom:30px; }
2
+ .newProducts ul, .newProducts ul ul, .newProducts ol, .newProducts ul.products-grid, .newProducts ul.products-list { list-style:none; margin:0 auto; padding:0; }
3
+ .newProducts ul li, .newProducts .pager .pages ol li { margin-left:0; }
4
+
5
+ .newProducts .pager { float:none; border-bottom:1px dotted #ddd; border-top:1px dotted #ddd; padding:10px 10px 5px; margin-bottom:20px; }
6
+
7
+ .newProducts .title h2 { font-weight:600; margin:10px 0; }
8
+
9
+ .newProducts .products-grid .price-box p { margin-bottom:0; }
10
+ .newProducts ul.products-list.rwd .price-box p { display:inline-block; margin:0 0 0 15px; }
11
+ .newProducts ul.products-list.default .price-box p { margin:0 0 3px; }
12
+
13
+ .default ul ul.add-to-links { margin-top:5px; }