Bestseller_products - Version 2.0.0

Version Notes

Best Seller

Download this release

Release Info

Developer Capacity Web Solutions
Extension Bestseller_products
Version 2.0.0
Comparing to
See all releases


Code changes from version 1.1.7 to 2.0.0

Files changed (34) hide show
  1. app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/Bestseller.php +19 -0
  2. app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/Bestseller/Edit.php +42 -0
  3. app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/Bestseller/Edit/Form.php +25 -0
  4. app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/Bestseller/Edit/Tab/Products.php +33 -0
  5. app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/Bestseller/Edit/Tabs.php +29 -0
  6. app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/Bestseller/Grid.php +179 -0
  7. app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/DefaultDirectCode.php +17 -0
  8. app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/DefaultTemplate.php +17 -0
  9. app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/DefaultXML.php +20 -0
  10. app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/RwdDirectCode.php +18 -0
  11. app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/RwdTemplate.php +17 -0
  12. app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/RwdXML.php +21 -0
  13. app/code/community/CapacityWebSolutions/Bestseller/Block/Bestseller.php +73 -25
  14. app/code/community/CapacityWebSolutions/Bestseller/Helper/Data.php +2 -2
  15. app/code/community/CapacityWebSolutions/Bestseller/Model/Bestseller.php +17 -0
  16. app/code/community/CapacityWebSolutions/Bestseller/Model/Mysql4/Bestseller.php +16 -0
  17. app/code/community/CapacityWebSolutions/Bestseller/Model/Mysql4/Bestseller/Collection.php +18 -0
  18. app/code/community/CapacityWebSolutions/Bestseller/Model/Mysql4/Product/Collection.php +415 -0
  19. app/code/community/CapacityWebSolutions/Bestseller/Model/System/Config/Source/Bundleproducts.php +1 -0
  20. app/code/community/CapacityWebSolutions/Bestseller/Model/System/Config/Source/Chooseproducts.php +1 -0
  21. app/code/community/CapacityWebSolutions/Bestseller/Model/System/Config/Source/Orderstatus.php +1 -0
  22. app/code/community/CapacityWebSolutions/Bestseller/Model/System/Config/Source/Sortorder.php +1 -0
  23. app/code/community/CapacityWebSolutions/Bestseller/controllers/Adminhtml/BestsellerController.php +142 -0
  24. app/code/community/CapacityWebSolutions/Bestseller/controllers/IndexController.php +0 -22
  25. app/code/community/CapacityWebSolutions/Bestseller/etc/config.xml +109 -40
  26. app/code/community/CapacityWebSolutions/Bestseller/etc/system.xml +130 -23
  27. app/code/community/CapacityWebSolutions/Bestseller/sql/bestseller_setup/mysql4-install-0.1.0.php +23 -0
  28. app/design/adminhtml/default/default/layout/bestseller.xml +13 -0
  29. app/design/adminhtml/default/default/template/bestseller/product.phtml +49 -0
  30. app/design/frontend/base/default/template/bestseller/bestseller-responsive.phtml +38 -109
  31. app/design/frontend/base/default/template/bestseller/bestseller.phtml +81 -154
  32. app/etc/modules/CapacityWebSolutions_Bestseller.xml +6 -16
  33. js/bestseller/product-selector.js +193 -0
  34. package.xml +5 -5
