Amm_Product - Version 1.0.0.2

Version Notes

enable to adding downloadable products in account

Download this release

Release Info

Developer Magento Core Team
Extension Amm_Product
Version 1.0.0.2
Comparing to
See all releases


Version 1.0.0.2

app/code/community/Amm/Product/Block/Adminhtml/Grid.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Amm_Product_Block_Adminhtml_Grid extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ //where is the controller
7
+ $this->_controller = 'adminhtml_product';
8
+ $this->_blockGroup = 'product';
9
+ //text in the admin header
10
+ $this->_headerText = "All Customer's Products";
11
+ //value of the add button
12
+ //$this->_addButtonLabel = 'Add a contact';
13
+ parent::__construct();
14
+ $this->_removeButton('add');
15
+ }
16
+ }
app/code/community/Amm/Product/Block/Adminhtml/Product/Grid.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Amm_Product_Block_Adminhtml_Product_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId('product_grid');
8
+ $this->setDefaultSort('id');
9
+ $this->setDefaultDir('DESC');
10
+ $this->setSaveParametersInSession(true);
11
+ }
12
+
13
+ protected function _prepareCollection()
14
+ {
15
+ $collection = Mage::getModel('product/product')->getCollection()->setOrder('id','desc');
16
+
17
+ $resource = Mage::getSingleton('core/resource');
18
+ $table14 = $resource->getTableName('eav_attribute');
19
+
20
+ $collection->getSelect()
21
+ ->join( array('ce1' => $resource->getTableName('customer_entity')), 'ce1.entity_id=main_table.id_customer', array('email' => 'email'))
22
+ ->join( array('ce2' => $resource->getTableName('customer_entity_varchar')), 'ce2.entity_id=main_table.id_customer AND ce2.attribute_id=(select ea1.attribute_id from '.$table14.' as ea1 where ea1.entity_type_id=ce2.entity_type_id and ea1.attribute_code=\'firstname\')', array('buyer_first_name' => 'value'))
23
+ ->join( array('ce3' => $resource->getTableName('customer_entity_varchar')), 'ce3.entity_id=main_table.id_customer AND ce3.attribute_id=(select ea1.attribute_id from '.$table14.' as ea1 where ea1.entity_type_id=ce3.entity_type_id and ea1.attribute_code=\'lastname\')', array('buyer_last_name' => 'value'))
24
+ ->join( array('ce4' => $resource->getTableName('catalog_product_entity')), 'ce4.entity_id=main_table.id_product', array('sku' => 'sku', 'created_at' => 'created_at'))
25
+ ->join( array('ce5' => $resource->getTableName('catalog_product_entity_decimal')), 'ce5.entity_id=main_table.id_product AND ce5.attribute_id=(select ea1.attribute_id from '.$table14.' as ea1 where ea1.entity_type_id=ce5.entity_type_id and ea1.attribute_code=\'price\')', array('value' => 'value'));
26
+
27
+ $this->setCollection($collection);
28
+ return parent::_prepareCollection();
29
+ }
30
+
31
+ protected function _prepareColumns()
32
+ {
33
+ $this->addColumn('ID',
34
+ array(
35
+ 'header' => 'ID',
36
+ 'align' =>'left',
37
+ 'type' => 'number',
38
+ 'filter' => false,
39
+ 'index' => 'id_product',
40
+ ));
41
+ $this->addColumn('First Name',
42
+ array(
43
+ 'header' => 'First Name',
44
+ 'align' =>'left',
45
+ 'type' => 'text',
46
+ 'filter' => false,
47
+ 'index' => 'buyer_first_name',
48
+ ));
49
+ $this->addColumn('Last Name',
50
+ array(
51
+ 'header' => 'Last Name',
52
+ 'align' =>'left',
53
+ 'type' => 'text',
54
+ 'filter' => false,
55
+ 'index' => 'buyer_last_name',
56
+ ));
57
+ $this->addColumn('Email',
58
+ array(
59
+ 'header' => 'Email',
60
+ 'align' =>'left',
61
+ 'type' => 'text',
62
+ 'index' => 'email',
63
+ ));
64
+ $this->addColumn('SKU',
65
+ array(
66
+ 'header' => 'SKU',
67
+ 'align' =>'left',
68
+ 'type' => 'text',
69
+ 'index' => 'sku',
70
+ ));
71
+ $this->addColumn('Created',
72
+ array(
73
+ 'header' => 'Created',
74
+ 'align' =>'left',
75
+ 'type' => 'date',
76
+ 'filter' => false,
77
+ 'index' => 'created_at',
78
+ ));
79
+ $this->addColumn('Price',
80
+ array(
81
+ 'header' => 'Price',
82
+ 'align' =>'left',
83
+ 'type' => 'number',
84
+ 'filter' => false,
85
+ 'index' => 'value',
86
+ ));
87
+ return parent::_prepareColumns();
88
+ }
89
+
90
+ public function getRowUrl($row)
91
+ {
92
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
93
+ }
94
+ }
app/code/community/Amm/Product/Block/Monblock.php ADDED
@@ -0,0 +1,786 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Amm_Product_Block_Monblock extends Mage_Core_Block_Template
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+
8
+ $session = $this->_getSession()->toArray();
9
+
10
+ $column = 'id_customer';
11
+ $value = $session['id'];
12
+
13
+ $collection = Mage::getModel('product/product')->getCollection()->addFilter($column,$value)->setOrder('id','desc');
14
+
15
+ $this->setCollection($collection);
16
+ }
17
+
18
+ protected function _getSession()
19
+ {
20
+ return Mage::getSingleton('customer/session');
21
+ }
22
+
23
+ protected function _prepareLayout()
24
+ {
25
+ parent::_prepareLayout();
26
+
27
+ $pager = $this->getLayout()->createBlock('page/html_pager', 'custom.pager');
28
+ $pager->setAvailableLimit(array(5=>5,10=>10,20=>20,'all'=>'all'));
29
+ $pager->setCollection($this->getCollection());
30
+ $this->setChild('pager', $pager);
31
+ $this->getCollection()->load();
32
+
33
+ return $this;
34
+ }
35
+
36
+ public function getPagerHtml()
37
+ {
38
+ return $this->getChildHtml('pager');
39
+ }
40
+
41
+ public function getEditProduct(){
42
+
43
+ $param = $this->getRequest()->getParams();
44
+ if($param['ep']!=0){
45
+
46
+ $session = $this->_getSession()->toArray();
47
+
48
+ $resource = Mage::getSingleton('core/resource');
49
+
50
+ $table1 = $resource->getTableName('amm_product');
51
+ $table2 = $resource->getTableName('catalog_product_entity');
52
+ $table3 = $resource->getTableName('catalog_product_entity_varchar');
53
+ $table4 = $resource->getTableName('catalog_product_entity_decimal');
54
+ $table5 = $resource->getTableName('catalog_product_entity_int');
55
+ $table6 = $resource->getTableName('catalog_product_entity_text');
56
+ $table7 = $resource->getTableName('catalog_category_product');
57
+ $table8 = $resource->getTableName('catalog_product_entity_media_gallery');
58
+ $table9 = $resource->getTableName('catalog_product_entity_media_gallery_value');
59
+ $table10 = $resource->getTableName('downloadable_sample');
60
+ $table11 = $resource->getTableName('downloadable_sample_title');
61
+ $table12 = $resource->getTableName('downloadable_link');
62
+ $table13 = $resource->getTableName('downloadable_link_title');
63
+ $table14 = $resource->getTableName('eav_attribute');
64
+
65
+ $query = 'select
66
+ t2.*,
67
+ t3.value as name,
68
+ t4.value as price,
69
+ t5.value as status,
70
+ t6.value as description
71
+ from
72
+ '.$table1.' as t1,
73
+ '.$table2.' as t2,
74
+ '.$table3.' as t3,
75
+ '.$table4.' as t4,
76
+ '.$table5.' as t5,
77
+ '.$table6.' as t6
78
+ where
79
+ t1.id_customer='.$session['id'].' and
80
+ t1.id_product='.$param['ep'].' and
81
+ t2.entity_id=t1.id_product and
82
+ t3.entity_id=t1.id_product and
83
+ t3.attribute_id=(select ea1.attribute_id from '.$table14.' as ea1 where ea1.entity_type_id=t2.entity_type_id and ea1.attribute_code=\'name\') and
84
+ t5.entity_id=t1.id_product and
85
+ t5.attribute_id=(select ea1.attribute_id from '.$table14.' as ea1 where ea1.entity_type_id=t2.entity_type_id and ea1.attribute_code=\'status\') and
86
+ t4.entity_id=t1.id_product and
87
+ t4.attribute_id=(select ea1.attribute_id from '.$table14.' as ea1 where ea1.entity_type_id=t2.entity_type_id and ea1.attribute_code=\'price\') and
88
+ t6.entity_id=t1.id_product and
89
+ t6.attribute_id=(select ea1.attribute_id from '.$table14.' as ea1 where ea1.entity_type_id=t2.entity_type_id and ea1.attribute_code=\'description\')
90
+ ';
91
+
92
+ $productsArray = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query);
93
+
94
+ $query2 = 'select
95
+ t6.value as short_description
96
+ from
97
+ '.$table1.' as t1,
98
+ '.$table6.' as t6
99
+ where
100
+ t1.id_customer='.$session['id'].' and
101
+ t1.id_product='.$param['ep'].' and
102
+ t6.entity_id=t1.id_product and
103
+ t6.attribute_id=(select ea1.attribute_id from '.$table14.' as ea1 where ea1.entity_type_id=t6.entity_type_id and ea1.attribute_code=\'short_description\')
104
+ ';
105
+
106
+ $productsArray2 = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query2);
107
+
108
+ $query3 = 'select
109
+ t7.category_id
110
+ from
111
+ '.$table1.' as t1,
112
+ '.$table7.' as t7
113
+ where
114
+ t1.id_customer='.$session['id'].' and
115
+ t1.id_product='.$param['ep'].' and
116
+ t7.product_id=t1.id_product
117
+ ';
118
+
119
+ $productsArray3 = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query3);
120
+
121
+ $query4 = 'select
122
+ t8.value_id,
123
+ t8.value,
124
+ t9.label,
125
+ t9.position,
126
+ t9.disabled
127
+ from
128
+ '.$table1.' as t1,
129
+ '.$table2.' as t2,
130
+ '.$table8.' as t8,
131
+ '.$table9.' as t9
132
+ where
133
+ t1.id_customer='.$session['id'].' and
134
+ t1.id_product='.$param['ep'].' and
135
+ t2.entity_id=t1.id_product and
136
+ t8.entity_id=t1.id_product and
137
+ t8.attribute_id=(select ea1.attribute_id from '.$table14.' as ea1 where ea1.entity_type_id=t2.entity_type_id and ea1.attribute_code=\'media_gallery\') and
138
+ t9.value_id=t8.value_id
139
+ order by t9.position asc;
140
+ ';
141
+
142
+ $productsArray4 = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query4);
143
+
144
+ $query5 = 'select
145
+ t3.value
146
+ from
147
+ '.$table1.' as t1,
148
+ '.$table3.' as t3
149
+ where
150
+ t1.id_customer='.$session['id'].' and
151
+ t1.id_product='.$param['ep'].' and
152
+ t3.entity_id=t1.id_product and
153
+ t3.attribute_id=(select ea1.attribute_id from '.$table14.' as ea1 where ea1.entity_type_id=t3.entity_type_id and ea1.attribute_code=\'image\')
154
+ ';
155
+
156
+ $productsArray5 = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query5);
157
+
158
+ $query6 = 'select
159
+ t3.value
160
+ from
161
+ '.$table1.' as t1,
162
+ '.$table3.' as t3
163
+ where
164
+ t1.id_customer='.$session['id'].' and
165
+ t1.id_product='.$param['ep'].' and
166
+ t3.entity_id=t1.id_product and
167
+ t3.attribute_id=(select ea1.attribute_id from '.$table14.' as ea1 where ea1.entity_type_id=t3.entity_type_id and ea1.attribute_code=\'small_image\')
168
+ ';
169
+
170
+ $productsArray6 = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query6);
171
+
172
+ $query7 = 'select
173
+ t3.value
174
+ from
175
+ '.$table1.' as t1,
176
+ '.$table3.' as t3
177
+ where
178
+ t1.id_customer='.$session['id'].' and
179
+ t1.id_product='.$param['ep'].' and
180
+ t3.entity_id=t1.id_product and
181
+ t3.attribute_id=(select ea1.attribute_id from '.$table14.' as ea1 where ea1.entity_type_id=t3.entity_type_id and ea1.attribute_code=\'thumbnail\')
182
+ ';
183
+
184
+ $productsArray7 = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query7);
185
+
186
+ $query8 = 'select
187
+ t3.value
188
+ from
189
+ '.$table3.' as t3
190
+ where
191
+ t3.entity_id='.$param['ep'].' and
192
+ t3.attribute_id=(select ea1.attribute_id from '.$table14.' as ea1 where ea1.entity_type_id=t3.entity_type_id and ea1.attribute_code=\'samples_title\')
193
+ ';
194
+
195
+ $productsArray8 = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query8);
196
+
197
+ $query9 = 'select
198
+ t3.value
199
+ from
200
+ '.$table3.' as t3
201
+ where
202
+ t3.entity_id='.$param['ep'].' and
203
+ t3.attribute_id=(select ea1.attribute_id from '.$table14.' as ea1 where ea1.entity_type_id=t3.entity_type_id and ea1.attribute_code=\'links_title\')
204
+ ';
205
+
206
+ $productsArray9 = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query9);
207
+
208
+ $query10 = 'select
209
+ t10.*,
210
+ t11.title
211
+ from
212
+ '.$table10.' as t10,
213
+ '.$table11.' as t11
214
+ where
215
+ t10.product_id='.$param['ep'].' and
216
+ t11.sample_id=t10.sample_id
217
+ ';
218
+
219
+ $productsArray10 = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query10);
220
+
221
+ $query11 = 'select
222
+ t12.*,
223
+ t13.title
224
+ from
225
+ '.$table12.' as t12,
226
+ '.$table13.' as t13
227
+ where
228
+ t12.product_id='.$param['ep'].' and
229
+ t13.link_id=t12.link_id
230
+ ';
231
+
232
+ $productsArray11 = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query11);
233
+
234
+ foreach($productsArray as $pa){
235
+ foreach($productsArray2 as $pa2){
236
+ $pa['short_description'] = $pa2['short_description'];
237
+ }
238
+ foreach($productsArray3 as $pa3){
239
+ $pa['category_id'][] = $pa3['category_id'];
240
+ }
241
+ $ik=0;
242
+ foreach($productsArray4 as $pa4){
243
+ $pa['image'][$ik]['value_id'] = $pa4['value_id'];
244
+ $pa['image'][$ik]['value'] = $pa4['value'];
245
+ $pa['image'][$ik]['label'] = $pa4['label'];
246
+ $pa['image'][$ik]['position'] = $pa4['position'];
247
+ $pa['image'][$ik]['disabled'] = $pa4['disabled'];
248
+ $ik++;
249
+ }
250
+ foreach($productsArray5 as $pa5){
251
+ $pa['image_radio'] = $pa5['value'];
252
+ }
253
+ foreach($productsArray6 as $pa6){
254
+ $pa['small_image_radio'] = $pa6['value'];
255
+ }
256
+ foreach($productsArray7 as $pa7){
257
+ $pa['thumb_image_radio'] = $pa7['value'];
258
+ }
259
+ foreach($productsArray8 as $pa8){
260
+ $pa['samples_title'] = $pa8['value'];
261
+ }
262
+ foreach($productsArray9 as $pa9){
263
+ $pa['links_title'] = $pa9['value'];
264
+ }
265
+ $ikd=0;
266
+ foreach($productsArray10 as $pa10){
267
+ $pa['sample'][$ikd]['sample_id'] = $pa10['sample_id'];
268
+ $pa['sample'][$ikd]['product_id'] = $pa10['product_id'];
269
+ $pa['sample'][$ikd]['sample_url'] = $pa10['sample_url'];
270
+ $pa['sample'][$ikd]['sample_file'] = $pa10['sample_file'];
271
+ $pa['sample'][$ikd]['sample_type'] = $pa10['sample_type'];
272
+ $pa['sample'][$ikd]['sort_order'] = $pa10['sort_order'];
273
+ $pa['sample'][$ikd]['title'] = $pa10['title'];
274
+ $ikd++;
275
+ }
276
+ $ikl=0;
277
+ foreach($productsArray11 as $pa11){
278
+ $pa['links'][$ikl]['link_id'] = $pa11['link_id'];
279
+ $pa['links'][$ikl]['product_id'] = $pa11['product_id'];
280
+ $pa['links'][$ikl]['number_of_downloads'] = $pa11['number_of_downloads'];
281
+ $pa['links'][$ikl]['is_shareable'] = $pa11['is_shareable'];
282
+ $pa['links'][$ikl]['link_url'] = $pa11['link_url'];
283
+ $pa['links'][$ikl]['link_file'] = $pa11['link_file'];
284
+ $pa['links'][$ikl]['link_type'] = $pa11['link_type'];
285
+ $pa['links'][$ikl]['sample_url'] = $pa11['sample_url'];
286
+ $pa['links'][$ikl]['sample_file'] = $pa11['sample_file'];
287
+ $pa['links'][$ikl]['sample_type'] = $pa11['sample_type'];
288
+ $pa['links'][$ikl]['sort_order'] = $pa11['sort_order'];
289
+ $pa['links'][$ikl]['title'] = $pa11['title'];
290
+ $ikl++;
291
+ }
292
+ return $pa;
293
+ }
294
+ }
295
+
296
+ return null;
297
+
298
+ }
299
+
300
+ public function productList()
301
+ {
302
+
303
+ $this->saveForm();
304
+
305
+ $params = $this->getRequest()->getParams();
306
+
307
+ $mLimit = 5;
308
+ if(isset($params['limit'])){ $mLimit = $params['limit']; }
309
+ $mPage = 0;
310
+ if(isset($params['p'])){ $mPage = $params['p'] * $mLimit - $mLimit; }
311
+
312
+
313
+
314
+ $session = $this->_getSession()->toArray();
315
+
316
+ $resource = Mage::getSingleton('core/resource');
317
+
318
+ $table1 = $resource->getTableName('amm_product');
319
+ $table2 = $resource->getTableName('catalog_product_entity');
320
+ $table3 = $resource->getTableName('catalog_product_entity_varchar');
321
+ $table4 = $resource->getTableName('catalog_product_entity_decimal');
322
+ $table5 = $resource->getTableName('catalog_product_entity_int');
323
+ $table6 = $resource->getTableName('eav_attribute');
324
+
325
+ //echo $table3.'<br />';
326
+
327
+ $query = "select
328
+ t2.*,
329
+ t3.value as name,
330
+ t4.value as price,
331
+ t5.value as status
332
+ from
333
+ ".$table1." as t1,
334
+ ".$table2." as t2,
335
+ ".$table3." as t3,
336
+ ".$table4." as t4,
337
+ ".$table5." as t5
338
+ where
339
+ t1.id_customer=".$session['id']." and
340
+ t2.entity_id=t1.id_product and
341
+ t3.entity_id=t1.id_product and
342
+ t3.entity_type_id=t2.entity_type_id and
343
+ t3.attribute_id=(select ea1.attribute_id from ".$table6." as ea1 where ea1.entity_type_id=t2.entity_type_id and ea1.attribute_code='name') and
344
+ t5.entity_id=t1.id_product and
345
+ t5.entity_type_id=t2.entity_type_id and
346
+ t5.attribute_id=(select ea1.attribute_id from ".$table6." as ea1 where ea1.entity_type_id=t2.entity_type_id and ea1.attribute_code='status') and
347
+ t4.entity_id=t1.id_product and
348
+ t4.entity_type_id=t2.entity_type_id and
349
+ t4.attribute_id=(select ea1.attribute_id from ".$table6." as ea1 where ea1.entity_type_id=t2.entity_type_id and ea1.attribute_code='price')
350
+ order by t2.created_at desc, t2.updated_at desc
351
+ limit ".$mPage.", ".$mLimit;
352
+
353
+ // echo $query.'<br />';
354
+
355
+ $arrayProductRecords = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query);
356
+
357
+ if($arrayProductRecords){
358
+
359
+ $arrayProductRecords[0]['limit']=$mLimit;
360
+ $arrayProductRecords[0]['page']=($mPage==0?1:$mPage);
361
+
362
+ }
363
+
364
+ return $arrayProductRecords;
365
+
366
+ }
367
+
368
+ public function productListStatistica()
369
+ {
370
+
371
+ $params = $this->getRequest()->getParams();
372
+
373
+ $mLimit = 5;
374
+ if(isset($params['limit'])){ $mLimit = $params['limit']; }
375
+ $mPage = 0;
376
+ if(isset($params['p'])){ $mPage = $params['p'] * $mLimit - $mLimit; }
377
+ $filter_from = '';
378
+ $db_filter_from = '';
379
+ if(isset($params['_dob'])){
380
+ $filter_from = $params['_dob'];
381
+ $dbfilterdate = split('\.', $filter_from);
382
+ $db_filter_from = $dbfilterdate[2].'-'.$dbfilterdate[1].'-'.$dbfilterdate[0];
383
+ }
384
+ $filter_to = '';
385
+ $db_filter_to = '';
386
+ if(isset($params['_dobto'])){
387
+ $filter_to = $params['_dobto'];
388
+ $dbfilterdate = split('\.', $filter_to);
389
+ $db_filter_to = $dbfilterdate[2].'-'.$dbfilterdate[1].'-'.$dbfilterdate[0];
390
+ }
391
+
392
+
393
+ $session = $this->_getSession()->toArray();
394
+
395
+ $resource = Mage::getSingleton('core/resource');
396
+
397
+ $table1 = $resource->getTableName('amm_product');
398
+ $table2 = $resource->getTableName('catalog_product_entity');
399
+ $table3 = $resource->getTableName('catalog_product_entity_varchar');
400
+ $table4 = $resource->getTableName('catalog_product_entity_decimal');
401
+ $table5 = $resource->getTableName('catalog_product_entity_int');
402
+
403
+ $table6 = $resource->getTableName('sales_flat_order_item');
404
+ $table7 = $resource->getTableName('sales_flat_order');
405
+ $table8 = $resource->getTableName('eav_attribute');
406
+
407
+ //echo $table3.'<br />';
408
+
409
+ $query = "select
410
+ t2.*,
411
+ t3.value as name,
412
+ t4.value as price,
413
+ t5.value as status
414
+ from
415
+ ".$table1." as t1,
416
+ ".$table2." as t2,
417
+ ".$table3." as t3,
418
+ ".$table4." as t4,
419
+ ".$table5." as t5
420
+ where
421
+ t1.id_customer=".$session['id']." and
422
+ t2.entity_id=t1.id_product and
423
+ t3.entity_id=t1.id_product and
424
+ t3.attribute_id=(select ea1.attribute_id from ".$table8." as ea1 where ea1.entity_type_id=t2.entity_type_id and ea1.attribute_code='name') and
425
+ t5.entity_id=t1.id_product and
426
+ t5.attribute_id=(select ea1.attribute_id from ".$table8." as ea1 where ea1.entity_type_id=t2.entity_type_id and ea1.attribute_code='status') and
427
+ t4.entity_id=t1.id_product and
428
+ t4.attribute_id=(select ea1.attribute_id from ".$table8." as ea1 where ea1.entity_type_id=t2.entity_type_id and ea1.attribute_code='price')
429
+ order by t2.created_at desc, t2.updated_at desc
430
+ limit ".$mPage.", ".$mLimit;
431
+
432
+ //echo $query.'<br />';
433
+
434
+ $arrayProductRecords = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query);
435
+
436
+ $ia=0;
437
+ foreach($arrayProductRecords as $apr){
438
+
439
+ $query1 = 'select
440
+ t7.entity_id
441
+ from
442
+ '.$table6.' as t6,
443
+ '.$table7.' as t7
444
+ where
445
+ (t7.customer_id='.$session['id'].' or ISNULL(t7.customer_id)) and
446
+ t7.status=\'complete\' and
447
+ t6.product_id='.$apr['entity_id'].' and
448
+ t6.order_id=t7.entity_id
449
+ '.($filter_from!=''?' and t6.updated_at>="'.$db_filter_from.' 00:00:00"':'').'
450
+ '.($filter_to!=''?' and t6.updated_at<="'.$db_filter_to.' 23:59:59"':'').'
451
+ ';
452
+
453
+ //echo $query1; exit();
454
+
455
+ $countSales = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query1);
456
+ $ic=0;
457
+ foreach($countSales as $cs){
458
+ $ic++;
459
+ }
460
+
461
+ $arrayProductRecords[$ia]['count']=$ic;
462
+
463
+ $ia++;
464
+
465
+ }
466
+
467
+
468
+ if($arrayProductRecords){
469
+
470
+ $arrayProductRecords[0]['limit']=$mLimit;
471
+ $arrayProductRecords[0]['page']=($mPage==0?1:$mPage);
472
+
473
+ $arrayProductRecords[0]['filter_from']=$filter_from;
474
+ $arrayProductRecords[0]['filter_to']=$filter_to;
475
+
476
+ }
477
+
478
+ return $arrayProductRecords;
479
+
480
+ }
481
+
482
+ public function selectTreeCategory($root=1, $category_id=array()){
483
+
484
+ //$html = 'rootID = '.$root.'<br />';
485
+ $html .= '<ul>';
486
+
487
+ $parentCategoryId = $root;
488
+ $categories = Mage::getModel('catalog/category')
489
+ ->getCollection()
490
+ ->addFieldToFilter('parent_id', array('eq'=>$parentCategoryId))
491
+ ->addFieldToFilter('is_active', array('eq'=>'1'))
492
+ ->addAttributeToSelect('*');
493
+
494
+ foreach($categories as $cats){
495
+ $html .= '<li><input type="checkbox" id="checkcat'.$cats->getEntityId().'" name="checkcat'.$cats->getEntityId().'" value="'.$cats->getEntityId().'" onclick="categorytree('.$cats->getEntityId().')" '.(in_array($cats->getEntityId(),$category_id)?'checked="checked"':'').'> '.$cats->getName();
496
+
497
+ $html .= $this->selectTreeCategory($cats->getEntityId(),$category_id);
498
+
499
+ $html .= '</li>';
500
+ }
501
+
502
+ $html .= '</ul>';
503
+
504
+ return $html;
505
+ }
506
+
507
+
508
+
509
+ public function saveForm(){
510
+
511
+ $storeId = $this->getRequest()->getParam('store');
512
+ $redirectBack = $this->getRequest()->getParam('back', false);
513
+ $productId = $this->getRequest()->getParam('id');
514
+ $isEdit = (int)($this->getRequest()->getParam('id') != null);
515
+
516
+ $data = $this->getRequest()->getPost();
517
+
518
+ if ($data) {
519
+
520
+ $this->_filterStockData($data['product']['stock_data']);
521
+
522
+ $product = $this->_initProductSave();
523
+
524
+ if ($downloadable = $this->getRequest()->getPost('downloadable')) {
525
+ $product->setDownloadableData($downloadable);
526
+ }
527
+
528
+ try {
529
+
530
+ $product->save();
531
+ $productId = $product->getId();
532
+
533
+ if(!$isEdit){
534
+
535
+ $resource = Mage::getSingleton('core/resource');
536
+ $table_amm = $resource->getTableName('amm_product');
537
+
538
+ $session = $this->_getSession()->toArray();
539
+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
540
+ $write->query("insert into ".$table_amm." (id_customer, id_product) values (".$session['id'].",".$product->getId().")");
541
+
542
+ }
543
+
544
+ /**
545
+ * Do copying data to stores
546
+ */
547
+ if (isset($data['copy_to_stores'])) {
548
+ foreach ($data['copy_to_stores'] as $storeTo=>$storeFrom) {
549
+ $newProduct = Mage::getModel('catalog/product')
550
+ ->setStoreId($storeFrom)
551
+ ->load($productId)
552
+ ->setStoreId($storeTo)
553
+ ->save();
554
+ }
555
+ }
556
+
557
+ Mage::getModel('catalogrule/rule')->applyAllRulesToProduct($productId);
558
+
559
+ } catch (Mage_Core_Exception $e) {
560
+ $redirectBack = true;
561
+ } catch (Exception $e) {
562
+ Mage::logException($e);
563
+ $redirectBack = true;
564
+ }
565
+ }
566
+ }
567
+
568
+
569
+
570
+ protected function _initProduct()
571
+ {
572
+ $productId = (int) $this->getRequest()->getParam('id');
573
+ $product = Mage::getModel('catalog/product')
574
+ ->setStoreId($this->getRequest()->getParam('store', 0));
575
+
576
+ if (!$productId) {
577
+ if ($setId = (int) $this->getRequest()->getParam('set')) {
578
+ $product->setAttributeSetId($setId);
579
+ }
580
+
581
+ if ($typeId = $this->getRequest()->getParam('type')) {
582
+ $product->setTypeId($typeId);
583
+ }
584
+ }
585
+
586
+ $product->setData('_edit_mode', true);
587
+ if ($productId) {
588
+ try {
589
+ $product->load($productId);
590
+ } catch (Exception $e) {
591
+ $product->setTypeId(Mage_Catalog_Model_Product_Type::DEFAULT_TYPE);
592
+ Mage::logException($e);
593
+ }
594
+ }
595
+
596
+ $attributes = $this->getRequest()->getParam('attributes');
597
+ if ($attributes && $product->isConfigurable() &&
598
+ (!$productId || !$product->getTypeInstance()->getUsedProductAttributeIds())) {
599
+ $product->getTypeInstance()->setUsedProductAttributeIds(
600
+ explode(",", base64_decode(urldecode($attributes)))
601
+ );
602
+ }
603
+
604
+ // Required attributes of simple product for configurable creation
605
+ if ($this->getRequest()->getParam('popup')
606
+ && $requiredAttributes = $this->getRequest()->getParam('required')) {
607
+ $requiredAttributes = explode(",", $requiredAttributes);
608
+ foreach ($product->getAttributes() as $attribute) {
609
+ if (in_array($attribute->getId(), $requiredAttributes)) {
610
+ $attribute->setIsRequired(1);
611
+ }
612
+ }
613
+ }
614
+
615
+ if ($this->getRequest()->getParam('popup')
616
+ && $this->getRequest()->getParam('product')
617
+ && !is_array($this->getRequest()->getParam('product'))
618
+ && $this->getRequest()->getParam('id', false) === false) {
619
+
620
+ $configProduct = Mage::getModel('catalog/product')
621
+ ->setStoreId(0)
622
+ ->load($this->getRequest()->getParam('product'))
623
+ ->setTypeId($this->getRequest()->getParam('type'));
624
+
625
+ /* @var $configProduct Mage_Catalog_Model_Product */
626
+ $data = array();
627
+ foreach ($configProduct->getTypeInstance()->getEditableAttributes() as $attribute) {
628
+
629
+ /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
630
+ if(!$attribute->getIsUnique()
631
+ && $attribute->getFrontend()->getInputType()!='gallery'
632
+ && $attribute->getAttributeCode() != 'required_options'
633
+ && $attribute->getAttributeCode() != 'has_options'
634
+ && $attribute->getAttributeCode() != $configProduct->getIdFieldName()) {
635
+ $data[$attribute->getAttributeCode()] = $configProduct->getData($attribute->getAttributeCode());
636
+ }
637
+ }
638
+
639
+ $product->addData($data)
640
+ ->setWebsiteIds($configProduct->getWebsiteIds());
641
+ }
642
+
643
+ Mage::register('product', $product);
644
+ Mage::register('current_product', $product);
645
+ Mage::getSingleton('cms/wysiwyg_config')->setStoreId($this->getRequest()->getParam('store'));
646
+ return $product;
647
+ }
648
+
649
+ protected function _initProductSave()
650
+ {
651
+ $product = $this->_initProduct();
652
+ $productData = $this->getRequest()->getPost('product');
653
+ if ($productData) {
654
+ $this->_filterStockData($productData['stock_data']);
655
+ }
656
+
657
+ /**
658
+ * Websites
659
+ */
660
+ if (!isset($productData['website_ids'])) {
661
+ $productData['website_ids'] = array();
662
+ }
663
+
664
+ $wasLockedMedia = false;
665
+ if ($product->isLockedAttribute('media')) {
666
+ $product->unlockAttribute('media');
667
+ $wasLockedMedia = true;
668
+ }
669
+
670
+ $product->addData($productData);
671
+
672
+ if ($wasLockedMedia) {
673
+ $product->lockAttribute('media');
674
+ }
675
+
676
+ if (Mage::app()->isSingleStoreMode()) {
677
+ $product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));
678
+ }
679
+
680
+ /**
681
+ * Create Permanent Redirect for old URL key
682
+ */
683
+ if ($product->getId() && isset($productData['url_key_create_redirect']))
684
+ // && $product->getOrigData('url_key') != $product->getData('url_key')
685
+ {
686
+ $product->setData('save_rewrites_history', (bool)$productData['url_key_create_redirect']);
687
+ }
688
+
689
+ /**
690
+ * Check "Use Default Value" checkboxes values
691
+ */
692
+ if ($useDefaults = $this->getRequest()->getPost('use_default')) {
693
+ foreach ($useDefaults as $attributeCode) {
694
+ $product->setData($attributeCode, false);
695
+ }
696
+ }
697
+
698
+ /**
699
+ * Init product links data (related, upsell, crosssel)
700
+ */
701
+ $links = $this->getRequest()->getPost('links');
702
+ if (isset($links['related']) && !$product->getRelatedReadonly()) {
703
+ $product->setRelatedLinkData(Mage::helper('adminhtml/js')->decodeGridSerializedInput($links['related']));
704
+ }
705
+ if (isset($links['upsell']) && !$product->getUpsellReadonly()) {
706
+ $product->setUpSellLinkData(Mage::helper('adminhtml/js')->decodeGridSerializedInput($links['upsell']));
707
+ }
708
+ if (isset($links['crosssell']) && !$product->getCrosssellReadonly()) {
709
+ $product->setCrossSellLinkData(Mage::helper('adminhtml/js')
710
+ ->decodeGridSerializedInput($links['crosssell']));
711
+ }
712
+ if (isset($links['grouped']) && !$product->getGroupedReadonly()) {
713
+ $product->setGroupedLinkData(Mage::helper('adminhtml/js')->decodeGridSerializedInput($links['grouped']));
714
+ }
715
+
716
+ /**
717
+ * Initialize product categories
718
+ */
719
+ $categoryIds = $this->getRequest()->getPost('category_ids');
720
+
721
+ if (null !== $categoryIds) {
722
+ if (empty($categoryIds)) {
723
+ $categoryIds = array();
724
+ }
725
+ $product->setCategoryIds($categoryIds);
726
+ }
727
+
728
+ /**
729
+ * Initialize data for configurable product
730
+ */
731
+ if (($data = $this->getRequest()->getPost('configurable_products_data'))
732
+ && !$product->getConfigurableReadonly()
733
+ ) {
734
+ $product->setConfigurableProductsData(Mage::helper('core')->jsonDecode($data));
735
+ }
736
+ if (($data = $this->getRequest()->getPost('configurable_attributes_data'))
737
+ && !$product->getConfigurableReadonly()
738
+ ) {
739
+ $product->setConfigurableAttributesData(Mage::helper('core')->jsonDecode($data));
740
+ }
741
+
742
+ $product->setCanSaveConfigurableAttributes(
743
+ (bool) $this->getRequest()->getPost('affect_configurable_product_attributes')
744
+ && !$product->getConfigurableReadonly()
745
+ );
746
+
747
+ /**
748
+ * Initialize product options
749
+ */
750
+ if (isset($productData['options']) && !$product->getOptionsReadonly()) {
751
+ $product->setProductOptions($productData['options']);
752
+ }
753
+
754
+ $product->setCanSaveCustomOptions(
755
+ (bool)$this->getRequest()->getPost('affect_product_custom_options')
756
+ && !$product->getOptionsReadonly()
757
+ );
758
+
759
+ Mage::dispatchEvent(
760
+ 'catalog_product_prepare_save',
761
+ array('product' => $product, 'request' => $this->getRequest())
762
+ );
763
+
764
+ return $product;
765
+ }
766
+
767
+ protected function _filterStockData(&$stockData) {
768
+ if (!isset($stockData['use_config_manage_stock'])) {
769
+ $stockData['use_config_manage_stock'] = 0;
770
+ }
771
+ if (isset($stockData['qty']) && (float)$stockData['qty'] > self::MAX_QTY_VALUE) {
772
+ $stockData['qty'] = self::MAX_QTY_VALUE;
773
+ }
774
+ if (isset($stockData['min_qty']) && (int)$stockData['min_qty'] < 0) {
775
+ $stockData['min_qty'] = 0;
776
+ }
777
+ if (!isset($stockData['is_decimal_divided']) || $stockData['is_qty_decimal'] == 0) {
778
+ $stockData['is_decimal_divided'] = 0;
779
+ }
780
+ }
781
+
782
+
783
+
784
+
785
+
786
+ }
app/code/community/Amm/Product/Helper/Data.php ADDED
@@ -0,0 +1,292 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Amm_Product_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ public function checkTable(){
7
+
8
+ $resource = Mage::getSingleton('core/resource');
9
+
10
+ $table1 = $resource->getTableName('amm_product');
11
+ $table2 = $resource->getTableName('catalog_product_entity');
12
+
13
+ $query1 = 'select
14
+ t1.id
15
+ from
16
+ '.$table1.' as t1
17
+ LEFT JOIN
18
+ '.$table2.' as t2
19
+ ON
20
+ t1.id_product=t2.entity_id
21
+ where
22
+ ISNULL(t2.entity_id);
23
+ ';
24
+
25
+ $resultd = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query1);
26
+ $queryd = '';
27
+ if($resultd){
28
+ foreach($resultd as $d){
29
+ $queryd .= " delete from ".$table1." where id=".$d['id'].";";
30
+ }
31
+
32
+ $resource->getConnection('core_write')->query($queryd);
33
+ }
34
+
35
+ }
36
+
37
+ public function getIdProduct($id=0){
38
+
39
+ $resource = Mage::getSingleton('core/resource');
40
+
41
+ $table1 = $resource->getTableName('amm_product');
42
+ $query1 = 'select
43
+ t1.id_product
44
+ from
45
+ '.$table1.' as t1
46
+ where
47
+ t1.id='.$id.';
48
+ ';
49
+ foreach(Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query1) as $far){
50
+ return $far['id_product'];
51
+ }
52
+ }
53
+
54
+ public function deleteProduct($session=0, $id=0){
55
+
56
+ $resource = Mage::getSingleton('core/resource');
57
+
58
+ $table1 = $resource->getTableName('amm_product');
59
+ $tables = array(
60
+ $resource->getTableName('catalog_product_entity'),
61
+ $resource->getTableName('catalog_product_entity_datetime'),
62
+ $resource->getTableName('catalog_product_entity_decimal'),
63
+ $resource->getTableName('catalog_product_entity_int'),
64
+ $resource->getTableName('catalog_product_entity_media_gallery'),
65
+ $resource->getTableName('catalog_product_entity_text'),
66
+ $resource->getTableName('catalog_product_entity_varchar'),
67
+ $resource->getTableName('catalog_product_flat_1'),
68
+ $resource->getTableName('catalog_product_index_eav'),
69
+ $resource->getTableName('catalog_product_index_eav_idx'),
70
+ $resource->getTableName('catalog_product_index_eav_tmp'),
71
+ $resource->getTableName('catalog_product_index_price'),
72
+ $resource->getTableName('catalog_product_index_price_idx'),
73
+ $resource->getTableName('catalog_product_index_price_tmp')
74
+ );
75
+
76
+ $query = "delete from ".$table1." where id_customer=".$session." and id_product=".$id.";";
77
+ foreach($tables as $ts){
78
+ $query .= " delete from ".$ts." where entity_id=".$id.";";
79
+ }
80
+
81
+ //echo $query; exit();
82
+
83
+ $resource->getConnection('core_write')->query($query);
84
+
85
+ return true;
86
+
87
+ }
88
+
89
+ public function getAdditionalFieldsProduct($id=0,$entid=0){
90
+
91
+ $resource = Mage::getSingleton('core/resource');
92
+
93
+ $table1 = $resource->getTableName('eav_attribute_group');
94
+ $table2 = $resource->getTableName('eav_entity_attribute');
95
+ $table3 = $resource->getTableName('eav_attribute');
96
+ $table4 = $resource->getTableName('catalog_product_entity_text');
97
+ $table5 = $resource->getTableName('catalog_product_entity_varchar');
98
+ $table6 = $resource->getTableName('catalog_product_entity_int');
99
+ $table7 = $resource->getTableName('catalog_eav_attribute');
100
+
101
+ $query1 = 'select
102
+ t1.attribute_group_id,
103
+ t1.attribute_group_name
104
+ from
105
+ '.$table1.' as t1
106
+ where
107
+ t1.attribute_set_id='.$id.' and
108
+ t1.attribute_group_name not like "%Design%" and
109
+ t1.attribute_group_name not like "%Description%" and
110
+ t1.attribute_group_name not like "%General%" and
111
+ t1.attribute_group_name not like "%Gift Options%" and
112
+ t1.attribute_group_name not like "%Images%" and
113
+ t1.attribute_group_name not like "%Meta Information%" and
114
+ t1.attribute_group_name not like "%Prices%" and
115
+ t1.attribute_group_name not like "%Recurring Profile%"
116
+ order by t1.sort_order asc;
117
+ ';
118
+
119
+ $productsArray1 = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query1);
120
+
121
+ $query2 = 'select
122
+ t2.entity_attribute_id,
123
+ t2.attribute_id,
124
+ t3.attribute_code,
125
+ t3.backend_type,
126
+ t3.frontend_input,
127
+ t3.frontend_label
128
+ from
129
+ '.$table1.' as t1,
130
+ '.$table2.' as t2,
131
+ '.$table3.' as t3,
132
+ '.$table7.' as t7
133
+ where
134
+ t1.attribute_set_id='.$id.' and
135
+ t1.attribute_group_name not like "%Design%" and
136
+ t1.attribute_group_name not like "%General%" and
137
+ t1.attribute_group_name not like "%Gift Options%" and
138
+ t1.attribute_group_name not like "%Images%" and
139
+ t1.attribute_group_name not like "%Meta Information%" and
140
+ t1.attribute_group_name not like "%Prices%" and
141
+ t1.attribute_group_name not like "%Recurring Profile%" and
142
+ t2.attribute_set_id=t1.attribute_set_id and
143
+ t2.attribute_group_id = t1.attribute_group_id and
144
+ t3.attribute_id = t2.attribute_id and
145
+ t7.attribute_id=t2.attribute_id and t7.apply_to like "%downloadable%"
146
+ order by t2.sort_order asc;
147
+ ';
148
+
149
+ $productsArray2 = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query2);
150
+
151
+ $query3 = 'select
152
+ t4.attribute_id,
153
+ t4.value
154
+ from
155
+ '.$table1.' as t1,
156
+ '.$table2.' as t2,
157
+ '.$table3.' as t3,
158
+ '.$table4.' as t4,
159
+ '.$table7.' as t7
160
+ where
161
+ t1.attribute_set_id='.$id.' and
162
+ t1.attribute_group_name not like "%Design%" and
163
+ t1.attribute_group_name not like "%General%" and
164
+ t1.attribute_group_name not like "%Gift Options%" and
165
+ t1.attribute_group_name not like "%Images%" and
166
+ t1.attribute_group_name not like "%Meta Information%" and
167
+ t1.attribute_group_name not like "%Prices%" and
168
+ t1.attribute_group_name not like "%Recurring Profile%" and
169
+ t2.attribute_set_id=t1.attribute_set_id and
170
+ t2.attribute_group_id = t1.attribute_group_id and
171
+ t3.attribute_id = t2.attribute_id and
172
+ t4.attribute_id = t2.attribute_id and
173
+ t4.entity_id = '.$entid.' and
174
+ t7.attribute_id=t2.attribute_id and t7.apply_to like "%downloadable%"
175
+ order by t2.sort_order asc;
176
+ ';
177
+
178
+ $productsArray3 = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query3);
179
+
180
+ $query4 = 'select
181
+ t5.attribute_id,
182
+ t5.value
183
+ from
184
+ '.$table1.' as t1,
185
+ '.$table2.' as t2,
186
+ '.$table3.' as t3,
187
+ '.$table5.' as t5,
188
+ '.$table7.' as t7
189
+ where
190
+ t1.attribute_set_id='.$id.' and
191
+ t1.attribute_group_name not like "%Design%" and
192
+ t1.attribute_group_name not like "%General%" and
193
+ t1.attribute_group_name not like "%Gift Options%" and
194
+ t1.attribute_group_name not like "%Images%" and
195
+ t1.attribute_group_name not like "%Meta Information%" and
196
+ t1.attribute_group_name not like "%Prices%" and
197
+ t1.attribute_group_name not like "%Recurring Profile%" and
198
+ t2.attribute_set_id=t1.attribute_set_id and
199
+ t2.attribute_group_id = t1.attribute_group_id and
200
+ t3.attribute_id = t2.attribute_id and
201
+ t5.attribute_id = t2.attribute_id and
202
+ t5.entity_id = '.$entid.' and
203
+ t7.attribute_id=t2.attribute_id and t7.apply_to like "%downloadable%"
204
+ order by t2.sort_order asc;
205
+ ';
206
+
207
+ $productsArray4 = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query4);
208
+
209
+ $query5 = 'select
210
+ t6.attribute_id,
211
+ t6.value
212
+ from
213
+ '.$table1.' as t1,
214
+ '.$table2.' as t2,
215
+ '.$table3.' as t3,
216
+ '.$table6.' as t6,
217
+ '.$table7.' as t7
218
+ where
219
+ t1.attribute_set_id='.$id.' and
220
+ t1.attribute_group_name not like "%Design%" and
221
+ t1.attribute_group_name not like "%General%" and
222
+ t1.attribute_group_name not like "%Gift Options%" and
223
+ t1.attribute_group_name not like "%Images%" and
224
+ t1.attribute_group_name not like "%Meta Information%" and
225
+ t1.attribute_group_name not like "%Prices%" and
226
+ t1.attribute_group_name not like "%Recurring Profile%" and
227
+ t2.attribute_set_id=t1.attribute_set_id and
228
+ t2.attribute_group_id = t1.attribute_group_id and
229
+ t3.attribute_id = t2.attribute_id and
230
+ t6.attribute_id = t2.attribute_id and
231
+ t6.entity_id = '.$entid.' and
232
+ t7.attribute_id=t2.attribute_id and t7.apply_to like "%downloadable%"
233
+ order by t2.sort_order asc;
234
+ ';
235
+
236
+ $productsArray5 = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($query5);
237
+
238
+ $arrayNot = array("Design","General","Gift Options","Images","Meta Information","Prices","Recurring Profile");
239
+
240
+ $result = '{"attributes":[';
241
+ $ir=0;
242
+ if($productsArray1){
243
+ foreach($productsArray1 as $pa1){
244
+ if(!in_array($pa1['attribute_group_name'], $arrayNot)){
245
+ $result .= ($ir>0?',':'').'{"group_id":"'.$pa1['attribute_group_id'].'", "group_name":"'.$pa1['attribute_group_name'].'"';
246
+
247
+ if($productsArray2){
248
+ $ir2=0;
249
+ $result .= ', "attribute_id":[';
250
+ foreach($productsArray2 as $pa2){
251
+ $value_textarea = '';
252
+ if($productsArray3){
253
+ foreach($productsArray3 as $pa3){
254
+ if($pa3['attribute_id']==$pa2['attribute_id']){
255
+ $value_textarea = $pa3['value'];
256
+ }
257
+ }
258
+ }
259
+ $value_text = '';
260
+ if($productsArray4){
261
+ foreach($productsArray4 as $pa4){
262
+ if($pa4['attribute_id']==$pa2['attribute_id']){
263
+ $value_text = $pa4['value'];
264
+ }
265
+ }
266
+ }
267
+ $value_boolean = '';
268
+ if($productsArray5){
269
+ foreach($productsArray5 as $pa5){
270
+ if($pa5['attribute_id']==$pa2['attribute_id']){
271
+ $value_boolean = $pa5['value'];
272
+ }
273
+ }
274
+ }
275
+
276
+ $result .= ($ir2>0?',':'').'{"id":"'.$pa2['attribute_id'].'", "code":"'.$pa2['attribute_code'].'", "type":"'.$pa2['backend_type'].'", "input":"'.$pa2['frontend_input'].'", "label":"'.$pa2['frontend_label'].'", "value":"'.($pa2['backend_type']=='text' && $pa2['frontend_input']=='textarea' ? $value_textarea : ($pa2['backend_type']=='varchar' && $pa2['frontend_input']=='text' ? $value_text : ($pa2['backend_type']=='int' && $pa2['frontend_input']=='boolean' ? $value_boolean : ''))).'"}';
277
+ $ir2++;
278
+ }
279
+ $result .= ']';
280
+ }
281
+ $result .= '}';
282
+ $ir++;
283
+ }
284
+ }
285
+ }
286
+ $result .= ']}';
287
+
288
+ return $result;
289
+ }
290
+
291
+ }
292
+
app/code/community/Amm/Product/Model/Mysql4/Product.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Amm_Product_Model_Mysql4_Product extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('product/product', 'id');
7
+ }
8
+ }
app/code/community/Amm/Product/Model/Mysql4/Product/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Amm_Product_Model_Mysql4_Product_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('product/product');
8
+ }
9
+ }
app/code/community/Amm/Product/Model/Mysql4/Setup.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+
3
+ class Amm_Product_Model_Mysql4_Setup extends Mage_Core_Model_Resource_Setup {
4
+ }
app/code/community/Amm/Product/Model/Product.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Amm_Product_Model_Product extends Mage_Core_Model_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('product/product');
8
+ }
9
+ }
app/code/community/Amm/Product/controllers/Adminhtml/IndexController.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Amm_Product_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+
5
+ protected function _initAction()
6
+ {
7
+ $this->loadLayout()->_setActiveMenu('adminhtml/adminhtml')->_addBreadcrumb('product Manager','product Manager');
8
+ return $this;
9
+ }
10
+
11
+ public function indexAction()
12
+ {
13
+ $this->_initAction()->renderLayout();
14
+ }
15
+
16
+ public function editAction()
17
+ {
18
+ $id = $this->getRequest()->getParam('id', null);
19
+ $url=Mage::getBaseUrl ()."admin/catalog_product/edit/id/".Mage::helper('product')->getIdProduct($id)."/key/97f1846ceb7058f32e09535060a4627f/";
20
+ //echo $url;
21
+ //exit();
22
+ $this->getResponse()->setRedirect($url);
23
+ //$this->_redirect('/admin/catalog_product/edit/id/'.$id.'/');
24
+ }
25
+
26
+ }
app/code/community/Amm/Product/controllers/IndexController.php ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Amm_Product_IndexController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ /**
6
+ * Index action
7
+ */
8
+
9
+ protected function _getSession()
10
+ {
11
+ return Mage::getSingleton('customer/session');
12
+ }
13
+
14
+ public function indexAction()
15
+ {
16
+ $session = $this->_getSession();
17
+
18
+ Mage::helper('product')->checkTable();
19
+
20
+ if(!$session->isLoggedIn()){
21
+ $this->_redirectUrl(Mage::helper('customer')->getLoginUrl());
22
+ }else{
23
+ $this->loadLayout();
24
+
25
+ $navigationBlock = $this->getLayout()->getBlock('customer_account_navigation');
26
+ if ($navigationBlock) {
27
+ $navigationBlock->setActive('product');
28
+ }
29
+
30
+ $this->renderLayout();
31
+ }
32
+ }
33
+
34
+ public function editAction()
35
+ {
36
+ $param = $this->getRequest()->getParams();
37
+ if($param['ep']==0){
38
+ $this->_redirectUrl('/product/');
39
+ }else{
40
+ $session = $this->_getSession();
41
+ if(!$session->isLoggedIn()){
42
+ $this->_redirectUrl(Mage::helper('customer')->getLoginUrl());
43
+ }else{
44
+ $this->loadLayout();
45
+
46
+ $navigationBlock = $this->getLayout()->getBlock('customer_account_navigation');
47
+ if ($navigationBlock) {
48
+ $navigationBlock->setActive('product');
49
+ }
50
+
51
+ $this->renderLayout();
52
+ }
53
+ }
54
+ }
55
+
56
+ public function deleteAction()
57
+ {
58
+ $param = $this->getRequest()->getParams();
59
+ if($param['p']!=0){
60
+ $session = $this->_getSession();
61
+ if(!$session->isLoggedIn()){
62
+ $this->_redirectUrl(Mage::helper('customer')->getLoginUrl());
63
+ }else{
64
+
65
+ $session_array = $session->toArray();
66
+ $result = Mage::helper('product')->deleteProduct($session_array['id'],$param['p']);
67
+ //var_dump($result);
68
+ }
69
+ }
70
+
71
+ $this->_redirectUrl('/product/');
72
+ }
73
+
74
+ public function uploadAction()
75
+ {
76
+ try {
77
+ $uploader = new Mage_Core_Model_File_Uploader('image');
78
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
79
+ $uploader->addValidateCallback('catalog_product_image',
80
+ Mage::helper('catalog/image'), 'validateUploadFile');
81
+ $uploader->setAllowRenameFiles(true);
82
+ $uploader->setFilesDispersion(true);
83
+ $result = $uploader->save(
84
+ Mage::getSingleton('catalog/product_media_config')->getBaseTmpMediaPath()
85
+ );
86
+
87
+ Mage::dispatchEvent('catalog_product_gallery_upload_image_after', array(
88
+ 'result' => $result,
89
+ 'action' => $this
90
+ ));
91
+
92
+ /**
93
+ * Workaround for prototype 1.7 methods "isJSON", "evalJSON" on Windows OS
94
+ */
95
+ $result['tmp_name'] = str_replace(DS, "/", $result['tmp_name']);
96
+ $result['path'] = str_replace(DS, "/", $result['path']);
97
+
98
+ $result['url'] = Mage::getSingleton('catalog/product_media_config')->getTmpMediaUrl($result['file']);
99
+ $result['file'] = $result['file'] . '.tmp';
100
+ $result['cookie'] = array(
101
+ 'name' => session_name(),
102
+ 'value' => $this->_getSession()->getSessionId(),
103
+ 'lifetime' => $this->_getSession()->getCookieLifetime(),
104
+ 'path' => $this->_getSession()->getCookiePath(),
105
+ 'domain' => $this->_getSession()->getCookieDomain()
106
+ );
107
+
108
+ } catch (Exception $e) {
109
+ $result = array(
110
+ 'error' => $e->getMessage(),
111
+ 'errorcode' => $e->getCode());
112
+ }
113
+
114
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
115
+ }
116
+
117
+ public function additionalfieldsAction(){
118
+ $param = $this->getRequest()->getParams();
119
+ $result = Mage::helper('product')->getAdditionalFieldsProduct($param['setp'],$param['entid']);
120
+ $this->getResponse()->setBody($result);
121
+ }
122
+
123
+ protected function _processDownload($resource, $resourceType)
124
+ {
125
+ $helper = Mage::helper('downloadable/download');
126
+ /* @var $helper Mage_Downloadable_Helper_Download */
127
+
128
+ $helper->setResource($resource, $resourceType);
129
+
130
+ $fileName = $helper->getFilename();
131
+ $contentType = $helper->getContentType();
132
+
133
+ $this->getResponse()
134
+ ->setHttpResponseCode(200)
135
+ ->setHeader('Pragma', 'public', true)
136
+ ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
137
+ ->setHeader('Content-type', $contentType, true);
138
+
139
+ if ($fileSize = $helper->getFilesize()) {
140
+ $this->getResponse()
141
+ ->setHeader('Content-Length', $fileSize);
142
+ }
143
+
144
+ if ($contentDisposition = $helper->getContentDisposition()) {
145
+ $this->getResponse()
146
+ ->setHeader('Content-Disposition', $contentDisposition . '; filename='.$fileName);
147
+ }
148
+
149
+ $this->getResponse()
150
+ ->clearBody();
151
+ $this->getResponse()
152
+ ->sendHeaders();
153
+
154
+ $helper->output();
155
+ }
156
+
157
+ /**
158
+ * Download link action
159
+ *
160
+ */
161
+ public function linkAction()
162
+ {
163
+ $linkId = $this->getRequest()->getParam('id', 0);
164
+ $link = Mage::getModel('downloadable/link')->load($linkId);
165
+ if ($link->getId()) {
166
+ $resource = '';
167
+ $resourceType = '';
168
+ if ($link->getLinkType() == Mage_Downloadable_Helper_Download::LINK_TYPE_URL) {
169
+ $resource = $link->getLinkUrl();
170
+ $resourceType = Mage_Downloadable_Helper_Download::LINK_TYPE_URL;
171
+ } elseif ($link->getLinkType() == Mage_Downloadable_Helper_Download::LINK_TYPE_FILE) {
172
+ $resource = Mage::helper('downloadable/file')->getFilePath(
173
+ Mage_Downloadable_Model_Link::getBasePath(), $link->getLinkFile()
174
+ );
175
+ $resourceType = Mage_Downloadable_Helper_Download::LINK_TYPE_FILE;
176
+ }
177
+ try {
178
+ $this->_processDownload($resource, $resourceType);
179
+ } catch (Mage_Core_Exception $e) {
180
+ $this->_getCustomerSession()->addError(Mage::helper('downloadable')->__('An error occurred while getting the requested content.'));
181
+ }
182
+ }
183
+ exit(0);
184
+ }
185
+
186
+ public function downloadableuploadAction()
187
+ {
188
+ $type = $this->getRequest()->getParam('type');
189
+ $tmpPath = '';
190
+ if ($type == 'samples') {
191
+ $tmpPath = Mage_Downloadable_Model_Sample::getBaseTmpPath();
192
+ } elseif ($type == 'links') {
193
+ $tmpPath = Mage_Downloadable_Model_Link::getBaseTmpPath();
194
+ } elseif ($type == 'link_samples') {
195
+ $tmpPath = Mage_Downloadable_Model_Link::getBaseSampleTmpPath();
196
+ }
197
+ $result = array();
198
+ try {
199
+ $uploader = new Mage_Core_Model_File_Uploader($type);
200
+ $uploader->setAllowRenameFiles(true);
201
+ $uploader->setFilesDispersion(true);
202
+ $result = $uploader->save($tmpPath);
203
+
204
+ /**
205
+ * Workaround for prototype 1.7 methods "isJSON", "evalJSON" on Windows OS
206
+ */
207
+ $result['tmp_name'] = str_replace(DS, "/", $result['tmp_name']);
208
+ $result['path'] = str_replace(DS, "/", $result['path']);
209
+
210
+ if (isset($result['file'])) {
211
+ $fullPath = rtrim($tmpPath, DS) . DS . ltrim($result['file'], DS);
212
+ Mage::helper('core/file_storage_database')->saveFile($fullPath);
213
+ }
214
+
215
+ $result['cookie'] = array(
216
+ 'name' => session_name(),
217
+ 'value' => $this->_getSession()->getSessionId(),
218
+ 'lifetime' => $this->_getSession()->getCookieLifetime(),
219
+ 'path' => $this->_getSession()->getCookiePath(),
220
+ 'domain' => $this->_getSession()->getCookieDomain()
221
+ );
222
+ } catch (Exception $e) {
223
+ $result = array('error'=>$e->getMessage(), 'errorcode'=>$e->getCode());
224
+ }
225
+
226
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
227
+ }
228
+ }
app/code/community/Amm/Product/controllers/StatisticaController.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Amm_Product_StatisticaController extends Mage_Core_Controller_Front_Action
4
+ {
5
+
6
+ protected function _getSession()
7
+ {
8
+ return Mage::getSingleton('customer/session');
9
+ }
10
+
11
+ public function indexAction()
12
+ {
13
+ $session = $this->_getSession();
14
+
15
+ Mage::helper('product')->checkTable();
16
+
17
+ if(!$session->isLoggedIn()){
18
+ $this->_redirectUrl(Mage::helper('customer')->getLoginUrl());
19
+ }else{
20
+
21
+ $this->loadLayout();
22
+
23
+ $navigationBlock = $this->getLayout()->getBlock('customer_account_navigation');
24
+ if ($navigationBlock) {
25
+ $navigationBlock->setActive('product/statistica');
26
+ }
27
+
28
+ $this->renderLayout();
29
+
30
+ }
31
+ }
32
+ }
app/code/community/Amm/Product/etc/config.xml ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Amm_Product>
5
+ <version>0.0.1</version>
6
+ </Amm_Product>
7
+ </modules>
8
+
9
+ <frontend>
10
+ <routers>
11
+ <product>
12
+ <use>standard</use>
13
+ <args>
14
+ <module>Amm_Product</module>
15
+ <frontName>product</frontName>
16
+ </args>
17
+ </product>
18
+ </routers>
19
+ <layout>
20
+ <updates>
21
+ <product>
22
+ <file>product.xml</file>
23
+ </product>
24
+ </updates>
25
+ </layout>
26
+ </frontend>
27
+
28
+ <admin>
29
+ <routers>
30
+ <product>
31
+ <use>admin</use>
32
+ <args>
33
+ <module>Amm_Product</module>
34
+ <frontName>product</frontName>
35
+ </args>
36
+ </product>
37
+ </routers>
38
+ </admin>
39
+
40
+ <adminhtml>
41
+ <layout>
42
+ <updates>
43
+ <product>
44
+ <file>product.xml</file>
45
+ </product>
46
+ </updates>
47
+ </layout>
48
+ <menu>
49
+ <adminhtml translate="title" module="adminhtml">
50
+ <title>Additional modules</title>
51
+ <sort_order>100</sort_order>
52
+ <children>
53
+ <productindex translate="title" module="adminhtml">
54
+ <title>Customer's products</title>
55
+ <action>product/adminhtml_index</action>
56
+ <sort_order>5</sort_order>
57
+ </productindex>
58
+ </children>
59
+ </adminhtml>
60
+ </menu>
61
+ </adminhtml>
62
+
63
+ <global>
64
+ <blocks>
65
+ <product>
66
+ <class>Amm_Product_Block</class>
67
+ </product>
68
+ </blocks>
69
+ <helpers>
70
+ <product>
71
+ <class>Amm_Product_Helper</class>
72
+ </product>
73
+ </helpers>
74
+ <models>
75
+ <product>
76
+ <class>Amm_Product_Model</class>
77
+ <resourceModel>product_mysql4</resourceModel>
78
+ </product>
79
+ <product_mysql4>
80
+ <class>Amm_Product_Model_Mysql4</class>
81
+ <entities>
82
+ <product>
83
+ <table>amm_product</table>
84
+ </product>
85
+ </entities>
86
+ </product_mysql4>
87
+ </models>
88
+ <!-- allow the plugin to read and write -->
89
+ <resources>
90
+
91
+ <product_setup>
92
+ <setup>
93
+ <module>Amm_Product</module>
94
+ <class>Amm_Product_Model_Mysql4_Setup</class>
95
+ </setup>
96
+ </product_setup>
97
+
98
+ <!-- connection to write -->
99
+ <product_write>
100
+ <connection>
101
+ <use>core_write</use>
102
+ </connection>
103
+ </product_write>
104
+ <!-- connection to read -->
105
+ <product_read>
106
+ <connection>
107
+ <use>core_read</use>
108
+ </connection>
109
+ </product_read>
110
+ </resources>
111
+ </global>
112
+ </config>
app/code/community/Amm/Product/sql/product_setup/mysql4-install-0.0.1.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $table = $installer->getConnection()->newTable($installer->getTable('amm_product'))
8
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
9
+ 'unsigned' => true,
10
+ 'nullable' => false,
11
+ 'primary' => true,
12
+ 'identity' => true,
13
+ ), 'ID')
14
+ ->addColumn('id_customer', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
15
+ 'unsigned' => true,
16
+ 'nullable' => true,
17
+ ), 'ID Customer')
18
+ ->addColumn('id_product', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
19
+ 'unsigned' => true,
20
+ 'nullable' => true,
21
+ ), 'ID Product')
22
+ ->setComment('amm_product table');
23
+ $installer->getConnection()->createTable($table);
24
+
25
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/product.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <layout version="0.0.1">
3
+ <product_adminhtml_index_index>
4
+ <reference name="content">
5
+ <block type="product/adminhtml_grid" name="product_grid" />
6
+ </reference>
7
+ </product_adminhtml_index_index>
8
+ </layout>
app/design/frontend/base/default/layout/product.xml ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <layout version="0.1.0">
2
+ <default>
3
+ <reference name="head">
4
+ <action method="addItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params></params></action>
5
+ <action method="addItem"><type>js</type><name>calendar/calendar.js</name></action>
6
+ <action method="addItem"><type>js</type><name>calendar/calendar-setup.js</name></action>
7
+ </reference>
8
+ <reference name="content">
9
+ </reference>
10
+ </default>
11
+
12
+ <customer_account>
13
+ <reference name="customer_account_navigation">
14
+ <action method="addLink" translate="label" module="product"><name>product</name><path>product</path><label>My Showcase</label></action>
15
+ <action method="addLink" translate="label" module="product"><name>product/statistica</name><path>product/statistica</path><label>My Statistica</label></action>
16
+ </reference>
17
+ </customer_account>
18
+
19
+
20
+ <product_index_index>
21
+ <remove name="right"/>
22
+
23
+ <update handle="customer_account"/>
24
+
25
+ <reference name="root">
26
+ <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
27
+ </reference>
28
+
29
+ <reference name="content">
30
+ <block type="product/monblock" name="show_monblock" template="product/show.phtml" />
31
+ </reference>
32
+ </product_index_index>
33
+
34
+ <product_index_edit>
35
+ <remove name="right"/>
36
+
37
+ <update handle="customer_account"/>
38
+
39
+ <reference name="root">
40
+ <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
41
+ </reference>
42
+
43
+ <reference name="content">
44
+ <block type="product/monblock" name="show_monblock" template="product/show.phtml" />
45
+ </reference>
46
+ </product_index_edit>
47
+
48
+ <product_index_delete>
49
+ <remove name="right"/>
50
+
51
+ <update handle="customer_account"/>
52
+
53
+ <reference name="root">
54
+ <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
55
+ </reference>
56
+
57
+ <reference name="content">
58
+ <block type="product/monblock" name="show_monblock" template="product/show.phtml" />
59
+ </reference>
60
+ </product_index_delete>
61
+
62
+ <product_statistica_index>
63
+ <remove name="right"/>
64
+
65
+ <update handle="customer_account"/>
66
+
67
+ <reference name="root">
68
+ <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
69
+ </reference>
70
+
71
+ <reference name="content">
72
+ <block type="product/monblock" name="show_monblock" template="product/statistica.phtml" />
73
+ </reference>
74
+ </product_statistica_index>
75
+ </layout>
app/etc/modules/Amm_Product.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Amm_Product>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Amm_Product>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Amm_Product</name>
4
+ <version>1.0.0.2</version>
5
+ <stability>stable</stability>
6
+ <license>GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Enables clients in account to add products in the category of the directory store.</summary>
10
+ <description>Enables clients in account to add products in the category of the directory store. &#xD;
11
+ Type products - Downloadable.</description>
12
+ <notes>enable to adding downloadable products in account</notes>
13
+ <authors><author><name>Alexey</name><user>auto-converted</user><email>softaliancecom@gmail.com</email></author></authors>
14
+ <date>2013-05-20</date>
15
+ <time>11:55:41</time>
16
+ <contents><target name="magecommunity"><dir name="Amm"><dir name="Product"><dir name="Block"><dir name="Adminhtml"><dir name="Product"><file name="Grid.php" hash="b4661fe5f4f754cdb0c91abe6b01f14f"/></dir><file name="Grid.php" hash="f93b4d141b863e2ec71feb169f440240"/></dir><file name="Monblock.php" hash="59f97b2e53b27e223f5d6e650ab7b5c4"/></dir><dir name="Helper"><file name="Data.php" hash="9b4fba746e0acdffc418696f0ab08b37"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Product"><file name="Collection.php" hash="a57cf43fb3989a3a865c23ca7fa9ff1a"/></dir><file name="Product.php" hash="15b7fea36193f2e377bd009d52c23121"/><file name="Setup.php" hash="92ed515cd2cb4963f9d363612cabdfca"/></dir><file name="Product.php" hash="afd9cd60318217520ee85b7c0e9f9e7c"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="9b01987b5765f788341173d0b86259ab"/></dir><file name="IndexController.php" hash="1403f6278b45d46aa252be5763f1e660"/><file name="StatisticaController.php" hash="65b01ef7adc9dfeff32791ec672a011f"/></dir><dir name="etc"><file name="config.xml" hash="613627e7d6bca7865232ca786a18e551"/></dir><dir name="sql"><dir name="product_setup"><file name="mysql4-install-0.0.1.php" hash="070155ac1b2191b9f4b2c2210e89ad4f"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Amm_Product.xml" hash="e239211fb553bb940071c95391a955e3"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="product.xml" hash="9cb80194a83716c2201d3782b8e497b2"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="product.xml" hash="71c6a8638e1a92986355ee8ee85d9a8b"/></dir></dir></dir></dir></target></contents>
17
+ <compatible/>
18
+ <dependencies/>
19
+ </package>