ZodiacMedia_Bestsellers - Version 1.0.0

Version Notes

Initial stable release.

Download this release

Release Info

Developer Zodiac Media
Extension ZodiacMedia_Bestsellers
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/ZodiacMedia/Bestsellers/Block/Bestsellers.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please contact us via our website at
12
+ * http://www.zodiacmedia.co.uk/contact-us so we can send you a copy immediately.
13
+ *
14
+ * @category ZodiacMedia
15
+ * @package ZodiacMedia_Bestsellers
16
+ * @copyright Copyright (c) 2013 Zodiac Media Ltd (http://www.zodiacmedia.co.uk)
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ class ZodiacMedia_Bestsellers_Block_Bestsellers extends Mage_Catalog_Block_Product_Abstract {
20
+
21
+ /**
22
+ * Internal contructor
23
+ *
24
+ */
25
+ protected function _construct()
26
+ {
27
+ parent::_construct();
28
+
29
+ $this->addColumnCountLayoutDepend('empty', 6)
30
+ ->addColumnCountLayoutDepend('one_column', 5)
31
+ ->addColumnCountLayoutDepend('two_columns_left', 4)
32
+ ->addColumnCountLayoutDepend('two_columns_right', 4)
33
+ ->addColumnCountLayoutDepend('three_columns', 3);
34
+
35
+ $this->addData(array(
36
+ 'cache_lifetime' => 86400,
37
+ 'cache_tags' => array(Mage_Catalog_Model_Product::CACHE_TAG),
38
+ ));
39
+ }
40
+
41
+ /**
42
+ * Get data for caching of block content.
43
+ *
44
+ * @return array
45
+ */
46
+ public function getCacheKeyInfo() {
47
+ return array(
48
+ 'CATALOG_PRODUCT_BESTSELLING',
49
+ Mage::app()->getStore()->getId(),
50
+ Mage::getDesign()->getPackageName(),
51
+ Mage::getDesign()->getTheme('template'),
52
+ Mage::getSingleton('customer/session')->getCustomerGroupId(),
53
+ 'template' => $this->getTemplate(),
54
+ $this->getProductsCount()
55
+ );
56
+ }
57
+
58
+ /**
59
+ * Prepare collection with new products and applied page limits.
60
+ *
61
+ * return ZodiacMedia_Bestsellers_Block_Bestsellers
62
+ */
63
+ protected function _beforeToHtml() {
64
+
65
+ $collection = Mage::getResourceModel('bestsellers/product_collection');
66
+
67
+ $collection = $this->_addProductAttributesAndPrices($collection)
68
+ ->addOrderedQty()
69
+ ->setOrder('ordered_qty', 'desc')
70
+ ->setPageSize($this->getProductsCount())
71
+ ->setCurPage(1)
72
+ ->load();
73
+
74
+ $this->setProductCollection($collection);
75
+
76
+ return parent::_beforeToHtml();
77
+ }
78
+ }
app/code/community/ZodiacMedia/Bestsellers/Block/Widget/Bestsellers.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please contact us via our website at
12
+ * http://www.zodiacmedia.co.uk/contact-us so we can send you a copy immediately.
13
+ *
14
+ * @category ZodiacMedia
15
+ * @package ZodiacMedia_Bestsellers
16
+ * @copyright Copyright (c) 2013 Zodiac Media Ltd (http://www.zodiacmedia.co.uk)
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ class ZodiacMedia_Bestsellers_Block_Widget_Bestsellers
20
+ extends ZodiacMedia_Bestsellers_Block_Bestsellers
21
+ implements Mage_Widget_Block_Interface {
22
+
23
+ const DEFAULT_PRODUCTS_COUNT = 12;
24
+ const DEFAULT_THUMBNAIL_SIZE = 135;
25
+
26
+ /**
27
+ * Internal contructor
28
+ *
29
+ */
30
+ protected function _construct() {
31
+ parent::_construct();
32
+
33
+ $this->addPriceBlockType('bundle', 'bundle/catalog_product_price', 'bundle/catalog/product/price.phtml');
34
+ }
35
+
36
+ /**
37
+ * Retrieve how many products should be displayed.
38
+ *
39
+ * @return int
40
+ */
41
+ public function getProductsCount() {
42
+ if (! $this->hasData('products_count'))
43
+ return self::DEFAULT_PRODUCTS_COUNT;
44
+
45
+ return $this->_getData('products_count');
46
+ }
47
+
48
+ /**
49
+ * Retrieve thumbnail size.
50
+ *
51
+ * @return int
52
+ */
53
+ public function getThumbnailSize() {
54
+ if (! $this->hasData('thumbnail_size'))
55
+ return self::DEFAULT_THUMBNAIL_SIZE;
56
+
57
+ return (int) $this->_getData('thumbnail_size');
58
+ }
59
+ }
app/code/community/ZodiacMedia/Bestsellers/Helper/Data.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please contact us via our website at
12
+ * http://www.zodiacmedia.co.uk/contact-us so we can send you a copy immediately.
13
+ *
14
+ * @category ZodiacMedia
15
+ * @package ZodiacMedia_Bestsellers
16
+ * @copyright Copyright (c) 2013 Zodiac Media Ltd (http://www.zodiacmedia.co.uk)
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ class ZodiacMedia_Bestsellers_Helper_Data extends Mage_Core_Helper_Abstract {}
app/code/community/ZodiacMedia/Bestsellers/Model/Resource/Product/Collection.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please contact us via our website at
12
+ * http://www.zodiacmedia.co.uk/contact-us so we can send you a copy immediately.
13
+ *
14
+ * @category ZodiacMedia
15
+ * @package ZodiacMedia_Bestsellers
16
+ * @copyright Copyright (c) 2013 Zodiac Media Ltd (http://www.zodiacmedia.co.uk)
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ class ZodiacMedia_Bestsellers_Model_Resource_Product_Collection extends Mage_Reports_Model_Resource_Product_Collection {
20
+
21
+ /**
22
+ * Add number of orders for products
23
+ *
24
+ * @param string $from
25
+ * @param string $to
26
+ * @return Mage_Reports_Model_Resource_Product_Collection
27
+ */
28
+ public function addOrderedQty($from = '', $to = '') {
29
+ $adapter = $this->getConnection();
30
+ $orderTableAliasName = $adapter->quoteIdentifier('order');
31
+
32
+ $orderJoinCondition = array(
33
+ $orderTableAliasName . '.entity_id = order_items.order_id',
34
+ $adapter->quoteInto("{$orderTableAliasName}.state <> ?", Mage_Sales_Model_Order::STATE_CANCELED),
35
+ );
36
+
37
+ $productJoinCondition = array(
38
+ 'e.entity_id = T1.final_product_id',
39
+ $adapter->quoteInto('e.entity_type_id = ?', $this->getProductEntityTypeId())
40
+ );
41
+
42
+ if ($from != '' && $to != '') {
43
+ $fieldName = $orderTableAliasName . '.created_at';
44
+ $orderJoinCondition[] = $this->_prepareBetweenSql($fieldName, $from, $to);
45
+ }
46
+
47
+ $subSelect = $this->getSelect()->reset()
48
+ ->from(
49
+ array('order_items' => $this->getTable('sales/order_item')),
50
+ array(
51
+ 'qty_ordered',
52
+ 'name',
53
+ 'final_product_id' => new Zend_Db_Expr("IF(parent_id IS NOT NULL AND visibility != " . Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH . ", parent_id, order_items.product_id)"),
54
+ ))
55
+ ->joinInner(
56
+ array('order' => $this->getTable('sales/order')),
57
+ implode(' AND ', $orderJoinCondition),
58
+ array())
59
+ ->joinLeft(
60
+ array('cpr' => $this->getTable('catalog/product_relation')),
61
+ 'cpr.child_id = order_items.product_id',
62
+ array(
63
+ 'parent_id',
64
+ ))
65
+ ->joinLeft(
66
+ array('cat_index' => $this->getTable('catalog/category_product_index')),
67
+ 'cat_index.product_id = order_items.product_id',
68
+ array(
69
+ 'store_id',
70
+ 'visibility',
71
+ 'category_id',
72
+ ))
73
+ ->where('parent_item_id IS NULL')
74
+ ->where('cat_index.store_id = ?', Mage::app()->getStore()->getId())
75
+ ->where('category_id = ?', Mage::app()->getStore()->getRootCategoryId());
76
+
77
+ $subSelectString = '(' . $subSelect->__toString() . ')';
78
+
79
+ $this->getSelect()->reset()
80
+ ->from(
81
+ array('T1' => new Zend_Db_Expr($subSelectString)),
82
+ array(
83
+ 'ordered_qty' => 'SUM(qty_ordered)',
84
+ 'order_items_name' => 'name',
85
+ 'entity_id' => 'final_product_id',
86
+ ))
87
+ ->joinLeft(
88
+ array('e' => $this->getProductEntityTableName()),
89
+ implode(' AND ', $productJoinCondition),
90
+ array(
91
+ 'entity_type_id' => 'e.entity_type_id',
92
+ 'attribute_set_id' => 'e.attribute_set_id',
93
+ 'type_id' => 'e.type_id',
94
+ 'sku' => 'e.sku',
95
+ 'has_options' => 'e.has_options',
96
+ 'required_options' => 'e.required_options',
97
+ 'created_at' => 'e.created_at',
98
+ 'updated_at' => 'e.updated_at'
99
+ ))
100
+ ->group('final_product_id');
101
+
102
+ return $this;
103
+ }
104
+ }
app/code/community/ZodiacMedia/Bestsellers/etc/config.xml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please contact us via our website at
13
+ * http://www.zodiacmedia.co.uk/contact-us so we can send you a copy immediately.
14
+ *
15
+ * @category ZodiacMedia
16
+ * @package ZodiacMedia_Bestsellers
17
+ * @copyright Copyright (c) 2013 Zodiac Media Ltd (http://www.zodiacmedia.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ -->
21
+ <config>
22
+ <modules>
23
+ <ZodiacMedia_Bestsellers>
24
+ <version>1.0.0</version>
25
+ </ZodiacMedia_Bestsellers>
26
+ </modules>
27
+ <global>
28
+ <helpers>
29
+ <bestsellers>
30
+ <class>ZodiacMedia_Bestsellers_Helper</class>
31
+ </bestsellers>
32
+ </helpers>
33
+ <blocks>
34
+ <bestsellers>
35
+ <class>ZodiacMedia_Bestsellers_Block</class>
36
+ </bestsellers>
37
+ </blocks>
38
+ <models>
39
+ <bestsellers>
40
+ <class>ZodiacMedia_Bestsellers_Model</class>
41
+ <resourceModel>bestsellers_resource</resourceModel>
42
+ </bestsellers>
43
+
44
+ <bestsellers_resource>
45
+ <class>ZodiacMedia_Bestsellers_Model_Resource</class>
46
+ </bestsellers_resource>
47
+ </models>
48
+ </global>
49
+ </config>
app/code/community/ZodiacMedia/Bestsellers/etc/widget.xml ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please contact us via our website at
13
+ * http://www.zodiacmedia.co.uk/contact-us so we can send you a copy immediately.
14
+ *
15
+ * @category ZodiacMedia
16
+ * @package ZodiacMedia_Bestsellers
17
+ * @copyright Copyright (c) 2013 Zodiac Media Ltd (http://www.zodiacmedia.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ -->
21
+ <widgets>
22
+ <bestsellers type="bestsellers/widget_bestsellers" translate="name description">
23
+ <name>Zodiac Media Bestsellers List</name>
24
+ <description>List of bestselling products.</description>
25
+ <is_email_compatible>1</is_email_compatible>
26
+ <parameters>
27
+ <products_count translate="label">
28
+ <required>1</required>
29
+ <visible>1</visible>
30
+ <value>12</value>
31
+ <label>Number of products to display</label>
32
+ <type>text</type>
33
+ </products_count>
34
+ <thumbnail_size translate="label">
35
+ <required>1</required>
36
+ <visible>1</visible>
37
+ <value>135</value>
38
+ <label>Maximum dimension of product thumbnail images (pixels)</label>
39
+ <type>text</type>
40
+ </thumbnail_size>
41
+ <show_title translate="label">
42
+ <required>1</required>
43
+ <visible>1</visible>
44
+ <label>Show widget title</label>
45
+ <type>select</type>
46
+ <value>0</value>
47
+ <values>
48
+ <default translate="label">
49
+ <value>0</value>
50
+ <label>No</label>
51
+ </default>
52
+ <list translate="label">
53
+ <value>1</value>
54
+ <label>Yes</label>
55
+ </list>
56
+ </values>
57
+ </show_title>
58
+ <template>
59
+ <required>1</required>
60
+ <visible>1</visible>
61
+ <label>Template</label>
62
+ <type>select</type>
63
+ <value>zodiacmedia/bestsellers/widget/bestsellers/content/bestsellers_grid.phtml</value>
64
+ <values>
65
+ <default translate="label">
66
+ <value>zodiacmedia/bestsellers/widget/bestsellers/content/bestsellers_grid.phtml</value>
67
+ <label>Bestsellers grid template</label>
68
+ </default>
69
+ <list translate="label">
70
+ <value>zodiacmedia/bestsellers/widget/bestsellers/content/bestsellers_list.phtml</value>
71
+ <label>Bestsellers list template</label>
72
+ </list>
73
+ </values>
74
+ </template>
75
+ <cache_lifetime translate="label description">
76
+ <label>Cache lifetime (seconds)</label>
77
+ <description>86400 by default, if not set. To refresh instantly, clear the 'Blocks HTML Output' cache.</description>
78
+ <visible>1</visible>
79
+ <type>text</type>
80
+ </cache_lifetime>
81
+ </parameters>
82
+ </bestsellers>
83
+ </widgets>
app/design/frontend/base/default/template/zodiacmedia/bestsellers/widget/bestsellers/content/bestsellers_grid.phtml ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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 design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * NOTICE OF LICENSE
30
+ *
31
+ * This source file is subject to the Open Software License (OSL 3.0)
32
+ * that is bundled with this package in the file LICENSE.txt.
33
+ * It is also available through the world-wide-web at this URL:
34
+ * http://opensource.org/licenses/osl-3.0.php
35
+ *
36
+ * If you did not receive a copy of the license and are unable to
37
+ * obtain it through the world-wide-web, please contact us via our website at
38
+ * http://www.zodiacmedia.co.uk/contact-us so we can send you a copy immediately.
39
+ *
40
+ * @category ZodiacMedia
41
+ * @package ZodiacMedia_Bestsellers
42
+ * @copyright Copyright (c) 2013 Zodiac Media Ltd (http://www.zodiacmedia.co.uk)
43
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
44
+ */
45
+ ?>
46
+ <?php
47
+ $_productCollection = $this->getProductCollection();
48
+ $_helper = $this->helper('catalog/output');
49
+ ?>
50
+ <?php if(! $_productCollection->count()): ?>
51
+ <p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
52
+ <?php else: ?>
53
+ <div class="category-products">
54
+ <?php $_collectionSize = $_productCollection->count() ?>
55
+ <?php $_columnCount = $this->getColumnCount(); ?>
56
+ <?php $i=0; foreach ($_productCollection as $_product): ?>
57
+ <?php if ($i++%$_columnCount==0): ?>
58
+ <ul class="products-grid bestsellers">
59
+ <?php endif ?>
60
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
61
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($this->getThumbnailSize()); ?>" width="<?php echo $this->getThumbnailSize() ?>" height="<?php echo $this->getThumbnailSize() ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
62
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
63
+ <?php if($_product->getRatingSummary()): ?>
64
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
65
+ <?php endif; ?>
66
+ <?php echo $this->getPriceHtml($_product, true) ?>
67
+ <div class="actions">
68
+ <?php if($_product->isSaleable()): ?>
69
+ <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
70
+ <?php else: ?>
71
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
72
+ <?php endif; ?>
73
+ <ul class="add-to-links">
74
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
75
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
76
+ <?php endif; ?>
77
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
78
+ <li><a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
79
+ <?php endif; ?>
80
+ </ul>
81
+ </div>
82
+ </li>
83
+ <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
84
+ </ul>
85
+ <?php endif ?>
86
+ <?php endforeach ?>
87
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
88
+ </div>
89
+ <?php endif; ?>
app/design/frontend/base/default/template/zodiacmedia/bestsellers/widget/bestsellers/content/bestsellers_list.phtml ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ *
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please contact us via our website at
12
+ * http://www.zodiacmedia.co.uk/contact-us so we can send you a copy immediately.
13
+ *
14
+ * @category ZodiacMedia
15
+ * @package ZodiacMedia_Bestsellers
16
+ * @copyright Copyright (c) 2013 Zodiac Media Ltd (http://www.zodiacmedia.co.uk)
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ ?>
20
+ <?php
21
+ $_productCollection = $this->getProductCollection();
22
+ $_helper = $this->helper('catalog/output');
23
+ ?>
24
+ <?php if(! $_productCollection->count()): ?>
25
+ <p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
26
+ <?php else: ?>
27
+ <div class="category-products">
28
+ <?php $_iterator = 0; ?>
29
+ <ol class="products-list bestsellers" id="products-list">
30
+ <?php foreach ($_productCollection as $_product): ?>
31
+ <li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
32
+ <?php // Product Image ?>
33
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($this->getThumbnailSize()); ?>" width="<?php echo $this->getThumbnailSize() ?>" height="<?php echo $this->getThumbnailSize() ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
34
+ <?php // Product description ?>
35
+ <div class="product-shop">
36
+ <div class="f-fix">
37
+ <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
38
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2>
39
+ <?php if($_product->getRatingSummary()): ?>
40
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
41
+ <?php endif; ?>
42
+ <?php echo $this->getPriceHtml($_product, true) ?>
43
+ <?php if($_product->isSaleable()): ?>
44
+ <p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
45
+ <?php else: ?>
46
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
47
+ <?php endif; ?>
48
+ <div class="desc std">
49
+ <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
50
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
51
+ </div>
52
+ <ul class="add-to-links">
53
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
54
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
55
+ <?php endif; ?>
56
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
57
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
58
+ <?php endif; ?>
59
+ </ul>
60
+ </div>
61
+ </div>
62
+ </li>
63
+ <?php endforeach; ?>
64
+ </ol>
65
+ <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
66
+ </div>
67
+ <?php endif; ?>
app/etc/modules/ZodiacMedia_Bestsellers.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please contact us via our website at
13
+ * http://www.zodiacmedia.co.uk/contact-us so we can send you a copy immediately.
14
+ *
15
+ * @category ZodiacMedia
16
+ * @package ZodiacMedia_Bestsellers
17
+ * @copyright Copyright (c) 2013 Zodiac Media Ltd (http://www.zodiacmedia.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ -->
21
+ <config>
22
+ <modules>
23
+ <ZodiacMedia_Bestsellers>
24
+ <active>true</active>
25
+ <codePool>community</codePool>
26
+ <depends>
27
+ <Mage_Cms />
28
+ </depends>
29
+ </ZodiacMedia_Bestsellers>
30
+ </modules>
31
+ </config>
package.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>ZodiacMedia_Bestsellers</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License v3.0 (OSL-3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>An easy to use Widget which dynamically generates an ordered list of bestselling products for your store.</summary>
10
+ <description>This Magento Widget uses data stored in your Magento store's database to dynamically generate a list of bestselling products that are currently visible in your store. This list is ordered by number of products sold descending. &#xD;
11
+ &#xD;
12
+ Being a Magento Widget this extension requires no coding to implement as you can add it to a CMS page using the Magento Admin Page's User Interface.&#xD;
13
+ &#xD;
14
+ This Widget also makes use of Magento caching to prevent unnecessary load on your database.</description>
15
+ <notes>Initial stable release.</notes>
16
+ <authors><author><name>Zodiac Media</name><user>zodiac_media</user><email>info@zodiacmedia.co.uk</email></author></authors>
17
+ <date>2013-12-19</date>
18
+ <time>17:13:45</time>
19
+ <contents><target name="mageetc"><dir name="modules"><file name="ZodiacMedia_Bestsellers.xml" hash="af3268521a3836420b95e48a16bbba44"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="zodiacmedia"><dir name="bestsellers"><dir name="widget"><dir name="bestsellers"><dir name="content"><file name="bestsellers_grid.phtml" hash="4c0010c017b01e139067c851829c26f4"/><file name="bestsellers_list.phtml" hash="579b94a60cd4d326d86f0d8c685938a7"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="ZodiacMedia"><dir name="Bestsellers"><dir name="Block"><file name="Bestsellers.php" hash="a822ac102a5aa2bf23508447ba27822c"/><dir name="Widget"><file name="Bestsellers.php" hash="84876dcec3eb10acf8d314b8617ef2f0"/></dir></dir><dir name="Helper"><file name="Data.php" hash="f7ced4fb3d3b51501cd8b6d0646e1618"/></dir><dir name="Model"><dir name="Resource"><dir name="Product"><file name="Collection.php" hash="2c88e954d4bd182877542318849cb454"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="909451a4b2597ca260db2ad35f9fe13b"/><file name="widget.xml" hash="289409cbbd416c36c4700eb18808afca"/></dir></dir></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
22
+ </package>