MD_FeaturedProducts - Version 1.0.0

Version Notes

please contact us : support@mage-designer.com

Download this release

Release Info

Developer OSWorld
Extension MD_FeaturedProducts
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (31) hide show
  1. app/code/local/MD/Featuredproducts/Block/Adminhtml/Edit.php +92 -0
  2. app/code/local/MD/Featuredproducts/Block/Adminhtml/Edit/Grid.php +322 -0
  3. app/code/local/MD/Featuredproducts/Block/Adminhtml/Edit/Renderer/Visibility.php +22 -0
  4. app/code/local/MD/Featuredproducts/Block/Catalog/Product/View.php +86 -0
  5. app/code/local/MD/Featuredproducts/Block/Catalog/Product/View/Media.php +5 -0
  6. app/code/local/MD/Featuredproducts/Block/List.php +139 -0
  7. app/code/local/MD/Featuredproducts/Block/Page/Html.php +16 -0
  8. app/code/local/MD/Featuredproducts/Block/Page/Html/Head.php +113 -0
  9. app/code/local/MD/Featuredproducts/Block/Product/List.php +93 -0
  10. app/code/local/MD/Featuredproducts/Helper/Data.php +20 -0
  11. app/code/local/MD/Featuredproducts/Model/System/Config/Source/Selectmode.php +11 -0
  12. app/code/local/MD/Featuredproducts/Model/System/Config/Source/Sort.php +15 -0
  13. app/code/local/MD/Featuredproducts/controllers/Adminhtml/FeaturedController.php +97 -0
  14. app/code/local/MD/Featuredproducts/controllers/IndexController.php +23 -0
  15. app/code/local/MD/Featuredproducts/controllers/ProductController.php +134 -0
  16. app/code/local/MD/Featuredproducts/etc/adminhtml.xml +47 -0
  17. app/code/local/MD/Featuredproducts/etc/config.xml +100 -0
  18. app/code/local/MD/Featuredproducts/etc/system.xml +156 -0
  19. app/code/local/MD/Featuredproducts/sql/featuredproducts_setup/mysql4-install-0.1.0.php +30 -0
  20. app/code/local/MD/Featuredproducts/sql/featuredproducts_setup/mysql4-install-1.0.1.php +32 -0
  21. app/code/local/MD/Featuredproducts/sql/featuredproducts_setup/mysql4-upgrade-1.0.1-1.1.1.php +9 -0
  22. app/code/local/MD/Featuredproducts/sql/featuredproducts_setup/mysql4-upgrade-1.0.1-1.1.3.php +9 -0
  23. app/code/local/MD/Featuredproducts/sql/featuredproducts_setup/mysql4-upgrade-1.1.3-1.2.0.php +8 -0
  24. app/code/local/MD/Featuredproducts/sql/featuredproducts_setup/mysql4-upgrade-1.2.0-1.2.1.php +37 -0
  25. app/code/local/MD/Featuredproducts/sql/featuredproducts_setup/mysql4-upgrade-1.2.1-1.2.2.php +8 -0
  26. app/code/local/MD/Featuredproducts/sql/featuredproducts_setup/mysql4-upgrade-1.2.2-1.2.3.php +8 -0
  27. app/design/frontend/default/default/layout/md_featuredproducts.xml +33 -0
  28. app/design/frontend/default/default/template/md/featuredproducts/list.phtml +101 -0
  29. app/etc/modules/MD_Featuredproducts.xml +17 -0
  30. package.xml +20 -0
  31. readme.txt +29 -0
