Adodis_Bestsellers - Version 1.0.0

Version Notes

Best sellers can be fetched based on admin selection and sale of products,both can be either turned off or on

Download this release

Release Info

Developer Jextn Themes
Extension Adodis_Bestsellers
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/local/Adodis/Bestsellers/Block/Product/Bestsellers.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Adodis_Bestsellers_Block_Product_Bestsellers extends Mage_Catalog_Block_Product_Abstract
3
+ {
4
+
5
+ public $auto,$tot_prod;
6
+ public function __construct()
7
+ {
8
+ $auto=Mage::getStoreConfig("adodis_bestsellers/adodis_general/adodis_bestsellers_auto");
9
+ $tot_prod=Mage::getStoreConfig("adodis_bestsellers/adodis_general/adodis_bestsellers_totprod");
10
+ parent::__construct();
11
+ if($auto==1){
12
+ $storeId = Mage::app()->getStore()->getId();
13
+ $products = Mage::getResourceModel('reports/product_collection')
14
+ ->addOrderedQty()
15
+ ->addAttributeToSelect('*')
16
+ ->setStoreId($storeId)
17
+ ->addStoreFilter($storeId)
18
+ ->setOrder('ordered_qty', 'desc');
19
+
20
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
21
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
22
+
23
+ $products->setPageSize($tot_prod)->setCurPage(1);
24
+
25
+ $this->setProductCollection($products);
26
+ }
27
+ else{
28
+ $storeId = Mage::app()->getStore()->getId();
29
+ $product = Mage::getModel('catalog/product');
30
+ /* @var $product Mage_Catalog_Model_Product */
31
+ $todayDate = $product->getResource()->formatDate(time());
32
+ $products = $product->setStoreId($storeId)->getCollection()
33
+ ->addAttributeToSelect('status')
34
+ ->addAttributeToFilter('bestsellers', array('Yes'=>true))
35
+ ->addAttributeToSelect(array('name', 'price', 'small_image'), 'inner')
36
+ ->addAttributeToSelect(array('special_price', 'special_from_date', 'special_to_date'), 'left');
37
+ /* @var $products Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection */
38
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
39
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
40
+ $products->setOrder('hot_deals')->setPageSize($tot_prod)->setCurPage(1);
41
+ $this->setProductCollection($products);
42
+
43
+
44
+ }
45
+ }
46
+ }
app/code/local/Adodis/Bestsellers/Model/Adminhtml/System/Config/Source/Activate.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Adodis_Bestsellers_Model_Adminhtml_System_Config_Source_Activate
3
+ {
4
+
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Enable')),
9
+ array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('Disable')),
10
+ );
11
+ }
12
+
13
+ }
app/code/local/Adodis/Bestsellers/Model/Adminhtml/System/Config/Source/Auto.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Adodis_Bestsellers_Model_Adminhtml_System_Config_Source_Auto
3
+ {
4
+
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Enable')),
9
+ array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('Disable')),
10
+ );
11
+ }
12
+
13
+ }
app/code/local/Adodis/Bestsellers/Model/Adminhtml/System/Config/Source/Listview.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Adodis_Bestsellers_Model_Adminhtml_System_Config_Source_Listview
3
+ {
4
+
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Enable')),
9
+ array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('Disable')),
10
+ );
11
+ }
12
+
13
+ }
app/code/local/Adodis/Bestsellers/etc/config.xml ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Adodis_Bestsellers>
5
+ <version>1.0.1</version>
6
+ </Adodis_Bestsellers>
7
+ </modules>
8
+ <adminhtml>
9
+ <menu>
10
+ <bestsellers>
11
+ <title>Best sellers</title>
12
+ <sort_order>69</sort_order>
13
+ <children>
14
+ <items>
15
+ <title>Settings</title>
16
+ <sort_order>0</sort_order>
17
+ <action>adminhtml/system_config/edit/section/adodis_bestsellers/</action>
18
+ </items>
19
+ </children>
20
+ </bestsellers>
21
+ </menu>
22
+ <acl>
23
+ <resources>
24
+ <admin>
25
+ <children>
26
+ <system>
27
+ <children>
28
+ <config>
29
+ <children>
30
+ <adodis_bestsellers>
31
+ <title>Bestsellers</title>
32
+ </adodis_bestsellers>
33
+ </children>
34
+ </config>
35
+ </children>
36
+ </system>
37
+ </children>
38
+ </admin>
39
+ </resources>
40
+ </acl>
41
+ </adminhtml>
42
+ <global>
43
+ <models>
44
+ <bestsellers>
45
+ <class>Adodis_Bestsellers_Model</class>
46
+ </bestsellers>
47
+ </models>
48
+ <resources>
49
+ <bestsellers_setup>
50
+ <setup>
51
+ <module>Adodis_Bestsellers</module>
52
+ </setup>
53
+ <connection>
54
+ <use>core_setup</use>
55
+ </connection>
56
+ </bestsellers_setup>
57
+ <bestsellers_write>
58
+ <connection>
59
+ <use>core_write</use>
60
+ </connection>
61
+ </bestsellers_write>
62
+ <bestsellers_read>
63
+ <connection>
64
+ <use>core_read</use>
65
+ </connection>
66
+ </bestsellers_read>
67
+ </resources>
68
+ <blocks>
69
+ <catalog>
70
+ <rewrite>
71
+ <product_bestsellers>Adodis_Bestsellers_Block_Product_Bestsellers</product_bestsellers>
72
+ </rewrite>
73
+ </catalog>
74
+ </blocks>
75
+ </global>
76
+ <default>
77
+ <adodis_bestsellers>
78
+ <adodis_general>
79
+ <adodis_bestsellers_enable>1</adodis_bestsellers_enable>
80
+ <adodis_bestsellers_title>Best Sellers</adodis_bestsellers_title>
81
+ <adodis_bestsellers_auto>0</adodis_bestsellers_auto>
82
+ <adodis_bestsellers_totprod>4</adodis_bestsellers_totprod>
83
+ <adodis_bestsellers_prod_image_height>135</adodis_bestsellers_prod_image_height>
84
+ <adodis_bestsellers_prod_image_width>135</adodis_bestsellers_prod_image_width>
85
+ <adodis_bestsellers_list_enable>0</adodis_bestsellers_list_enable>
86
+ <adodis_bestsellers_column_count>4</adodis_bestsellers_column_count>
87
+ </adodis_general>
88
+ </adodis_bestsellers>
89
+ </default>
90
+ </config>
app/code/local/Adodis/Bestsellers/etc/system.xml ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <adodis translate="label">
5
+ <label>Adodis</label>
6
+ <sort_order>190</sort_order>
7
+ </adodis>
8
+ </tabs>
9
+ <sections>
10
+ <adodis_bestsellers>
11
+ <label>Best Seller</label>
12
+ <tab>adodis</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>220</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <adodis_general translate="label">
20
+ <label>General</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>10</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <adodis_bestsellers_enable>
28
+ <label>Activate Bestsellers</label>
29
+ <frontend_type>select</frontend_type>
30
+ <source_model>bestsellers/adminhtml_system_config_source_activate</source_model>
31
+ <sort_order>0</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </adodis_bestsellers_enable>
36
+ <adodis_bestsellers_title>
37
+ <label>Title</label>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>1</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ </adodis_bestsellers_title>
44
+ <adodis_bestsellers_auto>
45
+ <label>Activate Auto Fetch</label>
46
+ <frontend_type>select</frontend_type>
47
+ <source_model>bestsellers/adminhtml_system_config_source_auto</source_model>
48
+ <comment>If this is enabled product will be fetched based on order</comment>
49
+ <sort_order>2</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ </adodis_bestsellers_auto>
54
+ <adodis_bestsellers_totprod>
55
+ <label>Enter total Number Of Product To Display(Per Page)</label>
56
+ <frontend_type>text</frontend_type>
57
+ <sort_order>3</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
+ </adodis_bestsellers_totprod>
62
+ <adodis_bestsellers_prod_image_height>
63
+ <label>Enter Product Image Height</label>
64
+ <frontend_type>text</frontend_type>
65
+ <sort_order>4</sort_order>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>1</show_in_store>
69
+ </adodis_bestsellers_prod_image_height>
70
+ <adodis_bestsellers_prod_image_width>
71
+ <label>Enter Product Image width</label>
72
+ <frontend_type>text</frontend_type>
73
+ <sort_order>5</sort_order>
74
+ <show_in_default>1</show_in_default>
75
+ <show_in_website>1</show_in_website>
76
+ <show_in_store>1</show_in_store>
77
+ </adodis_bestsellers_prod_image_width>
78
+ <adodis_bestsellers_list_enable>
79
+ <label>List view</label>
80
+ <frontend_type>select</frontend_type>
81
+ <source_model>bestsellers/adminhtml_system_config_source_listview</source_model>
82
+ <sort_order>6</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>1</show_in_store>
86
+ </adodis_bestsellers_list_enable>
87
+ <adodis_bestsellers_column_count>
88
+ <label>Enter Column Count</label>
89
+ <frontend_type>text</frontend_type>
90
+ <sort_order>7</sort_order>
91
+ <show_in_default>1</show_in_default>
92
+ <show_in_website>1</show_in_website>
93
+ <show_in_store>1</show_in_store>
94
+ </adodis_bestsellers_column_count>
95
+ </fields>
96
+ </adodis_general>
97
+ </groups>
98
+ </adodis_bestsellers>
99
+ </sections>
100
+ </config>
app/code/local/Adodis/Bestsellers/sql/bestsellers_setup/mysql4-install-1.0.1.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = new Mage_Eav_Model_Entity_Setup('core_setup');;
4
+ $installer->startSetup();
5
+ $installer->addAttribute('catalog_product', 'bestsellers', array(
6
+ 'group' => 'General',
7
+ 'type' => 'int',
8
+ 'backend' => '',
9
+ 'frontend' => '',
10
+ 'label' => 'Best Seller',
11
+ 'input' => 'boolean',
12
+ 'class' => '',
13
+ 'source' => '',
14
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
15
+ 'visible' => true,
16
+ 'required' => false,
17
+ 'user_defined' => true,
18
+ 'default' => '0',
19
+ 'searchable' => false,
20
+ 'filterable' => false,
21
+ 'comparable' => false,
22
+ 'visible_on_front' => false,
23
+ 'unique' => false,
24
+ 'apply_to' => 'simple,configurable,virtual,bundle,downloadable',
25
+ 'is_configurable' => false
26
+ ));
27
+ $installer->endSetup();
app/design/frontend/default/default/template/catalog/product/bestsellers.phtml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* backend values */
3
+
4
+ $image_height=Mage::getStoreConfig("adodis_bestsellers/adodis_general/adodis_bestsellers_prod_image_height");
5
+ $image_width=Mage::getStoreConfig("adodis_bestsellers/adodis_general/adodis_bestsellers_prod_image_width");
6
+ $listview=Mage::getStoreConfig("adodis_bestsellers/adodis_general/adodis_bestsellers_list_enable");
7
+ $title=Mage::getStoreConfig("adodis_bestsellers/adodis_general/adodis_bestsellers_title");
8
+ $enabled=Mage::getStoreConfig("adodis_bestsellers/adodis_general/adodis_bestsellers_enable");
9
+ ?>
10
+ <?php if($enabled==1){?>
11
+ <h3 style="margin-top:10px;"><strong><span><?php echo $title; ?></span></strong></h3>
12
+ <?php if($listview==1){?>
13
+ <?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
14
+ <ol class="products-list" id="products-list">
15
+ <?php $i=0; foreach ($_products->getItems() as $_product): ?>
16
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
17
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($image_width,$image_height) ?>" width="<?php echo $image_width; ?>" height="<?php echo $image_height; ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /></a>
18
+ <div class="align-prodname-price-review">
19
+ <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></h3>
20
+ <?php echo $this->getPriceHtml($_product, true, '-new') ?>
21
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
22
+ </div>
23
+ <div class="actions">
24
+ <?php if($_product->isSaleable()): ?>
25
+ <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
26
+ <?php else: ?>
27
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
28
+ <?php endif; ?>
29
+ </div>
30
+ </li>
31
+ <?php endforeach; ?>
32
+ </ol>
33
+ <?php endif; ?>
34
+ <?php } else { ?>
35
+ <?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
36
+ <?php $colcount=Mage::getStoreConfig("adodis_bestsellers/adodis_general/adodis_bestsellers_column_count"); ?>
37
+ <?php $_columnCount = $colcount; ?>
38
+ <?php $i=0; foreach ($_products->getItems() as $_product): ?>
39
+ <?php if ($i++%$_columnCount==0 ): ?>
40
+ <ul class="products-grid">
41
+ <?php endif ;?>
42
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
43
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($image_width,$image_height) ?>" width="<?php echo $image_width; ?>" height="<?php echo $image_height; ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /></a>
44
+ <div class="align-prodname-price-review">
45
+ <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></h3>
46
+ <?php echo $this->getPriceHtml($_product, true, '-new') ?>
47
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
48
+ </div>
49
+ <div class="actions">
50
+ <?php if($_product->isSaleable()): ?>
51
+ <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
52
+ <?php else: ?>
53
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
54
+ <?php endif; ?>
55
+ </div>
56
+ </li>
57
+ <?php if ($i%$_columnCount==0 || $i==count($_products)): ?>
58
+ </ul>
59
+ <?php endif ?>
60
+ <?php endforeach; ?>
61
+ <?php endif; ?>
62
+ <?php } ?>
63
+ <?php } ?>
app/etc/modules/Adodis_Bestsellers.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Adodis_Bestsellers>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Adodis_Bestsellers>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Adodis_Bestsellers</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>First release of bestsellers extension</summary>
10
+ <description>Best sellers can be fetched based on admin selection and sale of products,both can be either turned off or on</description>
11
+ <notes>Best sellers can be fetched based on admin selection and sale of products,both can be either turned off or on</notes>
12
+ <authors><author><name>Jextn Themes</name><user>adodistheme</user><email>magento-support@jextn.com</email></author></authors>
13
+ <date>2012-03-16</date>
14
+ <time>13:04:02</time>
15
+ <contents><target name="magelocal"><dir><dir name="Adodis"><dir name="Bestsellers"><dir name="Block"><dir name="Product"><file name="Bestsellers.php" hash="1dd5f7d63bc808249748f744b4c90a63"/></dir></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><file name="Activate.php" hash="3955ab83428038014361b49f536bd5b0"/><file name="Auto.php" hash="1511c318d235da3971e7fa5f0f1df0ab"/><file name="Listview.php" hash="0928d90be01be312e71b98008c5f5eac"/></dir></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="327d0079c6d4f172f1554417ff3aa138"/><file name="system.xml" hash="3931c482a80873e8dc013008a3f61810"/></dir><dir name="sql"><dir name="bestsellers_setup"><file name="mysql4-install-1.0.1.php" hash="ab854e4274b9bb60e87c6d87833ba529"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Adodis_Bestsellers.xml" hash="e275792d63fceb18fff4fbc81a6addd3"/></dir></dir></target><target name="magedesign"><dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="catalog"><dir name="product"><file name="bestsellers.phtml" hash="406201eaa4780aeff23efce5c8cd1d69"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.5.0</min><max>1.6.2</max></package></required></dependencies>
18
+ </package>