Version Notes
Mos tviewed Products
Download this release
Release Info
Developer | Capacity Web Solutions |
Extension | Mostviewed_Products |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/DefaultDirectCode.php +16 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/DefaultTemplate.php +16 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/DefaultXML.php +19 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed.php +29 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Edit.php +41 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Edit/Form.php +24 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Edit/Tab/Products.php +27 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Edit/Tabs.php +28 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Grid.php +178 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Block/Mostviewed.php +249 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Block/Promo/Widget/Chooser/Sku.php +158 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Block/Widget.php +25 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Block/Widget/Html/Pager.php +273 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Helper/Data.php +17 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Model/Mostviewed.php +15 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Model/Mysql4/Mostviewed.php +14 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Model/Mysql4/Mostviewed/Collection.php +16 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Category.php +65 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Chooseproducts.php +1 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Choosetype.php +1 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Sortby.php +1 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Sortorder.php +1 -0
- app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Template.php +1 -0
- app/code/community/CapacityWebSolutions/Mostviewed/controllers/Adminhtml/MostviewedController.php +219 -0
- app/code/community/CapacityWebSolutions/Mostviewed/controllers/Adminhtml/WidgetController.php +33 -0
- app/code/community/CapacityWebSolutions/Mostviewed/etc/adminhtml.xml +46 -0
- app/code/community/CapacityWebSolutions/Mostviewed/etc/config.xml +126 -0
- app/code/community/CapacityWebSolutions/Mostviewed/etc/system.xml +324 -0
- app/code/community/CapacityWebSolutions/Mostviewed/etc/widget.xml +195 -0
- app/code/community/CapacityWebSolutions/Mostviewed/sql/mostviewed_setup/mysql4-install-1.0.0.php +27 -0
- app/design/adminhtml/default/default/layout/mostviewed.xml +17 -0
- app/design/adminhtml/default/default/template/mostviewed/product.phtml +48 -0
- app/design/frontend/base/default/layout/mostviewed.xml +8 -0
- app/design/frontend/base/default/template/mostviewed/column/mostviewed_default_list-default.phtml +40 -0
- app/design/frontend/base/default/template/mostviewed/column/mostviewed_default_list.phtml +42 -0
- app/design/frontend/base/default/template/mostviewed/mostviewed-grid.phtml +140 -0
- app/design/frontend/base/default/template/mostviewed/mostviewed-list.phtml +143 -0
- app/etc/modules/CapacityWebSolutions_Mostviewed.xml +9 -0
- js/mostviewed/product-selector.js +193 -0
- package.xml +18 -0
- skin/frontend/base/default/css/mostviewed/mostviewed.css +13 -0
app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/DefaultDirectCode.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/***************************************************************************
|
3 |
+
Extension Name : Mostviewed Products
|
4 |
+
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
5 |
+
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
6 |
+
Support Email : support@magebees.com
|
7 |
+
***************************************************************************/
|
8 |
+
class CapacityWebSolutions_Mostviewed_Block_Adminhtml_DefaultDirectCode
|
9 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
10 |
+
{
|
11 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
12 |
+
{
|
13 |
+
return '<div style="background:#efefef;border:1px solid #d8d8d8;padding:10px;margin-bottom:10px;"><span><?php echo $this->getLayout()->createBlock("mostviewed/mostviewed")->toHtml(); ?></span></div>';
|
14 |
+
}
|
15 |
+
|
16 |
+
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/DefaultTemplate.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/***************************************************************************
|
3 |
+
Extension Name : Mostviewed Products
|
4 |
+
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
5 |
+
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
6 |
+
Support Email : support@magebees.com
|
7 |
+
***************************************************************************/
|
8 |
+
class CapacityWebSolutions_Mostviewed_Block_Adminhtml_DefaultTemplate
|
9 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
10 |
+
{
|
11 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
12 |
+
{
|
13 |
+
return '<div style="background:#efefef;border:1px solid #d8d8d8;padding:10px;margin-bottom:10px; "><span>{{block type="mostviewed/mostviewed" name="mostviewed"}}</span></div>';
|
14 |
+
}
|
15 |
+
|
16 |
+
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/DefaultXML.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/***************************************************************************
|
3 |
+
Extension Name : Mostviewed Products
|
4 |
+
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
5 |
+
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
6 |
+
Support Email : support@magebees.com
|
7 |
+
***************************************************************************/
|
8 |
+
class CapacityWebSolutions_Mostviewed_Block_Adminhtml_DefaultXML
|
9 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
10 |
+
{
|
11 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
12 |
+
{
|
13 |
+
return '<div style="background:#efefef;border:1px solid #d8d8d8;padding:10px;margin-bottom:10px;">
|
14 |
+
<span><reference name="content"> </br><block type="mostviewed/mostviewed" name="mostviewed"/></br></reference></span>
|
15 |
+
</div>';
|
16 |
+
|
17 |
+
}
|
18 |
+
|
19 |
+
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/***************************************************************************
|
3 |
+
Extension Name : Mostviewed Products
|
4 |
+
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
5 |
+
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
6 |
+
Support Email : support@magebees.com
|
7 |
+
***************************************************************************/
|
8 |
+
class CapacityWebSolutions_Mostviewed_Block_Adminhtml_Mostviewed extends Mage_Adminhtml_Block_Widget_Grid_Container
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
$this->_controller = 'adminhtml_mostviewed';
|
13 |
+
$this->_blockGroup = 'mostviewed';
|
14 |
+
$this->_headerText = Mage::helper('mostviewed')->__('Manage Most Viewed Products');
|
15 |
+
$this->_addButtonLabel = Mage::helper('mostviewed')->__('Select Products');
|
16 |
+
parent::__construct();
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _prepareLayout() {
|
20 |
+
$this->setChild('store_switcher', $this->getLayout()->createBlock('adminhtml/store_switcher', 'store_switcher')->setUseConfirm(false)
|
21 |
+
);
|
22 |
+
return parent::_prepareLayout();
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getGridHtml() {
|
26 |
+
|
27 |
+
return $this->getChildHtml('store_switcher') . $this->getChildHtml('grid');
|
28 |
+
}
|
29 |
+
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Edit.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/***************************************************************************
|
3 |
+
Extension Name : Mostviewed Products
|
4 |
+
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
5 |
+
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
6 |
+
Support Email : support@magebees.com
|
7 |
+
***************************************************************************/
|
8 |
+
class CapacityWebSolutions_Mostviewed_Block_Adminhtml_Mostviewed_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
$this->_objectId = 'id';
|
14 |
+
$this->_blockGroup = 'mostviewed';
|
15 |
+
$this->_controller = 'adminhtml_mostviewed';
|
16 |
+
$this->_updateButton('save', 'label','Save');
|
17 |
+
$this->_updateButton('delete','label','Delete');
|
18 |
+
$this->_addButton('save_and_continue', array(
|
19 |
+
'label' => Mage::helper('mostviewed')->__('Save And Continue Edit'),
|
20 |
+
'onclick' => 'saveAndContinueEdit()',
|
21 |
+
'class' => 'save'
|
22 |
+
), -100);
|
23 |
+
|
24 |
+
$this->_formScripts[] = "
|
25 |
+
function saveAndContinueEdit(){
|
26 |
+
editForm.submit($('edit_form').action + 'back/edit/');
|
27 |
+
}
|
28 |
+
|
29 |
+
";
|
30 |
+
$this->setId('mostviewed_edit');
|
31 |
+
}
|
32 |
+
|
33 |
+
public function getHeaderText()
|
34 |
+
{
|
35 |
+
if( Mage::registry('mostviewed_data') && Mage::registry('mostviewed_data')->getNewproductsId() ) {
|
36 |
+
return Mage::helper('mostviewed')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('mostviewed_data')->getSku()));
|
37 |
+
} else {
|
38 |
+
return Mage::helper('mostviewed')->__('Select Products');
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Edit/Form.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/***************************************************************************
|
3 |
+
Extension Name : Mostviewed Products
|
4 |
+
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
5 |
+
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
6 |
+
Support Email : support@magebees.com
|
7 |
+
***************************************************************************/
|
8 |
+
class CapacityWebSolutions_Mostviewed_Block_Adminhtml_Mostviewed_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
9 |
+
{
|
10 |
+
protected function _prepareForm()
|
11 |
+
{
|
12 |
+
$form = new Varien_Data_Form(
|
13 |
+
array(
|
14 |
+
'id'=>'edit_form',
|
15 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
16 |
+
'method'=>'post',
|
17 |
+
'enctype' => 'multipart/form-data'
|
18 |
+
)
|
19 |
+
);
|
20 |
+
$form->setUseContainer(true);
|
21 |
+
$this->setForm($form);
|
22 |
+
return parent::_prepareForm();
|
23 |
+
}
|
24 |
+
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Edit/Tab/Products.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/***************************************************************************
|
3 |
+
Extension Name : Mostviewed Products
|
4 |
+
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
5 |
+
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
6 |
+
Support Email : support@magebees.com
|
7 |
+
***************************************************************************/
|
8 |
+
class CapacityWebSolutions_Mostviewed_Block_Adminhtml_Mostviewed_Edit_Tab_Products extends Mage_Adminhtml_Block_Widget_Form
|
9 |
+
{
|
10 |
+
public function __construct() {
|
11 |
+
parent::__construct();
|
12 |
+
$this->setTemplate('mostviewed/product.phtml');
|
13 |
+
}
|
14 |
+
|
15 |
+
public function getSkusArr($element){
|
16 |
+
return $element['sku'];
|
17 |
+
}
|
18 |
+
|
19 |
+
public function getSkusString() {
|
20 |
+
$store_id = Mage::app()->getRequest()->getParam('store',0);
|
21 |
+
$featuredCollection = Mage::getModel('mostviewed/mostviewed')->getCollection()->addFieldToFilter('store_id', array(array('finset' => $store_id)));
|
22 |
+
$product_skus_arr = array_map(array($this,"getSkusArr"), $featuredCollection->getData());
|
23 |
+
$product_skus = implode(", ",$product_skus_arr);
|
24 |
+
return $product_skus;
|
25 |
+
}
|
26 |
+
|
27 |
+
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Edit/Tabs.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/***************************************************************************
|
3 |
+
Extension Name : Mostviewed Products
|
4 |
+
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
5 |
+
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
6 |
+
Support Email : support@magebees.com
|
7 |
+
***************************************************************************/
|
8 |
+
class CapacityWebSolutions_Mostviewed_Block_Adminhtml_Mostviewed_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
$this->setId('mostviewed_tabs');
|
14 |
+
$this->setDestElementId('edit_form');
|
15 |
+
$this->setTitle('Mostviewed Information');
|
16 |
+
}
|
17 |
+
|
18 |
+
protected function _beforeToHtml()
|
19 |
+
{
|
20 |
+
$this->addTab('product_section', array(
|
21 |
+
'label' => Mage::helper('mostviewed')->__('Products'),
|
22 |
+
'title' => Mage::helper('mostviewed')->__('Products'),
|
23 |
+
'content' => $this->getLayout()->createBlock('mostviewed/adminhtml_mostviewed_edit_tab_products')->toHtml(),
|
24 |
+
));
|
25 |
+
|
26 |
+
return parent::_beforeToHtml();
|
27 |
+
}
|
28 |
+
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Block/Adminhtml/Mostviewed/Grid.php
ADDED
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/***************************************************************************
|
3 |
+
Extension Name : Mostviewed Products
|
4 |
+
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
5 |
+
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
6 |
+
Support Email : support@magebees.com
|
7 |
+
***************************************************************************/
|
8 |
+
class CapacityWebSolutions_Mostviewed_Block_Adminhtml_Mostviewed_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
$this->setId('mostviewedGrid');
|
14 |
+
//$this->setDefaultSort('mostviewed_id');
|
15 |
+
$this->setDefaultSort('entity_id');
|
16 |
+
$this->setDefaultDir('ASC');
|
17 |
+
$this->setSaveParametersInSession(true);
|
18 |
+
$this->setUseAjax(true);
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _getStore()
|
22 |
+
{
|
23 |
+
$storeId = (int) $this->getRequest()->getParam('store', 0);
|
24 |
+
return Mage::app()->getStore($storeId);
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
protected function _prepareCollection()
|
29 |
+
{
|
30 |
+
$store = $this->_getStore();
|
31 |
+
$product_skus = $this->getProductSkus();
|
32 |
+
$collection = Mage::getModel('catalog/product')->getCollection()
|
33 |
+
->addAttributeToSelect('sku')
|
34 |
+
->addAttributeToSelect('name')
|
35 |
+
->addAttributeToSelect('attribute_set_id')
|
36 |
+
->addAttributeToSelect('type_id')
|
37 |
+
->addAttributeToFilter('sku', array('in' => $product_skus));
|
38 |
+
$adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
|
39 |
+
$collection->addStoreFilter($store);
|
40 |
+
$collection->joinAttribute(
|
41 |
+
'name',
|
42 |
+
'catalog_product/name',
|
43 |
+
'entity_id',
|
44 |
+
null,
|
45 |
+
'inner',
|
46 |
+
$adminStore
|
47 |
+
);
|
48 |
+
$collection->joinAttribute(
|
49 |
+
'custom_name',
|
50 |
+
'catalog_product/name',
|
51 |
+
'entity_id',
|
52 |
+
null,
|
53 |
+
'inner',
|
54 |
+
$store->getId()
|
55 |
+
);
|
56 |
+
$collection->joinAttribute(
|
57 |
+
'status',
|
58 |
+
'catalog_product/status',
|
59 |
+
'entity_id',
|
60 |
+
null,
|
61 |
+
'inner',
|
62 |
+
$store->getId()
|
63 |
+
);
|
64 |
+
$collection->joinAttribute(
|
65 |
+
'visibility',
|
66 |
+
'catalog_product/visibility',
|
67 |
+
'entity_id',
|
68 |
+
null,
|
69 |
+
'inner',
|
70 |
+
$store->getId()
|
71 |
+
);
|
72 |
+
$collection->joinAttribute(
|
73 |
+
'price',
|
74 |
+
'catalog_product/price',
|
75 |
+
'entity_id',
|
76 |
+
null,
|
77 |
+
'left',
|
78 |
+
$store->getId()
|
79 |
+
);
|
80 |
+
|
81 |
+
$this->setCollection($collection);
|
82 |
+
return parent::_prepareCollection();
|
83 |
+
}
|
84 |
+
|
85 |
+
protected function _prepareColumns()
|
86 |
+
{
|
87 |
+
$this->addColumn('entity_id',
|
88 |
+
array(
|
89 |
+
'header'=> Mage::helper('catalog')->__('ID'),
|
90 |
+
'width' => '50px',
|
91 |
+
'type' => 'number',
|
92 |
+
'index' => 'entity_id',
|
93 |
+
));
|
94 |
+
$this->addColumn('name',
|
95 |
+
array(
|
96 |
+
'header'=> Mage::helper('catalog')->__('Name'),
|
97 |
+
'index' => 'name',
|
98 |
+
));
|
99 |
+
|
100 |
+
$store = $this->_getStore();
|
101 |
+
if ($store->getId()) {
|
102 |
+
$this->addColumn('custom_name',
|
103 |
+
array(
|
104 |
+
'header'=> Mage::helper('catalog')->__('Name in %s', $store->getName()),
|
105 |
+
'index' => 'custom_name',
|
106 |
+
));
|
107 |
+
}
|
108 |
+
|
109 |
+
$this->addColumn('type',
|
110 |
+
array(
|
111 |
+
'header'=> Mage::helper('catalog')->__('Type'),
|
112 |
+
'width' => '100px',
|
113 |
+
'index' => 'type_id',
|
114 |
+
'type' => 'options',
|
115 |
+
'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
|
116 |
+
));
|
117 |
+
|
118 |
+
$this->addColumn('sku',
|
119 |
+
array(
|
120 |
+
'header'=> Mage::helper('catalog')->__('SKU'),
|
121 |
+
'width' => '80px',
|
122 |
+
'index' => 'sku',
|
123 |
+
));
|
124 |
+
|
125 |
+
$store = $this->_getStore();
|
126 |
+
$this->addColumn('price',
|
127 |
+
array(
|
128 |
+
'header'=> Mage::helper('catalog')->__('Price'),
|
129 |
+
'type' => 'price',
|
130 |
+
'currency_code' => $store->getBaseCurrency()->getCode(),
|
131 |
+
'index' => 'price',
|
132 |
+
));
|
133 |
+
|
134 |
+
return parent::_prepareColumns();
|
135 |
+
}
|
136 |
+
|
137 |
+
|
138 |
+
|
139 |
+
public function getSkusArr($element){
|
140 |
+
return $element['sku'];
|
141 |
+
}
|
142 |
+
|
143 |
+
public function getProductSkus(){
|
144 |
+
$store_id = Mage::app()->getRequest()->getParam('store',0);
|
145 |
+
|
146 |
+
$featuredCollection = Mage::getModel('mostviewed/mostviewed')->getCollection()->addFieldToFilter('store_id', array(array('finset' => $store_id)));
|
147 |
+
$product_skus=array_map(array($this,"getSkusArr"), $featuredCollection->getData());
|
148 |
+
return $product_skus;
|
149 |
+
}
|
150 |
+
|
151 |
+
//public function getRowUrl($row)
|
152 |
+
//{
|
153 |
+
//return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
154 |
+
//}
|
155 |
+
|
156 |
+
protected function _prepareMassaction()
|
157 |
+
{
|
158 |
+
$store_id = Mage::app()->getRequest()->getParam('store',0);
|
159 |
+
$url = $this->getUrl('*/*/massDelete',array('store'=>$store_id));
|
160 |
+
|
161 |
+
$this->setMassactionIdField('mostviewed_id');
|
162 |
+
$this->getMassactionBlock()->setFormFieldName('mostviewed');
|
163 |
+
|
164 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
165 |
+
'label' => Mage::helper('mostviewed')->__('Delete'),
|
166 |
+
'url' => $url,
|
167 |
+
'confirm' => Mage::helper('mostviewed')->__('Are you sure?')
|
168 |
+
));
|
169 |
+
|
170 |
+
return $this;
|
171 |
+
}
|
172 |
+
|
173 |
+
public function getGridUrl()
|
174 |
+
{
|
175 |
+
return $this->getUrl('*/*/grid', array('_current'=>true));
|
176 |
+
}
|
177 |
+
|
178 |
+
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Block/Mostviewed.php
ADDED
@@ -0,0 +1,249 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/***************************************************************************
|
3 |
+
Extension Name : Mostviewed Products
|
4 |
+
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
5 |
+
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
6 |
+
Support Email : support@magebees.com
|
7 |
+
***************************************************************************/
|
8 |
+
class CapacityWebSolutions_Mostviewed_Block_Mostviewed extends Mage_Catalog_Block_Product_Abstract
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Name of request parameter for page number value
|
12 |
+
*/
|
13 |
+
const PAGE_VAR_NAME = 'np';
|
14 |
+
|
15 |
+
public function __construct() {
|
16 |
+
parent::_construct();
|
17 |
+
$this->addColumnCountLayoutDepend('empty', 6)
|
18 |
+
->addColumnCountLayoutDepend('one_column', 5)
|
19 |
+
->addColumnCountLayoutDepend('two_columns_left', 4)
|
20 |
+
->addColumnCountLayoutDepend('two_columns_right', 4)
|
21 |
+
->addColumnCountLayoutDepend('three_columns', 3);
|
22 |
+
|
23 |
+
$this->setStoreId(Mage::app()->getStore()->getId());
|
24 |
+
|
25 |
+
//General Settings
|
26 |
+
$this->setEnabled((bool)Mage::getStoreConfig("mostviewed/general/enabled"));
|
27 |
+
$this->setDisplayHeading((bool)Mage::getStoreConfig("mostviewed/general/display_heading"));
|
28 |
+
$this->setHeading(Mage::getStoreConfig("mostviewed/general/heading"));
|
29 |
+
$this->setChooseProducts(Mage::getStoreConfig("mostviewed/general/choose_products"));
|
30 |
+
$this->setDisplayBy(Mage::getStoreConfig("mostviewed/general/display_by"));
|
31 |
+
$this->setCategories(Mage::getStoreConfig("mostviewed/general/categories"));
|
32 |
+
$this->setSortBy(Mage::getStoreConfig("mostviewed/general/sort_by"));
|
33 |
+
$this->setSortOrder(Mage::getStoreConfig("mostviewed/general/sort_order"));
|
34 |
+
$this->setProductsPrice((bool)Mage::getStoreConfig("mostviewed/general/products_price"));
|
35 |
+
$this->setReview((bool)Mage::getStoreConfig("mostviewed/general/review"));
|
36 |
+
$this->setShortDesc((bool)Mage::getStoreConfig("mostviewed/general/short_desc"));
|
37 |
+
$this->setDescLimit((int)Mage::getStoreConfig("mostviewed/general/desc_limit"));
|
38 |
+
$this->setAddToCart((bool)Mage::getStoreConfig("mostviewed/general/add_to_cart"));
|
39 |
+
$this->setAddToWishlist((bool)Mage::getStoreConfig("mostviewed/general/add_to_wishlist"));
|
40 |
+
$this->setAddToCompare((bool)Mage::getStoreConfig("mostviewed/general/add_to_compare"));
|
41 |
+
$this->setOutOfStock((bool)Mage::getStoreConfig("mostviewed/general/out_of_stock"));
|
42 |
+
$this->setIsResponsive((bool)Mage::getStoreConfig('mostviewed/general/isresponsive'));
|
43 |
+
|
44 |
+
//Template Settings
|
45 |
+
$this->setCustomTemplate(Mage::getStoreConfig("mostviewed/template/select_template"));
|
46 |
+
$this->setProductsCount((int)Mage::getStoreConfig("mostviewed/template/number_of_items"));
|
47 |
+
$this->setShowPager((bool)Mage::getStoreConfig("mostviewed/template/show_pager"));
|
48 |
+
$this->setProductsPerPage((int)Mage::getStoreConfig("mostviewed/template/products_per_page"));
|
49 |
+
$this->setHeight((int)Mage::getStoreConfig("mostviewed/template/thumbnail_height"));
|
50 |
+
$this->setWidth((int)Mage::getStoreConfig("mostviewed/template/thumbnail_width"));
|
51 |
+
}
|
52 |
+
|
53 |
+
public function setWidgetOptions(){
|
54 |
+
//General Settings
|
55 |
+
$this->setDisplayHeading((bool)$this->getWdDisplayHeading());
|
56 |
+
$this->setHeading($this->getWdHeading());
|
57 |
+
$this->setChooseProducts($this->getWdChooseProducts());
|
58 |
+
$this->setDisplayBy((int)$this->getWdDisplayBy());
|
59 |
+
$this->setCategories($this->getWdCategories());
|
60 |
+
$this->setSortBy($this->getWdSortBy());
|
61 |
+
$this->setSortOrder($this->getWdSortOrder());
|
62 |
+
$this->setProductsPrice((bool)$this->getWdProductsPrice());
|
63 |
+
$this->setReview((bool)$this->getWdReview());
|
64 |
+
$this->setShortDesc((bool)$this->getWdShortDesc());
|
65 |
+
$this->setDescLimit((int)$this->getWdDescLimit());
|
66 |
+
$this->setAddToCart((bool)$this->getWdAddToCart());
|
67 |
+
$this->setAddToWishlist((bool)$this->getWdAddToWishlist());
|
68 |
+
$this->setAddToCompare((bool)$this->getWdAddToCompare());
|
69 |
+
$this->setOutOfStock((bool)$this->getWdOutOfStock());
|
70 |
+
|
71 |
+
//Template Settings
|
72 |
+
$this->setProductsCount((int)$this->getWdNumberOfItems());
|
73 |
+
$this->setShowPager((bool)$this->getWdShowPager());
|
74 |
+
$this->setProductsPerPage((int)$this->getWdProductsPerPage());
|
75 |
+
$this->setHeight((int)$this->getWdThumbnailHeight());
|
76 |
+
$this->setWidth((int)$this->getWdThumbnailWidth());
|
77 |
+
}
|
78 |
+
|
79 |
+
public function getIdsArr($element){
|
80 |
+
return $element['entity_id'];
|
81 |
+
}
|
82 |
+
|
83 |
+
protected function _getProductCollection() {
|
84 |
+
switch ($this->getChooseProducts()) {
|
85 |
+
case 1: //Auto
|
86 |
+
$collection = $this->_getAutoProductCollection();
|
87 |
+
break;
|
88 |
+
case 2: //Manually
|
89 |
+
$collection = $this->_getManuallyAddedProductsCollection();
|
90 |
+
break;
|
91 |
+
case 3: //Both
|
92 |
+
$collection1 = $this->_getAutoProductCollection();
|
93 |
+
$collection2 = $this->_getManuallyAddedProductsCollection();
|
94 |
+
$ids=array_map(array($this,"getIdsArr"), $collection1->getData());//for magento1.4
|
95 |
+
$merged_ids = array_unique(array_merge($ids, $collection2->getAllIds()));
|
96 |
+
|
97 |
+
$collection = Mage::getResourceModel('catalog/product_collection')
|
98 |
+
->addFieldToFilter('entity_id', array('in' => $merged_ids))
|
99 |
+
->addAttributeToSelect('*');
|
100 |
+
break;
|
101 |
+
default:
|
102 |
+
$collection = $this->_getAutoProductCollection();
|
103 |
+
break;
|
104 |
+
}
|
105 |
+
|
106 |
+
$storeId = Mage::app()->getStore()->getId();
|
107 |
+
|
108 |
+
$collection ->addMinimalPrice()
|
109 |
+
->addFinalPrice()
|
110 |
+
->setStore($storeId)
|
111 |
+
->addStoreFilter($storeId)
|
112 |
+
->setPageSize($this->getProductsCount())
|
113 |
+
->setCurPage(1)
|
114 |
+
;
|
115 |
+
|
116 |
+
//Display out of stock products
|
117 |
+
if(!$this->getOutOfStock()){
|
118 |
+
Mage::getSingleton('cataloginventory/stock')
|
119 |
+
->addInStockFilterToCollection($collection);
|
120 |
+
}
|
121 |
+
|
122 |
+
//Display By Category
|
123 |
+
if($this->getDisplayBy()==2)
|
124 |
+
{
|
125 |
+
$categorytable = Mage::getSingleton('core/resource')->getTableName('catalog_category_product');
|
126 |
+
$collection->getSelect()
|
127 |
+
->joinLeft(array('at_category_id' => $categorytable),'e.entity_id = at_category_id.product_id','at_category_id.category_id')
|
128 |
+
->group('e.entity_id')
|
129 |
+
->where("at_category_id.category_id IN (".$this->getCategories().")")
|
130 |
+
;
|
131 |
+
}
|
132 |
+
|
133 |
+
//Set Sort Order
|
134 |
+
if($this->getSortOrder()=='rand'){
|
135 |
+
$collection->getSelect()->order('rand()');
|
136 |
+
}else{
|
137 |
+
$collection->addAttributeToSort($this->getSortBy(), $this->getSortOrder());
|
138 |
+
}
|
139 |
+
|
140 |
+
return $collection;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Prepare collection with new products
|
145 |
+
*
|
146 |
+
* @return Mage_Core_Block_Abstract
|
147 |
+
*/
|
148 |
+
protected function _beforeToHtml(){
|
149 |
+
if($this->getType()=="mostviewed/widget")
|
150 |
+
{
|
151 |
+
$this->setWidgetOptions();
|
152 |
+
}
|
153 |
+
$this->setProductCollection($this->_getProductCollection());
|
154 |
+
}
|
155 |
+
|
156 |
+
//Get most viewed products collection
|
157 |
+
protected function _getAutoProductCollection(){
|
158 |
+
$storeId = Mage::app()->getStore()->getId();
|
159 |
+
/* $collection = Mage::getResourceModel('reports/product_collection')
|
160 |
+
->addAttributeToSelect('*')
|
161 |
+
->addViewsCount()
|
162 |
+
->setStoreId($storeId)
|
163 |
+
->addStoreFilter($storeId); */
|
164 |
+
$collection = Mage::getResourceModel('reports/product_collection')
|
165 |
+
// ->addOrderedQty()
|
166 |
+
->addAttributeToSelect('*')
|
167 |
+
->addViewsCount()
|
168 |
+
->setStoreId($storeId)
|
169 |
+
->addStoreFilter($storeId)
|
170 |
+
;
|
171 |
+
|
172 |
+
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
|
173 |
+
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
|
174 |
+
$collection->getSelect()->where('cat_index.store_id ='.$storeId);
|
175 |
+
return $collection;
|
176 |
+
}
|
177 |
+
|
178 |
+
protected function _getManuallyAddedProductsCollection(){
|
179 |
+
/** @var $collection Mage_Catalog_Model_Resource_Product_Collection */
|
180 |
+
$collection = Mage::getResourceModel('catalog/product_collection');
|
181 |
+
$collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
|
182 |
+
|
183 |
+
$collection = $this->_addProductAttributesAndPrices($collection)
|
184 |
+
->addAttributeToFilter('sku', array('in' => $this->getSkus()));
|
185 |
+
return $collection;
|
186 |
+
}
|
187 |
+
|
188 |
+
public function getSkusArr($element){
|
189 |
+
return $element['sku'];
|
190 |
+
}
|
191 |
+
|
192 |
+
public function getSkus(){
|
193 |
+
$store_id = $this->getStoreId();
|
194 |
+
$featuredCollection = Mage::getModel('mostviewed/mostviewed')->getCollection()->addFieldToFilter('store_id', array(array('finset' => $store_id)));
|
195 |
+
$product_skus=array_map(array($this,"getSkusArr"), $featuredCollection->getData());
|
196 |
+
return $product_skus;
|
197 |
+
}
|
198 |
+
|
199 |
+
public function limit_word($text, $limit) {
|
200 |
+
if (str_word_count($text, 0) > $limit) {
|
201 |
+
$words = str_word_count($text, 2);
|
202 |
+
$pos = array_keys($words);
|
203 |
+
$text = substr($text, 0, $pos[$limit]) . '...';
|
204 |
+
}
|
205 |
+
return $text;
|
206 |
+
}
|
207 |
+
|
208 |
+
public function _toHtml(){
|
209 |
+
if (!$this->getEnabled()) {
|
210 |
+
return '';
|
211 |
+
}
|
212 |
+
if(!$this->getTemplate()){
|
213 |
+
if($this->getCustomTemplate()==2){
|
214 |
+
$this->setTemplate('mostviewed/mostviewed-list.phtml');
|
215 |
+
}else{
|
216 |
+
$this->setTemplate('mostviewed/mostviewed-grid.phtml');
|
217 |
+
}
|
218 |
+
}
|
219 |
+
return parent::_toHtml();
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Render pagination HTML
|
224 |
+
*
|
225 |
+
* @return string
|
226 |
+
*/
|
227 |
+
public function getPagerHtml()
|
228 |
+
{
|
229 |
+
if ($this->getShowPager()) {
|
230 |
+
if (!$this->_pager) {
|
231 |
+
$this->_pager = $this->getLayout()
|
232 |
+
->createBlock('mostviewed/widget_html_pager', 'widget.mostviewed.product.list.pager');
|
233 |
+
|
234 |
+
$this->_pager->setUseContainer(true)
|
235 |
+
->setShowAmounts(true)
|
236 |
+
->setShowPerPage(false)
|
237 |
+
->setPageVarName(self::PAGE_VAR_NAME)
|
238 |
+
->setLimit($this->getProductsPerPage())
|
239 |
+
->setTotalLimit($this->getProductsCount())
|
240 |
+
->setCollection($this->getProductCollection());
|
241 |
+
}
|
242 |
+
if ($this->_pager instanceof Mage_Core_Block_Abstract) {
|
243 |
+
return $this->_pager->toHtml();
|
244 |
+
}
|
245 |
+
}
|
246 |
+
return '';
|
247 |
+
}
|
248 |
+
|
249 |
+
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Block/Promo/Widget/Chooser/Sku.php
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/***************************************************************************
|
3 |
+
Extension Name : Mostviewed Products
|
4 |
+
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
5 |
+
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
6 |
+
Support Email : support@magebees.com
|
7 |
+
***************************************************************************/
|
8 |
+
class CapacityWebSolutions_Mostviewed_Block_Promo_Widget_Chooser_Sku extends Mage_Adminhtml_Block_Widget_Grid
|
9 |
+
{
|
10 |
+
|
11 |
+
public function __construct($arguments=array())
|
12 |
+
{
|
13 |
+
parent::__construct($arguments);
|
14 |
+
|
15 |
+
if ($this->getRequest()->getParam('current_grid_id')) {
|
16 |
+
$this->setId($this->getRequest()->getParam('current_grid_id'));
|
17 |
+
} else {
|
18 |
+
$this->setId('skuChooserGrid_'.$this->getId());
|
19 |
+
}
|
20 |
+
|
21 |
+
$form = $this->getJsFormObject();
|
22 |
+
$this->setRowClickCallback("$form.chooserGridRowClick.bind($form)");
|
23 |
+
$this->setCheckboxCheckCallback("$form.chooserGridCheckboxCheck.bind($form)");
|
24 |
+
$this->setRowInitCallback("$form.chooserGridRowInit.bind($form)");
|
25 |
+
$this->setDefaultSort('sku');
|
26 |
+
$this->setUseAjax(true);
|
27 |
+
if ($this->getRequest()->getParam('collapse')) {
|
28 |
+
$this->setIsCollapsed(true);
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Retrieve quote store object
|
34 |
+
* @return Mage_Core_Model_Store
|
35 |
+
*/
|
36 |
+
public function getStore()
|
37 |
+
{
|
38 |
+
return Mage::app()->getStore();
|
39 |
+
}
|
40 |
+
|
41 |
+
protected function _addColumnFilterToCollection($column)
|
42 |
+
{
|
43 |
+
// Set custom filter for in product flag
|
44 |
+
if ($column->getId() == 'in_products') {
|
45 |
+
$selected = $this->_getSelectedProducts();
|
46 |
+
if (empty($selected)) {
|
47 |
+
$selected = '';
|
48 |
+
}
|
49 |
+
if ($column->getFilter()->getValue()) {
|
50 |
+
$this->getCollection()->addFieldToFilter('sku', array('in'=>$selected));
|
51 |
+
} else {
|
52 |
+
$this->getCollection()->addFieldToFilter('sku', array('nin'=>$selected));
|
53 |
+
}
|
54 |
+
} else {
|
55 |
+
parent::_addColumnFilterToCollection($column);
|
56 |
+
}
|
57 |
+
return $this;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Prepare Catalog Product Collection for attribute SKU in Promo Conditions SKU chooser
|
62 |
+
*
|
63 |
+
* @return Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku
|
64 |
+
*/
|
65 |
+
protected function _prepareCollection()
|
66 |
+
{
|
67 |
+
$store_id = Mage::app()->getRequest()->getParam('store',0);
|
68 |
+
$collection = Mage::getResourceModel('catalog/product_collection')
|
69 |
+
//->setStoreId(0)
|
70 |
+
->setStoreId($store_id)
|
71 |
+
->addStoreFilter()
|
72 |
+
->addAttributeToSelect('name', 'type_id', 'attribute_set_id');
|
73 |
+
|
74 |
+
$this->setCollection($collection);
|
75 |
+
|
76 |
+
return parent::_prepareCollection();
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Define Cooser Grid Columns and filters
|
81 |
+
*
|
82 |
+
* @return Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku
|
83 |
+
*/
|
84 |
+
protected function _prepareColumns()
|
85 |
+
{
|
86 |
+
$this->addColumn('in_products', array(
|
87 |
+
'header_css_class' => 'a-center',
|
88 |
+
'type' => 'checkbox',
|
89 |
+
'name' => 'in_products',
|
90 |
+
'values' => $this->_getSelectedProducts(),
|
91 |
+
'align' => 'center',
|
92 |
+
'index' => 'sku',
|
93 |
+
'use_index' => true,
|
94 |
+
));
|
95 |
+
|
96 |
+
$this->addColumn('entity_id', array(
|
97 |
+
'header' => Mage::helper('sales')->__('ID'),
|
98 |
+
'sortable' => true,
|
99 |
+
'width' => '60px',
|
100 |
+
'index' => 'entity_id'
|
101 |
+
));
|
102 |
+
|
103 |
+
$this->addColumn('type',
|
104 |
+
array(
|
105 |
+
'header'=> Mage::helper('catalog')->__('Type'),
|
106 |
+
'width' => '60px',
|
107 |
+
'index' => 'type_id',
|
108 |
+
'type' => 'options',
|
109 |
+
'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
|
110 |
+
));
|
111 |
+
|
112 |
+
$sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
|
113 |
+
->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
|
114 |
+
->load()
|
115 |
+
->toOptionHash();
|
116 |
+
|
117 |
+
$this->addColumn('set_name',
|
118 |
+
array(
|
119 |
+
'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
|
120 |
+
'width' => '100px',
|
121 |
+
'index' => 'attribute_set_id',
|
122 |
+
'type' => 'options',
|
123 |
+
'options' => $sets,
|
124 |
+
));
|
125 |
+
|
126 |
+
$this->addColumn('chooser_sku', array(
|
127 |
+
'header' => Mage::helper('sales')->__('SKU'),
|
128 |
+
'name' => 'chooser_sku',
|
129 |
+
'width' => '80px',
|
130 |
+
'index' => 'sku'
|
131 |
+
));
|
132 |
+
$this->addColumn('chooser_name', array(
|
133 |
+
'header' => Mage::helper('sales')->__('Product Name'),
|
134 |
+
'name' => 'chooser_name',
|
135 |
+
'index' => 'name'
|
136 |
+
));
|
137 |
+
|
138 |
+
return parent::_prepareColumns();
|
139 |
+
}
|
140 |
+
|
141 |
+
public function getGridUrl()
|
142 |
+
{
|
143 |
+
return $this->getUrl('*/*/chooser', array(
|
144 |
+
'_current' => true,
|
145 |
+
'current_grid_id' => $this->getId(),
|
146 |
+
'collapse' => null
|
147 |
+
));
|
148 |
+
}
|
149 |
+
|
150 |
+
protected function _getSelectedProducts()
|
151 |
+
{
|
152 |
+
$products = $this->getRequest()->getPost('selected', array());
|
153 |
+
|
154 |
+
return $products;
|
155 |
+
}
|
156 |
+
|
157 |
+
}
|
158 |
+
|
app/code/community/CapacityWebSolutions/Mostviewed/Block/Widget.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/***************************************************************************
|
3 |
+
Extension Name : Mostviewed Products
|
4 |
+
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
5 |
+
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
6 |
+
Support Email : support@magebees.com
|
7 |
+
***************************************************************************/
|
8 |
+
class CapacityWebSolutions_Mostviewed_Block_Widget extends CapacityWebSolutions_Mostviewed_Block_Mostviewed // Mage_Core_Block_Template
|
9 |
+
implements Mage_Widget_Block_Interface
|
10 |
+
{
|
11 |
+
public function addData(array $arr){
|
12 |
+
$this->_data = array_merge($this->_data, $arr);
|
13 |
+
}
|
14 |
+
|
15 |
+
public function setData($key, $value = null){
|
16 |
+
$this->_data[$key] = $value;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function _toHtml(){
|
20 |
+
if($this->getData('template')){
|
21 |
+
$this->setTemplate($this->getData('template'));
|
22 |
+
}
|
23 |
+
return parent::_toHtml();
|
24 |
+
}
|
25 |
+
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Block/Widget/Html/Pager.php
ADDED
@@ -0,0 +1,273 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/***************************************************************************
|
3 |
+
Extension Name : Mostviewed Products
|
4 |
+
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
5 |
+
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
6 |
+
Support Email : support@magebees.com
|
7 |
+
***************************************************************************/
|
8 |
+
class CapacityWebSolutions_Mostviewed_Block_Widget_Html_Pager extends Mage_Page_Block_Html_Pager
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Collection size
|
12 |
+
*
|
13 |
+
* Size of collection which may has a manual limitation
|
14 |
+
*
|
15 |
+
* @var int
|
16 |
+
*/
|
17 |
+
protected $_collectionSize;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Current page
|
21 |
+
*
|
22 |
+
* @var int
|
23 |
+
*/
|
24 |
+
protected $_currentPage;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Last page
|
28 |
+
*
|
29 |
+
* @var int
|
30 |
+
*/
|
31 |
+
protected $_lastPage;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Return collection size
|
35 |
+
*
|
36 |
+
* It may be limited by manual
|
37 |
+
*
|
38 |
+
* @return int
|
39 |
+
*/
|
40 |
+
public function getCollectionSize()
|
41 |
+
{
|
42 |
+
if (null === $this->_collectionSize) {
|
43 |
+
$this->_collectionSize = $this->getCollection()->getSize();
|
44 |
+
if ($this->getTotalLimit() && $this->_collectionSize > $this->getTotalLimit()) {
|
45 |
+
$this->_collectionSize = $this->getTotalLimit();
|
46 |
+
}
|
47 |
+
}
|
48 |
+
return $this->_collectionSize;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Return number of current page
|
53 |
+
*
|
54 |
+
* If current page is grate then total count of page current page will be equals total count of page
|
55 |
+
*
|
56 |
+
* @return int
|
57 |
+
*/
|
58 |
+
public function getCurrentPage()
|
59 |
+
{
|
60 |
+
if (null === $this->_currentPage) {
|
61 |
+
$page = abs((int)$this->getRequest()->getParam($this->getPageVarName()));
|
62 |
+
if ($page > $this->getLastPageNum()) {
|
63 |
+
$this->_currentPage = $this->getLastPageNum();
|
64 |
+
} elseif ($page > 0) {
|
65 |
+
$this->_currentPage = $page;
|
66 |
+
} else {
|
67 |
+
$this->_currentPage = 1;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
return $this->_currentPage;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Return items count per page
|
75 |
+
*
|
76 |
+
* @return int
|
77 |
+
*/
|
78 |
+
public function getLimit()
|
79 |
+
{
|
80 |
+
if ($this->_limit > 0) {
|
81 |
+
return $this->_limit;
|
82 |
+
}
|
83 |
+
$limit = $this->getRequest()->getParam($this->getLimitVarName());
|
84 |
+
$limits = $this->getAvailableLimit();
|
85 |
+
if ($limit && isset($limits[$limit])) {
|
86 |
+
return $limit;
|
87 |
+
}
|
88 |
+
$limits = array_keys($limits);
|
89 |
+
return current($limits);
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Connect collection to paging
|
94 |
+
*
|
95 |
+
* @param Mage_Core_Model_Resource_Db_Collection_Abstract $collection
|
96 |
+
* @return Mage_Catalog_Block_Product_Widget_Html_Pager
|
97 |
+
*/
|
98 |
+
public function setCollection($collection)
|
99 |
+
{
|
100 |
+
$this->_collection = $collection;
|
101 |
+
$this->_collection->setPageSize(null)->setCurPage(null);
|
102 |
+
|
103 |
+
$collectionOffset = $this->getFirstNum() - 1;
|
104 |
+
$collectionLimit = $collectionOffset + $this->getLimit() > $this->getTotalNum()
|
105 |
+
? $this->getTotalNum() - $collectionOffset
|
106 |
+
: $this->getLimit();
|
107 |
+
|
108 |
+
$this->_collection->getSelect()->limit($collectionLimit, $collectionOffset);
|
109 |
+
$this->_setFrameInitialized(false);
|
110 |
+
return $this;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Return position number in collection for first item on current page
|
115 |
+
*
|
116 |
+
* @return int
|
117 |
+
*/
|
118 |
+
public function getFirstNum()
|
119 |
+
{
|
120 |
+
return $this->getLimit() * ($this->getCurrentPage() - 1) + 1;
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Return position number in collection for last item on current page
|
125 |
+
*
|
126 |
+
* @return int
|
127 |
+
*/
|
128 |
+
public function getLastNum()
|
129 |
+
{
|
130 |
+
$collection = $this->getCollection();
|
131 |
+
return $this->getLimit() * ($this->getCurrentPage() - 1) + $collection->count();
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Return total number of collection
|
136 |
+
*
|
137 |
+
* It may be limited by manual
|
138 |
+
*
|
139 |
+
* @return int
|
140 |
+
*/
|
141 |
+
public function getTotalNum()
|
142 |
+
{
|
143 |
+
return $this->getCollectionSize();
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Return number of last page
|
148 |
+
*
|
149 |
+
* @return bool
|
150 |
+
*/
|
151 |
+
public function getLastPageNum()
|
152 |
+
{
|
153 |
+
if (null === $this->_lastPage) {
|
154 |
+
$this->_lastPage = ceil($this->getCollectionSize() / $this->getLimit());
|
155 |
+
if ($this->_lastPage <= 0) {
|
156 |
+
$this->_lastPage = 1;
|
157 |
+
}
|
158 |
+
}
|
159 |
+
return $this->_lastPage;
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Checks if current page is the first page
|
164 |
+
*
|
165 |
+
* @return bool
|
166 |
+
*/
|
167 |
+
public function isFirstPage()
|
168 |
+
{
|
169 |
+
return $this->getCurrentPage() == 1;
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Checks if current page is the last page
|
174 |
+
*
|
175 |
+
* @return bool
|
176 |
+
*/
|
177 |
+
public function isLastPage()
|
178 |
+
{
|
179 |
+
return $this->getCurrentPage() >= $this->getLastPageNum();
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Return array of pages
|
184 |
+
*
|
185 |
+
* @return array
|
186 |
+
*/
|
187 |
+
public function getPages()
|
188 |
+
{
|
189 |
+
$pages = array();
|
190 |
+
if ($this->getLastPageNum() <= $this->_displayPages) {
|
191 |
+
$pages = range(1, $this->getLastPageNum());
|
192 |
+
} else {
|
193 |
+
$half = ceil($this->_displayPages / 2);
|
194 |
+
if ($this->getCurrentPage() >= $half && $this->getCurrentPage() <= $this->getLastPageNum() - $half) {
|
195 |
+
$start = ($this->getCurrentPage() - $half) + 1;
|
196 |
+
$finish = ($start + $this->_displayPages) - 1;
|
197 |
+
} elseif ($this->getCurrentPage() < $half) {
|
198 |
+
$start = 1;
|
199 |
+
$finish = $this->_displayPages;
|
200 |
+
} elseif ($this->getCurrentPage() > ($this->getLastPageNum() - $half)) {
|
201 |
+
$finish = $this->getLastPageNum();
|
202 |
+
$start = $finish - $this->_displayPages + 1;
|
203 |
+
}
|
204 |
+
$pages = range($start, $finish);
|
205 |
+
}
|
206 |
+
return $pages;
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Retrieve url for previous page
|
211 |
+
*
|
212 |
+
* @return string
|
213 |
+
*/
|
214 |
+
public function getPreviousPageUrl()
|
215 |
+
{
|
216 |
+
return $this->getPageUrl($this->getCurrentPage() - 1);
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Retrieve url for next page
|
221 |
+
*
|
222 |
+
* @return string
|
223 |
+
*/
|
224 |
+
public function getNextPageUrl()
|
225 |
+
{
|
226 |
+
return $this->getPageUrl($this->getCurrentPage() + 1);
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Retrieve url for last page
|
231 |
+
*
|
232 |
+
* @return string
|
233 |
+
*/
|
234 |
+
public function getLastPageUrl()
|
235 |
+
{
|
236 |
+
return $this->getPageUrl($this->getLastPageNum());
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Initialize frame data, such as frame start, frame start etc.
|
241 |
+
*
|
242 |
+
* @return Mage_Catalog_Block_Product_Widget_Html_Pager
|
243 |
+
*/
|
244 |
+
protected function _initFrame()
|
245 |
+
{
|
246 |
+
if (!$this->isFrameInitialized()) {
|
247 |
+
$start = 0;
|
248 |
+
$end = 0;
|
249 |
+
|
250 |
+
if ($this->getLastPageNum() <= $this->getFrameLength()) {
|
251 |
+
$start = 1;
|
252 |
+
$end = $this->getLastPageNum();
|
253 |
+
} else {
|
254 |
+
$half = ceil($this->getFrameLength() / 2);
|
255 |
+
if ($this->getCurrentPage() >= $half && $this->getCurrentPage() <= $this->getLastPageNum() - $half) {
|
256 |
+
$start = ($this->getCurrentPage() - $half) + 1;
|
257 |
+
$end = ($start + $this->getFrameLength()) - 1;
|
258 |
+
} elseif ($this->getCurrentPage() < $half) {
|
259 |
+
$start = 1;
|
260 |
+
$end = $this->getFrameLength();
|
261 |
+
} elseif ($this->getCurrentPage() > ($this->getLastPageNum() - $half)) {
|
262 |
+
$end = $this->getLastPageNum();
|
263 |
+
$start = $end - $this->getFrameLength() + 1;
|
264 |
+
}
|
265 |
+
}
|
266 |
+
$this->_frameStart = $start;
|
267 |
+
$this->_frameEnd = $end;
|
268 |
+
$this->_setFrameInitialized(true);
|
269 |
+
}
|
270 |
+
|
271 |
+
return $this;
|
272 |
+
}
|
273 |
+
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Helper/Data.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/***************************************************************************
|
3 |
+
Extension Name : Mostviewed Products
|
4 |
+
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
5 |
+
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
6 |
+
Support Email : support@magebees.com
|
7 |
+
***************************************************************************/
|
8 |
+
class CapacityWebSolutions_Mostviewed_Helper_Data extends Mage_Core_Helper_Abstract
|
9 |
+
{
|
10 |
+
public function getStoreViewIds(){
|
11 |
+
$allStores = Mage::app()->getStores();
|
12 |
+
foreach ($allStores as $_eachStoreId => $val){
|
13 |
+
$store_ids[] = Mage::app()->getStore($_eachStoreId)->getId();
|
14 |
+
}
|
15 |
+
return $store_ids;
|
16 |
+
}
|
17 |
+
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Model/Mostviewed.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/***************************************************************************
|
3 |
+
Extension Name : Mostviewed Products
|
4 |
+
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
5 |
+
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
6 |
+
Support Email : support@magebees.com
|
7 |
+
***************************************************************************/
|
8 |
+
class CapacityWebSolutions_Mostviewed_Model_Mostviewed extends Mage_Core_Model_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->_init('mostviewed/mostviewed');
|
14 |
+
}
|
15 |
+
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Model/Mysql4/Mostviewed.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/***************************************************************************
|
3 |
+
Extension Name : Mostviewed Products
|
4 |
+
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
5 |
+
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
6 |
+
Support Email : support@magebees.com
|
7 |
+
***************************************************************************/
|
8 |
+
class CapacityWebSolutions_Mostviewed_Model_Mysql4_Mostviewed extends Mage_Core_Model_Mysql4_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
$this->_init('mostviewed/mostviewed', 'mostviewed_id');
|
13 |
+
}
|
14 |
+
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Model/Mysql4/Mostviewed/Collection.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/***************************************************************************
|
3 |
+
Extension Name : Mostviewed Products
|
4 |
+
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
5 |
+
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
6 |
+
Support Email : support@magebees.com
|
7 |
+
***************************************************************************/
|
8 |
+
class CapacityWebSolutions_Mostviewed_Model_Mysql4_Mostviewed_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->_init('mostviewed/mostviewed');
|
14 |
+
}
|
15 |
+
|
16 |
+
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Category.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/***************************************************************************
|
3 |
+
Extension Name : Mostviewed Products
|
4 |
+
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
5 |
+
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
6 |
+
Support Email : support@magebees.com
|
7 |
+
***************************************************************************/
|
8 |
+
class CapacityWebSolutions_Mostviewed_Model_System_Config_Source_Category
|
9 |
+
{
|
10 |
+
public function buildCategoriesMultiselectValues(Varien_Data_Tree_Node $node, $values, $level = 0)
|
11 |
+
{
|
12 |
+
$nonEscapableNbspChar = html_entity_decode(' ', ENT_NOQUOTES, 'UTF-8');
|
13 |
+
|
14 |
+
$level++;
|
15 |
+
if ($level > 2) {
|
16 |
+
$values[$node->getId()]['value'] = $node->getId();
|
17 |
+
$values[$node->getId()]['label'] = str_repeat($nonEscapableNbspChar, ($level - 3) * 5).$node->getName();
|
18 |
+
}
|
19 |
+
|
20 |
+
foreach ($node->getChildren() as $child) {
|
21 |
+
$values = $this->buildCategoriesMultiselectValues($child, $values, $level);
|
22 |
+
}
|
23 |
+
|
24 |
+
return $values;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function toOptionArray()
|
28 |
+
{
|
29 |
+
$tree = Mage::getResourceSingleton('catalog/category_tree')->load();
|
30 |
+
|
31 |
+
$parentId = 1;
|
32 |
+
|
33 |
+
$root = $tree->getNodeById($parentId);
|
34 |
+
|
35 |
+
if($root && $root->getId() == 1) {
|
36 |
+
$root->setName(Mage::helper('catalog')->__('Root'));
|
37 |
+
}
|
38 |
+
|
39 |
+
$storeCode = Mage::app()->getRequest()->getParam('store',0);
|
40 |
+
$store_id = Mage::getModel('core/store')->load($storeCode, 'code')->getId();
|
41 |
+
|
42 |
+
$rootCategoryId = Mage::app()->getStore($store_id)->getRootCategoryId();
|
43 |
+
|
44 |
+
$category_model = Mage::getModel('catalog/category'); //get category model
|
45 |
+
$_category = $category_model->load($rootCategoryId );
|
46 |
+
$all_child_categories = $category_model->getResource()->getAllChildren($_category);
|
47 |
+
|
48 |
+
$collection = Mage::getModel('catalog/category')->getCollection()
|
49 |
+
->addAttributeToSelect('name')
|
50 |
+
->addAttributeToSelect('is_active');
|
51 |
+
|
52 |
+
if($storeCode){
|
53 |
+
$collection->addFieldToFilter('entity_id', array(array('in'=> $all_child_categories)));
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
$tree->addCollectionData($collection, true);
|
58 |
+
|
59 |
+
$values['---'] = array(
|
60 |
+
'value' => '',
|
61 |
+
'label' => '',
|
62 |
+
);
|
63 |
+
return $this->buildCategoriesMultiselectValues($root, $values);
|
64 |
+
}
|
65 |
+
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Chooseproducts.php
ADDED
@@ -0,0 +1 @@
|
|
|
|
0 |
Extension Name : Mostviewed Products
|
1 |
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
2 |
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
3 |
Support Email : support@magebees.com
|
4 |
***************************************************************************/
|
5 |
{
|
6 |
}
|
1 |
+
<?php
|
2 |
Extension Name : Mostviewed Products
|
3 |
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
4 |
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
5 |
Support Email : support@magebees.com
|
6 |
***************************************************************************/
|
7 |
{
|
8 |
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Choosetype.php
ADDED
@@ -0,0 +1 @@
|
|
|
|
0 |
Extension Name : Mostviewed Products
|
1 |
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
2 |
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
3 |
Support Email : support@magebees.com
|
4 |
***************************************************************************/
|
5 |
{
|
6 |
}
|
1 |
+
<?php
|
2 |
Extension Name : Mostviewed Products
|
3 |
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
4 |
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
5 |
Support Email : support@magebees.com
|
6 |
***************************************************************************/
|
7 |
{
|
8 |
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Sortby.php
ADDED
@@ -0,0 +1 @@
|
|
|
|
0 |
Extension Name : Mostviewed Products
|
1 |
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
2 |
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
3 |
Support Email : support@magebees.com
|
4 |
***************************************************************************/
|
5 |
{
|
6 |
}
|
1 |
+
<?php
|
2 |
Extension Name : Mostviewed Products
|
3 |
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
4 |
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
5 |
Support Email : support@magebees.com
|
6 |
***************************************************************************/
|
7 |
{
|
8 |
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Sortorder.php
ADDED
@@ -0,0 +1 @@
|
|
|
|
0 |
Extension Name : Mostviewed Products
|
1 |
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
2 |
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
3 |
Support Email : support@magebees.com
|
4 |
***************************************************************************/
|
5 |
{
|
6 |
}
|
1 |
+
<?php
|
2 |
Extension Name : Mostviewed Products
|
3 |
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
4 |
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
5 |
Support Email : support@magebees.com
|
6 |
***************************************************************************/
|
7 |
{
|
8 |
}
|
app/code/community/CapacityWebSolutions/Mostviewed/Model/System/Config/Source/Template.php
ADDED
@@ -0,0 +1 @@
|
|
|
|
0 |
Extension Name : Mostviewed Products
|
1 |
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
2 |
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
3 |
Support Email : support@magebees.com
|
4 |
***************************************************************************/
|
5 |
{
|
6 |
}
|
1 |
+
<?php
|
2 |
Extension Name : Mostviewed Products
|
3 |
Extension URL : http://www.magebees.com/magento-mostviewed-products-extension.html
|
4 |
Copyright : Copyright (c) 2015 MageBees, http://www.magebees.com
|
5 |
Support Email : support@magebees.com
|
6 |
***************************************************************************/
|
7 |
{
|
8 |
}
|
app/code/community/CapacityWebSolutions/Mostviewed/controllers/Adminhtml/MostviewedController.php
ADDED
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|