Bestseller_products - Version 1.0.0

Version Notes

Best Seller products

Download this release

Release Info

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


Code changes from version 0.1.1 to 1.0.0

app/code/community/CapacityWebSolutions/Bestseller/Block/Bestseller.php CHANGED
@@ -1,6 +1,6 @@
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
  ?>
@@ -18,13 +18,25 @@ class CapacityWebSolutions_Bestseller_Block_Bestseller extends Mage_Catalog_Bloc
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
  }
1
  <?php
2
  /**
3
+ * @copyright Copyright (c) 2011 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
  ?>
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
+ $this->setTimePeriod((int)Mage::getStoreConfig("bestseller/general/time_period"));
22
  }
23
  function getBestsellerProduct()
24
+ {
25
+
26
+ $timePeriod = ($this->getTimePeriod()) ? $this->getTimePeriod() : 60;
27
+ $date = date('Y-m-d');
28
+ $newdate = strtotime ( '-'.$timePeriod.' day' , strtotime ( $date ) ) ;
29
+ $newdate = date ( 'Y-m-j' , $newdate );
30
+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
31
+ $table_prefixx = Mage::getConfig()->getTablePrefix();
32
+ $upperLimit = ($this->getLimit()) ? $this->getLimit() : 4;
33
+ $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."");
34
+
35
+ while ($row = $res->fetch() ) {
36
+ $maxQty[]=$row['product_id'];
37
+ }
38
+
39
+ return $maxQty;
40
 
41
  }
42
  }
app/code/community/CapacityWebSolutions/Bestseller/Helper/Data.php CHANGED
@@ -1,7 +1,7 @@
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
 
1
  <?php
2
 
3
  /**
4
+ * @copyright Copyright (c) 2011 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
 
app/code/community/CapacityWebSolutions/Bestseller/controllers/IndexController.php CHANGED
@@ -1,6 +1,6 @@
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
  ?>
1
  <?php
2
  /**
3
+ * @copyright Copyright (c) 2011 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
  ?>
app/code/community/CapacityWebSolutions/Bestseller/etc/config.xml CHANGED
@@ -1,7 +1,7 @@
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
  -->
@@ -9,7 +9,7 @@
9
  <global>
10
  <modules>
11
  <CapacityWebSolutions_Bestseller>
12
- <version>0.1.0</version>
13
  </CapacityWebSolutions_Bestseller>
14
  </modules>
15
  <blocks>
1
  <?xml version="1.0"?>
2
  <!--
3
  /**
4
+ * @copyright Copyright (c) 2011 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
  -->
9
  <global>
10
  <modules>
11
  <CapacityWebSolutions_Bestseller>
12
+ <version>1.0.0</version>
13
  </CapacityWebSolutions_Bestseller>
14
  </modules>
15
  <blocks>
app/code/community/CapacityWebSolutions/Bestseller/etc/system.xml CHANGED
@@ -1,7 +1,7 @@
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
  -->
@@ -77,7 +77,17 @@
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>
1
  <?xml version="1.0"?>
2
  <!--
3
  /**
4
+ * @copyright Copyright (c) 2011 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
  -->
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
+
82
+ <time_period translate="label">
83
+ <label>Time Period</label>
84
+ <comment>Days bestselling product. Default 60 days.</comment>
85
+ <frontend_type>text</frontend_type>
86
+ <sort_order>5</sort_order>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ <show_in_store>1</show_in_store>
90
+ </time_period>
91
  </fields>
92
  </general>
93
  </groups>
app/design/frontend/default/default/template/bestseller/bestseller.phtml CHANGED
@@ -1,6 +1,6 @@
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
  ?>
@@ -9,7 +9,7 @@
9
  $result = $this->getBestsellerProduct();
10
  $itemPerRow = ($this->getItemsPerRow()) ? $this->getItemsPerRow() : 2 ;
11
  //getting product model
12
-
13
  $model = Mage::getModel('catalog/product');
14
  ?>
15
 
@@ -17,26 +17,27 @@ $model = Mage::getModel('catalog/product');
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
 
@@ -73,4 +74,4 @@ for($cnt = 0; $cnt<count($result); $cnt++)
73
 
74
  ?>
75
  </tr>
76
- </table>
1
  <?php
2
  /**
3
+ * @copyright Copyright (c) 2011 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
  ?>
9
  $result = $this->getBestsellerProduct();
10
  $itemPerRow = ($this->getItemsPerRow()) ? $this->getItemsPerRow() : 2 ;
11
  //getting product model
12
+
13
  $model = Mage::getModel('catalog/product');
14
  ?>
15
 
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
+ $_product = $model->load($result[$cnt]); //getting product object for particular product id
23
  if($i>($itemPerRow-1))
24
  echo '<tr valign="top">';
25
  ?>
26
+
27
 
28
  <td width="50%" class="product">
29
 
30
  <div class="prodimage">
31
+ <a href="<?php echo $this->getBaseUrl().$_product['url_path']; ?>" 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['name']) ?>"/>
33
  </a>
34
  </div>
35
  <div class="prodDetails">
36
+ <a href="<?php echo $this->getBaseUrl().$_product['url_path'] ?>" title="<?php echo $this->htmlEscape($_product['name']) ?>"><?php echo $this->htmlEscape($_product['name']) ?></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
+ <?php //echo $this->getPriceHtml($_product, true) ?>
41
  </div>
42
  <?php if($_product->isSaleable()): ?>
43
 
74
 
75
  ?>
76
  </tr>
77
+ </table>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Bestseller_products</name>
4
- <version>0.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>
@@ -10,9 +10,9 @@
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>08:08:41</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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Bestseller_products</name>
4
+ <version>1.0.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>
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>2011-02-07</date>
14
+ <time>07:08:01</time>
15
+ <contents><target name="magecommunity"><dir name="CapacityWebSolutions"><dir name="Bestseller"><dir name="Block"><file name="Bestseller.php" hash="d984c905e6a3c2ca9fe959ba79364ea7"/></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="688b234dcd7c7c6e76cf43dc29523ec9"/></dir><dir name="Helper"><file name="Data.php" hash="4f32df17e74aa95c488782c3d6cf0286"/></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="26d2bab77548839c8f91eace9d640385"/></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>