productcms - Version 1.0.12

Version Notes

Product CMS

Download this release

Release Info

Developer Magento Core Team
Extension productcms
Version 1.0.12
Comparing to
See all releases


Version 1.0.12

app/code/local/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Cms.php ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Crossell products admin grid
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Cms extends Mage_Adminhtml_Block_Widget_Grid
35
+ {
36
+ /**
37
+ * Set grid params
38
+ *
39
+ */
40
+ public function __construct()
41
+ {
42
+ parent::__construct();
43
+ $this->setId('cms_product_grid');
44
+ $this->setDefaultSort('page_id');
45
+ $this->setUseAjax(true);
46
+ $this->setDefaultDir('ASC');
47
+ if ($this->_getProduct()->getId()) {
48
+ // $this->setDefaultFilter(array('in_products'=>1));/add array cms id of product
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Retirve currently edited product model
54
+ *
55
+ * @return Mage_Catalog_Model_Product
56
+ */
57
+ protected function _getProduct()
58
+ {
59
+ return Mage::registry('current_product');
60
+ }
61
+ /**
62
+ * Add filter
63
+ *
64
+ * @param object $column
65
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Crosssell
66
+ */
67
+ protected function _addColumnFilterToCollection($column)
68
+ {
69
+ // Set custom filter for in product flag
70
+ if ($column->getId() == 'in_products') {
71
+ $productIds = $this->_getSelectedCms();
72
+ if (empty($productIds)) {
73
+ $productIds = 0;
74
+ }
75
+ if ($column->getFilter()->getValue()) {
76
+ $this->getCollection()->addFieldToFilter('page_id', array('in'=>$productIds));
77
+ } else {
78
+ if($productIds) {
79
+ $this->getCollection()->addFieldToFilter('page_id', array('nin'=>$productIds));
80
+ }
81
+ }
82
+ } else {
83
+ parent::_addColumnFilterToCollection($column);
84
+ }
85
+ return $this;
86
+ }
87
+
88
+
89
+
90
+ /**
91
+ * Prepare collection
92
+ *
93
+ * @return Mage_Adminhtml_Block_Widget_Grid
94
+ */
95
+ protected function _prepareCollection()
96
+ {
97
+ $collection = Mage::getModel('cms/page')->getCollection();
98
+ /* @var $collection Mage_Cms_Model_Mysql4_Page_Collection */
99
+ $collection->setFirstStoreFlag(true);
100
+
101
+
102
+ $this->setCollection($collection);
103
+
104
+ return parent::_prepareCollection();
105
+ }
106
+
107
+ /**
108
+ * Checks when this block is readonly
109
+ *
110
+ * @return boolean
111
+ */
112
+ public function isReadonly()
113
+ {
114
+ return $this->_getProduct()->getCrosssellReadonly();
115
+ }
116
+
117
+ /**
118
+ * Add columns to grid
119
+ *
120
+ * @return Mage_Adminhtml_Block_Widget_Grid
121
+ */
122
+ protected function _prepareColumns()
123
+ {
124
+ $baseUrl = $this->getUrl();
125
+ // if (!$this->isReadonly()) {
126
+ $this->addColumn('in_products', array(
127
+ 'header_css_class' => 'a-center',
128
+ 'type' => 'checkbox',
129
+ 'name' => 'in_products',
130
+ 'values' => $this->_getSelectedCms(),
131
+ 'align' => 'center',
132
+ 'index' => 'page_id'
133
+ ));
134
+ // }
135
+ $this->addColumn('title', array(
136
+ 'header' => Mage::helper('cms')->__('Title'),
137
+ 'align' => 'left',
138
+ 'index' => 'title',
139
+ ));
140
+
141
+ $this->addColumn('identifier', array(
142
+ 'header' => Mage::helper('cms')->__('URL Key'),
143
+ 'align' => 'left',
144
+ 'index' => 'identifier'
145
+ ));
146
+
147
+
148
+
149
+ $this->addColumn('root_template', array(
150
+ 'header' => Mage::helper('cms')->__('Layout'),
151
+ 'index' => 'root_template',
152
+ 'type' => 'options',
153
+ 'options' => Mage::getSingleton('page/source_layout')->getOptions(),
154
+ ));
155
+
156
+ /**
157
+ * Check is single store mode
158
+ */
159
+ if (!Mage::app()->isSingleStoreMode()) {
160
+ $this->addColumn('store_id', array(
161
+ 'header' => Mage::helper('cms')->__('Store View'),
162
+ 'index' => 'store_id',
163
+ 'type' => 'store',
164
+ 'store_all' => true,
165
+ 'store_view' => true,
166
+ 'sortable' => false,
167
+ 'filter_condition_callback'
168
+ => array($this, '_filterStoreCondition'),
169
+ ));
170
+ }
171
+
172
+ $this->addColumn('is_active', array(
173
+ 'header' => Mage::helper('cms')->__('Status'),
174
+ 'index' => 'is_active',
175
+ 'type' => 'options',
176
+ 'options' => Mage::getSingleton('cms/page')->getAvailableStatuses()
177
+ ));
178
+
179
+ $this->addColumn('creation_time', array(
180
+ 'header' => Mage::helper('cms')->__('Date Created'),
181
+ 'index' => 'creation_time',
182
+ 'type' => 'datetime',
183
+ ));
184
+
185
+ $this->addColumn('update_time', array(
186
+ 'header' => Mage::helper('cms')->__('Last Modified'),
187
+ 'index' => 'update_time',
188
+ 'type' => 'datetime',
189
+ ));
190
+
191
+ $this->addColumn('page_actions', array(
192
+ 'header' => Mage::helper('cms')->__('Action'),
193
+ 'width' => 10,
194
+ 'sortable' => false,
195
+ 'filter' => false,
196
+ 'renderer' => 'adminhtml/cms_page_grid_renderer_action',
197
+ ));
198
+
199
+
200
+ return parent::_prepareColumns();
201
+ }
202
+ protected function _afterLoadCollection()
203
+ {
204
+ $this->getCollection()->walk('afterLoad');
205
+ parent::_afterLoadCollection();
206
+ }
207
+
208
+ protected function _filterStoreCondition($collection, $column)
209
+ {
210
+ if (!$value = $column->getFilter()->getValue()) {
211
+ return;
212
+ }
213
+
214
+ $this->getCollection()->addStoreFilter($value);
215
+ }
216
+ /**
217
+ * Retrieve selected upsell products
218
+ *
219
+ * @return array
220
+ */
221
+ protected function _getSelectedCms()
222
+ {
223
+ $cms = $this->getProductsCms();
224
+ /* if (!is_array($products)) {
225
+ $cms = array_keys($this->getSelectedCmsProducts());
226
+ }*/
227
+ $cmscollection = Mage::getModel('productcms/productcms')->getCollection();
228
+ $cmscollection->addFieldToFilter('product_id',$this->_getProduct()->getId());
229
+ $cmsarr = '';
230
+ foreach($cmscollection as $cms){
231
+ $cmsarr .= '&'.$cms->getPageId();
232
+ }
233
+ $cms = explode('&',$cmsarr);
234
+ return $cms;
235
+ }
236
+
237
+ /**
238
+ * Retrieve upsell products
239
+ *
240
+ * @return array
241
+ */
242
+ public function getSelectedCms()
243
+ {
244
+ $cms = array();
245
+ foreach (Mage::registry('current_product')->getCmsProducts() as $product) {
246
+ $cms[$product->getId()] = array('position' => $product->getPosition());
247
+ }
248
+ return $cms;
249
+ }
250
+ /**
251
+ * Rerieve grid URL
252
+ *
253
+ * @return string
254
+ */
255
+ public function getGridUrl()
256
+ {
257
+ return $this->_getData('grid_url') ? $this->_getData('grid_url') : $this->getUrl('*/*/cmsGrid', array('_current'=>true));
258
+ }
259
+
260
+
261
+ }
app/code/local/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs.php ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * admin product edit tabs
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
35
+ {
36
+ protected $_attributeTabBlock = 'adminhtml/catalog_product_edit_tab_attributes';
37
+
38
+ public function __construct()
39
+ {
40
+ parent::__construct();
41
+ $this->setId('product_info_tabs');
42
+ $this->setDestElementId('product_edit_form');
43
+ $this->setTitle(Mage::helper('catalog')->__('Product Information'));
44
+ }
45
+
46
+ protected function _prepareLayout()
47
+ {
48
+ $product = $this->getProduct();
49
+
50
+ if (!($setId = $product->getAttributeSetId())) {
51
+ $setId = $this->getRequest()->getParam('set', null);
52
+ }
53
+
54
+ if ($setId) {
55
+ $groupCollection = Mage::getResourceModel('eav/entity_attribute_group_collection')
56
+ ->setAttributeSetFilter($setId)
57
+ ->setSortOrder()
58
+ ->load();
59
+
60
+ foreach ($groupCollection as $group) {
61
+ $attributes = $product->getAttributes($group->getId(), true);
62
+ // do not add groups without attributes
63
+
64
+ foreach ($attributes as $key => $attribute) {
65
+ if( !$attribute->getIsVisible() ) {
66
+ unset($attributes[$key]);
67
+ }
68
+ }
69
+
70
+ if (count($attributes)==0) {
71
+ continue;
72
+ }
73
+
74
+ $this->addTab('group_'.$group->getId(), array(
75
+ 'label' => Mage::helper('catalog')->__($group->getAttributeGroupName()),
76
+ 'content' => $this->_translateHtml($this->getLayout()->createBlock($this->getAttributeTabBlock(),
77
+ 'adminhtml.catalog.product.edit.tab.attributes')->setGroup($group)
78
+ ->setGroupAttributes($attributes)
79
+ ->toHtml()),
80
+ ));
81
+ }
82
+
83
+ if (Mage::helper('core')->isModuleEnabled('Mage_CatalogInventory')) {
84
+ $this->addTab('inventory', array(
85
+ 'label' => Mage::helper('catalog')->__('Inventory'),
86
+ 'content' => $this->_translateHtml($this->getLayout()
87
+ ->createBlock('adminhtml/catalog_product_edit_tab_inventory')->toHtml()),
88
+ ));
89
+ }
90
+
91
+ /**
92
+ * Don't display website tab for single mode
93
+ */
94
+ if (!Mage::app()->isSingleStoreMode()) {
95
+ $this->addTab('websites', array(
96
+ 'label' => Mage::helper('catalog')->__('Websites'),
97
+ 'content' => $this->_translateHtml($this->getLayout()
98
+ ->createBlock('adminhtml/catalog_product_edit_tab_websites')->toHtml()),
99
+ ));
100
+ }
101
+
102
+ $this->addTab('categories', array(
103
+ 'label' => Mage::helper('catalog')->__('Categories'),
104
+ 'url' => $this->getUrl('*/*/categories', array('_current' => true)),
105
+ 'class' => 'ajax',
106
+ ));
107
+
108
+ $this->addTab('related', array(
109
+ 'label' => Mage::helper('catalog')->__('Related Products'),
110
+ 'url' => $this->getUrl('*/*/related', array('_current' => true)),
111
+ 'class' => 'ajax',
112
+ ));
113
+
114
+ $this->addTab('upsell', array(
115
+ 'label' => Mage::helper('catalog')->__('Up-sells'),
116
+ 'url' => $this->getUrl('*/*/upsell', array('_current' => true)),
117
+ 'class' => 'ajax',
118
+ ));
119
+
120
+ $this->addTab('crosssell', array(
121
+ 'label' => Mage::helper('catalog')->__('Cross-sells'),
122
+ 'url' => $this->getUrl('*/*/crosssell', array('_current' => true)),
123
+ 'class' => 'ajax',
124
+ ));
125
+
126
+ $storeId = 0;
127
+ if ($this->getRequest()->getParam('store')) {
128
+ $storeId = Mage::app()->getStore($this->getRequest()->getParam('store'))->getId();
129
+ }
130
+
131
+ $alertPriceAllow = Mage::getStoreConfig('catalog/productalert/allow_price');
132
+ $alertStockAllow = Mage::getStoreConfig('catalog/productalert/allow_stock');
133
+
134
+ if (($alertPriceAllow || $alertStockAllow) && !$product->isGrouped()) {
135
+ $this->addTab('productalert', array(
136
+ 'label' => Mage::helper('catalog')->__('Product Alerts'),
137
+ 'content' => $this->_translateHtml($this->getLayout()
138
+ ->createBlock('adminhtml/catalog_product_edit_tab_alerts', 'admin.alerts.products')->toHtml())
139
+ ));
140
+ }
141
+
142
+ if( $this->getRequest()->getParam('id', false) ) {
143
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_Review')) {
144
+ if (Mage::getSingleton('admin/session')->isAllowed('admin/catalog/reviews_ratings')){
145
+ $this->addTab('reviews', array(
146
+ 'label' => Mage::helper('catalog')->__('Product Reviews'),
147
+ 'url' => $this->getUrl('*/*/reviews', array('_current' => true)),
148
+ 'class' => 'ajax',
149
+ ));
150
+ }
151
+ }
152
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_Tag')) {
153
+ if (Mage::getSingleton('admin/session')->isAllowed('admin/catalog/tag')){
154
+ $this->addTab('tags', array(
155
+ 'label' => Mage::helper('catalog')->__('Product Tags'),
156
+ 'url' => $this->getUrl('*/*/tagGrid', array('_current' => true)),
157
+ 'class' => 'ajax',
158
+ ));
159
+
160
+ $this->addTab('customers_tags', array(
161
+ 'label' => Mage::helper('catalog')->__('Customers Tagged Product'),
162
+ 'url' => $this->getUrl('*/*/tagCustomerGrid', array('_current' => true)),
163
+ 'class' => 'ajax',
164
+ ));
165
+ }
166
+ }
167
+
168
+ }
169
+
170
+ /**
171
+ * Do not change this tab id
172
+ * @see Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs_Configurable
173
+ * @see Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tabs
174
+ */
175
+ if (!$product->isGrouped()) {
176
+ $this->addTab('customer_options', array(
177
+ 'label' => Mage::helper('catalog')->__('Custom Options'),
178
+ 'url' => $this->getUrl('*/*/options', array('_current' => true)),
179
+ 'class' => 'ajax',
180
+ ));
181
+ }
182
+
183
+ }
184
+ else {
185
+ $this->addTab('set', array(
186
+ 'label' => Mage::helper('catalog')->__('Settings'),
187
+ 'content' => $this->_translateHtml($this->getLayout()
188
+ ->createBlock('adminhtml/catalog_product_edit_tab_settings')->toHtml()),
189
+ 'active' => true
190
+ ));
191
+ }
192
+ // add cms tab
193
+ $this->addTab('cms', array(
194
+ 'label' => Mage::helper('catalog')->__('CMS PAGE'),
195
+ 'url' => $this->getUrl('*/*/cms', array('_current' => true)),
196
+ 'class' => 'ajax',
197
+ ));
198
+ // end add cms tab
199
+ return parent::_prepareLayout();
200
+ }
201
+
202
+ /**
203
+ * Retrive product object from object if not from registry
204
+ *
205
+ * @return Mage_Catalog_Model_Product
206
+ */
207
+ public function getProduct()
208
+ {
209
+ if (!($this->getData('product') instanceof Mage_Catalog_Model_Product)) {
210
+ $this->setData('product', Mage::registry('product'));
211
+ }
212
+ return $this->getData('product');
213
+ }
214
+
215
+ /**
216
+ * Getting attribute block name for tabs
217
+ *
218
+ * @return string
219
+ */
220
+ public function getAttributeTabBlock()
221
+ {
222
+ if (is_null(Mage::helper('adminhtml/catalog')->getAttributeTabBlock())) {
223
+ return $this->_attributeTabBlock;
224
+ }
225
+ return Mage::helper('adminhtml/catalog')->getAttributeTabBlock();
226
+ }
227
+
228
+ public function setAttributeTabBlock($attributeTabBlock)
229
+ {
230
+ $this->_attributeTabBlock = $attributeTabBlock;
231
+ return $this;
232
+ }
233
+
234
+ /**
235
+ * Translate html content
236
+ *
237
+ * @param string $html
238
+ * @return string
239
+ */
240
+ protected function _translateHtml($html)
241
+ {
242
+ Mage::getSingleton('core/translate_inline')->processResponseBody($html);
243
+ return $html;
244
+ }
245
+ }
app/code/local/Mageex/Productcms/Block/Productcms.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Mageex_Productcms_Block_Productcms extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getProductcms()
10
+ {
11
+ if (!$this->hasData('productcms')) {
12
+ $this->setData('productcms', Mage::registry('productcms'));
13
+ }
14
+ return $this->getData('productcms');
15
+
16
+ }
17
+ }
app/code/local/Mageex/Productcms/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mageex_Productcms_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/local/Mageex/Productcms/Model/Mysql4/Productcms.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mageex_Productcms_Model_Mysql4_Productcms extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the productcms_id refers to the key field in your database table.
8
+ $this->_init('productcms/productcms', 'productcms_id');
9
+ }
10
+ }
app/code/local/Mageex/Productcms/Model/Mysql4/Productcms/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mageex_Productcms_Model_Mysql4_Productcms_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('productcms/productcms');
9
+ }
10
+ }
app/code/local/Mageex/Productcms/Model/Productcms.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mageex_Productcms_Model_Productcms extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('productcms/productcms');
9
+ }
10
+ }
app/code/local/Mageex/Productcms/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mageex_Productcms_Model_Status extends Varien_Object
4
+ {
5
+ const STATUS_ENABLED = 1;
6
+ const STATUS_DISABLED = 2;
7
+
8
+ static public function getOptionArray()
9
+ {
10
+ return array(
11
+ self::STATUS_ENABLED => Mage::helper('productcms')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('productcms')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/local/Mageex/Productcms/controllers/Adminhtml/Catalog/ProductController.php ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'Mage/Adminhtml/controllers/Catalog/ProductController.php';
3
+ class Mageex_Productcms_Adminhtml_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController
4
+ {
5
+
6
+ /**
7
+ * Get Cms products grid and serializer block
8
+ */
9
+ public function cmsAction()
10
+ {
11
+ $this->_initProduct();
12
+ $this->loadLayout();
13
+ $this->getLayout()->getBlock('catalog.product.edit.tab.cms');
14
+ // ->setProductsCms($this->getRequest()->getPost('products_cms', null));
15
+ $this->renderLayout();
16
+ }
17
+ /**
18
+ * Get cms products grid
19
+ */
20
+ public function cmsGridAction()
21
+ {
22
+ $this->_initProduct();
23
+ $this->loadLayout();
24
+ $this->getLayout()->getBlock('catalog.product.edit.tab.cms')
25
+ ->setProductsCms($this->getRequest()->getPost('products_cms', null));
26
+ $this->renderLayout();
27
+ }
28
+
29
+ /**
30
+ * Initialize product before saving
31
+ */
32
+ protected function _initProductSave()
33
+ {
34
+ $product = $this->_initProduct();
35
+ $productData = $this->getRequest()->getPost('product');
36
+ if ($productData && !isset($productData['stock_data']['use_config_manage_stock'])) {
37
+ $productData['stock_data']['use_config_manage_stock'] = 0;
38
+ }
39
+
40
+ /**
41
+ * Websites
42
+ */
43
+ if (!isset($productData['website_ids'])) {
44
+ $productData['website_ids'] = array();
45
+ }
46
+
47
+ $wasLockedMedia = false;
48
+ if ($product->isLockedAttribute('media')) {
49
+ $product->unlockAttribute('media');
50
+ $wasLockedMedia = true;
51
+ }
52
+
53
+ $product->addData($productData);
54
+
55
+ if ($wasLockedMedia) {
56
+ $product->lockAttribute('media');
57
+ }
58
+
59
+ if (Mage::app()->isSingleStoreMode()) {
60
+ $product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));
61
+ }
62
+
63
+ /**
64
+ * Create Permanent Redirect for old URL key
65
+ */
66
+ if ($product->getId() && isset($productData['url_key_create_redirect']))
67
+ // && $product->getOrigData('url_key') != $product->getData('url_key')
68
+ {
69
+ $product->setData('save_rewrites_history', (bool)$productData['url_key_create_redirect']);
70
+ }
71
+
72
+ /**
73
+ * Check "Use Default Value" checkboxes values
74
+ */
75
+ if ($useDefaults = $this->getRequest()->getPost('use_default')) {
76
+ foreach ($useDefaults as $attributeCode) {
77
+ $product->setData($attributeCode, false);
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Init product links data (related, upsell, crosssel)
83
+ */
84
+ $links = $this->getRequest()->getPost('links');
85
+ if (isset($links['related']) && !$product->getRelatedReadonly()) {
86
+ $product->setRelatedLinkData(Mage::helper('adminhtml/js')->decodeGridSerializedInput($links['related']));
87
+ }
88
+ if (isset($links['upsell']) && !$product->getUpsellReadonly()) {
89
+ $product->setUpSellLinkData(Mage::helper('adminhtml/js')->decodeGridSerializedInput($links['upsell']));
90
+ }
91
+ $product->setCmsLinkData(Mage::helper('adminhtml/js')->decodeGridSerializedInput($links['cms']));
92
+ if (isset($links['crosssell']) && !$product->getCrosssellReadonly()) {
93
+ $product->setCrossSellLinkData(Mage::helper('adminhtml/js')
94
+ ->decodeGridSerializedInput($links['crosssell']));
95
+ }
96
+ if (isset($links['grouped']) && !$product->getGroupedReadonly()) {
97
+ $product->setGroupedLinkData(Mage::helper('adminhtml/js')->decodeGridSerializedInput($links['grouped']));
98
+ }
99
+
100
+ /**
101
+ * Initialize product categories
102
+ */
103
+ $categoryIds = $this->getRequest()->getPost('category_ids');
104
+ if (null !== $categoryIds) {
105
+ if (empty($categoryIds)) {
106
+ $categoryIds = array();
107
+ }
108
+ $product->setCategoryIds($categoryIds);
109
+ }
110
+
111
+ /**
112
+ * Initialize data for configurable product
113
+ */
114
+ if (($data = $this->getRequest()->getPost('configurable_products_data'))
115
+ && !$product->getConfigurableReadonly()) {
116
+ $product->setConfigurableProductsData(Mage::helper('core')->jsonDecode($data));
117
+ }
118
+ if (($data = $this->getRequest()->getPost('configurable_attributes_data'))
119
+ && !$product->getConfigurableReadonly()) {
120
+ $product->setConfigurableAttributesData(Mage::helper('core')->jsonDecode($data));
121
+ }
122
+
123
+ $product->setCanSaveConfigurableAttributes(
124
+ (bool)$this->getRequest()->getPost('affect_configurable_product_attributes')
125
+ && !$product->getConfigurableReadonly()
126
+ );
127
+
128
+ /**
129
+ * Initialize product options
130
+ */
131
+ if (isset($productData['options']) && !$product->getOptionsReadonly()) {
132
+ $product->setProductOptions($productData['options']);
133
+ }
134
+
135
+ $product->setCanSaveCustomOptions(
136
+ (bool)$this->getRequest()->getPost('affect_product_custom_options')
137
+ && !$product->getOptionsReadonly()
138
+ );
139
+
140
+ Mage::dispatchEvent(
141
+ 'catalog_product_prepare_save',
142
+ array('product' => $product, 'request' => $this->getRequest())
143
+ );
144
+
145
+ return $product;
146
+ }
147
+
148
+ /**
149
+ * Save product action
150
+ */
151
+ public function saveAction()
152
+ {
153
+
154
+ $storeId = $this->getRequest()->getParam('store');
155
+ $redirectBack = $this->getRequest()->getParam('back', false);
156
+ $productId = $this->getRequest()->getParam('id');
157
+ $isEdit = (int)($this->getRequest()->getParam('id') != null);
158
+
159
+ $data = $this->getRequest()->getPost();
160
+
161
+ if ($data) {
162
+ if (!isset($data['product']['stock_data']['use_config_manage_stock'])) {
163
+ $data['product']['stock_data']['use_config_manage_stock'] = 0;
164
+ }
165
+ $product = $this->_initProductSave();
166
+
167
+ try {
168
+ $product->save();
169
+ $productId = $product->getId();
170
+ // Save cms product
171
+ $cms = $data['links']['cms'];
172
+ // Check cms
173
+ if($cms!=''){
174
+ $cmscollection=Mage::getModel('productcms/productcms')->getCollection();
175
+ $cmscollection->addFieldToFilter('product_id',$productId);
176
+ if(!sizeOf($cmscollection)){
177
+ $cmscollection=Mage::getModel('productcms/productcms');
178
+ $cmscollection->setProductId($productId);
179
+ $cmscollection->setPageId($cms);
180
+ $cmscollection->save();
181
+ }else{
182
+ foreach($cmscollection as $cmsc){
183
+ $cmsc->setPageId($cms);
184
+ $cmsc->save();
185
+ }
186
+ }
187
+ }
188
+ // end save product cms
189
+ /**
190
+ * Do copying data to stores
191
+ */
192
+ if (isset($data['copy_to_stores'])) {
193
+ foreach ($data['copy_to_stores'] as $storeTo=>$storeFrom) {
194
+ $newProduct = Mage::getModel('catalog/product')
195
+ ->setStoreId($storeFrom)
196
+ ->load($productId)
197
+ ->setStoreId($storeTo)
198
+ ->save();
199
+ }
200
+ }
201
+
202
+ Mage::getModel('catalogrule/rule')->applyAllRulesToProduct($productId);
203
+
204
+ $this->_getSession()->addSuccess($this->__('The product has been saved.'));
205
+ }
206
+ catch (Mage_Core_Exception $e) {
207
+ $this->_getSession()->addError($e->getMessage())
208
+ ->setProductData($data);
209
+ $redirectBack = true;
210
+ }
211
+ catch (Exception $e) {
212
+ Mage::logException($e);
213
+ $this->_getSession()->addError($e->getMessage());
214
+ $redirectBack = true;
215
+ }
216
+ }
217
+
218
+ if ($redirectBack) {
219
+ $this->_redirect('*/*/edit', array(
220
+ 'id' => $productId,
221
+ '_current'=>true
222
+ ));
223
+ }
224
+ else if($this->getRequest()->getParam('popup')) {
225
+ $this->_redirect('*/*/created', array(
226
+ '_current' => true,
227
+ 'id' => $productId,
228
+ 'edit' => $isEdit
229
+ ));
230
+ }
231
+ else {
232
+ $this->_redirect('*/*/', array('store'=>$storeId));
233
+ }
234
+ }
235
+
236
+
237
+ }
238
+ ?>
app/code/local/Mageex/Productcms/controllers/Adminhtml/Catalog/ProductController__.php ADDED
@@ -0,0 +1,1128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'Mage/Adminhtml/controllers/Catalog/ProductController.php';
3
+ class Mageex_Productcms_Adminhtml_Catalog_ProductController extends Mage_Adminhtml_Catalog_ProductController
4
+ {
5
+ /**
6
+ * Array of actions which can be processed without secret key validation
7
+ *
8
+ * @var array
9
+ */
10
+ protected $_publicActions = array('edit');
11
+
12
+ protected function _construct()
13
+ {
14
+ // Define module dependent translate
15
+ $this->setUsedModuleName('Mage_Catalog');
16
+ }
17
+
18
+ /**
19
+ * Initialize product from request parameters
20
+ *
21
+ * @return Mage_Catalog_Model_Product
22
+ */
23
+ protected function _initProduct()
24
+ {
25
+ $this->_title($this->__('Catalog'))
26
+ ->_title($this->__('Manage Products'));
27
+
28
+ $productId = (int) $this->getRequest()->getParam('id');
29
+ $product = Mage::getModel('catalog/product')
30
+ ->setStoreId($this->getRequest()->getParam('store', 0));
31
+
32
+ if (!$productId) {
33
+ if ($setId = (int) $this->getRequest()->getParam('set')) {
34
+ $product->setAttributeSetId($setId);
35
+ }
36
+
37
+ if ($typeId = $this->getRequest()->getParam('type')) {
38
+ $product->setTypeId($typeId);
39
+ }
40
+ }
41
+
42
+ $product->setData('_edit_mode', true);
43
+ if ($productId) {
44
+ try {
45
+ $product->load($productId);
46
+ } catch (Exception $e) {
47
+ $product->setTypeId(Mage_Catalog_Model_Product_Type::DEFAULT_TYPE);
48
+ Mage::logException($e);
49
+ }
50
+ }
51
+
52
+ $attributes = $this->getRequest()->getParam('attributes');
53
+ if ($attributes && $product->isConfigurable() &&
54
+ (!$productId || !$product->getTypeInstance()->getUsedProductAttributeIds())) {
55
+ $product->getTypeInstance()->setUsedProductAttributeIds(
56
+ explode(",", base64_decode(urldecode($attributes)))
57
+ );
58
+ }
59
+
60
+ // Required attributes of simple product for configurable creation
61
+ if ($this->getRequest()->getParam('popup')
62
+ && $requiredAttributes = $this->getRequest()->getParam('required')) {
63
+ $requiredAttributes = explode(",", $requiredAttributes);
64
+ foreach ($product->getAttributes() as $attribute) {
65
+ if (in_array($attribute->getId(), $requiredAttributes)) {
66
+ $attribute->setIsRequired(1);
67
+ }
68
+ }
69
+ }
70
+
71
+ if ($this->getRequest()->getParam('popup')
72
+ && $this->getRequest()->getParam('product')
73
+ && !is_array($this->getRequest()->getParam('product'))
74
+ && $this->getRequest()->getParam('id', false) === false) {
75
+
76
+ $configProduct = Mage::getModel('catalog/product')
77
+ ->setStoreId(0)
78
+ ->load($this->getRequest()->getParam('product'))
79
+ ->setTypeId($this->getRequest()->getParam('type'));
80
+
81
+ /* @var $configProduct Mage_Catalog_Model_Product */
82
+ $data = array();
83
+ foreach ($configProduct->getTypeInstance()->getEditableAttributes() as $attribute) {
84
+
85
+ /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
86
+ if(!$attribute->getIsUnique()
87
+ && $attribute->getFrontend()->getInputType()!='gallery'
88
+ && $attribute->getAttributeCode() != 'required_options'
89
+ && $attribute->getAttributeCode() != 'has_options'
90
+ && $attribute->getAttributeCode() != $configProduct->getIdFieldName()) {
91
+ $data[$attribute->getAttributeCode()] = $configProduct->getData($attribute->getAttributeCode());
92
+ }
93
+ }
94
+
95
+ $product->addData($data)
96
+ ->setWebsiteIds($configProduct->getWebsiteIds());
97
+ }
98
+
99
+ Mage::register('product', $product);
100
+ Mage::register('current_product', $product);
101
+ Mage::getSingleton('cms/wysiwyg_config')->setStoreId($this->getRequest()->getParam('store'));
102
+ return $product;
103
+ }
104
+
105
+ /**
106
+ * Create serializer block for a grid
107
+ *
108
+ * @param string $inputName
109
+ * @param Mage_Adminhtml_Block_Widget_Grid $gridBlock
110
+ * @param array $productsArray
111
+ * @return Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Ajax_Serializer
112
+ */
113
+ protected function _createSerializerBlock($inputName, Mage_Adminhtml_Block_Widget_Grid $gridBlock, $productsArray)
114
+ {
115
+ return $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_ajax_serializer')
116
+ ->setGridBlock($gridBlock)
117
+ ->setProducts($productsArray)
118
+ ->setInputElementName($inputName)
119
+ ;
120
+ }
121
+
122
+ /**
123
+ * Output specified blocks as a text list
124
+ */
125
+ protected function _outputBlocks()
126
+ {
127
+ $blocks = func_get_args();
128
+ $output = $this->getLayout()->createBlock('adminhtml/text_list');
129
+ foreach ($blocks as $block) {
130
+ $output->insert($block, '', true);
131
+ }
132
+ $this->getResponse()->setBody($output->toHtml());
133
+ }
134
+
135
+ /**
136
+ * Product list page
137
+ */
138
+ public function indexAction()
139
+ {
140
+ $this->_title($this->__('Catalog'))
141
+ ->_title($this->__('Manage Products'));
142
+
143
+ $this->loadLayout();
144
+ $this->_setActiveMenu('catalog/products');
145
+ $this->renderLayout();
146
+ }
147
+
148
+ /**
149
+ * Create new product page
150
+ */
151
+ public function newAction()
152
+ {
153
+ $product = $this->_initProduct();
154
+
155
+ $this->_title($this->__('New Product'));
156
+
157
+ Mage::dispatchEvent('catalog_product_new_action', array('product' => $product));
158
+
159
+ if ($this->getRequest()->getParam('popup')) {
160
+ $this->loadLayout('popup');
161
+ } else {
162
+ $_additionalLayoutPart = '';
163
+ if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE
164
+ && !($product->getTypeInstance()->getUsedProductAttributeIds()))
165
+ {
166
+ $_additionalLayoutPart = '_new';
167
+ }
168
+ $this->loadLayout(array(
169
+ 'default',
170
+ strtolower($this->getFullActionName()),
171
+ 'adminhtml_catalog_product_'.$product->getTypeId() . $_additionalLayoutPart
172
+ ));
173
+ $this->_setActiveMenu('catalog/products');
174
+ }
175
+
176
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
177
+
178
+ $block = $this->getLayout()->getBlock('catalog.wysiwyg.js');
179
+ if ($block) {
180
+ $block->setStoreId($product->getStoreId());
181
+ }
182
+
183
+ $this->renderLayout();
184
+ }
185
+
186
+ /**
187
+ * Product edit form
188
+ */
189
+ public function editAction()
190
+ {
191
+ $productId = (int) $this->getRequest()->getParam('id');
192
+ $product = $this->_initProduct();
193
+
194
+ if ($productId && !$product->getId()) {
195
+ $this->_getSession()->addError(Mage::helper('catalog')->__('This product no longer exists.'));
196
+ $this->_redirect('*/*/');
197
+ return;
198
+ }
199
+
200
+ $this->_title($product->getName());
201
+
202
+ Mage::dispatchEvent('catalog_product_edit_action', array('product' => $product));
203
+
204
+ $_additionalLayoutPart = '';
205
+ if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE
206
+ && !($product->getTypeInstance()->getUsedProductAttributeIds()))
207
+ {
208
+ $_additionalLayoutPart = '_new';
209
+ }
210
+
211
+ $this->loadLayout(array(
212
+ 'default',
213
+ strtolower($this->getFullActionName()),
214
+ 'adminhtml_catalog_product_'.$product->getTypeId() . $_additionalLayoutPart
215
+ ));
216
+
217
+ $this->_setActiveMenu('catalog/products');
218
+
219
+ if (!Mage::app()->isSingleStoreMode() && ($switchBlock = $this->getLayout()->getBlock('store_switcher'))) {
220
+ $switchBlock->setDefaultStoreName($this->__('Default Values'))
221
+ ->setWebsiteIds($product->getWebsiteIds())
222
+ ->setSwitchUrl(
223
+ $this->getUrl('*/*/*', array('_current'=>true, 'active_tab'=>null, 'tab' => null, 'store'=>null))
224
+ );
225
+ }
226
+
227
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
228
+
229
+ $block = $this->getLayout()->getBlock('catalog.wysiwyg.js');
230
+ if ($block) {
231
+ $block->setStoreId($product->getStoreId());
232
+ }
233
+
234
+ $this->renderLayout();
235
+ }
236
+
237
+ /**
238
+ * WYSIWYG editor action for ajax request
239
+ *
240
+ */
241
+ public function wysiwygAction()
242
+ {
243
+ $elementId = $this->getRequest()->getParam('element_id', md5(microtime()));
244
+ $storeId = $this->getRequest()->getParam('store_id', 0);
245
+ $storeMediaUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
246
+
247
+ $content = $this->getLayout()->createBlock('adminhtml/catalog_helper_form_wysiwyg_content', '', array(
248
+ 'editor_element_id' => $elementId,
249
+ 'store_id' => $storeId,
250
+ 'store_media_url' => $storeMediaUrl,
251
+ ));
252
+ $this->getResponse()->setBody($content->toHtml());
253
+ }
254
+
255
+ /**
256
+ * Product grid for AJAX request
257
+ */
258
+ public function gridAction()
259
+ {
260
+ $this->loadLayout();
261
+ $this->renderLayout();
262
+ }
263
+
264
+ /**
265
+ * Get specified tab grid
266
+ */
267
+ public function gridOnlyAction()
268
+ {
269
+ $this->_initProduct();
270
+ $this->loadLayout();
271
+ $this->getResponse()->setBody(
272
+ $this->getLayout()
273
+ ->createBlock('adminhtml/catalog_product_edit_tab_' . $this->getRequest()->getParam('gridOnlyBlock'))
274
+ ->toHtml()
275
+ );
276
+ }
277
+
278
+ /**
279
+ * Get categories fieldset block
280
+ *
281
+ */
282
+ public function categoriesAction()
283
+ {
284
+ $this->_initProduct();
285
+ $this->loadLayout();
286
+ $this->renderLayout();
287
+ }
288
+
289
+ /**
290
+ * Get options fieldset block
291
+ *
292
+ */
293
+ public function optionsAction()
294
+ {
295
+ $this->_initProduct();
296
+ $this->loadLayout();
297
+ $this->renderLayout();
298
+ }
299
+
300
+ /**
301
+ * Get related products grid and serializer block
302
+ */
303
+ public function relatedAction()
304
+ {
305
+ $this->_initProduct();
306
+ $this->loadLayout();
307
+ $this->getLayout()->getBlock('catalog.product.edit.tab.related')
308
+ ->setProductsRelated($this->getRequest()->getPost('products_related', null));
309
+ $this->renderLayout();
310
+ }
311
+
312
+ /**
313
+ * Get upsell products grid and serializer block
314
+ */
315
+ public function upsellAction()
316
+ {
317
+ $this->_initProduct();
318
+ $this->loadLayout();
319
+ $this->getLayout()->getBlock('catalog.product.edit.tab.upsell')
320
+ ->setProductsUpsell($this->getRequest()->getPost('products_upsell', null));
321
+ $this->renderLayout();
322
+ }
323
+
324
+ /**
325
+ * Get Cms products grid and serializer block
326
+ */
327
+ public function cmsAction()
328
+ {
329
+ $this->_initProduct();
330
+ $this->loadLayout();
331
+ $this->getLayout()->getBlock('catalog.product.edit.tab.cms');
332
+ // ->setProductsCms($this->getRequest()->getPost('products_cms', null));
333
+ $this->renderLayout();
334
+ }
335
+
336
+ /**
337
+ * Get crosssell products grid and serializer block
338
+ */
339
+ public function crosssellAction()
340
+ {
341
+ $this->_initProduct();
342
+ $this->loadLayout();
343
+ $this->getLayout()->getBlock('catalog.product.edit.tab.crosssell')
344
+ ->setProductsCrossSell($this->getRequest()->getPost('products_crosssell', null));
345
+ $this->renderLayout();
346
+ }
347
+
348
+ /**
349
+ * Get related products grid
350
+ */
351
+ public function relatedGridAction()
352
+ {
353
+ $this->_initProduct();
354
+ $this->loadLayout();
355
+ $this->getLayout()->getBlock('catalog.product.edit.tab.related')
356
+ ->setProductsRelated($this->getRequest()->getPost('products_related', null));
357
+ $this->renderLayout();
358
+ }
359
+
360
+ /**
361
+ * Get upsell products grid
362
+ */
363
+ public function upsellGridAction()
364
+ {
365
+ $this->_initProduct();
366
+ $this->loadLayout();
367
+ $this->getLayout()->getBlock('catalog.product.edit.tab.upsell')
368
+ ->setProductsRelated($this->getRequest()->getPost('products_upsell', null));
369
+ $this->renderLayout();
370
+ }
371
+
372
+ /**
373
+ * Get cms products grid
374
+ */
375
+ public function cmsGridAction()
376
+ {
377
+ $this->_initProduct();
378
+ $this->loadLayout();
379
+ $this->getLayout()->getBlock('catalog.product.edit.tab.cms')
380
+ ->setProductsCms($this->getRequest()->getPost('products_cms', null));
381
+ $this->renderLayout();
382
+ }
383
+
384
+ /**
385
+ * Get crosssell products grid
386
+ */
387
+ public function crosssellGridAction()
388
+ {
389
+ $this->_initProduct();
390
+ $this->loadLayout();
391
+ $this->getLayout()->getBlock('catalog.product.edit.tab.crosssell')
392
+ ->setProductsRelated($this->getRequest()->getPost('products_crosssell', null));
393
+ $this->renderLayout();
394
+ }
395
+
396
+ /**
397
+ * Get associated grouped products grid and serializer block
398
+ */
399
+ public function superGroupAction()
400
+ {
401
+ $this->_initProduct();
402
+ $this->loadLayout();
403
+ $this->getLayout()->getBlock('catalog.product.edit.tab.super.group')
404
+ ->setProductsGrouped($this->getRequest()->getPost('products_grouped', null));
405
+ $this->renderLayout();
406
+ }
407
+
408
+ /**
409
+ * Get associated grouped products grid only
410
+ *
411
+ */
412
+ public function superGroupGridOnlyAction()
413
+ {
414
+ $this->_initProduct();
415
+ $this->loadLayout();
416
+ $this->getLayout()->getBlock('catalog.product.edit.tab.super.group')
417
+ ->setProductsGrouped($this->getRequest()->getPost('products_grouped', null));
418
+ $this->renderLayout();
419
+ }
420
+
421
+ /**
422
+ * Get product reviews grid
423
+ *
424
+ */
425
+ public function reviewsAction()
426
+ {
427
+ $this->_initProduct();
428
+ $this->loadLayout();
429
+ $this->getLayout()->getBlock('admin.product.reviews')
430
+ ->setProductId(Mage::registry('product')->getId())
431
+ ->setUseAjax(true);
432
+ $this->renderLayout();
433
+ }
434
+
435
+ /**
436
+ * Get super config grid
437
+ *
438
+ */
439
+ public function superConfigAction()
440
+ {
441
+ $this->_initProduct();
442
+ $this->getResponse()->setBody(
443
+ $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_super_config_grid')->toHtml()
444
+ );
445
+ }
446
+
447
+ /**
448
+ * Deprecated since 1.2
449
+ *
450
+ */
451
+ public function bundlesAction()
452
+ {
453
+ $product = $this->_initProduct();
454
+ $this->getResponse()->setBody(
455
+ $this->getLayout()
456
+ ->createBlock('bundle/adminhtml_catalog_product_edit_tab_bundle', 'admin.product.bundle.items')
457
+ ->setProductId($product->getId())
458
+ ->toHtml()
459
+ );
460
+ }
461
+
462
+ /**
463
+ * Validate product
464
+ *
465
+ */
466
+ public function validateAction()
467
+ {
468
+ $response = new Varien_Object();
469
+ $response->setError(false);
470
+
471
+ try {
472
+ $productData = $this->getRequest()->getPost('product');
473
+
474
+ if ($productData && !isset($productData['stock_data']['use_config_manage_stock'])) {
475
+ $productData['stock_data']['use_config_manage_stock'] = 0;
476
+ }
477
+ $product = Mage::getModel('catalog/product');
478
+ $product->setData('_edit_mode', true);
479
+ if ($storeId = $this->getRequest()->getParam('store')) {
480
+ $product->setStoreId($storeId);
481
+ }
482
+ if ($setId = $this->getRequest()->getParam('set')) {
483
+ $product->setAttributeSetId($setId);
484
+ }
485
+ if ($typeId = $this->getRequest()->getParam('type')) {
486
+ $product->setTypeId($typeId);
487
+ }
488
+ if ($productId = $this->getRequest()->getParam('id')) {
489
+ $product->load($productId);
490
+ }
491
+
492
+ $dateFields = array();
493
+ $attributes = $product->getAttributes();
494
+ foreach ($attributes as $attrKey => $attribute) {
495
+ if ($attribute->getBackend()->getType() == 'datetime') {
496
+ if (array_key_exists($attrKey, $productData) && $productData[$attrKey] != ''){
497
+ $dateFields[] = $attrKey;
498
+ }
499
+ }
500
+ }
501
+ $productData = $this->_filterDates($productData, $dateFields);
502
+
503
+ $product->addData($productData);
504
+ $product->validate();
505
+ /**
506
+ * @todo implement full validation process with errors returning which are ignoring now
507
+ */
508
+ // if (is_array($errors = $product->validate())) {
509
+ // foreach ($errors as $code => $error) {
510
+ // if ($error === true) {
511
+ // Mage::throwException(Mage::helper('catalog')->__('Attribute "%s" is invalid.', $product->getResource()->getAttribute($code)->getFrontend()->getLabel()));
512
+ // }
513
+ // else {
514
+ // Mage::throwException($error);
515
+ // }
516
+ // }
517
+ // }
518
+ }
519
+ catch (Mage_Eav_Model_Entity_Attribute_Exception $e) {
520
+ $response->setError(true);
521
+ $response->setAttribute($e->getAttributeCode());
522
+ $response->setMessage($e->getMessage());
523
+ }
524
+ catch (Mage_Core_Exception $e) {
525
+ $response->setError(true);
526
+ $response->setMessage($e->getMessage());
527
+ }
528
+ catch (Exception $e) {
529
+ $this->_getSession()->addError($e->getMessage());
530
+ $this->_initLayoutMessages('adminhtml/session');
531
+ $response->setError(true);
532
+ $response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml());
533
+ }
534
+
535
+ $this->getResponse()->setBody($response->toJson());
536
+ }
537
+
538
+ /**
539
+ * Initialize product before saving
540
+ */
541
+ protected function _initProductSave()
542
+ {
543
+ $product = $this->_initProduct();
544
+ $productData = $this->getRequest()->getPost('product');
545
+ if ($productData && !isset($productData['stock_data']['use_config_manage_stock'])) {
546
+ $productData['stock_data']['use_config_manage_stock'] = 0;
547
+ }
548
+
549
+ /**
550
+ * Websites
551
+ */
552
+ if (!isset($productData['website_ids'])) {
553
+ $productData['website_ids'] = array();
554
+ }
555
+
556
+ $wasLockedMedia = false;
557
+ if ($product->isLockedAttribute('media')) {
558
+ $product->unlockAttribute('media');
559
+ $wasLockedMedia = true;
560
+ }
561
+
562
+ $product->addData($productData);
563
+
564
+ if ($wasLockedMedia) {
565
+ $product->lockAttribute('media');
566
+ }
567
+
568
+ if (Mage::app()->isSingleStoreMode()) {
569
+ $product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));
570
+ }
571
+
572
+ /**
573
+ * Create Permanent Redirect for old URL key
574
+ */
575
+ if ($product->getId() && isset($productData['url_key_create_redirect']))
576
+ // && $product->getOrigData('url_key') != $product->getData('url_key')
577
+ {
578
+ $product->setData('save_rewrites_history', (bool)$productData['url_key_create_redirect']);
579
+ }
580
+
581
+ /**
582
+ * Check "Use Default Value" checkboxes values
583
+ */
584
+ if ($useDefaults = $this->getRequest()->getPost('use_default')) {
585
+ foreach ($useDefaults as $attributeCode) {
586
+ $product->setData($attributeCode, false);
587
+ }
588
+ }
589
+
590
+ /**
591
+ * Init product links data (related, upsell, crosssel)
592
+ */
593
+ $links = $this->getRequest()->getPost('links');
594
+ if (isset($links['related']) && !$product->getRelatedReadonly()) {
595
+ $product->setRelatedLinkData(Mage::helper('adminhtml/js')->decodeGridSerializedInput($links['related']));
596
+ }
597
+ if (isset($links['upsell']) && !$product->getUpsellReadonly()) {
598
+ $product->setUpSellLinkData(Mage::helper('adminhtml/js')->decodeGridSerializedInput($links['upsell']));
599
+ }
600
+ $product->setCmsLinkData(Mage::helper('adminhtml/js')->decodeGridSerializedInput($links['cms']));
601
+ if (isset($links['crosssell']) && !$product->getCrosssellReadonly()) {
602
+ $product->setCrossSellLinkData(Mage::helper('adminhtml/js')
603
+ ->decodeGridSerializedInput($links['crosssell']));
604
+ }
605
+ if (isset($links['grouped']) && !$product->getGroupedReadonly()) {
606
+ $product->setGroupedLinkData(Mage::helper('adminhtml/js')->decodeGridSerializedInput($links['grouped']));
607
+ }
608
+
609
+ /**
610
+ * Initialize product categories
611
+ */
612
+ $categoryIds = $this->getRequest()->getPost('category_ids');
613
+ if (null !== $categoryIds) {
614
+ if (empty($categoryIds)) {
615
+ $categoryIds = array();
616
+ }
617
+ $product->setCategoryIds($categoryIds);
618
+ }
619
+
620
+ /**
621
+ * Initialize data for configurable product
622
+ */
623
+ if (($data = $this->getRequest()->getPost('configurable_products_data'))
624
+ && !$product->getConfigurableReadonly()) {
625
+ $product->setConfigurableProductsData(Mage::helper('core')->jsonDecode($data));
626
+ }
627
+ if (($data = $this->getRequest()->getPost('configurable_attributes_data'))
628
+ && !$product->getConfigurableReadonly()) {
629
+ $product->setConfigurableAttributesData(Mage::helper('core')->jsonDecode($data));
630
+ }
631
+
632
+ $product->setCanSaveConfigurableAttributes(
633
+ (bool)$this->getRequest()->getPost('affect_configurable_product_attributes')
634
+ && !$product->getConfigurableReadonly()
635
+ );
636
+
637
+ /**
638
+ * Initialize product options
639
+ */
640
+ if (isset($productData['options']) && !$product->getOptionsReadonly()) {
641
+ $product->setProductOptions($productData['options']);
642
+ }
643
+
644
+ $product->setCanSaveCustomOptions(
645
+ (bool)$this->getRequest()->getPost('affect_product_custom_options')
646
+ && !$product->getOptionsReadonly()
647
+ );
648
+
649
+ Mage::dispatchEvent(
650
+ 'catalog_product_prepare_save',
651
+ array('product' => $product, 'request' => $this->getRequest())
652
+ );
653
+
654
+ return $product;
655
+ }
656
+
657
+ public function categoriesJsonAction()
658
+ {
659
+ $product = $this->_initProduct();
660
+
661
+ $this->getResponse()->setBody(
662
+ $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_categories')
663
+ ->getCategoryChildrenJson($this->getRequest()->getParam('category'))
664
+ );
665
+ }
666
+
667
+ /**
668
+ * Save product action
669
+ */
670
+ public function saveAction()
671
+ {
672
+
673
+ $storeId = $this->getRequest()->getParam('store');
674
+ $redirectBack = $this->getRequest()->getParam('back', false);
675
+ $productId = $this->getRequest()->getParam('id');
676
+ $isEdit = (int)($this->getRequest()->getParam('id') != null);
677
+
678
+ $data = $this->getRequest()->getPost();
679
+
680
+ if ($data) {
681
+ if (!isset($data['product']['stock_data']['use_config_manage_stock'])) {
682
+ $data['product']['stock_data']['use_config_manage_stock'] = 0;
683
+ }
684
+ $product = $this->_initProductSave();
685
+
686
+ try {
687
+ $product->save();
688
+ $productId = $product->getId();
689
+ // Save cms product
690
+ $cms = $data['links']['cms'];
691
+ // Check cms
692
+ if($cms!=''){
693
+ $cmscollection=Mage::getModel('productcms/productcms')->getCollection();
694
+ $cmscollection->addFieldToFilter('product_id',$productId);
695
+ if(!sizeOf($cmscollection)){
696
+ $cmscollection=Mage::getModel('productcms/productcms');
697
+ $cmscollection->setProductId($productId);
698
+ $cmscollection->setPageId($cms);
699
+ $cmscollection->save();
700
+ }else{
701
+ foreach($cmscollection as $cmsc){
702
+ $cmsc->setPageId($cms);
703
+ $cmsc->save();
704
+ }
705
+ }
706
+ }
707
+ // end save product cms
708
+ /**
709
+ * Do copying data to stores
710
+ */
711
+ if (isset($data['copy_to_stores'])) {
712
+ foreach ($data['copy_to_stores'] as $storeTo=>$storeFrom) {
713
+ $newProduct = Mage::getModel('catalog/product')
714
+ ->setStoreId($storeFrom)
715
+ ->load($productId)
716
+ ->setStoreId($storeTo)
717
+ ->save();
718
+ }
719
+ }
720
+
721
+ Mage::getModel('catalogrule/rule')->applyAllRulesToProduct($productId);
722
+
723
+ $this->_getSession()->addSuccess($this->__('The product has been saved.'));
724
+ }
725
+ catch (Mage_Core_Exception $e) {
726
+ $this->_getSession()->addError($e->getMessage())
727
+ ->setProductData($data);
728
+ $redirectBack = true;
729
+ }
730
+ catch (Exception $e) {
731
+ Mage::logException($e);
732
+ $this->_getSession()->addError($e->getMessage());
733
+ $redirectBack = true;
734
+ }
735
+ }
736
+
737
+ if ($redirectBack) {
738
+ $this->_redirect('*/*/edit', array(
739
+ 'id' => $productId,
740
+ '_current'=>true
741
+ ));
742
+ }
743
+ else if($this->getRequest()->getParam('popup')) {
744
+ $this->_redirect('*/*/created', array(
745
+ '_current' => true,
746
+ 'id' => $productId,
747
+ 'edit' => $isEdit
748
+ ));
749
+ }
750
+ else {
751
+ $this->_redirect('*/*/', array('store'=>$storeId));
752
+ }
753
+ }
754
+
755
+ /**
756
+ * Create product duplicate
757
+ */
758
+ public function duplicateAction()
759
+ {
760
+ $product = $this->_initProduct();
761
+ try {
762
+ $newProduct = $product->duplicate();
763
+ $this->_getSession()->addSuccess($this->__('The product has been duplicated.'));
764
+ $this->_redirect('*/*/edit', array('_current'=>true, 'id'=>$newProduct->getId()));
765
+ }
766
+ catch (Exception $e) {
767
+ Mage::logException($e);
768
+ $this->_getSession()->addError($e->getMessage());
769
+ $this->_redirect('*/*/edit', array('_current'=>true));
770
+ }
771
+ }
772
+
773
+ /**
774
+ * @deprecated since 1.4.0.0-alpha2
775
+ */
776
+ protected function _decodeInput($encoded)
777
+ {
778
+ parse_str($encoded, $data);
779
+ foreach($data as $key=>$value) {
780
+ parse_str(base64_decode($value), $data[$key]);
781
+ }
782
+ return $data;
783
+ }
784
+
785
+ /**
786
+ * Delete product action
787
+ */
788
+ public function deleteAction()
789
+ {
790
+ if ($id = $this->getRequest()->getParam('id')) {
791
+ $product = Mage::getModel('catalog/product')
792
+ ->load($id);
793
+ $sku = $product->getSku();
794
+ try {
795
+ $product->delete();
796
+ $this->_getSession()->addSuccess($this->__('The product has been deleted.'));
797
+ }
798
+ catch (Exception $e) {
799
+ $this->_getSession()->addError($e->getMessage());
800
+ }
801
+ }
802
+ $this->getResponse()
803
+ ->setRedirect($this->getUrl('*/*/', array('store'=>$this->getRequest()->getParam('store'))));
804
+ }
805
+
806
+ /**
807
+ * Get tag grid
808
+ */
809
+ public function tagGridAction()
810
+ {
811
+ $this->loadLayout();
812
+ $this->getLayout()->getBlock('admin.product.tags')
813
+ ->setProductId($this->getRequest()->getParam('id'));
814
+ $this->renderLayout();
815
+ }
816
+
817
+ /**
818
+ * Get alerts price grid
819
+ */
820
+ public function alertsPriceGridAction()
821
+ {
822
+ $this->getResponse()->setBody(
823
+ $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_alerts_price')->toHtml()
824
+ );
825
+ }
826
+
827
+ /**
828
+ * Get alerts stock grid
829
+ */
830
+ public function alertsStockGridAction()
831
+ {
832
+ $this->getResponse()->setBody(
833
+ $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_alerts_stock')->toHtml()
834
+ );
835
+ }
836
+
837
+ public function addCustomersToAlertQueueAction()
838
+ {
839
+ $alerts = Mage::getSingleton('customeralert/config')->getAlerts();;
840
+ $block = $this->getLayout()
841
+ ->createBlock('adminhtml/messages', 'messages');
842
+ $collection = $block
843
+ ->getMessageCollection();
844
+ foreach ($alerts as $key=>$val) {
845
+ try {
846
+ if(Mage::getSingleton('customeralert/config')->getAlertByType($key)
847
+ ->setParamValues($this->getRequest()->getParams())
848
+ ->addCustomersToAlertQueue())
849
+ {
850
+ $getTitleByType = Mage::getSingleton('customeralert/config')->getTitleByType($key);
851
+ $collection->addMessage(Mage::getModel('core/message')->success(
852
+ $this->__('Customers for alert %s were successfuly added to queue', $getTitleByType)
853
+ ));
854
+ }
855
+ } catch (Exception $e) {
856
+ $title = Mage::getSingleton('customeralert/config')->getTitleByType($key);
857
+ $error = $e->getMessage();
858
+ $collection->addMessage(Mage::getModel('core/message')->error(
859
+ $this->__('An error occurred while adding customers for the %s alert. Message: %s', $title, $error)
860
+ ));
861
+ continue;
862
+ }
863
+ }
864
+ print $block->getGroupedHtml();
865
+ return $this;
866
+ }
867
+
868
+ public function addAttributeAction()
869
+ {
870
+ $this->_getSession()->addNotice(
871
+ Mage::helper('catalog')->__('Please click on the Close Window button if it is not closed automatically.')
872
+ );
873
+ $this->loadLayout('popup');
874
+ $this->_initProduct();
875
+ $this->_addContent(
876
+ $this->getLayout()->createBlock('adminhtml/catalog_product_attribute_new_product_created')
877
+ );
878
+ $this->renderLayout();
879
+ }
880
+
881
+ public function createdAction()
882
+ {
883
+ $this->_getSession()->addNotice(
884
+ Mage::helper('catalog')->__('Please click on the Close Window button if it is not closed automatically.')
885
+ );
886
+ $this->loadLayout('popup');
887
+ $this->_addContent(
888
+ $this->getLayout()->createBlock('adminhtml/catalog_product_created')
889
+ );
890
+ $this->renderLayout();
891
+ }
892
+
893
+ public function massDeleteAction()
894
+ {
895
+ $productIds = $this->getRequest()->getParam('product');
896
+ if (!is_array($productIds)) {
897
+ $this->_getSession()->addError($this->__('Please select product(s).'));
898
+ } else {
899
+ if (!empty($productIds)) {
900
+ try {
901
+ foreach ($productIds as $productId) {
902
+ $product = Mage::getSingleton('catalog/product')->load($productId);
903
+ Mage::dispatchEvent('catalog_controller_product_delete', array('product' => $product));
904
+ $product->delete();
905
+ }
906
+ $this->_getSession()->addSuccess(
907
+ $this->__('Total of %d record(s) have been deleted.', count($productIds))
908
+ );
909
+ } catch (Exception $e) {
910
+ $this->_getSession()->addError($e->getMessage());
911
+ }
912
+ }
913
+ }
914
+ $this->_redirect('*/*/index');
915
+ }
916
+
917
+ /**
918
+ * Update product(s) status action
919
+ *
920
+ */
921
+ public function massStatusAction()
922
+ {
923
+ $productIds = (array)$this->getRequest()->getParam('product');
924
+ $storeId = (int)$this->getRequest()->getParam('store', 0);
925
+ $status = (int)$this->getRequest()->getParam('status');
926
+
927
+ try {
928
+ $this->_validateMassStatus($productIds, $status);
929
+ Mage::getSingleton('catalog/product_action')
930
+ ->updateAttributes($productIds, array('status' => $status), $storeId);
931
+
932
+ $this->_getSession()->addSuccess(
933
+ $this->__('Total of %d record(s) have been updated.', count($productIds))
934
+ );
935
+ }
936
+ catch (Mage_Core_Model_Exception $e) {
937
+ $this->_getSession()->addError($e->getMessage());
938
+ }
939
+ catch (Mage_Core_Exception $e) {
940
+ $this->_getSession()->addError($e->getMessage());
941
+ }
942
+ catch (Exception $e) {
943
+ $this->_getSession()
944
+ ->addException($e, $this->__('An error occurred while updating the product(s) status.'));
945
+ }
946
+
947
+ $this->_redirect('*/*/', array('store'=> $storeId));
948
+ }
949
+
950
+ /**
951
+ * Validate batch of products before theirs status will be set
952
+ *
953
+ * @throws Mage_Core_Exception
954
+ * @param array $productIds
955
+ * @param int $status
956
+ * @return void
957
+ */
958
+ public function _validateMassStatus(array $productIds, $status)
959
+ {
960
+ if ($status == Mage_Catalog_Model_Product_Status::STATUS_ENABLED) {
961
+ if (!Mage::getModel('catalog/product')->isProductsHasSku($productIds)) {
962
+ throw new Mage_Core_Exception(
963
+ $this->__('Some of the processed products have no SKU value defined. Please fill it prior to performing operations on these products.')
964
+ );
965
+ }
966
+ }
967
+ }
968
+
969
+ /**
970
+ * Get tag customer grid
971
+ *
972
+ */
973
+ public function tagCustomerGridAction()
974
+ {
975
+ $this->loadLayout();
976
+ $this->getLayout()->getBlock('admin.product.tags.customers')
977
+ ->setProductId($this->getRequest()->getParam('id'));
978
+ $this->renderLayout();
979
+ }
980
+
981
+ public function quickCreateAction()
982
+ {
983
+ $result = array();
984
+
985
+ /* @var $configurableProduct Mage_Catalog_Model_Product */
986
+ $configurableProduct = Mage::getModel('catalog/product')
987
+ ->setStoreId(0)
988
+ ->load($this->getRequest()->getParam('product'));
989
+
990
+ if (!$configurableProduct->isConfigurable()) {
991
+ // If invalid parent product
992
+ $this->_redirect('*/*/');
993
+ return;
994
+ }
995
+
996
+ /* @var $product Mage_Catalog_Model_Product */
997
+
998
+ $product = Mage::getModel('catalog/product')
999
+ ->setStoreId(0)
1000
+ ->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)
1001
+ ->setAttributeSetId($configurableProduct->getAttributeSetId());
1002
+
1003
+
1004
+ foreach ($product->getTypeInstance()->getEditableAttributes() as $attribute) {
1005
+ if ($attribute->getIsUnique()
1006
+ || $attribute->getAttributeCode() == 'url_key'
1007
+ || $attribute->getFrontend()->getInputType() == 'gallery'
1008
+ || $attribute->getFrontend()->getInputType() == 'media_image'
1009
+ || !$attribute->getIsVisible()) {
1010
+ continue;
1011
+ }
1012
+
1013
+ $product->setData(
1014
+ $attribute->getAttributeCode(),
1015
+ $configurableProduct->getData($attribute->getAttributeCode())
1016
+ );
1017
+ }
1018
+
1019
+ $product->addData($this->getRequest()->getParam('simple_product', array()));
1020
+ $product->setWebsiteIds($configurableProduct->getWebsiteIds());
1021
+
1022
+ $autogenerateOptions = array();
1023
+ $result['attributes'] = array();
1024
+
1025
+ foreach ($configurableProduct->getTypeInstance()->getConfigurableAttributes() as $attribute) {
1026
+ $value = $product->getAttributeText($attribute->getProductAttribute()->getAttributeCode());
1027
+ $autogenerateOptions[] = $value;
1028
+ $result['attributes'][] = array(
1029
+ 'label' => $value,
1030
+ 'value_index' => $product->getData($attribute->getProductAttribute()->getAttributeCode()),
1031
+ 'attribute_id' => $attribute->getProductAttribute()->getId()
1032
+ );
1033
+ }
1034
+
1035
+ if ($product->getNameAutogenerate()) {
1036
+ $product->setName($configurableProduct->getName() . '-' . implode('-', $autogenerateOptions));
1037
+ }
1038
+
1039
+ if ($product->getSkuAutogenerate()) {
1040
+ $product->setSku($configurableProduct->getSku() . '-' . implode('-', $autogenerateOptions));
1041
+ }
1042
+
1043
+ if (is_array($product->getPricing())) {
1044
+ $result['pricing'] = $product->getPricing();
1045
+ $additionalPrice = 0;
1046
+ foreach ($product->getPricing() as $pricing) {
1047
+ if (empty($pricing['value'])) {
1048
+ continue;
1049
+ }
1050
+
1051
+ if (!empty($pricing['is_percent'])) {
1052
+ $pricing['value'] = ($pricing['value']/100)*$product->getPrice();
1053
+ }
1054
+
1055
+ $additionalPrice += $pricing['value'];
1056
+ }
1057
+
1058
+ $product->setPrice($product->getPrice() + $additionalPrice);
1059
+ $product->unsPricing();
1060
+ }
1061
+
1062
+ try {
1063
+ /**
1064
+ * @todo implement full validation process with errors returning which are ignoring now
1065
+ */
1066
+ // if (is_array($errors = $product->validate())) {
1067
+ // $strErrors = array();
1068
+ // foreach($errors as $code=>$error) {
1069
+ // $codeLabel = $product->getResource()->getAttribute($code)->getFrontend()->getLabel();
1070
+ // $strErrors[] = ($error === true)? Mage::helper('catalog')->__('Value for "%s" is invalid.', $codeLabel) : Mage::helper('catalog')->__('Value for "%s" is invalid: %s', $codeLabel, $error);
1071
+ // }
1072
+ // Mage::throwException('data_invalid', implode("\n", $strErrors));
1073
+ // }
1074
+
1075
+ $product->validate();
1076
+ $product->save();
1077
+ $result['product_id'] = $product->getId();
1078
+ $this->_getSession()->addSuccess(Mage::helper('catalog')->__('The product has been created.'));
1079
+ $this->_initLayoutMessages('adminhtml/session');
1080
+ $result['messages'] = $this->getLayout()->getMessagesBlock()->getGroupedHtml();
1081
+ } catch (Mage_Core_Exception $e) {
1082
+ $result['error'] = array(
1083
+ 'message' => $e->getMessage(),
1084
+ 'fields' => array(
1085
+ 'sku' => $product->getSku()
1086
+ )
1087
+ );
1088
+
1089
+ } catch (Exception $e) {
1090
+ Mage::logException($e);
1091
+ $result['error'] = array(
1092
+ 'message' => $this->__('An error occurred while saving the product. ') . $e->getMessage()
1093
+ );
1094
+ }
1095
+
1096
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
1097
+ }
1098
+
1099
+ /**
1100
+ * Check for is allowed
1101
+ *
1102
+ * @return boolean
1103
+ */
1104
+ protected function _isAllowed()
1105
+ {
1106
+ return Mage::getSingleton('admin/session')->isAllowed('catalog/products');
1107
+ }
1108
+
1109
+ /**
1110
+ * Show item update result from updateAction
1111
+ * in Wishlist and Cart controllers.
1112
+ *
1113
+ */
1114
+ public function showUpdateResultAction()
1115
+ {
1116
+ $session = Mage::getSingleton('adminhtml/session');
1117
+ if ($session->hasCompositeProductResult() && $session->getCompositeProductResult() instanceof Varien_Object){
1118
+ /* @var $helper Mage_Adminhtml_Helper_Catalog_Product_Composite */
1119
+ $helper = Mage::helper('adminhtml/catalog_product_composite');
1120
+ $helper->renderUpdateResult($this, $session->getCompositeProductResult());
1121
+ $session->unsCompositeProductResult();
1122
+ } else {
1123
+ $session->unsCompositeProductResult();
1124
+ return false;
1125
+ }
1126
+ }
1127
+ }
1128
+ ?>
app/code/local/Mageex/Productcms/controllers/IndexController.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Mageex_Productcms_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+
7
+ /*
8
+ * Load an object by id
9
+ * Request looking like:
10
+ * http://site.com/productcms?id=15
11
+ * or
12
+ * http://site.com/productcms/id/15
13
+ */
14
+ /*
15
+ $productcms_id = $this->getRequest()->getParam('id');
16
+
17
+ if($productcms_id != null && $productcms_id != '') {
18
+ $productcms = Mage::getModel('productcms/productcms')->load($productcms_id)->getData();
19
+ } else {
20
+ $productcms = null;
21
+ }
22
+ */
23
+
24
+ /*
25
+ * If no param we load a the last created item
26
+ */
27
+ /*
28
+ if($productcms == null) {
29
+ $resource = Mage::getSingleton('core/resource');
30
+ $read= $resource->getConnection('core_read');
31
+ $productcmsTable = $resource->getTableName('productcms');
32
+
33
+ $select = $read->select()
34
+ ->from($productcmsTable,array('productcms_id','title','content','status'))
35
+ ->where('status',1)
36
+ ->order('created_time DESC') ;
37
+
38
+ $productcms = $read->fetchRow($select);
39
+ }
40
+ Mage::register('productcms', $productcms);
41
+ */
42
+
43
+
44
+ $this->loadLayout();
45
+ $this->renderLayout();
46
+ }
47
+ }
app/code/local/Mageex/Productcms/etc/config.xml ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Mageex_Productcms>
5
+ <version>0.1.0</version>
6
+ </Mageex_Productcms>
7
+ </modules>
8
+ <admin>
9
+ <routers><!--
10
+ <productcms>
11
+ <use>admin</use>
12
+ <args>
13
+ <module>Mageex_Productcms</module>
14
+ <frontName>productcms</frontName>
15
+ </args>
16
+ </productcms>-->
17
+ <adminhtml>
18
+ <args>
19
+ <modules>
20
+ <Mageex_Productcms before="Mage_Adminhtml">Mageex_Productcms_Adminhtml</Mageex_Productcms>
21
+ </modules>
22
+ </args>
23
+ </adminhtml>
24
+ </routers>
25
+ </admin>
26
+ <adminhtml>
27
+ <layout>
28
+ <updates>
29
+ <productcms>
30
+ <file>productcms.xml</file>
31
+ </productcms>
32
+ </updates>
33
+ </layout>
34
+ </adminhtml>
35
+ <global>
36
+ <models>
37
+ <productcms>
38
+ <class>Mageex_Productcms_Model</class>
39
+ <resourceModel>productcms_mysql4</resourceModel>
40
+ </productcms>
41
+ <productcms_mysql4>
42
+ <class>Mageex_Productcms_Model_Mysql4</class>
43
+ <entities>
44
+ <productcms>
45
+ <table>productcms</table>
46
+ </productcms>
47
+ </entities>
48
+ </productcms_mysql4>
49
+ </models>
50
+ <resources>
51
+ <productcms_setup>
52
+ <setup>
53
+ <module>Mageex_Productcms</module>
54
+ </setup>
55
+ <connection>
56
+ <use>core_setup</use>
57
+ </connection>
58
+ </productcms_setup>
59
+ <productcms_write>
60
+ <connection>
61
+ <use>core_write</use>
62
+ </connection>
63
+ </productcms_write>
64
+ <productcms_read>
65
+ <connection>
66
+ <use>core_read</use>
67
+ </connection>
68
+ </productcms_read>
69
+ </resources>
70
+ <blocks>
71
+ <productcms>
72
+ <class>Mageex_Productcms_Block</class>
73
+ </productcms>
74
+ </blocks>
75
+ <helpers>
76
+ <productcms>
77
+ <class>Mageex_Productcms_Helper</class>
78
+ </productcms>
79
+ </helpers>
80
+ </global>
81
+ </config>
app/code/local/Mageex/Productcms/sql/productcms_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ -- DROP TABLE IF EXISTS {$this->getTable('productcms')};
10
+ CREATE TABLE {$this->getTable('productcms')} (
11
+ `productcms_id` int(11) unsigned NOT NULL auto_increment,
12
+ `product_id` int(11) NOT NULL default 0,
13
+ `page_id` varchar(255) NOT NULL default '',
14
+ PRIMARY KEY (`productcms_id`)
15
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
16
+ ");
17
+
18
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/productcms.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <!-- Add product cms tab -->
4
+ <adminhtml_catalog_product_cmsgrid>
5
+ <block type="core/text_list" name="root" output="toHtml" >
6
+ <block type="adminhtml/catalog_product_edit_tab_cms" name="catalog.product.edit.tab.cms"/>
7
+ </block>
8
+ </adminhtml_catalog_product_cmsgrid>
9
+ <adminhtml_catalog_product_cms>
10
+ <block type="core/text_list" name="root" output="toHtml">
11
+ <block type="adminhtml/catalog_product_edit_tab_cms" name="catalog.product.edit.tab.cms"/>
12
+ <block type="adminhtml/widget_grid_serializer" name="cms_grid_serializer">
13
+ <reference name="cms_grid_serializer">
14
+ <action method="initSerializerBlock">
15
+ <grid_block_name>catalog.product.edit.tab.cms</grid_block_name>
16
+ <data_callback>getSelectedCmsProducts</data_callback>
17
+ <hidden_input_name>links[cms]</hidden_input_name>
18
+ <reload_param_name>products_cms</reload_param_name>
19
+ </action>
20
+ </reference>
21
+ </block>
22
+ </block>
23
+ </adminhtml_catalog_product_cms>
24
+ <!-- End add product cms tab -->
25
+ </layout>
app/design/frontend/default/default/template/catalog/product/view.phtml ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product view template
29
+ *
30
+ * @see Mage_Catalog_Block_Product_View
31
+ * @see Mage_Review_Block_Product_View
32
+ */
33
+ ?>
34
+ <?php $_helper = $this->helper('catalog/output'); ?>
35
+ <?php $_product = $this->getProduct(); ?>
36
+ <script type="text/javascript">
37
+ var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
38
+ </script>
39
+ <div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
40
+ <div class="product-view">
41
+ <div class="product-essential">
42
+ <form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
43
+ <div class="no-display">
44
+ <input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
45
+ <input type="hidden" name="related_product" id="related-products-field" value="" />
46
+ </div>
47
+
48
+ <div class="product-shop">
49
+ <div class="product-name">
50
+ <h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>
51
+ </div>
52
+
53
+ <?php if ($this->canEmailToFriend()): ?>
54
+ <p class="email-friend"><a href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>"><?php echo $this->__('Email to a Friend') ?></a></p>
55
+ <?php endif; ?>
56
+
57
+ <?php
58
+
59
+ $cmspages = Mage::getModel('cms/page')->getCollection();
60
+ $productcms = Mage::getModel('productcms/productcms')->getCollection();
61
+ $productcms->addFieldToFilter('product_id',$_product->getId());
62
+ $cmsarr = '';
63
+ $cms = array();
64
+ foreach($productcms as $cms){
65
+ $cmsarr .= '&'.$cms->getPageId();
66
+ }
67
+ $cms = explode('&',$cmsarr);
68
+ $cmspages->addFieldToFilter('page_id',$cms);
69
+ foreach($cmspages as $cmspage):
70
+
71
+ ?>
72
+ <p><a alt="<?php echo $cmspage->getTitle(); ?>" href="<?php echo Mage::Helper('cms/page')->getPageUrl($cmspage->getId()); ?>" ><?php echo $cmspage->getTitle(); ?></a></p>
73
+ <?php endforeach; ?>
74
+
75
+
76
+ <?php echo $this->getReviewsSummaryHtml($_product, false, true)?>
77
+ <?php echo $this->getChildHtml('alert_urls') ?>
78
+ <?php echo $this->getChildHtml('product_type_data') ?>
79
+ <?php echo $this->getTierPriceHtml() ?>
80
+ <?php echo $this->getChildHtml('extrahint') ?>
81
+
82
+ <?php if (!$this->hasOptions()):?>
83
+ <div class="add-to-box">
84
+ <?php if($_product->isSaleable()): ?>
85
+ <?php echo $this->getChildHtml('addtocart') ?>
86
+ <?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
87
+ <span class="or"><?php echo $this->__('OR') ?></span>
88
+ <?php endif; ?>
89
+ <?php endif; ?>
90
+ <?php echo $this->getChildHtml('addto') ?>
91
+ </div>
92
+ <?php echo $this->getChildHtml('extra_buttons') ?>
93
+ <?php endif; ?>
94
+
95
+ <?php if ($_product->getShortDescription()):?>
96
+ <div class="short-description">
97
+ <h2><?php echo $this->__('Quick Overview') ?></h2>
98
+ <div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>
99
+ </div>
100
+ <?php endif;?>
101
+
102
+ <?php echo $this->getChildHtml('other');?>
103
+
104
+ <?php if ($_product->isSaleable() && $this->hasOptions()):?>
105
+ <?php echo $this->getChildChildHtml('container1', '', true, true) ?>
106
+ <?php endif;?>
107
+
108
+ </div>
109
+
110
+ <div class="product-img-box">
111
+ <?php echo $this->getChildHtml('media') ?>
112
+ </div>
113
+
114
+ <div class="clearer"></div>
115
+ <?php if ($_product->isSaleable() && $this->hasOptions()):?>
116
+ <?php echo $this->getChildChildHtml('container2', '', true, true) ?>
117
+ <?php endif;?>
118
+ </form>
119
+ <script type="text/javascript">
120
+ //<![CDATA[
121
+ var productAddToCartForm = new VarienForm('product_addtocart_form');
122
+ productAddToCartForm.submit = function(button, url) {
123
+ if (this.validator.validate()) {
124
+ var form = this.form;
125
+ var oldUrl = form.action;
126
+
127
+ if (url) {
128
+ form.action = url;
129
+ }
130
+ var e = null;
131
+ try {
132
+ this.form.submit();
133
+ } catch (e) {
134
+ }
135
+ this.form.action = oldUrl;
136
+ if (e) {
137
+ throw e;
138
+ }
139
+
140
+ if (button && button != 'undefined') {
141
+ button.disabled = true;
142
+ }
143
+ }
144
+ }.bind(productAddToCartForm);
145
+
146
+ productAddToCartForm.submitLight = function(button, url){
147
+ if(this.validator) {
148
+ var nv = Validation.methods;
149
+ delete Validation.methods['required-entry'];
150
+ delete Validation.methods['validate-one-required'];
151
+ delete Validation.methods['validate-one-required-by-name'];
152
+ if (this.validator.validate()) {
153
+ if (url) {
154
+ this.form.action = url;
155
+ }
156
+ this.form.submit();
157
+ }
158
+ Object.extend(Validation.methods, nv);
159
+ }
160
+ }.bind(productAddToCartForm);
161
+ //]]>
162
+ </script>
163
+ </div>
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+
174
+ <div class="product-collateral">
175
+ <?php foreach ($this->getChildGroup('detailed_info', 'getChildHtml') as $alias => $html):?>
176
+ <div class="box-collateral <?php echo "box-{$alias}"?>">
177
+ <?php if ($title = $this->getChildData($alias, 'title')):?>
178
+ <h2><?php echo $this->escapeHtml($title); ?></h2>
179
+ <?php endif;?>
180
+ <?php echo $html; ?>
181
+ </div>
182
+ <?php endforeach;?>
183
+ <?php echo $this->getChildHtml('upsell_products') ?>
184
+ <?php echo $this->getChildHtml('product_additional_data') ?>
185
+ </div>
186
+ </div>
app/etc/modules/Mageex_Productcms.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Mageex_Productcms>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Mageex_Productcms>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>productcms</name>
4
+ <version>1.0.12</version>
5
+ <stability>stable</stability>
6
+ <license>OSL-v 3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>mageex</summary>
10
+ <description>mageex</description>
11
+ <notes>Product CMS</notes>
12
+ <authors><author><name>mageex</name><user>auto-converted</user><email>hien.tran@mageex.com</email></author></authors>
13
+ <date>2012-03-02</date>
14
+ <time>05:12:07</time>
15
+ <contents><target name="mage"><dir name="app"><dir name="code"><dir name="local"><dir name="Mageex"><dir name="Productcms"><dir name="Block"><file name="Productcms.php" hash="fd4d1ba8fc914dc550c75f095a0ee1d6"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Catalog"><file name="ProductController__.php" hash="d1561cd4c0e55dd563aa820132700cb9"/><file name="ProductController.php" hash="4afa8d577e17c1139641b0e77779095c"/></dir></dir><file name="IndexController.php" hash="246e017784173f7e255a85aa02f309e2"/></dir><dir name="etc"><file name="config.xml" hash="5f6440f917026f0a39d33dc3219c745d"/></dir><dir name="Helper"><file name="Data.php" hash="114e9e40a4724bcf4bb029fc33a1ab34"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Productcms"><file name="Collection.php" hash="ca7bf4c826d2b8cd5e084e74947d4564"/></dir><file name="Productcms.php" hash="2885dfacae83d7449a22d72542023532"/></dir><file name="Productcms.php" hash="e1b3f3de0b903ed2ce7085dea7813ef9"/><file name="Status.php" hash="5018ea5ad9a8aa842fab1bafe13c1f41"/></dir><dir name="sql"><dir name="productcms_setup"><file name="mysql4-install-0.1.0.php" hash="0a75e177bc75416c7fb75e456c0767c3"/></dir></dir></dir></dir><dir name="Mage"><dir name="Adminhtml"><dir name="Block"><dir name="Catalog"><dir name="Product"><dir name="Edit"><dir name="Tab"><file name="Cms.php" hash="6d702d6698528725f7bbca0a9a45cd8b"/></dir><file name="Tabs.php" hash="504994ce4900de770a405680ec551734"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="design"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="cc76755098ea3957110747c563cad2ce"/></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="productcms.xml" hash="99d4ea02b2e6f31909f48ab24d870c02"/></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Mageex_Productcms.xml" hash="b1ac1aa04f879f2f23c73b2193d93e45"/></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>