appterra_1234 - Version 0.1.0

Version Notes

XML messages from EDI transactions are parsed and submitted as orders in Magento. Alternatively, Appterra can connect additional document types to your account for Orders, Acknowledgements, Advance Shipping Notices and Invoices (requires separate service from Appterra)

Download this release

Release Info

Developer appterra
Extension appterra_1234
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/local/Rip/Learning/Block/Adminhtml/Learning.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Rip_Learning_Block_Adminhtml_Learning extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+
7
+ $this->_controller = 'adminhtml_learning';
8
+ $this->_blockGroup = 'learning';
9
+ $this->_headerText = Mage::helper('learning')->__('Work Under Process');
10
+ $this->_addButtonLabel = Mage::helper('learning')->__('Add Item');
11
+ parent::__construct();
12
+ }
13
+ }
14
+
15
+
16
+
17
+
app/code/local/Rip/Learning/Block/Adminhtml/Learning/Edit.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Rip_Learning_Block_Adminhtml_Learning_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'id';
10
+ $this->_blockGroup = 'learning';
11
+ $this->_controller = 'adminhtml_learning';
12
+
13
+ /* $this->_updateButton('save', 'label', Mage::helper('learning')->__('Save Item'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('learning')->__('Delete Item'));
15
+
16
+ */
17
+
18
+ $this->_removeButton('save');
19
+ $this->_removeButton('back');
20
+ $this->_removeButton('reset');
21
+
22
+
23
+ $this->_addButton('saveandcontinue', array(
24
+ 'label' => Mage::helper('adminhtml')->__('Refresh Data'),
25
+ 'onclick' => "setLocation('{$this->getUrl('*/learning/refresh')}')",
26
+ 'class' => 'save',
27
+ ), -100);
28
+
29
+
30
+
31
+
32
+ }
33
+
34
+ public function getHeaderText()
35
+ {
36
+ if( Mage::registry('learning_data') && Mage::registry('learning_data')->getId() ) {
37
+ return Mage::helper('learning')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('learning_data')->getTitle()));
38
+ } else {
39
+ return Mage::helper('learning')->__('Appterra');
40
+ }
41
+ }
42
+ }
app/code/local/Rip/Learning/Block/Adminhtml/Learning/Edit/Form.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Rip_Learning_Block_Adminhtml_Learning_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ )
12
+ );
13
+
14
+ $form->setUseContainer(true);
15
+ $this->setForm($form);
16
+ return parent::_prepareForm();
17
+ }
18
+ }
app/code/local/Rip/Learning/Block/Adminhtml/Learning/Edit/Tab/Form.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Rip_Learning_Block_Adminhtml_Learning_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+
6
+
7
+ protected function _prepareForm()
8
+ {
9
+
10
+ $form = new Varien_Data_Form(
11
+ array(
12
+ 'id' => 'edit_form',
13
+ 'action' => $this->getUrl('*/*/save' , array('id' => $this->getRequest()->getParam('id'))),
14
+ 'method' => 'post',
15
+ )
16
+
17
+
18
+ );
19
+
20
+
21
+
22
+
23
+
24
+ $fieldset = $form->addFieldset('learning_form', array('legend'=>Mage::helper('learning')->__('Enter Ftp Detail')));
25
+
26
+ $model = Mage::getModel('learning/learning')->load(1);
27
+ $link = $model->getHost();
28
+ $username = $model->getUsername();
29
+ $password = $model->getPassword();
30
+ $filename = $model->getFilename();
31
+
32
+ $fieldset->addField('host', 'text', array(
33
+ 'label' => Mage::helper('learning')->__('FTP Host'),
34
+ 'class' => 'required-entry',
35
+ 'required' => true,
36
+ 'value' => $link,
37
+ 'name' => 'Host',
38
+ ));
39
+
40
+
41
+ $fieldset->addField('username', 'text', array(
42
+ 'label' => Mage::helper('learning')->__('FTP Username'),
43
+ 'class' => 'required-entry',
44
+ 'required' => true,
45
+ 'value' => $username,
46
+ 'name' => 'Username',
47
+ ));
48
+
49
+
50
+ $fieldset->addField('password', 'password', array(
51
+ 'label' => Mage::helper('learning')->__('FTP Password'),
52
+ 'class' => 'required-entry',
53
+ 'required' => true,
54
+ 'value' => $password,
55
+ 'name' => 'Password',
56
+ ));
57
+
58
+
59
+ $fieldset->addField('filename', 'text', array(
60
+ 'label' => Mage::helper('learning')->__('File Path'),
61
+ 'class' => 'required-entry',
62
+ 'required' => true,
63
+ 'value' => $filename,
64
+ 'name' => 'Filename',
65
+ 'after_element_html' => '</br>Note : <small>Strictly recommend to use the file path as (public_html/...)</small>',
66
+ ));
67
+
68
+
69
+
70
+
71
+ $fieldset->addField('submit', 'submit', array(
72
+ 'value' => 'Submit',
73
+ 'after_element_html' => '<small></small>',
74
+ 'onclick' => "setLocation('{$this->getUrl('*/learning/save')}')",
75
+ 'class' => 'form-button',
76
+ 'tabindex' => 2
77
+ ));
78
+
79
+
80
+
81
+ if ( Mage::getSingleton('adminhtml/session')->getlearningData() )
82
+ {
83
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getlearningData());
84
+ Mage::getSingleton('adminhtml/session')->setlearningData(null);
85
+ } elseif ( Mage::registry('learning_data') ) {
86
+ $form->setValues(Mage::registry('learning_data')->getData());
87
+ }
88
+
89
+
90
+ $form->setUseContainer(true);
91
+ $this->setForm($form);
92
+
93
+
94
+ return parent::_prepareForm();
95
+ }
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+ }
app/code/local/Rip/Learning/Block/Adminhtml/Learning/Edit/Tabs.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Rip_Learning_Block_Adminhtml_Learning_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('learning_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('learning')->__('News Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('learning')->__('Item Information'),
18
+ 'title' => Mage::helper('learning')->__('Item Information'),
19
+ 'content' => $this->getLayout()->createBlock('learning/adminhtml_learning_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/local/Rip/Learning/Block/Adminhtml/Learning/Grid.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Rip_Learning_Block_Adminhtml_Learning_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('learning_Grid');
9
+ // This is the primary key of the database
10
+ $this->setDefaultSort('apptera_id');
11
+ $this->setDefaultDir('ASC');
12
+ $this->setSaveParametersInSession(true);
13
+ $this->setUseAjax(true);
14
+ }
15
+
16
+ protected function _prepareCollection()
17
+ {
18
+ $collection = Mage::getModel('learning/learning')->getCollection();
19
+ $this->setCollection($collection);
20
+ return parent::_prepareCollection();
21
+ }
22
+
23
+ protected function _prepareColumns()
24
+ {
25
+ $this->addColumn('apptera_id', array(
26
+ 'header' => Mage::helper('learning')->__('ID'),
27
+ 'align' =>'right',
28
+ 'width' => '50px',
29
+ 'index' => 'apptera_id',
30
+ ));
31
+
32
+ $this->addColumn('link', array(
33
+ 'header' => Mage::helper('learning')->__('Link'),
34
+ 'align' =>'left',
35
+ 'index' => 'link',
36
+ ));
37
+
38
+ /*
39
+ $this->addColumn('content', array(
40
+ 'header' => Mage::helper('<module>')->__('Item Content'),
41
+ 'width' => '150px',
42
+ 'index' => 'content',
43
+ ));
44
+ */
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+ return parent::_prepareColumns();
54
+ }
55
+
56
+ public function getRowUrl($row)
57
+ {
58
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
59
+ }
60
+
61
+ public function getGridUrl()
62
+ {
63
+ return $this->getUrl('*/*/grid', array('_current'=>true));
64
+ }
65
+
66
+
67
+ }
app/code/local/Rip/Learning/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class Rip_Learning_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+
5
+
6
+ }
app/code/local/Rip/Learning/Model/Learning.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Rip_Learning_Model_Learning extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ //parent::_construct();
8
+ $this->_init('learning/learning');
9
+ }
10
+ }
app/code/local/Rip/Learning/Model/Resource/Learning.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Rip_Learning_Model_Resource_Learning extends Mage_Core_Model_Resource_Db_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('learning/learning', 'apptera_id');
8
+ }
9
+ }
app/code/local/Rip/Learning/Model/Resource/Learning/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Rip_Learning_Model_Resource_Learning_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('learning/learning');
9
+ }
10
+ }
app/code/local/Rip/Learning/Model/Resource/Setup.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Rip_Learning_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {
4
+
5
+ }
6
+
7
+
8
+ ?>
app/code/local/Rip/Learning/controllers/Adminhtml/LearningController.php ADDED
@@ -0,0 +1,524 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Rip_Learning_Adminhtml_LearningController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+
5
+
6
+
7
+ protected function _initAction()
8
+ {
9
+ $this->loadLayout()
10
+ ->_setActiveMenu('rip_learning')
11
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
12
+ return $this;
13
+ }
14
+
15
+ public function indexAction() {
16
+
17
+ $this->_initAction();
18
+ $this->_addContent($this->getLayout()->createBlock('learning/adminhtml_learning_edit'));
19
+
20
+
21
+ $this->_addContent($this->getLayout()->createBlock('learning/adminhtml_learning_edit_tab_form'));
22
+
23
+
24
+ /* $this->getResponse()->setBody(
25
+ $this->getLayout()->createBlock('learning/adminhtml_learning_grid')->toHtml());
26
+
27
+ */
28
+ $this->renderLayout();
29
+
30
+
31
+
32
+ }
33
+
34
+
35
+ public function refreshAction()
36
+ {
37
+
38
+ //calling ftp==========================================================================================
39
+
40
+ $model = Mage::getModel('learning/learning')->load(1);
41
+ $link = $model->getHost();
42
+ $username = $model->getUsername();
43
+ $password = $model->getPassword();
44
+ $filename = $model->getFilename();
45
+
46
+ //echo $username;
47
+ $url_test = Mage::getStoreConfig(Mage_Core_Model_Url::XML_PATH_SECURE_URL);
48
+ $url = Mage::getBaseUrl();
49
+
50
+
51
+ $remote_file = $filename;
52
+ $ftp_host = $link;
53
+ $ftp_user_name = $username.'@'.$link;
54
+ $ftp_user_pass = $password;
55
+
56
+ $local_file = 'consta.xml';
57
+ $connect_it = ftp_connect( $ftp_host )or die("Couldn't connect to $ftp_server");
58
+
59
+ $login_result = ftp_login( $connect_it, $ftp_user_name, $ftp_user_pass );
60
+
61
+ if ( ftp_get( $connect_it, $local_file, $remote_file, FTP_BINARY ) ) {
62
+ //echo "WOOT! Successfully written to $local_file\n";
63
+ }
64
+ else {
65
+ // echo "Doh! There was a problem\n";
66
+ }
67
+
68
+ ftp_close( $connect_it );
69
+
70
+
71
+
72
+ function call($sku)
73
+ {
74
+ $url = Mage::getBaseUrl();
75
+ $proxy = new SoapClient($url.'api/v2_soap/?wsdl'); // TODO : change url
76
+ $sessionId = $proxy->login('admmin', 'main12354'); // TODO : change login and pwd if necessary
77
+
78
+ $resultp = $proxy->catalogProductList($sessionId);
79
+ //echo"<pre>";
80
+ //print_r($resultp);
81
+ foreach($resultp as $key => $value1)
82
+ {
83
+ $product_sku=$value1->sku;
84
+ //echo"prosku-".$key."<br>";
85
+
86
+ if($sku == $product_sku)
87
+ {
88
+ $data = 1;
89
+ $prokey=$key;
90
+ break;
91
+ }
92
+ else
93
+ {
94
+ $data = 0;
95
+
96
+ }
97
+ }
98
+ //return $data;
99
+ return array('keyp' => $prokey, 'datap' => $data);
100
+ }
101
+
102
+
103
+ function customer_call($email)
104
+ {
105
+ $url = Mage::getBaseUrl();
106
+ $proxy = new SoapClient($url.'api/v2_soap/?wsdl'); // TODO : change url
107
+ $sessionId = $proxy->login('admmin', 'main12354'); // TODO : change login and pwd if necessary
108
+
109
+ $result_cust = $proxy->customerCustomerList($sessionId);
110
+ //echo"<pre>";
111
+ //print_r($result_cust);
112
+
113
+ foreach($result_cust as $key2 => $custemail)
114
+ {
115
+ $ct_email=$custemail->email;
116
+
117
+ if($email == $ct_email)
118
+ {
119
+ $datac = 1;
120
+ $cus_key=$key2;
121
+ break;
122
+ }
123
+ else
124
+ {
125
+ $datac = 0;
126
+
127
+ }
128
+ }
129
+ //return $datac;
130
+ return array('key' => $cus_key, 'data' => $datac);
131
+ }
132
+
133
+
134
+ $client = new SoapClient($url.'api/v2_soap/?wsdl');
135
+
136
+ // If some stuff requires api authentification,
137
+ // then get a session token
138
+ $apiuser='admmin';
139
+ $apikey='main12354';
140
+
141
+ $session = $client->login($apiuser, $apikey);
142
+
143
+ $headers = array(
144
+ "Content-type: application/atom+xml"
145
+ );
146
+ $curl = curl_init();
147
+ curl_setopt($curl, CURLOPT_URL, "".$url_test."consta.xml");
148
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
149
+ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
150
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
151
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
152
+ $info = curl_getinfo($curl);
153
+ $response = curl_exec($curl);
154
+ //print_r($response);
155
+
156
+ $responseDoc = new DOMDocument();
157
+ $responseDoc->loadXML($response);
158
+
159
+ $response = simplexml_import_dom($responseDoc);
160
+ //print_r($info);
161
+ //echo "<pre>";
162
+ //print_r($response);
163
+ //echo "</pre>";
164
+
165
+ $sales=$response->SalesOrder;
166
+ //print_r($sales);
167
+
168
+ foreach($sales as $ss)
169
+ {
170
+ //print_r($ss);
171
+
172
+ $order_id=$ss->OrderId;
173
+ //echo "<br>order-".$order_id;
174
+ $FirstName=$ss->BillingAddress->FirstName;
175
+ $LasttName=$ss->BillingAddress->LasttName;
176
+ $Street=$ss->BillingAddress->Street;
177
+ $City=$ss->BillingAddress->City;
178
+ $Country=$ss->BillingAddress->Country;
179
+ $State_Province=$ss->BillingAddress->State_Province;
180
+ $Zip=$ss->BillingAddress->Zip;
181
+ $Telephone=$ss->BillingAddress->Telephone;
182
+
183
+ $FirstNames=$ss->ShippingAddress->FirstName;
184
+ $LasttNames=$ss->ShippingAddress->LasttName;
185
+ $Streets=$ss->ShippingAddress->Street;
186
+ $Citys=$ss->ShippingAddress->City;
187
+ $Countrys=$ss->ShippingAddress->Country;
188
+ $State_Provinces=$ss->ShippingAddress->State_Province;
189
+ $Zips=$ss->ShippingAddress->Zip;
190
+ $Telephones=$ss->ShippingAddress->Telephone;
191
+
192
+ $product=$ss->Lines->Item;
193
+
194
+ //print_r($resultp);
195
+
196
+ foreach($product as $value)
197
+ {
198
+ $ProductId=$value->ProductId;
199
+ $ProductName=$value->ProductName;
200
+ $ProductSku=$value->ProductSku;
201
+ $Quantity=$value->Quantity;
202
+ $UnitPrice=$value->UnitPrice;
203
+ $weight=$value->weight;
204
+ $Description=$value->Description;
205
+ $ShortDescription=$value->ShortDescription;
206
+
207
+ //echo"Appterra sku-".$ProductSku."<br>";
208
+ // get attribute set
209
+ $pro_result=call($ProductSku);
210
+ $datap=$pro_result['datap'];
211
+ //echo"result-".$datap."<br>";
212
+ if($datap==0)
213
+ {
214
+
215
+ $client = new SoapClient($url.'api/v2_soap/?wsdl');
216
+ $apiuser='admmin';
217
+ $apikey='main12354';
218
+
219
+ $session = $client->login($apiuser, $apikey);
220
+
221
+ $attributeSets = $client->catalogProductAttributeSetList($session);
222
+ $attributeSet = current($attributeSets);
223
+
224
+ $result1 = $client->catalogProductCreate($session, 'simple', $attributeSet->set_id, $ProductSku, array(
225
+ 'name' => $ProductName,
226
+ 'description' => $Description,
227
+ 'short_description' => $ShortDescription,
228
+ 'weight' => $weight,
229
+ 'status' => '1',
230
+ 'visibility' => '4',
231
+ 'price' => $UnitPrice,
232
+ 'tax_class_id' => 1
233
+ ));
234
+
235
+ //echo"<pre>";
236
+ //print_r($result1);
237
+
238
+
239
+
240
+ $proxy = new SoapClient($url.'api/v2_soap/?wsdl');
241
+ $sessionId = $proxy->login('admmin','main12354');
242
+
243
+ $result = $proxy->catalogInventoryStockItemUpdate($sessionId, ''.$ProductSku.'', array(
244
+ 'qty' => '100',
245
+ 'is_in_stock' => 1
246
+ ));
247
+
248
+ //print_r($result);
249
+
250
+ }
251
+
252
+
253
+ }
254
+ $BuyerFirstName=$ss->BuyerFirstName;
255
+ //echo"<br>".$BuyerFirstName;
256
+ $BuyerLasttName=$ss->BuyerLasttName;
257
+ $BuyerEmail=$ss->BuyerEmail;
258
+
259
+ $buyer_email=customer_call($BuyerEmail);
260
+ $datacus=$buyer_email['data'];
261
+ //echo"resultc-".$datacus."<br>";
262
+ if($datacus == 0)
263
+ {
264
+
265
+ $result = $client->customerCustomerCreate($session, array('email' => $BuyerEmail, 'firstname' => $BuyerFirstName, 'lastname' => $BuyerLasttName, 'password' => 'password', 'website_id' => 1, 'store_id' => 1, 'group_id' => 1));
266
+ //var_dump ($session);
267
+ //echo"<pre>";
268
+ //print_r($result);
269
+ //echo"</pre>";
270
+ }
271
+
272
+ }
273
+
274
+ //create order
275
+ foreach($sales as $ss)
276
+ {
277
+
278
+ $BuyerFirstName=$ss->BuyerFirstName;
279
+ //echo"<br>".$BuyerFirstName;
280
+ $BuyerLasttName=$ss->BuyerLasttName;
281
+ $BuyerEmail=$ss->BuyerEmail;
282
+ $user = $apiuser;
283
+ $password = $apikey;
284
+ $proxy = new SoapClient($url.'api/v2_soap/?wsdl');
285
+ $sessionId = $proxy->login($user, $password);
286
+ $cartId = $proxy->shoppingCartCreate($sessionId, 1);
287
+ // load the customer list and select the first customer from the list
288
+ $customerList = $proxy->customerCustomerList($sessionId, array());
289
+ //print_r($customerList);
290
+ //$customer = (array) $customerList[2];
291
+ //$customer = end($customerList);
292
+
293
+ $cust_key = customer_call($BuyerEmail);
294
+ $datakey=$cust_key['key'];
295
+
296
+ $customer = (array) $customerList[$datakey];
297
+
298
+ $customer['mode'] = 'customer';
299
+ $proxy->shoppingCartCustomerSet($sessionId, $cartId, $customer);
300
+
301
+ $product=$ss->Lines->Item;
302
+ foreach($product as $value)
303
+ {
304
+ $ProductSku=$value->ProductSku;
305
+ $Quantity=$value->Quantity;
306
+
307
+ $pro_ky=call($ProductSku);
308
+ $datakey=$pro_ky['keyp'];
309
+ $productList = $proxy->catalogProductList($sessionId);
310
+ $product = (array) $productList[$datakey];
311
+ $product['qty'] = $Quantity;
312
+ $proxy->shoppingCartProductAdd($sessionId, $cartId, array($product));
313
+ }
314
+ $address = array(
315
+ array(
316
+ 'mode' => 'shipping',
317
+ 'firstname' => $customer['firstname'],
318
+ 'lastname' => $customer['lastname'],
319
+ 'street' => 'street address',
320
+ 'city' => 'city',
321
+ 'region' => 'region',
322
+ 'telephone' => 'phone number',
323
+ 'postcode' => 'postcode',
324
+ 'country_id' => 'country ID',
325
+ 'is_default_shipping' => 0,
326
+ 'is_default_billing' => 0
327
+ ),
328
+ array(
329
+ 'mode' => 'billing',
330
+ 'firstname' => $customer['firstname'],
331
+ 'lastname' => $customer['lastname'],
332
+ 'street' => 'street address',
333
+ 'city' => 'city',
334
+ 'region' => 'region',
335
+ 'telephone' => 'phone number',
336
+ 'postcode' => 'postcode',
337
+ 'country_id' => 'country ID',
338
+ 'is_default_shipping' => 0,
339
+ 'is_default_billing' => 0
340
+ ),
341
+ );
342
+ // add customer address
343
+ $proxy->shoppingCartCustomerAddresses($sessionId, $cartId, $address);
344
+ // add shipping method
345
+ $proxy->shoppingCartShippingMethod($sessionId, $cartId, 'flatrate_flatrate');
346
+
347
+ $paymentMethod = array(
348
+ 'po_number' => null,
349
+ 'method' => 'checkmo',
350
+ 'cc_cid' => null,
351
+ 'cc_owner' => null,
352
+ 'cc_number' => null,
353
+ 'cc_type' => null,
354
+ 'cc_exp_year' => null,
355
+ 'cc_exp_month' => null
356
+ );
357
+ // add payment method
358
+ $proxy->shoppingCartPaymentMethod($sessionId, $cartId, $paymentMethod);
359
+ // place the order
360
+ $orderId = $proxy->shoppingCartOrder($sessionId, $cartId,null,null);
361
+ //print_r($orderId);
362
+ }
363
+
364
+
365
+
366
+
367
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Purchase order successfully imported'));
368
+
369
+
370
+
371
+ $this->_forward('index');
372
+
373
+ }
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+
383
+ public function editAction()
384
+ {
385
+
386
+
387
+ $learningId = $this->getRequest()->getParam('id');
388
+ $learningModel = Mage::getModel('learning/learning')->load($learningId);
389
+
390
+ if ($learningModel->getId() || $learningId == 0) {
391
+
392
+ Mage::register('learning_data', $learningModel);
393
+
394
+ $this->loadLayout();
395
+ $this->_setActiveMenu('learning/items');
396
+
397
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
398
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
399
+
400
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
401
+
402
+ $this->_addContent($this->getLayout()->createBlock('learning/adminhtml_learning_edit'))
403
+ ->_addLeft($this->getLayout()->createBlock('learning/adminhtml_learning_edit_tabs'));
404
+
405
+ $this->renderLayout();
406
+ } else {
407
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('learning')->__('Item does not exist'));
408
+ $this->_redirect('*/*/');
409
+ }
410
+ }
411
+
412
+ public function newAction()
413
+ {
414
+ $this->_forward('edit');
415
+ }
416
+
417
+
418
+
419
+
420
+ public function saveAction()
421
+ {
422
+
423
+
424
+
425
+
426
+ if ( $this->getRequest()->getPost() ) {
427
+ try {
428
+
429
+ $postData = $this->getRequest()->getPost();
430
+
431
+
432
+ if($postData['Host'] and $postData['Username'] and $postData['Password'] and $postData['Filename']!=''){
433
+
434
+ /*
435
+ $learningModel = Mage::getModel('learning/learning')->load($this->getRequest()->getParam('id'));
436
+
437
+ $learningModel->setLink($postData['Link'])
438
+
439
+ ->save();
440
+ */
441
+
442
+ $id = 1;
443
+ echo "<script>alert('".$postData['Host']."');</script>";
444
+
445
+ $arrcustData = array('host'=>$postData['Host'],'username'=>$postData['Username'],'password'=>$postData['Password'],'filename'=>$postData['Filename']);
446
+
447
+ $model = Mage::getModel('learning/learning')->load($id)->addData($arrcustData );
448
+
449
+ $model->setId($id)->save();
450
+
451
+
452
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('FTP Details was successfully saved'));
453
+ Mage::getSingleton('adminhtml/session')->setlearningData(false);
454
+
455
+ }
456
+
457
+
458
+ else {
459
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('learning')->__('Invalid Input'));
460
+
461
+ }
462
+
463
+
464
+
465
+ $this->_redirect('*/*/');
466
+ return;
467
+ } catch (Exception $e) {
468
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
469
+ Mage::getSingleton('adminhtml/session')->setlearningData($this->getRequest()->getPost());
470
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
471
+ return;
472
+ }
473
+ }
474
+ $this->_redirect('*/*/');
475
+
476
+
477
+
478
+
479
+
480
+
481
+
482
+
483
+ }
484
+
485
+ public function deleteAction()
486
+ {
487
+ if( $this->getRequest()->getParam('id') > 0 ) {
488
+ try {
489
+ $learningModel = Mage::getModel('learning/learning');
490
+
491
+ $learningModel->setId($this->getRequest()->getParam('id'))
492
+ ->delete();
493
+
494
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
495
+ $this->_redirect('*/*/');
496
+ } catch (Exception $e) {
497
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
498
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
499
+ }
500
+ }
501
+ $this->_redirect('*/*/');
502
+ }
503
+ /**
504
+ * Product grid for AJAX request.
505
+ * Sort and filter result for example.
506
+ */
507
+ public function gridAction()
508
+ {
509
+ $this->loadLayout();
510
+ $this->getResponse()->setBody(
511
+ $this->getLayout()->createBlock('learning/adminhtml_learning_grid')->toHtml()
512
+ );
513
+ }
514
+
515
+
516
+
517
+
518
+
519
+
520
+
521
+
522
+
523
+
524
+ }
app/code/local/Rip/Learning/etc/adminhtml.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <menu>
4
+ <rip_learning module="learning" translate="title">
5
+ <title>Appterra</title>
6
+ <sort_order>100</sort_order>
7
+ <action>*/learning</action>
8
+ </rip_learning>
9
+
10
+
11
+
12
+ </menu>
13
+
14
+ <layout>
15
+ <updates>
16
+ <learning>
17
+ <file>learning.xml</file>
18
+ </learning>
19
+ </updates>
20
+ </layout>
21
+
22
+ </config>
23
+
24
+
25
+
app/code/local/Rip/Learning/etc/config.xml ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Rip_Learning>
5
+ <version>0.1.0</version> <!-- Version number of your module -->
6
+ </Rip_Learning>
7
+ </modules>
8
+
9
+ <frontend>
10
+ <routers>
11
+ <mymodule>
12
+ <use>admin</use>
13
+ <args>
14
+ <module>Rip_Learning</module>
15
+ <frontName>testmodule</frontName>
16
+ </args>
17
+ </mymodule>
18
+ </routers>
19
+ </frontend>
20
+
21
+ <global>
22
+
23
+
24
+
25
+ <helpers>
26
+ <learning>
27
+ <class>Rip_Learning_Helper</class>
28
+ </learning>
29
+ </helpers>
30
+
31
+ <blocks>
32
+ <learning>
33
+ <class>Rip_Learning_Block</class>
34
+ </learning>
35
+ </blocks>
36
+
37
+ <models>
38
+ <learning>
39
+ <class>Rip_Learning_Model</class>
40
+ <resourceModel>learning_resource</resourceModel>
41
+ </learning>
42
+
43
+ <learning_resource>
44
+ <class>Rip_Learning_Model_Resource</class>
45
+ <entities>
46
+ <learning>
47
+ <table>learning</table>
48
+ </learning>
49
+ </entities>
50
+ </learning_resource>
51
+ </models>
52
+
53
+
54
+ <resources>
55
+ <learning_setup>
56
+ <setup>
57
+ <module>Rip_Learning</module>
58
+ <class>Rip_Learning_Model_Resource_Setup</class>
59
+ </setup>
60
+ <connection>
61
+ <use>core_setup</use>
62
+ </connection>
63
+ </learning_setup>
64
+
65
+
66
+
67
+
68
+
69
+ <learning_write>
70
+ <connection>
71
+ <use>core_write</use>
72
+ </connection>
73
+ </learning_write>
74
+ <learning_read>
75
+ <connection>
76
+ <use>core_read</use>
77
+ </connection>
78
+ </learning_read>
79
+ </resources>
80
+
81
+
82
+
83
+ </global>
84
+
85
+
86
+
87
+
88
+
89
+
90
+ <admin>
91
+ <routers>
92
+ <adminhtml>
93
+ <args>
94
+ <modules>
95
+ <rip_learning before="Mage_Adminhtml">Rip_Learning_Adminhtml</rip_learning>
96
+ </modules>
97
+ </args>
98
+ </adminhtml>
99
+ </routers>
100
+ </admin>
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+ </config>
app/code/local/Rip/Learning/sql/learning_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+ $installer->run("CREATE TABLE IF NOT EXISTS `{$this->getTable('learning')}` (
5
+ `apptera_id` int(255) NOT NULL,
6
+ `host` varchar(2000) NOT NULL,
7
+ `username` varchar(1000) NOT NULL,
8
+ `password` varchar(200) NOT NULL,
9
+ `filename` varchar(300) NOT NULL
10
+ ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
11
+
12
+ ALTER TABLE `{$this->getTable('learning')}`
13
+ ADD PRIMARY KEY (`apptera_id`);
14
+
15
+ ALTER TABLE `{$this->getTable('learning')}`
16
+ MODIFY `apptera_id` int(255) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1;
17
+
18
+
19
+ INSERT INTO `{$this->getTable('learning')}` (host, username, password, filename) values ('Your host will be here', 'FTP Username', 'FTP Password', 'Filepath');");
20
+
21
+
22
+
23
+
24
+
25
+ /**
26
+ $installer->run("
27
+  CREATE TABLE `{$this->getTable('learning/learning')}` (
28
+   `apptera_id` int(11) unsigned NOT NULL auto_increment,
29
+   `host` varchar(2000) NOT NULL,
30
+ `username` varchar(1000) NOT NULL,
31
+ `password` varchar(200) NOT NULL,
32
+ `filename` varchar(300) NOT NULL
33
+   PRIMARY KEY (`apptera_id`)
34
+  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
35
+  
36
+ INSERT INTO `{$this->getTable('learning/learning')}` (host, username, password, filename) values ('Your host will be here', 'username', 'password', 'filename');
37
+ ");
38
+ **/
39
+ $installer->endSetup();
40
+ ?>
app/design/adminhtml/default/default/layout/learning.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <learning_adminhtml_learning_index>
4
+ <reference name="content">
5
+ <block type="learning/adminhtml_learning" name="learning" />
6
+ </reference>
7
+ </learning_adminhtml_learning_index>
8
+
9
+
10
+ <adminhtml_learning_grid>
11
+ <reference name="root">
12
+ <block type="learning/adminhtml_learning_grid" name="root" output="toHtml"/>
13
+ </reference>
14
+ </adminhtml_learning_grid>
15
+
16
+
17
+ </layout>
app/etc/modules/Rip_Learning.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Rip_Learning>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Rip_Learning>
8
+ </modules>
9
+ </config>
10
+
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>appterra_1234</name>
4
+ <version>0.1.0</version>
5
+ <stability>devel</stability>
6
+ <license>Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary> EZEDI for Magento provides seamless connectivity of EDI orders as orders into Magento</summary>
10
+ <description>XML messages from EDI transactions are parsed and submitted as orders in Magento. Alternatively, Appterra can connect additional document types to your account for Orders, Acknowledgements, Advance Shipping Notices and Invoices (requires separate service from Appterra)</description>
11
+ <notes>XML messages from EDI transactions are parsed and submitted as orders in Magento. Alternatively, Appterra can connect additional document types to your account for Orders, Acknowledgements, Advance Shipping Notices and Invoices (requires separate service from Appterra)</notes>
12
+ <authors><author><name>appterra</name><user>appterra</user><email>shubham.vajpayee@appterra.net</email></author></authors>
13
+ <date>2016-04-02</date>
14
+ <time>09:25:52</time>
15
+ <contents><target name="magelocal"><dir name="Rip"><dir name="Learning"><dir name="Block"><dir name="Adminhtml"><dir name="Learning"><dir name="Edit"><file name="Form.php" hash="bba6a578f8ea0a2a539c54fa7e63edc0"/><dir name="Tab"><file name="Form.php" hash="23548a538a35c0050d3b2a35412054b0"/></dir><file name="Tabs.php" hash="d2ea55af76e5e99f5b73554d322c8aef"/></dir><file name="Edit.php" hash="62f345d698658e27a9d6e2112cca7647"/><file name="Grid.php" hash="bc32d0b8503134c67535c145ea9efa37"/></dir><file name="Learning.php" hash="de983d8781e605623f1e91b1e2e93a58"/></dir></dir><dir name="Helper"><file name="Data.php" hash="17620df4dc7e07fd295abdefb71b1dc0"/></dir><dir name="Model"><file name="Learning.php" hash="8e69de616195d5f56f7111507a9c696c"/><dir name="Resource"><dir name="Learning"><file name="Collection.php" hash="2fe01f0f0df15b50e07969ce67cf8852"/></dir><file name="Learning.php" hash="d16c00a9d36176896eccb18303631496"/><file name="Setup.php" hash="69b7bfb9890ca4764c6f4115ad2bd2ab"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="LearningController.php" hash="0c4bf441bb7d173f43e6b33fb09addd3"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="4ad657ca86e83637a7142a458755345f"/><file name="config.xml" hash="fe79c7a695c8f279d3ecf6dc706ae493"/></dir><dir name="sql"><dir name="learning_setup"><file name="mysql4-install-0.1.0.php" hash="16471de0f88b873b72209a53de4867c6"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Rip_Learning.xml" hash="3f9bc52128f33cbecfeabe2bf5fc0449"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="learning.xml" hash="f057c10a762b945d507135cb1463fb0b"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>4.0.0</min><max>7.0.0</max></php></required></dependencies>
18
+ </package>