Version Notes
This is a plugin for Magento 1.8 - 1.9 that provides integration with the Fruugo products and orders API.
Download this release
Release Info
Developer | inoutput.io |
Extension | Fruugo_Integration |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Fruugo/Integration/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/.gitignore +1 -0
- app/code/community/Fruugo/Integration/Block/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/Block/Catalog/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/Block/Catalog/Product/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/Block/Catalog/Product/Tab.php +100 -0
- app/code/community/Fruugo/Integration/Block/Refreshcountriesbutton.php +39 -0
- app/code/community/Fruugo/Integration/Block/Sales/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/Block/Sales/Order/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/Block/Sales/Order/View/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/Block/Sales/Order/View/Tabs.php +96 -0
- app/code/community/Fruugo/Integration/Helper/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/Helper/ConfigLoader.php +44 -0
- app/code/community/Fruugo/Integration/Helper/Data.php +26 -0
- app/code/community/Fruugo/Integration/Helper/Defines.php +28 -0
- app/code/community/Fruugo/Integration/Helper/FruugoCountriesSeeder.php +72 -0
- app/code/community/Fruugo/Integration/Helper/Logger.php +29 -0
- app/code/community/Fruugo/Integration/Helper/OrdersFeedProcessor.php +340 -0
- app/code/community/Fruugo/Integration/Helper/ProductsFeedGenerator.php +251 -0
- app/code/community/Fruugo/Integration/Model/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/Model/Adminhtml/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/Model/Adminhtml/System/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/Model/Adminhtml/System/Config/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/Model/Adminhtml/System/Config/Backend/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/Model/Adminhtml/System/Config/Backend/OrderCron.php +57 -0
- app/code/community/Fruugo/Integration/Model/Adminhtml/System/Config/Backend/ProductCron.php +57 -0
- app/code/community/Fruugo/Integration/Model/Adminhtml/System/Config/Source/Hour.php +49 -0
- app/code/community/Fruugo/Integration/Model/Adminhtml/System/Config/Source/OrderPaymentMethod.php +46 -0
- app/code/community/Fruugo/Integration/Model/Adminhtml/System/Config/Source/ProductDescriptionType.php +45 -0
- app/code/community/Fruugo/Integration/Model/Countries.php +29 -0
- app/code/community/Fruugo/Integration/Model/CronJobObserver.php +53 -0
- app/code/community/Fruugo/Integration/Model/Observer.php +385 -0
- app/code/community/Fruugo/Integration/Model/Resource/Countries.php +29 -0
- app/code/community/Fruugo/Integration/Model/Resource/Countries/Collection.php +29 -0
- app/code/community/Fruugo/Integration/Model/Resource/Shipment.php +29 -0
- app/code/community/Fruugo/Integration/Model/Resource/Shipment/Collection.php +29 -0
- app/code/community/Fruugo/Integration/Model/Shipment.php +29 -0
- app/code/community/Fruugo/Integration/controllers/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/controllers/.gitignore +1 -0
- app/code/community/Fruugo/Integration/controllers/OrdersController.php +47 -0
- app/code/community/Fruugo/Integration/controllers/PackinglistController.php +77 -0
- app/code/community/Fruugo/Integration/controllers/ProductsController.php +114 -0
- app/code/community/Fruugo/Integration/data/fruugo_attributes_setup/data-install-0.1.1.php +65 -0
- app/code/community/Fruugo/Integration/design/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/design/adminhtml/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/design/adminhtml/default/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/design/adminhtml/default/default/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/design/adminhtml/default/default/layout/integration.xml +41 -0
- app/code/community/Fruugo/Integration/design/adminhtml/default/default/template/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/design/adminhtml/default/default/template/integration/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/design/adminhtml/default/default/template/integration/catalog/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/design/adminhtml/default/default/template/integration/catalog/product/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/design/adminhtml/default/default/template/integration/catalog/product/fruugo-allowed-countries.phtml +37 -0
- app/code/community/Fruugo/Integration/design/adminhtml/default/default/template/integration/sales/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/design/adminhtml/default/default/template/integration/sales/order/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/design/adminhtml/default/default/template/integration/sales/order/view/.DS_Store +0 -0
- app/code/community/Fruugo/Integration/design/adminhtml/default/default/template/integration/sales/order/view/tab/packinglist.phtml +49 -0
- app/code/community/Fruugo/Integration/etc/config.xml +161 -0
- app/code/community/Fruugo/Integration/etc/system.xml +164 -0
- app/code/community/Fruugo/Integration/sql/fruugo_attributes_setup/install-0.1.1.php +119 -0
- app/design/adminhtml/default/default/layout/integration.xml +41 -0
- app/design/adminhtml/default/default/template/integration/.DS_Store +0 -0
- app/design/adminhtml/default/default/template/integration/catalog/.DS_Store +0 -0
- app/design/adminhtml/default/default/template/integration/catalog/product/.DS_Store +0 -0
- app/design/adminhtml/default/default/template/integration/catalog/product/fruugo-allowed-countries.phtml +37 -0
- app/design/adminhtml/default/default/template/integration/sales/.DS_Store +0 -0
- app/design/adminhtml/default/default/template/integration/sales/order/.DS_Store +0 -0
- app/design/adminhtml/default/default/template/integration/sales/order/view/.DS_Store +0 -0
- app/design/adminhtml/default/default/template/integration/sales/order/view/tab/packinglist.phtml +49 -0
- app/etc/modules/Fruugo_Integration.xml +89 -0
- package.xml +24 -0
app/code/community/Fruugo/Integration/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
fruugo_countries.json
|
app/code/community/Fruugo/Integration/Block/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/Block/Catalog/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/Block/Catalog/Product/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/Block/Catalog/Product/Tab.php
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/Defines.php';
|
24 |
+
|
25 |
+
class Fruugo_Integration_Block_Catalog_Product_Tab extends Mage_Adminhtml_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
26 |
+
{
|
27 |
+
protected function _construct()
|
28 |
+
{
|
29 |
+
parent::_construct();
|
30 |
+
$this->setTemplate('integration/catalog/product/fruugo-allowed-countries.phtml');
|
31 |
+
}
|
32 |
+
|
33 |
+
public function getTabLabel()
|
34 |
+
{
|
35 |
+
return $this->__('Countries allowed on Fruugo');
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getTabTitle()
|
39 |
+
{
|
40 |
+
return $this->__('Countries allowed on Fruugo');
|
41 |
+
}
|
42 |
+
|
43 |
+
public function canShowTab()
|
44 |
+
{
|
45 |
+
return true;
|
46 |
+
}
|
47 |
+
|
48 |
+
public function isHidden()
|
49 |
+
{
|
50 |
+
return false;
|
51 |
+
}
|
52 |
+
|
53 |
+
public function getProduct()
|
54 |
+
{
|
55 |
+
return Mage::registry('current_product');
|
56 |
+
}
|
57 |
+
|
58 |
+
public function getCountrySelectForm()
|
59 |
+
{
|
60 |
+
$productId = $this->getProduct()->getId();
|
61 |
+
$actionLink = Mage::getUrl(
|
62 |
+
'integration/products/onCountriesSaved',
|
63 |
+
array('productId' => $productId)
|
64 |
+
);
|
65 |
+
|
66 |
+
$existingProductCountries = Mage::getModel('integration/countries')->load($productId, 'product_id');
|
67 |
+
$existingList = isset($existingProductCountries) ? $existingProductCountries->getFruugoCountries() : '';
|
68 |
+
|
69 |
+
$countryList = array();
|
70 |
+
$fruugoCountriesFilePath = Mage::getModuleDir('', 'Fruugo_Integration') . '/'. Fruugo_Integration_Helper_Defines::FRUUGO_COUNTRIES_FILE_NAME;
|
71 |
+
if (file_exists($fruugoCountriesFilePath)) {
|
72 |
+
$fruugoCountriesJson = file_get_contents($fruugoCountriesFilePath);
|
73 |
+
$countryList = json_decode($fruugoCountriesJson, true);
|
74 |
+
} else {
|
75 |
+
$countryList = Mage::getModel('directory/country')->getResourceCollection()
|
76 |
+
->loadByStore()
|
77 |
+
->toOptionArray(false);
|
78 |
+
}
|
79 |
+
|
80 |
+
$countrySelect = '<select name="allowed-countries[]" id="prd-country-select" multiple>';
|
81 |
+
|
82 |
+
foreach ($countryList as $country) {
|
83 |
+
if (!empty($country['value'])) {
|
84 |
+
if (strpos($existingList, $country['value']) !== false) {
|
85 |
+
$countrySelect .= '<option value="'.$country['value'].'" selected>'.$country['label'].'</option>';
|
86 |
+
} else {
|
87 |
+
$countrySelect .= '<option value="'.$country['value'].'">'.$country['label'].'</option>';
|
88 |
+
}
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
$countrySelect .= '</select>';
|
93 |
+
$countrySelectForm = '<form action="'.$actionLink.'">'
|
94 |
+
.$countrySelect
|
95 |
+
.'<p><input type="checkbox" name="disable-prd-fruugo" value="checked" '. ($existingList == 'Disabled' ? 'checked' : '') .'> Disable this product completely from Fruugo</p>'
|
96 |
+
.'<p><input type="submit" id="restrict-prd-country" /></p></form>';
|
97 |
+
|
98 |
+
return $countrySelectForm;
|
99 |
+
}
|
100 |
+
}
|
app/code/community/Fruugo/Integration/Block/Refreshcountriesbutton.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
class Fruugo_Integration_Block_Refreshcountriesbutton extends Mage_Adminhtml_Block_System_Config_Form_Field
|
24 |
+
{
|
25 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
26 |
+
{
|
27 |
+
$actionLink = Mage::getUrl('integration/products/onCountriesRefreshed');
|
28 |
+
$this->setElement($element);
|
29 |
+
|
30 |
+
$html = $this->getLayout()->createBlock('adminhtml/widget_button')
|
31 |
+
->setType('button')
|
32 |
+
->setClass('scalable')
|
33 |
+
->setLabel('Refresh')
|
34 |
+
->setOnClick("setLocation('$actionLink')")
|
35 |
+
->toHtml();
|
36 |
+
|
37 |
+
return $html;
|
38 |
+
}
|
39 |
+
}
|
app/code/community/Fruugo/Integration/Block/Sales/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/Block/Sales/Order/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/Block/Sales/Order/View/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/Block/Sales/Order/View/Tabs.php
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
class Fruugo_Integration_Block_Sales_Order_View_Tabs extends Mage_Adminhtml_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
24 |
+
{
|
25 |
+
protected function _construct()
|
26 |
+
{
|
27 |
+
parent::_construct();
|
28 |
+
$this->setTemplate('integration/sales/order/view/tab/packinglist.phtml');
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getTabLabel()
|
32 |
+
{
|
33 |
+
return $this->__('Fruugo Order Information');
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getTabTitle()
|
37 |
+
{
|
38 |
+
return $this->__('Fruugo Order Information');
|
39 |
+
}
|
40 |
+
|
41 |
+
public function canShowTab()
|
42 |
+
{
|
43 |
+
$order = $this->getOrder();
|
44 |
+
$fruugoId = $order->getFruugoOrderId();
|
45 |
+
|
46 |
+
if (!empty($fruugoId) && $fruugoId !== null) {
|
47 |
+
return true;
|
48 |
+
}
|
49 |
+
|
50 |
+
return false;
|
51 |
+
}
|
52 |
+
|
53 |
+
public function isHidden()
|
54 |
+
{
|
55 |
+
$order = $this->getOrder();
|
56 |
+
$fruugoId = $order->getFruugoOrderId();
|
57 |
+
|
58 |
+
if (!empty($fruugoId) && $fruugoId !== null) {
|
59 |
+
return false;
|
60 |
+
}
|
61 |
+
|
62 |
+
return true;
|
63 |
+
}
|
64 |
+
|
65 |
+
public function getOrder()
|
66 |
+
{
|
67 |
+
return Mage::registry('current_order');
|
68 |
+
}
|
69 |
+
|
70 |
+
public function isOrderShipped()
|
71 |
+
{
|
72 |
+
$shipmentModel = Mage::getModel('integration/shipment');
|
73 |
+
$shipmentCollection = $shipmentModel->getCollection();
|
74 |
+
if (count($shipmentCollection) > 0) {
|
75 |
+
return true;
|
76 |
+
}
|
77 |
+
|
78 |
+
return false;
|
79 |
+
}
|
80 |
+
|
81 |
+
public function getFruugoOrderId()
|
82 |
+
{
|
83 |
+
return $this->getOrder()->getFruugoOrderId();
|
84 |
+
}
|
85 |
+
|
86 |
+
public function getFruugoShipmentIds()
|
87 |
+
{
|
88 |
+
$shipmentIds = array();
|
89 |
+
$shipmentModel = Mage::getModel('integration/shipment');
|
90 |
+
$shipmentCollection = $shipmentModel->getCollection();
|
91 |
+
foreach ($shipmentCollection as $shipment) {
|
92 |
+
array_push($shipmentIds, $shipment->getShipmentId());
|
93 |
+
}
|
94 |
+
return $shipmentIds;
|
95 |
+
}
|
96 |
+
}
|
app/code/community/Fruugo/Integration/Helper/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/Helper/ConfigLoader.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
class Fruugo_Integration_Helper_ConfigLoader extends Mage_Core_Helper_Abstract
|
24 |
+
{
|
25 |
+
public static function load($path)
|
26 |
+
{
|
27 |
+
$resource = Mage::getSingleton('core/resource');
|
28 |
+
$readConnection = $resource->getConnection('core_read');
|
29 |
+
$table = $resource->getTableName('core/config_data');
|
30 |
+
$query = 'SELECT value FROM ' . $table . ' WHERE path = \'' . $path . '\'';
|
31 |
+
$value = $readConnection->fetchOne($query);
|
32 |
+
|
33 |
+
return $value;
|
34 |
+
}
|
35 |
+
|
36 |
+
public static function save($path, $value)
|
37 |
+
{
|
38 |
+
$resource = Mage::getSingleton('core/resource');
|
39 |
+
$writeConnection = $resource->getConnection('core_write');
|
40 |
+
$table = $resource->getTableName('core/config_data');
|
41 |
+
$query = 'UPDATE ' . $table . ' SET value = \'' . $value . '\' WHERE path = \'' . $path . '\'';
|
42 |
+
$writeConnection->query($query);
|
43 |
+
}
|
44 |
+
}
|
app/code/community/Fruugo/Integration/Helper/Data.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
class Fruugo_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
24 |
+
{
|
25 |
+
|
26 |
+
}
|
app/code/community/Fruugo/Integration/Helper/Defines.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
class Fruugo_Integration_Helper_Defines extends Mage_Core_Helper_Abstract
|
24 |
+
{
|
25 |
+
const FRUUGO_ORDERS_ENDPOINT = 'https://www.fruugo.com/orders';
|
26 |
+
const FRUUGO_COUNTRIES_ENDPOINT = 'http://mintegproxy.fruugo.net/feeds/FruugoCountriesXML.xml';
|
27 |
+
const FRUUGO_COUNTRIES_FILE_NAME = 'fruugo_countries.json';
|
28 |
+
}
|
app/code/community/Fruugo/Integration/Helper/FruugoCountriesSeeder.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/OrdersFeedProcessor.php';
|
24 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/Logger.php';
|
25 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/Defines.php';
|
26 |
+
use \DOMDocument as DOMDocument;
|
27 |
+
use \DOMXpath as DOMXpath;
|
28 |
+
|
29 |
+
class Fruugo_Integration_Helper_FruugoCountriesSeeder extends Mage_Core_Helper_Abstract
|
30 |
+
{
|
31 |
+
public static function getFruugoCountries()
|
32 |
+
{
|
33 |
+
Fruugo_Integration_Helper_Logger::log('Pulling Fruugo countries information');
|
34 |
+
$fruugoCountriesXml = @file_get_contents(Fruugo_Integration_Helper_Defines::FRUUGO_COUNTRIES_ENDPOINT);
|
35 |
+
if ($fruugoCountriesXml !== false) {
|
36 |
+
$doc = new DOMDocument();
|
37 |
+
$doc->loadXML($fruugoCountriesXml);
|
38 |
+
$xpath = new DOMXpath($doc);
|
39 |
+
$countriesXml = $xpath->query('//CountryInfo');
|
40 |
+
$orderFeedProcessor = new Fruugo_Integration_OrdersFeedProcessor();
|
41 |
+
|
42 |
+
$fruugoCountries = array();
|
43 |
+
foreach ($countriesXml as $countryXml) {
|
44 |
+
$countryArray = $orderFeedProcessor->convertXmlToArray($countryXml);
|
45 |
+
$countryName = $countryArray['CountryName'];
|
46 |
+
$countryCode = $countryArray['CountryCode'];
|
47 |
+
|
48 |
+
array_push($fruugoCountries, array(
|
49 |
+
'value' => $countryCode,
|
50 |
+
'label' => $countryName
|
51 |
+
));
|
52 |
+
}
|
53 |
+
|
54 |
+
self::arraySortByColumn($fruugoCountries, 'label');
|
55 |
+
$fruugoCountriesJson = json_encode($fruugoCountries);
|
56 |
+
$path = Mage::getModuleDir('', 'Fruugo_Integration') . '/'. Fruugo_Integration_Helper_Defines::FRUUGO_COUNTRIES_FILE_NAME;
|
57 |
+
file_put_contents($path, $fruugoCountriesJson);
|
58 |
+
} else {
|
59 |
+
Fruugo_Integration_Helper_Logger::log('Failed pulling Fruugo countries information. Either the URL is not valid any more or there was a network error.');
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
private static function arraySortByColumn(&$arr, $col, $dir = SORT_ASC)
|
64 |
+
{
|
65 |
+
$sort_col = array();
|
66 |
+
foreach ($arr as $key => $row) {
|
67 |
+
$sort_col[$key] = $row[$col];
|
68 |
+
}
|
69 |
+
|
70 |
+
array_multisort($sort_col, $dir, $arr);
|
71 |
+
}
|
72 |
+
}
|
app/code/community/Fruugo/Integration/Helper/Logger.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
class Fruugo_Integration_Helper_Logger extends Mage_Core_Helper_Abstract
|
24 |
+
{
|
25 |
+
public static function log($message)
|
26 |
+
{
|
27 |
+
Mage::log("Integration - " . $message);
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Fruugo/Integration/Helper/OrdersFeedProcessor.php
ADDED
@@ -0,0 +1,340 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/Defines.php';
|
24 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/ConfigLoader.php';
|
25 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Model/Observer.php';
|
26 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/Logger.php';
|
27 |
+
|
28 |
+
use \DOMDocument as DOMDocument;
|
29 |
+
use \DOMXpath as DOMXpath;
|
30 |
+
|
31 |
+
class Fruugo_Integration_OrdersFeedProcessor extends Mage_Core_Helper_Abstract
|
32 |
+
{
|
33 |
+
public function processOrders($from = null)
|
34 |
+
{
|
35 |
+
$apiUrl = Fruugo_Integration_Helper_Defines::FRUUGO_ORDERS_ENDPOINT;
|
36 |
+
$devMode = Mage::getStoreConfig('integration_options/orders_options/dev_mode');
|
37 |
+
|
38 |
+
if ($devMode == '1') {
|
39 |
+
$apiUrl = Mage::getStoreConfig('integration_options/orders_options/order_api_url');
|
40 |
+
}
|
41 |
+
|
42 |
+
$apiUrl .= '/download';
|
43 |
+
|
44 |
+
$username = Mage::getStoreConfig('integration_options/orders_options/username');
|
45 |
+
$password = Mage::getStoreConfig('integration_options/orders_options/password');
|
46 |
+
|
47 |
+
$context = stream_context_create(array(
|
48 |
+
'http' => array(
|
49 |
+
'header' => "Authorization: Basic " . base64_encode("$username:$password")
|
50 |
+
)
|
51 |
+
));
|
52 |
+
|
53 |
+
if (empty($from) || $from === null) {
|
54 |
+
$from = Fruugo_Integration_Helper_ConfigLoader::load('integration_options/orders_options/orders_endpoint_last_checked');
|
55 |
+
if (empty($from) || $from === null) {
|
56 |
+
$from = new DateTime('NOW');
|
57 |
+
$from = $from->format(DateTime::ISO8601);
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
$apiUrl .= ("?from=".urlencode($from));
|
62 |
+
|
63 |
+
try {
|
64 |
+
Fruugo_Integration_Helper_Logger::log("Getting new orders from Integration. From: " . $from);
|
65 |
+
|
66 |
+
$data = @file_get_contents($apiUrl, false, $context);
|
67 |
+
|
68 |
+
if ($data === false) {
|
69 |
+
throw new Exception("Failed to download orders from the Fruugo API at the URL $apiUrl. Make sure your Fruugo username and password are correct.");
|
70 |
+
}
|
71 |
+
|
72 |
+
$lastChecked = new DateTime('NOW');
|
73 |
+
$lastChecked = $lastChecked->format(DateTime::ISO8601);
|
74 |
+
|
75 |
+
Fruugo_Integration_Helper_ConfigLoader::save('integration_options/orders_options/orders_endpoint_last_checked', $lastChecked);
|
76 |
+
|
77 |
+
$doc = new DOMDocument();
|
78 |
+
$doc->loadXML($data);
|
79 |
+
|
80 |
+
$xpath = new DOMXpath($doc);
|
81 |
+
$xpath->registerNameSpace('o', 'https://www.fruugo.com/orders/schema');
|
82 |
+
$orders = $xpath->query('//o:order');
|
83 |
+
|
84 |
+
if ($orders->length == 0) {
|
85 |
+
Fruugo_Integration_Helper_Logger::log('No new Fruugo orders to process.');
|
86 |
+
} else {
|
87 |
+
foreach ($orders as $orderXml) {
|
88 |
+
$this->_mapOrderFromXml($orderXml);
|
89 |
+
}
|
90 |
+
Fruugo_Integration_Helper_Logger::log("Processing new orders finished.");
|
91 |
+
}
|
92 |
+
} catch (Exception $ex) {
|
93 |
+
Mage::logException($ex);
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
public function _mapOrderFromXml($orderXml)
|
98 |
+
{
|
99 |
+
$orderArray = $this->convertXmlToArray($orderXml);
|
100 |
+
$fruugoId = $orderArray['orderId'];
|
101 |
+
|
102 |
+
if ($orderArray['orderStatus'] !== 'PENDING') {
|
103 |
+
Fruugo_Integration_Helper_Logger::log('Fruugo order ' . $fruugoId . ' status is not PENDING. Order skipped.');
|
104 |
+
return false;
|
105 |
+
}
|
106 |
+
|
107 |
+
$salesModel = Mage::getModel("sales/order");
|
108 |
+
$existingCount = $salesModel->getCollection()->addAttributeToFilter('fruugo_order_id', $fruugoId)->count();
|
109 |
+
|
110 |
+
if ($existingCount > 0) {
|
111 |
+
Fruugo_Integration_Helper_Logger::log("The Fruugo order $fruugoId already exists and is being skipped");
|
112 |
+
return false;
|
113 |
+
}
|
114 |
+
|
115 |
+
$orderDate = $orderArray['orderDate'];
|
116 |
+
$shippingAddress = $orderArray['shippingAddress'];
|
117 |
+
$firstName = $shippingAddress['firstName'];
|
118 |
+
$lastName = $shippingAddress['lastName'];
|
119 |
+
$streetAddress = $shippingAddress['streetAddress'];
|
120 |
+
$city = $shippingAddress['city'];
|
121 |
+
$postcode = $shippingAddress['postalCode'];
|
122 |
+
$countryCode = $shippingAddress['countryCode'];
|
123 |
+
$phoneNumber = $shippingAddress['phoneNumber'];
|
124 |
+
$email = 'help+order-' . $fruugoId . '@fruugo.com';
|
125 |
+
$password = $this->_randomPassword();
|
126 |
+
|
127 |
+
$websiteId = Mage::app()->getWebsite()->getId();
|
128 |
+
$fruugoStore = null;
|
129 |
+
$stores = Mage::app()->getStores();
|
130 |
+
foreach ($stores as $id => $store) {
|
131 |
+
if ($store->getCode() == 'fruugo') {
|
132 |
+
$fruugoStore = $store;
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
+
if (empty($fruugoStore)) {
|
137 |
+
$fruugoStore = Mage::app()->getStore();
|
138 |
+
}
|
139 |
+
|
140 |
+
// create customer
|
141 |
+
$customer = Mage::getModel("customer/customer");
|
142 |
+
$customer->setWebsiteId($websiteId)
|
143 |
+
->setStore($fruugoStore);
|
144 |
+
|
145 |
+
$customer->loadByEmail($email);
|
146 |
+
$customer->setFirstname($firstName)
|
147 |
+
->setLastname($lastName)
|
148 |
+
->setEmail($email)
|
149 |
+
->setPassword($password);
|
150 |
+
$customer->setCreatedAt($orderDate);
|
151 |
+
$customer->save();
|
152 |
+
|
153 |
+
// create quote
|
154 |
+
$quote = Mage::getModel('sales/quote')->setStoreId($fruugoStore->getId());
|
155 |
+
$quote->setStore($fruugoStore);
|
156 |
+
|
157 |
+
$currencyCode = '';
|
158 |
+
// for deleted products
|
159 |
+
$orderItemsInfo = '';
|
160 |
+
$nonExistProductInfo = '';
|
161 |
+
foreach ($orderArray['orderLines'] as $orderLine) {
|
162 |
+
$productId = $orderLine['productId'];
|
163 |
+
$productSku = $orderLine['skuId'];
|
164 |
+
$currencyCode = $orderLine['currencyCode'];
|
165 |
+
$fruugoProductId = $orderLine['fruugoProductId'];
|
166 |
+
$fruugoSkuId = $orderLine['fruugoSkuId'];
|
167 |
+
$quantity = $orderLine['totalNumberOfItems'];
|
168 |
+
|
169 |
+
$quoteItem = $this->_mapLineItem($orderLine);
|
170 |
+
if (!$quoteItem) {
|
171 |
+
// product does not exist any more, cancel this item
|
172 |
+
$orderItemsInfo .= '&item=' . $fruugoProductId.','
|
173 |
+
.$fruugoSkuId.','
|
174 |
+
.(int)$quantity;
|
175 |
+
$nonExistProductInfo .= "ProductId:{$productId}, Sku:{$productSku}";
|
176 |
+
continue;
|
177 |
+
}
|
178 |
+
|
179 |
+
$quoteItem->setQuote($quote);
|
180 |
+
$quoteItem->setStoreId($fruugoStore->getId());
|
181 |
+
// set the fruugo skuid and fruugo
|
182 |
+
$quoteItem->setFruugoProductId($fruugoProductId);
|
183 |
+
$quoteItem->setFruugoSkuId($fruugoSkuId);
|
184 |
+
$quoteItem->setData('fruugo_product_id', $fruugoProductId);
|
185 |
+
$quoteItem->setData('fruugo_sku_id', $fruugoSkuId);
|
186 |
+
|
187 |
+
$quote->addItem($quoteItem);
|
188 |
+
}
|
189 |
+
|
190 |
+
$quote->setQuoteCurrencyCode($currencyCode);
|
191 |
+
$quote->assignCustomer($customer);
|
192 |
+
|
193 |
+
$addressData = array(
|
194 |
+
'firstname' => $firstName,
|
195 |
+
'lastname' => $lastName,
|
196 |
+
'street' => $streetAddress,
|
197 |
+
'city' => $city,
|
198 |
+
'postcode' => $postcode,
|
199 |
+
'region_id' => '1',
|
200 |
+
'telephone' => $phoneNumber,
|
201 |
+
'country_id' => $countryCode
|
202 |
+
);
|
203 |
+
|
204 |
+
$billingAddress = $quote->getBillingAddress()->addData($addressData);
|
205 |
+
$shippingAddress = $quote->getShippingAddress()->addData($addressData);
|
206 |
+
|
207 |
+
// set payment method
|
208 |
+
$paymentMethod = Mage::getStoreConfig('integration_options/orders_options/payment_method');
|
209 |
+
$shippingAddress->setCollectShippingRates(true)->collectShippingRates()
|
210 |
+
->setShippingMethod('flatrate_flatrate')->setPaymentMethod($paymentMethod);
|
211 |
+
$quote->getPayment()->importData(array('method' => $paymentMethod));
|
212 |
+
|
213 |
+
$quote->setFruugoOrderId($fruugoId);
|
214 |
+
$quote->setData('fruugo_order_id', $fruugoId);
|
215 |
+
|
216 |
+
$quote->collectTotals()->save();
|
217 |
+
|
218 |
+
$service = Mage::getModel('sales/service_quote', $quote);
|
219 |
+
$order = $service->submitOrder();
|
220 |
+
|
221 |
+
$order->addStatusHistoryComment("Note: Discard billing address as it is not valid.")
|
222 |
+
->setIsVisibleOnFront(false)
|
223 |
+
->setIsCustomerNotified(false);
|
224 |
+
|
225 |
+
$order->setCreatedAt(Varien_Date::formatDate($orderDate, true));
|
226 |
+
$order->setOrderCurrencyCode($currencyCode);
|
227 |
+
$order->setData('fruugo_order_id', $fruugoId);
|
228 |
+
$order->addStatusHistoryComment("Order created from Fruugo orders feed. The Fruugo Order ID is $fruugoId")
|
229 |
+
->setIsVisibleOnFront(false)
|
230 |
+
->setIsCustomerNotified(false);
|
231 |
+
|
232 |
+
// if you don't save each order item, the fruugo_product_id and fruugo_sku_id will not be saved
|
233 |
+
foreach ($order->getAllItems() as $orderItem) {
|
234 |
+
$orderItem->save();
|
235 |
+
}
|
236 |
+
|
237 |
+
$order->save();
|
238 |
+
|
239 |
+
// remove items from shopping cart
|
240 |
+
$quote->removeAllItems();
|
241 |
+
$quote->save();
|
242 |
+
|
243 |
+
if (count($order->getAllItems()) == 0) {
|
244 |
+
$nonExistProductInfo = '';
|
245 |
+
foreach ($orderArray['orderLines'] as $orderLine) {
|
246 |
+
$productId = $orderLine['productId'];
|
247 |
+
$productSku = $orderLine['skuId'];
|
248 |
+
$nonExistProductInfo .= "ProductId:{$productId}, Sku:{$productSku}";
|
249 |
+
}
|
250 |
+
$this->cancelItemsOnProductNotExist($order, $fruugoId, $nonExistProductInfo);
|
251 |
+
} elseif (!empty($orderItemsInfo)) {
|
252 |
+
$this->cancelItemsOnProductNotExist($order, $fruugoId, $nonExistProductInfo, $orderItemsInfo);
|
253 |
+
}
|
254 |
+
}
|
255 |
+
|
256 |
+
private function _mapLineItem($orderLine)
|
257 |
+
{
|
258 |
+
$sku = $orderLine['skuId'];
|
259 |
+
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
|
260 |
+
|
261 |
+
if ($product == null || empty($product)) {
|
262 |
+
return false;
|
263 |
+
}
|
264 |
+
|
265 |
+
$quoteItem = Mage::getModel('sales/quote_item')->setProduct($product);
|
266 |
+
$quoteItem->setQty($orderLine['totalNumberOfItems']);
|
267 |
+
return $quoteItem;
|
268 |
+
}
|
269 |
+
|
270 |
+
public function convertXmlToArray($xmlNode)
|
271 |
+
{
|
272 |
+
$arr = array();
|
273 |
+
$arrayTypes = array('orderLine', 'shipment', 'shipmentLine', 'attribute');
|
274 |
+
|
275 |
+
$previous_name = '';
|
276 |
+
foreach ($xmlNode->childNodes as $childNode) {
|
277 |
+
$arrName = str_replace('o:', '', $childNode->nodeName);
|
278 |
+
|
279 |
+
$arrayType = in_array($arrName, $arrayTypes);
|
280 |
+
if ($arrayType) {
|
281 |
+
array_push($arr, $this->convertXmlToArray($childNode));
|
282 |
+
} else {
|
283 |
+
if ($childNode->nodeName != '#text' && $childNode->childNodes->length == 1) {
|
284 |
+
$arr[$arrName] = $childNode->nodeValue;
|
285 |
+
} elseif ($childNode->nodeName != '#text' && $childNode->childNodes->length > 1) {
|
286 |
+
$arr[$arrName] = $this->convertXmlToArray($childNode);
|
287 |
+
}
|
288 |
+
}
|
289 |
+
}
|
290 |
+
|
291 |
+
return $arr;
|
292 |
+
}
|
293 |
+
|
294 |
+
private function _randomPassword()
|
295 |
+
{
|
296 |
+
$alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
|
297 |
+
$pass = array();
|
298 |
+
$alphaLength = strlen($alphabet) - 1;
|
299 |
+
|
300 |
+
for ($i = 0; $i < 8; $i++) {
|
301 |
+
$n = rand(0, $alphaLength);
|
302 |
+
$pass[] = $alphabet[$n];
|
303 |
+
}
|
304 |
+
|
305 |
+
return implode($pass);
|
306 |
+
}
|
307 |
+
|
308 |
+
private function cancelItemsOnProductNotExist($order, $fruugoId, $nonExistProductInfo, $orderItemsInfo = null)
|
309 |
+
{
|
310 |
+
$observer = new Fruugo_Integration_Model_Observer;
|
311 |
+
$data = array();
|
312 |
+
$devMode = Mage::getStoreConfig('integration_options/orders_options/dev_mode');
|
313 |
+
|
314 |
+
if ($devMode == '1') {
|
315 |
+
$apiUrl = Mage::getStoreConfig('integration_options/orders_options/order_api_url');
|
316 |
+
|
317 |
+
if (strpos($apiUrl, '127.0.0.1')) {
|
318 |
+
$data['mock_api_operation'] = 'cancel';
|
319 |
+
$data['orderId'] = $fruugoId;
|
320 |
+
}
|
321 |
+
}
|
322 |
+
|
323 |
+
$apiUrl .= '/cancel';
|
324 |
+
|
325 |
+
$postFields = 'orderId='.$fruugoId;
|
326 |
+
if (!empty($orderItemsInfo)) {
|
327 |
+
$postFields .= $orderItemsInfo;
|
328 |
+
}
|
329 |
+
|
330 |
+
$postFields .= '&cancellationReason=product_discontinued';
|
331 |
+
$data['postFields'] = $postFields;
|
332 |
+
list($httpcode, $response) = $observer->_sendToApi($apiUrl, $data);
|
333 |
+
|
334 |
+
if ($httpcode == 200) {
|
335 |
+
$observer->_saveHistoryComment($order, "Sent notification to Fruugo of cancellation of order {$fruugoId} because the following products do not exist: {$nonExistProductInfo}");
|
336 |
+
} else {
|
337 |
+
$observer->_saveHistoryComment($order, "Failed to send notification to Fruugo of cancellation of order {$fruugoId}. Server response code: {$httpcode}, response message: {$response}");
|
338 |
+
}
|
339 |
+
}
|
340 |
+
}
|
app/code/community/Fruugo/Integration/Helper/ProductsFeedGenerator.php
ADDED
@@ -0,0 +1,251 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/Logger.php';
|
24 |
+
|
25 |
+
class Fruugo_Integration_ProductsFeedGenerator extends Mage_Core_Helper_Abstract
|
26 |
+
{
|
27 |
+
public function generateProdcutsFeed($cached = false)
|
28 |
+
{
|
29 |
+
$cachedFile = Mage::getModuleDir('', 'Fruugo_Integration') . '/controllers/products.xml';
|
30 |
+
if ($cached === true && file_exists($cachedFile)) {
|
31 |
+
return $cachedFile;
|
32 |
+
} else {
|
33 |
+
Fruugo_Integration_Helper_Logger::log("Start exporting products data feed.");
|
34 |
+
$productsXml;
|
35 |
+
|
36 |
+
$devMode = Mage::getStoreConfig('integration_options/orders_options/dev_mode');
|
37 |
+
if ($devMode == '1') {
|
38 |
+
$productsXml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?>'
|
39 |
+
.'<Products xmlns="http://schemas.fruugo.com/fruugoflat"></Products>');
|
40 |
+
} else {
|
41 |
+
$productsXml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?>'
|
42 |
+
.'<Products></Products>');
|
43 |
+
}
|
44 |
+
|
45 |
+
$products = Mage::getModel('catalog/product')
|
46 |
+
->getCollection()
|
47 |
+
->addAttributeToSelect('*') // select all attributes
|
48 |
+
->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED) // only select enabled products
|
49 |
+
->addAttributeToFilter('type_id', Mage_Catalog_Model_Product_Type::TYPE_SIMPLE); // only select simple products
|
50 |
+
|
51 |
+
foreach ($products as $product) {
|
52 |
+
$disabledOnFruugo = false;
|
53 |
+
$productCountries = Mage::getModel('integration/countries')->load($product->getId(), 'product_id');
|
54 |
+
if (isset($productCountries) && $productCountries->getFruugoCountries() == 'Disabled') {
|
55 |
+
$disabledOnFruugo = true;
|
56 |
+
}
|
57 |
+
$imageUrl = $product->getImageUrl();
|
58 |
+
if (!$disabledOnFruugo &&
|
59 |
+
$product->getSku() !== null &&
|
60 |
+
$product->getName() !== null &&
|
61 |
+
$product->getDescription() !== null &&
|
62 |
+
$product->getPrice() !== null &&
|
63 |
+
!empty($imageUrl)) {
|
64 |
+
$productXml = $productsXml->addChild('Product');
|
65 |
+
$productXml = $this->_fillProductXml($productXml, $product);
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
Fruugo_Integration_Helper_Logger::log("Exporting products data feed finished.");
|
70 |
+
return $productsXml;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
public function _fillProductXml($productXml, $product)
|
75 |
+
{
|
76 |
+
// M: Mandatory R: Recommended O: Optional
|
77 |
+
$parentProduct = null;
|
78 |
+
|
79 |
+
$parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')
|
80 |
+
->getParentIdsByChild($product->getId());
|
81 |
+
|
82 |
+
// ProductId *M
|
83 |
+
if (isset($parentIds[0])) {
|
84 |
+
$parentProduct = Mage::getModel('catalog/product')->load($parentIds[0]);
|
85 |
+
$productXml->addChild('ProductId', $parentProduct->getId());
|
86 |
+
} else {
|
87 |
+
$productXml->addChild('ProductId', $product->getId());
|
88 |
+
}
|
89 |
+
|
90 |
+
// SkuId *M
|
91 |
+
$productXml->addChild('SkuId', htmlspecialchars($product->getSku()));
|
92 |
+
|
93 |
+
// EAN *R
|
94 |
+
if ($product->getEan() !== null) {
|
95 |
+
$productXml->addChild('EAN', $product->getEan());
|
96 |
+
}
|
97 |
+
|
98 |
+
// ISBN *O
|
99 |
+
if ($product->getIsbn() !== null) {
|
100 |
+
$productXml->addChild('ISBN', $product->getIsbn());
|
101 |
+
}
|
102 |
+
|
103 |
+
// Brand *R
|
104 |
+
if ($product->getBrand() !== null) {
|
105 |
+
$productXml->addChild('Brand', htmlspecialchars($product->getBrand()));
|
106 |
+
}
|
107 |
+
|
108 |
+
// Manufacturer *O
|
109 |
+
if ($product->getManufacturer() !== null && $product->getAttributeText('manufacturer')) {
|
110 |
+
$productXml->addChild('Manufacturer', htmlspecialchars($product->getAttributeText('manufacturer')));
|
111 |
+
}
|
112 |
+
|
113 |
+
// Category *R
|
114 |
+
$categoryEntity = $product->getCategoryCollection()
|
115 |
+
->addAttributeToSort('level', 'DESC')
|
116 |
+
->addAttributeToSort('position', 'DESC')
|
117 |
+
->addAttributeToFilter('is_active', '1')
|
118 |
+
->getFirstItem();
|
119 |
+
|
120 |
+
$category = Mage::getModel('catalog/category')
|
121 |
+
->load($categoryEntity->getId());
|
122 |
+
|
123 |
+
if ($category->getName() !== null) {
|
124 |
+
$productXml->addChild('Category', htmlspecialchars($category->getName()));
|
125 |
+
}
|
126 |
+
|
127 |
+
// Imageurl1 *M
|
128 |
+
$productXml->addChild('Imageurl1', htmlspecialchars(Mage::helper('catalog/image')->init($product, 'image')));
|
129 |
+
|
130 |
+
// Imageurl2, Imageurl3, Imageurl4, Imageurl5 *R
|
131 |
+
|
132 |
+
// StockStatus & StockQuantity *M
|
133 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
134 |
+
|
135 |
+
if ($stockItem === null || !$stockItem->getIsInStock()) {
|
136 |
+
$productXml->addChild('StockStatus', 'OUTOFSTOCK');
|
137 |
+
} else {
|
138 |
+
$productXml->addChild('StockStatus', 'INSTOCK');
|
139 |
+
$stocklevel = (int)$stockItem->getQty();
|
140 |
+
$productXml->addChild('StockQuantity', $stocklevel);
|
141 |
+
}
|
142 |
+
|
143 |
+
// RestockDate *O
|
144 |
+
|
145 |
+
// LeadTime *O
|
146 |
+
|
147 |
+
// PackageWeight **O
|
148 |
+
if ($product->getWeight() !== null) {
|
149 |
+
$productXml->addChild('PackageWeight', round($product->getWeight(), 0));
|
150 |
+
}
|
151 |
+
|
152 |
+
// Description Node
|
153 |
+
$stores = Mage::app()->getStores(false);
|
154 |
+
|
155 |
+
foreach ($stores as $store) {
|
156 |
+
// store 'fruugo' is for Fruugo orders
|
157 |
+
if ($store->getCode() != 'fruugo') {
|
158 |
+
$product->setStoreId($store->getId())->load($product->getId());
|
159 |
+
|
160 |
+
$localeCode = Mage::getStoreConfig('general/locale/code', $store->getId());
|
161 |
+
$language = substr($localeCode, 0, strpos($localeCode, '_'));
|
162 |
+
|
163 |
+
// Language *R
|
164 |
+
$descriptionXml = $productXml->addChild('Description');
|
165 |
+
$descriptionXml->addChild('Language', $language);
|
166 |
+
|
167 |
+
$descriptionXml->addChild('Title', htmlspecialchars($product->getName()));
|
168 |
+
|
169 |
+
// description
|
170 |
+
$nestedDescriptionXml = $descriptionXml->addChild('Description');
|
171 |
+
$descriptionType = Mage::getStoreConfig('integration_options/products_options/descrption_type');
|
172 |
+
|
173 |
+
if ($descriptionType == 'long') {
|
174 |
+
$this->_addCData($nestedDescriptionXml, $product->getDescription());
|
175 |
+
} elseif ($descriptionType == 'short') {
|
176 |
+
$this->_addCData($nestedDescriptionXml, $product->getShortDescription());
|
177 |
+
} else {
|
178 |
+
$this->_addCData($nestedDescriptionXml, $product->getDescription() . PHP_EOL . $product->getShortDescription());
|
179 |
+
}
|
180 |
+
|
181 |
+
// AttributeColor *R
|
182 |
+
if ($product->getColor() !== null && $product->getAttributeText('color')) {
|
183 |
+
$descriptionXml->addChild('AttributeColor', $product->getAttributeText('color'));
|
184 |
+
}
|
185 |
+
|
186 |
+
// AttributeSize *R
|
187 |
+
if ($product->getShoeSize() !== null && $product->getAttributeText('shoe_size')) {
|
188 |
+
$descriptionXml->addChild('AttributeSize', $product->getAttributeText('shoe_size'));
|
189 |
+
} elseif ($product->getSize() !== null && $product->getAttributeText('size')) {
|
190 |
+
$descriptionXml->addChild('AttributeSize', $product->getAttributeText('size'));
|
191 |
+
}
|
192 |
+
|
193 |
+
// optional attributes: Arrtibute1 - Attribute10 *O
|
194 |
+
if ($product->getFit() !== null) {
|
195 |
+
$descriptionXml->addChild('Attribute1', $product->getFit());
|
196 |
+
}
|
197 |
+
if ($product->getLength() !== null) {
|
198 |
+
$descriptionXml->addChild('Attribute2', $product->getLength());
|
199 |
+
}
|
200 |
+
if ($product->getWidth() !== null) {
|
201 |
+
$descriptionXml->addChild('Attribute3', $product->getWidth());
|
202 |
+
}
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
$addedCurrencies = array();
|
207 |
+
foreach ($stores as $store) {
|
208 |
+
if ($store->getCode() != 'fruugo') {
|
209 |
+
$currencyCode = $store->getCurrentCurrencyCode();
|
210 |
+
if (in_array($currencyCode, $addedCurrencies)) {
|
211 |
+
continue;
|
212 |
+
} else {
|
213 |
+
array_push($addedCurrencies, $currencyCode);
|
214 |
+
}
|
215 |
+
$product->setStoreId($store->getId())->load($product->getId());
|
216 |
+
// Price Node
|
217 |
+
$priceXml = $productXml->addChild('Price');
|
218 |
+
// Currency *R
|
219 |
+
$priceXml->addChild('Currency', $currencyCode);
|
220 |
+
// Country
|
221 |
+
$existingProductCountries = Mage::getModel('integration/countries')->load($product->getId(), 'product_id');
|
222 |
+
if (isset($existingProductCountries) && $existingProductCountries->getFruugoCountries() != null) {
|
223 |
+
$existingList = $existingProductCountries->getFruugoCountries();
|
224 |
+
$priceXml->addChild('Country', $existingList);
|
225 |
+
}
|
226 |
+
|
227 |
+
$taxCalculation = Mage::getModel('tax/calculation');
|
228 |
+
$request = $taxCalculation->getRateRequest(null, null, null, $store);
|
229 |
+
$normalPriceExclTax = $product->getFinalPrice();
|
230 |
+
$priceXml->addChild('NormalPriceWithoutVAT', number_format($normalPriceExclTax, 2, '.', ''));
|
231 |
+
|
232 |
+
$taxClassId = $product->getTaxClassId();
|
233 |
+
$percent = $taxCalculation->getRate($request->setProductClassId($taxClassId));
|
234 |
+
$priceXml->addChild('VATRate', number_format($percent, 2, '.', ''));
|
235 |
+
|
236 |
+
// DiscountPriceStartDate *O
|
237 |
+
// DiscountPriceEndDate *O
|
238 |
+
}
|
239 |
+
}
|
240 |
+
|
241 |
+
return $productXml;
|
242 |
+
}
|
243 |
+
|
244 |
+
private function _addCData($xml, $cdata_text)
|
245 |
+
{
|
246 |
+
$node = dom_import_simplexml($xml);
|
247 |
+
$no = $node->ownerDocument;
|
248 |
+
$node->appendChild($no->createCDATASection(htmlspecialchars($cdata_text)));
|
249 |
+
return $xml;
|
250 |
+
}
|
251 |
+
}
|
app/code/community/Fruugo/Integration/Model/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/Model/Adminhtml/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/Model/Adminhtml/System/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/Model/Adminhtml/System/Config/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/Model/Adminhtml/System/Config/Backend/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/Model/Adminhtml/System/Config/Backend/OrderCron.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/Logger.php';
|
24 |
+
|
25 |
+
class Fruugo_Integration_Model_Adminhtml_System_Config_Backend_OrderCron extends Mage_Core_Model_Config_Data
|
26 |
+
{
|
27 |
+
const CRON_STRING_PATH = 'crontab/jobs/download_orders/schedule/cron_expr';
|
28 |
+
|
29 |
+
protected function _afterSave()
|
30 |
+
{
|
31 |
+
$time = $this->getData('groups/orders_options/fields/fetch_frequency/value');
|
32 |
+
|
33 |
+
$frequencyDaily = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_DAILY;
|
34 |
+
|
35 |
+
$cronExprString = '';
|
36 |
+
|
37 |
+
if ($time === $frequencyDaily) {
|
38 |
+
$cronExprString = '@daily';
|
39 |
+
} else {
|
40 |
+
$cronExprString = '0 */' . $time . ' * * *';
|
41 |
+
}
|
42 |
+
|
43 |
+
try {
|
44 |
+
Mage::getModel('core/config_data')
|
45 |
+
->load(self::CRON_STRING_PATH, 'path')
|
46 |
+
->setValue($cronExprString)
|
47 |
+
->setPath(self::CRON_STRING_PATH)
|
48 |
+
->save();
|
49 |
+
|
50 |
+
$message = "fetch_frequency cron job config saved. cron_expr: " . $cronExprString;
|
51 |
+
|
52 |
+
Fruugo_Integration_Helper_Logger::log($message);
|
53 |
+
} catch (Exception $e) {
|
54 |
+
Fruugo_Integration_Helper_Logger::log("Unable to save the cron expression. Error: " . $e);
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
app/code/community/Fruugo/Integration/Model/Adminhtml/System/Config/Backend/ProductCron.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/Logger.php';
|
24 |
+
|
25 |
+
class Fruugo_Integration_Model_Adminhtml_System_Config_Backend_ProductCron extends Mage_Core_Model_Config_Data
|
26 |
+
{
|
27 |
+
const CRON_STRING_PATH = 'crontab/jobs/export_products/schedule/cron_expr';
|
28 |
+
|
29 |
+
protected function _afterSave()
|
30 |
+
{
|
31 |
+
$time = $this->getData('groups/products_options/fields/export_frequency/value');
|
32 |
+
|
33 |
+
$frequencyDaily = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_DAILY;
|
34 |
+
|
35 |
+
$cronExprString = '';
|
36 |
+
|
37 |
+
if ($time === $frequencyDaily) {
|
38 |
+
$cronExprString = '@daily';
|
39 |
+
} else {
|
40 |
+
$cronExprString = '0 */' . $time . ' * * *';
|
41 |
+
}
|
42 |
+
|
43 |
+
try {
|
44 |
+
Mage::getModel('core/config_data')
|
45 |
+
->load(self::CRON_STRING_PATH, 'path')
|
46 |
+
->setValue($cronExprString)
|
47 |
+
->setPath(self::CRON_STRING_PATH)
|
48 |
+
->save();
|
49 |
+
|
50 |
+
$message = "export_products cron job config saved. cron_expr: " . $cronExprString;
|
51 |
+
|
52 |
+
Fruugo_Integration_Helper_Logger::log($message);
|
53 |
+
} catch (Exception $e) {
|
54 |
+
Fruugo_Integration_Helper_Logger::log("Unable to save the cron expression. Error: " . $e);
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
app/code/community/Fruugo/Integration/Model/Adminhtml/System/Config/Source/Hour.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Used in creating options for Hour config value selection
|
25 |
+
*
|
26 |
+
*/
|
27 |
+
class Fruugo_Integration_Model_Adminhtml_System_Config_Source_Hour
|
28 |
+
{
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Options getter
|
32 |
+
*
|
33 |
+
* @return array
|
34 |
+
*/
|
35 |
+
public function toOptionArray()
|
36 |
+
{
|
37 |
+
$hours = array();
|
38 |
+
|
39 |
+
array_push($hours, array('value' => '1', 'label' => '1 hour'));
|
40 |
+
array_push($hours, array('value' => '2', 'label' => '2 hours'));
|
41 |
+
array_push($hours, array('value' => '4', 'label' => '4 hours'));
|
42 |
+
array_push($hours, array('value' => '6', 'label' => '6 hours'));
|
43 |
+
array_push($hours, array('value' => '8', 'label' => '8 hours'));
|
44 |
+
array_push($hours, array('value' => '12', 'label' => '12 hours'));
|
45 |
+
array_push($hours, array('value' => 'D', 'label' => 'Daily'));
|
46 |
+
|
47 |
+
return $hours;
|
48 |
+
}
|
49 |
+
}
|
app/code/community/Fruugo/Integration/Model/Adminhtml/System/Config/Source/OrderPaymentMethod.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Used in creating options for Fruugo product descritption type
|
25 |
+
*
|
26 |
+
*/
|
27 |
+
class Fruugo_Integration_Model_Adminhtml_System_Config_Source_OrderPaymentMethod
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* Options getter
|
31 |
+
*
|
32 |
+
* @return array
|
33 |
+
*/
|
34 |
+
public function toOptionArray()
|
35 |
+
{
|
36 |
+
$paymentMethods = array();
|
37 |
+
$allActivePaymentMethods = Mage::getModel('payment/config')->getActiveMethods();
|
38 |
+
|
39 |
+
foreach ($allActivePaymentMethods as $key => $value) {
|
40 |
+
$label = $paymentTitle = Mage::getStoreConfig('payment/'.$key.'/title');
|
41 |
+
array_push($paymentMethods, array('value' => $key, 'label' => $label));
|
42 |
+
}
|
43 |
+
|
44 |
+
return $paymentMethods;
|
45 |
+
}
|
46 |
+
}
|
app/code/community/Fruugo/Integration/Model/Adminhtml/System/Config/Source/ProductDescriptionType.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Used in creating options for Fruugo product descritption type
|
25 |
+
*
|
26 |
+
*/
|
27 |
+
class Fruugo_Integration_Model_Adminhtml_System_Config_Source_ProductDescriptionType
|
28 |
+
{
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Options getter
|
32 |
+
*
|
33 |
+
* @return array
|
34 |
+
*/
|
35 |
+
public function toOptionArray()
|
36 |
+
{
|
37 |
+
$descriptionTypes = array();
|
38 |
+
|
39 |
+
array_push($descriptionTypes, array('value' => 'long', 'label' => 'Description only'));
|
40 |
+
array_push($descriptionTypes, array('value' => 'short', 'label' => 'Short description only'));
|
41 |
+
array_push($descriptionTypes, array('value' => 'merge', 'label' => 'Merge description and short description'));
|
42 |
+
|
43 |
+
return $descriptionTypes;
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Fruugo/Integration/Model/Countries.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
class Fruugo_Integration_Model_Countries extends Mage_Core_Model_Abstract
|
24 |
+
{
|
25 |
+
protected function _construct()
|
26 |
+
{
|
27 |
+
$this->_init('integration/countries');
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Fruugo/Integration/Model/CronJobObserver.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/ProductsFeedGenerator.php';
|
24 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/OrdersFeedProcessor.php';
|
25 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/Logger.php';
|
26 |
+
|
27 |
+
class Fruugo_Integration_Model_CronJobObserver
|
28 |
+
{
|
29 |
+
public function exportProducts()
|
30 |
+
{
|
31 |
+
// Export products xml
|
32 |
+
$productsFeedGenerator = new Fruugo_Integration_ProductsFeedGenerator();
|
33 |
+
$xml = $productsFeedGenerator->generateProdcutsFeed(false)->asXML();
|
34 |
+
|
35 |
+
try {
|
36 |
+
Fruugo_Integration_Helper_Logger::log("Writing exported products to file.");
|
37 |
+
$outputDir = Mage::getModuleDir('', 'Fruugo_Integration') . '/controllers/products.xml';
|
38 |
+
$myfile = fopen($outputDir, "w");
|
39 |
+
fwrite($myfile, $xml);
|
40 |
+
fclose($myfile);
|
41 |
+
Fruugo_Integration_Helper_Logger::log("Writing products data feed finished.");
|
42 |
+
} catch (Exception $e) {
|
43 |
+
Mage::logException($e);
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
public function downloadOrders()
|
48 |
+
{
|
49 |
+
$orderFeedProcessor = new Fruugo_Integration_OrdersFeedProcessor();
|
50 |
+
Fruugo_Integration_Helper_Logger::log("Starting downloading orders.");
|
51 |
+
$orderFeedProcessor->processOrders();
|
52 |
+
}
|
53 |
+
}
|
app/code/community/Fruugo/Integration/Model/Observer.php
ADDED
@@ -0,0 +1,385 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/OrdersFeedProcessor.php';
|
24 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/Defines.php';
|
25 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/Logger.php';
|
26 |
+
|
27 |
+
use \DOMDocument as DOMDocument;
|
28 |
+
use \DOMXpath as DOMXpath;
|
29 |
+
|
30 |
+
class Fruugo_Integration_Model_Observer
|
31 |
+
{
|
32 |
+
public function beforeSaveOrder(Varien_Event_Observer $observer)
|
33 |
+
{
|
34 |
+
try {
|
35 |
+
$event = $observer->getEvent();
|
36 |
+
$order = $event->getOrder();
|
37 |
+
$fruugoId = $order->getFruugoOrderId();
|
38 |
+
|
39 |
+
if (!empty($fruugoId) && $fruugoId !== null) {
|
40 |
+
$existingStatus = null;
|
41 |
+
if (!empty($order->getId()) && $order->getId() !== null) {
|
42 |
+
$origData = $order->getOrigData();
|
43 |
+
}
|
44 |
+
}
|
45 |
+
} catch (Exception $ex) {
|
46 |
+
Mage::logException($ex);
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
public function orderInvoiced(Varien_Event_Observer $observer)
|
51 |
+
{
|
52 |
+
$apiUrl = Fruugo_Integration_Helper_Defines::FRUUGO_ORDERS_ENDPOINT;
|
53 |
+
try {
|
54 |
+
$event = $observer->getEvent();
|
55 |
+
$invoice = $observer->getEvent()->getInvoice();
|
56 |
+
$order = $invoice->getOrder();
|
57 |
+
$fruugoId = $order->getFruugoOrderId();
|
58 |
+
|
59 |
+
if (!empty($fruugoId) && $fruugoId !== null) {
|
60 |
+
$data = array();
|
61 |
+
$devMode = Mage::getStoreConfig('integration_options/orders_options/dev_mode');
|
62 |
+
|
63 |
+
$postFields = 'orderId='.$fruugoId;
|
64 |
+
|
65 |
+
Fruugo_Integration_Helper_Logger::log("Invoice created for Fruugo order {$fruugoId}");
|
66 |
+
|
67 |
+
$itemsInvoiced = $invoice->getAllItems();
|
68 |
+
foreach ($itemsInvoiced as $invoiceItem) {
|
69 |
+
$orderItem = $invoiceItem->getOrderItem();
|
70 |
+
$itemInfo = $orderItem->getFruugoProductId().','
|
71 |
+
.$orderItem->getFruugoSkuId().','
|
72 |
+
.(int)$invoiceItem->getQty();
|
73 |
+
|
74 |
+
$postFields .= '&item=' . $itemInfo;
|
75 |
+
}
|
76 |
+
|
77 |
+
if ($devMode == '1') {
|
78 |
+
$apiUrl = Mage::getStoreConfig('integration_options/orders_options/order_api_url');
|
79 |
+
|
80 |
+
if (strpos($apiUrl, '127.0.0.1')) {
|
81 |
+
$data['mock_api_operation'] = 'confirm';
|
82 |
+
$data['orderId'] = $fruugoId;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
$apiUrl .= '/confirm';
|
87 |
+
$data['postFields'] = $postFields;
|
88 |
+
list($httpcode, $response) = $this->_sendToApi($apiUrl, $data);
|
89 |
+
|
90 |
+
if ($httpcode == 200) {
|
91 |
+
$this->_saveHistoryComment($order, "Sent confirmation to Fruugo of order {$fruugoId}. Details: {$postFields}.");
|
92 |
+
Fruugo_Integration_Helper_Logger::log("Sent confirmation to Fruugo of order {$fruugoId}. Details: {$postFields}.");
|
93 |
+
} else {
|
94 |
+
$this->_saveHistoryComment($order, "Failed to send notification to Fruugo of confirmation of order {$fruugoId}. Server response code: {$httpcode}, response message: {$response}");
|
95 |
+
Fruugo_Integration_Helper_Logger::log("Failed to send notification to Fruugo of confirmation of order {$fruugoId}. Server response code: {$httpcode}, response message: {$response}");
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
} catch (Exception $ex) {
|
100 |
+
Mage::logException($ex);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
public function orderCancelled(Varien_Event_Observer $observer)
|
105 |
+
{
|
106 |
+
$apiUrl = Fruugo_Integration_Helper_Defines::FRUUGO_ORDERS_ENDPOINT;
|
107 |
+
try {
|
108 |
+
$event = $observer->getEvent();
|
109 |
+
$orderItem = $event->getItem();
|
110 |
+
$order = $orderItem->getOrder();
|
111 |
+
$fruugoId = $order->getFruugoOrderId();
|
112 |
+
|
113 |
+
if (!empty($fruugoId) && $fruugoId !== null) {
|
114 |
+
$data = array();
|
115 |
+
$devMode = Mage::getStoreConfig('integration_options/orders_options/dev_mode');
|
116 |
+
|
117 |
+
if ($devMode == '1') {
|
118 |
+
$apiUrl = Mage::getStoreConfig('integration_options/orders_options/order_api_url');
|
119 |
+
|
120 |
+
if (strpos($apiUrl, '127.0.0.1')) {
|
121 |
+
$data['mock_api_operation'] = 'cancel';
|
122 |
+
$data['orderId'] = $fruugoId;
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
$apiUrl .= '/cancel';
|
127 |
+
$postFields = 'orderId='.$fruugoId;
|
128 |
+
|
129 |
+
if ($orderItem->getQtyOrdered() > 0) {
|
130 |
+
$itemInfo = $orderItem->getFruugoProductId().','
|
131 |
+
.$orderItem->getFruugoSkuId().','
|
132 |
+
.(int)$orderItem->getQtyOrdered();
|
133 |
+
|
134 |
+
$postFields .= '&item=' . $itemInfo;
|
135 |
+
}
|
136 |
+
|
137 |
+
$postFields .= '&cancellationReason=other';
|
138 |
+
$data['postFields'] = $postFields;
|
139 |
+
list($httpcode, $response) = $this->_sendToApi($apiUrl, $data);
|
140 |
+
|
141 |
+
if ($httpcode == 200) {
|
142 |
+
$this->_saveHistoryComment($order, "Sent notification to Fruugo of cancellation of order {$fruugoId}. Details: {$postFields}");
|
143 |
+
Fruugo_Integration_Helper_Logger::log("Sent notification to Fruugo of cancellation of order {$fruugoId}. Details: {$postFields}");
|
144 |
+
} else {
|
145 |
+
$this->_saveHistoryComment($order, "Failed to send notification to Fruugo of cancellation of order {$fruugoId}. Server response code: {$httpcode}, response message: {$response}");
|
146 |
+
Fruugo_Integration_Helper_Logger::log("Failed to send notification to Fruugo of cancellation of order {$fruugoId}. Server response code: {$httpcode}, response message: {$response}");
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
} catch (Exception $ex) {
|
151 |
+
Mage::logException($ex);
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
public function orderShipment(Varien_Event_Observer $observer)
|
156 |
+
{
|
157 |
+
$apiUrl = Fruugo_Integration_Helper_Defines::FRUUGO_ORDERS_ENDPOINT;
|
158 |
+
|
159 |
+
try {
|
160 |
+
$event = $observer->getEvent();
|
161 |
+
$shipment = $event->getShipment();
|
162 |
+
$order = $shipment->getOrder();
|
163 |
+
$fruugoId = $order->getFruugoOrderId();
|
164 |
+
|
165 |
+
if (!empty($fruugoId) && $fruugoId !== null) {
|
166 |
+
if ($order->canInvoice()) {
|
167 |
+
$qtys = array();
|
168 |
+
$orderItemsNotToShip = $order->getAllItems();
|
169 |
+
|
170 |
+
foreach ($shipment->getAllItems() as $shipmentItem) {
|
171 |
+
$orderItemFromShipmentItem = $shipmentItem->getOrderItem();
|
172 |
+
|
173 |
+
foreach ($orderItemsNotToShip as $key => $value) {
|
174 |
+
if ($value->getId() == $orderItemFromShipmentItem->getId()) {
|
175 |
+
unset($orderItemsNotToShip[$key]);
|
176 |
+
}
|
177 |
+
}
|
178 |
+
|
179 |
+
$qty = (int)$shipmentItem->getQty();
|
180 |
+
$qtys[$orderItemFromShipmentItem->getId()] = $qty;
|
181 |
+
$itemFruugoProductId = $orderItemFromShipmentItem->getFruugoProductId();
|
182 |
+
$itemFruugoSkuId = $orderItemFromShipmentItem->getFruugoSkuId();
|
183 |
+
$order->addStatusHistoryComment("Automatically set to invoiced and paid by Fruugo for item: Fruugo ProductId: {$itemFruugoProductId}, Fruugo SkuId: {$itemFruugoSkuId}, quantity: {$qty}.", false);
|
184 |
+
}
|
185 |
+
|
186 |
+
// for items not being shipped, it needs to be put in qtys as 0 qty
|
187 |
+
foreach ($orderItemsNotToShip as $orderItemNotToShip) {
|
188 |
+
$qtys[$orderItemNotToShip->getId()] = 0;
|
189 |
+
}
|
190 |
+
|
191 |
+
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice($qtys);
|
192 |
+
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
|
193 |
+
$invoice->register();
|
194 |
+
$invoice->getOrder()->setCustomerNoteNotify(false);
|
195 |
+
$invoice->getOrder()->setIsInProcess(true);
|
196 |
+
|
197 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
198 |
+
->addObject($invoice)
|
199 |
+
->addObject($invoice->getOrder());
|
200 |
+
$transactionSave->save();
|
201 |
+
}
|
202 |
+
|
203 |
+
$trackingNumber = null;
|
204 |
+
$shippingCompany = null;
|
205 |
+
$tracks = $shipment->getAllTracks();
|
206 |
+
$postFields = '';
|
207 |
+
if (is_array($tracks) && count($tracks) > 0) {
|
208 |
+
$track = $tracks[0];
|
209 |
+
$trackingNumber = $track->getTrackNumber();
|
210 |
+
$shippingCompany = $track->getCarrierCode();
|
211 |
+
|
212 |
+
$postFields .= '&trackingCode=' . $trackingNumber;
|
213 |
+
$postFields .= '&messageToCustomer=' . $shippingCompany;
|
214 |
+
} elseif (!is_array($tracks) && isset($tracks)) {
|
215 |
+
$trackingNumber = $tracks;
|
216 |
+
$postFields .= '&trackingCode=' . $trackingNumber;
|
217 |
+
}
|
218 |
+
|
219 |
+
$data = array();
|
220 |
+
$devMode = Mage::getStoreConfig('integration_options/orders_options/dev_mode');
|
221 |
+
|
222 |
+
if ($devMode == '1') {
|
223 |
+
$apiUrl = Mage::getStoreConfig('integration_options/orders_options/order_api_url');
|
224 |
+
|
225 |
+
if (strpos($apiUrl, '127.0.0.1')) {
|
226 |
+
$data['mock_api_operation'] = 'ship';
|
227 |
+
$data['orderId'] = $fruugoId;
|
228 |
+
}
|
229 |
+
}
|
230 |
+
|
231 |
+
$apiUrl .= '/ship';
|
232 |
+
$postFields = 'orderId='.$fruugoId;
|
233 |
+
foreach ($shipment->getAllItems() as $shipmentItem) {
|
234 |
+
$orderItem = $shipmentItem->getOrderItem();
|
235 |
+
$itemInfo = $orderItem->getFruugoProductId().','
|
236 |
+
.$orderItem->getFruugoSkuId().','
|
237 |
+
.(int)$shipmentItem->getQty();
|
238 |
+
|
239 |
+
$postFields .= '&item=' . $itemInfo;
|
240 |
+
}
|
241 |
+
|
242 |
+
$data['postFields'] = $postFields;
|
243 |
+
$ch = $this->_getCurlRequest($apiUrl, $data);
|
244 |
+
$response = curl_exec($ch);
|
245 |
+
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
246 |
+
curl_close($ch);
|
247 |
+
|
248 |
+
if ($httpcode == 200) {
|
249 |
+
$shippedOrder = $response;
|
250 |
+
$ordersFeedProcessor = new Fruugo_Integration_OrdersFeedProcessor();
|
251 |
+
$doc = new DOMDocument();
|
252 |
+
$doc->loadXML($shippedOrder);
|
253 |
+
|
254 |
+
$xpath = new DOMXpath($doc);
|
255 |
+
$xpath->registerNameSpace('o', 'https://www.fruugo.com/orders/schema');
|
256 |
+
$orders = $xpath->query('//o:order');
|
257 |
+
|
258 |
+
if ($orders->length == 0) {
|
259 |
+
$this->_saveHistoryComment($order, "Fruugo returned invalid data for shipped order $fruugoId. Response: $shippedOrder");
|
260 |
+
Fruugo_Integration_Helper_Logger::log("Fruugo returned invalid data for shipped order $fruugoId. Response: $shippedOrder");
|
261 |
+
} else {
|
262 |
+
$this->_saveHistoryComment($order, "Sent notification to Fruugo of shipment of order $fruugoId");
|
263 |
+
Fruugo_Integration_Helper_Logger::log("Sent notification to Fruugo of shipment of order $fruugoId");
|
264 |
+
foreach ($orders as $orderXml) {
|
265 |
+
$orderArray = $ordersFeedProcessor->convertXmlToArray($orderXml);
|
266 |
+
foreach ($orderArray['shipments'] as $shipment) {
|
267 |
+
$shipmentId = $shipment['shipmentId'];
|
268 |
+
$data = array('fruugo_shipment_id' => $shipmentId,
|
269 |
+
'fruugo_order_id' => $fruugoId,
|
270 |
+
'created_at' => date_format(new DateTime('NOW'), 'Y-m-d H:i:s'));
|
271 |
+
|
272 |
+
$model = Mage::getModel('integration/shipment')->setData($data);
|
273 |
+
try {
|
274 |
+
$insertId = $model->save()->getId();
|
275 |
+
Fruugo_Integration_Helper_Logger::log("Saved shipment info of Fruugo order {$fruugoId}. ShipmentId: {$shipmentId}");
|
276 |
+
} catch (Exception $ex) {
|
277 |
+
Mage::logException($ex);
|
278 |
+
}
|
279 |
+
}
|
280 |
+
}
|
281 |
+
}
|
282 |
+
Fruugo_Integration_Helper_Logger::log("Sent notification to Fruugo of shipment of order {$fruugoId}. Details: {$postFields}");
|
283 |
+
} else {
|
284 |
+
Fruugo_Integration_Helper_Logger::log("Failed to send notification to Fruugo of shipment of order {$fruugoId}. Server response code: {$httpcode}. Response message: {$response}");
|
285 |
+
}
|
286 |
+
}
|
287 |
+
} catch (Exception $ex) {
|
288 |
+
Mage::logException($ex);
|
289 |
+
}
|
290 |
+
}
|
291 |
+
|
292 |
+
public function orderRefunded(Varien_Event_Observer $observer)
|
293 |
+
{
|
294 |
+
$apiUrl = Fruugo_Integration_Helper_Defines::FRUUGO_ORDERS_ENDPOINT;
|
295 |
+
try {
|
296 |
+
$event = $observer->getEvent();
|
297 |
+
$creditmemo = $event->getCreditmemo();
|
298 |
+
$order = $creditmemo->getOrder();
|
299 |
+
$fruugoId = $order->getFruugoOrderId();
|
300 |
+
|
301 |
+
if (!empty($fruugoId) && $fruugoId !== null) {
|
302 |
+
$data = array();
|
303 |
+
$devMode = Mage::getStoreConfig('integration_options/orders_options/dev_mode');
|
304 |
+
|
305 |
+
if ($devMode == '1') {
|
306 |
+
$apiUrl = Mage::getStoreConfig('integration_options/orders_options/order_api_url');
|
307 |
+
|
308 |
+
if (strpos($apiUrl, '127.0.0.1')) {
|
309 |
+
$data['mock_api_operation'] = 'return';
|
310 |
+
$data['orderId'] = $fruugoId;
|
311 |
+
}
|
312 |
+
}
|
313 |
+
|
314 |
+
$apiUrl .= '/return';
|
315 |
+
$postFields = 'orderId='.$fruugoId;
|
316 |
+
$itemsRefunded = $creditmemo->getAllItems();
|
317 |
+
foreach ($itemsRefunded as $refundedItem) {
|
318 |
+
$orderItem = $refundedItem->getOrderItem();
|
319 |
+
$itemInfo = $orderItem->getFruugoProductId().','
|
320 |
+
.$orderItem->getFruugoSkuId().','
|
321 |
+
.(int)$refundedItem->getQty();
|
322 |
+
|
323 |
+
$postFields .= '&item=' . $itemInfo;
|
324 |
+
}
|
325 |
+
|
326 |
+
$data['postFields'] = $postFields;
|
327 |
+
list($httpcode, $response) = $this->_sendToApi($apiUrl, $data);
|
328 |
+
|
329 |
+
if ($httpcode == 200) {
|
330 |
+
$this->_saveHistoryComment($order, "Sent return notification to Fruugo of order {$fruugoId}. Details: {$postFields}");
|
331 |
+
Fruugo_Integration_Helper_Logger::log("Sent return notification to Fruugo of order {$fruugoId}. Details: {$postFields}");
|
332 |
+
} else {
|
333 |
+
$this->_saveHistoryComment($order, "Failed to send notification to Fruugo of return of order {$fruugoId}. Server response code: {$httpcode}, response message: {$response}");
|
334 |
+
Fruugo_Integration_Helper_Logger::log("Failed to send notification to Fruugo of return of order {$fruugoId}. Server response code: {$httpcode}, response message: {$response}");
|
335 |
+
}
|
336 |
+
}
|
337 |
+
} catch (Exception $ex) {
|
338 |
+
Mage::logException($ex);
|
339 |
+
}
|
340 |
+
}
|
341 |
+
|
342 |
+
//Use this when the order is being saved in a transaction in the process
|
343 |
+
//that triggered the event otherwise you will get MySql errors
|
344 |
+
public function _saveHistoryComment($order, $comment)
|
345 |
+
{
|
346 |
+
$history = Mage::getModel('sales/order_status_history')
|
347 |
+
->setStatus($order->getStatus())
|
348 |
+
->setComment($comment)
|
349 |
+
->setIsVisibleOnFront(false)
|
350 |
+
->setIsCustomerNotified(false)
|
351 |
+
->setEntityName(Mage_Sales_Model_Order::HISTORY_ENTITY_NAME);
|
352 |
+
$history->setOrder($order);
|
353 |
+
$history->save();
|
354 |
+
}
|
355 |
+
|
356 |
+
private function _getCurlRequest($url, $data)
|
357 |
+
{
|
358 |
+
$ch = curl_init($url);
|
359 |
+
$username = Mage::getStoreConfig('integration_options/orders_options/username');
|
360 |
+
$password = Mage::getStoreConfig('integration_options/orders_options/password');
|
361 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
362 |
+
|
363 |
+
if (strpos($url, '127.0.0.1')) {
|
364 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
365 |
+
} else {
|
366 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $data['postFields']);
|
367 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
|
368 |
+
}
|
369 |
+
|
370 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
371 |
+
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
|
372 |
+
|
373 |
+
return $ch;
|
374 |
+
}
|
375 |
+
|
376 |
+
public function _sendToApi($url, $data)
|
377 |
+
{
|
378 |
+
$ch = $this->_getCurlRequest($url, $data);
|
379 |
+
$response = curl_exec($ch);
|
380 |
+
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
381 |
+
curl_close($ch);
|
382 |
+
|
383 |
+
return array($httpcode, $response);
|
384 |
+
}
|
385 |
+
}
|
app/code/community/Fruugo/Integration/Model/Resource/Countries.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
class Fruugo_Integration_Model_Resource_Countries extends Mage_Core_Model_Resource_Db_Abstract
|
24 |
+
{
|
25 |
+
protected function _construct()
|
26 |
+
{
|
27 |
+
$this->_init('integration/countries', 'fpc_id');
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Fruugo/Integration/Model/Resource/Countries/Collection.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
class Fruugo_Integration_Model_Resource_Countries_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
24 |
+
{
|
25 |
+
public function _construct()
|
26 |
+
{
|
27 |
+
$this->_init('integration/countries');
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Fruugo/Integration/Model/Resource/Shipment.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
class Fruugo_Integration_Model_Resource_Shipment extends Mage_Core_Model_Resource_Db_Abstract
|
24 |
+
{
|
25 |
+
protected function _construct()
|
26 |
+
{
|
27 |
+
$this->_init('integration/shipment', 'shipment_id');
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Fruugo/Integration/Model/Resource/Shipment/Collection.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
class Fruugo_Integration_Model_Resource_Shipment_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
24 |
+
{
|
25 |
+
public function _construct()
|
26 |
+
{
|
27 |
+
$this->_init('integration/shipment');
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Fruugo/Integration/Model/Shipment.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
class Fruugo_Integration_Model_Shipment extends Mage_Core_Model_Abstract
|
24 |
+
{
|
25 |
+
protected function _construct()
|
26 |
+
{
|
27 |
+
$this->_init('integration/shipment');
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Fruugo/Integration/controllers/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/controllers/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
*.xml
|
app/code/community/Fruugo/Integration/controllers/OrdersController.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/OrdersFeedProcessor.php';
|
24 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/Logger.php';
|
25 |
+
|
26 |
+
class Fruugo_Integration_OrdersController extends Mage_Core_Controller_Front_Action
|
27 |
+
{
|
28 |
+
public function indexAction()
|
29 |
+
{
|
30 |
+
Fruugo_Integration_Helper_Logger::log("Force downloading new orders.");
|
31 |
+
$ordersFeedProcessor = new Fruugo_Integration_OrdersFeedProcessor();
|
32 |
+
$from = $this->getRequest()->getParam('from');
|
33 |
+
|
34 |
+
if (empty($from) || $from === null) {
|
35 |
+
$ordersFeedProcessor->processOrders();
|
36 |
+
return;
|
37 |
+
} else {
|
38 |
+
try {
|
39 |
+
$date = new DateTime($from);
|
40 |
+
$ordersFeedProcessor->processOrders($from);
|
41 |
+
} catch (Exception $e) {
|
42 |
+
Fruugo_Integration_Helper_Logger::log("Force downloading new orders cancelled. Invalid from time parameter: " . $from);
|
43 |
+
echo "Force downloading new orders cancelled. Invalid from time parameter: " . $from;
|
44 |
+
}
|
45 |
+
}
|
46 |
+
}
|
47 |
+
}
|
app/code/community/Fruugo/Integration/controllers/PackinglistController.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/Defines.php';
|
24 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/Logger.php';
|
25 |
+
|
26 |
+
class Fruugo_Integration_PackinglistController extends Mage_Core_Controller_Front_Action
|
27 |
+
{
|
28 |
+
public function getPackingListAction()
|
29 |
+
{
|
30 |
+
$fruugoOrderId = $this->getRequest()->getParam('fruugoOrderId');
|
31 |
+
$shipmentId = $this->getRequest()->getParam('shipmentId');
|
32 |
+
|
33 |
+
Fruugo_Integration_Helper_Logger::log("Downloading fruugo order packing list ". $fruugoOrderId . ', ' . $shipmentId);
|
34 |
+
|
35 |
+
$apiUrl = Fruugo_Integration_Helper_Defines::FRUUGO_ORDERS_ENDPOINT;
|
36 |
+
|
37 |
+
$devMode = Mage::getStoreConfig('integration_options/orders_options/dev_mode');
|
38 |
+
if ($devMode == '1') {
|
39 |
+
$apiUrl = Mage::getStoreConfig('integration_options/orders_options/order_api_url');
|
40 |
+
}
|
41 |
+
|
42 |
+
$username = Mage::getStoreConfig('integration_options/orders_options/username');
|
43 |
+
$password = Mage::getStoreConfig('integration_options/orders_options/password');
|
44 |
+
|
45 |
+
$apiUrl .= "/packinglist?orderId=". $fruugoOrderId . "&shipmentId=".$shipmentId;
|
46 |
+
|
47 |
+
try {
|
48 |
+
$ch = curl_init($apiUrl);
|
49 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
50 |
+
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
|
51 |
+
$response = curl_exec($ch);
|
52 |
+
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
53 |
+
curl_close($ch);
|
54 |
+
|
55 |
+
if ($httpcode != 200) {
|
56 |
+
throw new Exception("Failed to download fruugo order packing list from the Fruugo API at the URL $apiUrl. Error: " . $response);
|
57 |
+
}
|
58 |
+
|
59 |
+
$filename = 'fruugo_packinglist_order_'.$fruugoOrderId.'_shipment_'.$shipmentId.'_'.date("Y_m_d_H_i_s").'.pdf';
|
60 |
+
|
61 |
+
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
62 |
+
header('Content-Description: File Transfer');
|
63 |
+
header("Content-type: application/pdf");
|
64 |
+
header("Content-Disposition: attachment; filename={$filename}");
|
65 |
+
header("Expires: 0");
|
66 |
+
header("Pragma: public");
|
67 |
+
|
68 |
+
$packinglistFile = fopen('php://output', 'w');
|
69 |
+
fwrite($packinglistFile, $response);
|
70 |
+
fclose($packinglistFile);
|
71 |
+
|
72 |
+
exit;
|
73 |
+
} catch (Exception $ex) {
|
74 |
+
Mage::logException($ex);
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
app/code/community/Fruugo/Integration/controllers/ProductsController.php
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/ProductsFeedGenerator.php';
|
24 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/FruugoCountriesSeeder.php';
|
25 |
+
|
26 |
+
class Fruugo_Integration_ProductsController extends Mage_Core_Controller_Front_Action
|
27 |
+
{
|
28 |
+
public function indexAction()
|
29 |
+
{
|
30 |
+
$productsFeedGenerator = new Fruugo_Integration_ProductsFeedGenerator();
|
31 |
+
$productsXml = $productsFeedGenerator->generateProdcutsFeed(false);
|
32 |
+
$outputDir = Mage::getModuleDir('', 'Fruugo_Integration') . '/controllers/products.xml';
|
33 |
+
$productsFeedFile = fopen($outputDir, "w");
|
34 |
+
fwrite($productsFeedFile, $productsXml->asXML());
|
35 |
+
fclose($productsFeedFile);
|
36 |
+
$this->getResponse()->setHeader('Content-type', 'text/xml');
|
37 |
+
$this->getResponse()->setBody($productsXml->asXML());
|
38 |
+
}
|
39 |
+
|
40 |
+
public function dataFeedAction()
|
41 |
+
{
|
42 |
+
$productsFeedGenerator = new Fruugo_Integration_ProductsFeedGenerator();
|
43 |
+
$cachedFile = $productsFeedGenerator->generateProdcutsFeed(true);
|
44 |
+
|
45 |
+
$this->getResponse()
|
46 |
+
->setHttpResponseCode(200)
|
47 |
+
->setHeader('Pragma', 'public', true)
|
48 |
+
->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
|
49 |
+
->setHeader('Content-type', 'application/force-download')
|
50 |
+
->setHeader('Content-Length', filesize($cachedFile))
|
51 |
+
->setHeader('Content-Disposition', 'filename=' . basename($cachedFile));
|
52 |
+
$this->getResponse()->clearBody();
|
53 |
+
$this->getResponse()->sendHeaders();
|
54 |
+
readfile($cachedFile);
|
55 |
+
exit;
|
56 |
+
}
|
57 |
+
|
58 |
+
public function onCountriesSavedAction()
|
59 |
+
{
|
60 |
+
$countries = $this->getRequest()->getParam('allowed-countries');
|
61 |
+
$productId = $this->getRequest()->getParam('productId');
|
62 |
+
$offFruugo = $this->getRequest()->getParam('disable-prd-fruugo');
|
63 |
+
|
64 |
+
if (isset($productId) && $productId != null) {
|
65 |
+
$allowedCountries = '';
|
66 |
+
|
67 |
+
if ($offFruugo == 'checked') {
|
68 |
+
$allowedCountries = 'Disabled';
|
69 |
+
} elseif (!empty($countries)) {
|
70 |
+
foreach ($countries as $country) {
|
71 |
+
$allowedCountries .= $country . ' ';
|
72 |
+
}
|
73 |
+
|
74 |
+
$allowedCountries = trim($allowedCountries);
|
75 |
+
}
|
76 |
+
|
77 |
+
if (!empty($allowedCountries)) {
|
78 |
+
$currentDate = new DateTime('NOW');
|
79 |
+
$currentDateStr = $currentDate->format('Y-m-d H:i:s');
|
80 |
+
|
81 |
+
try {
|
82 |
+
$productCountries = Mage::getModel('integration/countries')->load($productId, 'product_id');
|
83 |
+
$existingId = isset($productCountries) ? $productCountries->getProductId() : null;
|
84 |
+
if (!empty($existingId)) {
|
85 |
+
$productCountries->setFruugoCountries($allowedCountries);
|
86 |
+
$productCountries->setUpdatedAt($currentDateStr);
|
87 |
+
} else {
|
88 |
+
$data = array(
|
89 |
+
'product_id' => $productId,
|
90 |
+
'fruugo_countries' => $allowedCountries,
|
91 |
+
'created_at' => $currentDateStr
|
92 |
+
);
|
93 |
+
$productCountries = Mage::getModel('integration/countries')->setData($data);
|
94 |
+
}
|
95 |
+
$productCountries->save();
|
96 |
+
} catch (Exception $e) {
|
97 |
+
Mage::logException($e);
|
98 |
+
}
|
99 |
+
} else {
|
100 |
+
$productCountries = Mage::getModel('integration/countries')->load($productId, 'product_id');
|
101 |
+
if (isset($productCountries) && $productCountries->getProductId() != null) {
|
102 |
+
$productCountries->delete();
|
103 |
+
}
|
104 |
+
}
|
105 |
+
}
|
106 |
+
$this->_redirectReferer();
|
107 |
+
}
|
108 |
+
|
109 |
+
public function onCountriesRefreshedAction()
|
110 |
+
{
|
111 |
+
Fruugo_Integration_Helper_FruugoCountriesSeeder::getFruugoCountries();
|
112 |
+
$this->_redirectReferer();
|
113 |
+
}
|
114 |
+
}
|
app/code/community/Fruugo/Integration/data/fruugo_attributes_setup/data-install-0.1.1.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/Logger.php';
|
24 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/Defines.php';
|
25 |
+
require_once Mage::getModuleDir('', 'Fruugo_Integration') . '/Helper/FruugoCountriesSeeder.php';
|
26 |
+
|
27 |
+
try {
|
28 |
+
Fruugo_Integration_Helper_Logger::log('Running Fruugo plugin data script.');
|
29 |
+
// create a new store for Fruugo orders
|
30 |
+
Mage::registry('isSecureArea');
|
31 |
+
$website_id = Mage::app()->getWebsite()->getId();
|
32 |
+
$rootCategoryId = Mage::getModel('core/store')->load(Mage_Core_Model_App::DISTRO_STORE_ID)->getRootCategoryId();
|
33 |
+
|
34 |
+
$fruugoStoreExists = false;
|
35 |
+
$stores = Mage::app()->getStores();
|
36 |
+
|
37 |
+
foreach ($stores as $id => $store) {
|
38 |
+
if ($store->getCode() == 'fruugo') {
|
39 |
+
$fruugoStoreExists = true;
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
if (!$fruugoStoreExists) {
|
44 |
+
// add store group
|
45 |
+
$storeGroup = Mage::getModel('core/store_group');
|
46 |
+
$storeGroup->setWebsiteId($website_id)
|
47 |
+
->setName('Fruugo')
|
48 |
+
->setRootCategoryId($rootCategoryId)
|
49 |
+
->save();
|
50 |
+
|
51 |
+
// add store
|
52 |
+
$store = Mage::getModel('core/store');
|
53 |
+
$store->setCode('fruugo')
|
54 |
+
->setWebsiteId($storeGroup->getWebsiteId())
|
55 |
+
->setGroupId($storeGroup->getId())
|
56 |
+
->setName('Fruugo Orders')
|
57 |
+
->setIsActive(1)
|
58 |
+
->save();
|
59 |
+
}
|
60 |
+
|
61 |
+
// pulling Fruugo countries xml
|
62 |
+
Fruugo_Integration_Helper_FruugoCountriesSeeder::getFruugoCountries();
|
63 |
+
} catch (Exception $e) {
|
64 |
+
Fruugo_Integration_Helper_Logger::log('Error running Fruugo plugin data script. Detail: ' . $e);
|
65 |
+
}
|
app/code/community/Fruugo/Integration/design/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/design/adminhtml/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/design/adminhtml/default/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/design/adminhtml/default/default/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/design/adminhtml/default/default/layout/integration.xml
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
7 |
+
*
|
8 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
9 |
+
*
|
10 |
+
* This program is free software: you can redistribute it and/or modify
|
11 |
+
* it under the terms of the GNU General Public License as published by
|
12 |
+
* the Free Software Foundation, either version 3 of the License, or
|
13 |
+
* (at your option) any later version.
|
14 |
+
*
|
15 |
+
* This program is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
18 |
+
* See the GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
21 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*/
|
23 |
+
-->
|
24 |
+
<layout>
|
25 |
+
<adminhtml_sales_order_view>
|
26 |
+
<reference name="sales_order_tabs">
|
27 |
+
<action method="addTab">
|
28 |
+
<name>FruugoOrderPackingList</name>
|
29 |
+
<block>integration/Sales_Order_View_Tabs</block>
|
30 |
+
</action>
|
31 |
+
</reference>
|
32 |
+
</adminhtml_sales_order_view>
|
33 |
+
<adminhtml_catalog_product_edit>
|
34 |
+
<reference name="product_tabs">
|
35 |
+
<action method="addTab">
|
36 |
+
<name>AllowedCountriesOnFruugo</name>
|
37 |
+
<block>integration/Catalog_Product_Tab</block>
|
38 |
+
</action>
|
39 |
+
</reference>
|
40 |
+
</adminhtml_catalog_product_edit>
|
41 |
+
</layout>
|
app/code/community/Fruugo/Integration/design/adminhtml/default/default/template/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/design/adminhtml/default/default/template/integration/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/design/adminhtml/default/default/template/integration/catalog/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/design/adminhtml/default/default/template/integration/catalog/product/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/design/adminhtml/default/default/template/integration/catalog/product/fruugo-allowed-countries.phtml
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
-->
|
23 |
+
<style>
|
24 |
+
#prd-country-select { min-height:200px; min-width:200px; margin-bottom: 10px; }
|
25 |
+
#restrict-prd-country::-moz-focus-inner { padding:0; border:0; } /* FF Fix */
|
26 |
+
#restrict-prd-country { -webkit-border-fit:lines; } /* <- Safari & Google Chrome Fix */
|
27 |
+
#restrict-prd-country,
|
28 |
+
.form-button { border-width:1px; border-style:solid; border-color:#ed6502 #a04300 #a04300 #ed6502; padding:1px 7px 2px 7px; background:#ffac47 url(images/btn_bg.gif) repeat-x 0 100%; color:#fff; font:bold 12px arial, helvetica, sans-serif; cursor:pointer; text-align:center !important; white-space:nowrap; }
|
29 |
+
#restrict-prd-country:hover { background:#f77c16 url(images/btn_over_bg.gif) repeat-x 0 0; }
|
30 |
+
#restrict-prd-country:active { background:#f77c16 url(images/btn_on_bg.gif) repeat-x 0 0; }
|
31 |
+
#restrict-prd-country span { line-height:1.35em; background-repeat:no-repeat; background-position:0 50%; }
|
32 |
+
#restrict-prd-country span span { background:none !important; padding:0 !important; margin:0 !important; display:inline !important; }
|
33 |
+
</style>
|
34 |
+
<?php
|
35 |
+
echo '<h4>Select the countries to restrict the product display on Fruugo. Please only use if this product differs from your standard account settings.</h4>';
|
36 |
+
echo $this->getCountrySelectForm();
|
37 |
+
echo '<p>Please click the Submit button to save.</p>';
|
app/code/community/Fruugo/Integration/design/adminhtml/default/default/template/integration/sales/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/design/adminhtml/default/default/template/integration/sales/order/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/design/adminhtml/default/default/template/integration/sales/order/view/.DS_Store
ADDED
Binary file
|
app/code/community/Fruugo/Integration/design/adminhtml/default/default/template/integration/sales/order/view/tab/packinglist.phtml
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
-->
|
23 |
+
<?php
|
24 |
+
|
25 |
+
echo '<p>Fruugo Order Id: ' . $this->getFruugoOrderId() . '</p>';
|
26 |
+
echo '<p>Order Items:</p>';
|
27 |
+
|
28 |
+
$order = $this->getOrder();
|
29 |
+
foreach($order->getAllItems() as $orderItem) {
|
30 |
+
echo '<p>Fruugo Product Id: ' . $orderItem->getFruugoProductId() . '</p>';
|
31 |
+
echo '<p>Fruugo Sku: ' . $orderItem->getFruugoSkuId() . '</p>';
|
32 |
+
}
|
33 |
+
|
34 |
+
$fruugoOrderId = $this->getFruugoOrderId();
|
35 |
+
$shipmentIds = $order->getFruugoShipmentIds();
|
36 |
+
|
37 |
+
if (count($shipmentIds) > 0)
|
38 |
+
{
|
39 |
+
foreach ($shipmentIds as $shipmentId)
|
40 |
+
{
|
41 |
+
$link = '<p><a href="';
|
42 |
+
|
43 |
+
$link .= Mage::getUrl('integration/packinglist/getPackingList', array('fruugoOrderId'=>$fruugoOrderId, 'shipmentId'=>$shipmentId));
|
44 |
+
|
45 |
+
$link .= '">Download Packing List</a></p>';
|
46 |
+
|
47 |
+
echo $link;
|
48 |
+
}
|
49 |
+
}
|
app/code/community/Fruugo/Integration/etc/config.xml
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
7 |
+
*
|
8 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
9 |
+
*
|
10 |
+
* This program is free software: you can redistribute it and/or modify
|
11 |
+
* it under the terms of the GNU General Public License as published by
|
12 |
+
* the Free Software Foundation, either version 3 of the License, or
|
13 |
+
* (at your option) any later version.
|
14 |
+
*
|
15 |
+
* This program is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
18 |
+
* See the GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
21 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*/
|
23 |
+
-->
|
24 |
+
<config>
|
25 |
+
<modules>
|
26 |
+
<Fruugo_Integration>
|
27 |
+
<version>1.0.0</version> <!-- Version number of your module -->
|
28 |
+
</Fruugo_Integration>
|
29 |
+
</modules>
|
30 |
+
<global>
|
31 |
+
<models>
|
32 |
+
<integration>
|
33 |
+
<class>Fruugo_Integration_Model</class>
|
34 |
+
<resourceModel>integration_resource</resourceModel>
|
35 |
+
</integration>
|
36 |
+
<integration_resource>
|
37 |
+
<class>Fruugo_Integration_Model_Resource</class>
|
38 |
+
<entities>
|
39 |
+
<shipment>
|
40 |
+
<table>fruugo_shipment</table>
|
41 |
+
</shipment>
|
42 |
+
<countries>
|
43 |
+
<table>fruugo_product_countries</table>
|
44 |
+
</countries>
|
45 |
+
</entities>
|
46 |
+
</integration_resource>
|
47 |
+
</models>
|
48 |
+
<helpers>
|
49 |
+
<integration>
|
50 |
+
<class>Fruugo_Integration_Helper</class>
|
51 |
+
</integration>
|
52 |
+
</helpers>
|
53 |
+
<resources>
|
54 |
+
<fruugo_attributes_setup>
|
55 |
+
<setup>
|
56 |
+
<module>Fruugo_Integration</module>
|
57 |
+
<class>Mage_Eav_Model_Entity_Setup</class>
|
58 |
+
</setup>
|
59 |
+
</fruugo_attributes_setup>
|
60 |
+
</resources>
|
61 |
+
<blocks>
|
62 |
+
<integration>
|
63 |
+
<class>Fruugo_Integration_Block</class>
|
64 |
+
</integration>
|
65 |
+
</blocks>
|
66 |
+
<fieldsets>
|
67 |
+
<sales_convert_quote>
|
68 |
+
<fruugo_order_id>
|
69 |
+
<to_order>*</to_order>
|
70 |
+
</fruugo_order_id>
|
71 |
+
</sales_convert_quote>
|
72 |
+
<sales_convert_quote_item>
|
73 |
+
<fruugo_product_id>
|
74 |
+
<to_order_item>*</to_order_item>
|
75 |
+
</fruugo_product_id>
|
76 |
+
<fruugo_sku_id>
|
77 |
+
<to_order_item>*</to_order_item>
|
78 |
+
</fruugo_sku_id>
|
79 |
+
</sales_convert_quote_item>
|
80 |
+
</fieldsets>
|
81 |
+
</global>
|
82 |
+
<frontend>
|
83 |
+
<routers>
|
84 |
+
<integration>
|
85 |
+
<use>standard</use>
|
86 |
+
<args>
|
87 |
+
<module>Fruugo_Integration</module>
|
88 |
+
<frontName>fruugo-integration</frontName>
|
89 |
+
</args>
|
90 |
+
</integration>
|
91 |
+
</routers>
|
92 |
+
</frontend>
|
93 |
+
<admin>
|
94 |
+
<routers>
|
95 |
+
<adminhtml>
|
96 |
+
<args>
|
97 |
+
<modules>
|
98 |
+
<integration after="Mage_Adminhtml">Fruugo_Integration</integration>
|
99 |
+
</modules>
|
100 |
+
</args>
|
101 |
+
</adminhtml>
|
102 |
+
</routers>
|
103 |
+
</admin>
|
104 |
+
<adminhtml>
|
105 |
+
<layout>
|
106 |
+
<updates>
|
107 |
+
<integration>
|
108 |
+
<file>integration.xml</file>
|
109 |
+
</integration>
|
110 |
+
</updates>
|
111 |
+
</layout>
|
112 |
+
<acl>
|
113 |
+
<resources>
|
114 |
+
<all>
|
115 |
+
<title>Allow Everything</title>
|
116 |
+
</all>
|
117 |
+
<admin>
|
118 |
+
<children>
|
119 |
+
<system>
|
120 |
+
<children>
|
121 |
+
<config>
|
122 |
+
<children>
|
123 |
+
<integration_options>
|
124 |
+
<title>Integration Options</title>
|
125 |
+
</integration_options>
|
126 |
+
</children>
|
127 |
+
</config>
|
128 |
+
</children>
|
129 |
+
</system>
|
130 |
+
</children>
|
131 |
+
</admin>
|
132 |
+
</resources>
|
133 |
+
</acl>
|
134 |
+
</adminhtml>
|
135 |
+
<default>
|
136 |
+
<integration_options>
|
137 |
+
<products_options>
|
138 |
+
<export_frequency>12</export_frequency>
|
139 |
+
<descrption_type>long</descrption_type>
|
140 |
+
</products_options>
|
141 |
+
<orders_options>
|
142 |
+
<fetch_frequency>4</fetch_frequency>
|
143 |
+
<payment_method>checkmo</payment_method>
|
144 |
+
</orders_options>
|
145 |
+
</integration_options>
|
146 |
+
</default>
|
147 |
+
<crontab>
|
148 |
+
<jobs>
|
149 |
+
<export_products>
|
150 |
+
<run>
|
151 |
+
<model>integration/CronJobObserver::exportProducts</model>
|
152 |
+
</run>
|
153 |
+
</export_products>
|
154 |
+
<download_orders>
|
155 |
+
<run>
|
156 |
+
<model>integration/CronJobObserver::downloadOrders</model>
|
157 |
+
</run>
|
158 |
+
</download_orders>
|
159 |
+
</jobs>
|
160 |
+
</crontab>
|
161 |
+
</config>
|
app/code/community/Fruugo/Integration/etc/system.xml
ADDED
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
7 |
+
*
|
8 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
9 |
+
*
|
10 |
+
* This program is free software: you can redistribute it and/or modify
|
11 |
+
* it under the terms of the GNU General Public License as published by
|
12 |
+
* the Free Software Foundation, either version 3 of the License, or
|
13 |
+
* (at your option) any later version.
|
14 |
+
*
|
15 |
+
* This program is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
18 |
+
* See the GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
21 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*/
|
23 |
+
-->
|
24 |
+
<config>
|
25 |
+
<tabs>
|
26 |
+
<integration translate="label" module="integration">
|
27 |
+
<label>Fruugo Integration</label>
|
28 |
+
<sort_order>100</sort_order>
|
29 |
+
</integration>
|
30 |
+
</tabs>
|
31 |
+
<sections>
|
32 |
+
<integration_options translate="label" module="integration">
|
33 |
+
<label>Integration Options</label>
|
34 |
+
<tab>integration</tab>
|
35 |
+
<frontend_type>text</frontend_type>
|
36 |
+
<sort_order>1000</sort_order>
|
37 |
+
<show_in_default>1</show_in_default>
|
38 |
+
<show_in_website>1</show_in_website>
|
39 |
+
<show_in_store>1</show_in_store>
|
40 |
+
<expanded>1</expanded>
|
41 |
+
<groups>
|
42 |
+
<products_options translate="label" module="integration">
|
43 |
+
<label>Products XML Feed Options</label>
|
44 |
+
<frontend_type>text</frontend_type>
|
45 |
+
<sort_order>1000</sort_order>
|
46 |
+
<show_in_default>1</show_in_default>
|
47 |
+
<show_in_website>1</show_in_website>
|
48 |
+
<show_in_store>1</show_in_store>
|
49 |
+
<fields>
|
50 |
+
<export_frequency translate="label">
|
51 |
+
<label>Frequency</label>
|
52 |
+
<frontend_type>select</frontend_type>
|
53 |
+
<source_model>Fruugo_Integration_Model_Adminhtml_System_Config_Source_Hour</source_model>
|
54 |
+
<backend_model>Fruugo_Integration_Model_Adminhtml_System_Config_Backend_ProductCron</backend_model>
|
55 |
+
<sort_order>10</sort_order>
|
56 |
+
<show_in_default>1</show_in_default>
|
57 |
+
<show_in_website>1</show_in_website>
|
58 |
+
<show_in_store>1</show_in_store>
|
59 |
+
<comment>Set intervals of products xml feed generation</comment>
|
60 |
+
</export_frequency>
|
61 |
+
<descrption_type translate="label">
|
62 |
+
<label>Description Type</label>
|
63 |
+
<frontend_type>select</frontend_type>
|
64 |
+
<source_model>Fruugo_Integration_Model_Adminhtml_System_Config_Source_ProductDescriptionType</source_model>
|
65 |
+
<sort_order>20</sort_order>
|
66 |
+
<show_in_default>1</show_in_default>
|
67 |
+
<show_in_website>1</show_in_website>
|
68 |
+
<show_in_store>1</show_in_store>
|
69 |
+
<comment>Choose description and/or short description to be used for Fruugo product description</comment>
|
70 |
+
</descrption_type>
|
71 |
+
<refresh_countries translate="label">
|
72 |
+
<label>Refresh Fruugo Countries</label>
|
73 |
+
<frontend_type>button</frontend_type>
|
74 |
+
<frontend_model>integration/refreshcountriesbutton</frontend_model>
|
75 |
+
<sort_order>30</sort_order>
|
76 |
+
<show_in_default>1</show_in_default>
|
77 |
+
<show_in_website>1</show_in_website>
|
78 |
+
<show_in_store>1</show_in_store>
|
79 |
+
<comment>Refresh countries mulitple select list to restrict product display on Fruugo</comment>
|
80 |
+
</refresh_countries>
|
81 |
+
</fields>
|
82 |
+
</products_options>
|
83 |
+
<orders_options translate="label" module="integration">
|
84 |
+
<label>Orders Api Options</label>
|
85 |
+
<frontend_type>text</frontend_type>
|
86 |
+
<sort_order>2000</sort_order>
|
87 |
+
<show_in_default>1</show_in_default>
|
88 |
+
<show_in_website>1</show_in_website>
|
89 |
+
<show_in_store>1</show_in_store>
|
90 |
+
<fields>
|
91 |
+
<username translate="label">
|
92 |
+
<label>Username</label>
|
93 |
+
<frontend_type>text</frontend_type>
|
94 |
+
<sort_order>10</sort_order>
|
95 |
+
<show_in_default>1</show_in_default>
|
96 |
+
<show_in_website>1</show_in_website>
|
97 |
+
<show_in_store>1</show_in_store>
|
98 |
+
<comment>Fruugo orders API http authentication username</comment>
|
99 |
+
</username>
|
100 |
+
<password translate="label">
|
101 |
+
<label>Password</label>
|
102 |
+
<frontend_type>password</frontend_type>
|
103 |
+
<sort_order>20</sort_order>
|
104 |
+
<show_in_default>1</show_in_default>
|
105 |
+
<show_in_website>1</show_in_website>
|
106 |
+
<show_in_store>1</show_in_store>
|
107 |
+
<comment>Fruugo orders API http authentication password</comment>
|
108 |
+
</password>
|
109 |
+
<fetch_frequency translate="label">
|
110 |
+
<label>Frequency</label>
|
111 |
+
<frontend_type>select</frontend_type>
|
112 |
+
<source_model>Fruugo_Integration_Model_Adminhtml_System_Config_Source_Hour</source_model>
|
113 |
+
<backend_model>Fruugo_Integration_Model_Adminhtml_System_Config_Backend_OrderCron</backend_model>
|
114 |
+
<sort_order>30</sort_order>
|
115 |
+
<show_in_default>1</show_in_default>
|
116 |
+
<show_in_website>1</show_in_website>
|
117 |
+
<show_in_store>1</show_in_store>
|
118 |
+
<comment>Set intervals of fetching orders from Fruugo</comment>
|
119 |
+
</fetch_frequency>
|
120 |
+
<payment_method translate="label">
|
121 |
+
<label>Payment Method</label>
|
122 |
+
<frontend_type>select</frontend_type>
|
123 |
+
<source_model>Fruugo_Integration_Model_Adminhtml_System_Config_Source_OrderPaymentMethod</source_model>
|
124 |
+
<sort_order>40</sort_order>
|
125 |
+
<show_in_default>1</show_in_default>
|
126 |
+
<show_in_website>1</show_in_website>
|
127 |
+
<show_in_store>1</show_in_store>
|
128 |
+
<comment>Choose payment method for Fruugo order</comment>
|
129 |
+
</payment_method>
|
130 |
+
<dev_mode translate="label">
|
131 |
+
<label>Enable Development Mode</label>
|
132 |
+
<frontend_type>select</frontend_type>
|
133 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
134 |
+
<sort_order>50</sort_order>
|
135 |
+
<show_in_default>1</show_in_default>
|
136 |
+
<show_in_website>1</show_in_website>
|
137 |
+
<show_in_store>1</show_in_store>
|
138 |
+
<comment>Enable development mode for testing</comment>
|
139 |
+
</dev_mode>
|
140 |
+
<order_api_url translate="label">
|
141 |
+
<label>Fruugo orders API URL for testing</label>
|
142 |
+
<frontend_type>text</frontend_type>
|
143 |
+
<sort_order>60</sort_order>
|
144 |
+
<show_in_default>1</show_in_default>
|
145 |
+
<show_in_website>1</show_in_website>
|
146 |
+
<show_in_store>1</show_in_store>
|
147 |
+
<depends>
|
148 |
+
<dev_mode><value>1</value></dev_mode>
|
149 |
+
</depends>
|
150 |
+
<comment>Fruugo Orders Api for testing</comment>
|
151 |
+
</order_api_url>
|
152 |
+
<orders_endpoint_last_checked translate="label">
|
153 |
+
<frontend_type>hidden</frontend_type>
|
154 |
+
<sort_order>70</sort_order>
|
155 |
+
<show_in_default>1</show_in_default>
|
156 |
+
<show_in_website>1</show_in_website>
|
157 |
+
<show_in_store>1</show_in_store>
|
158 |
+
</orders_endpoint_last_checked>
|
159 |
+
</fields>
|
160 |
+
</orders_options>
|
161 |
+
</groups>
|
162 |
+
</integration_options>
|
163 |
+
</sections>
|
164 |
+
</config>
|
app/code/community/Fruugo/Integration/sql/fruugo_attributes_setup/install-0.1.1.php
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
|
23 |
+
$installer = new Mage_Sales_Model_Resource_Setup('core_setup');
|
24 |
+
$installer->addAttribute('order', 'fruugo_order_id', array(
|
25 |
+
'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
26 |
+
'label' => 'The Fruggo order ID for this order',
|
27 |
+
'visible' => true,
|
28 |
+
'required' => false,
|
29 |
+
'user_defined' => true,
|
30 |
+
'searchable' => true,
|
31 |
+
'filterable' => true,
|
32 |
+
'comparable' => true,
|
33 |
+
'default' => null,
|
34 |
+
'visible_on_front' => true
|
35 |
+
));
|
36 |
+
|
37 |
+
$installer->addAttribute('order_item', 'fruugo_product_id', array(
|
38 |
+
'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
39 |
+
'label' => 'The Fruggo product ID for this order item',
|
40 |
+
'visible' => true,
|
41 |
+
'required' => false,
|
42 |
+
'user_defined' => true,
|
43 |
+
'searchable' => true,
|
44 |
+
'filterable' => true,
|
45 |
+
'comparable' => true,
|
46 |
+
'default' => null,
|
47 |
+
'visible_on_front' => true
|
48 |
+
));
|
49 |
+
|
50 |
+
$installer->addAttribute('order_item', 'fruugo_sku_id', array(
|
51 |
+
'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
|
52 |
+
'label' => 'The Fruggo SKU for this order item',
|
53 |
+
'visible' => true,
|
54 |
+
'required' => false,
|
55 |
+
'user_defined' => true,
|
56 |
+
'searchable' => true,
|
57 |
+
'filterable' => true,
|
58 |
+
'comparable' => true,
|
59 |
+
'default' => null,
|
60 |
+
'visible_on_front' => true
|
61 |
+
));
|
62 |
+
|
63 |
+
$installer->endSetup();
|
64 |
+
|
65 |
+
$installer = $this;
|
66 |
+
|
67 |
+
if (!$installer->getConnection()->isTableExists('fruugo_shipment')) {
|
68 |
+
$installer->startSetup();
|
69 |
+
$table = $installer->getConnection()
|
70 |
+
->newTable($installer->getTable('integration/shipment'))
|
71 |
+
->addColumn('shipment_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
72 |
+
'identity' => true,
|
73 |
+
'unsigned' => true,
|
74 |
+
'nullable' => false,
|
75 |
+
'primary' => true,
|
76 |
+
), 'Id')
|
77 |
+
->addColumn('fruugo_shipment_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
78 |
+
'nullable' => false,
|
79 |
+
), 'ShipmentId')
|
80 |
+
->addColumn('fruugo_order_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
|
81 |
+
'nullable' => false,
|
82 |
+
), 'FruugoOrderId')
|
83 |
+
->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
|
84 |
+
'nullable' => true,
|
85 |
+
), 'CreatedAt')
|
86 |
+
->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
|
87 |
+
'nullable' => true,
|
88 |
+
), 'UpdatedAt');
|
89 |
+
|
90 |
+
$installer->getConnection()->createTable($table);
|
91 |
+
$installer->endSetup();
|
92 |
+
}
|
93 |
+
|
94 |
+
if (!$installer->getConnection()->isTableExists('fruugo_product_countries')) {
|
95 |
+
$installer->startSetup();
|
96 |
+
$table = $installer->getConnection()
|
97 |
+
->newTable($installer->getTable('integration/countries'))
|
98 |
+
->addColumn('fpc_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
99 |
+
'identity' => true,
|
100 |
+
'unsigned' => true,
|
101 |
+
'nullable' => false,
|
102 |
+
'primary' => true,
|
103 |
+
), 'Id')
|
104 |
+
->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
105 |
+
'nullable' => true,
|
106 |
+
), 'ProductId')
|
107 |
+
->addColumn('fruugo_countries', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
108 |
+
'nullable' => true,
|
109 |
+
), 'FruugoProductCountries')
|
110 |
+
->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
|
111 |
+
'nullable' => true,
|
112 |
+
), 'CreatedAt')
|
113 |
+
->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
|
114 |
+
'nullable' => true,
|
115 |
+
), 'UpdatedAt');
|
116 |
+
|
117 |
+
$installer->getConnection()->createTable($table);
|
118 |
+
$installer->endSetup();
|
119 |
+
}
|
app/design/adminhtml/default/default/layout/integration.xml
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
7 |
+
*
|
8 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
9 |
+
*
|
10 |
+
* This program is free software: you can redistribute it and/or modify
|
11 |
+
* it under the terms of the GNU General Public License as published by
|
12 |
+
* the Free Software Foundation, either version 3 of the License, or
|
13 |
+
* (at your option) any later version.
|
14 |
+
*
|
15 |
+
* This program is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
18 |
+
* See the GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
21 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*/
|
23 |
+
-->
|
24 |
+
<layout>
|
25 |
+
<adminhtml_sales_order_view>
|
26 |
+
<reference name="sales_order_tabs">
|
27 |
+
<action method="addTab">
|
28 |
+
<name>FruugoOrderPackingList</name>
|
29 |
+
<block>integration/Sales_Order_View_Tabs</block>
|
30 |
+
</action>
|
31 |
+
</reference>
|
32 |
+
</adminhtml_sales_order_view>
|
33 |
+
<adminhtml_catalog_product_edit>
|
34 |
+
<reference name="product_tabs">
|
35 |
+
<action method="addTab">
|
36 |
+
<name>AllowedCountriesOnFruugo</name>
|
37 |
+
<block>integration/Catalog_Product_Tab</block>
|
38 |
+
</action>
|
39 |
+
</reference>
|
40 |
+
</adminhtml_catalog_product_edit>
|
41 |
+
</layout>
|
app/design/adminhtml/default/default/template/integration/.DS_Store
ADDED
Binary file
|
app/design/adminhtml/default/default/template/integration/catalog/.DS_Store
ADDED
Binary file
|
app/design/adminhtml/default/default/template/integration/catalog/product/.DS_Store
ADDED
Binary file
|
app/design/adminhtml/default/default/template/integration/catalog/product/fruugo-allowed-countries.phtml
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
-->
|
23 |
+
<style>
|
24 |
+
#prd-country-select { min-height:200px; min-width:200px; margin-bottom: 10px; }
|
25 |
+
#restrict-prd-country::-moz-focus-inner { padding:0; border:0; } /* FF Fix */
|
26 |
+
#restrict-prd-country { -webkit-border-fit:lines; } /* <- Safari & Google Chrome Fix */
|
27 |
+
#restrict-prd-country,
|
28 |
+
.form-button { border-width:1px; border-style:solid; border-color:#ed6502 #a04300 #a04300 #ed6502; padding:1px 7px 2px 7px; background:#ffac47 url(images/btn_bg.gif) repeat-x 0 100%; color:#fff; font:bold 12px arial, helvetica, sans-serif; cursor:pointer; text-align:center !important; white-space:nowrap; }
|
29 |
+
#restrict-prd-country:hover { background:#f77c16 url(images/btn_over_bg.gif) repeat-x 0 0; }
|
30 |
+
#restrict-prd-country:active { background:#f77c16 url(images/btn_on_bg.gif) repeat-x 0 0; }
|
31 |
+
#restrict-prd-country span { line-height:1.35em; background-repeat:no-repeat; background-position:0 50%; }
|
32 |
+
#restrict-prd-country span span { background:none !important; padding:0 !important; margin:0 !important; display:inline !important; }
|
33 |
+
</style>
|
34 |
+
<?php
|
35 |
+
echo '<h4>Select the countries to restrict the product display on Fruugo. Please only use if this product differs from your standard account settings.</h4>';
|
36 |
+
echo $this->getCountrySelectForm();
|
37 |
+
echo '<p>Please click the Submit button to save.</p>';
|
app/design/adminhtml/default/default/template/integration/sales/.DS_Store
ADDED
Binary file
|
app/design/adminhtml/default/default/template/integration/sales/order/.DS_Store
ADDED
Binary file
|
app/design/adminhtml/default/default/template/integration/sales/order/view/.DS_Store
ADDED
Binary file
|
app/design/adminhtml/default/default/template/integration/sales/order/view/tab/packinglist.phtml
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
/**
|
3 |
+
* NOTICE OF LICENSE
|
4 |
+
*
|
5 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
6 |
+
*
|
7 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
8 |
+
*
|
9 |
+
* This program is free software: you can redistribute it and/or modify
|
10 |
+
* it under the terms of the GNU General Public License as published by
|
11 |
+
* the Free Software Foundation, either version 3 of the License, or
|
12 |
+
* (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This program is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
17 |
+
* See the GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
20 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*/
|
22 |
+
-->
|
23 |
+
<?php
|
24 |
+
|
25 |
+
echo '<p>Fruugo Order Id: ' . $this->getFruugoOrderId() . '</p>';
|
26 |
+
echo '<p>Order Items:</p>';
|
27 |
+
|
28 |
+
$order = $this->getOrder();
|
29 |
+
foreach($order->getAllItems() as $orderItem) {
|
30 |
+
echo '<p>Fruugo Product Id: ' . $orderItem->getFruugoProductId() . '</p>';
|
31 |
+
echo '<p>Fruugo Sku: ' . $orderItem->getFruugoSkuId() . '</p>';
|
32 |
+
}
|
33 |
+
|
34 |
+
$fruugoOrderId = $this->getFruugoOrderId();
|
35 |
+
$shipmentIds = $order->getFruugoShipmentIds();
|
36 |
+
|
37 |
+
if (count($shipmentIds) > 0)
|
38 |
+
{
|
39 |
+
foreach ($shipmentIds as $shipmentId)
|
40 |
+
{
|
41 |
+
$link = '<p><a href="';
|
42 |
+
|
43 |
+
$link .= Mage::getUrl('integration/packinglist/getPackingList', array('fruugoOrderId'=>$fruugoOrderId, 'shipmentId'=>$shipmentId));
|
44 |
+
|
45 |
+
$link .= '">Download Packing List</a></p>';
|
46 |
+
|
47 |
+
echo $link;
|
48 |
+
}
|
49 |
+
}
|
app/etc/modules/Fruugo_Integration.xml
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* NOTICE OF LICENSE
|
5 |
+
*
|
6 |
+
* Magento extension which extracts a product feed from Magento, imports the feed into Fruugo and uses the Fruugo Order API to export all Fruugo orders into Magento.
|
7 |
+
*
|
8 |
+
* Copyright (C) 2015 Fruugo.com Ltd
|
9 |
+
*
|
10 |
+
* This program is free software: you can redistribute it and/or modify
|
11 |
+
* it under the terms of the GNU General Public License as published by
|
12 |
+
* the Free Software Foundation, either version 3 of the License, or
|
13 |
+
* (at your option) any later version.
|
14 |
+
*
|
15 |
+
* This program is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
18 |
+
* See the GNU General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU General Public License along with this program.
|
21 |
+
* If not, see <http://www.gnu.org/licenses/>.
|
22 |
+
*/
|
23 |
+
-->
|
24 |
+
<config>
|
25 |
+
<modules>
|
26 |
+
<Fruugo_Integration>
|
27 |
+
<active>true</active>
|
28 |
+
<codePool>community</codePool>
|
29 |
+
<depends>
|
30 |
+
<Mage_Adminhtml/>
|
31 |
+
<Mage_Sales />
|
32 |
+
</depends>
|
33 |
+
</Fruugo_Integration>
|
34 |
+
</modules>
|
35 |
+
<global>
|
36 |
+
<models>
|
37 |
+
<Fruugo_Integration>
|
38 |
+
<class>Fruugo_Integration_Model_Observer</class>
|
39 |
+
</Fruugo_Integration>
|
40 |
+
</models>
|
41 |
+
<events>
|
42 |
+
<sales_order_save_before>
|
43 |
+
<observers>
|
44 |
+
<Fruugo_Integration_Model_Observer>
|
45 |
+
<type>singleton</type>
|
46 |
+
<class>Fruugo_Integration_Model_Observer</class>
|
47 |
+
<method>beforeSaveOrder</method>
|
48 |
+
</Fruugo_Integration_Model_Observer>
|
49 |
+
</observers>
|
50 |
+
</sales_order_save_before>
|
51 |
+
<sales_order_invoice_pay>
|
52 |
+
<observers>
|
53 |
+
<Fruugo_Integration_Model_Observer>
|
54 |
+
<type>singleton</type>
|
55 |
+
<class>Fruugo_Integration_Model_Observer</class>
|
56 |
+
<method>orderInvoiced</method>
|
57 |
+
</Fruugo_Integration_Model_Observer>
|
58 |
+
</observers>
|
59 |
+
</sales_order_invoice_pay>
|
60 |
+
<sales_order_item_cancel>
|
61 |
+
<observers>
|
62 |
+
<Fruugo_Integration_Model_Observer>
|
63 |
+
<type>singleton</type>
|
64 |
+
<class>Fruugo_Integration_Model_Observer</class>
|
65 |
+
<method>orderCancelled</method>
|
66 |
+
</Fruugo_Integration_Model_Observer>
|
67 |
+
</observers>
|
68 |
+
</sales_order_item_cancel>
|
69 |
+
<sales_order_shipment_save_after>
|
70 |
+
<observers>
|
71 |
+
<Fruugo_Integration_Model_Observer>
|
72 |
+
<type>singleton</type>
|
73 |
+
<class>Fruugo_Integration_Model_Observer</class>
|
74 |
+
<method>orderShipment</method>
|
75 |
+
</Fruugo_Integration_Model_Observer>
|
76 |
+
</observers>
|
77 |
+
</sales_order_shipment_save_after>
|
78 |
+
<sales_order_payment_refund>
|
79 |
+
<observers>
|
80 |
+
<Fruugo_Integration_Model_Observer>
|
81 |
+
<type>singleton</type>
|
82 |
+
<class>Fruugo_Integration_Model_Observer</class>
|
83 |
+
<method>orderRefunded</method>
|
84 |
+
</Fruugo_Integration_Model_Observer>
|
85 |
+
</observers>
|
86 |
+
</sales_order_payment_refund>
|
87 |
+
</events>
|
88 |
+
</global>
|
89 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Fruugo_Integration</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.gnu.org/licenses/">GNU</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>This is a plugin for Magento 1.8 - 1.9 that provides integration with the Fruugo products and orders API.</summary>
|
10 |
+
<description>This is a plugin for Magento 1.8 - 1.9 that provides integration with the Fruugo products and orders API.
|
11 |
+

|
12 |
+
This plugin mainly performs two tasks:
|
13 |
+

|
14 |
+
- Generate products xml feed from Magento periodically on a specified frequency.
|
15 |
+

|
16 |
+
- Read from Fruugo Rrders API periodically on a specified frequency, and notifies Magento order events to Fruugo Orders API.</description>
|
17 |
+
<notes>This is a plugin for Magento 1.8 - 1.9 that provides integration with the Fruugo products and orders API.</notes>
|
18 |
+
<authors><author><name>inoutput.io</name><user>inoutput</user><email>support@inoutput.io</email></author><author><name>fruugo.com</name><user>Fruugo</user><email>support@fruugo.com</email></author></authors>
|
19 |
+
<date>2015-08-01</date>
|
20 |
+
<time>14:19:25</time>
|
21 |
+
<contents><target name="magecommunity"><dir name="Fruugo"><dir name="Integration"><dir name="Block"><dir name="Catalog"><dir name="Product"><file name="Tab.php" hash="412d5a38c07f78fd56e3509809038008"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="a71b7917e305e5e1d3eb4270af2f4c0f"/></dir><file name="Refreshcountriesbutton.php" hash="5a7e3af708dd470725981ec187b2c07d"/><dir name="Sales"><dir name="Order"><dir name="View"><file name="Tabs.php" hash="d98faeeede3c06d5f28f8f9731438314"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="96d65b8df6dd703c05fd8e186aeaca8e"/></dir><file name=".DS_Store" hash="bbae86b9af10fdcbf50c8644074ed58c"/></dir><file name=".DS_Store" hash="26d674cc95490ff01df42facb067195e"/></dir><dir name="Helper"><file name="ConfigLoader.php" hash="f930d687b44fe0a3a9e70383e0500a7c"/><file name="Data.php" hash="866fe8e1ea50749218d6efcab8454f28"/><file name="Defines.php" hash="038845512a7e052d1a78ff7bae8d5223"/><file name="FruugoCountriesSeeder.php" hash="68949469a1b1ce6a605fccd132e9e3c0"/><file name="Logger.php" hash="ac482415c8c1bc6643c81779f3d580c7"/><file name="OrdersFeedProcessor.php" hash="22169b8147c5f0f550fbadcfd685c886"/><file name="ProductsFeedGenerator.php" hash="925303775a6a70f68e9b3467b9a4861b"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><file name="OrderCron.php" hash="8187697b999171b8940be7e5306a3bc7"/><file name="ProductCron.php" hash="a8bdd62ad14cdb85d9ef0ae2b85cecad"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Source"><file name="Hour.php" hash="fab1337425532af32cf8642b8b244930"/><file name="OrderPaymentMethod.php" hash="e6099a75b7b90b0f2ec23cc67adc88f9"/><file name="ProductDescriptionType.php" hash="578f3cec24605d376d4014cf1e38d8cd"/></dir><file name=".DS_Store" hash="31b6ce4b49f1589852adb4fb6ee80e6d"/></dir><file name=".DS_Store" hash="782e716ac0ede1e358eef842ea11a6e7"/></dir><file name=".DS_Store" hash="8d9a68bec4c8fd63565202d10541e71b"/></dir><file name="Countries.php" hash="a23378525c616fd87c5589933aec48c6"/><file name="CronJobObserver.php" hash="e8ddc80c37a3ef2b4ce025879f04e7c0"/><file name="Observer.php" hash="c70fcc89b827b7694d5474d3bef3d982"/><dir name="Resource"><dir name="Countries"><file name="Collection.php" hash="618a95f1535d4c63724a2f7eaebf6c2b"/></dir><file name="Countries.php" hash="dc3da7aec3c3472a4ccd73e2b2f255f0"/><dir name="Shipment"><file name="Collection.php" hash="66d038f890e36403f9ffb2e283e88daf"/></dir><file name="Shipment.php" hash="d8c13444ba5089cf606241f2c7c9a87d"/></dir><file name="Shipment.php" hash="23b1c0b4bc4e29cb137c9b3819723a63"/><file name=".DS_Store" hash="8d9d24e0109f860450c1177ba6d2c349"/></dir><dir name="controllers"><file name="OrdersController.php" hash="a2d9d2f4c916c376f146cfccecb4110d"/><file name="PackinglistController.php" hash="d76ac40e81f51635a073fb20492883f8"/><file name="ProductsController.php" hash="4bdd77b2e4c536eaa0a4c3c108871bf2"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/><file name=".gitignore" hash="acd4f929fc2eebc0a25a1b7a06b4f56f"/></dir><dir name="data"><dir name="fruugo_attributes_setup"><file name="data-install-0.1.1.php" hash="73a6210fdb6c5a2edfa0222a6a239e9a"/></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="integration.xml" hash="3f173b27f9f483c00b33b713c0bad737"/></dir><dir name="template"><dir name="integration"><dir name="catalog"><dir name="product"><file name="fruugo-allowed-countries.phtml" hash="066098b4583e6bd3882c01645bd9ed1d"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="4859d3f8a851fe27a09013a9b3c826e9"/></dir><dir name="sales"><dir name="order"><dir name="view"><dir name="tab"><file name="packinglist.phtml" hash="9ec64369d5c23043976b08573f3435dd"/></dir><file name=".DS_Store" hash="d26113bef03e4a93d3b16a9aacd87cfc"/></dir><file name=".DS_Store" hash="96bd4b45d72afef63db9e4ca6973ea7a"/></dir><file name=".DS_Store" hash="6ab1f047e942f2d939c7cccba9d7b5cf"/></dir><file name=".DS_Store" hash="5e3b5dca196bbd2c9702ade45af32abd"/></dir><file name=".DS_Store" hash="475750e5ce2da00a7ec22eab4ca53a23"/></dir><file name=".DS_Store" hash="28fc05e6ccd3e5bdd0adefd1bc7c7b7c"/></dir><file name=".DS_Store" hash="855f2a92ccf96475a00db4e3d0e4df01"/></dir><file name=".DS_Store" hash="3d0d0b6a6dd6a3990a86b24a0e6799f4"/></dir><file name=".DS_Store" hash="466e7eaa43e0d7602b4cf93b7e8e7c85"/></dir><dir name="etc"><file name="config.xml" hash="690898046a7be568878e9151e1bf11fa"/><file name="system.xml" hash="4b71753bf9baf263bd30b463c97c434f"/></dir><dir name="sql"><dir name="fruugo_attributes_setup"><file name="install-0.1.1.php" hash="326629d7305e3c3b20aaf8d97de1f17b"/></dir></dir><file name=".DS_Store" hash="9d606525894e5a9b2dd24af08eb738bf"/><file name=".gitignore" hash="f0cb20b35e2469e9e9617f658ed452a5"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="integration.xml" hash="3f173b27f9f483c00b33b713c0bad737"/></dir><dir name="template"><dir name="integration"><dir name="catalog"><dir name="product"><file name="fruugo-allowed-countries.phtml" hash="066098b4583e6bd3882c01645bd9ed1d"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="4859d3f8a851fe27a09013a9b3c826e9"/></dir><dir name="sales"><dir name="order"><dir name="view"><dir name="tab"><file name="packinglist.phtml" hash="9ec64369d5c23043976b08573f3435dd"/></dir><file name=".DS_Store" hash="d26113bef03e4a93d3b16a9aacd87cfc"/></dir><file name=".DS_Store" hash="96bd4b45d72afef63db9e4ca6973ea7a"/></dir><file name=".DS_Store" hash="6ab1f047e942f2d939c7cccba9d7b5cf"/></dir><file name=".DS_Store" hash="5e3b5dca196bbd2c9702ade45af32abd"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Fruugo_Integration.xml" hash="b01dcb5088d487517bd87af216d6d7c8"/></dir></target></contents>
|
22 |
+
<compatible/>
|
23 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.8</min><max>1.9</max></package></required></dependencies>
|
24 |
+
</package>
|