Bestseller_products - Version 1.1.3

Version Notes

Best Seller

Download this release

Release Info

Developer Capacity Web Solutions
Extension Bestseller_products
Version 1.1.3
Comparing to
See all releases


Code changes from version 1.1.2 to 1.1.3

app/code/community/CapacityWebSolutions/Bestseller/Block/Bestseller.php CHANGED
@@ -30,12 +30,14 @@ class CapacityWebSolutions_Bestseller_Block_Bestseller extends Mage_Catalog_Bloc
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
  }
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
+ $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");
34
+
35
  while ($row = $res->fetch())
36
  {
37
  $maxQty[]=$row['product_id'];
38
+
39
  }
40
+
41
  return $maxQty;
42
  }
43
  }
app/code/community/CapacityWebSolutions/Bestseller/etc/system.xml CHANGED
@@ -151,9 +151,19 @@
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>
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
+ <out_of_stoke translate="label">
157
+ <label>Display out of stock items</label>
158
+ <comment>Select Yes for display the out of stock items on frontend.</comment>
159
+ <source_model>adminhtml/system_config_source_yesno</source_model>
160
+ <frontend_type>select</frontend_type>
161
+ <sort_order>11</sort_order>
162
+ <show_in_default>1</show_in_default>
163
+ <show_in_website>1</show_in_website>
164
+ <show_in_store>1</show_in_store>
165
+ </out_of_stoke>
166
+
167
 
168
  </fields>
169
  </general>
app/design/frontend/default/default/template/bestseller/bestseller.phtml CHANGED
@@ -11,28 +11,44 @@
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>
@@ -78,9 +94,97 @@ $review = Mage::getStoreConfig('bestseller/general/review');
78
  </div>
79
  </td>
80
  <?php
81
- $i++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
- if($i>($itemPerRow-1))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  { $i=0;
85
  echo "</tr>";
86
  echo '<tr><td colspan="3" class="hline"><img src="'. $this->getSkinUrl('images/spacer.gif') .'" alt="" /></td></tr>';
@@ -89,7 +193,18 @@ $review = Mage::getStoreConfig('bestseller/general/review');
89
  {
90
  echo '<td class="vline"><img src="'. $this->getSkinUrl('images/spacer.gif') .'" alt=""/></td>';
91
  }
92
- }
93
- ?>
 
 
 
 
 
 
 
94
  </tr>
 
 
 
 
95
  </table>
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
  </style>
15
  <?php
16
  $result = $this->getBestsellerProduct();
17
+ $upperLimit = ($this->getLimit()) ? $this->getLimit() : 1;
18
+ $itemPerRow = ($this->getItemsPerRow()) ? $this->getItemsPerRow() : 1 ;
19
  $model = Mage::getModel('catalog/product');
20
  $products_price = Mage::getStoreConfig('bestseller/general/products_price');
21
+ $review = Mage::getStoreConfig('bestseller/general/review');
22
+ $out_of_stoke = Mage::getStoreConfig('bestseller/general/out_of_stoke');
23
  ?>
24
  <div class="sectionHead"><h2><?php echo $this->getHeader(); ?></h2></div>
25
  <table border="0" cellpadding="0" cellspacing="0" class="productList">
