Bestseller_products - Version 1.1.2

Version Notes

Best Seller

Download this release

Release Info

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


Code changes from version 1.1.1 to 1.1.2

app/code/community/CapacityWebSolutions/Bestseller/Block/Bestseller.php CHANGED
@@ -8,9 +8,7 @@
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"));
@@ -25,34 +23,20 @@ class CapacityWebSolutions_Bestseller_Block_Bestseller extends Mage_Catalog_Bloc
25
}
26
function getBestsellerProduct()
27
{
28
-
29
- $timePeriod = ($this->getTimePeriod()) ? $this->getTimePeriod() : 60;
30
- $date = date('Y-m-d');
31
$newdate = strtotime ( '-'.$timePeriod.' day' , strtotime ( $date ) ) ;
32
$newdate = date ( 'Y-m-j' , $newdate );
33
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
34
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
35
$table_prefixx = Mage::getConfig()->getTablePrefix();
36
$upperLimit = ($this->getLimit()) ? $this->getLimit() : 4;
37
- /* $res = $write->query("select max(qo) as des_qty,`product_id` FROM (select sum(`qty_ordered`) AS qo,`product_id`,created_at,store_id from ".$table_prefixx."sales_flat_order_item Group By `product_id`) AS t1 where store_id = ".$this->getStoreId()." Group By `product_id` order By des_qty desc LIMIT 0, ".$upperLimit."");
38
- */
39
- // echo "select max(qo) as des_qty,`product_id` FROM (select sum(`qty_ordered`) AS qo,`product_id`,created_at,store_id from ".$table_prefixx."sales_flat_order_item Group By `product_id`) AS t1 where store_id = ".$this->getStoreId()." AND created_at between'".$newdate."' AND '".$date."' Group By `product_id` order By des_qty desc LIMIT 0, ".$upperLimit."";
40
-
41
- $res = $write->query("select max(qo) as des_qty,`product_id` FROM (select sum(`qty_ordered`) AS qo,`product_id`,created_at,store_id from ".$table_prefixx."sales_flat_order_item Group By `product_id`) AS t1 where store_id = ".$this->getStoreId()." AND created_at between'".$newdate."' AND '".$date."' Group By `product_id` order By des_qty desc LIMIT 0, ".$upperLimit."");
42
- //echo "<pre>";
43
- //print_r($res);
44
-
45
-
46
-
47
- while ($row = $res->fetch())
48
- {
49
$maxQty[]=$row['product_id'];
50
- }
51
-
52
- return $maxQty;
53
}
54
}
55
-
56
-
57
-
58
?>
8
9
class CapacityWebSolutions_Bestseller_Block_Bestseller extends Mage_Catalog_Block_Product_Abstract // Mage_Core_Block_Template
10
{
11
+ public function __construct()
12
{
13
$this->setHeader(Mage::getStoreConfig("bestseller/general/heading"));
14
$this->setLimit((int)Mage::getStoreConfig("bestseller/general/number_of_items"));
23
}
24
function getBestsellerProduct()
25
{
26
+ $timePeriod = ($this->getTimePeriod()) ? $this->getTimePeriod() : 60;
27
+ $date = date('Y-m-d H:i:s');
28
$newdate = strtotime ( '-'.$timePeriod.' day' , strtotime ( $date ) ) ;
29
$newdate = date ( 'Y-m-j' , $newdate );
30
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
31
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
32
$table_prefixx = Mage::getConfig()->getTablePrefix();
33
$upperLimit = ($this->getLimit()) ? $this->getLimit() : 4;
34
+ $res = $write->query("select max(qo) as des_qty,`product_id`,`parent_item_id` FROM (select sum(`qty_ordered`) AS qo,`product_id`,created_at,store_id,`parent_item_id` from ".$table_prefixx."sales_flat_order_item Group By `product_id`) AS t1 where store_id = ".$this->getStoreId()." AND parent_item_id is null AND created_at between'".$newdate."' AND '".$date."' Group By `product_id` order By des_qty desc LIMIT 0, ".$upperLimit."");
35
+ while ($row = $res->fetch())
36
+ {
37
$maxQty[]=$row['product_id'];
38
+ }
39
+ return $maxQty;
40
}
41
}
42
?>
app/code/community/CapacityWebSolutions/Bestseller/etc/system.xml CHANGED
@@ -62,7 +62,7 @@
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>
@@ -71,7 +71,7 @@
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>
@@ -97,14 +97,35 @@
97
<show_in_website>1</show_in_website>
98
<show_in_store>1</show_in_store>
99
</time_period>
100
-
101
-
102
<add_to_cart translate="label">
103
<label>Add to Cart</label>
104
<comment>Select Yes for display the Add to cart button on frontend.</comment>
105
<source_model>adminhtml/system_config_source_yesno</source_model>
106
<frontend_type>select</frontend_type>
107
- <sort_order>6</sort_order>
108
<show_in_default>1</show_in_default>
109
<show_in_website>1</show_in_website>
110
<show_in_store>1</show_in_store>
@@ -115,7 +136,7 @@
115
<comment>Select Yes for display the Add to Wishlist Link on frontend.</comment>
116
<frontend_type>select</frontend_type>
117
<source_model>adminhtml/system_config_source_yesno</source_model>
118
- <sort_order>7</sort_order>
119
<show_in_default>1</show_in_default>
120
<show_in_website>1</show_in_website>
121
<show_in_store>1</show_in_store>
@@ -126,12 +147,14 @@
126
<comment>Select Yes for display the Add to Compare Link on frontend.</comment>
127
<source_model>adminhtml/system_config_source_yesno</source_model>
128
<frontend_type>select</frontend_type>
129
- <sort_order>8</sort_order>
130
<show_in_default>1</show_in_default>
131
<show_in_website>1</show_in_website>
132
<show_in_store>1</show_in_store>
133
</add_to_compare>
134
-
135
</fields>
136
</general>
137
</groups>
62
</number_of_items_per_row>
63
64
<thumbnail_height translate="label">
65
+ <label>Thumbnail Width</label>
66
<frontend_type>text</frontend_type>
67
<sort_order>3</sort_order>
68
<show_in_default>1</show_in_default>
71
</thumbnail_height>
72
73
<thumbnail_width translate="label">
74
+ <label>Thumbnail Height </label>
75
<frontend_type>text</frontend_type>
76
<sort_order>4</sort_order>
77
<show_in_default>1</show_in_default>
97
<show_in_website>1</show_in_website>
98
<show_in_store>1</show_in_store>
99
</time_period>
100
+
101
+ <products_price translate="label">
102
+ <label>Show Products Price</label>
103
+ <comment>Select Yes for display the Products Price on frontend.</comment>
104
+ <source_model>adminhtml/system_config_source_yesno</source_model>
105
+ <frontend_type>select</frontend_type>
106
+ <sort_order>6</sort_order>
107
+ <show_in_default>1</show_in_default>
108
+ <show_in_website>1</show_in_website>
109
+ <show_in_store>1</show_in_store>
110
+ </products_price>
111
+
112
+ <review translate="label">
113
+ <label>Show Reviews Ratings</label>
114
+ <comment>Select Yes for display the Reviews Ratings on frontend.</comment>
115
+ <source_model>adminhtml/system_config_source_yesno</source_model>
116
+ <frontend_type>select</frontend_type>
117
+ <sort_order>7</sort_order>
118
+ <show_in_default>1</show_in_default>
119
+ <show_in_website>1</show_in_website>
120
+ <show_in_store>1</show_in_store>
121
+ </review>
122
+
123
<add_to_cart translate="label">
124
<label>Add to Cart</label>
125
<comment>Select Yes for display the Add to cart button on frontend.</comment>
126
<source_model>adminhtml/system_config_source_yesno</source_model>
127
<frontend_type>select</frontend_type>
128
+ <sort_order>8</sort_order>
129
<show_in_default>1</show_in_default>
130
<show_in_website>1</show_in_website>
131
<show_in_store>1</show_in_store>
136
<comment>Select Yes for display the Add to Wishlist Link on frontend.</comment>
137
<frontend_type>select</frontend_type>
138
<source_model>adminhtml/system_config_source_yesno</source_model>
139
+ <sort_order>9</sort_order>
140
<show_in_default>1</show_in_default>
141
<show_in_website>1</show_in_website>
142
<show_in_store>1</show_in_store>
147
<comment>Select Yes for display the Add to Compare Link on frontend.</comment>
148
<source_model>adminhtml/system_config_source_yesno</source_model>
149
<frontend_type>select</frontend_type>
150
+ <sort_order>10</sort_order>
151
<show_in_default>1</show_in_default>
152
<show_in_website>1</show_in_website>
153
<show_in_store>1</show_in_store>
154
</add_to_compare>
155
+
156
+
157
+
158
</fields>
159
</general>
160
</groups>
app/design/frontend/default/default/template/bestseller/bestseller.phtml CHANGED
@@ -6,48 +6,53 @@
6
?>
7
<style>
8
.productList { float:left; width:720px; }
9
- .productList .product { background:#fff; border:1px solid #ccc; padding:5px; width:150px; float:left; margin:10px 8px 10px 0; text-align:center; }
10
- .productList .product .cl { padding:0 0 0 30px; }
11
- .productList .product .addCompare { float:left; clear:both; }
12
- .productList .product .addWishlist { float:left; clear:both; }
13
14
</style>
15
<?php
16
-
17
-
18
- $result = $this->getBestsellerProduct();
19
$itemPerRow = ($this->getItemsPerRow()) ? $this->getItemsPerRow() : 2 ;
20
//getting product model
21
-
22
$model = Mage::getModel('catalog/product');
23
?>
24
-
25
<div class="sectionHead"><h2><?php echo $this->getHeader(); ?></h2></div>
26
<table border="0" cellpadding="0" cellspacing="0" class="productList">
27
<tr>
28
- <?php $i=0;
29
- for($cnt = 0; $cnt<count($result); $cnt++){
30
-
31
- $_product = $model->load($result[$cnt]); //getting product object for particular product id
32
- if($i>($itemPerRow-1))
33
- echo '<tr valign="top">';
34
?>
35
-
36
-
37
- <td width="50%" class="product">
38
-
39
- <div class="prodimage">
40
<a href="<?php echo $this->getBaseUrl().$_product['url_path']; ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">
41
- <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['name']) ?>"/>
42
</a>
43
- </div>
44
- <div class="prodDetails">
45
<a href="<?php echo $this->getBaseUrl().$_product['url_path'] ?>" title="<?php echo $this->htmlEscape($_product['name']) ?>"><?php echo $this->htmlEscape($_product['name']) ?></a>
46
- <div class="prodprice paddtl">
47
-
48
- <span class="price-box"><?php echo Mage::helper('core')->currency(number_format($_product->getPrice(),2)); ?></span>
49
- <?php //echo $this->getPriceHtml($_product, true) ?>
50
- </div>
51
<?php $addtocartval = $this->getAddToCart();
52
if($addtocartval == 1){
53
if($_product->isSaleable()): ?>
@@ -56,13 +61,15 @@ for($cnt = 0; $cnt<count($result); $cnt++){
56
<?php else: ?>
57
<span class="out-of-stock"><?php echo $this->__('Out of stock') ?></span>
58
<?php endif; }?>
59
- </div>
60
- <div class="cl">
61
<?php $wishlists = $this->getActive();
62
if($wishlists == 1){
63
if ($this->helper('wishlist')->isAllow()) : ?>
64
<a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="addWishlist"><?php echo $this->__('Add to Wishlist') ?></a>
65
<?php endif; }?>
66
<?php $addtocompare = $this->getAddToCompare();
67
if($addtocompare==1){
68
if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
@@ -78,15 +85,11 @@ for($cnt = 0; $cnt<count($result); $cnt++){
78
echo "</tr>";
79
echo '<tr><td colspan="3" class="hline"><img src="'. $this->getSkinUrl('images/spacer.gif') .'" alt="" /></td></tr>';
80
}
81
-
82
if($i==($itemPerRow))
83
{
84
- echo '<td class="vline"><img src="'. $this->getSkinUrl('images/spacer.gif') .'" alt=""/></td>';
85
- }
86
-
87
-
88
}
89
-
90
?>
91
</tr>
92
</table>
6
?>
7
<style>
8
.productList { float:left; width:720px; }
9
+ .productList .product { background:#fff; border:1px solid #ccc; padding:5px; float:left; margin:10px 8px 10px 0; text-align:center; }
10
+ .productList .product .cl { padding:0 0 0 0px; text-align:center;}
11
+ .productList .product .prodDetails {text-align:center; padding:0 0 0 0px; }
12
+ .productList .product .addCompare { text-align:center; clear:both; }
13
+ .productList .product .addWishlist {clear:both; text-align:center; }
14
15
+ }
16
</style>
17
<?php
18
+ $result = $this->getBestsellerProduct();
19
$itemPerRow = ($this->getItemsPerRow()) ? $this->getItemsPerRow() : 2 ;
20
//getting product model
21
$model = Mage::getModel('catalog/product');
22
+ $products_price = Mage::getStoreConfig('bestseller/general/products_price');
23
+ $review = Mage::getStoreConfig('bestseller/general/review');
24
?>
25
<div class="sectionHead"><h2><?php echo $this->getHeader(); ?></h2></div>
26
<table border="0" cellpadding="0" cellspacing="0" class="productList">
27
<tr>
28
+ <?php $i=0;
29
+ for($cnt = 0; $cnt<count($result); $cnt++){
30
+ $_product = $model->load($result[$cnt]); //getting product object for particular product id
31
+ if($i>($itemPerRow-1))
32
+ echo '<tr valign="top">';
33
?>
34
+ <td class="product">
35
+ <div class="prodimage">
36
<a href="<?php echo $this->getBaseUrl().$_product['url_path']; ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">
37
+ <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(($this->getImageHeight()) ? $this->getImageHeight() : 135,($this->getImageWidth()) ? $this->getImageWidth() : 135); ?>" alt="<?php echo $this->htmlEscape($_product['name']) ?>"/>
38
</a>
39
+ </div>
40
+ <div align="center">
41
+ <div class="prodDetails" align="center" style="width:150px;" >
42
<a href="<?php echo $this->getBaseUrl().$_product['url_path'] ?>" title="<?php echo $this->htmlEscape($_product['name']) ?>"><?php echo $this->htmlEscape($_product['name']) ?></a>
43
+
44
+ <?php if($review == 1)
45
+ {
46
+ $_product = Mage::getModel('catalog/product')->load($_product->getId());
47
+ echo $this->getReviewsSummaryHtml($_product, 'short');
48
+ }
49
+ if($products_price == 1)
50
+ {
51
+ $_product = Mage::getModel('catalog/product')->load($_product->getId());
52
+ echo $this->getPriceHtml($_product, true);
53
+ }
54
+ ?>
55
+ </div>
56
<?php $addtocartval = $this->getAddToCart();
57
if($addtocartval == 1){
58
if($_product->isSaleable()): ?>
61
<?php else: ?>
62
<span class="out-of-stock"><?php echo $this->__('Out of stock') ?></span>
63
<?php endif; }?>
64
+ </div>
65
+ <div class="cl">
66
<?php $wishlists = $this->getActive();
67
if($wishlists == 1){
68
if ($this->helper('wishlist')->isAllow()) : ?>
69
<a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="addWishlist"><?php echo $this->__('Add to Wishlist') ?></a>
70
<?php endif; }?>
71
+ </div>
72
+ <div class="cl">
73
<?php $addtocompare = $this->getAddToCompare();
74
if($addtocompare==1){
75
if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
85
echo "</tr>";
86
echo '<tr><td colspan="3" class="hline"><img src="'. $this->getSkinUrl('images/spacer.gif') .'" alt="" /></td></tr>';
87
}
88
if($i==($itemPerRow))
89
{
90
+ echo '<td class="vline"><img src="'. $this->getSkinUrl('images/spacer.gif') .'" alt=""/></td>';
91
+ }
92
}
93
?>
94
</tr>
95
</table>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
<?xml version="1.0"?>
2
<package>
3
<name>Bestseller_products</name>
4
- <version>1.1.1</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>
@@ -9,10 +9,10 @@
9
<summary>This extension is display best seller product.</summary>
10
<description>This extension is display best seller product.</description>
11
<notes>Best Seller</notes>
12
- <authors><author><name>Capacity Web Solutions</name><user>capacitywebsolutions</user><email>magento@capacitywebsolutions.com</email></author></authors>
13
- <date>2012-07-21</date>
14
- <time>06:16:05</time>
15
- <contents><target name="mageetc"><dir name="modules"><file name="CapacityWebSolutions_Bestseller.xml" hash="2da8de0fa3abb8b91292f66ceb23bc33"/></dir></target><target name="magecommunity"><dir name="CapacityWebSolutions"><dir name="Bestseller"><dir name="Block"><file name="Bestseller.php" hash="1177dde36ac5bda8586521f47f6ab4cb"/></dir><dir name="Helper"><file name="Data.php" hash="4f32df17e74aa95c488782c3d6cf0286"/></dir><dir name="controllers"><file name="IndexController.php" hash="a9d5c5fde53e96b28272fbb59a6fefe9"/></dir><dir name="etc"><file name="config.xml" hash="4442fe49feb8c2d85f47dca490416d81"/><file name="system.xml" hash="124d754fd64c8eeed33e99b7b5f3bf47"/></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="0737bc1a1c1c273316e12b30e42ca7e5"/></dir></dir></dir></dir></dir></target></contents>
16
<compatible/>
17
- <dependencies><required><php><min>5.0.0</min><max>5.5.2</max></php></required></dependencies>
18
</package>
1
<?xml version="1.0"?>
2
<package>
3
<name>Bestseller_products</name>
4
+ <version>1.1.2</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>
9
<summary>This extension is display best seller product.</summary>
10
<description>This extension is display best seller product.</description>
11
<notes>Best Seller</notes>
12
+ <authors><author><name>Capacity Web Solutions</name><user>auto-converted</user><email>magento@capacitywebsolutions.com</email></author></authors>
13
+ <date>2013-11-19</date>
14
+ <time>07:57:50</time>
15
+ <contents><target name="magecommunity"><dir name="CapacityWebSolutions"><dir name="Bestseller"><dir name="Block"><file name="Bestseller.php" hash="ae931fdb3e4da3fffaec3c200d408a9d"/></dir><dir name="Helper"><file name="Data.php" hash="4f32df17e74aa95c488782c3d6cf0286"/></dir><dir name="controllers"><file name="IndexController.php" hash="a9d5c5fde53e96b28272fbb59a6fefe9"/></dir><dir name="etc"><file name="config.xml" hash="4442fe49feb8c2d85f47dca490416d81"/><file name="system.xml" hash="d371cae3764f3863a00c2d1c82443e24"/></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="d92d62cb7cf13e7e15006e8e9b66db00"/></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>