Magazento_Productivity - Version 1.0.0

Version Notes

test community release

Download this release

Release Info

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


Version 1.0.0

app/code/community/Ip/Productactivity/Block/Developer.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ip_Productactivity_Block_Developer extends Mage_Adminhtml_Block_System_Config_Form_Fieldset {
4
+
5
+
6
+ public function render(Varien_Data_Form_Element_Abstract $element) {
7
+ $content = '<p></p>';
8
+ $content.= '<style>';
9
+ $content.= '.developer {
10
+ background:#FAFAFA;
11
+ border: 1px solid #CCCCCC;
12
+ margin-bottom: 10px;
13
+ padding: 10px;
14
+ height:auto;
15
+
16
+ }
17
+ .developer h3 {
18
+ color: #EA7601;
19
+ }
20
+ .contact-type {
21
+ color: #EA7601;
22
+ font-weight:bold;
23
+ }
24
+ .developer img {
25
+
26
+ float:left;
27
+ height:255px;
28
+ width:220px;
29
+ }
30
+ .developer .info {
31
+ border: 1px solid #CCCCCC;
32
+ background:#E7EFEF;
33
+ padding: 5px 10px 0 5px;
34
+ margin-left:230px;
35
+ height:250px;
36
+ }
37
+ ';
38
+ $content.= '</style>';
39
+
40
+
41
+ $content.= '<div class="developer">';
42
+ $content.= '<a href="http://www.ecommerceoffice.com/" target="_blank"><img src="'.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'frontend/base/default/ip_productactivity/promo.jpg" alt="www.ecommerceoffice.com" /></a>';
43
+ $content.= '<div class="info">';
44
+ $content.= '<h3>PROFESSIONAL MAGENTO DEVELOPMENT</h3>';
45
+ $content.= '<p>We provide premium services for Business, Corporate built with the latest innovations in web-development and SEO niche. <br/> You will pay less to go live with our wide range of solutions and services.<br/>';
46
+ $content.= 'If you need Magento development , please contact us.</p>';
47
+ $content.= '<span class="contact-type">Website:</span> <br/><a href="http://www.magazento.com/" target="_blank">www.magazento.com</a> <br/>';
48
+ $content.= '<span class="contact-type">E-mail:</span> <br/>service@magazento.com <br/>';
49
+ $content.= '<span class="contact-type">LinkedIn:</span> <br/><a href="http://www.linkedin.com/pub/ivan-proskuryakov/31/200/316" target="_blank">http://www.linkedin.com/pub/ivan-proskuryakov/31/200/316</a> <br/>';
50
+
51
+ $content.= '</div>';
52
+
53
+ $content.= '</div>';
54
+
55
+ return $content;
56
+
57
+
58
+ }
59
+
60
+
61
+ }
app/code/community/Ip/Productactivity/Block/New.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Created on May 3, 2011
5
+ * Author Ivan Proskuryakov - volgodark@gmail.com - Magazento.com
6
+ * Copyright Proskuryakov Ivan. Magazento.com © 2011. All Rights Reserved.
7
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
8
+ */
9
+ ?>
10
+ <?php
11
+
12
+ class Ip_Productactivity_Block_New extends Mage_Catalog_Block_Product_Abstract {
13
+
14
+
15
+
16
+
17
+ protected function _construct() {
18
+
19
+ $data = Mage::helper('productactivity')->getCurrentCategory();
20
+ $this->addData(array(
21
+ 'cache_lifetime' => 86400,
22
+ 'cache_tags' => array("ip_productactivity_home_new" ."_".$data['category'].'_'.Mage::app()->getStore()->getId()),
23
+ 'cache_key' => "ip_productactivity_home_new".'_'.$data['route'].'_'.$data['category'].'_'.Mage::app()->getStore()->getId(),
24
+ ));
25
+ }
26
+
27
+
28
+
29
+
30
+
31
+ protected function _beforeToHtml() {
32
+
33
+ $collection = Mage::getResourceModel('catalog/product_collection');
34
+ $from = Mage::getStoreConfig('productactivity/new/from');
35
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
36
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
37
+ $newDate = $this->getModel()->getSellDate($this->getModel()->getProductactivityDaysLimit());
38
+ $collection = $this->_addProductAttributesAndPrices($collection)
39
+ ->addStoreFilter()
40
+ ->addAttributeToFilter(array(
41
+ array('attribute' => 'created_at', 'from' => $from, 'to' => $newDate['todaydate'])
42
+ ))
43
+ ->setPageSize($this->getModel()->getNewCount())
44
+ ->setCurPage(1)
45
+ ;
46
+
47
+ $data = Mage::helper('productactivity')->getCurrentCategory();
48
+
49
+ if ($data['category'] > 0) {
50
+ $category = $this->getModel()->getCategory($data['category']);
51
+ $collection->addCategoryFilter($category);
52
+ }
53
+
54
+ $this->setProductCollection($collection);
55
+ }
56
+
57
+ public function getModel() {
58
+ return Mage::getModel('productactivity/Data');
59
+ }
60
+
61
+ }
app/code/community/Ip/Productactivity/Block/Popular.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on May 3, 2011
4
+ * Author Ivan Proskuryakov - volgodark@gmail.com - Magazento.com
5
+ * Copyright Proskuryakov Ivan. Magazento.com © 2011. All Rights Reserved.
6
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
7
+ */
8
+ ?>
9
+ <?php
10
+
11
+ class Ip_Productactivity_Block_Popular extends Mage_Catalog_Block_Product_Abstract {
12
+
13
+
14
+ protected function _construct() {
15
+
16
+ $data = Mage::helper('productactivity')->getCurrentCategory();
17
+ $this->addData(array(
18
+ 'cache_lifetime' => 86400,
19
+ 'cache_tags' => array("ip_productactivity_home_popular" ."_".$data['category'].'_'.Mage::app()->getStore()->getId()),
20
+ 'cache_key' => "ip_productactivity_home_popular".'_'.$data['route'].'_'.$data['category'].'_'.Mage::app()->getStore()->getId(),
21
+ ));
22
+ }
23
+
24
+
25
+
26
+
27
+ protected function _beforeToHtml() {
28
+ $storeId = Mage::app()->getStore()->getId();
29
+ $collection = Mage::getResourceModel('reports/product_collection')
30
+ ->addOrderedQty()
31
+ ->addAttributeToSelect('*')
32
+ ->addAttributeToSelect(array('name', 'price', 'small_image')) //edit to suit tastes
33
+ ->setStoreId($storeId)
34
+ ->addStoreFilter($storeId)
35
+ ->addViewsCount();
36
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
37
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
38
+ $collection->setPageSize($this->getModel()->getPopularCount())->setCurPage(1);
39
+
40
+
41
+
42
+ $data = Mage::helper('productactivity')->getCurrentCategory();
43
+ if ($data['category'] > 0) {
44
+ $category = $this->getModel()->getCategory($data['category']);
45
+ $collection->addCategoryFilter($category);
46
+ }
47
+
48
+
49
+ $this->setProductCollection($collection);
50
+ return parent::_beforeToHtml();
51
+ }
52
+
53
+ public function getModel() {
54
+ return Mage::getModel('productactivity/Data');
55
+ }
56
+
57
+ }
58
+
app/code/community/Ip/Productactivity/Block/Review.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on May 3, 2011
4
+ * Author Ivan Proskuryakov - volgodark@gmail.com - Magazento.com
5
+ * Copyright Proskuryakov Ivan. Magazento.com © 2011. All Rights Reserved.
6
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
7
+ */
8
+ ?>
9
+ <?php
10
+
11
+ class Ip_Productactivity_Block_Review extends Mage_Catalog_Block_Product_Abstract {
12
+
13
+ protected function _construct() {
14
+
15
+ $data = Mage::helper('productactivity')->getCurrentCategory();
16
+
17
+ $this->addData(array(
18
+ 'cache_lifetime' => 86400,
19
+ 'cache_tags' => array("ip_productactivity_home_review" ."_".$data['category'].'_'.Mage::app()->getStore()->getId()),
20
+ 'cache_key' => "ip_productactivity_home_review".'_'.$data['route'].'_'.$data['category'].'_'.Mage::app()->getStore()->getId(),
21
+ ));
22
+ }
23
+
24
+
25
+
26
+ function getReviewsData(){
27
+ $pending = 2;
28
+ $declined = 3;
29
+ $reviews = $this->getReviews();
30
+ $count = 0;
31
+ foreach ($reviews as $review){
32
+ if($review['status_id'] != $pending || $review['status_id'] != $declined){
33
+
34
+ $_product = Mage::getModel('catalog/product')->load($review->getData('entity_pk_value'));
35
+
36
+ $vals = $this->getRatingValues($review);
37
+ $allReviews[$count]['review_url'] = $review->getReviewUrl($review->getId());
38
+ $allReviews[$count]['product_id'] = $review->getData('entity_pk_value');
39
+ $allReviews[$count]['product'] = $_product;
40
+
41
+ $num = $count +1;
42
+ $allReviews[$count]['title'] = $num.'. '.$review['title'];
43
+ $allReviews[$count]['detail'] = $review['detail'];
44
+ $allReviews[$count]['nickname'] = $review['nickname'];
45
+ $allReviews[$count]['ratings'] = $vals;
46
+ $count++;
47
+ }
48
+ }
49
+
50
+ return $allReviews;
51
+ }
52
+ function getRatingValues(Mage_Review_Model_Review $review){
53
+ $avg = 0;
54
+ if( count($review->getRatingVotes()) ) {
55
+ $ratings = array();
56
+ $c = 0;
57
+ foreach( $review->getRatingVotes() as $rating ) {
58
+ $type = $rating->getRatingCode();
59
+ $pcnt = $rating->getPercent();
60
+ if($type){
61
+ $val[$c][$type] = $pcnt;
62
+
63
+ }
64
+ $ratings[] = $rating->getPercent();
65
+ }
66
+ $c++;
67
+ $avg = array_sum($ratings)/count($ratings);
68
+ }
69
+ return $val;
70
+ }
71
+
72
+ function getReviews() {
73
+ $reviews = Mage::getModel('review/review')->getResourceCollection();
74
+ $reviews->addStoreFilter( Mage::app()->getStore()->getId() )
75
+ ->addStatusFilter( Mage_Review_Model_Review::STATUS_APPROVED )
76
+ ->setDateOrder()
77
+ ->addRateVotes()
78
+ ->load();
79
+
80
+
81
+
82
+
83
+
84
+
85
+ // -------------------------------
86
+ //
87
+ //products
88
+
89
+ $data = Mage::helper('productactivity')->getCurrentCategory();
90
+ $catId = $data['category'];
91
+
92
+ if ($catId > 0) {
93
+ $category = $this -> getModel() -> getCategory($catId);
94
+ $collection = Mage::getModel('catalog/product')
95
+ -> getCollection()
96
+ -> addStoreFilter()
97
+ -> setOrder($order, 'ASC')
98
+ -> addAttributeToSelect('entity_id')
99
+ -> addCategoryFilter($category)
100
+ -> addAttributeToFilter('status', array('eq' => '1'));
101
+
102
+ //category filter
103
+
104
+
105
+ $product_array = array();
106
+ foreach ($collection as $_product) {
107
+ $product_array[] = $_product -> getId();
108
+ }
109
+ $return = array();
110
+ $i = 0;
111
+ foreach ($reviews as $review) {
112
+ if (in_array($review->getData('entity_pk_value'), $product_array)) {
113
+ $return[] = $review;
114
+ $i++;
115
+ }
116
+ if ($i == $this -> getModel() -> getReviewsCount()) break;
117
+ }
118
+
119
+
120
+ } else {
121
+
122
+ // -------------------------------
123
+ $return = array();
124
+ $i=0;
125
+ foreach ( $reviews as $review) {
126
+ $return[] = $review;
127
+ $i++; if ($i == $this->getModel()->getReviewsCount()) break;
128
+
129
+ }
130
+ }
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+ return $return;
143
+ }
144
+
145
+
146
+
147
+ public function getModel() {
148
+ return Mage::getModel('productactivity/Data');
149
+ }
150
+
151
+ }
152
+
app/code/community/Ip/Productactivity/Block/Toprated.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on May 3, 2011
4
+ * Author Ivan Proskuryakov - volgodark@gmail.com - Magazento.com
5
+ * Copyright Proskuryakov Ivan. Magazento.com © 2011. All Rights Reserved.
6
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
7
+ */
8
+ ?>
9
+ <?php
10
+ class Ip_Productactivity_Block_Toprated extends Mage_Catalog_Block_Product_Abstract {
11
+
12
+ protected function _construct() {
13
+
14
+ $data = Mage::helper('productactivity')->getCurrentCategory();
15
+
16
+ $this->addData(array(
17
+ 'cache_lifetime' => 86400,
18
+ 'cache_tags' => array("ip_productactivity_home_toprated" ."_".$data['category'].'_'.Mage::app()->getStore()->getId()),
19
+ 'cache_key' => "ip_productactivity_home_toprated".'_'.$data['route'].'_'.$data['category'].'_'.Mage::app()->getStore()->getId(),
20
+ ));
21
+
22
+
23
+ }
24
+
25
+
26
+ public function getTopRatedProduct() {
27
+ $limit = $this->getModel()->getTopratedCount();
28
+ $collection = Mage::getModel('catalog/product')->getCollection();
29
+ $collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
30
+ $collection->addAttributeToSelect('*')->addStoreFilter();
31
+
32
+
33
+ $data = Mage::helper('productactivity')->getCurrentCategory();
34
+ if ($data['category'] > 0) {
35
+ $category = $this->getModel()->getCategory($data['category']);
36
+ $collection->addCategoryFilter($category);
37
+ }
38
+
39
+
40
+ $_rating = array();
41
+ foreach($collection as $_product) {
42
+ $storeId = Mage::app()->getStore()->getId();
43
+ $_productRating = Mage::getModel('review/review_summary')
44
+ ->setStoreId($storeId)
45
+ ->load($_product->getId());
46
+ $_rating[] = array(
47
+ 'rating' => $_productRating['rating_summary'],
48
+ 'product' => $_product
49
+ );
50
+ }
51
+ arsort($_rating);
52
+ return array_slice($_rating, 0, $limit);
53
+ }
54
+
55
+ public function getModel() {
56
+ return Mage::getModel('productactivity/Data');
57
+ }
58
+
59
+ }
app/code/community/Ip/Productactivity/Block/Topsell.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on May 3, 2011
4
+ * Author Ivan Proskuryakov - volgodark@gmail.com - Magazento.com
5
+ * Copyright Proskuryakov Ivan. Magazento.com © 2011. All Rights Reserved.
6
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
7
+ */
8
+ ?>
9
+ <?php
10
+
11
+ class Ip_Productactivity_Block_Topsell extends Mage_Catalog_Block_Product_Abstract {
12
+
13
+ protected function _construct() {
14
+
15
+ $data = Mage::helper('productactivity')->getCurrentCategory();
16
+ $this->addData(array(
17
+ 'cache_lifetime' => 86400,
18
+ 'cache_tags' => array("ip_productactivity_home_topsell" ."_".$data['category'].'_'.Mage::app()->getStore()->getId()),
19
+ 'cache_key' => "ip_productactivity_home_topsell".'_'.$data['route'].'_'.$data['category'].'_'.Mage::app()->getStore()->getId(),
20
+ ));
21
+
22
+ }
23
+
24
+
25
+ protected function _beforeToHtml() {
26
+
27
+ $storeId = Mage::app()->getStore()->getId();
28
+ $sellDate=$this->getModel()->getSellDate($this->getModel()->getProductactivityDaysLimit());
29
+ $collection = Mage::getResourceModel('reports/product_sold_collection')
30
+ ->addOrderedQty()
31
+ ->setStoreId($storeId)
32
+ ->addStoreFilter($storeId)
33
+ ->setDateRange($sellDate['startdate'], $sellDate['todaydate']) //
34
+ ->addUrlRewrite()
35
+ // ->addAttributeToFilter('visibility', array('in' => array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)))
36
+ ->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
37
+ ->setOrder('ordered_qty', 'desc')
38
+ ->setPageSize($this->getModel()->getTopsellCount())
39
+ ->setCurPage(1)
40
+ ->setOrder('ordered_qty', 'desc');
41
+
42
+
43
+
44
+ $data = Mage::helper('productactivity')->getCurrentCategory();
45
+ if ($data['category'] > 0) {
46
+ $category = $this->getModel()->getCategory($data['category']);
47
+ $collection->addCategoryFilter($category);
48
+ }
49
+
50
+
51
+ $this->setProductCollection($collection);
52
+ return parent::_beforeToHtml();
53
+ }
54
+
55
+
56
+ public function getModel() {
57
+ return Mage::getModel('productactivity/Data');
58
+ }
59
+
60
+ }
61
+
62
+
app/code/community/Ip/Productactivity/Helper/Data.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Created on May 3, 2011
5
+ * Author Ivan Proskuryakov - volgodark@gmail.com - Magazento.com
6
+ * Copyright Proskuryakov Ivan. Magazento.com © 2011. All Rights Reserved.
7
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
8
+ */
9
+ ?>
10
+ <?php
11
+
12
+ class Ip_Productactivity_Helper_Data extends Mage_Core_Helper_Abstract {
13
+
14
+ public function getTitleNew() {
15
+ return Mage::getStoreConfig('productactivity/new/title');
16
+ }
17
+
18
+ public function getTitlePopular() {
19
+ return Mage::getStoreConfig('productactivity/popular/title');
20
+ }
21
+
22
+ public function getTitleReview() {
23
+ return Mage::getStoreConfig('productactivity/review/title');
24
+ }
25
+
26
+ public function getTitleToprated() {
27
+ return Mage::getStoreConfig('productactivity/toprated/title');
28
+ }
29
+
30
+ public function getTitleTopSell() {
31
+ return Mage::getStoreConfig('productactivity/topsell/title');
32
+ }
33
+
34
+ public function getCurrentCategory() {
35
+
36
+ if (Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms') {
37
+ return array('route' => 'page', 'category' => 0);
38
+ }
39
+
40
+ if (Mage::registry('current_product') != null) {
41
+ $_category = Mage::registry('current_product')->getCategoryIds();
42
+ return array('route' => 'product', 'category' => $_category[0]);
43
+ }
44
+ //
45
+ if (Mage::registry('current_category') != null) {
46
+ return array('route' => 'catalog', 'category' => Mage::registry('current_category')->getId());
47
+ }
48
+ }
49
+
50
+ }
app/code/community/Ip/Productactivity/Model/Data.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on May 3, 2011
4
+ * Author Ivan Proskuryakov - volgodark@gmail.com - Magazento.com
5
+ * Copyright Proskuryakov Ivan. Magazento.com © 2011. All Rights Reserved.
6
+ * Single Use, Limited Licence and Single Use No Resale Licence ["Single Use"]
7
+ */
8
+ ?>
9
+ <?php
10
+ Class Ip_Productactivity_Model_Data {
11
+
12
+
13
+ public function getSellDate($days) {
14
+ $product = Mage::getModel('catalog/product');
15
+ $product=array();
16
+ $outputFormat='Y-m-d H:i:s';
17
+ // $outputFormat = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
18
+ // var_dump($outputFormat);
19
+ // $dateFormatIso = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
20
+ // $dateformat=Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
21
+ $product['todaydate'] = date($outputFormat, time());
22
+ $product['startdate'] = date($outputFormat, time() - 60 * 60 * 24 * $days);
23
+ return $product;
24
+
25
+ }
26
+
27
+ public function getCategory ($id){
28
+ $categoryId = $id;
29
+ if (!$categoryId || !is_numeric($categoryId))
30
+ $category = Mage::registry("current_category");
31
+ else {
32
+ $category = Mage::getModel("catalog/category")->load($categoryId);
33
+ if (!$category->getId())
34
+ $category = Mage::registry("current_category");
35
+ }
36
+ return $category;
37
+ }
38
+
39
+
40
+ public function getReviewsCount() {
41
+ $count = (int) Mage::getStoreConfig('productactivity/review/count');
42
+ if ($count <=0) $count=5;
43
+ return $count;
44
+ }
45
+ public function getTopsellCount() {
46
+ $count = (int) Mage::getStoreConfig('productactivity/topsell/count');
47
+ if ($count <=0) $count=5;
48
+ return $count;
49
+ }
50
+
51
+ public function getNewCount() {
52
+ $count = (int) Mage::getStoreConfig('productactivity/new/count');
53
+ if ($count <=0) $count=5;
54
+ return $count;
55
+ }
56
+
57
+ public function getPopularCount() {
58
+ $count = (int) Mage::getStoreConfig('productactivity/popular/count');
59
+ if ($count <=0) $count=5;
60
+ return $count;
61
+ }
62
+ public function getTopratedCount() {
63
+ $count = (int) Mage::getStoreConfig('productactivity/toprated/count');
64
+ if ($count <=0) $count=5;
65
+ return $count;
66
+ }
67
+
68
+ public function getProductactivityDaysLimit() {
69
+ $count = (int) Mage::getStoreConfig('productactivity/topsell/days');
70
+ if ($count <=0) $count=5;
71
+ return $count;
72
+ }
73
+
74
+
75
+
76
+
77
+ }
app/code/community/Ip/Productactivity/etc/config.xml ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <config>
3
+ <modules>
4
+ <Ip_Productactivity>
5
+ <version>1.0.1</version>
6
+ </Ip_Productactivity>
7
+ </modules>
8
+ <frontend>
9
+ <layout>
10
+ <updates>
11
+ <productactivity>
12
+ <file>ip_productactivity.xml</file>
13
+ </productactivity>
14
+ </updates>
15
+ </layout>
16
+ <!-- <translate>
17
+ <modules>
18
+ <Ip_Productactivity>
19
+ <files>
20
+ <default>Ip_Productactivity.csv</default>
21
+ </files>
22
+ </Ip_Productactivity>
23
+ </modules>
24
+ </translate>-->
25
+ </frontend>
26
+
27
+ <global>
28
+ <models>
29
+ <productactivity>
30
+ <class>Ip_Productactivity_Model</class>
31
+ <resourceModel>productactivity_mysql4</resourceModel>
32
+ </productactivity>
33
+ </models>
34
+ <resources>
35
+ <productactivity_setup>
36
+ <setup>
37
+ <module>Ip_Productactivity</module>
38
+ </setup>
39
+ <connection>
40
+ <use>core_setup</use>
41
+ </connection>
42
+ </productactivity_setup>
43
+ <productactivity_write>
44
+ <connection>
45
+ <use>core_write</use>
46
+ </connection>
47
+ </productactivity_write>
48
+ <productactivity_read>
49
+ <connection>
50
+ <use>core_read</use>
51
+ </connection>
52
+ </productactivity_read>
53
+ </resources>
54
+ <blocks>
55
+ <productactivity>
56
+ <class>Ip_Productactivity_Block</class>
57
+ </productactivity>
58
+ </blocks>
59
+ <helpers>
60
+ <productactivity>
61
+ <class>Ip_Productactivity_Helper</class>
62
+ </productactivity>
63
+ </helpers>
64
+ </global>
65
+ <admin>
66
+ <routers>
67
+ <ip_productactivity>
68
+ <use>admin</use>
69
+ <args>
70
+ <module>Ip_Productactivity</module>
71
+ <frontName>productactivity</frontName>
72
+ </args>
73
+ </ip_productactivity>
74
+ </routers>
75
+ </admin>
76
+ <adminhtml>
77
+ <acl>
78
+ <resources>
79
+ <admin>
80
+ <children>
81
+ <system>
82
+ <children>
83
+ <config>
84
+ <children>
85
+ <productactivity translate="title" module="productactivity">
86
+ <title>Productactivity</title>
87
+ </productactivity>
88
+ </children>
89
+ </config>
90
+ </children>
91
+ </system>
92
+ </children>
93
+ </admin>
94
+ </resources>
95
+ </acl>
96
+ <!-- <menu>
97
+ <ip translate="title" module="productactivity">
98
+ <title>Ip</title>
99
+ <sort_order>65</sort_order>
100
+ <children>
101
+ <productactivity translate="title" module="productactivity">
102
+ <title>Productactivity</title>
103
+ <sort_order>65</sort_order>
104
+ <children>
105
+ <settings translate="title" module="productactivity">
106
+ <title>Settings</title>
107
+ <action>adminhtml/system_config/edit/section/productactivity</action>
108
+ <sort_order>40</sort_order>
109
+ </settings>
110
+ </children>
111
+ </productactivity>
112
+ </children>
113
+ </ip>
114
+ </menu>-->
115
+ </adminhtml>
116
+ <default>
117
+ <productactivity>
118
+ <options>
119
+ <actions>1</actions>
120
+ <price>1</price>
121
+ <salable>1</salable>
122
+ <noproduct>There are no products that match your criteria. Please try again with different options.</noproduct>
123
+ <count>5</count>
124
+ </options>
125
+ <topsell>
126
+ <enable>1</enable>
127
+ <title>TOPSELLERS</title>
128
+ <count>5</count>
129
+ <days>365</days>
130
+ </topsell>
131
+ <new>
132
+ <enable>1</enable>
133
+ <title>NEW PRODUCTS</title>
134
+ <count>5</count>
135
+ <from>2007-08-23</from>
136
+ </new>
137
+ <popular>
138
+ <enable>1</enable>
139
+ <title>POPULAR PRODUCTS</title>
140
+ <count>5</count>
141
+ </popular>
142
+ <toprated>
143
+ <enable>1</enable>
144
+ <title>TOPRATED PRODUCTS</title>
145
+ <count>5</count>
146
+ </toprated>
147
+ <review>
148
+ <enable>1</enable>
149
+ <title>OUR LAST 5 REVIEWS</title>
150
+ <count>5</count>
151
+ </review>
152
+ </productactivity>
153
+ </default>
154
+ </config>
app/code/community/Ip/Productactivity/etc/system.xml ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <ip translate="label">
5
+ <label>Magazento.com</label>
6
+ <sort_order>250</sort_order>
7
+ </ip>
8
+ </tabs>
9
+ <sections>
10
+ <productactivity translate="label" module="productactivity">
11
+ <label>Bestsellers - All In One</label>
12
+ <tab>magazento</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>100</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <developer>
20
+ <frontend_model>productactivity/developer</frontend_model>
21
+ <sort_order>999</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ </developer>
26
+ <options translate="label">
27
+ <label>General</label>
28
+ <frontend_type>text</frontend_type>
29
+ <sort_order>2</sort_order>
30
+ <show_in_default>1</show_in_default>
31
+ <show_in_website>1</show_in_website>
32
+ <show_in_store>1</show_in_store>
33
+ <fields>
34
+ <price translate="label">
35
+ <label>Display price</label>
36
+ <frontend_type>select</frontend_type>
37
+ <source_model>adminhtml/system_config_source_yesno</source_model>
38
+ <sort_order>53</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
+ </price>
43
+ <actions translate="label">
44
+ <label>Display actions</label>
45
+ <frontend_type>select</frontend_type>
46
+ <source_model>adminhtml/system_config_source_yesno</source_model>
47
+ <sort_order>54</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ </actions>
52
+ <salable translate="label">
53
+ <label>Salable products</label>
54
+ <frontend_type>select</frontend_type>
55
+ <source_model>adminhtml/system_config_source_yesno</source_model>
56
+ <sort_order>55</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ </salable>
61
+ <noproduct translate="label">
62
+ <label>No product text</label>
63
+ <frontend_type>text</frontend_type>
64
+ <sort_order>66</sort_order>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>1</show_in_website>
67
+ <show_in_store>1</show_in_store>
68
+ </noproduct>
69
+ <count translate="label">
70
+ <label>Row count</label>
71
+ <frontend_type>text</frontend_type>
72
+ <sort_order>68</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>1</show_in_store>
76
+ </count>
77
+ </fields>
78
+ </options>
79
+ <topsell translate="label">
80
+ <label>Topsellers</label>
81
+ <frontend_type>text</frontend_type>
82
+ <sort_order>2</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>1</show_in_store>
86
+ <fields>
87
+ <enable translate="label">
88
+ <label>Enable</label>
89
+ <frontend_type>select</frontend_type>
90
+ <source_model>adminhtml/system_config_source_yesno</source_model>
91
+ <sort_order>51</sort_order>
92
+ <show_in_default>1</show_in_default>
93
+ <show_in_website>1</show_in_website>
94
+ <show_in_store>1</show_in_store>
95
+ </enable>
96
+ <title translate="label">
97
+ <label>Title</label>
98
+ <frontend_type>text</frontend_type>
99
+ <sort_order>56</sort_order>
100
+ <show_in_default>1</show_in_default>
101
+ <show_in_website>1</show_in_website>
102
+ <show_in_store>1</show_in_store>
103
+ </title>
104
+ <count translate="label">
105
+ <label>Count</label>
106
+ <frontend_type>text</frontend_type>
107
+ <sort_order>62</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>
111
+ </count>
112
+ <days translate="label">
113
+ <label>Topseller for * days</label>
114
+ <frontend_type>text</frontend_type>
115
+ <sort_order>63</sort_order>
116
+ <show_in_default>1</show_in_default>
117
+ <show_in_website>1</show_in_website>
118
+ <show_in_store>1</show_in_store>
119
+ </days>
120
+ </fields>
121
+ </topsell>
122
+ <new translate="label">
123
+ <label>New Products</label>
124
+ <frontend_type>text</frontend_type>
125
+ <sort_order>3</sort_order>
126
+ <show_in_default>1</show_in_default>
127
+ <show_in_website>1</show_in_website>
128
+ <show_in_store>1</show_in_store>
129
+ <fields>
130
+ <enable translate="label">
131
+ <label>Enable</label>
132
+ <frontend_type>select</frontend_type>
133
+ <source_model>adminhtml/system_config_source_yesno</source_model>
134
+ <sort_order>51</sort_order>
135
+ <show_in_default>1</show_in_default>
136
+ <show_in_website>1</show_in_website>
137
+ <show_in_store>1</show_in_store>
138
+ </enable>
139
+ <title translate="label">
140
+ <label>Title</label>
141
+ <frontend_type>text</frontend_type>
142
+ <sort_order>56</sort_order>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>1</show_in_website>
145
+ <show_in_store>1</show_in_store>
146
+ </title>
147
+ <count translate="label">
148
+ <label>Count</label>
149
+ <frontend_type>text</frontend_type>
150
+ <sort_order>62</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
+ </count>
155
+ <from translate="label">
156
+ <label>New from</label>
157
+ <frontend_type>text</frontend_type>
158
+ <sort_order>63</sort_order>
159
+ <show_in_default>1</show_in_default>
160
+ <show_in_website>1</show_in_website>
161
+ <show_in_store>1</show_in_store>
162
+ </from>
163
+ </fields>
164
+ </new>
165
+ <popular translate="label">
166
+ <label>Popular Products</label>
167
+ <frontend_type>text</frontend_type>
168
+ <sort_order>4</sort_order>
169
+ <show_in_default>1</show_in_default>
170
+ <show_in_website>1</show_in_website>
171
+ <show_in_store>1</show_in_store>
172
+ <fields>
173
+ <enable translate="label">
174
+ <label>Enable</label>
175
+ <frontend_type>select</frontend_type>
176
+ <source_model>adminhtml/system_config_source_yesno</source_model>
177
+ <sort_order>51</sort_order>
178
+ <show_in_default>1</show_in_default>
179
+ <show_in_website>1</show_in_website>
180
+ <show_in_store>1</show_in_store>
181
+ </enable>
182
+ <title translate="label">
183
+ <label>Title</label>
184
+ <frontend_type>text</frontend_type>
185
+ <sort_order>56</sort_order>
186
+ <show_in_default>1</show_in_default>
187
+ <show_in_website>1</show_in_website>
188
+ <show_in_store>1</show_in_store>
189
+ </title>
190
+ <count translate="label">
191
+ <label>Count</label>
192
+ <frontend_type>text</frontend_type>
193
+ <sort_order>62</sort_order>
194
+ <show_in_default>1</show_in_default>
195
+ <show_in_website>1</show_in_website>
196
+ <show_in_store>1</show_in_store>
197
+ </count>
198
+ </fields>
199
+ </popular>
200
+
201
+ <toprated translate="label">
202
+ <label>Toprated Products</label>
203
+ <frontend_type>text</frontend_type>
204
+ <sort_order>4</sort_order>
205
+ <show_in_default>1</show_in_default>
206
+ <show_in_website>1</show_in_website>
207
+ <show_in_store>1</show_in_store>
208
+ <fields>
209
+ <enable translate="label">
210
+ <label>Enable</label>
211
+ <frontend_type>select</frontend_type>
212
+ <source_model>adminhtml/system_config_source_yesno</source_model>
213
+ <sort_order>51</sort_order>
214
+ <show_in_default>1</show_in_default>
215
+ <show_in_website>1</show_in_website>
216
+ <show_in_store>1</show_in_store>
217
+ </enable>
218
+ <title translate="label">
219
+ <label>Title</label>
220
+ <frontend_type>text</frontend_type>
221
+ <sort_order>56</sort_order>
222
+ <show_in_default>1</show_in_default>
223
+ <show_in_website>1</show_in_website>
224
+ <show_in_store>1</show_in_store>
225
+ </title>
226
+ <count translate="label">
227
+ <label>Count</label>
228
+ <frontend_type>text</frontend_type>
229
+ <sort_order>62</sort_order>
230
+ <show_in_default>1</show_in_default>
231
+ <show_in_website>1</show_in_website>
232
+ <show_in_store>1</show_in_store>
233
+ </count>
234
+ </fields>
235
+ </toprated>
236
+ <review translate="label">
237
+ <label>Reviews</label>
238
+ <frontend_type>text</frontend_type>
239
+ <sort_order>7</sort_order>
240
+ <show_in_default>1</show_in_default>
241
+ <show_in_website>1</show_in_website>
242
+ <show_in_store>1</show_in_store>
243
+ <fields>
244
+ <enable translate="label">
245
+ <label>Enable</label>
246
+ <frontend_type>select</frontend_type>
247
+ <source_model>adminhtml/system_config_source_yesno</source_model>
248
+ <sort_order>51</sort_order>
249
+ <show_in_default>1</show_in_default>
250
+ <show_in_website>1</show_in_website>
251
+ <show_in_store>1</show_in_store>
252
+ </enable>
253
+ <title translate="label">
254
+ <label>Title</label>
255
+ <frontend_type>text</frontend_type>
256
+ <sort_order>56</sort_order>
257
+ <show_in_default>1</show_in_default>
258
+ <show_in_website>1</show_in_website>
259
+ <show_in_store>1</show_in_store>
260
+ </title>
261
+ <count translate="label">
262
+ <label>Count</label>
263
+ <frontend_type>text</frontend_type>
264
+ <sort_order>62</sort_order>
265
+ <show_in_default>1</show_in_default>
266
+ <show_in_website>1</show_in_website>
267
+ <show_in_store>1</show_in_store>
268
+ </count>
269
+ </fields>
270
+ </review>
271
+ </groups>
272
+ </productactivity>
273
+ </sections>
274
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Magazento_Productivity</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Show best, popular, new reviews and new products and reviews to your customers</summary>
10
+ <description>Show best, popular, new reviews and new products and reviews to your customers</description>
11
+ <notes>test community release</notes>
12
+ <authors><author><name>volgodark</name><user>auto-converted</user><email>volgodark@gmail.com</email></author></authors>
13
+ <date>2012-12-03</date>
14
+ <time>22:17:50</time>
15
+ <contents><target name="magecommunity"><dir name="Ip"><dir name="Productactivity"><dir name="Block"><file name="Developer.php" hash="e779bd431338e7f703148338ef02fdc4"/><file name="New.php" hash="c05d663f09f242ef8bbdf04dbf5925a9"/><file name="Popular.php" hash="d296c325bbc3fcd51d839e559e0baa6b"/><file name="Review.php" hash="d79ceddd7d74c6cf77c94e7d04b808bc"/><file name="Toprated.php" hash="413c113f5849eb5b055fc071d3df33c2"/><file name="Topsell.php" hash="a3172ab702d3e7ef2c5844407098cfd9"/></dir><dir name="Helper"><file name="Data.php" hash="ca7d799b81f41b7098e04ce0daefaa8d"/></dir><dir name="Model"><file name="Data.php" hash="0f41804ab583e2fef0eae3e98e7810b4"/></dir><dir name="etc"><file name="config.xml" hash="c1974d781b7e2eae921b158c249cd929"/><file name="system.xml" hash="aacdce560d44c6c8b2bb29176168924d"/></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>