26
+ <?php
27
+ if ($out_of_stoke == 0)
28
+ {
29
+ ?>
30
+
31
  <tr>
32
+ <?php
33
+ $i=0;
34
+ $x = 1;
35
+ for($cnt = 0; $cnt<count($result); $cnt++)
36
+ {
37
+ $_product = $model->load($result[$cnt]); //getting product object for particular product id
38
+ $status = $_product->getData('status');
39
+ $is_salable = $_product->getData('is_salable');
40
+
41
+ if($status == 1)
42
+ {
43
+ if ($is_salable == 1 )
44
+ {
45
+ if($x <= $upperLimit)
46
+ {
47
+ if($i>($itemPerRow-1))
48
+ echo '<tr valign="top">';
49
  ?>
50
  <td class="product">
51
+ <div class="prodimage">
52
  <a href="<?php echo $this->getBaseUrl().$_product['url_path']; ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">
53
  <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']) ?>"/>
54
  </a>
94
  </div>
95
  </td>
96
  <?php
97
+ $i++;
98
+ if($i>($itemPerRow-1))
99
+ { $i=0;
100
+ echo "</tr>";
101
+ echo '<tr><td colspan="3" class="hline"><img src="'. $this->getSkinUrl('images/spacer.gif') .'" alt="" /></td></tr>';
102
+ }
103
+ if($i==($itemPerRow))
104
+ {
105
+ echo '<td class="vline"><img src="'. $this->getSkinUrl('images/spacer.gif') .'" alt=""/></td>';
106
+ }
107
+ }
108
+ else
109
+ {
110
+ //break;
111
+ }
112
+ $x++;
113
+ }
114
+
115
+ }
116
+ }
117
+ ?>
118
+ </tr>
119
+ <?php
120
+ }
121
+ else
122
+ {
123
+ ?>
124
+ <tr>
125
+ <?php
126
+ $i=0;
127
+ $x = 1;
128
+ for($cnt = 0; $cnt<count($result); $cnt++)
129
+ {
130
+ $_product = $model->load($result[$cnt]); //getting product object for particular product id
131
+ $status = $_product->getData('status');
132
+ if ($status == 1)
133
+ {
134
+ if($x <= $upperLimit)
135
+ {
136
+ if($i>($itemPerRow-1))
137
+ echo '<tr valign="top">';
138
+ ?>
139
+ <td class="product">
140
+ <div class="prodimage">
141
+ <a href="<?php echo $this->getBaseUrl().$_product['url_path']; ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">
142
+ <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']) ?>"/>
143
+ </a>
144
+ </div>
145
+ <div align="center">
146
+ <div class="prodDetails" align="center" style="width:150px;" >
147
+ <a href="<?php echo $this->getBaseUrl().$_product['url_path'] ?>" title="<?php echo $this->htmlEscape($_product['name']) ?>"><?php echo $this->htmlEscape($_product['name']) ?></a>
148
 
149
+ <?php if($review == 1)
150
+ {
151
+ $_product = Mage::getModel('catalog/product')->load($_product->getId());
152
+ echo $this->getReviewsSummaryHtml($_product, 'short');
153
+ }
154
+ if($products_price == 1)
155
+ {
156
+ $_product = Mage::getModel('catalog/product')->load($_product->getId());
157
+ echo $this->getPriceHtml($_product, true);
158
+ }
159
+ ?>
160
+ </div>
161
+ <?php $addtocartval = $this->getAddToCart();
162
+ if($addtocartval == 1){
163
+ if($_product->isSaleable()): ?>
164
+
165
+ <button class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('Add to Cart') ?></span></button>
166
+ <?php else: ?>
167
+ <span class="out-of-stock"><?php echo $this->__('Out of stock') ?></span>
168
+ <?php endif; }?>
169
+ </div>
170
+ <div class="cl">
171
+ <?php $wishlists = $this->getActive();
172
+ if($wishlists == 1){
173
+ if ($this->helper('wishlist')->isAllow()) : ?>
174
+ <a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="addWishlist"><?php echo $this->__('Add to Wishlist') ?></a>
175
+ <?php endif; }?>
176
+ </div>
177
+ <div class="cl">
178
+ <?php $addtocompare = $this->getAddToCompare();
179
+ if($addtocompare==1){
180
+ if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
181
+ &nbsp;<a href="<?php echo $_compareUrl; ?>" class="addCompare"><?php echo $this->__('Add to Compare') ?></a>
182
+ <?php endif; }?>
183
+ </div>
184
+ </td>
185
+ <?php
186
+ $i++;
187
+ if($i>($itemPerRow-1))
188
  { $i=0;
189
  echo "</tr>";
190
  echo '<tr><td colspan="3" class="hline"><img src="'. $this->getSkinUrl('images/spacer.gif') .'" alt="" /></td></tr>';
193
  {
194
  echo '<td class="vline"><img src="'. $this->getSkinUrl('images/spacer.gif') .'" alt=""/></td>';
195
  }
196
+ }
197
+ else
198
+ {
199
+ // break;
200
+ }
201
+ $x++;
202
+ }
203
+ }
204
+ ?>
205
  </tr>
206
+ <?php
207
+ }
208
+ ?>
209
+
210
  </table>
package.xml CHANGED
@@ -1,18 +1,18 @@
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>
8
  <extends/>
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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Bestseller_products</name>
4
+ <version>1.1.3</version>
5
  <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
  <channel>community</channel>
8
  <extends/>
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>2013-12-31</date>
14
+ <time>09:51:47</time>
15
+ <contents><target name="magecommunity"><dir name="CapacityWebSolutions"><dir name="Bestseller"><dir name="Block"><file name="Bestseller.php" hash="f093834ec19c9d52cad2e1894510c539"/></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="c424576d1ef1ae368bb26323abde2e33"/></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="255726be101f48d4cd14278c5a1938a4"/></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><required><php><min>5.0.0</min><max>5.5.5</max></php></required></dependencies>
18
  </package>