1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27:
28: 29: 30: 31: 32: 33: 34:
35: class Mage_Sales_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
36: {
37: 38: 39: 40: 41:
42: protected $_flatEntityTables = array(
43: 'quote' => 'sales/quote',
44: 'quote_item' => 'sales/quote_item',
45: 'quote_address' => 'sales/quote_address',
46: 'quote_address_item'=> 'sales/quote_address_item',
47: 'quote_address_rate'=> 'sales/quote_shipping_rate',
48: 'quote_payment' => 'sales/quote_payment',
49: 'order' => 'sales/order',
50: 'order_payment' => 'sales/order_payment',
51: 'order_item' => 'sales/order_item',
52: 'order_address' => 'sales/order_address',
53: 'order_status_history' => 'sales/order_status_history',
54: 'invoice' => 'sales/invoice',
55: 'invoice_item' => 'sales/invoice_item',
56: 'invoice_comment' => 'sales/invoice_comment',
57: 'creditmemo' => 'sales/creditmemo',
58: 'creditmemo_item' => 'sales/creditmemo_item',
59: 'creditmemo_comment'=> 'sales/creditmemo_comment',
60: 'shipment' => 'sales/shipment',
61: 'shipment_item' => 'sales/shipment_item',
62: 'shipment_track' => 'sales/shipment_track',
63: 'shipment_comment' => 'sales/shipment_comment',
64: );
65:
66: 67: 68: 69: 70:
71: protected $_flatEntitiesGrid = array(
72: 'order',
73: 'invoice',
74: 'shipment',
75: 'creditmemo'
76: );
77:
78: 79: 80: 81: 82: 83:
84: protected function _flatTableExist($table)
85: {
86: $tablesList = $this->getConnection()->listTables();
87: return in_array(strtoupper($this->getTable($table)), array_map('strtoupper', $tablesList));
88: }
89:
90: 91: 92: 93: 94: 95: 96: 97:
98: public function addAttribute($entityTypeId, $code, array $attr)
99: {
100: if (isset($this->_flatEntityTables[$entityTypeId]) &&
101: $this->_flatTableExist($this->_flatEntityTables[$entityTypeId]))
102: {
103: $this->_addFlatAttribute($this->_flatEntityTables[$entityTypeId], $code, $attr);
104: $this->_addGridAttribute($this->_flatEntityTables[$entityTypeId], $code, $attr, $entityTypeId);
105: } else {
106: parent::addAttribute($entityTypeId, $code, $attr);
107: }
108: return $this;
109: }
110:
111: 112: 113: 114: 115: 116: 117: 118:
119: protected function _addFlatAttribute($table, $attribute, $attr)
120: {
121: $tableInfo = $this->getConnection()->describeTable($this->getTable($table));
122: if (isset($tableInfo[$attribute])) {
123: return $this;
124: }
125: $columnDefinition = $this->_getAttributeColumnDefinition($attribute, $attr);
126: $this->getConnection()->addColumn($this->getTable($table), $attribute, $columnDefinition);
127: return $this;
128: }
129:
130: 131: 132: 133: 134: 135: 136: 137: 138:
139: protected function _addGridAttribute($table, $attribute, $attr, $entityTypeId)
140: {
141: if (in_array($entityTypeId, $this->_flatEntitiesGrid) && !empty($attr['grid'])) {
142: $columnDefinition = $this->_getAttributeColumnDefinition($attribute, $attr);
143: $this->getConnection()->addColumn($this->getTable($table . '_grid'), $attribute, $columnDefinition);
144: }
145: return $this;
146: }
147:
148: 149: 150: 151: 152: 153: 154:
155: protected function _getAttributeColumnDefinition($code, $data)
156: {
157:
158: $data['type'] = isset($data['type']) ? $data['type'] : 'varchar';
159: $type = null;
160: $length = null;
161: switch ($data['type']) {
162: case 'timestamp':
163: $type = Varien_Db_Ddl_Table::TYPE_TIMESTAMP;
164: break;
165: case 'datetime':
166: $type = Varien_Db_Ddl_Table::TYPE_DATETIME;
167: break;
168: case 'decimal':
169: $type = Varien_Db_Ddl_Table::TYPE_DECIMAL;
170: $length = '12,4';
171: break;
172: case 'int':
173: $type = Varien_Db_Ddl_Table::TYPE_INTEGER;
174: break;
175: case 'text':
176: $type = Varien_Db_Ddl_Table::TYPE_TEXT;
177: $length = 65536;
178: break;
179: case 'char':
180: case 'varchar':
181: $type = Varien_Db_Ddl_Table::TYPE_TEXT;
182: $length = 255;
183: break;
184: }
185: if ($type !== null) {
186: $data['type'] = $type;
187: $data['length'] = $length;
188: }
189:
190: $data['nullable'] = isset($data['required']) ? !$data['required'] : true;
191: $data['comment'] = isset($data['comment']) ? $data['comment'] : ucwords(str_replace('_', ' ', $code));
192: return $data;
193: }
194:
195: 196: 197: 198: 199:
200: public function getDefaultEntities()
201: {
202: return array(
203: 'quote'=>array(
204: 'entity_model' => 'sales/quote',
205: 'table' => 'sales/quote',
206: 'attributes' => array(
207: 'entity_id' => array('type'=>'static'),
208: 'is_active' => array('type'=>'static'),
209: 'store_id' => array('type'=>'static'),
210: 'remote_ip' => array('type'=>'static'),
211: 'checkout_method' => array('type'=>'static'),
212: 'password_hash' => array('type'=>'static'),
213: 'orig_order_id' => array('type'=>'static'),
214: 'converted_at' => array('type'=>'static'),
215: 'reserved_order_id' => array('type'=>'static'),
216:
217: 'coupon_code' => array('type'=>'static'),
218: 'global_currency_code' => array('type'=>'static'),
219: 'base_currency_code' => array('type'=>'static'),
220: 'store_currency_code' => array('type'=>'static'),
221: 'quote_currency_code' => array('type'=>'static'),
222: 'store_to_base_rate' => array('type'=>'static'),
223: 'store_to_quote_rate' => array('type'=>'static'),
224: 'base_to_global_rate' => array('type'=>'static'),
225: 'base_to_quote_rate' => array('type'=>'static'),
226:
227: 'items_count' => array('type'=>'static'),
228: 'items_qty' => array('type'=>'static'),
229:
230: 'grand_total' => array('type'=>'static'),
231: 'base_grand_total' => array('type'=>'static'),
232:
233: 'applied_rule_ids' => array('type'=>'static'),
234:
235: 'is_virtual' => array('type'=>'static'),
236: 'is_multi_shipping' => array('type'=>'static'),
237:
238: 'customer_id' => array('type'=>'static'),
239: 'customer_tax_class_id' => array('type'=>'static'),
240: 'customer_group_id' => array('type'=>'static'),
241: 'customer_email' => array('type'=>'static'),
242: 'customer_prefix' => array('type'=>'static'),
243: 'customer_firstname' => array('type'=>'static'),
244: 'customer_middlename' => array('type'=>'static'),
245: 'customer_lastname' => array('type'=>'static'),
246: 'customer_suffix' => array('type'=>'static'),
247: 'customer_note' => array('type'=>'static'),
248: 'customer_note_notify' => array('type'=>'static'),
249: 'customer_is_guest' => array('type'=>'static'),
250: 'customer_taxvat' => array('type'=>'static'),
251: 'customer_dob' => array('type'=>'static'),
252: 'customer_gender' => array('type'=>'static'),
253: ),
254: ),
255:
256: 'quote_item' => array(
257: 'entity_model' => 'sales/quote_item',
258: 'table' => 'sales/quote_item',
259: 'attributes' => array(
260: 'product_id' => array('type'=>'static'),
261: 'super_product_id' => array('type'=>'static'),
262: 'parent_product_id' => array('type'=>'static'),
263: 'sku' => array('type'=>'static'),
264: 'name' => array('type'=>'static'),
265: 'description' => array('type'=>'static'),
266:
267: 'weight' => array('type'=>'static'),
268: 'free_shipping' => array('type'=>'static'),
269: 'qty' => array('type'=>'static'),
270: 'is_qty_decimal' => array('type'=>'static'),
271:
272: 'price' => array('type'=>'static'),
273: 'custom_price' => array('type'=>'static'),
274: 'discount_percent' => array('type'=>'static'),
275: 'discount_amount' => array('type'=>'static'),
276: 'no_discount' => array('type'=>'static'),
277: 'tax_percent' => array('type'=>'static'),
278: 'tax_amount' => array('type'=>'static'),
279: 'row_total' => array('type'=>'static'),
280: 'row_total_with_discount' => array('type'=>'static'),
281:
282: 'base_price' => array('type'=>'static'),
283: 'base_discount_amount' => array('type'=>'static'),
284: 'base_tax_amount' => array('type'=>'static'),
285: 'base_row_total' => array('type'=>'static'),
286:
287: 'row_weight' => array('type'=>'static'),
288: 'applied_rule_ids' => array('type'=>'static'),
289: 'additional_data' => array('type'=>'static'),
290: ),
291: ),
292:
293: 'quote_address' => array(
294: 'entity_model' => 'sales/quote_address',
295: 'table' => 'sales/quote_address',
296: 'attributes' => array(
297: 'address_type' => array('type'=>'static'),
298:
299: 'customer_id' => array('type'=>'static'),
300: 'customer_address_id' => array('type'=>'static'),
301: 'save_in_address_book' => array('type'=>'static'),
302: 'email' => array('type'=>'static'),
303: 'prefix' => array('type'=>'static'),
304: 'firstname' => array('type'=>'static'),
305: 'middlename' => array('type'=>'static'),
306: 'lastname' => array('type'=>'static'),
307: 'suffix' => array('type'=>'static'),
308: 'company' => array('type'=>'static'),
309: 'street' => array('type'=>'static'),
310: 'city' => array('type'=>'static'),
311: 'region' => array('type'=>'static'),
312: 'region_id' => array('type'=>'static'),
313: 'postcode' => array('type'=>'static'),
314: 'country_id' => array('type'=>'static'),
315: 'telephone' => array('type'=>'static'),
316: 'fax' => array('type'=>'static'),
317:
318: 'same_as_billing' => array('type'=>'static'),
319: 'free_shipping' => array('type'=>'static'),
320: 'weight' => array('type'=>'static'),
321: 'collect_shipping_rates' => array('type'=>'static'),
322:
323: 'shipping_method' => array('type'=>'static'),
324: 'shipping_description' => array('type'=>'static'),
325:
326: 'subtotal' => array('type'=>'static'),
327: 'subtotal_with_discount' => array('type'=>'static'),
328: 'tax_amount' => array('type'=>'static'),
329: 'shipping_amount' => array('type'=>'static'),
330: 'shipping_tax_amount' => array('type'=>'static'),
331: 'discount_amount' => array('type'=>'static'),
332: 'grand_total' => array('type'=>'static'),
333:
334: 'base_subtotal' => array('type'=>'static'),
335: 'base_subtotal_with_discount' => array('type'=>'static'),
336: 'base_tax_amount' => array('type'=>'static'),
337: 'base_shipping_amount' => array('type'=>'static'),
338: 'base_shipping_tax_amount' => array('type'=>'static'),
339: 'base_discount_amount' => array('type'=>'static'),
340: 'base_grand_total' => array('type'=>'static'),
341:
342: 'customer_notes' => array('type'=>'static'),
343: 'applied_taxes' => array('type'=>'text'),
344: ),
345: ),
346: 'quote_address_item' => array(
347: 'entity_model' => 'sales/quote_address_item',
348: 'table' =>'sales/quote_entity',
349: 'attributes' => array(
350: 'quote_item_id' => array('type'=>'int'),
351: 'product_id' => array('type'=>'int'),
352: 'super_product_id' => array('type'=>'int'),
353: 'parent_product_id' => array('type'=>'int'),
354: 'sku' => array(),
355: 'image' => array(),
356: 'name' => array(),
357: 'description' => array('type'=>'text'),
358:
359: 'weight' => array('type'=>'decimal'),
360: 'free_shipping' => array('type'=>'int'),
361: 'qty' => array('type'=>'decimal'),
362: 'is_qty_decimal' => array('type'=>'int'),
363:
364: 'price' => array('type'=>'decimal'),
365: 'discount_percent' => array('type'=>'decimal'),
366: 'discount_amount' => array('type'=>'decimal'),
367: 'no_discount' => array('type'=>'int'),
368: 'tax_percent' => array('type'=>'decimal'),
369: 'tax_amount' => array('type'=>'decimal'),
370: 'row_total' => array('type'=>'decimal'),
371: 'row_total_with_discount' => array('type'=>'decimal'),
372:
373: 'base_price' => array('type'=>'decimal'),
374: 'base_discount_amount' => array('type'=>'decimal'),
375: 'base_tax_amount' => array('type'=>'decimal'),
376: 'base_row_total' => array('type'=>'decimal'),
377:
378: 'row_weight' => array('type'=>'decimal'),
379: 'applied_rule_ids' => array(),
380: 'additional_data' => array('type'=>'text'),
381: ),
382: ),
383: 'quote_address_rate' => array(
384: 'entity_model' => 'sales/quote_address_rate',
385: 'table' => 'sales/quote_entity',
386: 'attributes' => array(
387: 'code' => array(),
388: 'carrier' => array(),
389: 'carrier_title' => array(),
390: 'method' => array(),
391: 'method_description' => array('type'=>'text'),
392: 'price' => array('type'=>'decimal'),
393: 'error_message' => array('type'=>'text'),
394: ),
395: ),
396: 'quote_payment' => array(
397: 'entity_model' => 'sales/quote_payment',
398: 'table' =>'sales/quote_entity',
399: 'attributes' => array(
400: 'method' => array(),
401: 'additional_data' => array('type'=>'text'),
402: 'po_number' => array(),
403: 'cc_type' => array(),
404: 'cc_number_enc' => array(),
405: 'cc_last4' => array(),
406: 'cc_owner' => array(),
407: 'cc_exp_month' => array('type'=>'int'),
408: 'cc_exp_year' => array('type'=>'int'),
409: 'cc_cid_enc' => array(),
410: 'cc_ss_issue' => array(),
411: 'cc_ss_start_month' => array('type'=>'int'),
412: 'cc_ss_start_year' => array('type'=>'int'),
413: ),
414: ),
415:
416: 'order' => array(
417: 'entity_model' => 'sales/order',
418: 'table' => 'sales/order',
419: 'increment_model' => 'eav/entity_increment_numeric',
420: 'increment_per_store' =>true,
421: 'backend_prefix' =>'sales_entity/order_attribute_backend',
422: 'attributes' => array(
423: 'entity_id' => array(
424: 'type' =>'static',
425: 'backend' =>'sales_entity/order_attribute_backend_parent'
426: ),
427: 'store_id' => array('type'=>'static'),
428: 'store_name' => array('type'=>'varchar'),
429: 'remote_ip' => array(),
430:
431: 'status' => array('type'=>'varchar'),
432: 'state' => array('type'=>'varchar'),
433: 'hold_before_status' => array('type'=>'varchar'),
434: 'hold_before_state' => array('type'=>'varchar'),
435:
436: 'relation_parent_id' => array('type'=>'varchar'),
437: 'relation_parent_real_id' => array('type'=>'varchar'),
438: 'relation_child_id' => array('type'=>'varchar'),
439: 'relation_child_real_id' => array('type'=>'varchar'),
440: 'original_increment_id' => array('type'=>'varchar'),
441: 'edit_increment' => array('type'=>'int'),
442:
443: 'ext_order_id' => array('type'=>'varchar'),
444: 'ext_customer_id' => array('type'=>'varchar'),
445:
446: 'quote_id' => array('type'=>'int'),
447: 'quote_address_id' => array('type'=>'int'),
448: 'billing_address_id' => array('type'=>'int', 'backend'=>'_billing'),
449: 'shipping_address_id' => array('type'=>'int', 'backend'=>'_shipping'),
450:
451: 'coupon_code' => array(),
452: 'applied_rule_ids' => array(),
453:
454: 'global_currency_code' => array(),
455: 'base_currency_code' => array(),
456: 'store_currency_code' => array(),
457: 'order_currency_code' => array(),
458: 'store_to_base_rate' => array('type'=>'decimal'),
459: 'store_to_order_rate' => array('type'=>'decimal'),
460: 'base_to_global_rate' => array('type'=>'decimal'),
461: 'base_to_order_rate' => array('type'=>'decimal'),
462:
463: 'is_virtual' => array('type'=>'int'),
464:
465: 'shipping_method' => array(),
466: 'shipping_description' => array(),
467: 'weight' => array('type'=>'decimal'),
468:
469: 'tax_amount' => array('type'=>'static'),
470: 'shipping_amount' => array('type'=>'static'),
471: 'shipping_tax_amount' => array('type'=>'static'),
472: 'discount_amount' => array('type'=>'static'),
473:
474: 'subtotal' => array('type'=>'static'),
475: 'grand_total' => array('type'=>'static'),
476: 'total_paid' => array('type'=>'static'),
477: 'total_due' => array('type'=>'decimal'),
478: 'total_refunded' => array('type'=>'static'),
479: 'total_qty_ordered' => array('type'=>'static'),
480: 'total_canceled' => array('type'=>'static'),
481: 'total_invoiced' => array('type'=>'static'),
482: 'total_online_refunded' => array('type'=>'static'),
483: 'total_offline_refunded' => array('type'=>'static'),
484: 'adjustment_positive' => array('type'=>'decimal'),
485: 'adjustment_negative' => array('type'=>'decimal'),
486:
487: 'base_tax_amount' => array('type'=>'static'),
488: 'base_shipping_amount' => array('type'=>'static'),
489: 'base_shipping_tax_amount' => array('type'=>'static'),
490: 'base_discount_amount' => array('type'=>'static'),
491:
492: 'base_subtotal' => array('type'=>'static'),
493: 'base_grand_total' => array('type'=>'static'),
494: 'base_total_paid' => array('type'=>'static'),
495: 'base_total_due' => array('type'=>'decimal'),
496: 'base_total_refunded' => array('type'=>'static'),
497: 'base_total_qty_ordered' => array('type'=>'static'),
498: 'base_total_canceled' => array('type'=>'static'),
499: 'base_total_invoiced' => array('type'=>'static'),
500: 'base_total_online_refunded' => array('type'=>'static'),
501: 'base_total_offline_refunded'=> array('type'=>'static'),
502: 'base_adjustment_positive' => array('type'=>'decimal'),
503: 'base_adjustment_negative' => array('type'=>'decimal'),
504:
505: 'subtotal_refunded' => array('type'=>'static'),
506: 'subtotal_canceled' => array('type'=>'static'),
507: 'discount_refunded' => array('type'=>'static'),
508: 'discount_canceled' => array('type'=>'static'),
509: 'discount_invoiced' => array('type'=>'static'),
510: 'subtotal_invoiced' => array('type'=>'static'),
511: 'tax_refunded' => array('type'=>'static'),
512: 'tax_canceled' => array('type'=>'static'),
513: 'tax_invoiced' => array('type'=>'static'),
514: 'shipping_refunded' => array('type'=>'static'),
515: 'shipping_canceled' => array('type'=>'static'),
516: 'shipping_invoiced' => array('type'=>'static'),
517: 'base_subtotal_refunded' => array('type'=>'static'),
518: 'base_subtotal_canceled' => array('type'=>'static'),
519: 'base_discount_refunded' => array('type'=>'static'),
520: 'base_discount_canceled' => array('type'=>'static'),
521: 'base_discount_invoiced' => array('type'=>'static'),
522: 'base_subtotal_invoiced' => array('type'=>'static'),
523: 'base_tax_refunded' => array('type'=>'static'),
524: 'base_tax_canceled' => array('type'=>'static'),
525: 'base_tax_invoiced' => array('type'=>'static'),
526: 'base_shipping_refunded' => array('type'=>'static'),
527: 'base_shipping_canceled' => array('type'=>'static'),
528: 'base_shipping_invoiced' => array('type'=>'static'),
529:
530: 'protect_code' => array('type' => 'static'),
531:
532: 'customer_id' => array('type'=>'static', 'visible'=>false),
533: 'customer_group_id' => array('type'=>'int', 'visible'=>false),
534: 'customer_email' => array('type'=>'varchar', 'visible'=>false),
535: 'customer_prefix' => array('type'=>'varchar', 'visible'=>false),
536: 'customer_firstname' => array('type'=>'varchar', 'visible'=>false),
537: 'customer_middlename' => array('type'=>'varchar', 'visible'=>false),
538: 'customer_lastname' => array('type'=>'varchar', 'visible'=>false),
539: 'customer_suffix' => array('type'=>'varchar', 'visible'=>false),
540: 'customer_note' => array('type'=>'text', 'visible'=>false),
541: 'customer_note_notify' => array('type'=>'int', 'visible'=>false),
542: 'customer_is_guest' => array('type'=>'int', 'visible'=>false),
543: 'email_sent' => array('type'=>'int', 'visible'=>false),
544: 'customer_taxvat' => array('type'=>'varchar', 'visible'=>false),
545: 'customer_dob' => array('type'=>'datetime',
546: 'backend' => 'eav/entity_attribute_backend_datetime'),
547: 'customer_gender' => array('type'=>'int', 'visible'=>false),
548: ),
549: ),
550: 'order_address' => array(
551: 'entity_model' => 'sales/order_address',
552: 'table' =>'sales/order_entity',
553: 'attributes' => array(
554: 'parent_id' => array('type'=>'static', 'backend'=>'sales_entity/order_attribute_backend_child'),
555: 'quote_address_id' => array('type'=>'int'),
556: 'address_type' => array(),
557: 'customer_id' => array('type'=>'int'),
558: 'customer_address_id' => array('type'=>'int'),
559: 'email' => array(),
560: 'prefix' => array(),
561: 'firstname' => array(),
562: 'middlename' => array(),
563: 'lastname' => array(),
564: 'suffix' => array(),
565: 'company' => array(),
566: 'street' => array(),
567: 'city' => array(),
568: 'region' => array(),
569: 'region_id' => array('type'=>'int'),
570: 'postcode' => array(),
571: 'country_id' => array('type'=>'varchar'),
572: 'telephone' => array(),
573: 'fax' => array(),
574:
575: ),
576: ),
577: 'order_item' => array(
578: 'entity_model' => 'sales/order_item',
579: 'table' =>'sales/order_entity',
580: 'attributes' => array(
581: 'parent_id' => array(
582: 'type' =>'static',
583: 'backend' =>'sales_entity/order_attribute_backend_child'
584: ),
585:
586: 'quote_item_id' => array('type'=>'int'),
587: 'product_id' => array('type'=>'int'),
588: 'super_product_id' => array('type'=>'int'),
589: 'parent_product_id' => array('type'=>'int'),
590: 'is_virtual' => array('type'=>'int'),
591: 'sku' => array(),
592: 'name' => array(),
593: 'description' => array('type'=>'text'),
594: 'weight' => array('type'=>'decimal'),
595:
596: 'is_qty_decimal' => array('type'=>'int'),
597: 'qty_ordered' => array('type'=>'decimal'),
598: 'qty_backordered' => array('type'=>'decimal'),
599: 'qty_invoiced' => array('type'=>'decimal'),
600: 'qty_canceled' => array('type'=>'decimal'),
601: 'qty_shipped' => array('type'=>'decimal'),
602: 'qty_refunded' => array('type'=>'decimal'),
603:
604: 'original_price' => array('type'=>'decimal'),
605: 'price' => array('type'=>'decimal'),
606: 'cost' => array('type'=>'decimal'),
607:
608: 'discount_percent' => array('type'=>'decimal'),
609: 'discount_amount' => array('type'=>'decimal'),
610: 'discount_invoiced' => array('type'=>'decimal'),
611:
612: 'tax_percent' => array('type'=>'decimal'),
613: 'tax_amount' => array('type'=>'decimal'),
614: 'tax_invoiced' => array('type'=>'decimal'),
615:
616: 'row_total' => array('type'=>'decimal'),
617: 'row_weight' => array('type'=>'decimal'),
618: 'row_invoiced' => array('type'=>'decimal'),
619: 'invoiced_total' => array('type'=>'decimal'),
620: 'amount_refunded' => array('type'=>'decimal'),
621:
622: 'base_price' => array('type'=>'decimal'),
623: 'base_original_price' => array('type'=>'decimal'),
624: 'base_discount_amount' => array('type'=>'decimal'),
625: 'base_discount_invoiced' => array('type'=>'decimal'),
626: 'base_tax_amount' => array('type'=>'decimal'),
627: 'base_tax_invoiced' => array('type'=>'decimal'),
628: 'base_row_total' => array('type'=>'decimal'),
629: 'base_row_invoiced' => array('type'=>'decimal'),
630: 'base_invoiced_total' => array('type'=>'decimal'),
631: 'base_amount_refunded' => array('type'=>'decimal'),
632:
633: 'applied_rule_ids' => array(),
634: 'additional_data' => array('type'=>'text'),
635: ),
636: ),
637: 'order_payment' => array(
638: 'entity_model' => 'sales/order_payment',
639: 'table'=>'sales/order_entity',
640: 'attributes' => array(
641: 'parent_id' => array(
642: 'type'=>'static',
643: 'backend'=>'sales_entity/order_attribute_backend_child'
644: ),
645: 'quote_payment_id' => array('type'=>'int'),
646: 'method' => array(),
647: 'additional_data' => array('type'=>'text'),
648: 'last_trans_id' => array(),
649: 'po_number' => array(),
650:
651: 'cc_type' => array(),
652: 'cc_number_enc' => array(),
653: 'cc_last4' => array(),
654: 'cc_owner' => array(),
655: 'cc_exp_month' => array(),
656: 'cc_exp_year' => array(),
657:
658: 'cc_ss_issue' => array(),
659: 'cc_ss_start_month' => array(),
660: 'cc_ss_start_year' => array(),
661:
662: 'cc_status' => array(),
663: 'cc_status_description' => array(),
664: 'cc_trans_id' => array(),
665: 'cc_approval' => array(),
666: 'cc_avs_status' => array(),
667: 'cc_cid_status' => array(),
668:
669: 'cc_debug_request_body' => array(),
670: 'cc_debug_response_body'=> array(),
671: 'cc_debug_response_serialized' => array(),
672:
673: 'anet_trans_method' => array(),
674: 'echeck_routing_number' => array(),
675: 'echeck_bank_name' => array(),
676: 'echeck_account_type' => array(),
677: 'echeck_account_name' => array(),
678: 'echeck_type' => array(),
679:
680: 'amount_ordered' => array('type'=>'decimal'),
681: 'amount_authorized' => array('type'=>'decimal'),
682: 'amount_paid' => array('type'=>'decimal'),
683: 'amount_canceled' => array('type'=>'decimal'),
684: 'amount_refunded' => array('type'=>'decimal'),
685: 'shipping_amount' => array('type'=>'decimal'),
686: 'shipping_captured' => array('type'=>'decimal'),
687: 'shipping_refunded' => array('type'=>'decimal'),
688:
689: 'base_amount_ordered' => array('type'=>'decimal'),
690: 'base_amount_authorized' => array('type'=>'decimal'),
691: 'base_amount_paid' => array('type'=>'decimal'),
692: 'base_amount_paid_online' => array('type'=>'decimal'),
693: 'base_amount_canceled' => array('type'=>'decimal'),
694: 'base_amount_refunded' => array('type'=>'decimal'),
695: 'base_amount_refunded_online' => array('type'=>'decimal'),
696: 'base_shipping_amount' => array('type'=>'decimal'),
697: 'base_shipping_captured' => array('type'=>'decimal'),
698: 'base_shipping_refunded' => array('type'=>'decimal'),
699: ),
700: ),
701:
702: 'order_status_history' => array(
703: 'entity_model' => 'sales/order_status_history',
704: 'table'=>'sales/order_entity',
705: 'attributes' => array(
706: 'parent_id' => array(
707: 'type'=>'static',
708: 'backend'=>'sales_entity/order_attribute_backend_child'
709: ),
710: 'status' => array('type'=>'varchar'),
711: 'comment' => array('type'=>'text'),
712: 'is_customer_notified' => array('type'=>'int'),
713: ),
714: ),
715:
716: 'invoice' => array(
717: 'entity_model' => 'sales/order_invoice',
718: 'table' =>'sales/order_entity',
719: 'increment_model' =>'eav/entity_increment_numeric',
720: 'increment_per_store'=>true,
721: 'backend_prefix' =>'sales_entity/order_attribute_backend',
722: 'attributes' => array(
723: 'entity_id' => array(
724: 'type'=>'static',
725: 'backend'=>'sales_entity/order_invoice_attribute_backend_parent'
726: ),
727:
728: 'state' => array('type'=>'int'),
729: 'is_used_for_refund' => array('type'=>'int'),
730: 'transaction_id' => array(),
731:
732:
733: 'order_id' => array(
734: 'type'=>'int',
735: 'backend'=>'sales_entity/order_invoice_attribute_backend_order'
736: ),
737:
738: 'billing_address_id' => array('type'=>'int'),
739: 'shipping_address_id' => array('type'=>'int'),
740:
741: 'global_currency_code' => array(),
742: 'base_currency_code' => array(),
743: 'store_currency_code' => array(),
744: 'order_currency_code' => array(),
745: 'store_to_base_rate' => array('type'=>'decimal'),
746: 'store_to_order_rate' => array('type'=>'decimal'),
747: 'base_to_global_rate' => array('type'=>'decimal'),
748: 'base_to_order_rate' => array('type'=>'decimal'),
749:
750: 'subtotal' => array('type'=>'decimal'),
751: 'discount_amount' => array('type'=>'decimal'),
752: 'tax_amount' => array('type'=>'decimal'),
753: 'shipping_amount' => array('type'=>'decimal'),
754: 'grand_total' => array('type'=>'decimal'),
755: 'total_qty' => array('type'=>'decimal'),
756:
757: 'can_void_flag' => array('type'=>'int'),
758:
759: 'base_subtotal' => array('type'=>'decimal'),
760: 'base_discount_amount' => array('type'=>'decimal'),
761: 'base_tax_amount' => array('type'=>'decimal'),
762: 'base_shipping_amount' => array('type'=>'decimal'),
763: 'base_grand_total' => array('type'=>'decimal'),
764: 'email_sent' => array('type'=>'int'),
765: 'store_id' => array('type'=>'static'),
766: ),
767: ),
768:
769: 'invoice_item' => array(
770: 'entity_model' => 'sales/order_invoice_item',
771:
772: 'table'=>'sales/order_entity',
773: 'attributes' => array(
774: 'parent_id' => array(
775: 'type'=>'static',
776: 'backend'=>'sales_entity/order_invoice_attribute_backend_child'
777: ),
778: 'order_item_id' => array('type'=>'int'),
779: 'product_id' => array('type'=>'int'),
780: 'name' => array(),
781: 'description' => array('type'=>'text'),
782: 'sku' => array(),
783: 'qty' => array('type'=>'decimal'),
784: 'cost' => array('type'=>'decimal'),
785: 'price' => array('type'=>'decimal'),
786: 'discount_amount' => array('type'=>'decimal'),
787: 'tax_amount' => array('type'=>'decimal'),
788: 'row_total' => array('type'=>'decimal'),
789:
790: 'base_price' => array('type'=>'decimal'),
791: 'base_discount_amount' => array('type'=>'decimal'),
792: 'base_tax_amount' => array('type'=>'decimal'),
793: 'base_row_total' => array('type'=>'decimal'),
794:
795: 'additional_data' => array('type'=>'text'),
796: ),
797: ),
798:
799: 'invoice_comment' => array(
800: 'entity_model' => 'sales/order_invoice_comment',
801: 'table'=>'sales/order_entity',
802: 'attributes' => array(
803: 'parent_id' => array(
804: 'type'=>'static',
805: 'backend'=>'sales_entity/order_invoice_attribute_backend_child'
806: ),
807: 'comment' => array('type'=>'text'),
808: 'is_customer_notified' => array('type'=>'int'),
809: ),
810: ),
811:
812:
813:
814: 'shipment' => array(
815: 'entity_model' => 'sales/order_shipment',
816:
817: 'table'=>'sales/order_entity',
818: 'increment_model'=>'eav/entity_increment_numeric',
819: 'increment_per_store'=>true,
820: 'backend_prefix'=>'sales_entity/order_attribute_backend',
821: 'attributes' => array(
822: 'entity_id' => array(
823: 'type'=>'static',
824: 'backend'=>'sales_entity/order_shipment_attribute_backend_parent'
825: ),
826:
827: 'customer_id' => array('type'=>'int'),
828: 'order_id' => array('type'=>'int'),
829: 'shipment_status' => array('type'=>'int'),
830: 'billing_address_id' => array('type'=>'int'),
831: 'shipping_address_id' => array('type'=>'int'),
832:
833: 'total_qty' => array('type'=>'decimal'),
834: 'total_weight' => array('type'=>'decimal'),
835: 'email_sent' => array('type'=>'int'),
836: 'store_id' => array('type' => 'static'),
837: ),
838: ),
839:
840: 'shipment_item' => array(
841: 'entity_model' => 'sales/order_shipment_item',
842:
843: 'table'=>'sales/order_entity',
844: 'attributes' => array(
845: 'parent_id' => array(
846: 'type'=>'static',
847: 'backend'=>'sales_entity/order_shipment_attribute_backend_child'
848: ),
849: 'order_item_id' => array('type'=>'int'),
850: 'product_id' => array('type'=>'int'),
851: 'name' => array(),
852: 'description' => array('type'=>'text'),
853: 'sku' => array(),
854: 'qty' => array('type'=>'decimal'),
855: 'price' => array('type'=>'decimal'),
856: 'weight' => array('type'=>'decimal'),
857: 'row_total' => array('type'=>'decimal'),
858:
859: 'additional_data' => array('type'=>'text'),
860: ),
861: ),
862:
863: 'shipment_comment' => array(
864: 'entity_model' => 'sales/order_shipment_comment',
865: 'table'=>'sales/order_entity',
866: 'attributes' => array(
867: 'parent_id' => array(
868: 'type'=>'static',
869: 'backend'=>'sales_entity/order_shipment_attribute_backend_child'
870: ),
871: 'comment' => array('type'=>'text'),
872: 'is_customer_notified' => array('type'=>'int'),
873: ),
874: ),
875:
876: 'shipment_track' => array(
877: 'entity_model' => 'sales/order_shipment_track',
878: 'table'=>'sales/order_entity',
879: 'attributes' => array(
880: 'parent_id' => array(
881: 'type'=>'static',
882: 'backend'=>'sales_entity/order_shipment_attribute_backend_child'
883: ),
884: 'order_id' => array('type'=>'int'),
885: 'number' => array('type'=>'text'),
886: 'carrier_code' => array('type'=>'varchar'),
887: 'title' => array('type'=>'varchar'),
888: 'description' => array('type'=>'text'),
889: 'qty' => array('type'=>'decimal'),
890: 'weight' => array('type'=>'decimal'),
891: ),
892: ),
893:
894: 'creditmemo' => array(
895: 'entity_model' => 'sales/order_creditmemo',
896:
897: 'table'=>'sales/order_entity',
898: 'increment_model'=>'eav/entity_increment_numeric',
899: 'increment_per_store'=>true,
900: 'backend_prefix'=>'sales_entity/order_attribute_backend',
901: 'attributes' => array(
902: 'entity_id' => array(
903: 'type'=>'static',
904: 'backend'=>'sales_entity/order_creditmemo_attribute_backend_parent'
905: ),
906: 'state' => array('type'=>'int'),
907: 'invoice_id' => array('type'=>'int'),
908: 'transaction_id'=> array(),
909:
910: 'order_id' => array('type'=>'int'),
911: 'creditmemo_status' => array('type'=>'int'),
912: 'billing_address_id' => array('type'=>'int'),
913: 'shipping_address_id' => array('type'=>'int'),
914:
915: 'global_currency_code' => array(),
916: 'base_currency_code' => array(),
917: 'store_currency_code' => array(),
918: 'order_currency_code' => array(),
919: 'store_to_base_rate' => array('type'=>'decimal'),
920: 'store_to_order_rate' => array('type'=>'decimal'),
921: 'base_to_global_rate' => array('type'=>'decimal'),
922: 'base_to_order_rate' => array('type'=>'decimal'),
923:
924: 'subtotal' => array('type'=>'decimal'),
925: 'discount_amount' => array('type'=>'decimal'),
926: 'tax_amount' => array('type'=>'decimal'),
927: 'shipping_amount' => array('type'=>'decimal'),
928: 'adjustment' => array('type'=>'decimal'),
929: 'adjustment_positive' => array('type'=>'decimal'),
930: 'adjustment_negative' => array('type'=>'decimal'),
931: 'grand_total' => array('type'=>'decimal'),
932:
933: 'base_subtotal' => array('type'=>'decimal'),
934: 'base_discount_amount' => array('type'=>'decimal'),
935: 'base_tax_amount' => array('type'=>'decimal'),
936: 'base_shipping_amount' => array('type'=>'decimal'),
937: 'base_adjustment' => array('type'=>'decimal'),
938: 'base_adjustment_positive' => array('type'=>'decimal'),
939: 'base_adjustment_negative' => array('type'=>'decimal'),
940: 'base_grand_total' => array('type'=>'decimal'),
941: 'email_sent' => array('type' => 'int'),
942: 'store_id' => array('type' => 'static'),
943: ),
944: ),
945:
946: 'creditmemo_item' => array(
947: 'entity_model' => 'sales/order_creditmemo_item',
948:
949: 'table'=>'sales/order_entity',
950: 'attributes' => array(
951: 'parent_id' => array(
952: 'type'=>'static',
953: 'backend'=>'sales_entity/order_creditmemo_attribute_backend_child'
954: ),
955: 'order_item_id' => array('type'=>'int'),
956: 'product_id' => array('type'=>'int'),
957: 'name' => array(),
958: 'description' => array('type'=>'text'),
959: 'sku' => array(),
960: 'qty' => array('type'=>'decimal'),
961: 'cost' => array('type'=>'decimal'),
962: 'price' => array('type'=>'decimal'),
963: 'discount_amount' => array('type'=>'decimal'),
964: 'tax_amount' => array('type'=>'decimal'),
965: 'row_total' => array('type'=>'decimal'),
966:
967: 'base_price' => array('type'=>'decimal'),
968: 'base_discount_amount' => array('type'=>'decimal'),
969: 'base_tax_amount' => array('type'=>'decimal'),
970: 'base_row_total' => array('type'=>'decimal'),
971:
972: 'additional_data' => array('type'=>'text'),
973: ),
974: ),
975:
976: 'creditmemo_comment' => array(
977: 'entity_model' => 'sales/order_creditmemo_comment',
978: 'table'=>'sales/order_entity',
979: 'attributes' => array(
980: 'parent_id' => array(
981: 'type'=>'static',
982: 'backend'=>'sales_entity/order_creditmemo_attribute_backend_child'
983: ),
984: 'comment' => array('type'=>'text'),
985: 'is_customer_notified' => array('type'=>'int'),
986: ),
987: ),
988:
989: );
990: }
991: }
992: