dzinehub_best_sellers_v1 - Version 1.0.0.1

Version Notes

Tested to work with magento v1.9, v 1.8, v1.7, v1.6 and v1.5

Download this release

Release Info

Developer Arun
Extension dzinehub_best_sellers_v1
Version 1.0.0.1
Comparing to
See all releases


Version 1.0.0.1

app/code/community/Dzinehub/Bestseller/Block/Product/Bestsellers.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Dynamic Bestseller Products.
4
+ @Version : 1.0.0.1
5
+ @package : Dzinehub_Bestseller
6
+ @class : app/code/community/Dzinehub/Bestseller/Block/Product/Bestsellers.php
7
+ @author : arun@dzine-hub.com
8
+ @support : http://www.dzine-hub.com/contact-us/
9
+ ***************************************************************************/
10
+
11
+ class Dzinehub_Bestseller_Block_Product_Bestsellers extends Mage_Catalog_Block_Product_Abstract
12
+ {
13
+ function getBestsellerProduct()
14
+ {
15
+ $extensionenableflag = Mage::getStoreConfig('dzinehub_bestseller/general/active',Mage::app()->getStore());
16
+ if($extensionenableflag==1)
17
+ {
18
+ $productCount = 50; // Cache
19
+ $storeId = Mage::app()->getStore()->getId();
20
+
21
+ /****** Get the list of best selling product ******/
22
+
23
+ $_productCollection = Mage::getResourceModel('reports/product_collection')
24
+ ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
25
+ ->addAttributeToSelect('image')
26
+ ->addAttributeToSelect('name')
27
+ ->addAttributeToSelect('url')
28
+ ->addAttributeToSelect('price')
29
+ ->setPageSize($productCount)
30
+ ->addOrderedQty()
31
+ ->setOrder('ordered_qty', 'desc');
32
+
33
+ return $_productCollection;
34
+ }
35
+ }
36
+ }
app/code/community/Dzinehub/Bestseller/Model/System/Config/Source/Enabledisable.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ class Dzinehub_Catalog_Model_System_Config_Source_Enabledisable
29
+ {
30
+ public function toOptionArray()
31
+ {
32
+ return array(
33
+ array('value'=>'enable', 'label'=>Mage::helper('adminhtml')->__('Enable')),
34
+ array('value'=>'disable', 'label'=>Mage::helper('adminhtml')->__('Disable')),
35
+ );
36
+ }
37
+ }
app/code/community/Dzinehub/Bestseller/Model/System/Config/Source/Yesno.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Used in creating options for Yes|No config value selection
29
+ *
30
+ */
31
+ class Mage_Adminhtml_Model_System_Config_Source_Yesno
32
+ {
33
+
34
+ /**
35
+ * Options getter
36
+ *
37
+ * @return array
38
+ */
39
+ public function toOptionArray()
40
+ {
41
+ return array(
42
+ array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Yes')),
43
+ array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('No')),
44
+ );
45
+ }
46
+
47
+ /**
48
+ * Get options in "key-value" format
49
+ *
50
+ * @return array
51
+ */
52
+ public function toArray()
53
+ {
54
+ return array(
55
+ 0 => Mage::helper('adminhtml')->__('No'),
56
+ 1 => Mage::helper('adminhtml')->__('Yes'),
57
+ );
58
+ }
59
+
60
+ }
app/code/community/Dzinehub/Bestseller/etc/adminhtml.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <dzinehub_bestseller>
12
+ <title>Dzinehub_Bestseller</title> <!-- Used in resources tree -->
13
+ </dzinehub_bestseller>
14
+ </children>
15
+ </config>
16
+ </children>
17
+ </system>
18
+ </children>
19
+ </admin>
20
+ </resources>
21
+ </acl>
22
+ </config>
app/code/community/Dzinehub/Bestseller/etc/config.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dzinehub_Bestseller>
5
+ <codePool>community</codePool>
6
+ <version>1.1.0</version>
7
+ </Dzinehub_Bestseller>
8
+ </modules>
9
+ <global>
10
+ <blocks>
11
+ <bestseller>
12
+ <!--<class>Dzinehub_Bestseller_Block</class>-->
13
+ <rewrite>
14
+ <product_bestsellers>Dzinehub_Bestseller_Block_Product_Bestsellers</product_bestsellers>
15
+ </rewrite>
16
+ </bestseller>
17
+ </blocks>
18
+ </global>
19
+ <frontend>
20
+ <layout>
21
+ <updates>
22
+ <Dzinehub_Bestseller>
23
+ <file>bestsellers.xml</file>
24
+ </Dzinehub_Bestseller>
25
+ </updates>
26
+ </layout>
27
+ </frontend>
28
+ </config>
app/code/community/Dzinehub/Bestseller/etc/system.xml ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <Dzine-Hub translate="label">
5
+ <!-- <label>Dzine-Hub</label>-->
6
+ <label><![CDATA[<div style="position: absolute;"><img id="dzinehub_extension" src="" alt="Dzine-Hub" border="0" /></div>&nbsp;<script>$('dzinehub_extension').src = SKIN_URL + "images/dzinehub/dzinehub.png";</script>]]></label>
7
+ <sort_order>150</sort_order>
8
+ </Dzine-Hub>
9
+ </tabs>
10
+ <sections>
11
+ <dzinehub_bestseller translate="label" module="adminhtml">
12
+ <label>Bestseller</label>
13
+ <tab>Dzine-Hub</tab>
14
+ <sort_order>10</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
+ <general translate="label comment">
20
+ <label>General</label>
21
+ <sort_order>10</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ <comment><![CDATA[<a href="http://www.dzine-hub.com/" target="_blank">Click here for support.</a>]]></comment>
26
+ <fields>
27
+ <active translate="label comment">
28
+ <label>Enable/Disable</label>
29
+ <frontend_type>select</frontend_type>
30
+ <sort_order>1</sort_order>
31
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
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
+ </active>
36
+ <titleyesno translate="label comment">
37
+ <label>Section Title</label>
38
+ <frontend_type>select</frontend_type>
39
+ <source_model>adminhtml/system_config_source_yesno</source_model>
40
+ <sort_order>2</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ </titleyesno>
45
+ <titletext translate="label comment">
46
+ <label>Title Text</label>
47
+ <frontend_type>text</frontend_type>
48
+ <sort_order>3</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>1</show_in_store>
52
+ <depends>
53
+ <titleyesno>1</titleyesno>
54
+ </depends>
55
+ </titletext>
56
+ <numberofitems translate="label comment">
57
+ <label>Number of items to display in frontend</label>
58
+ <comment>Default number of items to display in frontend is 4</comment>
59
+ <frontend_type>text</frontend_type>
60
+ <validate>validate-not-negative-number</validate>
61
+ <sort_order>4</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ </numberofitems>
66
+ <showproducttitle translate="label comment">
67
+ <label>Show Product Title</label>
68
+ <frontend_type>select</frontend_type>
69
+ <source_model>adminhtml/system_config_source_yesno</source_model>
70
+ <sort_order>5</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>1</show_in_store>
74
+ </showproducttitle>
75
+ <showproductprice translate="label comment">
76
+ <label>Show Product Price</label>
77
+ <frontend_type>select</frontend_type>
78
+ <source_model>adminhtml/system_config_source_yesno</source_model>
79
+ <sort_order>6</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>1</show_in_store>
83
+ </showproductprice>
84
+ <showproductviewlink translate="label comment">
85
+ <label>Show Product View Button</label>
86
+ <frontend_type>select</frontend_type>
87
+ <source_model>adminhtml/system_config_source_yesno</source_model>
88
+ <sort_order>7</sort_order>
89
+ <show_in_default>1</show_in_default>
90
+ <show_in_website>1</show_in_website>
91
+ <show_in_store>1</show_in_store>
92
+ </showproductviewlink>
93
+ </fields>
94
+ </general>
95
+ </groups>
96
+ </dzinehub_bestseller>
97
+ </sections>
98
+ </config>
app/design/frontend/base/default/layout/bestsellers.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <dzinehub_index_bestsellers>
4
+ <reference name="content">
5
+ <blocks>
6
+ <bestseller>
7
+ <class>Dzinehub_Bestseller_Block</class>
8
+ <rewrite>
9
+ <product_bestsellers>Dzinehub_Bestseller_Block_Product_Bestsellers</product_bestsellers>
10
+ </rewrite>
11
+ </bestseller>
12
+ </blocks>
13
+ <models>
14
+ <bestseller>
15
+ <class>Dzinehub_Bestseller_Model</class>
16
+ </bestseller>
17
+ </models>
18
+ </reference>
19
+ </dzinehub_index_bestsellers>
20
+ </layout>
app/design/frontend/base/default/template/dzinehub/bestsellers.phtml ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /***************************************************************************
3
+ @extension : Dynamic Bestseller Products.
4
+ @Version : 1.0.0.1
5
+ @package : Dzinehub_Bestseller
6
+ @class : app/code/community/Dzinehub/Bestseller/Block/Product/Bestsellers.php
7
+ @author : arun@dzine-hub.com
8
+ @support : http://www.dzine-hub.com/contact-us/
9
+ ***************************************************************************/
10
+
11
+ $extensionenableflag = Mage::getStoreConfig('dzinehub_bestseller/general/active',Mage::app()->getStore());
12
+ if($extensionenableflag == 1 )
13
+ {
14
+ $titleyesno = Mage::getStoreConfig('dzinehub_bestseller/general/titleyesno',Mage::app()->getStore());
15
+ if($titleyesno == 1)
16
+ {
17
+ $titletext = Mage::getStoreConfig('dzinehub_bestseller/general/titletext',Mage::app()->getStore());
18
+ }
19
+ $numberofitems = Mage::getStoreConfig('dzinehub_bestseller/general/numberofitems',Mage::app()->getStore());
20
+ if($numberofitems == "")
21
+ {
22
+ $numberofitems = 4;
23
+ }
24
+ $showproducttitle = Mage::getStoreConfig('dzinehub_bestseller/general/showproducttitle',Mage::app()->getStore());
25
+ $showproductprice = Mage::getStoreConfig('dzinehub_bestseller/general/showproductprice',Mage::app()->getStore());
26
+ $showproductviewlink = Mage::getStoreConfig('dzinehub_bestseller/general/showproductviewlink',Mage::app()->getStore());
27
+ $totalPerPage = $numberofitems; // Display
28
+ $counter = 1;
29
+
30
+ $_productCollection = $this->getBestsellerProduct();
31
+ $storeId = Mage::app()->getStore()->getId();
32
+ ?>
33
+ <?php
34
+ if($titletext <> "")
35
+ {
36
+ ?>
37
+ <h2 class="dzbestsellertitle"><?php echo $titletext; ?></h2>
38
+ <?php
39
+ }
40
+ ?>
41
+ <div class="dzbestseller" id="dzbestseller">
42
+ <ul class="dzbestseller">
43
+ <?php
44
+ foreach($_productCollection as $product)
45
+ {
46
+ $productTypecheck = "0";
47
+ $productentity = $product->entity_id;
48
+
49
+ $product_1=Mage::getModel('catalog/product')->load($productentity);
50
+ $productVisibileCheck = $product_1->visibility;
51
+ $productType=$product_1->getTypeID();
52
+
53
+ /****** Check Product Type - Simple/Configurable ******/
54
+
55
+ if($productType == 'simple' && ($productVisibileCheck == "2" || $productVisibileCheck == "4") && $product_1['stock_item']['is_in_stock'] == '1' && $product_1['status'] == "1")
56
+ {
57
+ $productTypecheck = "1";
58
+ }
59
+
60
+ /****** Check configurable product - Type/Visibile ******/
61
+
62
+ if($productType == 'configurable' && ($productVisibileCheck == "2" || $productVisibileCheck == "4"))
63
+ {
64
+ /****** Get the list of associated items of configurable product ******/
65
+
66
+ $configurable= Mage::getModel('catalog/product_type_configurable')->setProduct($product_1);
67
+ $simpleCollection = $configurable->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
68
+
69
+ /****** Check associated items of configurable product - Status/instock ******/
70
+
71
+ foreach($simpleCollection as $simpleProduct)
72
+ {
73
+ if($simpleProduct['status'] == "1" && $simpleProduct['stock_item']['is_in_stock'] == '1' )
74
+ {
75
+ $productTypecheck = "1";
76
+ }
77
+ }
78
+
79
+ }
80
+
81
+ /****** Display best selling product ******/
82
+ if($productTypecheck == "1")
83
+ {
84
+ if($counter <= $totalPerPage)
85
+ {
86
+ $productUrl = $product->getProductUrl() ?>
87
+ <li>
88
+ <img src="<?php echo $this->helper('catalog/image')->init($product, 'image')->resize(120); ?>" alt="Product image" />
89
+ <?php
90
+ if($showproducttitle == 1)
91
+ {?>
92
+ <a href="<?php echo $productUrl ?>" title="View <?php echo $product->name ?>">
93
+ <span><?php echo $product->name ?></span>
94
+ </a>
95
+ <?php
96
+ }
97
+ if($showproductprice == 1)
98
+ {?>
99
+ <?php echo $this->getPriceHtml($product, true, '') ?>
100
+ <?php
101
+ }
102
+ if($showproductviewlink == 1)
103
+ {?>
104
+ <a href="<?php echo $productUrl ?>" title="View <?php echo $product->name ?>">View
105
+ </a>
106
+ <?php /*echo (int)$product->ordered_qty;*/
107
+ }
108
+ ?>
109
+ </li>
110
+ <?php
111
+ $counter++;
112
+ }
113
+
114
+ }
115
+
116
+ } ?>
117
+ </ul>
118
+ </div>
119
+ <?php
120
+ if ($counter<=1)
121
+ {?>
122
+ <script type="text/javascript">
123
+ document.getElementById("dzdailydealmain").style.display="none";
124
+ </script>
125
+
126
+ <?php
127
+ }?>
128
+ <?php
129
+ }
130
+ ?>
app/etc/modules/Dzinehub_Bestseller.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dzinehub_Bestseller>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Dzinehub_Bestseller>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>dzinehub_best_sellers_v1</name>
4
+ <version>1.0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/gpl-license.php">GNU General Public License (GPL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>To display the list of best selling products in your Magento store homepage, product page or any other page on the website.</summary>
10
+ <description>Dynamically retrieved list of best selling products, sorted based on the number of items sold. Display this list of hot selling products on your website using our simple extension. For any support inquiries, contact us at www.dzine-hub.com/contact</description>
11
+ <notes>Tested to work with magento v1.9, v 1.8, v1.7, v1.6 and v1.5</notes>
12
+ <authors><author><name>Arun</name><user>Arun</user><email>arun@dzine-hub.com</email></author></authors>
13
+ <date>2015-03-12</date>
14
+ <time>08:08:40</time>
15
+ <contents><target name="magecommunity"><dir name="Dzinehub"><dir name="Bestseller"><dir><dir name="Block"><dir name="Product"><file name="Bestsellers.php" hash="39064f3d67406f4b292976bd62ba6aa6"/></dir></dir><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Enabledisable.php" hash="cc907542cfe11f4d5aa4fb537c3584e9"/><file name="Yesno.php" hash="b506c229f70bf2101f244e8191f9a3bd"/></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="ee3b113cd5af9aef4464f1ffeff28c54"/><file name="config.xml" hash="203e69c0cada6f517ecbd8ad8cd1708a"/><file name="system.xml" hash="a8d7c573be8bfb76a6d9b4d0c5804893"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="dzinehub"><file name="bestsellers.phtml" hash="2fdb55d8369ccadac82d32760a2517fd"/></dir></dir><dir name="layout"><file name="bestsellers.xml" hash="48cc42de01b9f114413504158e33783b"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Dzinehub_Bestseller.xml" hash="4aac8ed0547771e8e8033ab252ab48da"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="dzinehub"><file name="dzinehub.png" hash="1938212479ffe381cc68af0299d7d832"/></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.1</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/adminhtml/default/default/images/dzinehub/dzinehub.png ADDED
Binary file