Version Notes
Versão 0.1.0
- listando todos os pedidos
Download this release
Release Info
Developer | Inovarti |
Extension | Inovarti_Enviei |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/community/Inovarti/Enviei/Helper/Data.php +12 -0
- app/code/community/Inovarti/Enviei/Model/Api.php +105 -0
- app/code/community/Inovarti/Enviei/Model/System/Config/Source/Line.php +27 -0
- app/code/community/Inovarti/Enviei/etc/adminhtml.xml +32 -0
- app/code/community/Inovarti/Enviei/etc/api.xml +46 -0
- app/code/community/Inovarti/Enviei/etc/config.xml +49 -0
- app/code/community/Inovarti/Enviei/etc/system.xml +67 -0
- app/etc/modules/Inovarti_Enviei.xml +8 -0
- app/locale/pt_BR/Inovarti_Enviei.csv +10 -0
- package.xml +19 -0
app/code/community/Inovarti/Enviei/Helper/Data.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Enviei
|
5 |
+
*
|
6 |
+
* @category Enviei
|
7 |
+
* @package Inovarti_Enviei
|
8 |
+
* @copyright Copyright (c) 2013 Inovarti. (http://www.inovarti.com.br)
|
9 |
+
*/
|
10 |
+
class Inovarti_Enviei_Helper_Data extends Mage_Core_Helper_Abstract {
|
11 |
+
|
12 |
+
}
|
app/code/community/Inovarti/Enviei/Model/Api.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Enviei
|
5 |
+
*
|
6 |
+
* @category Enviei
|
7 |
+
* @package Inovarti_Enviei
|
8 |
+
* @copyright Copyright (c) 2013 Inovarti. (http://www.inovarti.com.br)
|
9 |
+
*/
|
10 |
+
class Inovarti_Enviei_Model_Api extends Mage_Api_Model_Resource_Abstract {
|
11 |
+
|
12 |
+
const LIMIT = 50;
|
13 |
+
|
14 |
+
protected $_resource;
|
15 |
+
protected $_connection;
|
16 |
+
|
17 |
+
public function orders($params) {
|
18 |
+
$params = json_decode($params, true);
|
19 |
+
|
20 |
+
$limit = $this->_getParamValue($params, 'limit', self::LIMIT);
|
21 |
+
$orderId = $this->_getParamValue($params, 'orderId');
|
22 |
+
|
23 |
+
$select = $this->_getConnection()
|
24 |
+
->select()
|
25 |
+
->from(array('o' => $this->_getResource()->getTableName('sales/order')), array(
|
26 |
+
'OrderId' => 'entity_id',
|
27 |
+
'IncrementId' => 'increment_id',
|
28 |
+
'TotalCost' => 'base_grand_total',
|
29 |
+
'Email' => 'customer_email',
|
30 |
+
))
|
31 |
+
->join(array('a' => $this->_getResource()->getTableName('sales/order_address')), 'a.parent_id = o.entity_id', array(
|
32 |
+
'FirstName' => 'firstname',
|
33 |
+
'LastName' => 'lastname',
|
34 |
+
'Phone' => 'telephone',
|
35 |
+
'City' => 'city',
|
36 |
+
'Address' => $this->_getDbExprField('address'),
|
37 |
+
'More' => $this->_getDbExprField('more'),
|
38 |
+
'Number' => $this->_getDbExprField('number'),
|
39 |
+
'ZipCode' => 'postcode',
|
40 |
+
'Reverse' => new Zend_Db_Expr('0')
|
41 |
+
))
|
42 |
+
->joinLeft(array('r' => $this->_getResource()->getTableName('directory/country_region')), 'r.region_id = a.region_id', array(
|
43 |
+
'State' => 'code'
|
44 |
+
))
|
45 |
+
->joinLeft(array('t' => $this->_getResource()->getTableName('sales/shipment_track')), 't.order_id = o.entity_id', array(
|
46 |
+
'TrackingNumber' => 'track_number'
|
47 |
+
))
|
48 |
+
->where('o.status NOT IN(?)', array('canceled', 'holded'))
|
49 |
+
->where('a.address_type = ?', 'shipping')
|
50 |
+
//->where('t.carrier_code LIKE ? OR t.carrier_code = \'custom\' ', '%correios%')
|
51 |
+
->order('o.entity_id ASC')
|
52 |
+
->limit($limit);
|
53 |
+
|
54 |
+
if ($orderId) {
|
55 |
+
$select->where('o.entity_id > ?', $orderId);
|
56 |
+
}
|
57 |
+
//return $select->__toString();
|
58 |
+
return json_encode($this->_getConnection()->fetchAll($select));
|
59 |
+
}
|
60 |
+
|
61 |
+
protected function _getDbExprField($field) {
|
62 |
+
$line = Mage::getStoreConfig('enviei/fields/' . $field);
|
63 |
+
if ($line) {
|
64 |
+
$expr = 'SUBSTRING_INDEX(SUBSTRING_INDEX(a.street, "\n", ' . $line . '), "\n", -1)';
|
65 |
+
} else {
|
66 |
+
$expr = '""';
|
67 |
+
}
|
68 |
+
|
69 |
+
return new Zend_Db_Expr($expr);
|
70 |
+
}
|
71 |
+
|
72 |
+
protected function _getOrderIdByIncrementId($incrementId) {
|
73 |
+
$select = $this->_getConnection()
|
74 |
+
->select()
|
75 |
+
->from(array('o' => $this->_getResource()->getTableName('sales/order')), array('entity_id'))
|
76 |
+
->where('o.increment_id = ?', $incrementId);
|
77 |
+
//Mage::log("_getOrderIdByIncrementId(): " . print_r($select->__toString(), 1));
|
78 |
+
return $this->_getConnection()->fetchOne($select);
|
79 |
+
}
|
80 |
+
|
81 |
+
protected function _getParamValue($params, $key, $default = null) {
|
82 |
+
if (isset($params[$key]) && $params[$key]) {
|
83 |
+
$value = $params[$key];
|
84 |
+
} else {
|
85 |
+
$value = $default;
|
86 |
+
}
|
87 |
+
|
88 |
+
return $value;
|
89 |
+
}
|
90 |
+
|
91 |
+
protected function _getResource() {
|
92 |
+
if (is_null($this->_resource)) {
|
93 |
+
$this->_resource = Mage::getSingleton('core/resource');
|
94 |
+
}
|
95 |
+
return $this->_resource;
|
96 |
+
}
|
97 |
+
|
98 |
+
protected function _getConnection() {
|
99 |
+
if (is_null($this->_connection)) {
|
100 |
+
$this->_connection = $this->_getResource()->getConnection('core_read');
|
101 |
+
}
|
102 |
+
return $this->_connection;
|
103 |
+
}
|
104 |
+
|
105 |
+
}
|
app/code/community/Inovarti/Enviei/Model/System/Config/Source/Line.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Enviei
|
5 |
+
*
|
6 |
+
* @category Enviei
|
7 |
+
* @package Inovarti_Enviei
|
8 |
+
* @copyright Copyright (c) 2013 Inovarti. (http://www.inovarti.com.br)
|
9 |
+
*/
|
10 |
+
class Inovarti_Enviei_Model_System_Config_Source_Line {
|
11 |
+
|
12 |
+
protected $_options;
|
13 |
+
|
14 |
+
public function toOptionArray() {
|
15 |
+
if (!$this->_options) {
|
16 |
+
$this->_options = array(
|
17 |
+
array('value' => '', 'label' => Mage::helper('enviei')->__('Empty')),
|
18 |
+
array('value' => 1, 'label' => Mage::helper('enviei')->__('Street Line %s', 1)),
|
19 |
+
array('value' => 2, 'label' => Mage::helper('enviei')->__('Street Line %s', 2)),
|
20 |
+
array('value' => 3, 'label' => Mage::helper('enviei')->__('Street Line %s', 3)),
|
21 |
+
array('value' => 4, 'label' => Mage::helper('enviei')->__('Street Line %s', 4))
|
22 |
+
);
|
23 |
+
}
|
24 |
+
return $this->_options;
|
25 |
+
}
|
26 |
+
|
27 |
+
}
|
app/code/community/Inovarti/Enviei/etc/adminhtml.xml
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Enviei
|
5 |
+
*
|
6 |
+
* @category Enviei
|
7 |
+
* @package Inovarti_Enviei
|
8 |
+
* @copyright Copyright (c) 2013 Inovarti. (http://www.inovarti.com.br)
|
9 |
+
*/
|
10 |
+
-->
|
11 |
+
<config>
|
12 |
+
<acl>
|
13 |
+
<resources>
|
14 |
+
<admin>
|
15 |
+
<children>
|
16 |
+
<system>
|
17 |
+
<children>
|
18 |
+
<config>
|
19 |
+
<children>
|
20 |
+
<enviei translate="title" module="enviei">
|
21 |
+
<title>Enviei</title>
|
22 |
+
<sort_order>200</sort_order>
|
23 |
+
</enviei>
|
24 |
+
</children>
|
25 |
+
</config>
|
26 |
+
</children>
|
27 |
+
</system>
|
28 |
+
</children>
|
29 |
+
</admin>
|
30 |
+
</resources>
|
31 |
+
</acl>
|
32 |
+
</config>
|
app/code/community/Inovarti/Enviei/etc/api.xml
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Enviei
|
5 |
+
*
|
6 |
+
* @category Enviei
|
7 |
+
* @package Inovarti_Enviei
|
8 |
+
* @copyright Copyright (c) 2013 Inovarti. (http://www.inovarti.com.br)
|
9 |
+
*/
|
10 |
+
-->
|
11 |
+
<config>
|
12 |
+
<api>
|
13 |
+
<resources>
|
14 |
+
<enviei translate="title" module="enviei">
|
15 |
+
<model>enviei/api</model>
|
16 |
+
<title>Enviei Resource</title>
|
17 |
+
<acl>enviei</acl>
|
18 |
+
<methods>
|
19 |
+
<orders translate="title" module="enviei">
|
20 |
+
<title>Order List</title>
|
21 |
+
<method>orders</method>
|
22 |
+
<acl>enviei/orders</acl>
|
23 |
+
</orders>
|
24 |
+
</methods>
|
25 |
+
<faults module="enviei">
|
26 |
+
<not_exists>
|
27 |
+
<code>100</code>
|
28 |
+
<message>Order not exists.</message>
|
29 |
+
</not_exists>
|
30 |
+
</faults>
|
31 |
+
</enviei>
|
32 |
+
</resources>
|
33 |
+
<acl>
|
34 |
+
<resources>
|
35 |
+
<enviei translate="title" module="enviei">
|
36 |
+
<title>Enviei Resource</title>
|
37 |
+
<sort_order>100</sort_order>
|
38 |
+
<orders translate="title" module="enviei">
|
39 |
+
<title>Order List</title>
|
40 |
+
<sort_order>10</sort_order>
|
41 |
+
</orders>
|
42 |
+
</enviei>
|
43 |
+
</resources>
|
44 |
+
</acl>
|
45 |
+
</api>
|
46 |
+
</config>
|
app/code/community/Inovarti/Enviei/etc/config.xml
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Enviei
|
5 |
+
*
|
6 |
+
* @category Enviei
|
7 |
+
* @package Inovarti_Enviei
|
8 |
+
* @copyright Copyright (c) 2013 Inovarti. (http://www.inovarti.com.br)
|
9 |
+
*/
|
10 |
+
-->
|
11 |
+
<config>
|
12 |
+
<modules>
|
13 |
+
<Inovarti_Enviei>
|
14 |
+
<version>0.1.0</version>
|
15 |
+
</Inovarti_Enviei>
|
16 |
+
</modules>
|
17 |
+
<global>
|
18 |
+
<models>
|
19 |
+
<enviei>
|
20 |
+
<class>Inovarti_Enviei_Model</class>
|
21 |
+
</enviei>
|
22 |
+
</models>
|
23 |
+
<helpers>
|
24 |
+
<enviei>
|
25 |
+
<class>Inovarti_Enviei_Helper</class>
|
26 |
+
</enviei>
|
27 |
+
</helpers>
|
28 |
+
</global>
|
29 |
+
<adminhtml>
|
30 |
+
<translate>
|
31 |
+
<modules>
|
32 |
+
<Inovarti_Enviei>
|
33 |
+
<files>
|
34 |
+
<default>Inovarti_Enviei.csv</default>
|
35 |
+
</files>
|
36 |
+
</Inovarti_Enviei>
|
37 |
+
</modules>
|
38 |
+
</translate>
|
39 |
+
</adminhtml>
|
40 |
+
<default>
|
41 |
+
<enviei>
|
42 |
+
<fields>
|
43 |
+
<address>1</address>
|
44 |
+
<number>2</number>
|
45 |
+
<more>3</more>
|
46 |
+
</fields>
|
47 |
+
</enviei>
|
48 |
+
</default>
|
49 |
+
</config>
|
app/code/community/Inovarti/Enviei/etc/system.xml
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Enviei
|
5 |
+
*
|
6 |
+
* @category Enviei
|
7 |
+
* @package Inovarti_Enviei
|
8 |
+
* @copyright Copyright (c) 2013 Inovarti. (http://www.inovarti.com.br)
|
9 |
+
*/
|
10 |
+
-->
|
11 |
+
<config>
|
12 |
+
<tabs>
|
13 |
+
<inovarti translate="label" module="enviei">
|
14 |
+
<label>Inovarti</label>
|
15 |
+
<sort_order>299</sort_order>
|
16 |
+
</inovarti>
|
17 |
+
</tabs>
|
18 |
+
<sections>
|
19 |
+
<enviei translate="label" module="enviei">
|
20 |
+
<label>Enviei</label>
|
21 |
+
<tab>inovarti</tab>
|
22 |
+
<frontend_type>text</frontend_type>
|
23 |
+
<sort_order>200</sort_order>
|
24 |
+
<show_in_default>1</show_in_default>
|
25 |
+
<show_in_website>1</show_in_website>
|
26 |
+
<show_in_store>1</show_in_store>
|
27 |
+
<groups>
|
28 |
+
<fields translate="label">
|
29 |
+
<label>Address Fields</label>
|
30 |
+
<sort_order>20</sort_order>
|
31 |
+
<show_in_default>1</show_in_default>
|
32 |
+
<show_in_website>0</show_in_website>
|
33 |
+
<show_in_store>0</show_in_store>
|
34 |
+
<fields>
|
35 |
+
<address translate="label">
|
36 |
+
<label>Address</label>
|
37 |
+
<frontend_type>select</frontend_type>
|
38 |
+
<source_model>enviei/system_config_source_line</source_model>
|
39 |
+
<sort_order>10</sort_order>
|
40 |
+
<show_in_default>1</show_in_default>
|
41 |
+
<show_in_website>0</show_in_website>
|
42 |
+
<show_in_store>0</show_in_store>
|
43 |
+
</address>
|
44 |
+
<number translate="label">
|
45 |
+
<label>Number</label>
|
46 |
+
<frontend_type>select</frontend_type>
|
47 |
+
<source_model>enviei/system_config_source_line</source_model>
|
48 |
+
<sort_order>20</sort_order>
|
49 |
+
<show_in_default>1</show_in_default>
|
50 |
+
<show_in_website>0</show_in_website>
|
51 |
+
<show_in_store>0</show_in_store>
|
52 |
+
</number>
|
53 |
+
<more translate="label">
|
54 |
+
<label>More</label>
|
55 |
+
<frontend_type>select</frontend_type>
|
56 |
+
<source_model>enviei/system_config_source_line</source_model>
|
57 |
+
<sort_order>30</sort_order>
|
58 |
+
<show_in_default>1</show_in_default>
|
59 |
+
<show_in_website>0</show_in_website>
|
60 |
+
<show_in_store>0</show_in_store>
|
61 |
+
</more>
|
62 |
+
</fields>
|
63 |
+
</fields>
|
64 |
+
</groups>
|
65 |
+
</enviei>
|
66 |
+
</sections>
|
67 |
+
</config>
|
app/etc/modules/Inovarti_Enviei.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<config>
|
2 |
+
<modules>
|
3 |
+
<Inovarti_Enviei>
|
4 |
+
<active>true</active>
|
5 |
+
<codePool>community</codePool>
|
6 |
+
</Inovarti_Enviei>
|
7 |
+
</modules>
|
8 |
+
</config>
|
app/locale/pt_BR/Inovarti_Enviei.csv
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"General","Geral"
|
2 |
+
"Initial Order Number","Número do Pedido Inicial"
|
3 |
+
"Address Fields","Campos do Endereço"
|
4 |
+
"Address","Endereço"
|
5 |
+
"Number","Número"
|
6 |
+
"More","Complemento"
|
7 |
+
"Empty","Vazio"
|
8 |
+
"Street Line %s","Linha %s do endereço de rua"
|
9 |
+
"Enviei Resource","Enviei"
|
10 |
+
"Order List","Lista de Pedidos com Envío"
|
package.xml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Inovarti_Enviei</name>
|
4 |
+
<version>0.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>Inovarti License</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>API para integrar com Enviei</summary>
|
10 |
+
<description>http://enviei.com</description>
|
11 |
+
<notes>Versão 0.1.0
|
12 |
+
- listando todos os pedidos</notes>
|
13 |
+
<authors><author><name>Inovarti</name><user>Inovarti</user><email>suporte@inovarti.com.br</email></author></authors>
|
14 |
+
<date>2014-08-29</date>
|
15 |
+
<time>17:15:34</time>
|
16 |
+
<contents><target name="magecommunity"><dir name="Inovarti"><dir name="Enviei"><dir name="Helper"><file name="Data.php" hash="34d29a32681b28fd3aa8053cba92933a"/></dir><dir name="Model"><file name="Api.php" hash="d027bbdee89e608f6bdff1f05a4734df"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Line.php" hash="9411767e4ab94f4e53994dba26f4f4a4"/></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="429bc53e264dc7597a7e5c208698082f"/><file name="api.xml" hash="7f4ac8aabd6d4bae51cdc80daa825c1c"/><file name="config.xml" hash="e0e7d6235ba172c9ce80c1a956292b6e"/><file name="system.xml" hash="87da435ef7683f9ae18d7d623880d4ef"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Inovarti_Enviei.xml" hash="938ef18b66c9d05e6ab02f32f3d5787a"/></dir></target><target name="magelocale"><dir><dir name="pt_BR"><file name="Inovarti_Enviei.csv" hash="aa78274d9766cd1dc7998336f82fec6e"/></dir></dir></target></contents>
|
17 |
+
<compatible/>
|
18 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
+
</package>
|