app/code/local/MD/Featuredproducts/Block/Adminhtml/Edit.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class MD_Featuredproducts_Block_Adminhtml_Edit extends Mage_Adminhtml_Block_Widget_Grid_Container {
5
+
6
+ protected $_saveButtonLabel = 'Save Featured Products';
7
+ protected $_inchooUrl = 'http://www.mage-designer.com/';
8
+
9
+ public function __construct() {
10
+
11
+
12
+ $this->_blockGroup = 'featuredproducts';
13
+ $this->_controller = 'adminhtml_edit';
14
+
15
+
16
+ $this->_headerText = Mage::helper('adminhtml')->__('Featured products');
17
+
18
+ parent::__construct();
19
+
20
+ $this->_removeButton('add');
21
+
22
+ $this->_addButton('save', array(
23
+ 'label' => $this->_saveButtonLabel,
24
+ 'onclick' => 'categorySubmit(\'' . $this->getSaveUrl() . '\')',
25
+ 'class' => 'Save',
26
+ ));
27
+ }
28
+
29
+ public function getSaveUrl() {
30
+ return $this->getUrl('*/*/save', array('store' => $this->getRequest()->getParam('store')));
31
+ }
32
+
33
+ protected function _afterToHtml($html) {
34
+ return $this->_prependHtml() . parent::_afterToHtml($html) . $this->_appendHtml();
35
+ }
36
+
37
+ private function _prependHtml() {
38
+ $html = '
39
+
40
+ <form id="featured_edit_form" action="' . $this->getSaveUrl() . '" method="post" enctype="multipart/form-data">
41
+ <input name="form_key" type="hidden" value="' . $this->getFormKey() . '" />
42
+ <div class="no-display">
43
+ <input type="hidden" name="featured_products" id="in_featured_products" value="" />
44
+ </div>
45
+ </form>
46
+ ';
47
+
48
+ return $html;
49
+ }
50
+
51
+ private function _appendHtml() {
52
+ $html =
53
+ '
54
+ <style type="text/css">
55
+ <!--
56
+ #logo_wrapp a{
57
+ display:block;
58
+ width:75px;
59
+ float:right;
60
+ padding:0px 0px 0px 0px;
61
+ margin:5px 0px 0px 0px;
62
+ background:url(' . $this->getSkinUrl('images/inchoo/inchoo-small-logo.png') . ') no-repeat 0px 0px;
63
+ text-indent: -9999px;
64
+ font-size: 0px;
65
+ line-height: 0px;
66
+ height:13px;
67
+ }
68
+ #logo_wrapp a:hover {background:url(' . $this->getSkinUrl('images/inchoo/inchoo-small-logo.png') . ') no-repeat 0px -13px; }
69
+ -->
70
+ </style>
71
+ <div style="text-align:right;">Community version of <a href="' . $this->_inchooUrl . '/ecommerce/magento/featured-products-on-magento-frontpage/" target="_blank">Featured Products Extension</a></div>
72
+ <div id="logo_wrapp"><a href="' . $this->_inchooUrl . '" target="_blank">Mage-Designer</a></div>
73
+ ';
74
+ return $html;
75
+ }
76
+
77
+ public function getHeaderHtml() {
78
+ return '<h3 style="background-image: url(' . $this->getSkinUrl('images/product_rating_full_star.gif') . ');" class="' . $this->getHeaderCssClass() . '">' . $this->getHeaderText() . '</h3>';
79
+ }
80
+
81
+ protected function _prepareLayout() {
82
+ $this->setChild('store_switcher', $this->getLayout()->createBlock('adminhtml/store_switcher', 'store_switcher')->setUseConfirm(false)
83
+ );
84
+ return parent::_prepareLayout();
85
+ }
86
+
87
+ public function getGridHtml() {
88
+
89
+ return $this->getChildHtml('store_switcher') . $this->getChildHtml('grid');
90
+ }
91
+
92
+ }
app/code/local/MD/Featuredproducts/Block/Adminhtml/Edit/Grid.php ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MD_Featuredproducts_Block_Adminhtml_Edit_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+
8
+ $this->setId('md_featured_products');
9
+ $this->setDefaultSort('entity_id');
10
+ $this->setUseAjax(true);
11
+
12
+ $this->setRowClickCallback('FeaturedRowClick');
13
+ }
14
+
15
+ public function getProduct() {
16
+ return Mage::registry('product');
17
+ }
18
+
19
+ protected function _getStore() {
20
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
21
+ return Mage::app()->getStore($storeId);
22
+ }
23
+
24
+ protected function _addColumnFilterToCollection($column) {
25
+
26
+ if ($this->getCollection()) {
27
+ if ($column->getId() == 'websites') {
28
+
29
+ $this->getCollection()->joinField('websites', 'catalog/product_website', 'website_id', 'product_id=entity_id', null, 'left');
30
+ }
31
+ }
32
+
33
+
34
+ if ($column->getId() == "featured") {
35
+ $productIds = $this->_getSelectedProducts();
36
+
37
+ if (empty($productIds)) {
38
+ $productIds = 0;
39
+ }
40
+ if ($column->getFilter()->getValue()) {
41
+ $this->getCollection()->addFieldToFilter('entity_id', array('in' => $productIds));
42
+ } elseif (!empty($productIds)) {
43
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin' => $productIds));
44
+ }
45
+ } else {
46
+
47
+ parent::_addColumnFilterToCollection($column);
48
+ }
49
+
50
+ return $this;
51
+ }
52
+
53
+ protected function _prepareCollection() {
54
+ $store = $this->_getStore();
55
+
56
+
57
+ $collection = Mage::getModel('catalog/product')->getCollection()
58
+ ->addAttributeToSelect('name')
59
+ ->addAttributeToSelect('sku')
60
+ ->addAttributeToSelect('md_featured_product')
61
+ ->addAttributeToSelect('type_id')
62
+ ->addAttributeToFilter('visibility', array('nin' => array(1,3)));
63
+
64
+
65
+ if ($store->getId()) {
66
+ //$collection->setStoreId($store->getId());
67
+ $collection->addStoreFilter($store);
68
+ $collection->joinAttribute('custom_name', 'catalog_product/name', 'entity_id', null, 'inner', $store->getId());
69
+ $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner', $store->getId());
70
+ $collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', 1, 'inner', $store->getId());
71
+ $collection->joinAttribute('price', 'catalog_product/price', 'entity_id', null, 'left', $store->getId());
72
+ } else {
73
+ $collection->addAttributeToSelect('price');
74
+ $collection->addAttributeToSelect('status');
75
+ $collection->addAttributeToSelect('visibility');
76
+ }
77
+
78
+
79
+
80
+ $this->setCollection($collection);
81
+
82
+
83
+
84
+ parent::_prepareCollection();
85
+
86
+ $this->getCollection()->addWebsiteNamesToResult();
87
+ return $this;
88
+ }
89
+
90
+ protected function _prepareColumns() {
91
+
92
+
93
+ $this->addColumn('featured', array(
94
+ 'header_css_class' => 'a-center',
95
+ 'type' => 'checkbox',
96
+ 'name' => 'featured',
97
+ 'values' => $this->_getSelectedProducts(),
98
+ 'align' => 'center',
99
+ 'index' => 'entity_id'
100
+ ));
101
+
102
+ $this->addColumn('entity_id', array(
103
+ 'header' => Mage::helper('catalog')->__('ID'),
104
+ 'sortable' => true,
105
+ 'width' => '60',
106
+ 'index' => 'entity_id'
107
+ ));
108
+
109
+ $this->addColumn('name', array(
110
+ 'header' => Mage::helper('catalog')->__('Name'),
111
+ 'index' => 'name'
112
+ ));
113
+
114
+ $this->addColumn('type',
115
+ array(
116
+ 'header'=> Mage::helper('catalog')->__('Type'),
117
+ 'width' => '60px',
118
+ 'index' => 'type_id',
119
+ 'type' => 'options',
120
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
121
+ ));
122
+
123
+ $this->addColumn('sku', array(
124
+ 'header' => Mage::helper('catalog')->__('SKU'),
125
+ 'width' => '140',
126
+ 'index' => 'sku'
127
+ ));
128
+
129
+ $this->addColumn('visibility', array(
130
+ 'header' => Mage::helper('catalog')->__('Visibility'),
131
+ 'width' => '140',
132
+ 'index' => 'visibility',
133
+ 'filter' => false,
134
+ 'renderer' => 'featuredproducts/adminhtml_edit_renderer_visibility',
135
+ ));
136
+
137
+ if (!Mage::app()->isSingleStoreMode()) {
138
+ $this->addColumn('websites', array(
139
+ 'header' => Mage::helper('catalog')->__('Websites'),
140
+ 'width' => '100px',
141
+ 'sortable' => false,
142
+ 'index' => 'websites',
143
+ 'type' => 'options',
144
+ 'options' => Mage::getModel('core/website')->getCollection()->toOptionHash(),
145
+ ));
146
+ }
147
+
148
+ /*
149
+ $this->addColumn('visibility',
150
+ array(
151
+ 'header'=> Mage::helper('catalog')->__('Visibility'),
152
+ 'width' => '70px',
153
+ 'index' => 'visibility',
154
+ 'type' => 'options',
155
+ 'options' => Mage::getModel('catalog/product_visibility')->getOptionArray(),
156
+ ));
157
+ */
158
+
159
+
160
+
161
+ $store = $this->_getStore();
162
+ $this->addColumn('price',
163
+ array(
164
+ 'header'=> Mage::helper('catalog')->__('Price'),
165
+ 'type' => 'price',
166
+ 'currency_code' => $store->getBaseCurrency()->getCode(),
167
+ 'index' => 'price',
168
+ ));
169
+
170
+ /*
171
+ $this->addColumn('price', array(
172
+ 'header' => Mage::helper('catalog')->__('Price'),
173
+ 'type' => 'currency',
174
+ 'width' => '1',
175
+ 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
176
+ 'index' => 'price'
177
+ ));
178
+ */
179
+
180
+
181
+
182
+ return parent::_prepareColumns();
183
+ }
184
+
185
+ public function getGridUrl() {
186
+ return $this->getUrl('*/*/grid', array('_current' => true));
187
+ }
188
+
189
+ protected function _getSelectedProducts($json=false) {
190
+ $temp = $this->getRequest()->getPost('featured_ids');
191
+ $store = $this->_getStore();
192
+
193
+ if ($temp) {
194
+ parse_str($temp, $featured_ids);
195
+ }
196
+
197
+ $_prod = Mage::getModel('catalog/product')->getCollection()
198
+ ->joinAttribute('md_featured_product', 'catalog_product/md_featured_product', 'entity_id', null, 'left', $store->getId())
199
+ ->addAttributeToFilter('md_featured_product', '1');
200
+
201
+ $products = $_prod->getColumnValues('entity_id');
202
+ $selected_products = array();
203
+
204
+
205
+ if ($json == true) {
206
+ foreach ($products as $key => $value) {
207
+ $selected_products[$value] = '1';
208
+ }
209
+ return Zend_Json::encode($selected_products);
210
+ } else {
211
+
212
+ foreach ($products as $key => $value) {
213
+ if ((isset($featured_ids[$value])) && ($featured_ids[$value] == 0)) {
214
+
215
+ }else
216
+ $selected_products[$value] = '0';
217
+ }
218
+
219
+ if (isset($featured_ids))
220
+ foreach ($featured_ids as $key => $value) {
221
+ if ($value == 1)
222
+ $selected_products[$key] = '0';
223
+ }
224
+
225
+ return array_keys($selected_products);
226
+ }
227
+
228
+ return $products;
229
+ }
230
+
231
+ //add javascript before/after grid html
232
+ protected function _afterToHtml($html) {
233
+ return $this->_prependHtml() . parent::_afterToHtml($html) . $this->_appendHtml();
234
+ }
235
+
236
+ private function _prependHtml() {
237
+ $gridName = $this->getJsObjectName();
238
+
239
+ $html =
240
+ <<<EndHTML
241
+ <script type="text/javascript">
242
+ //<![CDATA[
243
+
244
+ categoryForm = new varienForm('featured_edit_form');
245
+ categoryForm.submit= function (url) {
246
+
247
+ this._submit();
248
+
249
+ return true;
250
+
251
+
252
+ };
253
+
254
+ function categorySubmit(url) {
255
+
256
+ var params = {};
257
+ var fields = $('featured_edit_form').getElementsBySelector('input', 'select');
258
+
259
+ categoryForm.submit();
260
+ }
261
+
262
+ function FeaturedRowClick(grid, event)
263
+ {
264
+ var trElement = Event.findElement(event, 'tr');
265
+ var isInput = Event.element(event).tagName == 'INPUT';
266
+
267
+ var checkbox = Element.getElementsBySelector(trElement, 'input.checkbox').first();
268
+ if(!checkbox) return;
269
+
270
+ if(checkbox.checked) checkBoxes.set(checkbox.value, 1);
271
+ else checkBoxes.set(checkbox.value, 0);
272
+
273
+ //else checkBoxes.unset(checkbox.value);
274
+
275
+
276
+ $("in_featured_products").value = checkBoxes.toQueryString();
277
+ //console.log("Products", checkBoxes);
278
+ $gridName.reloadParams = {'featured_ids':checkBoxes.toQueryString()};
279
+ }
280
+
281
+ //]]>
282
+
283
+
284
+
285
+
286
+ </script>
287
+ EndHTML;
288
+
289
+ return $html;
290
+ }
291
+
292
+ private function _appendHtml() {
293
+ $html =
294
+ '
295
+ <script type="text/javascript">
296
+ var checkBoxes = $H();
297
+
298
+ var checkbox_all = $$("#md_featured_products_table thead input.checkbox").first();
299
+ var everycheckbox = $$("#md_featured_products_table tbody input.checkbox");
300
+
301
+ checkbox_all.observe("click", function(event) {
302
+
303
+ if(checkbox_all.checked)
304
+ {
305
+ everycheckbox.each(function(element, index) {
306
+ checkBoxes.set(element.value, 1)
307
+ });
308
+ } else
309
+ {
310
+ everycheckbox.each(function(element, index) {
311
+ checkBoxes.set(element.value, 0)
312
+ });
313
+ }
314
+ $("in_featured_products").value = checkBoxes.toQueryString();
315
+ });
316
+ </script>
317
+ ';
318
+
319
+ return $html;
320
+ }
321
+
322
+ }
app/code/local/MD/Featuredproducts/Block/Adminhtml/Edit/Renderer/Visibility.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MD_Featuredproducts_Block_Adminhtml_Edit_Renderer_Visibility extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
4
+ {
5
+ protected $_values;
6
+
7
+ /**
8
+ * Renders grid column
9
+ *
10
+ * @param Varien_Object $row
11
+ * @return string
12
+ */
13
+ public function render(Varien_Object $row)
14
+ {
15
+
16
+ $this->_values = Mage::getModel('catalog/product_visibility')->getOptionArray();
17
+
18
+ $html = $this->_values[$row->getData($this->getColumn()->getIndex())];
19
+
20
+ return $html;
21
+ }
22
+ }
app/code/local/MD/Featuredproducts/Block/Catalog/Product/View.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MD_FeaturedProducts_Block_Catalog_Product_View extends Mage_Catalog_Block_Product_View
4
+ {
5
+
6
+ public function getTemplate()
7
+ {
8
+ return 'md/featuredproducts/catalog/product/view.phtml';
9
+ }
10
+
11
+ public function _stripTags($var1,$var2,$var3)
12
+ {
13
+ if(Mage::getVersion() == '1.4.0.1'){
14
+ return $this->htmlEscape($var1,$var2,$var3);
15
+ }else{
16
+ return $this->stripTags($var1,$var2,$var3);
17
+ }
18
+ }
19
+ public function _getJsonConfig()
20
+ {
21
+ $config = array();
22
+ if (!$this->hasOptions()) {
23
+ return Mage::helper('core')->jsonEncode($config);
24
+ }
25
+
26
+ $_request = Mage::getSingleton('tax/calculation')->getRateRequest(false, false, false);
27
+ /* @var $product Mage_Catalog_Model_Product */
28
+ $product = $this->getProduct();
29
+ $_request->setProductClassId($product->getTaxClassId());
30
+ $defaultTax = Mage::getSingleton('tax/calculation')->getRate($_request);
31
+
32
+ $_request = Mage::getSingleton('tax/calculation')->getRateRequest();
33
+ $_request->setProductClassId($product->getTaxClassId());
34
+ $currentTax = Mage::getSingleton('tax/calculation')->getRate($_request);
35
+
36
+ $_regularPrice = $product->getPrice();
37
+ $_finalPrice = $product->getFinalPrice();
38
+ $_priceInclTax = Mage::helper('tax')->getPrice($product, $_finalPrice, true);
39
+ $_priceExclTax = Mage::helper('tax')->getPrice($product, $_finalPrice);
40
+ $_tierPrices = array();
41
+ $_tierPricesInclTax = array();
42
+ foreach ($product->getTierPrice() as $tierPrice) {
43
+ $_tierPrices[] = Mage::helper('core')->currency($tierPrice['website_price'], false, false);
44
+ $_tierPricesInclTax[] = Mage::helper('core')->currency(
45
+ Mage::helper('tax')->getPrice($product, (int)$tierPrice['website_price'], true),
46
+ false, false);
47
+ }
48
+ $config = array(
49
+ 'productId' => $product->getId(),
50
+ 'priceFormat' => Mage::app()->getLocale()->getJsPriceFormat(),
51
+ 'includeTax' => Mage::helper('tax')->priceIncludesTax() ? 'true' : 'false',
52
+ 'showIncludeTax' => Mage::helper('tax')->displayPriceIncludingTax(),
53
+ 'showBothPrices' => Mage::helper('tax')->displayBothPrices(),
54
+ 'productPrice' => Mage::helper('core')->currency($_finalPrice, false, false),
55
+ 'productOldPrice' => Mage::helper('core')->currency($_regularPrice, false, false),
56
+ 'priceInclTax' => Mage::helper('core')->currency($_priceInclTax, false, false),
57
+ 'priceExclTax' => Mage::helper('core')->currency($_priceExclTax, false, false),
58
+ /**
59
+ * @var skipCalculate
60
+ * @deprecated after 1.5.1.0
61
+ */
62
+ 'skipCalculate' => ($_priceExclTax != $_priceInclTax ? 0 : 1),
63
+ 'defaultTax' => $defaultTax,
64
+ 'currentTax' => $currentTax,
65
+ 'idSuffix' => '_cloneover',
66
+ 'oldPlusDisposition' => 0,
67
+ 'plusDisposition' => 0,
68
+ 'plusDispositionTax' => 0,
69
+ 'oldMinusDisposition' => 0,
70
+ 'minusDisposition' => 0,
71
+ 'tierPrices' => $_tierPrices,
72
+ 'tierPricesInclTax' => $_tierPricesInclTax,
73
+ );
74
+
75
+ $responseObject = new Varien_Object();
76
+ Mage::dispatchEvent('catalog_product_view_config', array('response_object'=>$responseObject));
77
+ if (is_array($responseObject->getAdditionalOptions())) {
78
+ foreach ($responseObject->getAdditionalOptions() as $option=>$value) {
79
+ $config[$option] = $value;
80
+ }
81
+ }
82
+
83
+ return Mage::helper('core')->jsonEncode($config);
84
+ }
85
+
86
+ }
app/code/local/MD/Featuredproducts/Block/Catalog/Product/View/Media.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class MD_FeaturedProducts_Block_Catalog_Product_View_Media extends Mage_Catalog_Block_Product_View_Media
4
+ {
5
+ }
app/code/local/MD/Featuredproducts/Block/List.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MD_FeaturedProducts_Block_List extends Mage_Catalog_Block_Product_List
4
+ {
5
+ protected $_productCollection;
6
+ protected $_sort_by;
7
+
8
+ const XML_PATH_QUICK = 'featuredproducts/viewsetting/enableview';
9
+ const XML_PATH_LIBRARY = 'featuredproducts/viewsetting/library';
10
+ const XML_PATH_DIALOG_WIDTH = 'featuredproducts/viewsetting/dialog_width';
11
+ const XML_PATH_DIALOG_HEIGHT = 'featuredproducts/viewsetting/dialog_height';
12
+ const XML_PATH_IS_MODAL = 'featuredproducts/viewsetting/is_modal';
13
+
14
+ /**
15
+ * Get dialog width
16
+ * @return int
17
+ */
18
+ public function getDialogWidth()
19
+ {
20
+ return Mage::getStoreConfig(self::XML_PATH_DIALOG_WIDTH);
21
+ }
22
+
23
+
24
+ /**
25
+ * Get dialog height
26
+ *
27
+ * @return int
28
+ */
29
+
30
+ public function getDialogHeight()
31
+ {
32
+ return Mage::getStoreConfig(self::XML_PATH_DIALOG_HEIGHT);
33
+ }
34
+
35
+ /**
36
+ * Get library
37
+ *
38
+ * @return int
39
+ */
40
+
41
+ public function getLibrary()
42
+ {
43
+ return Mage::getStoreConfig(self::XML_PATH_LIBRARY);
44
+ }
45
+
46
+
47
+
48
+ public function getQuickview()
49
+ {
50
+ return Mage::getStoreConfig(self::XML_PATH_QUICK);
51
+ }
52
+ /**
53
+ * Get is modal
54
+ *
55
+ * @return string
56
+ */
57
+ public function getIsModal()
58
+ {
59
+ return (Mage::getStoreConfig(self::XML_PATH_IS_MODAL) == '1' ? 'true' : 'false');
60
+ }
61
+
62
+ protected function _prepareLayout()
63
+ {
64
+ // if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) {
65
+ // $breadcrumbsBlock->addCrumb('home', array(
66
+ // 'label'=>Mage::helper('catalog')->__('Home'),
67
+ // 'title'=>Mage::helper('catalog')->__('Go to Home Page'),
68
+ // 'link'=>Mage::getBaseUrl()
69
+ // ));
70
+ // }
71
+
72
+ parent::_prepareLayout();
73
+ }
74
+
75
+ /*
76
+ * Remove "Position" option from Sort By dropdown
77
+ * */
78
+ protected function _beforeToHtml()
79
+ {
80
+ parent::_beforeToHtml();
81
+ $toolbar = $this->getToolbarBlock();
82
+ $toolbar->removeOrderFromAvailableOrders('position');
83
+ return $this;
84
+ }
85
+
86
+
87
+ /*
88
+ * Load featured products collection
89
+ * */
90
+ protected function _getProductCollection()
91
+ {
92
+ if (is_null($this->_productCollection)) {
93
+ $collection = Mage::getModel('catalog/product')->getCollection();
94
+
95
+ $attributes = Mage::getSingleton('catalog/config')
96
+ ->getProductAttributes();
97
+
98
+ $collection->addAttributeToSelect($attributes)
99
+ ->addMinimalPrice()
100
+ ->addFinalPrice()
101
+ ->addTaxPercents()
102
+ ->addAttributeToFilter('md_featured_product', 1, 'left')
103
+ ->addStoreFilter();
104
+
105
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
106
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
107
+ $this->_productCollection = $collection;
108
+ }
109
+ return $this->_productCollection;
110
+ }
111
+
112
+ /**
113
+ * Retrieve loaded featured products collection
114
+ *
115
+ * @return Mage_Eav_Model_Entity_Collection_Abstract
116
+ */
117
+ public function getFeaturedProductCollection()
118
+ {
119
+ return $this->_getProductCollection();
120
+ }
121
+
122
+ public function getColumgrid()
123
+ {
124
+ return Mage::getStoreConfig("featuredproducts/general/number_of_itemsgrid");
125
+ }
126
+
127
+
128
+ /**
129
+ * Get HTML if there's anything to show
130
+ */
131
+ protected function _toHtml()
132
+ {
133
+ if ($this->_getProductCollection()->count()){
134
+ return parent::_toHtml();
135
+ }
136
+ return '';
137
+ }
138
+
139
+ }
app/code/local/MD/Featuredproducts/Block/Page/Html.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MD_FeaturedProducts_Block_Page_Html extends Mage_Page_Block_Html
4
+ {
5
+
6
+ public function getTemplate()
7
+ {
8
+ if (empty($this->_template)) {
9
+ $this->_template = $this->_getData('template');
10
+ }
11
+ if ($this->_template == 'md/featuredProducts/page/empty.phtml') {
12
+ return 'md/featuredProducts/page/empty.phtml';
13
+ }
14
+ return $this->_template;
15
+ }
16
+ }
app/code/local/MD/Featuredproducts/Block/Page/Html/Head.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MD_FeaturedProducts_Block_Page_Html_Head extends Mage_Page_Block_Html_Head
4
+ {
5
+
6
+ public function addFirst($type, $name, $params=null, $if=null, $cond=null)
7
+ {
8
+ $_item = array(
9
+ $type.'/'.$name => array(
10
+ 'type' => $type,
11
+ 'name' => $name,
12
+ 'params' => $params,
13
+ 'if' => $if,
14
+ 'cond' => $cond)
15
+ );
16
+ $_head = $this->__getHeadBlock();
17
+ $_itemList = $_head->getData('items');
18
+ $_itemList = array_merge($_item, $_itemList);
19
+
20
+ $_head->setData('items', $_itemList);
21
+ }
22
+
23
+
24
+ public function addBefore($type, $name, $before=null, $params=null, $if=null, $cond=null)
25
+ {
26
+ if ($before) {
27
+ $_backItem = array();
28
+ $_searchStatus = false;
29
+ $_searchKey = $type.'/'.$before;
30
+ $_head = $this->__getHeadBlock();
31
+ $_itemList = $_head->getData('items');
32
+
33
+ if (is_array($_itemList)) {
34
+ $keyList = array_keys($_itemList);
35
+ foreach ($keyList as &$_key) {
36
+ if ($_searchKey == $_key) {
37
+ $_searchStatus = true;
38
+ }
39
+
40
+ if ($_searchStatus) {
41
+ $_backItem[$_key] = $_itemList[$_key];
42
+ unset($_itemList[$_key]);
43
+ }
44
+ }
45
+ }
46
+
47
+ if ($type==='skin_css' && empty($params)) {
48
+ $params = 'media="all"';
49
+ }
50
+ $_itemList[$type.'/'.$name] = array(
51
+ 'type' => $type,
52
+ 'name' => $name,
53
+ 'params' => $params,
54
+ 'if' => $if,
55
+ 'cond' => $cond,
56
+ );
57
+
58
+ if (is_array($_backItem)) {
59
+ $_itemList = array_merge($_itemList, $_backItem);
60
+ }
61
+
62
+ $_head->setData('items', $_itemList);
63
+ }
64
+ }
65
+
66
+
67
+ public function addAfter($type, $name, $after=null, $params=null, $if=null, $cond=null)
68
+ {
69
+ if ($after) {
70
+ $_backItem = array();
71
+ $_searchStatus = false;
72
+ $_searchKey = $type.'/'.$after;
73
+ $_head = $this->__getHeadBlock();
74
+ $_itemList = $_head->getData('items');
75
+ if (is_array($_itemList)) {
76
+ $keyList = array_keys($_itemList);
77
+ foreach ($keyList as &$_key) {
78
+ if ($_searchStatus) {
79
+ $_backItem[$_key] = $_itemList[$_key];
80
+ unset($_itemList[$_key]);
81
+ }
82
+ if ($_searchKey == $_key) {
83
+ $_searchStatus = true;
84
+ }
85
+ }
86
+ }
87
+
88
+ if ($type==='skin_css' && empty($params)) {
89
+ $params = 'media="all"';
90
+ }
91
+ $_itemList[$type.'/'.$name] = array(
92
+ 'type' => $type,
93
+ 'name' => $name,
94
+ 'params' => null,
95
+ 'if' => null,
96
+ 'cond' => null,
97
+ );
98
+
99
+ if (is_array($_backItem)) {
100
+ $_itemList = array_merge($_itemList, $_backItem);
101
+ }
102
+
103
+ $_head->setData('items', $_itemList);
104
+ }
105
+ }
106
+
107
+ /*
108
+ * Get head block
109
+ */
110
+ private function __getHeadBlock() {
111
+ return Mage::getSingleton('core/layout')->getBlock('head');
112
+ }
113
+ }
app/code/local/MD/Featuredproducts/Block/Product/List.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MD_FeaturedProducts_Block_Product_List extends Mage_Catalog_Block_Product_List
4
+ {
5
+ protected $_productCollection;
6
+ protected $_sort_by;
7
+
8
+ protected function _prepareLayout()
9
+ {
10
+ if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) {
11
+ $breadcrumbsBlock->addCrumb('home', array(
12
+ 'label'=>Mage::helper('catalog')->__('Home'),
13
+ 'title'=>Mage::helper('catalog')->__('Go to Home Page'),
14
+ 'link'=>Mage::getBaseUrl()
15
+ ));
16
+ }
17
+
18
+ parent::_prepareLayout();
19
+ }
20
+ public function stripTags($data, $allowableTags = null, $allowHtmlEntities = false)
21
+ {
22
+ return $this->_stripTags($data, $allowableTags, $allowHtmlEntities);
23
+ }
24
+ public function _stripTags($data, $allowableTags = null, $escape = false)
25
+ {
26
+ $result = strip_tags($data, $allowableTags);
27
+ return $escape ? $this->escapeHtml($result, $allowableTags) : $result;
28
+ }
29
+ /*
30
+ * Remove "Position" option from Sort By dropdown
31
+ * */
32
+ protected function _beforeToHtml()
33
+ {
34
+ parent::_beforeToHtml();
35
+ $toolbar = $this->getToolbarBlock();
36
+ $toolbar->removeOrderFromAvailableOrders('position');
37
+ return $this;
38
+ }
39
+
40
+
41
+ /*
42
+ * Load featured products collection
43
+ * */
44
+ protected function _getProductCollection()
45
+ {
46
+ if (is_null($this->_productCollection)) {
47
+ $collection = Mage::getModel('catalog/product')->getCollection();
48
+
49
+ $attributes = Mage::getSingleton('catalog/config')
50
+ ->getProductAttributes();
51
+
52
+ $collection->addAttributeToSelect($attributes)
53
+ ->addMinimalPrice()
54
+ ->addFinalPrice()
55
+ ->addTaxPercents()
56
+ ->addAttributeToFilter('md_featured_product', 1, 'left')
57
+ ->addStoreFilter();
58
+
59
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
60
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
61
+ $this->_productCollection = $collection;
62
+ }
63
+ return $this->_productCollection;
64
+ }
65
+
66
+ /**
67
+ * Retrieve loaded featured products collection
68
+ *
69
+ * @return Mage_Eav_Model_Entity_Collection_Abstract
70
+ */
71
+ public function getFeaturedProductCollection()
72
+ {
73
+ return $this->_getProductCollection();
74
+ }
75
+
76
+ public function getColumgrid()
77
+ {
78
+ return Mage::getStoreConfig("featuredproducts/general/number_of_itemsgrid");
79
+ }
80
+
81
+
82
+ /**
83
+ * Get HTML if there's anything to show
84
+ */
85
+ protected function _toHtml()
86
+ {
87
+ if ($this->_getProductCollection()->count()){
88
+ return parent::_toHtml();
89
+ }
90
+ return '';
91
+ }
92
+
93
+ }
app/code/local/MD/Featuredproducts/Helper/Data.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MD_FeaturedProducts_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ const PATH_PAGE_HEADING = 'featuredproducts/general/heading';
6
+ const PATH_CMS_HEADING = 'featuredproducts/general/heading_block';
7
+ const DEFAULT_LABEL = 'Featured Products';
8
+
9
+ public function getCmsBlockLabel()
10
+ {
11
+ $configValue = Mage::getStoreConfig(self::PATH_CMS_HEADING);
12
+ return strlen($configValue) > 0 ? $configValue : self::DEFAULT_LABEL;
13
+ }
14
+
15
+ public function getPageLabel()
16
+ {
17
+ $configValue = Mage::getStoreConfig(self::PATH_PAGE_HEADING);
18
+ return strlen($configValue) > 0 ? $configValue : self::DEFAULT_LABEL;
19
+ }
20
+ }
app/code/local/MD/Featuredproducts/Model/System/Config/Source/Selectmode.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class MD_FeaturedProducts_Model_System_Config_Source_Selectmode
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('Thickbox')),
8
+ array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Modalbox')),
9
+ );
10
+ }
11
+ }
app/code/local/MD/Featuredproducts/Model/System/Config/Source/Sort.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MD_FeaturedProducts_Model_System_Config_Source_Sort
4
+ {
5
+ /*
6
+ * Prepare data for System->Configuration dropdown
7
+ * */
8
+ public function toOptionArray()
9
+ {
10
+ return array(
11
+ 0 => Mage::helper('adminhtml')->__('Random'),
12
+ 1 => Mage::helper('adminhtml')->__('Last Added')
13
+ );
14
+ }
15
+ }
app/code/local/MD/Featuredproducts/controllers/Adminhtml/FeaturedController.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MD_Featuredproducts_Adminhtml_FeaturedController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+
6
+ protected function _initProduct()
7
+ {
8
+
9
+ $product = Mage::getModel('catalog/product')
10
+ ->setStoreId($this->getRequest()->getParam('store', 0));
11
+
12
+
13
+ if ($setId = (int) $this->getRequest()->getParam('set')) {
14
+ $product->setAttributeSetId($setId);
15
+ }
16
+
17
+ if ($typeId = $this->getRequest()->getParam('type')) {
18
+ $product->setTypeId($typeId);
19
+ }
20
+
21
+ $product->setData('_edit_mode', true);
22
+
23
+ Mage::register('product', $product);
24
+
25
+ return $product;
26
+ }
27
+
28
+
29
+
30
+
31
+
32
+
33
+ public function indexAction()
34
+ {
35
+ $this->_initProduct();
36
+
37
+ $this->loadLayout()->_setActiveMenu('catalog/featuredproduct');
38
+
39
+ $this->_addContent($this->getLayout()->createBlock('featuredproducts/adminhtml_edit'));
40
+
41
+ $this->renderLayout();
42
+
43
+ }
44
+
45
+ public function gridAction()
46
+ {
47
+
48
+ $this->getResponse()->setBody(
49
+ $this->getLayout()->createBlock('featuredproducts/adminhtml_edit_grid')->toHtml()
50
+ );
51
+
52
+ }
53
+
54
+ public function saveAction()
55
+ {
56
+ $data = $this->getRequest()->getPost();
57
+ $collection = Mage::getModel('catalog/product')->getCollection();
58
+ $storeId = $this->getRequest()->getParam('store', 0);
59
+
60
+
61
+ parse_str($data['featured_products'], $featured_products);
62
+
63
+
64
+ $collection->addIdFilter(array_keys($featured_products));
65
+
66
+ try {
67
+
68
+ foreach($collection->getItems() as $product)
69
+ {
70
+
71
+ $product->setData('md_featured_product',$featured_products[$product->getEntityId()]);
72
+ $product->setStoreId($storeId);
73
+ $product->save();
74
+ }
75
+
76
+
77
+ $this->_getSession()->addSuccess($this->__('Featured product was successfully saved.'));
78
+ $this->_redirect('*/*/index', array('store'=> $this->getRequest()->getParam('store')));
79
+
80
+ }catch (Exception $e){
81
+ $this->_getSession()->addError($e->getMessage());
82
+ $this->_redirect('*/*/index', array('store'=> $this->getRequest()->getParam('store')));
83
+ }
84
+
85
+ }
86
+
87
+ protected function _validateSecretKey()
88
+ {
89
+ return true;
90
+ }
91
+
92
+ protected function _isAllowed()
93
+ {
94
+ return Mage::getSingleton('admin/session')->isAllowed('admin/catalog/featuredproduct');
95
+ }
96
+
97
+ }
app/code/local/MD/Featuredproducts/controllers/IndexController.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MD_FeaturedProducts_IndexController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ /*
6
+ * Check settings set in System->Configuration and apply them for featured-products page
7
+ * */
8
+ public function indexAction()
9
+ {
10
+ $this->loadLayout();
11
+ $this->getLayout()->getBlock('head')->setTitle($this->__(Mage::getStoreConfig("featuredproducts/general/meta_title")));
12
+ $this->getLayout()->getBlock('head')->setDescription($this->__(Mage::getStoreConfig("featuredproducts/general/meta_description")));
13
+ $this->getLayout()->getBlock('head')->setKeywords($this->__(Mage::getStoreConfig("featuredproducts/general/meta_keywords")));
14
+
15
+ $breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs');
16
+ $breadcrumbsBlock->addCrumb('featured_products', array(
17
+ 'label'=>Mage::helper('featuredproducts')->__(Mage::helper('featuredproducts')->getPageLabel()),
18
+ 'title'=>Mage::helper('featuredproducts')->__(Mage::helper('featuredproducts')->getPageLabel()),
19
+ ));
20
+
21
+ $this->renderLayout();
22
+ }
23
+ }
app/code/local/MD/Featuredproducts/controllers/ProductController.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MD_FeaturedProducts_ProductController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ /**
6
+ * Initialize requested product object
7
+ *
8
+ * @return Mage_Catalog_Model_Product
9
+ */
10
+ protected function _initProduct()
11
+ {
12
+ Mage::dispatchEvent('catalog_controller_product_init_before', array('controller_action'=>$this));
13
+ $categoryId = (int) $this->getRequest()->getParam('category', false);
14
+ $productId = (int) $this->getRequest()->getParam('id');
15
+
16
+ if (!$productId) {
17
+ return false;
18
+ }
19
+
20
+ $product = Mage::getModel('catalog/product')
21
+ ->setStoreId(Mage::app()->getStore()->getId())
22
+ ->load($productId);
23
+
24
+ if (!Mage::helper('catalog/product')->canShow($product)) {
25
+ return false;
26
+ }
27
+ if (!in_array(Mage::app()->getStore()->getWebsiteId(), $product->getWebsiteIds())) {
28
+ return false;
29
+ }
30
+
31
+ $category = null;
32
+ if ($categoryId) {
33
+ $category = Mage::getModel('catalog/category')->load($categoryId);
34
+ $product->setCategory($category);
35
+ Mage::register('current_category', $category);
36
+ }
37
+ elseif ($categoryId = Mage::getSingleton('catalog/session')->getLastVisitedCategoryId()) {
38
+ if ($product->canBeShowInCategory($categoryId)) {
39
+ $category = Mage::getModel('catalog/category')->load($categoryId);
40
+ $product->setCategory($category);
41
+ Mage::register('current_category', $category);
42
+ }
43
+ }
44
+
45
+
46
+ Mage::register('current_product', $product);
47
+ Mage::register('product', $product);
48
+
49
+ try {
50
+ Mage::dispatchEvent('catalog_controller_product_init', array('product'=>$product));
51
+ Mage::dispatchEvent('catalog_controller_product_init_after', array('product'=>$product, 'controller_action' => $this));
52
+ } catch (Mage_Core_Exception $e) {
53
+ Mage::logException($e);
54
+ return false;
55
+ }
56
+
57
+ return $product;
58
+ }
59
+
60
+ /**
61
+ * Initialize product view layout
62
+ *
63
+ * @param Mage_Catalog_Model_Product $product
64
+ * @return Mage_Catalog_ProductController
65
+ */
66
+ protected function _initProductLayout($product)
67
+ {
68
+ $update = $this->getLayout()->getUpdate();
69
+ $update->addHandle('default');
70
+ $this->addActionLayoutHandles();
71
+
72
+ $update->addHandle('PRODUCT_TYPE_'.$product->getTypeId());
73
+ $update->addHandle('PRODUCT_'.$product->getId());
74
+
75
+ if ($product->getPageLayout()) {
76
+ $this->getLayout()->helper('page/layout')
77
+ ->applyHandle($product->getPageLayout());
78
+ }
79
+
80
+ $this->loadLayoutUpdates();
81
+
82
+
83
+ $update->addUpdate($product->getCustomLayoutUpdate());
84
+
85
+ $this->generateLayoutXml()->generateLayoutBlocks();
86
+
87
+ if ($product->getPageLayout()) {
88
+ $this->getLayout()->helper('page/layout')
89
+ ->applyTemplate($product->getPageLayout());
90
+ }
91
+
92
+ $currentCategory = Mage::registry('current_category');
93
+ if ($root = $this->getLayout()->getBlock('root')) {
94
+ $root->addBodyClass('product-'.$product->getUrlKey());
95
+ if ($currentCategory instanceof Mage_Catalog_Model_Category) {
96
+ $root->addBodyClass('categorypath-'.$currentCategory->getUrlPath())
97
+ ->addBodyClass('category-'.$currentCategory->getUrlKey());
98
+ }
99
+ }
100
+ return $this;
101
+ }
102
+
103
+ /**
104
+ * View product action
105
+ */
106
+ public function viewAction()
107
+ {
108
+
109
+ if ($product = $this->_initProduct()) {
110
+ Mage::dispatchEvent('catalog_controller_product_view', array('product'=>$product));
111
+
112
+ if ($this->getRequest()->getParam('options')) {
113
+ $notice = $product->getTypeInstance(true)->getSpecifyOptionMessage();
114
+ Mage::getSingleton('catalog/session')->addNotice($notice);
115
+ }
116
+
117
+ Mage::getSingleton('catalog/session')->setLastViewedProductId($product->getId());
118
+ Mage::getModel('catalog/design')->applyDesign($product, Mage_Catalog_Model_Design::APPLY_FOR_PRODUCT);
119
+
120
+ $this->_initProductLayout($product);
121
+ $this->_initLayoutMessages('catalog/session');
122
+ $this->_initLayoutMessages('tag/session');
123
+ $this->_initLayoutMessages('checkout/session');
124
+ $this->renderLayout();
125
+ }
126
+ else {
127
+ if (isset($_GET['store']) && !$this->getResponse()->isRedirect()) {
128
+ $this->_redirect('');
129
+ } elseif (!$this->getResponse()->isRedirect()) {
130
+ $this->_forward('noRoute');
131
+ }
132
+ }
133
+ }
134
+ }
app/code/local/MD/Featuredproducts/etc/adminhtml.xml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <menu>
3
+ <catalog>
4
+ <children>
5
+ <featuredproduct translate="title">
6
+ <title>Featured Products</title>
7
+ <sort_order>1</sort_order>
8
+ <action>adminhtml/featured/index</action>
9
+ </featuredproduct>
10
+
11
+ </children>
12
+ </catalog>
13
+ </menu>
14
+
15
+ <acl>
16
+ <resources>
17
+ <admin>
18
+ <children>
19
+ <system>
20
+ <children>
21
+ <config>
22
+ <children>
23
+ <featuredproducts translate="title" module="featuredproducts">
24
+ <title>Featured Products Settings</title>
25
+ <sort_order>50</sort_order>
26
+ </featuredproducts>
27
+ </children>
28
+ </config>
29
+ </children>
30
+ </system>
31
+ </children>
32
+ </admin>
33
+ <admin>
34
+ <children>
35
+ <catalog>
36
+ <children>
37
+ <featuredproduct translate="title" module="featuredproducts">
38
+ <title>Featured Products Data</title>
39
+ <sort_order>60</sort_order>
40
+ </featuredproduct>
41
+ </children>
42
+ </catalog>
43
+ </children>
44
+ </admin>
45
+ </resources>
46
+ </acl>
47
+ </config>
app/code/local/MD/Featuredproducts/etc/config.xml ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <MD_Featuredproducts>
5
+ <version>0.1.0</version>
6
+ </MD_Featuredproducts>
7
+ </modules>
8
+
9
+ <global>
10
+ <blocks>
11
+ <featuredproducts>
12
+ <class>MD_Featuredproducts_Block</class>
13
+ </featuredproducts>
14
+ </blocks>
15
+
16
+ <helpers>
17
+ <featuredproducts>
18
+ <class>MD_Featuredproducts_Helper</class>
19
+ </featuredproducts>
20
+ </helpers>
21
+
22
+ <models>
23
+ <featuredproducts>
24
+ <class>MD_Featuredproducts_Model</class>
25
+ </featuredproducts>
26
+ </models>
27
+
28
+ <resources>
29
+ <featuredproducts_setup>
30
+ <setup>
31
+ <module>MD_Featuredproducts</module>
32
+ <class>Mage_Eav_Model_Entity_Setup</class>
33
+ </setup>
34
+
35
+ <connection>
36
+ <use>core_setup</use>
37
+ </connection>
38
+ </featuredproducts_setup>
39
+
40
+ <featuredproducts_write>
41
+ <connection>
42
+ <use>core_write</use>
43
+ </connection>
44
+ </featuredproducts_write>
45
+ <featuredproducts_read>
46
+ <connection>
47
+ <use>core_read</use>
48
+ </connection>
49
+ </featuredproducts_read>
50
+ </resources>
51
+ </global>
52
+
53
+ <frontend>
54
+ <routers>
55
+ <featuredproducts>
56
+ <use>standard</use>
57
+ <args>
58
+ <module>MD_Featuredproducts</module>
59
+ <frontName>featured-products</frontName>
60
+ </args>
61
+ </featuredproducts>
62
+ </routers>
63
+ <layout>
64
+ <updates>
65
+ <featuredproducts>
66
+ <file>md_featuredproducts.xml</file>
67
+ </featuredproducts>
68
+ </updates>
69
+ </layout>
70
+ </frontend>
71
+
72
+ <admin>
73
+ <routers>
74
+ <adminhtml>
75
+ <args>
76
+ <modules>
77
+ <featuredproducts before="Mage_Adminhtml">MD_Featuredproducts_Adminhtml</featuredproducts>
78
+ </modules>
79
+ </args>
80
+ </adminhtml>
81
+ </routers>
82
+ </admin>
83
+
84
+ <default>
85
+ <featuredproducts>
86
+ <general>
87
+ <heading>Featured Products</heading>
88
+ <heading_block>Featured Products</heading_block>
89
+ <meta_title>Featured Products</meta_title>
90
+ <meta_description>Check out our great collection of Featured products</meta_description>
91
+ <meta_keywords>featured, products</meta_keywords>
92
+ <product_sort_by>random</product_sort_by>
93
+ <number_of_itemsgrid>3</number_of_itemsgrid>
94
+ <number_of_items>5</number_of_items>
95
+ <number_of_items_per_row>2</number_of_items_per_row>
96
+ <layout>two_columns_right</layout>
97
+ </general>
98
+ </featuredproducts>
99
+ </default>
100
+ </config>
app/code/local/MD/Featuredproducts/etc/system.xml ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <md module="featuredproducts">
5
+ <label>Mage-Designer</label>
6
+ <sort_order>110</sort_order>
7
+ </md>
8
+ </tabs>
9
+ <sections>
10
+ <featuredproducts translate="label" module="featuredproducts">
11
+ <class>separator-top</class>
12
+ <label>Featured Products</label>
13
+ <tab>md</tab>
14
+ <sort_order>10</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
+ <general translate="label">
20
+ <label>General</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>1</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <enable_featuredproducts translate="label">
28
+ <label>Enable Featured Products</label>
29
+ <frontend_type>select</frontend_type>
30
+ <source_model>adminhtml/system_config_source_yesno</source_model>
31
+ <sort_order>0</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </enable_featuredproducts>
36
+ <enable_onepage translate="label">
37
+ <label>Enable One Columns</label>
38
+ <frontend_type>select</frontend_type>
39
+ <source_model>adminhtml/system_config_source_yesno</source_model>
40
+ <sort_order>1</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ </enable_onepage>
45
+ <enable_rightpage translate="label">
46
+ <label>Enable 2 Columns Right</label>
47
+ <frontend_type>select</frontend_type>
48
+ <source_model>adminhtml/system_config_source_yesno</source_model>
49
+ <sort_order>2</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ </enable_rightpage>
54
+ <enable_threepage translate="label">
55
+ <label>Enable 3 Columns</label>
56
+ <frontend_type>select</frontend_type>
57
+ <source_model>adminhtml/system_config_source_yesno</source_model>
58
+ <sort_order>3</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ </enable_threepage>
63
+ <enable_leftpage translate="label">
64
+ <label>Enable 2 Columns Left</label>
65
+ <frontend_type>select</frontend_type>
66
+ <source_model>adminhtml/system_config_source_yesno</source_model>
67
+ <sort_order>4</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ <comment>
72
+ <![CDATA[<script>
73
+ $('featuredproducts_general_enable_onepage').observe('change', function() {
74
+
75
+ if($('featuredproducts_general_enable_onepage').value==1){
76
+ $('featuredproducts_general_enable_rightpage')[1].selected = true;
77
+ $('featuredproducts_general_enable_leftpage')[1].selected = true;
78
+ $('featuredproducts_general_enable_threepage')[1].selected = true;
79
+ }
80
+ });
81
+ $('featuredproducts_general_enable_rightpage').observe('change', function() {
82
+
83
+ if($('featuredproducts_general_enable_rightpage').value==1){
84
+ $('featuredproducts_general_enable_onepage')[1].selected = true;
85
+ $('featuredproducts_general_enable_leftpage')[1].selected = true;
86
+ $('featuredproducts_general_enable_threepage')[1].selected = true;
87
+ }
88
+ });
89
+ $('featuredproducts_general_enable_leftpage').observe('change', function() {
90
+
91
+ if($('featuredproducts_general_enable_leftpage').value==1){
92
+ $('featuredproducts_general_enable_rightpage')[1].selected = true;
93
+ $('featuredproducts_general_enable_onepage')[1].selected = true;
94
+ $('featuredproducts_general_enable_threepage')[1].selected = true;
95
+ }
96
+ });
97
+ $('featuredproducts_general_enable_threepage').observe('change', function() {
98
+
99
+ if($('featuredproducts_general_enable_threepage').value==1){
100
+ $('featuredproducts_general_enable_rightpage')[1].selected = true;
101
+ $('featuredproducts_general_enable_onepage')[1].selected = true;
102
+ $('featuredproducts_general_enable_leftpage')[1].selected = true;
103
+ }
104
+ });
105
+ </script>]]>
106
+ </comment>
107
+ </enable_leftpage>
108
+ <heading translate="label comment">
109
+ <label>Heading</label>
110
+ <frontend_type>text</frontend_type>
111
+ <sort_order>5</sort_order>
112
+ <show_in_default>1</show_in_default>
113
+ <show_in_website>1</show_in_website>
114
+ <show_in_store>1</show_in_store>
115
+ </heading>
116
+ <meta_title translate="label comment">
117
+ <label>Meta Title</label>
118
+ <frontend_type>text</frontend_type>
119
+ <sort_order>6</sort_order>
120
+ <show_in_default>1</show_in_default>
121
+ <show_in_website>1</show_in_website>
122
+ <show_in_store>1</show_in_store>
123
+ </meta_title>
124
+
125
+ <meta_description translate="label comment">
126
+ <label>Meta Description</label>
127
+ <frontend_type>textarea</frontend_type>
128
+ <sort_order>7</sort_order>
129
+ <show_in_default>1</show_in_default>
130
+ <show_in_website>1</show_in_website>
131
+ <show_in_store>1</show_in_store>
132
+ </meta_description>
133
+
134
+ <meta_keywords translate="label comment">
135
+ <label>Meta Keywords</label>
136
+ <frontend_type>textarea</frontend_type>
137
+ <sort_order>8</sort_order>
138
+ <show_in_default>1</show_in_default>
139
+ <show_in_website>1</show_in_website>
140
+ <show_in_store>1</show_in_store>
141
+ </meta_keywords>
142
+ <number_of_itemsgrid translate="label comment">
143
+ <label>Number of items per row of grid</label>
144
+ <comment>How many featured products will be showed in per row of grid?</comment>
145
+ <frontend_type>text</frontend_type>
146
+ <sort_order>9</sort_order>
147
+ <show_in_default>1</show_in_default>
148
+ <show_in_website>1</show_in_website>
149
+ <show_in_store>1</show_in_store>
150
+ </number_of_itemsgrid>
151
+ </fields>
152
+ </general>
153
+ </groups>
154
+ </featuredproducts>
155
+ </sections>
156
+ </config>
app/code/local/MD/Featuredproducts/sql/featuredproducts_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = new Mage_Eav_Model_Entity_Setup('core_setup');
4
+ $installer->startSetup();
5
+
6
+
7
+ $installer->addAttribute('catalog_product', 'md_featured_product', array(
8
+ 'group' => 'General',
9
+ 'type' => 'int',
10
+ 'backend' => '',
11
+ 'frontend' => '',
12
+ 'label' => 'Featured product',
13
+ 'input' => 'boolean',
14
+ 'class' => '',
15
+ 'source' => '',
16
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
17
+ 'visible' => true,
18
+ 'required' => false,
19
+ 'user_defined' => true,
20
+ 'default' => '0',
21
+ 'searchable' => false,
22
+ 'filterable' => false,
23
+ 'comparable' => false,
24
+ 'visible_on_front' => false,
25
+ 'unique' => false,
26
+ 'apply_to' => 'simple,configurable,virtual,bundle,downloadable',
27
+ 'is_configurable' => false
28
+ ));
29
+
30
+ $installer->endSetup();
app/code/local/MD/Featuredproducts/sql/featuredproducts_setup/mysql4-install-1.0.1.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Mage_Eav_Model_Entity_Setup */
5
+
6
+ $installer->startSetup();
7
+
8
+
9
+ $installer->addAttribute('catalog_product', 'md_featured_product', array(
10
+ 'group' => 'General',
11
+ 'type' => 'int',
12
+ 'backend' => '',
13
+ 'frontend' => '',
14
+ 'label' => 'Featured product',
15
+ 'input' => 'boolean',
16
+ 'class' => '',
17
+ 'source' => '',
18
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
19
+ 'visible' => true,
20
+ 'required' => false,
21
+ 'user_defined' => true,
22
+ 'default' => '0',
23
+ 'searchable' => false,
24
+ 'filterable' => false,
25
+ 'comparable' => false,
26
+ 'visible_on_front' => false,
27
+ 'unique' => false,
28
+ 'apply_to' => 'simple,configurable,virtual,bundle,downloadable',
29
+ 'is_configurable' => false
30
+ ));
31
+
32
+ $installer->endSetup();
app/code/local/MD/Featuredproducts/sql/featuredproducts_setup/mysql4-upgrade-1.0.1-1.1.1.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Mage_Eav_Model_Entity_Setup */
5
+
6
+ $installer->startSetup();
7
+ $installer->updateAttribute('catalog_product', 'md_featured_product', 'is_global', Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE);
8
+
9
+ $installer->endSetup();
app/code/local/MD/Featuredproducts/sql/featuredproducts_setup/mysql4-upgrade-1.0.1-1.1.3.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Mage_Eav_Model_Entity_Setup */
5
+
6
+ $installer->startSetup();
7
+ $installer->updateAttribute('catalog_product', 'md_featured_product', 'is_global', Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE);
8
+
9
+ $installer->endSetup();
app/code/local/MD/Featuredproducts/sql/featuredproducts_setup/mysql4-upgrade-1.1.3-1.2.0.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
4
+ $installer = $this;
5
+
6
+ $installer->startSetup();
7
+ $installer->removeAttribute('catalog_product', 'md_featured_product');
8
+ $installer->endSetup();
app/code/local/MD/Featuredproducts/sql/featuredproducts_setup/mysql4-upgrade-1.2.0-1.2.1.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ $installer = $this;
5
+ /* @var $installer Mage_Eav_Model_Entity_Setup */
6
+
7
+ $installer->startSetup();
8
+
9
+
10
+ $installer->addAttribute('catalog_product', 'md_featured_product', array(
11
+ 'group' => 'General',
12
+ 'type' => 'int',
13
+ 'backend' => '',
14
+ 'frontend' => '',
15
+ 'label' => 'Featured product',
16
+ 'input' => 'boolean',
17
+ 'class' => '',
18
+ 'source' => '',
19
+ 'is_global', Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
20
+ 'visible' => true,
21
+ 'required' => false,
22
+ 'user_defined' => false,
23
+ 'default' => '0',
24
+ 'searchable' => false,
25
+ 'filterable' => false,
26
+ 'comparable' => false,
27
+ 'visible_on_front' => false,
28
+ 'unique' => false,
29
+ 'apply_to' => 'simple,configurable,virtual,bundle,downloadable',
30
+ 'is_configurable' => false,
31
+ 'used_in_product_listing', '1'
32
+ ));
33
+
34
+
35
+ $installer->updateAttribute('catalog_product', 'md_featured_product', 'used_in_product_listing', '1');
36
+
37
+ $installer->endSetup();
app/code/local/MD/Featuredproducts/sql/featuredproducts_setup/mysql4-upgrade-1.2.1-1.2.2.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Mage_Eav_Model_Entity_Setup */
5
+
6
+ $installer->startSetup();
7
+
8
+ $installer->endSetup();
app/code/local/MD/Featuredproducts/sql/featuredproducts_setup/mysql4-upgrade-1.2.2-1.2.3.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Mage_Eav_Model_Entity_Setup */
5
+
6
+ $installer->startSetup();
7
+
8
+ $installer->endSetup();
app/design/frontend/default/default/layout/md_featuredproducts.xml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ </default>
5
+ <featuredproducts_index_index>
6
+ <reference name="root">
7
+ <action method="setTemplate" ifconfig="featuredproducts/general/enable_rightpage">
8
+ <template>page/2columns-right.phtml</template>
9
+ </action>
10
+ <action method="setTemplate" ifconfig="featuredproducts/general/enable_leftpage">
11
+ <template>page/2columns-left.phtml</template>
12
+ </action>
13
+ <action method="setTemplate" ifconfig="featuredproducts/general/enable_onepage">
14
+ <template>page/1column.phtml</template>
15
+ </action>
16
+ <action method="setTemplate" ifconfig="featuredproducts/general/enable_threepage">
17
+ <template>page/3columns.phtml</template>
18
+ </action>
19
+ </reference>
20
+ <reference name="content">
21
+ <block type="featuredproducts/product_list" name="featured_product_list" as="featured_product_list"
22
+ template="md/featuredproducts/list.phtml">
23
+ <block type="catalog/product_list_toolbar" name="product_list_toolbar"
24
+ template="catalog/product/list/toolbar.phtml">
25
+ <block type="page/html_pager" name="product_list_toolbar_pager"/>
26
+ </block>
27
+ <action method="setToolbarBlockName">
28
+ <name>product_list_toolbar</name>
29
+ </action>
30
+ </block>
31
+ </reference>
32
+ </featuredproducts_index_index>
33
+ </layout>
app/design/frontend/default/default/template/md/featuredproducts/list.phtml ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $enableFeatured = Mage::getStoreConfig('featuredproducts/general/enable_featuredproducts');
3
+ if($enableFeatured==1):
4
+ $_productCollection=$this->getFeaturedProductCollection();
5
+ $_helper = $this->helper('catalog/output');
6
+ ?>
7
+ <div class="category-head">
8
+ <h2><?php echo $this->__($this->helper('featuredproducts')->getPageLabel());?></h2>
9
+ </div>
10
+ <?php if(!$_productCollection->count()): ?>
11
+ <p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
12
+ <?php else: ?>
13
+ <div class="category-products">
14
+ <?php echo $this->getToolbarHtml() ?>
15
+ <?php // List mode ?>
16
+ <?php if($this->getMode()!='grid'): ?>
17
+ <?php $_iterator = 0; ?>
18
+ <ol class="products-list" id="products-list">
19
+ <?php foreach ($_productCollection as $_product): ?>
20
+ <li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
21
+ <?php // Product Image ?>
22
+ <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(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
23
+ <?php // Product description ?>
24
+ <div class="product-shop">
25
+ <div class="f-fix">
26
+ <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
27
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2>
28
+ <?php if($_product->getRatingSummary()): ?>
29
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
30
+ <?php endif; ?>
31
+ <?php echo $this->getPriceHtml($_product, true) ?>
32
+ <?php if($_product->isSaleable()): ?>
33
+ <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>
34
+ <?php else: ?>
35
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
36
+ <?php endif; ?>
37
+ <div class="desc std">
38
+ <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
39
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
40
+ </div>
41
+ <ul class="add-to-links">
42
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
43
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
44
+ <?php endif; ?>
45
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
46
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
47
+ <?php endif; ?>
48
+ </ul>
49
+ </div>
50
+ </div>
51
+ </li>
52
+ <?php endforeach; ?>
53
+ </ol>
54
+ <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
55
+
56
+ <?php else: ?>
57
+
58
+ <?php // Grid Mode ?>
59
+
60
+ <?php $_collectionSize = $_productCollection->count() ?>
61
+ <?php $_columnCount = $this->getColumgrid(); ?>
62
+ <?php $i=0; foreach ($_productCollection as $_product): ?>
63
+ <?php if ($i++%$_columnCount==0): ?>
64
+ <ul class="products-grid">
65
+ <?php endif ?>
66
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
67
+ <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(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
68
+ <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>
69
+ <?php if($_product->getRatingSummary()): ?>
70
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
71
+ <?php endif; ?>
72
+ <?php echo $this->getPriceHtml($_product, true) ?>
73
+ <div class="actions">
74
+ <?php if($_product->isSaleable()): ?>
75
+ <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>
76
+ <?php else: ?>
77
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
78
+ <?php endif; ?>
79
+ <ul class="add-to-links">
80
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
81
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
82
+ <?php endif; ?>
83
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
84
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
85
+ <?php endif; ?>
86
+ </ul>
87
+ </div>
88
+ </li>
89
+ <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
90
+ </ul>
91
+ <?php endif ?>
92
+ <?php endforeach ?>
93
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
94
+ <?php endif; ?>
95
+
96
+ <div class="toolbar-bottom">
97
+ <?php echo $this->getToolbarHtml() ?>
98
+ </div>
99
+ </div>
100
+ <?php endif; ?>
101
+ <?php endif; ?>
app/etc/modules/MD_Featuredproducts.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category MD
5
+ * @package MD_Featuredproducts
6
+ * @author Mage-Designer.com
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <MD_Featuredproducts>
13
+ <active>true</active>
14
+ <codePool>local</codePool>
15
+ </MD_Featuredproducts>
16
+ </modules>
17
+ </config>
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>MD_FeaturedProducts</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>
8
+ <extends/>
9
+ <summary>Featured Products Extension is the ideal solution for any online shop to get a nice shop interface as well as maximum flexibility and convenience.</summary>
10
+ <description>Featured Products Extension is the ideal solution for any online shop to get a nice shop interface as well as maximum flexibility and convenience.&#xD;
11
+ &#xD;
12
+ Featured Products This useful extension offers a great deal of optimal functions to display and sort your products and assist your customers in searching and choosing products. It also provides the best admin management with flexible support and toolbar. Now with Featured Products Extension, your featured products will be effectively managed.</description>
13
+ <notes>please contact us : support@mage-designer.com</notes>
14
+ <authors><author><name>OSWorld</name><user>OSWorld</user><email>thinhct@mage-designer.com</email></author></authors>
15
+ <date>2013-01-21</date>
16
+ <time>05:10:02</time>
17
+ <contents><target name="magelocal"><dir name="MD"><dir name="Featuredproducts"><dir name="Block"><dir name="Adminhtml"><dir name="Edit"><file name="Grid.php" hash="f99d415ba56b92920bfbb363f570ea04"/><dir name="Renderer"><file name="Visibility.php" hash="2def8332786d3f566235c518aa875f54"/></dir></dir><file name="Edit.php" hash="47c5b541b1f56b9fd9d1acc6253dc92e"/></dir><dir name="Catalog"><dir name="Product"><dir name="View"><file name="Media.php" hash="9372b6aedf32d1adc4d1dd81180363be"/></dir><file name="View.php" hash="a2054397b461e4dfcac47a2e0263e7c4"/></dir></dir><file name="List.php" hash="ad367a21bc21e2984639a03d97f28cc6"/><dir name="Page"><dir name="Html"><file name="Head.php" hash="c1291ae1b30285280b52486a310cbae0"/></dir><file name="Html.php" hash="f74d81faeaff14ee5933b6527fdb5ae1"/></dir><dir name="Product"><file name="List.php" hash="579b7ba403ed7745140de15790ee6f73"/></dir></dir><dir name="Helper"><file name="Data.php" hash="aee2e9eef7dca94e475634e5d467fa6d"/></dir><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Selectmode.php" hash="138289cb9f27e85654a65d46ba7ae91a"/><file name="Sort.php" hash="ab8b7f5e2540eadebf2de4ed7544e3af"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="FeaturedController.php" hash="1cfa676371bce03ab52a23ab351e0fa1"/></dir><file name="IndexController.php" hash="f0840f0f45d0d2fd1f0ce0d0fb33b8a1"/><file name="ProductController.php" hash="462855de794f086ba94ed007476dff73"/></dir><dir name="etc"><file name="adminhtml.xml" hash="ab8d70af3f8a81e1f437745708692274"/><file name="config.xml" hash="48e6cd26dfa33d66b930dbfd4a6d4301"/><file name="system.xml" hash="4fdf7dd05903e58cef08ec051439b5f2"/></dir><dir name="sql"><dir name="featuredproducts_setup"><file name="mysql4-install-0.1.0.php" hash="6a7c48860d430cdcdb2ef45a94f39169"/><file name="mysql4-install-1.0.1.php" hash="b37c4858d4243172019acef1ddb52494"/><file name="mysql4-upgrade-1.0.1-1.1.1.php" hash="68e6dfcb92f6ce1b1c796e9d73a24cd4"/><file name="mysql4-upgrade-1.0.1-1.1.3.php" hash="68e6dfcb92f6ce1b1c796e9d73a24cd4"/><file name="mysql4-upgrade-1.1.3-1.2.0.php" hash="1abf980cfc0da199ca89252385a61033"/><file name="mysql4-upgrade-1.2.0-1.2.1.php" hash="c1d326462bd6223141ddfb20bf9b67cf"/><file name="mysql4-upgrade-1.2.1-1.2.2.php" hash="934affd2d88b662d83260766ca9c50be"/><file name="mysql4-upgrade-1.2.2-1.2.3.php" hash="934affd2d88b662d83260766ca9c50be"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="md_featuredproducts.xml" hash="769668564d56bb5c24710cbb19a1cd7f"/></dir><dir name="template"><dir name="md"><dir name="featuredproducts"><file name="list.phtml" hash="ea21aa6ca036f09c520a3007b88215a3"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MD_Featuredproducts.xml" hash="ccde9e3197518bc1c777eb2a72e70e32"/></dir></target><target name="mageweb"><dir name="."><file name="readme.txt" hash="d6bb7c11b01bbd3a1f480f27c05e8bf6"/></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
20
+ </package>
readme.txt ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Mage-designer.com ==== FEATURED PRODUCTS INSTALLATION GUIDE - Version 1.0 === Mage-designer.com
2
+
3
+ With the Featured Products extension you can drive more of your visitors� attention to your best
4
+ and most profitable products in your Magento web-store. Boost revenues by capturing the
5
+ effectively attracting and arousing your prospects� interest in products that you want them to buy.
6
+
7
+ INSTALLATION GUIDE
8
+ ------------------
9
+
10
+ 1. Copy folder app, skin to magento root folder.( This do not override any file in your magento)
11
+
12
+ 2. Make sure to clear cache in admin of magento
13
+
14
+ 3. Config in admin:
15
+ Goto admin->system->configuration-> MAGE-DESIGNER -> Feature Products to setup information general
16
+
17
+ 4. Save
18
+
19
+ 5. Go to menu Catalog -> Featured Products : choose one or multi product to Featured Product.
20
+
21
+ 6. Save and go to front end : /domain/featured-products to see.
22
+
23
+ If after install extension, you get message "Access denied", please try to logout and login again.
24
+
25
+ If you have any problem please email to: noreply@mage-designer.com
26
+
27
+ Thanks,
28
+
29
+ Mage-designer.com