Bestseller_products - Version 0.1.0

Version Notes

Best Seller products

Download this release

Release Info

Developer Magento Core Team
Extension Bestseller_products
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/community/CapacityWebSolutions/Bestseller/Block/Bestseller.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2010 Capacity Web Solutions Pvt. Ltd (http://www.capacitywebsolutions.com)
4
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
5
+ */
6
+ ?>
7
+ <?php
8
+
9
+ class CapacityWebSolutions_Bestseller_Block_Bestseller extends Mage_Catalog_Block_Product_Abstract // Mage_Core_Block_Template
10
+ {
11
+
12
+
13
+ public function __construct()
14
+ {
15
+ $this->setHeader(Mage::getStoreConfig("bestseller/general/heading"));
16
+ $this->setLimit((int)Mage::getStoreConfig("bestseller/general/number_of_items"));
17
+ $this->setItemsPerRow((int)Mage::getStoreConfig("bestseller/general/number_of_items_per_row"));
18
+ $this->setStoreId(Mage::app()->getStore()->getId());
19
+ $this->setImageHeight((int)Mage::getStoreConfig("bestseller/general/thumbnail_height"));
20
+ $this->setImageWidth((int)Mage::getStoreConfig("bestseller/general/thumbnail_width"));
21
+ }
22
+ function getBestsellerProduct()
23
+ {
24
+
25
+ $collection = Mage::getModel('sales/order_item')->getCollection()->addFieldToFilter("store_id",array("eq"=>$this->getStoreId())) ->setOrder('qty_ordered', 'desc')->setPageSize(($this->getLimit()) ? $this->getLimit() : 4)->getData();
26
+
27
+ return $collection;
28
+
29
+ }
30
+ }
31
+
32
+
33
+
34
+ ?>
app/code/community/CapacityWebSolutions/Bestseller/Helper/Data.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @copyright Copyright (c) 2010 Capacity Web Solutions Pvt. Ltd (http://www.capacitywebsolutions.com)
5
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
6
+ */
7
+
8
+ class CapacityWebSolutions_Bestseller_Helper_Data extends Mage_Core_Helper_Abstract
9
+ {
10
+ }
app/code/community/CapacityWebSolutions/Bestseller/controllers/IndexController.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2010 Capacity Web Solutions Pvt. Ltd (http://www.capacitywebsolutions.com)
4
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
5
+ */
6
+ ?>
7
+ <?php
8
+
9
+ class CapacityWebSolutions_Bestseller_IndexController extends Mage_Core_Controller_Front_Action
10
+ {
11
+ public function indexAction()
12
+ {
13
+ $this->loadLayout(array('default'));
14
+ $this->renderLayout();
15
+ }
16
+ }
17
+
18
+
19
+ ?>
app/code/community/CapacityWebSolutions/Bestseller/etc/config.xml ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @copyright Copyright (c) 2010 Capacity Web Solutions Pvt. Ltd (http://www.capacitywebsolutions.com)
5
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
6
+ */
7
+ -->
8
+ <config>
9
+ <global>
10
+ <modules>
11
+ <CapacityWebSolutions_Bestseller>
12
+ <version>0.1.0</version>
13
+ </CapacityWebSolutions_Bestseller>
14
+ </modules>
15
+ <blocks>
16
+ <bestseller>
17
+ <rewrite>
18
+ <bestseller>CapacityWebSolutions_Bestseller_Block_Bestseller</bestseller>
19
+ </rewrite>
20
+ </bestseller>
21
+ </blocks>
22
+
23
+ </global>
24
+ <frontend>
25
+ <routers>
26
+ <bestseller>
27
+ <use>standard</use>
28
+ <args>
29
+ <module>CapacityWebSolutions_Bestseller</module>
30
+ <frontName>bestseller</frontName>
31
+ </args>
32
+ </bestseller>
33
+ </routers>
34
+ <layout>
35
+ <updates>
36
+ <bestseller>
37
+ <file>bestseller.xml</file>
38
+ </bestseller>
39
+ </updates>
40
+ </layout>
41
+ </frontend>
42
+ <adminhtml>
43
+ <acl>
44
+ <resources>
45
+ <admin>
46
+ <children>
47
+ <system>
48
+ <children>
49
+ <config>
50
+ <children>
51
+ <bestseller>
52
+ <title>Bestseller Section</title>
53
+ </bestseller>
54
+ </children>
55
+ </config>
56
+ </children>
57
+ </system>
58
+ </children>
59
+ </admin>
60
+ </resources>
61
+ </acl>
62
+
63
+ </adminhtml>
64
+ </config>
app/code/community/CapacityWebSolutions/Bestseller/etc/system.xml ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @copyright Copyright (c) 2010 Capacity Web Solutions Pvt. Ltd (http://www.capacitywebsolutions.com)
5
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
6
+ */
7
+ -->
8
+ <config>
9
+
10
+ <tabs>
11
+ <bestseller>
12
+ <label>Capacity Web Solutions</label>
13
+ <sort_order>100</sort_order>
14
+ </bestseller>
15
+ </tabs>
16
+ <sections>
17
+ <bestseller translate="label">
18
+ <class>separator-top</class>
19
+ <label>Best Seller Products</label>
20
+ <tab>bestseller</tab>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>40</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
+ <groups>
27
+ <general translate="label">
28
+ <label>General</label>
29
+ <frontend_type>text</frontend_type>
30
+ <sort_order>100</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ <fields>
35
+ <heading translate="label">
36
+ <label>Heading</label>
37
+ <frontend_type>text</frontend_type>
38
+ <sort_order>0</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ </heading>
43
+
44
+ <number_of_items translate="label comment">
45
+ <label>Number Of Items in Main Block</label>
46
+ <comment>How many best seller products will be showed in main block?</comment>
47
+ <frontend_type>text</frontend_type>
48
+ <sort_order>1</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
+ </number_of_items>
53
+
54
+ <number_of_items_per_row translate="label comment">
55
+ <label>Number Of Items per row in Main Block</label>
56
+ <comment>How many best seller products will be showed per row?</comment>
57
+ <frontend_type>text</frontend_type>
58
+ <sort_order>2</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ </number_of_items_per_row>
63
+
64
+ <thumbnail_height translate="label">
65
+ <label>Thumbnail Height</label>
66
+ <frontend_type>text</frontend_type>
67
+ <sort_order>3</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ </thumbnail_height>
72
+
73
+ <thumbnail_width translate="label">
74
+ <label>Thumbnail Width</label>
75
+ <frontend_type>text</frontend_type>
76
+ <sort_order>4</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>1</show_in_store>
80
+ </thumbnail_width>
81
+ </fields>
82
+ </general>
83
+ </groups>
84
+ </bestseller>
85
+ </sections>
86
+ </config>
app/design/frontend/default/default/template/bestseller/bestseller.phtml ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright Copyright (c) 2010 Capacity Web Solutions Pvt. Ltd (http://www.capacitywebsolutions.com)
4
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
5
+ */
6
+ ?>
7
+ <?php
8
+
9
+ $result = $this->getBestsellerProduct();
10
+ $itemPerRow = ($this->getItemsPerRow()) ? $this->getItemsPerRow() : 2 ;
11
+ //getting product model
12
+
13
+ $model = Mage::getModel('catalog/product');
14
+ ?>
15
+
16
+ <div class="sectionHead"><h2><?php echo $this->getHeader(); ?></h2></div>
17
+ <table border="0" cellpadding="0" cellspacing="0" class="productList">
18
+ <tr>
19
+ <?php $i=0;
20
+ for($cnt = 0; $cnt<count($result); $cnt++)
21
+ {
22
+
23
+ $_product = $model->load($result[$cnt]['product_id']); //getting product object for particular product id
24
+ if($i>($itemPerRow-1))
25
+ echo '<tr valign="top">';
26
+ ?>
27
+
28
+ <td width="50%" class="product">
29
+
30
+ <div class="prodimage">
31
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">
32
+ <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(($this->getImageHeight()) ? $this->getImageHeight() : 65,($this->getImageWidth()) ? $this->getImageWidth() : 65); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>"/>
33
+ </a>
34
+ </div>
35
+ <div class="prodDetails">
36
+ <a class="product-name" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>)"><?php echo $_product->getName() ?></a>
37
+ <div class="prodprice paddtl">
38
+
39
+ <span class="price-box"><?php echo Mage::helper('core')->currency(number_format($_product->getPrice(),2)); ?></span>
40
+ </div>
41
+ <?php if($_product->isSaleable()): ?>
42
+
43
+ <button class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('Add to Cart') ?></span></button>
44
+ <?php else: ?>
45
+ <span class="out-of-stock"><?php echo $this->__('Out of stock') ?></span>
46
+ <?php endif; ?>
47
+ </div>
48
+ <div class="cl">
49
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
50
+ <a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="addWishlist"><?php echo $this->__('Add to Wishlist') ?></a>
51
+ <?php endif; ?>
52
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
53
+ &nbsp;<a href="<?php echo $_compareUrl; ?>" class="addCompare"><?php echo $this->__('Add to Compare') ?></a>
54
+ <?php endif; ?>
55
+ </div>
56
+ </td>
57
+ <?php
58
+ $i++;
59
+
60
+ if($i>($itemPerRow-1))
61
+ { $i=0;
62
+ echo "</tr>";
63
+ echo '<tr><td colspan="3" class="hline"><img src="'. $this->getSkinUrl('images/spacer.gif') .'" alt="" /></td></tr>';
64
+ }
65
+
66
+ if($i==($itemPerRow))
67
+ {
68
+ echo '<td class="vline"><img src="'. $this->getSkinUrl('images/spacer.gif') .'" alt=""/></td>';
69
+ }
70
+
71
+
72
+ }
73
+
74
+ ?>
75
+ </tr>
76
+ </table>
app/etc/modules/CapacityWebSolutions_Bestseller.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <CapacityWebSolutions_Bestseller>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </CapacityWebSolutions_Bestseller>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Bestseller_products</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This extension is display best selling product of your store.</summary>
10
+ <description>This extension is display best selling product of your store. You can display best selling product of each store.</description>
11
+ <notes>Best Seller products</notes>
12
+ <authors><author><name>Capacity Web Solutions</name><user>auto-converted</user><email>magento@capacitywebsolutions.com</email></author></authors>
13
+ <date>2010-12-22</date>
14
+ <time>07:56:35</time>
15
+ <contents><target name="magecommunity"><dir name="CapacityWebSolutions"><dir name="Bestseller"><dir name="Block"><file name="Bestseller.php" hash="b7e714e89ca5e700b13f6b1a6072a53a"/></dir><dir name="controllers"><file name="IndexController.php" hash="05f41956b0de27f979b9d12506676a2c"/></dir><dir name="etc"><file name="config.xml" hash="28f4e9ec6244c8c0d048165f5104ef86"/><file name="system.xml" hash="260bf56993891a72e636337d89cdaae3"/></dir><dir name="Helper"><file name="Data.php" hash="fe921d0069a230f79dc6ddeaa2691a52"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="bestseller"><file name="bestseller.phtml" hash="f72ff87ccc12fdd0415f552e22e32060"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="CapacityWebSolutions_Bestseller.xml" hash="2da8de0fa3abb8b91292f66ceb23bc33"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>