app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/Bestseller.php ADDED
@@ -0,0 +1,19 @@
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Bestseller Product.
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_Bestseller_Block_Adminhtml_Bestseller extends Mage_Adminhtml_Block_Widget_Grid_Container
10
+ {
11
+ public function __construct()
12
+ {
13
+ $this->_controller = 'adminhtml_bestseller';
14
+ $this->_blockGroup = 'bestseller';
15
+ $this->_headerText = Mage::helper('bestseller')->__('Manage Products Manually');
16
+ $this->_addButtonLabel = Mage::helper('bestseller')->__('Select Products');
17
+ parent::__construct();
18
+ }
19
+ }
app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/Bestseller/Edit.php ADDED
@@ -0,0 +1,42 @@
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Bestseller Product.
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_Bestseller_Block_Adminhtml_Bestseller_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
10
+ {
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+ $this->_objectId = 'id';
15
+ $this->_blockGroup = 'bestseller';
16
+ $this->_controller = 'adminhtml_bestseller';
17
+ $this->_updateButton('save', 'label','Save');
18
+ $this->_updateButton('delete','label','Delete');
19
+ $this->_addButton('save_and_continue', array(
20
+ 'label' => Mage::helper('bestseller')->__('Save And Continue Edit'),
21
+ 'onclick' => 'saveAndContinueEdit()',
22
+ 'class' => 'save'
23
+ ), -100);
24
+
25
+ $this->_formScripts[] = "
26
+ function saveAndContinueEdit(){
27
+ editForm.submit($('edit_form').action + 'back/edit/');
28
+ }
29
+
30
+ ";
31
+ $this->setId('bestseller_edit');
32
+ }
33
+
34
+ public function getHeaderText()
35
+ {
36
+ if( Mage::registry('bestseller_data') && Mage::registry('bestseller_data')->getBestsellerId() ) {
37
+ return Mage::helper('bestseller')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('bestseller_data')->getSku()));
38
+ } else {
39
+ return Mage::helper('bestseller')->__('Select Products');
40
+ }
41
+ }
42
+ }
app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/Bestseller/Edit/Form.php ADDED
@@ -0,0 +1,25 @@
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Bestseller Product.
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_Bestseller_Block_Adminhtml_Bestseller_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
10
+ {
11
+ protected function _prepareForm()
12
+ {
13
+ $form = new Varien_Data_Form(
14
+ array(
15
+ 'id'=>'edit_form',
16
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
17
+ 'method'=>'post',
18
+ 'enctype' => 'multipart/form-data'
19
+ )
20
+ );
21
+ $form->setUseContainer(true);
22
+ $this->setForm($form);
23
+ return parent::_prepareForm();
24
+ }
25
+ }
app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/Bestseller/Edit/Tab/Products.php ADDED
@@ -0,0 +1,33 @@
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Bestseller Product.
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_Bestseller_Block_Adminhtml_Bestseller_Edit_Tab_Products extends Mage_Adminhtml_Block_Widget_Form
10
+ {
11
+ public function __construct() {
12
+ parent::__construct();
13
+ $this->setTemplate('bestseller/product.phtml');
14
+ }
15
+
16
+ protected function getProductIds() {
17
+ $data = Mage::registry('bestseller_data');
18
+ $prd_model = Mage::getModel('bestseller/bestseller')->getCollection();
19
+
20
+ $_productList = array();
21
+
22
+ foreach($prd_model as $prd_data){
23
+ $_productList[] = $prd_data->getData('sku');
24
+ }
25
+
26
+ return is_array($_productList) ? $_productList : array();
27
+ }
28
+
29
+ public function getIdsString() {
30
+ return implode(', ', $this->getProductIds());
31
+ }
32
+
33
+ }
app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/Bestseller/Edit/Tabs.php ADDED
@@ -0,0 +1,29 @@
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Bestseller Product.
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_Bestseller_Block_Adminhtml_Bestseller_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
10
+ {
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+ $this->setId('bestseller_tabs');
15
+ $this->setDestElementId('edit_form');
16
+ $this->setTitle('Bestseller Information');
17
+ }
18
+
19
+ protected function _beforeToHtml()
20
+ {
21
+ $this->addTab('product_section', array(
22
+ 'label' => Mage::helper('bestseller')->__('Products'),
23
+ 'title' => Mage::helper('bestseller')->__('Products'),
24
+ 'content' => $this->getLayout()->createBlock('bestseller/adminhtml_bestseller_edit_tab_products')->toHtml(),
25
+ ));
26
+
27
+ return parent::_beforeToHtml();
28
+ }
29
+ }
app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/Bestseller/Grid.php ADDED
@@ -0,0 +1,179 @@
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Bestseller Product.
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_Bestseller_Block_Adminhtml_Bestseller_Grid extends Mage_Adminhtml_Block_Widget_Grid
10
+ {
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+ $this->setId('bestsellerGrid');
15
+ //$this->setDefaultSort('bestseller_id');
16
+ $this->setDefaultSort('entity_id');
17
+ $this->setDefaultDir('ASC');
18
+ $this->setSaveParametersInSession(true);
19
+ $this->setUseAjax(true);
20
+ }
21
+
22
+ protected function _getStore()
23
+ {
24
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
25
+ return Mage::app()->getStore($storeId);
26
+ }
27
+
28
+
29
+ protected function _prepareCollection()
30
+ {
31
+ $store = $this->_getStore();
32
+ $product_skus = $this->getProductSkus();
33
+ $collection = Mage::getModel('catalog/product')->getCollection()
34
+ ->addAttributeToSelect('sku')
35
+ ->addAttributeToSelect('name')
36
+ ->addAttributeToSelect('attribute_set_id')
37
+ ->addAttributeToSelect('type_id')
38
+ ->addAttributeToFilter('sku', array('in' => $product_skus));
39
+ $adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
40
+ $collection->addStoreFilter($store);
41
+ $collection->joinAttribute(
42
+ 'name',
43
+ 'catalog_product/name',
44
+ 'entity_id',
45
+ null,
46
+ 'inner',
47
+ $adminStore
48
+ );
49
+ $collection->joinAttribute(
50
+ 'custom_name',
51
+ 'catalog_product/name',
52
+ 'entity_id',
53
+ null,
54
+ 'inner',
55
+ $store->getId()
56
+ );
57
+ $collection->joinAttribute(
58
+ 'status',
59
+ 'catalog_product/status',
60
+ 'entity_id',
61
+ null,
62
+ 'inner',
63
+ $store->getId()
64
+ );
65
+ $collection->joinAttribute(
66
+ 'visibility',
67
+ 'catalog_product/visibility',
68
+ 'entity_id',
69
+ null,
70
+ 'inner',
71
+ $store->getId()
72
+ );
73
+ $collection->joinAttribute(
74
+ 'price',
75
+ 'catalog_product/price',
76
+ 'entity_id',
77
+ null,
78
+ 'left',
79
+ $store->getId()
80
+ );
81
+
82
+ $this->setCollection($collection);
83
+ return parent::_prepareCollection();
84
+ }
85
+
86
+ protected function _prepareColumns()
87
+ {
88
+ /* $this->addColumn('bestseller_id', array(
89
+ 'header' => Mage::helper('bestseller')->__('ID'),
90
+ 'align' => 'right',
91
+ 'width' => '50px',
92
+ 'index' => 'bestseller_id',
93
+ ));
94
+ */
95
+ $this->addColumn('entity_id',
96
+ array(
97
+ 'header'=> Mage::helper('catalog')->__('ID'),
98
+ 'width' => '50px',
99
+ 'type' => 'number',
100
+ 'index' => 'entity_id',
101
+ ));
102
+ $this->addColumn('name',
103
+ array(
104
+ 'header'=> Mage::helper('catalog')->__('Name'),
105
+ 'index' => 'name',
106
+ ));
107
+
108
+ $store = $this->_getStore();
109
+ if ($store->getId()) {
110
+ $this->addColumn('custom_name',
111
+ array(
112
+ 'header'=> Mage::helper('catalog')->__('Name in %s', $store->getName()),
113
+ 'index' => 'custom_name',
114
+ ));
115
+ }
116
+
117
+ $this->addColumn('type',
118
+ array(
119
+ 'header'=> Mage::helper('catalog')->__('Type'),
120
+ 'width' => '100px',
121
+ 'index' => 'type_id',
122
+ 'type' => 'options',
123
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
124
+ ));
125
+
126
+ $this->addColumn('sku',
127
+ array(
128
+ 'header'=> Mage::helper('catalog')->__('SKU'),
129
+ 'width' => '80px',
130
+ 'index' => 'sku',
131
+ ));
132
+
133
+ $store = $this->_getStore();
134
+ $this->addColumn('price',
135
+ array(
136
+ 'header'=> Mage::helper('catalog')->__('Price'),
137
+ 'type' => 'price',
138
+ 'currency_code' => $store->getBaseCurrency()->getCode(),
139
+ 'index' => 'price',
140
+ ));
141
+
142
+ return parent::_prepareColumns();
143
+ }
144
+
145
+ public function getSkusArr($element){
146
+ return $element['sku'];
147
+ }
148
+
149
+ public function getProductSkus(){
150
+ $model = Mage::getModel('bestseller/bestseller')->getCollection();
151
+ $product_skus=array_map(array($this,"getSkusArr"), $model->getData());
152
+ return $product_skus;
153
+ }
154
+
155
+ //public function getRowUrl($row)
156
+ //{
157
+ //return $this->getUrl('*/*/edit', array('id' => $row->getId()));
158
+ //}
159
+
160
+ protected function _prepareMassaction()
161
+ {
162
+ $this->setMassactionIdField('bestseller_id');
163
+ $this->getMassactionBlock()->setFormFieldName('bestseller');
164
+
165
+ $this->getMassactionBlock()->addItem('delete', array(
166
+ 'label' => Mage::helper('bestseller')->__('Delete'),
167
+ 'url' => $this->getUrl('*/*/massDelete'),
168
+ 'confirm' => Mage::helper('bestseller')->__('Are you sure?')
169
+ ));
170
+
171
+ return $this;
172
+ }
173
+
174
+ public function getGridUrl()
175
+ {
176
+ return $this->getUrl('*/*/grid', array('_current'=>true));
177
+ }
178
+
179
+ }
app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/DefaultDirectCode.php ADDED
@@ -0,0 +1,17 @@
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Bestseller Product.
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_Bestseller_Block_Adminhtml_DefaultDirectCode
10
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
11
+ {
12
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
13
+ {
14
+ return '<div style="background:#efefef;border:1px solid #d8d8d8;padding:10px;margin-bottom:10px;"><span>&lt?php echo $this->getLayout()->createBlock("bestseller/bestseller")->setTemplate("bestseller/bestseller.phtml")->toHtml(); ?&gt;</span></div>';
15
+ }
16
+
17
+ }
app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/DefaultTemplate.php ADDED
@@ -0,0 +1,17 @@
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Bestseller Product.
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_Bestseller_Block_Adminhtml_DefaultTemplate
10
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
11
+ {
12
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
13
+ {
14
+ return '<div style="background:#efefef;border:1px solid #d8d8d8;padding:10px;margin-bottom:10px; "><span>{{block type="bestseller/bestseller" name="bestseller" template="bestseller/bestseller.phtml"}}</span></div>';
15
+ }
16
+
17
+ }
app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/DefaultXML.php ADDED
@@ -0,0 +1,20 @@
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Bestseller Product.
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_Bestseller_Block_Adminhtml_DefaultXML
10
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
11
+ {
12
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
13
+ {
14
+ return '<div style="background:#efefef;border:1px solid #d8d8d8;padding:10px;margin-bottom:10px;">
15
+ <span>&lt;reference name="content"&gt; </br>&lt;block type="bestseller/bestseller" name="bestseller" template="bestseller/bestseller.phtml"/&gt;</br>&lt;/reference&gt;</span>
16
+ </div>';
17
+
18
+ }
19
+
20
+ }
app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/RwdDirectCode.php ADDED
@@ -0,0 +1,18 @@
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Bestseller Product.
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_Bestseller_Block_Adminhtml_RwdDirectCode
10
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
11
+ {
12
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
13
+ {
14
+ return '<div style="background:#efefef;border:1px solid #d8d8d8;padding:10px;margin-bottom:10px;">
15
+ <span>&lt?php echo $this->getLayout()->createBlock("bestseller/bestseller")->setTemplate("bestseller/bestseller-responsive.phtml")->toHtml(); ?&gt;</span></div>';
16
+ }
17
+
18
+ }
app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/RwdTemplate.php ADDED
@@ -0,0 +1,17 @@
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Bestseller Product.
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_Bestseller_Block_Adminhtml_RwdTemplate
10
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
11
+ {
12
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
13
+ {
14
+ return '<div style="background:#efefef;border:1px solid #d8d8d8;padding:10px;margin-bottom:10px; "><span>{{block type="bestseller/bestseller" name="bestseller" template="bestseller/bestseller-responsive.phtml"}}</span></div>';
15
+ }
16
+
17
+ }
app/code/community/CapacityWebSolutions/Bestseller/Block/Adminhtml/RwdXML.php ADDED
@@ -0,0 +1,21 @@
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Bestseller Product.
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_Bestseller_Block_Adminhtml_RwdXML
11
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
12
+ {
13
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
14
+ {
15
+ return '<div style="background:#efefef;border:1px solid #d8d8d8;padding:10px;margin-bottom:10px;">
16
+ <span>&lt;reference name="content"&gt; </br>&lt;block type="bestseller/bestseller" name="bestseller" template="bestseller/bestseller-responsive.phtml"/&gt;</br>&lt;/reference&gt;</span>
17
+ </div>';
18
+
19
+ }
20
+
21
+ }
app/code/community/CapacityWebSolutions/Bestseller/Block/Bestseller.php CHANGED
@@ -1,18 +1,17 @@
1
<?php
2
/***************************************************************************
3
@extension : Bestseller Product.
4
- @copyright : Copyright (c) 2014 Capacity Web Solutions.
5
( http://www.capacitywebsolutions.com )
6
@author : Capacity Web Solutions Pvt. Ltd.
7
@support : magento@capacitywebsolutions.com
8
***************************************************************************/
9
- ?>
10
- <?php
11
12
class CapacityWebSolutions_Bestseller_Block_Bestseller extends Mage_Catalog_Block_Product_Abstract // Mage_Core_Block_Template
13
{
14
- public function __construct()
15
- {
16
$this->setHeader(Mage::getStoreConfig("bestseller/general/heading"));
17
$this->setLimit((int)Mage::getStoreConfig("bestseller/general/number_of_items"));
18
$this->setItemsPerRow((int)Mage::getStoreConfig("bestseller/general/number_of_items_per_row"));
@@ -23,26 +22,75 @@ class CapacityWebSolutions_Bestseller_Block_Bestseller extends Mage_Catalog_Bloc
23
$this->setAddToCart((bool)Mage::getStoreConfig('bestseller/general/add_to_cart'));
24
$this->setActive((bool)Mage::getStoreConfigFlag("bestseller/general/active"));
25
$this->setAddToCompare((bool)Mage::getStoreConfig("bestseller/general/add_to_compare"));
26
- }
27
- function getBestsellerProduct()
28
- {
29
- $timePeriod = ($this->getTimePeriod()) ? $this->getTimePeriod() : 60;
30
- $date = date('Y-m-d H:i:s');
31
- $newdate = strtotime ( '-'.$timePeriod.' day' , strtotime ( $date ) ) ;
32
- $newdate = date ( 'Y-m-j' , $newdate );
33
- $write = Mage::getSingleton('core/resource')->getConnection('core_write');
34
- $read = Mage::getSingleton('core/resource')->getConnection('core_read');
35
- $table_prefixx = Mage::getConfig()->getTablePrefix();
36
- $res = $write->query("select max(qo) as des_qty,`product_id`,`parent_item_id`,`order_id` FROM (select sum(p.qty_ordered) AS qo,p.product_id,p.created_at,p.store_id,p.parent_item_id, s.status, p.order_id from sales_flat_order as s, sales_flat_order_item as p where s.entity_id = p.order_id AND s.status = 'complete' AND p.store_id = ".$this->getStoreId()." Group By p.product_id) AS t1 where store_id = ".$this->getStoreId()." AND parent_item_id is null AND created_at between'".$newdate."' AND '".$date."' Group By `product_id` order By des_qty desc");
37
-
38
39
- while ($row = $res->fetch())
40
- {
41
- $maxQty[]=$row['product_id'];
42
-
43
- }
44
45
- return $maxQty;
46
- }
47
}
48
- ?>
1
<?php
2
/***************************************************************************
3
@extension : Bestseller Product.
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_Bestseller_Block_Bestseller extends Mage_Catalog_Block_Product_Abstract // Mage_Core_Block_Template
11
{
12
+ public function __construct()
13
+ {
14
+ $this->setEnabled((bool)Mage::getStoreConfigFlag("bestseller/general/enabled"));
15
$this->setHeader(Mage::getStoreConfig("bestseller/general/heading"));
16
$this->setLimit((int)Mage::getStoreConfig("bestseller/general/number_of_items"));
17
$this->setItemsPerRow((int)Mage::getStoreConfig("bestseller/general/number_of_items_per_row"));
22
$this->setAddToCart((bool)Mage::getStoreConfig('bestseller/general/add_to_cart'));
23
$this->setActive((bool)Mage::getStoreConfigFlag("bestseller/general/active"));
24
$this->setAddToCompare((bool)Mage::getStoreConfig("bestseller/general/add_to_compare"));
25
+ $this->setProductsPrice((int)Mage::getStoreConfig('bestseller/general/products_price'));
26
+ $this->setReview((int)Mage::getStoreConfig('bestseller/general/review'));
27
+ $this->setOutofStock((int)Mage::getStoreConfig('bestseller/general/out_of_stoke'));
28
+ $this->setChooseProducts((int)Mage::getStoreConfig('bestseller/general/choose_products'));
29
+ $this->setSortOrder((int)Mage::getStoreConfig('bestseller/general/sort_order_both'));
30
+ $this->setOrderStatus(Mage::getStoreConfig('bestseller/general/order_status'));
31
+ }
32
+
33
+ public function getBestsellerProduct() {
34
+ $o_status = $this->getOrderStatus();
35
+ if($o_status != "all"){
36
+ $order_statuses = explode(",",$o_status);
37
+ $order_status = "'" . implode("','", $order_statuses) . "'";
38
+ }
39
+
40
+ $productCount = $this->getLimit();
41
+ $timePeriod = ($this->getTimePeriod()) ? $this->getTimePeriod() : 60;
42
+ $storeId = Mage::app()->getStore()->getId();
43
+ $today = strtotime(date('Y-m-d H:i:s',Mage::getModel('core/date')->gmtTimestamp()));
44
+ $last = $today - (60*60*24*$timePeriod);
45
+ $from = date("Y-m-d H:i:s", $last);
46
+ $to = date("Y-m-d H:i:s", $today);
47
48
+ $products = Mage::getResourceModel('bestseller/product_collection')
49
+ ->addAttributeToSelect('*')
50
+ ->addOrderedQty($from, $to)
51
+ //->setStoreId($storeId)
52
+ //->addStoreFilter($storeId)
53
+ ->setOrder('ordered_qty', 'desc')
54
+ ->setPageSize($productCount);
55
+ Mage::getSingleton('catalog/product_status')
56
+ ->addVisibleFilterToCollection($products);
57
+ Mage::getSingleton('catalog/product_visibility')
58
+ ->addVisibleInCatalogFilterToCollection($products);
59
+ $products->getSelect()->where('order_items.store_id ='.$storeId);
60
61
+ if($o_status != "all"){
62
+ $products->getSelect()->where('order.status IN ('.$order_status.')');
63
+ }
64
+ return $products;
65
+ }
66
+
67
+ public function getProducts($productid) {
68
+ $collection = Mage::getModel('catalog/product')->load($productid);
69
+ if($collection->getVisibility()!=1){
70
+ if(!$this->getOutofStock()){
71
+ if($collection->isSalable()){
72
+ return $collection;
73
+ }
74
+ else{
75
+ return false;
76
+ }
77
+ }
78
+ else{
79
+ return $collection;
80
+ }
81
+ }else{
82
+ return false;
83
+ }
84
+ }
85
+
86
+ public function getIdsArr($element){
87
+ return $element['product_id'];
88
+ }
89
+
90
+ public function getProductIds(){
91
+ $model = Mage::getModel('bestseller/bestseller')->getCollection();
92
+ $product_ids=array_map(array($this,"getIdsArr"), $model->getData());
93
+ return $product_ids;
94
+ }
95
+
96
}
app/code/community/CapacityWebSolutions/Bestseller/Helper/Data.php CHANGED
@@ -1,7 +1,7 @@
1
<?php
2
/***************************************************************************
3
- @extension : Bestseller Product.
4
- @copyright : Copyright (c) 2014 Capacity Web Solutions.
5
( http://www.capacitywebsolutions.com )
6
@author : Capacity Web Solutions Pvt. Ltd.
7
@support : magento@capacitywebsolutions.com
1
<?php
2
/***************************************************************************
3
+ @extension : Best Seller 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
app/code/community/CapacityWebSolutions/Bestseller/Model/Bestseller.php ADDED
@@ -0,0 +1,17 @@
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Best Seller 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_Bestseller_Model_Bestseller extends Mage_Core_Model_Abstract
11
+ {
12
+ public function _construct()
13
+ {
14
+ parent::_construct();
15
+ $this->_init('bestseller/bestseller');
16
+ }
17
+ }
app/code/community/CapacityWebSolutions/Bestseller/Model/Mysql4/Bestseller.php ADDED
@@ -0,0 +1,16 @@
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Best Seller 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_Bestseller_Model_Mysql4_Bestseller extends Mage_Core_Model_Mysql4_Abstract
11
+ {
12
+ public function _construct()
13
+ {
14
+ $this->_init('bestseller/bestseller', 'bestseller_id');
15
+ }
16
+ }
app/code/community/CapacityWebSolutions/Bestseller/Model/Mysql4/Bestseller/Collection.php ADDED
@@ -0,0 +1,18 @@
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Best Seller 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_Bestseller_Model_Mysql4_Bestseller_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
11
+ {
12
+ public function _construct()
13
+ {
14
+ parent::_construct();
15
+ $this->_init('bestseller/bestseller');
16
+ }
17
+
18
+ }
app/code/community/CapacityWebSolutions/Bestseller/Model/Mysql4/Product/Collection.php ADDED
@@ -0,0 +1,415 @@
1
+ <?php
2
+ class CapacityWebSolutions_Bestseller_Model_Mysql4_Product_Collection extends Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
3
+ {
4
+ const SELECT_COUNT_SQL_TYPE_CART = 1;
5
+
6
+ /**
7
+ * Product entity identifier
8
+ *
9
+ * @var int
10
+ */
11
+ protected $_productEntityId;
12
+
13
+ /**
14
+ * Product entity table name
15
+ *
16
+ * @var string
17
+ */
18
+ protected $_productEntityTableName;
19
+
20
+ /**
21
+ * Product entity type identifier
22
+ *
23
+ * @var int
24
+ */
25
+ protected $_productEntityTypeId;
26
+
27
+ /**
28
+ * select count
29
+ *
30
+ * @var int
31
+ */
32
+ protected $_selectCountSqlType = 0;
33
+
34
+
35
+ /**
36
+ * Init main class options
37
+ *
38
+ */
39
+ public function __construct()
40
+ {
41
+ $product = Mage::getResourceSingleton('catalog/product');
42
+ /* @var $product Mage_Catalog_Model_Entity_Product */
43
+ $this->setProductEntityId($product->getEntityIdField());
44
+ $this->setProductEntityTableName($product->getEntityTable());
45
+ $this->setProductEntityTypeId($product->getTypeId());
46
+ parent::__construct();
47
+ }
48
+ /**
49
+ * Set Type for COUNT SQL Select
50
+ *
51
+ * @param int $type
52
+ * @return Mage_Reports_Model_Resource_Product_Collection
53
+ */
54
+ public function setSelectCountSqlType($type)
55
+ {
56
+ $this->_selectCountSqlType = $type;
57
+ return $this;
58
+ }
59
+
60
+ /**
61
+ * Set product entity id
62
+ *
63
+ * @param int $value
64
+ * @return Mage_Reports_Model_Resource_Product_Collection
65
+ */
66
+ public function setProductEntityId($entityId)
67
+ {
68
+ $this->_productEntityId = (int)$entityId;
69
+ return $this;
70
+ }
71
+
72
+ /**
73
+ * Get product entity id
74
+ *
75
+ * @return int
76
+ */
77
+ public function getProductEntityId()
78
+ {
79
+ return $this->_productEntityId;
80
+ }
81
+
82
+ /**
83
+ * Set product entity table name
84
+ *
85
+ * @param string $value
86
+ * @return Mage_Reports_Model_Resource_Product_Collection
87
+ */
88
+ public function setProductEntityTableName($value)
89
+ {
90
+ $this->_productEntityTableName = $value;
91
+ return $this;
92
+ }
93
+
94
+ /**
95
+ * Get product entity table name
96
+ *
97
+ * @return string
98
+ */
99
+ public function getProductEntityTableName()
100
+ {
101
+ return $this->_productEntityTableName;
102
+ }
103
+
104
+ /**
105
+ * Set product entity type id
106
+ *
107
+ * @param int $value
108
+ * @return Mage_Reports_Model_Resource_Product_Collection
109
+ */
110
+ public function setProductEntityTypeId($value)
111
+ {
112
+ $this->_productEntityTypeId = $value;
113
+ return $this;
114
+ }
115
+
116
+ /**
117
+ * Get product entity tyoe id
118
+ *
119
+ * @return int
120
+ */
121
+ public function getProductEntityTypeId()
122
+ {
123
+ return $this->_productEntityTypeId;
124
+ }
125
+
126
+ /**
127
+ * Join fields
128
+ *
129
+ * @return Mage_Reports_Model_Resource_Product_Collection
130
+ */
131
+ protected function _joinFields()
132
+ {
133
+ $this->_totals = new Varien_Object();
134
+
135
+ $this->addAttributeToSelect('entity_id')
136
+ ->addAttributeToSelect('name')
137
+ ->addAttributeToSelect('price');
138
+
139
+ return $this;
140
+ }
141
+
142
+ /**
143
+ * Get select count sql
144
+ *
145
+ * @return unknown
146
+ */
147
+ public function getSelectCountSql()
148
+ {
149
+ if ($this->_selectCountSqlType == self::SELECT_COUNT_SQL_TYPE_CART) {
150
+ $countSelect = clone $this->getSelect();
151
+ $countSelect->reset()
152
+ ->from(
153
+ array('quote_item_table' => $this->getTable('sales/quote_item')),
154
+ array('COUNT(DISTINCT quote_item_table.product_id)'))
155
+ ->join(
156
+ array('quote_table' => $this->getTable('sales/quote')),
157
+ 'quote_table.entity_id = quote_item_table.quote_id AND quote_table.is_active = 1',
158
+ array()
159
+ );
160
+ return $countSelect;
161
+ }
162
+
163
+ $countSelect = clone $this->getSelect();
164
+ $countSelect->reset(Zend_Db_Select::ORDER);
165
+ $countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
166
+ $countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
167
+ $countSelect->reset(Zend_Db_Select::COLUMNS);
168
+ $countSelect->reset(Zend_Db_Select::GROUP);
169
+ $countSelect->reset(Zend_Db_Select::HAVING);
170
+ $countSelect->columns("count(DISTINCT e.entity_id)");
171
+
172
+ return $countSelect;
173
+ }
174
+
175
+ /**
176
+ * Add carts count
177
+ *
178
+ * @return Mage_Reports_Model_Resource_Product_Collection
179
+ */
180
+ public function addCartsCount()
181
+ {
182
+ $countSelect = clone $this->getSelect();
183
+ $countSelect->reset();
184
+
185
+ $countSelect->from(array('quote_items' => $this->getTable('sales/quote_item')), 'COUNT(*)')
186
+ ->join(array('quotes' => $this->getTable('sales/quote')),
187
+ 'quotes.entity_id = quote_items.quote_id AND quotes.is_active = 1',
188
+ array())
189
+ ->where("quote_items.product_id = e.entity_id");
190
+
191
+ $this->getSelect()
192
+ ->columns(array("carts" => "({$countSelect})"))
193
+ ->group("e.{$this->getProductEntityId()}")
194
+ ->having('carts > ?', 0);
195
+
196
+ return $this;
197
+ }
198
+
199
+ /**
200
+ * Add orders count
201
+ *
202
+ * @param string $from
203
+ * @param string $to
204
+ * @return Mage_Reports_Model_Resource_Product_Collection
205
+ */
206
+ public function addOrdersCount($from = '', $to = '')
207
+ {
208
+ $orderItemTableName = $this->getTable('sales/order_item');
209
+ $productFieldName = sprintf('e.%s', $this->getProductEntityId());
210
+
211
+ $this->getSelect()
212
+ ->joinLeft(
213
+ array('order_items' => $orderItemTableName),
214
+ "order_items.product_id = {$productFieldName}",
215
+ array())
216
+ ->columns(array('orders' => 'COUNT(order_items2.item_id)'))
217
+ ->group($productFieldName);
218
+
219
+ $dateFilter = array('order_items2.item_id = order_items.item_id');
220
+ if ($from != '' && $to != '') {
221
+ $dateFilter[] = $this->_prepareBetweenSql('order_items2.created_at', $from, $to);
222
+ }
223
+
224
+ $this->getSelect()
225
+ ->joinLeft(
226
+ array('order_items2' => $orderItemTableName),
227
+ implode(' AND ', $dateFilter),
228
+ array()
229
+ );
230
+
231
+ return $this;
232
+ }
233
+
234
+ /**
235
+ * Add ordered qty's
236
+ *
237
+ * @param string $from
238
+ * @param string $to
239
+ * @return Mage_Reports_Model_Resource_Product_Collection
240
+ */
241
+ public function addOrderedQty($from = '', $to = '')
242
+ {
243
+ $adapter = $this->getConnection();
244
+
245
+ $config_product_option = Mage::getStoreConfig('bestseller/general/bundle_products');
246
+ //$compositeTypeIds = Mage::getSingleton('catalog/product_type')->getCompositeTypes();
247
+
248
+ if( $config_product_option == 2){
249
+ $compositeTypeIds = array ( 'grouped','configurable','bundle','simple','downloadable','virtual' );
250
+ }elseif( $config_product_option == 1){
251
+ $compositeTypeIds = array ( 'grouped','simple','downloadable','virtual' );
252
+ }else{
253
+ $compositeTypeIds = array ( 'grouped','configurable','bundle','simple','downloadable','virtual' );
254
+ }
255
+
256
+ $orderTableAliasName = $adapter->quoteIdentifier('order');
257
+
258
+ $orderJoinCondition = array(
259
+ $orderTableAliasName . '.entity_id = order_items.order_id',
260
+ $adapter->quoteInto("{$orderTableAliasName}.state <> ?", Mage_Sales_Model_Order::STATE_CANCELED),
261
+
262
+ );
263
+
264
+ $productJoinCondition = array(
265
+ $adapter->quoteInto('(e.type_id IN (?))', $compositeTypeIds),
266
+ 'e.entity_id = order_items.product_id',
267
+ $adapter->quoteInto('e.entity_type_id = ?', $this->getProductEntityTypeId())
268
+ );
269
+
270
+ if ($from != '' && $to != '') {
271
+ $fieldName = $orderTableAliasName . '.created_at';
272
+ $orderJoinCondition[] = $this->_prepareBetweenSql($fieldName, $from, $to);
273
+ }
274
+
275
+ $this->getSelect()->reset()
276
+ ->from(
277
+ array('order_items' => $this->getTable('sales/order_item')),
278
+ array(
279
+ 'ordered_qty' => 'SUM(order_items.qty_ordered)',
280
+ 'order_items_name' => 'order_items.name'
281
+ ))
282
+ ->joinInner(
283
+ array('order' => $this->getTable('sales/order')),
284
+ implode(' AND ', $orderJoinCondition),
285
+ array())
286
+ ->joinLeft(
287
+ array('e' => $this->getProductEntityTableName()),
288
+ implode(' AND ', $productJoinCondition),
289
+ array(
290
+ 'entity_id' => 'order_items.product_id',
291
+ 'entity_type_id' => 'e.entity_type_id',
292
+ 'attribute_set_id' => 'e.attribute_set_id',
293
+ 'type_id' => 'e.type_id',
294
+ 'sku' => 'e.sku',
295
+ 'has_options' => 'e.has_options',
296
+ 'required_options' => 'e.required_options',
297
+ 'created_at' => 'e.created_at',
298
+ 'updated_at' => 'e.updated_at'
299
+ ))
300
+ ->group('order_items.product_id')
301
+ ->having('SUM(order_items.qty_ordered) > ?', 0);
302
+ if( $config_product_option == 2){
303
+ $this->getSelect()->where('parent_item_id IS NULL');
304
+ }
305
+
306
+ return $this;
307
+ }
308
+
309
+ /**
310
+ * Set order
311
+ *
312
+ * @param string $attribute
313
+ * @param string $dir
314
+ * @return Mage_Reports_Model_Resource_Product_Collection
315
+ */
316
+ public function setOrder($attribute, $dir = self::SORT_ORDER_DESC)
317
+ {
318
+ if (in_array($attribute, array('carts', 'orders', 'ordered_qty'))) {
319
+ $this->getSelect()->order($attribute . ' ' . $dir);
320
+ } else {
321
+ parent::setOrder($attribute, $dir);
322
+ }
323
+
324
+ return $this;
325
+ }
326
+
327
+ /**
328
+ * Add views count
329
+ *
330
+ * @param string $from
331
+ * @param string $to
332
+ * @return Mage_Reports_Model_Resource_Product_Collection
333
+ */
334
+ public function addViewsCount($from = '', $to = '')
335
+ {
336
+ /**
337
+ * Getting event type id for catalog_product_view event
338
+ */
339
+ foreach (Mage::getModel('reports/event_type')->getCollection() as $eventType) {
340
+ if ($eventType->getEventName() == 'catalog_product_view') {
341
+ $productViewEvent = (int)$eventType->getId();
342
+ break;
343
+ }
344
+ }
345
+
346
+ $this->getSelect()->reset()
347
+ ->from(
348
+ array('report_table_views' => $this->getTable('reports/event')),
349
+ array('views' => 'COUNT(report_table_views.event_id)'))
350
+ ->join(array('e' => $this->getProductEntityTableName()),
351
+ $this->getConnection()->quoteInto(
352
+ "e.entity_id = report_table_views.object_id AND e.entity_type_id = ?",
353
+ $this->getProductEntityTypeId()))
354
+ ->where('report_table_views.event_type_id = ?', $productViewEvent)
355
+ ->group('e.entity_id')
356
+ ->order('views ' . self::SORT_ORDER_DESC)
357
+ ->having('COUNT(report_table_views.event_id) > ?', 0);
358
+
359
+ if ($from != '' && $to != '') {
360
+ $this->getSelect()
361
+ ->where('logged_at >= ?', $from)
362
+ ->where('logged_at <= ?', $to);
363
+ }
364
+
365
+ $this->_useAnalyticFunction = true;
366
+ return $this;
367
+ }
368
+
369
+ /**
370
+ * Prepare between sql
371
+ *
372
+ * @param string $fieldName Field name with table suffix ('created_at' or 'main_table.created_at')
373
+ * @param string $from
374
+ * @param string $to
375
+ * @return string Formatted sql string
376
+ */
377
+ protected function _prepareBetweenSql($fieldName, $from, $to)
378
+ {
379
+ return sprintf('(%s BETWEEN %s AND %s)',
380
+ $fieldName,
381
+ $this->getConnection()->quote($from),
382
+ $this->getConnection()->quote($to)
383
+ );
384
+ }
385
+
386
+ /**
387
+ * Add store restrictions to product collection
388
+ *
389
+ * @param array $storeIds
390
+ * @param array $websiteIds
391
+ * @return Mage_Reports_Model_Resource_Product_Collection
392
+ */
393
+ public function addStoreRestrictions($storeIds, $websiteIds)
394
+ {
395
+ if (!is_array($storeIds)) {
396
+ $storeIds = array($storeIds);
397
+ }
398
+ if (!is_array($websiteIds)) {
399
+ $websiteIds = array($websiteIds);
400
+ }
401
+
402
+ $filters = $this->_productLimitationFilters;
403
+ if (isset($filters['store_id'])) {
404
+ if (!in_array($filters['store_id'], $storeIds)) {
405
+ $this->addStoreFilter($filters['store_id']);
406
+ } else {
407
+ $this->addStoreFilter($this->getStoreId());
408
+ }
409
+ } else {
410
+ $this->addWebsiteFilter($websiteIds);
411
+ }
412
+
413
+ return $this;
414
+ }
415
+ }
app/code/community/CapacityWebSolutions/Bestseller/Model/System/Config/Source/Bundleproducts.php ADDED
@@ -0,0 +1 @@
0
{
1
}
1
+ <?php
2
{
3
}
app/code/community/CapacityWebSolutions/Bestseller/Model/System/Config/Source/Chooseproducts.php ADDED
@@ -0,0 +1 @@
0
{
1
}
1
+ <?php
2
{
3
}
app/code/community/CapacityWebSolutions/Bestseller/Model/System/Config/Source/Orderstatus.php ADDED
@@ -0,0 +1 @@
0
{
1
}
1
+ <?php
2
{
3
}
app/code/community/CapacityWebSolutions/Bestseller/Model/System/Config/Source/Sortorder.php ADDED
@@ -0,0 +1 @@
0
{
1
}
1
+ <?php
2
{
3
}
app/code/community/CapacityWebSolutions/Bestseller/controllers/Adminhtml/BestsellerController.php ADDED
@@ -0,0 +1,142 @@
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Bestseller Product.
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_Bestseller_Adminhtml_BestsellerController 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('bestseller/bestseller')->load($id);
30
+
31
+ if ($model->getBestsellerId() || $id == 0) {
32
+
33
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
34
+ if (!empty($data)) {
35
+ $model->setData($data);
36
+ }
37
+
38
+ Mage::register('bestseller_data', $model);
39
+
40
+ $this->loadLayout();
41
+ $this->_setActiveMenu('cws');
42
+
43
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Best Seller Products'), Mage::helper('adminhtml')->__('Best Seller Products'));
44
+
45
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
46
+
47
+ $this->_addContent($this->getLayout()->createBlock('bestseller/adminhtml_bestseller_edit'))
48
+ ->_addLeft($this->getLayout()->createBlock('bestseller/adminhtml_bestseller_edit_tabs'));
49
+
50
+ $this->renderLayout();
51
+ } else {
52
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('bestseller')->__('Best Seller Products does not exist'));
53
+ $this->_redirect('*/*/');
54
+ }
55
+ }
56
+
57
+ public function saveAction() {
58
+ $product_skus = array();
59
+ $product_ids = array();
60
+
61
+ if ($data = $this->getRequest()->getPost()) {
62
+
63
+ $id = $this->getRequest()->getParam('id');
64
+
65
+ if (isset($data['product_sku'])) {
66
+ $data['product_sku'] = explode(', ',$data['product_sku']);
67
+ if (is_array($data['product_sku'])) {
68
+ $product_skus = array_unique($data['product_sku']);
69
+ }
70
+ }
71
+
72
+ foreach($product_skus as $sku){
73
+ $product_ids[$sku] = Mage::getModel("catalog/product")->getIdBySku($sku);
74
+ }
75
+
76
+ try {
77
+ //save product skus
78
+ $model = Mage::getModel('bestseller/bestseller');
79
+ $prd_data = $model->getCollection();
80
+ $prd_data->walk('delete');
81
+
82
+ foreach($product_skus as $sku){
83
+ if($sku){
84
+ $model->setData('sku',$sku);
85
+ $model->setData('product_id',$product_ids[$sku]);
86
+ $model->save();
87
+ $model->unsetData();
88
+ }
89
+ }
90
+
91
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('bestseller')->__('Best Seller Products was successfully saved'));
92
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
93
+
94
+ if ($this->getRequest()->getParam('back')) {
95
+ $this->_redirect('*/*/edit', array('id' => $model->getBestsellerId()));
96
+ return;
97
+ }
98
+ $this->_redirect('*/*/');
99
+ return;
100
+ } catch (Exception $e) {
101
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
102
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
103
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
104
+ return;
105
+ }
106
+ }
107
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('bestseller')->__('Unable to find Best Seller Products to save'));
108
+ $this->_redirect('*/*/');
109
+ }
110
+
111
+ public function massDeleteAction() {
112
+ $bestseller_ids = $this->getRequest()->getParam('bestseller');
113
+
114
+ if(!is_array($bestseller_ids)) {
115
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
116
+ } else {
117
+ try {
118
+ foreach ($bestseller_ids as $bestseller_id) {
119
+ $bestseller = Mage::getModel('bestseller/bestseller')->load($bestseller_id,'product_id');
120
+ $bestseller->delete();
121
+ }
122
+ Mage::getSingleton('adminhtml/session')->addSuccess(
123
+ Mage::helper('adminhtml')->__(
124
+ 'Total of %d record(s) were successfully deleted', count($bestseller_ids)
125
+ )
126
+ );
127
+ } catch (Exception $e) {
128
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
129
+ }
130
+ }
131
+ $this->_redirect('*/*/index');
132
+ }
133
+
134
+ public function gridAction()
135
+ {
136
+ $this->loadLayout();
137
+ $this->getResponse()->setBody(
138
+ $this->getLayout()->createBlock('bestseller/adminhtml_bestseller_grid')->toHtml()
139
+ );
140
+ }
141
+
142
+ }
app/code/community/CapacityWebSolutions/Bestseller/controllers/IndexController.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
- /***************************************************************************
3
- @extension : Bestseller Product.
4
- @copyright : Copyright (c) 2014 Capacity Web Solutions.
5
- ( http://www.capacitywebsolutions.com )
6
- @author : Capacity Web Solutions Pvt. Ltd.
7
- @support : magento@capacitywebsolutions.com
8
- ***************************************************************************/
9
- ?>
10
- <?php
11
-
12
- class CapacityWebSolutions_Bestseller_IndexController extends Mage_Core_Controller_Front_Action
13
- {
14
- public function indexAction()
15
- {
16
- $this->loadLayout(array('default'));
17
- $this->renderLayout();
18
- }
19
- }
20
-
21
-
22
- ?>
app/code/community/CapacityWebSolutions/Bestseller/etc/config.xml CHANGED
@@ -1,27 +1,55 @@
1
<?xml version="1.0"?>
2
- <!--
3
- /***************************************************************************
4
- @extension : Bestseller Product.
5
- @copyright : Copyright (c) 2014 Capacity Web Solutions.
6
- ( http://www.capacitywebsolutions.com )
7
- @author : Capacity Web Solutions Pvt. Ltd.
8
- @support : magento@capacitywebsolutions.com
9
- ***************************************************************************/
10
- -->
11
<config>
12
<global>
13
- <modules>
14
- <CapacityWebSolutions_Bestseller>
15
- <version>1.1.7</version>
16
- </CapacityWebSolutions_Bestseller>
17
- </modules>
18
- <blocks>
19
<bestseller>
20
- <rewrite>
21
- <bestseller>CapacityWebSolutions_Bestseller_Block_Bestseller</bestseller>
22
- </rewrite>
23
</bestseller>
24
- </blocks>
25
</global>
26
<frontend>
27
<routers>
@@ -33,15 +61,53 @@
33
</args>
34
</bestseller>
35
</routers>
36
<layout>
37
<updates>
38
<bestseller>
39
- <file>bestseller.xml</file>
40
</bestseller>
41
</updates>
42
- </layout>
43
- </frontend>
44
- <adminhtml>
45
<acl>
46
<resources>
47
<admin>
@@ -63,21 +129,24 @@
63
</acl>
64
</adminhtml>
65
<default> <!-- Default text value set from admin-->
66
- <bestseller>
67
- <general>
68
- <enabled>1</enabled>
69
- <heading>BESTSELLER PRODUCTS</heading>
70
- <number_of_items>6</number_of_items>
71
- <number_of_items_per_row>3</number_of_items_per_row>
72
- <thumbnail_height>135</thumbnail_height>
73
- <thumbnail_width>135</thumbnail_width>
74
- <time_period>60</time_period>
75
- <products_price>1</products_price>
76
- <review>1</review>
77
- <add_to_cart>1</add_to_cart>
78
- <active>1</active>
79
- <add_to_compare>1</add_to_compare>
80
- </general>
81
- </bestseller>
82
- </default>
83
</config>
1
<?xml version="1.0"?>
2
<config>
3
+ <modules>
4
+ <CapacityWebSolutions_Bestseller>
5
+ <version>2.0.0</version>
6
+ </CapacityWebSolutions_Bestseller>
7
+ </modules>
8
<global>
9
+ <models>
10
<bestseller>
11
+ <class>CapacityWebSolutions_Bestseller_Model</class>
12
+ <resourceModel>bestseller_mysql4</resourceModel>
13
</bestseller>
14
+ <bestseller_mysql4>
15
+ <class>CapacityWebSolutions_Bestseller_Model_Mysql4</class>
16
+ <entities>
17
+ <bestseller>
18
+ <table>bestseller</table>
19
+ </bestseller>
20
+ </entities>
21
+ </bestseller_mysql4>
22
+ </models>
23
+ <resources>
24
+ <bestseller_setup>
25
+ <setup>
26
+ <module>CapacityWebSolutions_Bestseller</module>
27
+ </setup>
28
+ <connection>
29
+ <use>core_setup</use>
30
+ </connection>
31
+ </bestseller_setup>
32
+ <bestseller_write>
33
+ <connection>
34
+ <use>core_write</use>
35
+ </connection>
36
+ </bestseller_write>
37
+ <bestseller_read>
38
+ <connection>
39
+ <use>core_read</use>
40
+ </connection>
41
+ </bestseller_read>
42
+ </resources>
43
+ <blocks>
44
+ <bestseller>
45
+ <class>CapacityWebSolutions_Bestseller_Block</class>
46
+ </bestseller>
47
+ </blocks>
48
+ <helpers>
49
+ <bestseller>
50
+ <class>CapacityWebSolutions_Bestseller_Helper</class>
51
+ </bestseller>
52
+ </helpers>
53
</global>
54
<frontend>
55
<routers>
61
</args>
62
</bestseller>
63
</routers>
64
+ </frontend>
65
+
66
+ <admin>
67
+ <routers>
68
+ <bestseller>
69
+ <use>admin</use>
70
+ <args>
71
+ <module>CapacityWebSolutions_Bestseller</module>
72
+ <frontName>bestseller</frontName>
73
+ </args>
74
+ </bestseller>
75
+ </routers>
76
+ </admin>
77
+
78
+ <adminhtml>
79
+ <menu>
80
+ <cws module="bestseller">
81
+ <title>CWS Extensions</title>
82
+ <sort_order>70</sort_order>
83
+ <children>
84
+ <bestseller module="bestseller">
85
+ <title>Bestseller Products</title>
86
+ <sort_order>70</sort_order>
87
+ <children>
88
+ <groups module="bestseller">
89
+ <title>Manage Products Manually</title>
90
+ <sort_order>10</sort_order>
91
+ <action>bestseller/adminhtml_bestseller</action>
92
+ </groups>
93
+ <settings>
94
+ <title>Manage Settings</title>
95
+ <sort_order>20</sort_order>
96
+ <action>adminhtml/system_config/edit/section/bestseller</action>
97
+ </settings>
98
+ </children>
99
+
100
+ </bestseller>
101
+ </children>
102
+ </cws>
103
+ </menu>
104
<layout>
105
<updates>
106
<bestseller>
107
+ <file>bestseller.xml</file>
108
</bestseller>
109
</updates>
110
+ </layout>
111
<acl>
112
<resources>
113
<admin>
129
</acl>
130
</adminhtml>
131
<default> <!-- Default text value set from admin-->
132
+ <bestseller>
133
+ <general>
134
+ <enabled>1</enabled>
135
+ <heading>BESTSELLER PRODUCTS</heading>
136
+ <number_of_items>6</number_of_items>
137
+ <number_of_items_per_row>3</number_of_items_per_row>
138
+ <thumbnail_height>135</thumbnail_height>
139
+ <thumbnail_width>135</thumbnail_width>
140
+ <time_period>60</time_period>
141
+ <products_price>1</products_price>
142
+ <review>1</review>
143
+ <add_to_cart>1</add_to_cart>
144
+ <active>1</active>
145
+ <add_to_compare>1</add_to_compare>
146
+ <order_status>all</order_status>
147
+ <choose_products>1</choose_products>
148
+ <bundle_products>1</bundle_products>
149
+ </general>
150
+ </bestseller>
151
+ </default>
152
</config>
app/code/community/CapacityWebSolutions/Bestseller/etc/system.xml CHANGED
@@ -1,13 +1,4 @@
1
<?xml version="1.0"?>
2
- <!--
3
- /***************************************************************************
4
- @extension : Bestseller Product.
5
- @copyright : Copyright (c) 2014 Capacity Web Solutions.
6
- ( http://www.capacitywebsolutions.com )
7
- @author : Capacity Web Solutions Pvt. Ltd.
8
- @support : magento@capacitywebsolutions.com
9
- ***************************************************************************/
10
- -->
11
<config>
12
<tabs>
13
<cws>
@@ -26,6 +17,75 @@
26
<show_in_website>1</show_in_website>
27
<show_in_store>1</show_in_store>
28
<groups>
29
<general translate="label">
30
<label>General</label>
31
<frontend_type>text</frontend_type>
@@ -43,7 +103,7 @@
43
<show_in_default>1</show_in_default>
44
<show_in_website>1</show_in_website>
45
<show_in_store>1</show_in_store>
46
- </enabled>
47
<heading translate="label">
48
<label>Heading</label>
49
<comment>Here, We can Set Heading.</comment>
@@ -53,11 +113,48 @@
53
<show_in_website>1</show_in_website>
54
<show_in_store>1</show_in_store>
55
</heading>
56
<number_of_items translate="label comment">
57
<label>Number Of Items in Main Block</label>
58
<comment>Show Number of best seller products in main block</comment>
59
<frontend_type>text</frontend_type>
60
- <sort_order>2</sort_order>
61
<show_in_default>1</show_in_default>
62
<show_in_website>1</show_in_website>
63
<show_in_store>1</show_in_store>
@@ -66,7 +163,7 @@
66
<label>Number Of Items per row in Main Block</label>
67
<comment>Show Number of best seller products in per row</comment>
68
<frontend_type>text</frontend_type>
69
- <sort_order>3</sort_order>
70
<show_in_default>1</show_in_default>
71
<show_in_website>1</show_in_website>
72
<show_in_store>1</show_in_store>
@@ -75,7 +172,7 @@
75
<label>Thumbnail Width</label>
76
<comment>Default Thumbnail Width: 135px</comment>
77
<frontend_type>text</frontend_type>
78
- <sort_order>4</sort_order>
79
<show_in_default>1</show_in_default>
80
<show_in_website>1</show_in_website>
81
<show_in_store>1</show_in_store>
@@ -84,7 +181,7 @@
84
<label>Thumbnail Height </label>
85
<comment>Default Thumbnail Height: 135px</comment>
86
<frontend_type>text</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>
@@ -93,7 +190,7 @@
93
<label>Time Period</label>
94
<comment>Days bestselling product. Default 60 days.</comment>
95
<frontend_type>text</frontend_type>
96
- <sort_order>6</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>
@@ -102,7 +199,7 @@
102
<label>Time Period</label>
103
<comment>Days bestselling product. Default 60 days.</comment>
104
<frontend_type>text</frontend_type>
105
- <sort_order>7</sort_order>
106
<show_in_default>1</show_in_default>
107
<show_in_website>1</show_in_website>
108
<show_in_store>1</show_in_store>
@@ -112,7 +209,7 @@
112
<comment>Select Yes for display the Products Price on frontend.</comment>
113
<source_model>adminhtml/system_config_source_yesno</source_model>
114
<frontend_type>select</frontend_type>
115
- <sort_order>8</sort_order>
116
<show_in_default>1</show_in_default>
117
<show_in_website>1</show_in_website>
118
<show_in_store>1</show_in_store>
@@ -122,7 +219,7 @@
122
<comment>Select Yes for display the Reviews Ratings on frontend.</comment>
123
<source_model>adminhtml/system_config_source_yesno</source_model>
124
<frontend_type>select</frontend_type>
125
- <sort_order>9</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>
@@ -132,7 +229,7 @@
132
<comment>Select Yes for display the Add to cart button on frontend.</comment>
133
<source_model>adminhtml/system_config_source_yesno</source_model>
134
<frontend_type>select</frontend_type>
135
- <sort_order>10</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>
@@ -142,7 +239,7 @@
142
<comment>Select Yes for display the Add to Wishlist Link on frontend.</comment>
143
<frontend_type>select</frontend_type>
144
<source_model>adminhtml/system_config_source_yesno</source_model>
145
- <sort_order>11</sort_order>
146
<show_in_default>1</show_in_default>
147
<show_in_website>1</show_in_website>
148
<show_in_store>1</show_in_store>
@@ -152,7 +249,7 @@
152
<comment>Select Yes for display the Add to Compare Link on frontend.</comment>
153
<source_model>adminhtml/system_config_source_yesno</source_model>
154
<frontend_type>select</frontend_type>
155
- <sort_order>12</sort_order>
156
<show_in_default>1</show_in_default>
157
<show_in_website>1</show_in_website>
158
<show_in_store>1</show_in_store>
@@ -162,11 +259,21 @@
162
<comment>Select Yes for display the out of stock items on frontend.</comment>
163
<source_model>adminhtml/system_config_source_yesno</source_model>
164
<frontend_type>select</frontend_type>
165
- <sort_order>13</sort_order>
166
<show_in_default>1</show_in_default>
167
<show_in_website>1</show_in_website>
168
<show_in_store>1</show_in_store>
169
- </out_of_stoke>
170
</fields>
171
</general>
172
</groups>
1
<?xml version="1.0"?>
2
<config>
3
<tabs>
4
<cws>
17
<show_in_website>1</show_in_website>
18
<show_in_store>1</show_in_store>
19
<groups>
20
+ <default_code translate="label">
21
+ <label>Default Package Code</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>80</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
+ <bsxml translate="label comment">
29
+ <comment><![CDATA[]]></comment>
30
+ <label>XML Tag Representation</label>
31
+ <frontend_type>text</frontend_type>
32
+ <frontend_model>CapacityWebSolutions_Bestseller_Block_Adminhtml_DefaultXML</frontend_model>
33
+ <sort_order>1</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ </bsxml>
36
+ <bstemplated translate="label comment">
37
+ <comment><![CDATA[]]></comment>
38
+ <label>Template Tag Representation</label>
39
+ <frontend_type>text</frontend_type>
40
+ <frontend_model>CapacityWebSolutions_Bestseller_Block_Adminhtml_DefaultTemplate</frontend_model>
41
+ <sort_order>2</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ </bstemplated>
44
+ <bsdirect 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_Bestseller_Block_Adminhtml_DefaultDirectCode</frontend_model>
49
+ <sort_order>3</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ </bsdirect>
52
+ </fields>
53
+ </default_code>
54
+ <rwd_code translate="label">
55
+ <label>RWD Package Code</label>
56
+ <frontend_type>text</frontend_type>
57
+ <sort_order>90</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
+ <bsxml translate="label comment">
63
+ <comment><![CDATA[]]></comment>
64
+ <label>XML Tag Representation</label>
65
+ <frontend_type>text</frontend_type>
66
+ <frontend_model>CapacityWebSolutions_Bestseller_Block_Adminhtml_RwdXML</frontend_model>
67
+ <sort_order>1</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+
70
+ </bsxml>
71
+ <bstemplated translate="label comment">
72
+ <comment><![CDATA[]]></comment>
73
+ <label>Template Tag Representation</label>
74
+ <frontend_type>text</frontend_type>
75
+ <frontend_model>CapacityWebSolutions_Bestseller_Block_Adminhtml_RwdTemplate</frontend_model>
76
+ <sort_order>2</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ </bstemplated>
79
+ <bsdirect translate="label comment">
80
+ <comment><![CDATA[]]></comment>
81
+ <label>Call Via Frontend Template File</label>
82
+ <frontend_type>text</frontend_type>
83
+ <frontend_model>CapacityWebSolutions_Bestseller_Block_Adminhtml_RwdDirectCode</frontend_model>
84
+ <sort_order>3</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ </bsdirect>
87
+ </fields>
88
+ </rwd_code>
89
<general translate="label">
90
<label>General</label>
91
<frontend_type>text</frontend_type>
103
<show_in_default>1</show_in_default>
104
<show_in_website>1</show_in_website>
105
<show_in_store>1</show_in_store>
106
+ </enabled>
107
<heading translate="label">
108
<label>Heading</label>
109
<comment>Here, We can Set Heading.</comment>
113
<show_in_website>1</show_in_website>
114
<show_in_store>1</show_in_store>
115
</heading>
116
+ <choose_products translate="label">
117
+ <label>Best Seller Products</label>
118
+ <comment><![CDATA[Auto >> Show system generated products.<br>
119
+ Manually >> Show manually added products.<br>
120
+ Both >> Show both system generated and manually added products.]]>
121
+ </comment>
122
+ <source_model>bestseller/system_config_source_chooseproducts</source_model>
123
+ <frontend_type>select</frontend_type>
124
+ <sort_order>2</sort_order>
125
+ <show_in_default>1</show_in_default>
126
+ <show_in_website>1</show_in_website>
127
+ <show_in_store>1</show_in_store>
128
+ </choose_products>
129
+ <sort_order_both>
130
+ <label>Sort Order for Both</label>
131
+ <comment><![CDATA[Auto >> Show System generated products first then manually added products.<br>
132
+ Manually >> Show manually added products first then system generated products.
133
+ ]]></comment>
134
+ <source_model>bestseller/system_config_source_sortorder</source_model>
135
+ <frontend_type>select</frontend_type>
136
+ <sort_order>3</sort_order>
137
+ <show_in_default>1</show_in_default>
138
+ <show_in_website>1</show_in_website>
139
+ <show_in_store>1</show_in_store>
140
+ <depends><choose_products>3</choose_products></depends>
141
+ </sort_order_both>
142
+ <bundle_products>
143
+ <label>Display Bundle and Configurable Products</label>
144
+ <comment><![CDATA[Applied only if "Best Seller Products" field is set to "Auto" or "Both".]]>
145
+ </comment>
146
+ <source_model>bestseller/system_config_source_bundleproducts</source_model>
147
+ <frontend_type>select</frontend_type>
148
+ <sort_order>4</sort_order>
149
+ <show_in_default>1</show_in_default>
150
+ <show_in_website>1</show_in_website>
151
+ <show_in_store>1</show_in_store>
152
+ </bundle_products>
153
<number_of_items translate="label comment">
154
<label>Number Of Items in Main Block</label>
155
<comment>Show Number of best seller products in main block</comment>
156
<frontend_type>text</frontend_type>
157
+ <sort_order>6</sort_order>
158
<show_in_default>1</show_in_default>
159
<show_in_website>1</show_in_website>
160
<show_in_store>1</show_in_store>
163
<label>Number Of Items per row in Main Block</label>
164
<comment>Show Number of best seller products in per row</comment>
165
<frontend_type>text</frontend_type>
166
+ <sort_order>7</sort_order>
167
<show_in_default>1</show_in_default>
168
<show_in_website>1</show_in_website>
169
<show_in_store>1</show_in_store>
172
<label>Thumbnail Width</label>
173
<comment>Default Thumbnail Width: 135px</comment>
174
<frontend_type>text</frontend_type>
175
+ <sort_order>8</sort_order>
176
<show_in_default>1</show_in_default>
177
<show_in_website>1</show_in_website>
178
<show_in_store>1</show_in_store>
181
<label>Thumbnail Height </label>
182
<comment>Default Thumbnail Height: 135px</comment>
183
<frontend_type>text</frontend_type>
184
+ <sort_order>9</sort_order>
185
<show_in_default>1</show_in_default>
186
<show_in_website>1</show_in_website>
187
<show_in_store>1</show_in_store>
190
<label>Time Period</label>
191
<comment>Days bestselling product. Default 60 days.</comment>
192
<frontend_type>text</frontend_type>
193
+ <sort_order>10</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>
199
<label>Time Period</label>
200
<comment>Days bestselling product. Default 60 days.</comment>
201
<frontend_type>text</frontend_type>
202
+ <sort_order>11</sort_order>
203
<show_in_default>1</show_in_default>
204
<show_in_website>1</show_in_website>
205
<show_in_store>1</show_in_store>
209
<comment>Select Yes for display the Products Price on frontend.</comment>
210
<source_model>adminhtml/system_config_source_yesno</source_model>
211
<frontend_type>select</frontend_type>
212
+ <sort_order>12</sort_order>
213
<show_in_default>1</show_in_default>
214
<show_in_website>1</show_in_website>
215
<show_in_store>1</show_in_store>
219
<comment>Select Yes for display the Reviews Ratings on frontend.</comment>
220
<source_model>adminhtml/system_config_source_yesno</source_model>
221
<frontend_type>select</frontend_type>
222
+ <sort_order>13</sort_order>
223
<show_in_default>1</show_in_default>
224
<show_in_website>1</show_in_website>
225
<show_in_store>1</show_in_store>
229
<comment>Select Yes for display the Add to cart button on frontend.</comment>
230
<source_model>adminhtml/system_config_source_yesno</source_model>
231
<frontend_type>select</frontend_type>
232
+ <sort_order>14</sort_order>
233
<show_in_default>1</show_in_default>
234
<show_in_website>1</show_in_website>
235
<show_in_store>1</show_in_store>
239
<comment>Select Yes for display the Add to Wishlist Link on frontend.</comment>
240
<frontend_type>select</frontend_type>
241
<source_model>adminhtml/system_config_source_yesno</source_model>
242
+ <sort_order>15</sort_order>
243
<show_in_default>1</show_in_default>
244
<show_in_website>1</show_in_website>
245
<show_in_store>1</show_in_store>
249
<comment>Select Yes for display the Add to Compare Link on frontend.</comment>
250
<source_model>adminhtml/system_config_source_yesno</source_model>
251
<frontend_type>select</frontend_type>
252
+ <sort_order>16</sort_order>
253
<show_in_default>1</show_in_default>
254
<show_in_website>1</show_in_website>
255
<show_in_store>1</show_in_store>
259
<comment>Select Yes for display the out of stock items on frontend.</comment>
260
<source_model>adminhtml/system_config_source_yesno</source_model>
261
<frontend_type>select</frontend_type>
262
+ <sort_order>17</sort_order>
263
+ <show_in_default>1</show_in_default>
264
+ <show_in_website>1</show_in_website>
265
+ <show_in_store>1</show_in_store>
266
+ </out_of_stoke>
267
+ <order_status translate="label">
268
+ <label>Order Status</label>
269
+ <comment>Applied only if "Best Seller Products" field is set to "Auto" or "Both".</comment>
270
+ <source_model>bestseller/system_config_source_orderstatus</source_model>
271
+ <frontend_type>multiselect</frontend_type>
272
+ <sort_order>18</sort_order>
273
<show_in_default>1</show_in_default>
274
<show_in_website>1</show_in_website>
275
<show_in_store>1</show_in_store>
276
+ </order_status>
277
</fields>
278
</general>
279
</groups>
app/code/community/CapacityWebSolutions/Bestseller/sql/bestseller_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,23 @@
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ CREATE TABLE IF NOT EXISTS `".$this->getTable('bestseller')."` (
10
+ `bestseller_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
11
+ `sku` varchar(32) NOT NULL DEFAULT '',
12
+ `product_id` int(11) unsigned NOT NULL,
13
+ PRIMARY KEY (`bestseller_id`),
14
+ KEY `IDX_BESTSELLER_PRODUCT_SKU` (`sku`),
15
+ KEY `IDX_BESTSELLER_PRODUCT_ID` (`product_id`)
16
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
17
+
18
+ ALTER TABLE `".$this->getTable('bestseller')."`
19
+ ADD CONSTRAINT `IDX_BESTSELLER_PRODUCT_SKU` FOREIGN KEY (`sku`) REFERENCES `".$this->getTable('catalog_product_entity')."` (`sku`) ON DELETE CASCADE ON UPDATE CASCADE,
20
+ ADD CONSTRAINT `IDX_BESTSELLER_PRODUCT_ID` FOREIGN KEY (`product_id`) REFERENCES `".$this->getTable('catalog_product_entity')."` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE;
21
+ ");
22
+
23
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/bestseller.xml ADDED
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <bestseller_adminhtml_bestseller_index>
4
+ <reference name="content">
5
+ <block type="bestseller/adminhtml_bestseller" name="bestseller" />
6
+ </reference>
7
+ </bestseller_adminhtml_bestseller_index>
8
+ <bestseller_adminhtml_bestseller_edit>
9
+ <reference name="head">
10
+ <action method="addJs"><script>bestseller/product-selector.js</script></action>
11
+ </reference>
12
+ </bestseller_adminhtml_bestseller_edit>
13
+ </layout>
app/design/adminhtml/default/default/template/bestseller/product.phtml ADDED
@@ -0,0 +1,49 @@
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Bestseller Product.
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
+ <style>
11
+ .product-param label { padding-right: 10px; }
12
+ .product-param .label { color: black; font-weight: bold; }
13
+ .product-param .label:hover { color: blue; font-weight: bold; }
14
+ .product-param .element { display: none; }
15
+ .product-param input, .product-param select { min-width: 350px; width: auto !important; }
16
+ .product-param-edit .label { display: none; }
17
+ .product-param-edit .element { display: inline; }
18
+ .product-chooser { border: 1px solid #CCC; display: none; margin: 10px 0; padding: 5px; }
19
+ </style>
20
+
21
+ <div class="entry-edit">
22
+ <div class="entry-edit-head">
23
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('bestseller')->__('Manually Products') ?></h4>
24
+
25
+ </div>
26
+ <fieldset id="product_fieldset">
27
+ <ul>
28
+ <li>
29
+ <span class="product-param">
30
+ <label for="product_sku"><?php echo Mage::helper('bestseller')->__('Select Best Seller Product SKUs') ?></label>
31
+ <a class="label" href="javascript:void(0)"><?php if($this->getIdsString()) { echo $this->getIdsString(); } else { echo Mage::helper('bestseller')->__('Click Here To Add Products'); } ?></a>
32
+ <span class="element">
33
+ <input id="product_sku" class="input-text element-value-changer" type="text" value="<?php echo $this->getIdsString() ?>" name="product_sku">
34
+ <a class="product-chooser-trigger" href="javascript:void(0)">
35
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('images/rule_chooser_trigger.gif') ?>" alt="" class="v-middle product-chooser-trigger" title="<?php echo Mage::helper('bestseller')->__('Open Chooser') ?>" />
36
+ </a>
37
+ </span>
38
+ </span>
39
+ <div class="product-chooser" url="<?php echo Mage::getUrl('adminhtml/promo_widget/chooser/attribute/sku/form/rule_conditions_fieldset', array('_secure' => Mage::app()->getStore()->isAdminUrlSecure())); ?>">
40
+ </li>
41
+ </ul>
42
+ </fieldset>
43
+ </div>
44
+
45
+ <script type="text/javascript">
46
+ 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())) ?>');
47
+
48
+
49
+ </script>
app/design/frontend/base/default/template/bestseller/bestseller-responsive.phtml CHANGED
@@ -1,7 +1,7 @@
1
<?php
2
/***************************************************************************
3
@extension : Bestseller Product.
4
- @copyright : Copyright (c) 2014 Capacity Web Solutions.
5
( http://www.capacitywebsolutions.com )
6
@author : Capacity Web Solutions Pvt. Ltd.
7
@support : magento@capacitywebsolutions.com
@@ -13,37 +13,50 @@
13
.std .products-grid li { margin-left:0; padding:0; list-style:none; }
14
</style>
15
<?php
16
- $result = $this->getBestsellerProduct();
17
- $collection = Mage::getResourceModel('catalog/product_collection');
18
- $collection->addFieldToFilter('entity_id',array('in'=>$result))->load();
19
- $foundIds = array_intersect($result,array_keys($collection->toArray()));
20
- $result = array_values($foundIds);
21
$upperLimit = ($this->getLimit()) ? $this->getLimit() : 1;
22
$_columnCount = ($this->getItemsPerRow()) ? $this->getItemsPerRow() : 1 ;
23
- $model = Mage::getModel('catalog/product');
24
- $enabled = Mage::getStoreConfig('bestseller/general/enabled');
25
- $products_price = Mage::getStoreConfig('bestseller/general/products_price');
26
- $review = Mage::getStoreConfig('bestseller/general/review');
27
- $out_of_stoke = Mage::getStoreConfig('bestseller/general/out_of_stoke');
28
29
?>
30
31
- <?php if($enabled == 1): ?>
32
<div class="page-title category-title">
33
- <h1><?php echo $this->getHeader(); ?></h1>
34
</div>
35
- <?php if ($out_of_stoke == 0) { ?>
36
<ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col">
37
<?php
38
$i=0; $x = 1;
39
- for($cnt = 0; $cnt<count($result); $cnt++) {
40
- $_product = $model->load($result[$cnt]);
41
- $visibility = $_product->getData('visibility');
42
- $status = $_product->getData('status');
43
- $is_salable = $_product->getData('is_salable');
44
- if($status == 1 && $visibility == 4) {
45
- if ($is_salable == 1 ){
46
- if($x <= $upperLimit) {
47
48
?>
49
<li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
@@ -103,98 +116,14 @@
103
<?php
104
}
105
$x++;
106
- }
107
- }
108
}
109
?>
110
</ul>
111
<script type="text/javascript">decorateGeneric($('ul.products-grid'), ['odd','even','first','last'])</script>
112
- <?php
113
- }
114
- else
115
- {
116
- ?>
117
- <ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col">
118
- <?php
119
- $i=0; $x = 1;
120
- for($cnt = 0; $cnt<count($result); $cnt++){
121
- $_product = $model->load($result[$cnt]);
122
- $visibility = $_product->getData('visibility');
123
124
- $status = $_product->getData('status');
125
- if ($status == 1 && $visibility == 4){
126
- if($x <= $upperLimit) {
127
-
128
- ?>
129
- <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
130
- <a href="<?php echo $this->getBaseUrl().$_product['url_path']; ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" class="product-image">
131
- <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(($this->getImageHeight()) ? $this->getImageHeight() : 135,($this->getImageWidth()) ? $this->getImageWidth() : 135); ?>" alt="<?php echo $this->htmlEscape($_product['name']) ?>"/>
132
- </a>
133
-
134
- <div class="product-info">
135
-
136
- <h2 class="product-name"><a href="<?php echo $this->getBaseUrl().$_product['url_path'] ?>" title="<?php echo $this->htmlEscape($_product['name']) ?>"><?php echo $this->htmlEscape($_product['name']) ?></a></h2>
137
-
138
- <?php
139
- if($review == 1) {
140
- $_product = Mage::getModel('catalog/product')->load($_product->getId());
141
- echo $this->getReviewsSummaryHtml($_product, 'short');
142
- }
143
- if($products_price == 1) {
144
- $_product = Mage::getModel('catalog/product')->load($_product->getId());
145
- echo $this->getPriceHtml($_product, true);
146
- }
147
- ?>
148
- <div class="actions" style="display:block !important">
149
- <?php $addtocartval = $this->getAddToCart();
150
- if($addtocartval == 1){
151
- if($_product->isSaleable() && !$_product->canConfigure()): ?>
152
- <button class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')">
153
- <span><?php echo $this->__('Add to Cart') ?></span>
154
- </button>
155
- <?php elseif($_product->isSaleable()): ?>
156
- <button class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')">
157
- <span><?php echo $this->__('View Details')?></span>
158
- </button>
159
- <?php else: ?>
160
- <span class="out-of-stock">
161
- <?php echo $this->__('Out of stock') ?>
162
- </span>
163
- <?php endif; }?>
164
-
165
- <ul class="add-to-links">
166
- <?php $wishlists = $this->getActive();
167
- if($wishlists == 1){
168
- if ($this->helper('wishlist')->isAllow()) : ?>
169
- <li><a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="addWishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
170
- <?php endif; }?>
171
-
172
-
173
- <?php $addtocompare = $this->getAddToCompare();
174
- if($addtocompare==1){
175
- if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
176
- <li><a href="<?php echo $_compareUrl; ?>" class="addCompare"><?php echo $this->__('Add to Compare') ?></a></li>
177
- <?php endif; }?>
178
-
179
- </ul>
180
-
181
- </div>
182
-
183
- </div>
184
-
185
- </li>
186
- <?php
187
-
188
- }
189
- $x++;
190
- }
191
- }
192
- ?>
193
- </ul>
194
- <script type="text/javascript">decorateGeneric($('ul.products-grid'), ['odd','even','first','last'])</script>
195
- <?php
196
- }
197
- ?>
198
199
200
<?php endif; ?>