Version Notes
New version of Lengow's Connector
Download this release
Release Info
Developer | Ludovic |
Extension | Lengow_Export |
Version | 2.0.1.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.5 to 2.0.1.0
- app/code/community/Lengow/Dashboard/Block/Adminhtml/Dashboard/Charts.php +28 -0
- app/code/community/Lengow/Dashboard/Block/Adminhtml/Dashboard/Diagrams.php +29 -0
- app/code/community/Lengow/Dashboard/Helper/Data.php +10 -0
- app/code/community/Lengow/Dashboard/Model/Config.php +22 -0
- app/code/community/Lengow/Dashboard/etc/config.xml +78 -0
- app/code/community/Lengow/Export/Block/.DS_Store +0 -0
- app/code/community/Lengow/Export/Block/Adminhtml/Product.php +55 -0
- app/code/community/Lengow/Export/Block/Adminhtml/Product/Grid.php +205 -0
- app/code/community/Lengow/Export/Helper/Data.php +98 -0
- app/code/community/Lengow/Export/Helper/Security.php +59 -0
- app/code/community/Lengow/Export/Model/.DS_Store +0 -0
- app/code/community/Lengow/Export/Model/Catalog/Product.php +244 -0
- app/code/community/Lengow/Export/Model/Config.php +196 -0
- app/code/community/Lengow/Export/Model/Convert/Parser/Product.php +42 -0
- app/code/community/Lengow/Export/Model/Export/Rewrite/Catalog/Config.php +46 -0
- app/code/community/Lengow/Export/Model/Feed/Abstract.php +37 -0
- app/code/community/Lengow/Export/Model/Feed/Csv.php +102 -0
- app/code/community/Lengow/Export/Model/Feed/Json.php +35 -0
- app/code/community/Lengow/Export/Model/Feed/Xml.php +37 -0
- app/code/community/Lengow/Export/Model/Feed/Yaml.php +52 -0
- app/code/community/Lengow/Export/Model/Generate.php +406 -0
- app/code/community/Lengow/Export/Model/Observer.php +31 -0
- app/code/community/Lengow/Export/Model/Shipping/Carrier/Lengow.php +65 -0
- app/code/community/Lengow/Export/Model/Source/.DS_Store +0 -0
- app/code/community/Lengow/Export/Model/Source/Attributes.php +20 -0
- app/code/community/Lengow/Export/Model/Source/Types.php +20 -0
- app/code/community/Lengow/Export/Model/System/Config/Backend/Apikey.php +24 -0
- app/code/community/Lengow/Export/Model/System/Config/Source/Category/Level.php +33 -0
- app/code/community/Lengow/Export/Model/System/Config/Source/Format.php +34 -0
- app/code/community/Lengow/Export/Model/System/Config/Source/Getattributes.php +28 -0
- app/code/community/Lengow/Export/Model/System/Config/Source/Images.php +31 -0
- app/code/community/Lengow/Export/Model/System/Config/Source/Status.php +33 -0
- app/code/community/Lengow/Export/Model/System/Config/Source/Types.php +37 -0
- app/code/community/Lengow/Export/controllers/.DS_Store +0 -0
- app/code/community/Lengow/Export/controllers/Adminhtml/.DS_Store +0 -0
- app/code/community/Lengow/Export/controllers/Adminhtml/Lengow/ExportController.php +64 -0
- app/code/community/Lengow/Export/controllers/FeedController.php +53 -0
- app/code/community/Lengow/Export/etc/config.xml +169 -0
- app/code/community/Lengow/Export/etc/system.xml +243 -0
- app/code/community/Lengow/Feed/Block/Adminhtml/Feed.php +57 -0
- app/code/community/Lengow/Feed/Block/Adminhtml/Feed/Grid.php +204 -0
- app/code/community/Lengow/Feed/Block/Adminhtml/Feed/Renderer/Migrate.php +26 -0
- app/code/community/Lengow/Feed/Block/Adminhtml/Feed/Renderer/Select.php +54 -0
- app/code/community/Lengow/Feed/Block/Adminhtml/Feed/Renderer/Url.php +25 -0
- app/code/community/Lengow/Feed/Helper/Data.php +51 -0
- app/code/community/Lengow/Feed/Model/Config.php +26 -0
- app/code/community/Lengow/Feed/Model/Feed.php +121 -0
- app/code/community/Lengow/Feed/controllers/Adminhtml/Lengow/FeedController.php +84 -0
- app/code/community/Lengow/Feed/etc/config.xml +109 -0
- app/code/community/Lengow/Feed/etc/system.xml +40 -0
- app/code/community/Lengow/Sync/.DS_Store +0 -0
- app/code/community/Lengow/Sync/Block/.DS_Store +0 -0
- app/code/community/Lengow/Sync/Block/Adminhtml/Import.php +8 -0
- app/code/community/Lengow/Sync/Block/Adminhtml/Log.php +25 -0
- app/code/community/Lengow/Sync/Block/Adminhtml/Log/Grid.php +52 -0
- app/code/community/Lengow/Sync/Block/Adminhtml/Order.php +34 -0
- app/code/community/Lengow/Sync/Block/Adminhtml/Order/Grid.php +201 -0
- app/code/community/Lengow/Sync/Block/Adminhtml/Order/Tab.php +106 -0
- app/code/community/Lengow/Sync/Block/Payment/Info/Purchaseorder.php +18 -0
- app/code/community/Lengow/Sync/Helper/Data.php +103 -0
- app/code/community/Lengow/Sync/Model/.DS_Store +0 -0
- app/code/community/Lengow/Sync/Model/Config.php +104 -0
- app/code/community/Lengow/Sync/Model/Connector.php +299 -0
- app/code/community/Lengow/Sync/Model/Connector/Exception.php +58 -0
- app/code/community/Lengow/Sync/Model/Customer/Customer.php +88 -0
- app/code/community/Lengow/Sync/Model/Import.php +209 -0
- app/code/community/Lengow/Sync/Model/Log.php +32 -0
- app/code/community/Lengow/Sync/Model/Marketplace.php +264 -0
- app/code/community/Lengow/Sync/Model/Marketplace/Exception.php +59 -0
- app/code/community/Lengow/Sync/Model/Mysql4/.DS_Store +0 -0
- app/code/community/Lengow/Sync/Model/Mysql4/Log.php +16 -0
- app/code/community/Lengow/Sync/Model/Mysql4/Log/Collection.php +16 -0
- app/code/community/Lengow/Sync/Model/Observer.php +71 -0
- app/code/community/Lengow/Sync/Model/Order.php +374 -0
- app/code/community/Lengow/Sync/Model/Payment/.DS_Store +0 -0
- app/code/community/Lengow/Sync/Model/Payment/Method/Lengow.php +40 -0
- app/code/community/Lengow/Sync/Model/Quote/Item.php +111 -0
- app/code/community/Lengow/Sync/Model/Shipping/Carrier/Lengow.php +64 -0
- app/code/community/Lengow/Sync/controllers/.DS_Store +0 -0
- app/code/community/Lengow/Sync/controllers/Adminhtml/.DS_Store +0 -0
- app/code/community/Lengow/Sync/controllers/Adminhtml/Lengow/LogController.php +40 -0
- app/code/community/Lengow/Sync/controllers/Adminhtml/Lengow/OrderController.php +73 -0
- app/code/community/Lengow/Sync/controllers/ApiController.php +55 -0
- app/code/community/Lengow/Sync/etc/config.xml +269 -0
- app/code/community/Lengow/Sync/etc/marketplaces.xml +715 -0
- app/code/community/Lengow/Sync/etc/system.xml +86 -0
- app/code/community/Lengow/Sync/sql/lengow_setup/mysql4-install-2.0.0.0.php +185 -0
- app/code/community/Lengow/Sync/sql/lengow_setup/mysql4-upgrade-2.0.0.0-2.0.0.1.php +62 -0
- app/code/community/Lengow/Tracker/Block/.DS_Store +0 -0
- app/code/community/Lengow/Tracker/Block/Adminhtml/System/Config/Check.php +52 -0
- app/code/community/Lengow/Tracker/Block/Adminhtml/System/Config/Check/Point.php +55 -0
- app/code/community/Lengow/Tracker/Block/Tag/Capsule.php +234 -0
- app/code/community/Lengow/Tracker/Block/Tag/Simple.php +42 -0
- app/code/community/Lengow/Tracker/Block/Tracker.php +92 -0
- app/code/community/Lengow/Tracker/Helper/Check.php +86 -0
- app/code/community/Lengow/Tracker/Helper/Data.php +13 -0
- app/code/community/Lengow/Tracker/Model/Capsule.php +37 -0
- app/code/community/Lengow/Tracker/Model/Config.php +22 -0
- app/code/community/Lengow/Tracker/Model/System/Config/Source/Tracker.php +13 -0
- app/code/community/Lengow/Tracker/Model/Tracker.php +32 -0
- app/code/community/Lengow/Tracker/etc/.DS_Store +0 -0
- app/code/community/Lengow/Tracker/etc/config.xml +111 -0
- app/code/community/Lengow/Tracker/etc/plugins.xml +11 -0
- app/code/community/Lengow/Tracker/etc/system.xml +101 -0
- app/code/local/Lengow/Export/Helper/Data.php +0 -4
- app/code/local/Lengow/Export/Model/Observer.php +0 -0
- app/code/local/Lengow/Export/Model/Products.php +0 -96
- app/code/local/Lengow/Export/Model/System/Config/Source/Attributes.php +0 -19
- app/code/local/Lengow/Export/Model/System/Config/Source/Categories.php +0 -19
- app/code/local/Lengow/Export/Model/System/Config/Source/Description.php +0 -13
- app/code/local/Lengow/Export/Model/System/Config/Source/Price.php +0 -12
- app/code/local/Lengow/Export/controllers/IndexController.php +0 -165
- app/code/local/Lengow/Export/etc/config.xml +0 -55
- app/code/local/Lengow/Export/etc/system.xml +0 -41
- app/code/local/Lengow/Information/Helper/Data.php +0 -4
- app/code/local/Lengow/Information/etc/config.xml +0 -43
- app/code/local/Lengow/Information/etc/system.xml +0 -38
- app/design/adminhtml/default/default/layout/lengow.xml +75 -0
- app/design/adminhtml/default/default/template/lengow/.DS_Store +0 -0
- app/design/adminhtml/default/default/template/lengow/check/point.phtml +33 -0
- app/design/adminhtml/default/default/template/lengow/dashboard/charts.phtml +86 -0
- app/design/adminhtml/default/default/template/lengow/export/.DS_Store +0 -0
- app/design/adminhtml/default/default/template/lengow/export/product.phtml +22 -0
- app/design/adminhtml/default/default/template/lengow/feed/grid.phtml +55 -0
- app/design/adminhtml/default/default/template/lengow/sales/.DS_Store +0 -0
- app/design/adminhtml/default/default/template/lengow/sales/order/tab/info.phtml +42 -0
- app/design/adminhtml/default/default/template/lengow/sales/payment/info/purchaseorder.phtml +28 -0
- app/design/frontend/base/default/layout/lengow.xml +14 -0
- app/design/frontend/base/default/template/lengow/tracker/simpletag.phtml +4 -0
- app/design/frontend/base/default/template/lengow/tracker/tag.phtml +2 -0
- app/design/frontend/base/default/template/lengow/tracker/tagcapsule.phtml +31 -0
- app/etc/modules/Lengow_All.xml +0 -15
- app/etc/modules/Lengow_Connector.xml +72 -0
- app/locale/en_US/Lengow_Export.csv +0 -4
- app/locale/en_US/Lengow_Information.csv +0 -3
- app/locale/fr_FR/Lengow_Connector.csv +136 -0
- app/locale/fr_FR/Lengow_Export.csv +0 -4
- app/locale/fr_FR/Lengow_Information.csv +0 -3
- package.xml +11 -30
- skin/adminhtml/default/default/lengow/css/admin.css +89 -0
- skin/adminhtml/default/default/lengow/js/charts.min.js +39 -0
- skin/adminhtml/default/default/lengow/js/tracker.js +35 -0
app/code/community/Lengow/Dashboard/Block/Adminhtml/Dashboard/Charts.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Lengow_Tracker Tracking Block Capsule
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Tracker
|
8 |
+
* @author Romain Le Polh <romain@lengow.com>
|
9 |
+
*/
|
10 |
+
class Lengow_Dashboard_Block_Adminhtml_Dashboard_Charts extends Mage_Core_Block_Template {
|
11 |
+
|
12 |
+
protected $_data = array();
|
13 |
+
|
14 |
+
public function __construct() {
|
15 |
+
parent::__construct();
|
16 |
+
|
17 |
+
$this->setData('config_model', Mage::getSingleton('dashboard/config'));
|
18 |
+
$this->setData('id_client', $this->getData('config_model')->get('general/login'));
|
19 |
+
$this->setData('id_group', $this->getData('config_model')->get('general/group'));
|
20 |
+
$this->setData('api_key', $this->getData('config_model')->get('general/api_key'));
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _prepareLayout() {
|
24 |
+
parent::_prepareLayout();
|
25 |
+
$this->setTemplate('lengow/dashboard/charts.phtml');
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
}
|
app/code/community/Lengow/Dashboard/Block/Adminhtml/Dashboard/Diagrams.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow dashboard Block Dashboard diagrams
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Dashboard
|
7 |
+
* @author Romain Le Polh <romain@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
|
12 |
+
class Lengow_Dashboard_Block_Adminhtml_Dashboard_Diagrams extends Mage_Adminhtml_Block_Dashboard_Diagrams {
|
13 |
+
|
14 |
+
protected $_data = array();
|
15 |
+
|
16 |
+
public function __construct() {
|
17 |
+
parent::__construct();
|
18 |
+
}
|
19 |
+
|
20 |
+
protected function _prepareLayout(){
|
21 |
+
parent::_prepareLayout();
|
22 |
+
$this->addTab('lengow', array(
|
23 |
+
'label' => Mage::helper('adminhtml')->__('Lengow'),
|
24 |
+
'content' => $this->getLayout()->createBlock('dashboard/adminhtml_dashboard_charts')->toHtml(),
|
25 |
+
'active' => false
|
26 |
+
));
|
27 |
+
}
|
28 |
+
|
29 |
+
}
|
app/code/community/Lengow/Dashboard/Helper/Data.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow Dashboard Helper
|
4 |
+
* @category Lengow
|
5 |
+
* @package Lengow_Dashboard
|
6 |
+
* @author Romain Le Polh
|
7 |
+
*/
|
8 |
+
class Lengow_Dashboard_Helper_Data extends Mage_Core_Helper_Abstract {
|
9 |
+
|
10 |
+
}
|
app/code/community/Lengow/Dashboard/Model/Config.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Lengow dashboard model config
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Dashboard
|
8 |
+
* @author Romain Le Polh <romain@lengow.com>
|
9 |
+
* @copyright 2013 Lengow SAS
|
10 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
11 |
+
*/
|
12 |
+
class Lengow_Dashboard_Model_Config extends Varien_Object {
|
13 |
+
|
14 |
+
public function setStore($id_store) {
|
15 |
+
$this->_id_store = $id_store;
|
16 |
+
}
|
17 |
+
|
18 |
+
public function get($key) {
|
19 |
+
return Mage::getStoreConfig('tracker/' . $key, $this->_id_store);
|
20 |
+
}
|
21 |
+
|
22 |
+
}
|
app/code/community/Lengow/Dashboard/etc/config.xml
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Lengow_Dashboard>
|
5 |
+
<version>2.0.1.0</version>
|
6 |
+
</Lengow_Dashboard>
|
7 |
+
</modules>
|
8 |
+
<admin>
|
9 |
+
<routers>
|
10 |
+
<adminhtml>
|
11 |
+
<args>
|
12 |
+
<modules>
|
13 |
+
<dashboard before="Mage_Adminhtml">Lengow_Dashboard_Adminhtml</dashboard>
|
14 |
+
</modules>
|
15 |
+
</args>
|
16 |
+
</adminhtml>
|
17 |
+
</routers>
|
18 |
+
</admin>
|
19 |
+
<global>
|
20 |
+
<models>
|
21 |
+
<dashboard>
|
22 |
+
<class>Lengow_Dashboard_Model</class>
|
23 |
+
<resourceModel>dashboard_mysql4</resourceModel>
|
24 |
+
</dashboard>
|
25 |
+
<dashboard_mysql4>
|
26 |
+
<class>Lengow_Dashboard_Model_Mysql4</class>
|
27 |
+
<entities>
|
28 |
+
<manageorders_log>
|
29 |
+
<table>lengow_log</table>
|
30 |
+
</manageorders_log>
|
31 |
+
</entities>
|
32 |
+
</dashboard_mysql4>
|
33 |
+
</models>
|
34 |
+
<resources>
|
35 |
+
<dashboard_setup>
|
36 |
+
<connection>
|
37 |
+
<use>core_setup</use>
|
38 |
+
</connection>
|
39 |
+
</dashboard_setup>
|
40 |
+
<dashboard_write>
|
41 |
+
<connection>
|
42 |
+
<use>core_write</use>
|
43 |
+
</connection>
|
44 |
+
</dashboard_write>
|
45 |
+
<dashboard_read>
|
46 |
+
<connection>
|
47 |
+
<use>core_read</use>
|
48 |
+
</connection>
|
49 |
+
</dashboard_read>
|
50 |
+
</resources>
|
51 |
+
<blocks>
|
52 |
+
<adminhtml>
|
53 |
+
<rewrite>
|
54 |
+
<dashboard_diagrams>Lengow_Dashboard_Block_Adminhtml_Dashboard_Diagrams</dashboard_diagrams>
|
55 |
+
</rewrite>
|
56 |
+
</adminhtml>
|
57 |
+
<dashboard>
|
58 |
+
<class>Lengow_Dashboard_Block</class>
|
59 |
+
</dashboard>
|
60 |
+
</blocks>
|
61 |
+
<helpers>
|
62 |
+
<dashboard>
|
63 |
+
<class>Lengow_Dashboard_Helper</class>
|
64 |
+
</dashboard>
|
65 |
+
</helpers>
|
66 |
+
</global>
|
67 |
+
<adminhtml>
|
68 |
+
<translate>
|
69 |
+
<modules>
|
70 |
+
<Lengow_Dashboard>
|
71 |
+
<files>
|
72 |
+
<default>Lengow_Connector.csv</default>
|
73 |
+
</files>
|
74 |
+
</Lengow_Dashboard>
|
75 |
+
</modules>
|
76 |
+
</translate>
|
77 |
+
</adminhtml>
|
78 |
+
</config>
|
app/code/community/Lengow/Export/Block/.DS_Store
ADDED
Binary file
|
app/code/community/Lengow/Export/Block/Adminhtml/Product.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow select products block
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Export_Block_Adminhtml_Product extends Mage_Adminhtml_Block_Widget_Container {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Set template
|
15 |
+
*/
|
16 |
+
public function __construct() {
|
17 |
+
parent::__construct();
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Prepare button and grid
|
22 |
+
*
|
23 |
+
* @return Mage_Adminhtml_Block_Catalog_Product
|
24 |
+
*/
|
25 |
+
protected function _prepareLayout() {
|
26 |
+
$this->_addButton('export', array(
|
27 |
+
'label' => Mage::helper('catalog')->__('Export'),
|
28 |
+
'onclick' => 'popWin(\''.$this->getUrl('lengow/feed').'\', \'_blank\')',
|
29 |
+
'class' => 'add'
|
30 |
+
));
|
31 |
+
$this->setChild('grid', $this->getLayout()->createBlock('export/adminhtml_product_grid', 'product.grid'));
|
32 |
+
return parent::_prepareLayout();
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Render grid
|
37 |
+
*
|
38 |
+
* @return string
|
39 |
+
*/
|
40 |
+
public function getGridHtml() {
|
41 |
+
return $this->getChildHtml('grid');
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Check whether it is single store mode
|
46 |
+
*
|
47 |
+
* @return bool
|
48 |
+
*/
|
49 |
+
public function isSingleStoreMode() {
|
50 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
51 |
+
return false;
|
52 |
+
}
|
53 |
+
return true;
|
54 |
+
}
|
55 |
+
}
|
app/code/community/Lengow/Export/Block/Adminhtml/Product/Grid.php
ADDED
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow grid products block
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Export_Block_Adminhtml_Product_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
12 |
+
|
13 |
+
public function __construct() {
|
14 |
+
parent::__construct();
|
15 |
+
$this->setId('productGrid');
|
16 |
+
$this->setDefaultSort('entity_id');
|
17 |
+
$this->setDefaultDir('desc');
|
18 |
+
$this->setSaveParametersInSession(true);
|
19 |
+
$this->setUseAjax(true);
|
20 |
+
$this->setVarNameFilter('product_filter');
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _getStore() {
|
24 |
+
$storeId = (int) $this->getRequest()->getParam('store', 0);
|
25 |
+
return Mage::app()->getStore($storeId);
|
26 |
+
}
|
27 |
+
|
28 |
+
protected function _prepareCollection() {
|
29 |
+
$store = $this->_getStore();
|
30 |
+
$collection = Mage::getModel('catalog/product')->getCollection()
|
31 |
+
->addAttributeToSelect('sku')
|
32 |
+
->addAttributeToSelect('name')
|
33 |
+
->addAttributeToSelect('lengow_product')
|
34 |
+
->addAttributeToSelect('attribute_set_id')
|
35 |
+
->addAttributeToSelect('type_id')
|
36 |
+
->joinField('qty',
|
37 |
+
'cataloginventory/stock_item',
|
38 |
+
'qty',
|
39 |
+
'product_id=entity_id',
|
40 |
+
'{{table}}.stock_id=1',
|
41 |
+
'left');
|
42 |
+
|
43 |
+
if ($store->getId()) {
|
44 |
+
//$collection->setStoreId($store->getId());
|
45 |
+
$collection->addStoreFilter($store);
|
46 |
+
$collection->joinAttribute('custom_name', 'catalog_product/name', 'entity_id', null, 'inner', $store->getId());
|
47 |
+
$collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner', $store->getId());
|
48 |
+
$collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner', $store->getId());
|
49 |
+
$collection->joinAttribute('price', 'catalog_product/price', 'entity_id', null, 'left', $store->getId());
|
50 |
+
} else {
|
51 |
+
$collection->addAttributeToSelect('price');
|
52 |
+
$collection->addAttributeToSelect('status');
|
53 |
+
$collection->addAttributeToSelect('visibility');
|
54 |
+
}
|
55 |
+
$this->setCollection($collection);
|
56 |
+
parent::_prepareCollection();
|
57 |
+
$this->getCollection()->addWebsiteNamesToResult();
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
|
61 |
+
protected function _addColumnFilterToCollection($column) {
|
62 |
+
if ($this->getCollection()) {
|
63 |
+
if ($column->getId() == 'websites') {
|
64 |
+
$this->getCollection()->joinField('websites',
|
65 |
+
'catalog/product_website',
|
66 |
+
'website_id',
|
67 |
+
'product_id=entity_id',
|
68 |
+
null,
|
69 |
+
'left');
|
70 |
+
}
|
71 |
+
}
|
72 |
+
return parent::_addColumnFilterToCollection($column);
|
73 |
+
}
|
74 |
+
|
75 |
+
protected function _prepareColumns() {
|
76 |
+
$this->addColumn('entity_id',
|
77 |
+
array(
|
78 |
+
'header'=> Mage::helper('catalog')->__('ID'),
|
79 |
+
'width' => '50px',
|
80 |
+
'type' => 'number',
|
81 |
+
'index' => 'entity_id',
|
82 |
+
));
|
83 |
+
$this->addColumn('name',
|
84 |
+
array(
|
85 |
+
'header'=> Mage::helper('catalog')->__('Name'),
|
86 |
+
'index' => 'name',
|
87 |
+
));
|
88 |
+
$store = $this->_getStore();
|
89 |
+
if ($store->getId()) {
|
90 |
+
$this->addColumn('custom_name',
|
91 |
+
array(
|
92 |
+
'header'=> Mage::helper('catalog')->__('Name In %s', $store->getName()),
|
93 |
+
'index' => 'custom_name',
|
94 |
+
));
|
95 |
+
}
|
96 |
+
$this->addColumn('type',
|
97 |
+
array(
|
98 |
+
'header'=> Mage::helper('catalog')->__('Type'),
|
99 |
+
'width' => '60px',
|
100 |
+
'index' => 'type_id',
|
101 |
+
'type' => 'options',
|
102 |
+
'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
|
103 |
+
));
|
104 |
+
$sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
|
105 |
+
->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
|
106 |
+
->load()
|
107 |
+
->toOptionHash();
|
108 |
+
$this->addColumn('set_name',
|
109 |
+
array(
|
110 |
+
'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
|
111 |
+
'width' => '100px',
|
112 |
+
'index' => 'attribute_set_id',
|
113 |
+
'type' => 'options',
|
114 |
+
'options' => $sets,
|
115 |
+
));
|
116 |
+
$this->addColumn('sku',
|
117 |
+
array(
|
118 |
+
'header'=> Mage::helper('catalog')->__('SKU'),
|
119 |
+
'width' => '80px',
|
120 |
+
'index' => 'sku',
|
121 |
+
));
|
122 |
+
$store = $this->_getStore();
|
123 |
+
$this->addColumn('price',
|
124 |
+
array(
|
125 |
+
'header'=> Mage::helper('catalog')->__('Price'),
|
126 |
+
'type' => 'price',
|
127 |
+
'currency_code' => $store->getBaseCurrency()->getCode(),
|
128 |
+
'index' => 'price',
|
129 |
+
));
|
130 |
+
$this->addColumn('qty',
|
131 |
+
array(
|
132 |
+
'header'=> Mage::helper('catalog')->__('Qty'),
|
133 |
+
'width' => '100px',
|
134 |
+
'type' => 'number',
|
135 |
+
'index' => 'qty',
|
136 |
+
));
|
137 |
+
$this->addColumn('visibility',
|
138 |
+
array(
|
139 |
+
'header'=> Mage::helper('catalog')->__('Visibility'),
|
140 |
+
'width' => '70px',
|
141 |
+
'index' => 'visibility',
|
142 |
+
'type' => 'options',
|
143 |
+
'options' => Mage::getModel('catalog/product_visibility')->getOptionArray(),
|
144 |
+
));
|
145 |
+
$this->addColumn('status',
|
146 |
+
array(
|
147 |
+
'header'=> Mage::helper('catalog')->__('Status'),
|
148 |
+
'width' => '70px',
|
149 |
+
'index' => 'status',
|
150 |
+
'type' => 'options',
|
151 |
+
'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
|
152 |
+
));
|
153 |
+
$options = array(0 => Mage::helper('catalog')->__('No'),
|
154 |
+
1 => Mage::helper('catalog')->__('Yes'));
|
155 |
+
$this->addColumn('lengow_product',
|
156 |
+
array(
|
157 |
+
'header'=> Mage::helper('catalog')->__('Publish on Lengow'),
|
158 |
+
'width' => '70px',
|
159 |
+
'index' => 'lengow_product',
|
160 |
+
'type' => 'options',
|
161 |
+
'options' => $options,
|
162 |
+
));
|
163 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
164 |
+
$this->addColumn('websites',
|
165 |
+
array(
|
166 |
+
'header'=> Mage::helper('catalog')->__('Websites'),
|
167 |
+
'width' => '100px',
|
168 |
+
'sortable' => false,
|
169 |
+
'index' => 'websites',
|
170 |
+
'type' => 'options',
|
171 |
+
'options' => Mage::getModel('core/website')->getCollection()->toOptionHash(),
|
172 |
+
));
|
173 |
+
}
|
174 |
+
return parent::_prepareColumns();
|
175 |
+
}
|
176 |
+
|
177 |
+
protected function _prepareMassaction() {
|
178 |
+
$this->setMassactionIdField('entity_id');
|
179 |
+
$this->getMassactionBlock()->setFormFieldName('product');
|
180 |
+
$options = array(0 => Mage::helper('catalog')->__('No'),
|
181 |
+
1 => Mage::helper('catalog')->__('Yes'));
|
182 |
+
$this->getMassactionBlock()->addItem('publish', array(
|
183 |
+
'label'=> Mage::helper('catalog')->__('Change publication'),
|
184 |
+
'url' => $this->getUrl('*/*/massPublish', array('_current'=>true)),
|
185 |
+
'additional' => array(
|
186 |
+
'visibility' => array(
|
187 |
+
'name' => 'publish',
|
188 |
+
'type' => 'select',
|
189 |
+
'class' => 'required-entry',
|
190 |
+
'label' => Mage::helper('catalog')->__('Publication'),
|
191 |
+
'values' => $options
|
192 |
+
)
|
193 |
+
)
|
194 |
+
));
|
195 |
+
return $this;
|
196 |
+
}
|
197 |
+
|
198 |
+
public function getGridUrl() {
|
199 |
+
return $this->getUrl('*/*/grid', array('_current'=>true));
|
200 |
+
}
|
201 |
+
|
202 |
+
public function getRowUrl($row) {
|
203 |
+
return '';
|
204 |
+
}
|
205 |
+
}
|
app/code/community/Lengow/Export/Helper/Data.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Lengow Helper
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author kassim belghait
|
8 |
+
*/
|
9 |
+
class Lengow_Export_Helper_Data extends Mage_Core_Helper_Abstract {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Returns the node and children as an array
|
13 |
+
* Values ares trimed
|
14 |
+
*
|
15 |
+
* @param bool $isCanonical - whether to ignore attributes
|
16 |
+
* @return array|string
|
17 |
+
*/
|
18 |
+
public function asArray(SimpleXMLElement $xml, $isCanonical = true) {
|
19 |
+
$result = array();
|
20 |
+
if (!$isCanonical) {
|
21 |
+
// add attributes
|
22 |
+
foreach ($xml->attributes() as $attributeName => $attribute) {
|
23 |
+
if ($attribute) {
|
24 |
+
$result['@'][$attributeName] = trim((string) $attribute);
|
25 |
+
}
|
26 |
+
}
|
27 |
+
}
|
28 |
+
// add children values
|
29 |
+
if ($xml->hasChildren()) {
|
30 |
+
foreach ($xml->children() as $childName => $child) {
|
31 |
+
if (!$child->hasChildren())
|
32 |
+
$result[$childName] = $this->asArray($child, $isCanonical);
|
33 |
+
else
|
34 |
+
$result[$childName][] = $this->asArray($child, $isCanonical);
|
35 |
+
}
|
36 |
+
} else {
|
37 |
+
if (empty($result)) {
|
38 |
+
// return as string, if nothing was found
|
39 |
+
$result = trim((string) $xml);
|
40 |
+
} else {
|
41 |
+
// value has zero key element
|
42 |
+
$result[0] = trim((string) $xml);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
return $result;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Convert specials chars to html chars
|
50 |
+
* Clean None utf-8 characters
|
51 |
+
*
|
52 |
+
* @param string $value The content
|
53 |
+
* @param boolean $convert If convert specials chars
|
54 |
+
* @return string $value
|
55 |
+
*/
|
56 |
+
public function cleanData($value, $convert = false) {
|
57 |
+
if ($convert)
|
58 |
+
$value = htmlentities($value);
|
59 |
+
|
60 |
+
$value = nl2br($value);
|
61 |
+
$value = Mage::helper('core/string')->cleanString($value);
|
62 |
+
// Reject overly long 2 byte sequences, as well as characters above U+10000 and replace with blank
|
63 |
+
$value = preg_replace('/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]' .
|
64 |
+
'|[\x00-\x7F][\x80-\xBF]+' .
|
65 |
+
'|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*' .
|
66 |
+
'|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})' .
|
67 |
+
'|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S', '', $value);
|
68 |
+
// Reject overly long 3 byte sequences and UTF-16 surrogates and replace with blank
|
69 |
+
$value = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]' .
|
70 |
+
'|\xED[\xA0-\xBF][\x80-\xBF]/S', '', $value);
|
71 |
+
$pattern = '@<[\/\!]*?[^<>]*?>@si'; //nettoyage du code HTML
|
72 |
+
$value = preg_replace($pattern, ' ', $value);
|
73 |
+
$value = preg_replace('/[\s]+/', ' ', $value); //nettoyage des espaces multiples
|
74 |
+
$value = trim($value);
|
75 |
+
$value = str_replace(' ', ' ', $value);
|
76 |
+
$value = str_replace('|', ' ', $value);
|
77 |
+
$value = str_replace('"', '\'', $value);
|
78 |
+
$value = str_replace('’', '\'', $value);
|
79 |
+
$value = str_replace(''', ' ', $value);
|
80 |
+
$value = str_replace('–', '-', $value);
|
81 |
+
$value = str_replace(chr(9), ' ', $value);
|
82 |
+
$value = str_replace(chr(10), ' ', $value);
|
83 |
+
$value = str_replace(chr(13), ' ', $value);
|
84 |
+
$value = str_replace(chr(31), '', $value);
|
85 |
+
$value = str_replace(chr(30), '', $value);
|
86 |
+
$value = str_replace(chr(29), '', $value);
|
87 |
+
$value = str_replace(chr(28), '', $value);
|
88 |
+
return $value;
|
89 |
+
}
|
90 |
+
|
91 |
+
function _convert($content) {
|
92 |
+
if (!mb_check_encoding($content, 'UTF-8') OR !($content === mb_convert_encoding(mb_convert_encoding($content, 'UTF-32', 'UTF-8'), 'UTF-8', 'UTF-32'))) {
|
93 |
+
$content = mb_convert_encoding($content, 'UTF-8');
|
94 |
+
}
|
95 |
+
return $content;
|
96 |
+
}
|
97 |
+
|
98 |
+
}
|
app/code/community/Lengow/Export/Helper/Security.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export helper security
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Export_Helper_Security extends Mage_Core_Helper_Abstract {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Lengow IP.
|
15 |
+
*/
|
16 |
+
public static $IPS_LENGOW = array(
|
17 |
+
'127.0.0.1' ,
|
18 |
+
'95.131.137.18' ,
|
19 |
+
'95.131.137.19' ,
|
20 |
+
'95.131.137.21' ,
|
21 |
+
'95.131.137.26' ,
|
22 |
+
'95.131.137.27' ,
|
23 |
+
'88.164.17.227' ,
|
24 |
+
'88.164.17.216' ,
|
25 |
+
'109.190.78.5' ,
|
26 |
+
'80.11.36.123' ,
|
27 |
+
'95.131.141.169' ,
|
28 |
+
'95.131.141.170' ,
|
29 |
+
'95.131.141.171' ,
|
30 |
+
);
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Check if current IP is authorized.
|
34 |
+
*
|
35 |
+
* @return boolean.
|
36 |
+
*/
|
37 |
+
public function checkIP() {
|
38 |
+
$ips = Mage::getStoreConfig('export/global/valid_ip');
|
39 |
+
$ips = trim(str_replace(array("\r\n", ',', '-', '|', ' '), ';', $ips), ';');
|
40 |
+
$ips = explode(';', $ips);
|
41 |
+
$authorized_ips = array_merge($ips, self::$IPS_LENGOW);
|
42 |
+
// Proxy
|
43 |
+
/*if(function_exists('apache_request_headers')) {
|
44 |
+
$headers = apache_request_headers();
|
45 |
+
if (array_key_exists('X-Forwarded-For', $headers)) {
|
46 |
+
$hostname_ip = $headers['X-Forwarded-For'];
|
47 |
+
} else {
|
48 |
+
$hostname_ip = $_SERVER['REMOTE_ADDR'];
|
49 |
+
}
|
50 |
+
} else {
|
51 |
+
$hostname_ip = $_SERVER['REMOTE_ADDR'];
|
52 |
+
}*/
|
53 |
+
$hostname_ip = $_SERVER['REMOTE_ADDR'];
|
54 |
+
if(in_array($hostname_ip, $authorized_ips))
|
55 |
+
return true;
|
56 |
+
return false;
|
57 |
+
}
|
58 |
+
|
59 |
+
}
|
app/code/community/Lengow/Export/Model/.DS_Store
ADDED
Binary file
|
app/code/community/Lengow/Export/Model/Catalog/Product.php
ADDED
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export model convert parser product
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Export_Model_Catalog_Product extends Mage_Catalog_Model_Product {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Config model export
|
15 |
+
*
|
16 |
+
* @var object
|
17 |
+
*/
|
18 |
+
protected $_config_model = true;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Initialize resources
|
22 |
+
*/
|
23 |
+
protected function _construct() {
|
24 |
+
$this->_init('catalog/product');
|
25 |
+
$this->_config_model = Mage::getSingleton('export/config');
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getShippingInfo($product_instance) {
|
29 |
+
$data['shipping-name'] = '';
|
30 |
+
$data['shipping-price'] = '';
|
31 |
+
$carrier = $this->_config_model->get('data/default_shipping_method');
|
32 |
+
if(empty($carrier))
|
33 |
+
return $data;
|
34 |
+
$carrierTab = explode('_',$carrier);
|
35 |
+
list($carrierCode,$methodCode) = $carrierTab;
|
36 |
+
$data['shipping-name'] = ucfirst($methodCode);
|
37 |
+
$shippingPrice = 0;
|
38 |
+
$countryCode = $this->_config_model->get('data/shipping_price_based_on');
|
39 |
+
$shippingPrice = $this->_getShippingPrice($product_instance, $carrier, $countryCode);
|
40 |
+
if(!$shippingPrice) {
|
41 |
+
$shippingPrice = $this->_config_model->get('data/default_shipping_price');
|
42 |
+
}
|
43 |
+
$data['shipping-price'] = $shippingPrice;
|
44 |
+
|
45 |
+
return $data;
|
46 |
+
}
|
47 |
+
|
48 |
+
protected function _getShippingPrice($product_instance, $carrierValue, $countryCode = 'FR') {
|
49 |
+
$carrierTab = explode('_', $carrierValue);
|
50 |
+
list($carrierCode, $methodCode) = $carrierTab;
|
51 |
+
$shipping = Mage::getModel('shipping/shipping');
|
52 |
+
$methodModel = $shipping->getCarrierByCode($carrierCode);
|
53 |
+
if($methodModel) {
|
54 |
+
$result = $methodModel->collectRates($this->_getShippingRateRequest($product_instance, $countryCode = 'FR'));
|
55 |
+
if($result != NULL) {
|
56 |
+
if($result->getError()) {
|
57 |
+
Mage::logException(new Exception($result->getError()));
|
58 |
+
} else {
|
59 |
+
foreach($result->getAllRates() as $rate) {
|
60 |
+
return $rate->getPrice();
|
61 |
+
}
|
62 |
+
}
|
63 |
+
} else {
|
64 |
+
return false;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
return false;
|
68 |
+
}
|
69 |
+
|
70 |
+
protected function _getShippingRateRequest($product_instance, $countryCode = 'FR') {
|
71 |
+
/** @var $request Mage_Shipping_Model_Rate_Request */
|
72 |
+
$request = Mage::getModel('shipping/rate_request');
|
73 |
+
$storeId = $request->getStoreId();
|
74 |
+
if (!$request->getOrig()) {
|
75 |
+
$request->setCountryId($countryCode)
|
76 |
+
->setRegionId('')
|
77 |
+
->setCity('')
|
78 |
+
->setPostcode('');
|
79 |
+
}
|
80 |
+
$item = Mage::getModel('sales/quote_item');
|
81 |
+
$item->setStoreId($storeId);
|
82 |
+
$item->setOptions($this->getCustomOptions())
|
83 |
+
->setProduct($this);
|
84 |
+
$request->setAllItems(array($item));
|
85 |
+
$request->setDestCountryId($countryCode);
|
86 |
+
$request->setDestRegionId('');
|
87 |
+
$request->setDestRegionCode('');
|
88 |
+
$request->setDestPostcode('');
|
89 |
+
$request->setPackageValue($product_instance->getPrice());
|
90 |
+
$request->setPackageValueWithDiscount($product_instance->getFinalPrice());
|
91 |
+
$request->setPackageWeight($product_instance->getWeight());
|
92 |
+
$request->setFreeMethodWeight(0);
|
93 |
+
$request->setPackageQty(1);
|
94 |
+
$request->setStoreId(Mage::app()->getStore()->getId());
|
95 |
+
$request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
|
96 |
+
$request->setBaseCurrency(Mage::app()->getStore()->getBaseCurrency());
|
97 |
+
$request->setPackageCurrency(Mage::app()->getStore()->getCurrentCurrency());
|
98 |
+
return $request;
|
99 |
+
}
|
100 |
+
|
101 |
+
public function getPrices($product_instance, $configurable_instance = null) {
|
102 |
+
/* @var $configurable_instance Mage_Catalog_Model_Product */
|
103 |
+
if ($configurable_instance) {
|
104 |
+
$price = $configurable_instance->getPrice();
|
105 |
+
$finalPrice = $configurable_instance->getFinalPrice();
|
106 |
+
$configurablePrice = 0;
|
107 |
+
$configurableOldPrice = 0;
|
108 |
+
$attributes = $configurable_instance->getTypeInstance(true)->getConfigurableAttributes($configurable_instance);
|
109 |
+
$attributes = Mage::helper('core')->decorateArray($attributes);
|
110 |
+
if($attributes) {
|
111 |
+
foreach($attributes as $attribute) {
|
112 |
+
$productAttribute = $attribute->getProductAttribute();
|
113 |
+
$productAttributeId = $productAttribute->getId();
|
114 |
+
$attributeValue = $product_instance->getData($productAttribute->getAttributeCode());
|
115 |
+
foreach($attribute->getPrices() as $priceChange) {
|
116 |
+
if ($price['value_index'] == $attributeValue) {
|
117 |
+
$configurableOldPrice += (float) ( $priceChange['is_percent'] ? ( ( (float) $priceChange['pricing_value'] ) * $price / 100 ) : $priceChange['pricing_value'] );
|
118 |
+
$configurablePrice += (float) ( $priceChange['is_percent'] ? ( ( (float) $priceChange['pricing_value'] ) * $finalPrice / 100 ) : $priceChange['pricing_value'] );
|
119 |
+
}
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
$configurable_instance->setConfigurablePrice($configurablePrice);
|
124 |
+
$configurable_instance->setParentId(true);
|
125 |
+
Mage::dispatchEvent(
|
126 |
+
'catalog_product_type_configurable_price',
|
127 |
+
array('product' => $configurable_instance)
|
128 |
+
);
|
129 |
+
$configurablePrice = $configurable_instance->getConfigurablePrice();
|
130 |
+
$price_including_tax = Mage::helper('tax')->getPrice(
|
131 |
+
$configurable_instance->setTaxPercent(null),
|
132 |
+
$configurable_instance->getPrice() + $configurableOldPrice
|
133 |
+
);
|
134 |
+
$final_price_including_tax = Mage::helper('tax')->getPrice(
|
135 |
+
$configurable_instance->setTaxPercent(null),
|
136 |
+
$configurable_instance->getFinalPrice() + $configurablePrice
|
137 |
+
);
|
138 |
+
} else {
|
139 |
+
$price_including_tax = Mage::helper('tax')->getPrice(
|
140 |
+
$product_instance->setTaxPercent(null),
|
141 |
+
$product_instance->getPrice()
|
142 |
+
);
|
143 |
+
$final_price_including_tax = Mage::helper('tax')->getPrice(
|
144 |
+
$product_instance->setTaxPercent(null),
|
145 |
+
$product_instance->getFinalPrice()
|
146 |
+
);
|
147 |
+
}
|
148 |
+
$discount_amount = $price_including_tax - $final_price_including_tax;
|
149 |
+
$data['price-ttc'] = round($final_price_including_tax, 2);
|
150 |
+
$data['price-before-discount'] = round($price_including_tax, 2);
|
151 |
+
$data['discount-amount'] = $discount_amount > 0 ? round($discount_amount, 2) : '0';
|
152 |
+
$data['discount-percent'] = $discount_amount > 0 ? round(($discount_amount * 100) / $price_including_tax, 0) : '0';
|
153 |
+
$data['start-date-discount'] = $product_instance->getSpecialFromDate;
|
154 |
+
$data['end-date-discount'] = $product_instance->getSpecialToDate;
|
155 |
+
return $data;
|
156 |
+
}
|
157 |
+
|
158 |
+
public function getCategories($product_instance, $parent_instance, $id_store) {
|
159 |
+
if($product_instance->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE && isset($parent_instance)) {
|
160 |
+
$categories = $parent_instance->getCategoryCollection()
|
161 |
+
->exportToArray();
|
162 |
+
} else {
|
163 |
+
$categories = $product_instance->getCategoryCollection()
|
164 |
+
->exportToArray();
|
165 |
+
}
|
166 |
+
$max_level = $this->_config_model->get('data/levelcategory');
|
167 |
+
$current_level = 0;
|
168 |
+
$category_buffer = false;
|
169 |
+
foreach($categories as $category) {
|
170 |
+
if($category['level'] > $current_level) {
|
171 |
+
$current_level = $category['level'];
|
172 |
+
$category_buffer = $category;
|
173 |
+
}
|
174 |
+
if($current_level > $max_level)
|
175 |
+
break;
|
176 |
+
}
|
177 |
+
if(isset($category) && $category['path'] != '')
|
178 |
+
$categories = explode('/', $category_buffer['path']);
|
179 |
+
else
|
180 |
+
$categories = array();
|
181 |
+
$data['category'] = '';
|
182 |
+
$data['category-url'] = '';
|
183 |
+
for($i = 1; $i <= $max_level; $i++) {
|
184 |
+
$data['category-sub-'.($i)] = '';
|
185 |
+
$data['category-url-sub-'.($i)] = '';
|
186 |
+
}
|
187 |
+
$i = 0;
|
188 |
+
$ariane = array();
|
189 |
+
foreach($categories as $cid) {
|
190 |
+
$c = Mage::getModel('catalog/category')
|
191 |
+
->setStoreId($id_store)
|
192 |
+
->load($cid);
|
193 |
+
if($c->getId() != 1) {
|
194 |
+
// No root category
|
195 |
+
if($i == 0) {
|
196 |
+
$data['category'] = $c->getName();
|
197 |
+
$data['category-url'] = $c->getUrl();
|
198 |
+
$ariane[] = $c->getName();
|
199 |
+
} elseif($i <= $max_level) {
|
200 |
+
$ariane[] = $c->getName();
|
201 |
+
$data['category-sub-'.$i] = $c->getName();
|
202 |
+
$data['category-url-sub-'.$i] = $c->getUrl();
|
203 |
+
}
|
204 |
+
$i++;
|
205 |
+
}
|
206 |
+
}
|
207 |
+
$data['category-breadcrumb'] = implode(' > ', $ariane);
|
208 |
+
unset($categories, $category, $ariane);
|
209 |
+
return $data;
|
210 |
+
}
|
211 |
+
|
212 |
+
// TODO : Clean, don't understand the merge of images parents/childs
|
213 |
+
public function getImages($images, $parentimages = false) {
|
214 |
+
// Si des images du parent sont à exporter
|
215 |
+
// On fusionne les deux listes, le reste du script fera le reste
|
216 |
+
if($parentimages !== false) {
|
217 |
+
$images = array_merge($parentimages, $images);
|
218 |
+
$_images = array();
|
219 |
+
$_ids = array();
|
220 |
+
// Nettoyage du tableau
|
221 |
+
foreach($images as $image) {
|
222 |
+
if(array_key_exists('value_id', $image) && !in_array($image['value_id'], $_ids)) {
|
223 |
+
$_ids[] = $image['value_id'];
|
224 |
+
$_images[]['file'] = $image['file'];
|
225 |
+
}
|
226 |
+
}
|
227 |
+
$images = $_images;
|
228 |
+
unset($_images, $_ids, $parentimages);
|
229 |
+
}
|
230 |
+
$data = array();
|
231 |
+
for($i = 1; $i < 6; $i++) {
|
232 |
+
$data['image-url-'.$i] = '';
|
233 |
+
}
|
234 |
+
$c = 1;
|
235 |
+
foreach($images as $i) {
|
236 |
+
$url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' . $i['file'];
|
237 |
+
$data['image-url-' . $c++] = $url;
|
238 |
+
if($i == 6)
|
239 |
+
break;
|
240 |
+
}
|
241 |
+
return $data;
|
242 |
+
}
|
243 |
+
|
244 |
+
}
|
app/code/community/Lengow/Export/Model/Config.php
ADDED
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export model config
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Export_Model_Config extends Varien_Object {
|
12 |
+
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Config key "Enable manage orders"
|
16 |
+
*/
|
17 |
+
const ENABLED = 'active';
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Config key "Filter by attribute"
|
21 |
+
*/
|
22 |
+
const EXPORT_ONLY_SELECTED = 'global/export_only_selected';
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Config key "Export soldout"
|
26 |
+
*/
|
27 |
+
const EXPORT_SOLDOUT = 'export_soldout';
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Config key "Export count images"
|
31 |
+
*/
|
32 |
+
const COUNT_IMAGES = 'data/count_images';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Config key "Filter by attribute"
|
36 |
+
*/
|
37 |
+
const LIMIT_PRODUCT = 'limit_product';
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Config key "Attributes kow"
|
41 |
+
*/
|
42 |
+
const ATTRIBUTES_KNOW = 'attributes_know';
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Config key "Attributes unkow"
|
46 |
+
*/
|
47 |
+
const ATTRIBUTES_UNKNOW = 'attributes_unknow';
|
48 |
+
|
49 |
+
/*
|
50 |
+
* @var array $_attributesKnow
|
51 |
+
*/
|
52 |
+
protected $_attributesKnow = null;
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @var array $_attributesUnKnow
|
56 |
+
*/
|
57 |
+
protected $_attributesUnKnow = null;
|
58 |
+
|
59 |
+
protected $_attributesSelected = null;
|
60 |
+
|
61 |
+
protected $_id_store;
|
62 |
+
|
63 |
+
public function setStore($id_store) {
|
64 |
+
$this->_id_store = $id_store;
|
65 |
+
}
|
66 |
+
|
67 |
+
public function get($key) {
|
68 |
+
return Mage::getStoreConfig('export/' . $key, $this->_id_store);
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Return config var
|
73 |
+
*
|
74 |
+
* @param string $key Var path key
|
75 |
+
* @param int $id_store Store View Id
|
76 |
+
* @return mixed
|
77 |
+
*/
|
78 |
+
public function getConfigData($key, $group = 'global', $id_store = null) {
|
79 |
+
if (!$this->hasData($key)) {
|
80 |
+
$value = Mage::getStoreConfig('export/' . $group . '/' . $key, $id_store);
|
81 |
+
$this->setData($key, $value);
|
82 |
+
}
|
83 |
+
return $this->getData($key);
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Return config var
|
88 |
+
*
|
89 |
+
* @param string $key Var path key
|
90 |
+
* @param int $id_store Store View Id
|
91 |
+
* @return mixed
|
92 |
+
*/
|
93 |
+
public function getConfigFlag($key, $group = 'global', $id_store = null) {
|
94 |
+
if (!$this->hasData($key)) {
|
95 |
+
$value = Mage::getStoreConfigFlag('export/' . $group . '/' . $key, $id_store);
|
96 |
+
$this->setData($key, $value);
|
97 |
+
}
|
98 |
+
return $this->getData($key);
|
99 |
+
}
|
100 |
+
|
101 |
+
|
102 |
+
public function getAny($group, $key, $id_store = null) {
|
103 |
+
return Mage::getStoreConfig('export/' . $group . '/' . $key, $id_store);
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Retrieve if export is active
|
108 |
+
*
|
109 |
+
* @return boolean
|
110 |
+
*/
|
111 |
+
public function isEnabled() {
|
112 |
+
return $this->getConfigFlag(self::ENABLED);
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Retrieve if export is active
|
117 |
+
*
|
118 |
+
* @return boolean
|
119 |
+
*/
|
120 |
+
public function onlySelectedProducts() {
|
121 |
+
return $this->get(self::EXPORT_ONLY_SELECTED);
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Retrieve if export sold out products
|
126 |
+
*
|
127 |
+
* @return boolean
|
128 |
+
*/
|
129 |
+
public function isExportSoldout() {
|
130 |
+
return $this->getConfigFlag(self::EXPORT_SOLDOUT);
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Retrieve limit of product in query
|
135 |
+
*
|
136 |
+
* @return int
|
137 |
+
*/
|
138 |
+
public function getLimitProduct() {
|
139 |
+
return (int) $this->getConfigData(self::LIMIT_PRODUCT);
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Retrieve limit of product in query
|
144 |
+
*
|
145 |
+
* @return int
|
146 |
+
*/
|
147 |
+
public function getCountExportImages() {
|
148 |
+
return (int) $this->getConfigData(self::COUNT_IMAGES);
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Return Attributes Unknowed in array with key=>value
|
153 |
+
* key = node adn value = inner text
|
154 |
+
* @param int $id_store
|
155 |
+
* @return array
|
156 |
+
*/
|
157 |
+
public function getMappgingAttributesUnKnow($id_store = null) {
|
158 |
+
//if(is_null($this->_attributesUnKnow))
|
159 |
+
if($this->_attributesUnKnow === null || !isset($this->_attributesUnKnow) || empty($this->_attributesUnKnow)) {
|
160 |
+
$this->_attributesUnKnow = Mage::getStoreConfig('export/attributes_unknow', $id_store);
|
161 |
+
}
|
162 |
+
|
163 |
+
return $this->_attributesUnKnow;
|
164 |
+
}
|
165 |
+
|
166 |
+
public function getSelectedAttributes($id_store = null) {
|
167 |
+
|
168 |
+
$tab = array();
|
169 |
+
$this->_attributesSelected = array();
|
170 |
+
if($this->_attributesSelected === null || !isset($this->_attributesSelected) || empty($this->_attributesSelected)) {
|
171 |
+
$val = Mage::getStoreConfig('export/attributelist/attributes', $id_store);
|
172 |
+
if(!empty($val)) {
|
173 |
+
$tab = explode(',',$val);
|
174 |
+
$this->_attributesSelected = array_flip($tab);
|
175 |
+
}
|
176 |
+
}
|
177 |
+
if(!empty($tab)) {
|
178 |
+
foreach($this->_attributesSelected as $key => $value) {
|
179 |
+
$this->_attributesSelected[$key] = $key;
|
180 |
+
}
|
181 |
+
}
|
182 |
+
return $this->_attributesSelected;
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Return ALL Attributes Knowed and Unknowed in array with key=>value
|
187 |
+
* key = node adn value = inner text
|
188 |
+
* @return array
|
189 |
+
* @param int $id_store
|
190 |
+
*/
|
191 |
+
public function getMappingAllAttributes($id_store = null) {
|
192 |
+
return $this->getSelectedAttributes($id_store);
|
193 |
+
}
|
194 |
+
|
195 |
+
|
196 |
+
}
|
app/code/community/Lengow/Export/Model/Convert/Parser/Product.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export model convert parser product
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Export_Model_Convert_Parser_Product extends Mage_Catalog_Model_Convert_Parser_Product {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Retrieve accessible external product attributes
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
public function getExternalAttributes() {
|
19 |
+
$productAttributes = array();
|
20 |
+
if(file_exists(Mage::getModuleDir(null,'Mage_Catalog') . 'Model/Resource/Eav/Mysql4/Product/Attribute/Collection')) {
|
21 |
+
$productAttributes = Mage::getResourceModel('catalog/product_attribute_collection')->load();
|
22 |
+
} else {
|
23 |
+
$entityTypeId = Mage::getSingleton('eav/config')->getEntityType('catalog_product')->getId();
|
24 |
+
$productAttributes = Mage::getResourceModel('eav/entity_attribute_collection')
|
25 |
+
->setEntityTypeFilter($entityTypeId)
|
26 |
+
->load();
|
27 |
+
}
|
28 |
+
$attributes = $this->_externalFields;
|
29 |
+
foreach ($productAttributes as $attr) {
|
30 |
+
$code = $attr->getAttributeCode();
|
31 |
+
if (in_array($code, $this->_internalFields) || $attr->getFrontendInput() == 'hidden') {
|
32 |
+
continue;
|
33 |
+
}
|
34 |
+
$attributes[$code] = $code;
|
35 |
+
}
|
36 |
+
foreach ($this->_inventoryFields as $field) {
|
37 |
+
$attributes[$field] = $field;
|
38 |
+
}
|
39 |
+
return $attributes;
|
40 |
+
}
|
41 |
+
|
42 |
+
}
|
app/code/community/Lengow/Export/Model/Export/Rewrite/Catalog/Config.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Mage_Catalog
|
23 |
+
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
|
28 |
+
class Lengow_Export_Model_Rewrite_Catalog_Config extends Mage_Catalog_Model_Config{
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Get attribute by code for entity type
|
32 |
+
*
|
33 |
+
* @param mixed $entityType
|
34 |
+
* @param mixed $code
|
35 |
+
* @return Mage_Eav_Model_Entity_Attribute_Abstract
|
36 |
+
*/
|
37 |
+
public function getAttribute($entityType, $code) {
|
38 |
+
$attribute = parent::getAttribute($entityType, $code);
|
39 |
+
if(is_object($attribute) && $attribute->getAttributeCode() == '') {
|
40 |
+
$attribute->setAttributeCode($code);
|
41 |
+
}
|
42 |
+
return $attribute;
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
}
|
app/code/community/Lengow/Export/Model/Feed/Abstract.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export feed abstract
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
abstract class Lengow_Export_Model_Feed_Abstract {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Version.
|
15 |
+
*/
|
16 |
+
const VERSION = '1.0.0';
|
17 |
+
|
18 |
+
protected $_fields;
|
19 |
+
|
20 |
+
protected $_content_type;
|
21 |
+
|
22 |
+
public function getContentType() {
|
23 |
+
}
|
24 |
+
|
25 |
+
public function setFields($array = array()) {
|
26 |
+
$this->_fields = $array;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function makeHeader() {
|
30 |
+
}
|
31 |
+
|
32 |
+
public function makeData($array, $args = array()) {
|
33 |
+
}
|
34 |
+
|
35 |
+
public function makeFooter() {
|
36 |
+
}
|
37 |
+
}
|
app/code/community/Lengow/Export/Model/Feed/Csv.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export feed csv
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Export_Model_Feed_Csv extends Lengow_Export_Model_Feed_Abstract {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* CSV separator.
|
15 |
+
*/
|
16 |
+
public static $CSV_SEPARATOR = '|';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* CSV protection.
|
20 |
+
*/
|
21 |
+
public static $CSV_PROTECTION = '"';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* CSV End of line.
|
25 |
+
*/
|
26 |
+
public static $CSV_EOL = "\r\n";
|
27 |
+
|
28 |
+
protected $_content_type = 'text/plain';
|
29 |
+
|
30 |
+
public function getContentType() {
|
31 |
+
return $this->_content_type;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function makeHeader() {
|
35 |
+
$head = '';
|
36 |
+
foreach($this->_fields as $name) {
|
37 |
+
$head .= self::$CSV_PROTECTION . $this->_clean(substr(str_replace('-', '_', $name), 0, 59)) . self::$CSV_PROTECTION . self::$CSV_SEPARATOR;
|
38 |
+
}
|
39 |
+
return rtrim($head, self::$CSV_SEPARATOR) . self::$CSV_EOL;
|
40 |
+
}
|
41 |
+
|
42 |
+
public function makeData($array, $args = array()) {
|
43 |
+
$line = '';
|
44 |
+
foreach($this->_fields as $name) {
|
45 |
+
$line .= self::$CSV_PROTECTION . (array_key_exists($name, $array) ? (str_replace(array(self::$CSV_PROTECTION, '\\'), '', $array[$name])) : '') . self::$CSV_PROTECTION . self::$CSV_SEPARATOR;
|
46 |
+
}
|
47 |
+
return rtrim($line, self::$CSV_SEPARATOR) . self::$CSV_EOL;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function makeFooter() {
|
51 |
+
return '';
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Clean header
|
56 |
+
*
|
57 |
+
* @param string $str The fieldname *
|
58 |
+
* @return string The formated header.
|
59 |
+
*/
|
60 |
+
private function _clean($str) {
|
61 |
+
$patterns = array(
|
62 |
+
/* Lowercase */
|
63 |
+
'/[\x{0105}\x{00E0}\x{00E1}\x{00E2}\x{00E3}\x{00E4}\x{00E5}]/u',
|
64 |
+
'/[\x{00E7}\x{010D}\x{0107}]/u',
|
65 |
+
'/[\x{010F}]/u',
|
66 |
+
'/[\x{00E8}\x{00E9}\x{00EA}\x{00EB}\x{011B}\x{0119}]/u',
|
67 |
+
'/[\x{00EC}\x{00ED}\x{00EE}\x{00EF}]/u',
|
68 |
+
'/[\x{0142}\x{013E}\x{013A}]/u',
|
69 |
+
'/[\x{00F1}\x{0148}]/u',
|
70 |
+
'/[\x{00F2}\x{00F3}\x{00F4}\x{00F5}\x{00F6}\x{00F8}]/u',
|
71 |
+
'/[\x{0159}\x{0155}]/u',
|
72 |
+
'/[\x{015B}\x{0161}]/u',
|
73 |
+
'/[\x{00DF}]/u',
|
74 |
+
'/[\x{0165}]/u',
|
75 |
+
'/[\x{00F9}\x{00FA}\x{00FB}\x{00FC}\x{016F}]/u',
|
76 |
+
'/[\x{00FD}\x{00FF}]/u',
|
77 |
+
'/[\x{017C}\x{017A}\x{017E}]/u',
|
78 |
+
'/[\x{00E6}]/u',
|
79 |
+
'/[\x{0153}]/u',
|
80 |
+
/* Uppercase */
|
81 |
+
'/[\x{0104}\x{00C0}\x{00C1}\x{00C2}\x{00C3}\x{00C4}\x{00C5}]/u',
|
82 |
+
'/[\x{00C7}\x{010C}\x{0106}]/u',
|
83 |
+
'/[\x{010E}]/u',
|
84 |
+
'/[\x{00C8}\x{00C9}\x{00CA}\x{00CB}\x{011A}\x{0118}]/u',
|
85 |
+
'/[\x{0141}\x{013D}\x{0139}]/u',
|
86 |
+
'/[\x{00D1}\x{0147}]/u',
|
87 |
+
'/[\x{00D3}]/u',
|
88 |
+
'/[\x{0158}\x{0154}]/u',
|
89 |
+
'/[\x{015A}\x{0160}]/u',
|
90 |
+
'/[\x{0164}]/u',
|
91 |
+
'/[\x{00D9}\x{00DA}\x{00DB}\x{00DC}\x{016E}]/u',
|
92 |
+
'/[\x{017B}\x{0179}\x{017D}]/u',
|
93 |
+
'/[\x{00C6}]/u',
|
94 |
+
'/[\x{0152}]/u');
|
95 |
+
$replacements = array(
|
96 |
+
'a', 'c', 'd', 'e', 'i', 'l', 'n', 'o', 'r', 's', 'ss', 't', 'u', 'y', 'z', 'ae', 'oe',
|
97 |
+
'A', 'C', 'D', 'E', 'L', 'N', 'O', 'R', 'S', 'T', 'U', 'Z', 'AE', 'OE'
|
98 |
+
);
|
99 |
+
return preg_replace($patterns, $replacements, $str);
|
100 |
+
}
|
101 |
+
|
102 |
+
}
|
app/code/community/Lengow/Export/Model/Feed/Json.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export feed json
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Export_Model_Feed_Json extends Lengow_Export_Model_Feed_Abstract {
|
12 |
+
|
13 |
+
protected $_content_type = 'application/json';
|
14 |
+
|
15 |
+
public function getContentType() {
|
16 |
+
return $this->_content_type;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function makeHeader() {
|
20 |
+
return '{"catalog":[';
|
21 |
+
}
|
22 |
+
|
23 |
+
public function makeData($array, $args = array()) {
|
24 |
+
foreach($this->_fields as $name) {
|
25 |
+
$json_array[$name] = array_key_exists($name, $array) ? $array[$name] : '';
|
26 |
+
}
|
27 |
+
$line = Mage::helper('core')->jsonEncode($json_array) . (!$args['last'] ? ',' : '') ;
|
28 |
+
return $line;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function makeFooter() {
|
32 |
+
return ']}';
|
33 |
+
}
|
34 |
+
|
35 |
+
}
|
app/code/community/Lengow/Export/Model/Feed/Xml.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export feed xml
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Export_Model_Feed_Xml extends Lengow_Export_Model_Feed_Abstract {
|
12 |
+
|
13 |
+
protected $_content_type = 'text/xml';
|
14 |
+
|
15 |
+
public function getContentType() {
|
16 |
+
return $this->_content_type;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function makeHeader() {
|
20 |
+
return '<?xml version="1.0" ?>' . "\r\n"
|
21 |
+
. '<catalog>' . "\r\n";
|
22 |
+
}
|
23 |
+
|
24 |
+
public function makeData($array, $args = array()) {
|
25 |
+
$line = '<product>' . "\r\n";
|
26 |
+
foreach($this->_fields as $name) {
|
27 |
+
$line .= '<' . $name . '><![CDATA[' . (isset($array[$name]) ? $array[$name] : '') . ']]></' . $name . '>' . "\r\n";
|
28 |
+
}
|
29 |
+
$line .= '</product>' . "\r\n";
|
30 |
+
return $line;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function makeFooter() {
|
34 |
+
return '</catalog>';
|
35 |
+
}
|
36 |
+
|
37 |
+
}
|
app/code/community/Lengow/Export/Model/Feed/Yaml.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export feed yaml
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Export_Model_Feed_Yaml extends Lengow_Export_Model_Feed_Abstract {
|
12 |
+
|
13 |
+
protected $_content_type = 'text/x-yaml';
|
14 |
+
|
15 |
+
public function getContentType() {
|
16 |
+
return $this->_content_type;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function makeHeader() {
|
20 |
+
return '';
|
21 |
+
}
|
22 |
+
|
23 |
+
public function makeData($array, $args = array()) {
|
24 |
+
$line = ' ' . '"product":' . "\r\n";
|
25 |
+
foreach($this->_fields as $name) {
|
26 |
+
$line .= ' ' . '"' . $name . '":' . $this->_addSpaces($name , 22) . (isset($array[$name]) ? $array[$name] : '') . "\r\n";
|
27 |
+
}
|
28 |
+
return $line;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function makeFooter() {
|
32 |
+
return '';
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* For YAML, add spaces to have good indentation.
|
37 |
+
*
|
38 |
+
* @param string $name The fielname
|
39 |
+
* @param string $maxsize The max spaces
|
40 |
+
*
|
41 |
+
* @return string Spaces.
|
42 |
+
*/
|
43 |
+
private function _addSpaces($name, $size) {
|
44 |
+
$strlen = strlen($name);
|
45 |
+
$spaces = '';
|
46 |
+
for($i = $strlen; $i < $size; $i++) {
|
47 |
+
$spaces .= ' ';
|
48 |
+
}
|
49 |
+
return $spaces;
|
50 |
+
}
|
51 |
+
|
52 |
+
}
|
app/code/community/Lengow/Export/Model/Generate.php
ADDED
@@ -0,0 +1,406 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow adminhtml export controller
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Export_Model_Generate extends Varien_Object {
|
12 |
+
|
13 |
+
private $_id_store;
|
14 |
+
|
15 |
+
private $_file;
|
16 |
+
|
17 |
+
private $_filename = 'lengow_feed';
|
18 |
+
|
19 |
+
private $_stream;
|
20 |
+
|
21 |
+
private $_format;
|
22 |
+
|
23 |
+
private $_config_model;
|
24 |
+
|
25 |
+
private $_product_model;
|
26 |
+
|
27 |
+
private $_eav_model;
|
28 |
+
|
29 |
+
private $_helper;
|
30 |
+
|
31 |
+
private $_time = null;
|
32 |
+
|
33 |
+
private $_excludes = array('media_gallery',
|
34 |
+
'tier_price',
|
35 |
+
'short_description',
|
36 |
+
'description',
|
37 |
+
'quantity');
|
38 |
+
/**
|
39 |
+
* Default fields.
|
40 |
+
*/
|
41 |
+
public static $DEFAULT_FIELDS = array('sku' => 'sku' ,
|
42 |
+
'entity_id' => 'product-id' ,
|
43 |
+
'parent-id' => 'parent-id' ,
|
44 |
+
'qty' => 'qty' ,
|
45 |
+
'name' => 'name' ,
|
46 |
+
'description' => 'description' ,
|
47 |
+
'short_description' => 'short_description' ,
|
48 |
+
'price-ttc' => 'price-ttc' ,
|
49 |
+
'shipping-name' => 'shipping-name' ,
|
50 |
+
'image-url-1' => 'image-url-1' ,
|
51 |
+
'product-url' => 'product-url');
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Construct generator
|
55 |
+
* Set models
|
56 |
+
*/
|
57 |
+
public function __construct() {
|
58 |
+
$this->_config_model = Mage::getSingleton('export/config');
|
59 |
+
$this->_product_model = Mage::getModel('export/catalog_product');
|
60 |
+
$this->_eav_model = Mage::getResourceModel('eav/entity_attribute_collection');
|
61 |
+
$this->_stream = $this->_config_model->get('performances/usesavefile') ? false : true;
|
62 |
+
$this->_helper = Mage::helper('export/data');
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Make the feed
|
67 |
+
*
|
68 |
+
* @param integer $id_store ID of store
|
69 |
+
* @param varchar $mode The mode of export
|
70 |
+
* size : display only count of products to export
|
71 |
+
* full : export simple product + configured product
|
72 |
+
* xxx,yyy : export xxx type product + yyy type product
|
73 |
+
* @param varchar $format Format of export
|
74 |
+
* @param varchar $types Type(s) of product
|
75 |
+
* @param varchar $status Status of product to export
|
76 |
+
* @param boolean $export_child Export child of product
|
77 |
+
* @param boolean $out_of_stock Export product out of stock
|
78 |
+
*
|
79 |
+
* @return Mage_Catalog_Model_Product
|
80 |
+
*/
|
81 |
+
public function exec($id_store,
|
82 |
+
$mode = null,
|
83 |
+
$format = 'csv',
|
84 |
+
$types = null,
|
85 |
+
$status = null,
|
86 |
+
$export_child = null,
|
87 |
+
$out_of_stock = null,
|
88 |
+
$selected_products = null,
|
89 |
+
$stream = null,
|
90 |
+
$limit = null,
|
91 |
+
$offset = null,
|
92 |
+
$ids_product = null) {
|
93 |
+
$this->_id_store = $id_store;
|
94 |
+
$this->_format = $format;
|
95 |
+
// Get products list to export
|
96 |
+
$products = $this->_getProductsCollection($types, $status, $export_child, $out_of_stock, $selected_products, $limit, $offset, $ids_product);
|
97 |
+
// Mode size, return count of products
|
98 |
+
if($mode == 'size')
|
99 |
+
die((string) sizeof($products));
|
100 |
+
if(!is_null($stream))
|
101 |
+
$this->_stream = $stream;
|
102 |
+
if(!$this->_stream) {
|
103 |
+
header('Content-Type: text/html; charset=utf-8');
|
104 |
+
echo date('Y-m-d h:i:s') . ' - Start export<br />';
|
105 |
+
flush();
|
106 |
+
}
|
107 |
+
// Gestion des attributs à exporter
|
108 |
+
$attributes_to_export = $this->_config_model->getMappingAllAttributes();
|
109 |
+
$products_data = array();
|
110 |
+
$this->_attrs = array();
|
111 |
+
$feed = Mage::getModel('Lengow_Export_Model_Feed_' . ucfirst($this->_format));
|
112 |
+
$first = true;
|
113 |
+
$last = false;
|
114 |
+
$total_product = count($products);
|
115 |
+
$pi = 1;
|
116 |
+
if(!$this->_stream) {
|
117 |
+
echo date('Y-m-d h:i:s') . ' - Find ' . $total_product . ' products<br />';
|
118 |
+
flush();
|
119 |
+
}
|
120 |
+
// Generate data
|
121 |
+
foreach($products as $p) {
|
122 |
+
$array_data = array();
|
123 |
+
$parent = false;
|
124 |
+
$pi++;
|
125 |
+
if($total_product < $pi)
|
126 |
+
$last = true;
|
127 |
+
$product = $this->_product_model->load($p['entity_id']);
|
128 |
+
$product_instance = Mage::getModel('catalog/product')->load($p['entity_id']);
|
129 |
+
|
130 |
+
$data = $product->getData();
|
131 |
+
// Load first parent if exist
|
132 |
+
$parents = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($p['entity_id']);
|
133 |
+
$parent_instance = null;
|
134 |
+
$configurable_instance = null;
|
135 |
+
$parent_id = null;
|
136 |
+
$product_type = 'simple';
|
137 |
+
$variation_name = '';
|
138 |
+
if($product_instance->getTypeId() == 'configurable') {
|
139 |
+
$product_type = 'parent';
|
140 |
+
$variations = $product_instance->getTypeInstance(true)
|
141 |
+
->getConfigurableAttributesAsArray($product_instance);
|
142 |
+
if($variations) {
|
143 |
+
foreach ($variations as $variation) {
|
144 |
+
$variation_name .= $variation['frontend_label'] . ',';
|
145 |
+
}
|
146 |
+
$variation_name = rtrim($variation_name, ',');
|
147 |
+
}
|
148 |
+
}
|
149 |
+
if($product_instance->getTypeId() == 'simple') {
|
150 |
+
$parents = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($p['entity_id']);
|
151 |
+
if(!empty($parents)) {
|
152 |
+
$parent_instance = Mage::getModel('catalog/product')
|
153 |
+
->getCollection()
|
154 |
+
->addAttributeToFilter('type_id', 'configurable')
|
155 |
+
->addAttributeToFilter('entity_id', array('in' => $parents))
|
156 |
+
->getFirstItem();
|
157 |
+
if($parent_instance && $parent_instance->getId()) {
|
158 |
+
$parent_id = $parent_instance->getId();
|
159 |
+
$parent = $this->_product_model->load($parent_id);
|
160 |
+
$parent_instance = Mage::getModel('catalog/product')->load($parent_id);
|
161 |
+
$configurable_instance = $parent_instance;
|
162 |
+
$variations = $parent_instance->getTypeInstance(true)
|
163 |
+
->getConfigurableAttributesAsArray($parent_instance);
|
164 |
+
if($variations) {
|
165 |
+
foreach ($variations as $variation) {
|
166 |
+
$variation_name .= $variation['frontend_label'] . ',';
|
167 |
+
}
|
168 |
+
$variation_name = rtrim($variation_name, ',');
|
169 |
+
}
|
170 |
+
$product_type = 'child';
|
171 |
+
}
|
172 |
+
}
|
173 |
+
}
|
174 |
+
$parents = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($parent_id ? $parent_id : $p['entity_id']);
|
175 |
+
if(!empty($parents)) {
|
176 |
+
$parent_instance = Mage::getModel('catalog/product')
|
177 |
+
->getCollection()
|
178 |
+
->addAttributeToFilter('type_id','grouped')
|
179 |
+
->addAttributeToFilter('entity_id', array('in' => $parents))
|
180 |
+
->getFirstItem();
|
181 |
+
if($parent_instance && $parent_instance->getId()) {
|
182 |
+
//$parent_id = $parent_instance->getId();
|
183 |
+
$parent = $this->_product_model->load($parent_id);
|
184 |
+
$parent_instance = Mage::getModel('catalog/product')->load($parent_id);
|
185 |
+
}
|
186 |
+
}
|
187 |
+
$qty = $product_instance->getData('stock_item');
|
188 |
+
// Default data
|
189 |
+
$array_data['sku'] = $product_instance->getSku();
|
190 |
+
$array_data['product_id'] = $product_instance->getId();
|
191 |
+
$array_data['qty'] = (integer) $qty->getQty();
|
192 |
+
if($this->_config_model->get('data/without_product_ordering'))
|
193 |
+
$array_data['qty'] = $array_data['qty'] - (integer) $qty->getQtyOrdered();
|
194 |
+
$array_data = array_merge($array_data, $product->getCategories($product_instance, $parent_instance, $this->_id_store));
|
195 |
+
$array_data = array_merge($array_data, $product->getPrices($product_instance, $configurable_instance));
|
196 |
+
$array_data = array_merge($array_data, $product->getShippingInfo($product_instance));
|
197 |
+
// Images, gestion de la fusion parent / enfant
|
198 |
+
if($this->_config_model->get('data/parentsimages') && $parent !== false)
|
199 |
+
$array_data = array_merge($array_data, $product->getImages($data['media_gallery']['images'], $parent->getData('media_gallery')));
|
200 |
+
else
|
201 |
+
$array_data = array_merge($array_data, $product->getImages($data['media_gallery']['images']));
|
202 |
+
$array_data['name'] = $product_instance->getName();
|
203 |
+
if($product_instance->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE && isset($parent_instance)) {
|
204 |
+
$array_data['product-url'] = $parent_instance->getUrlInStore();
|
205 |
+
//$array_data['name'] = $parent_instance->getName();
|
206 |
+
$array_data['description'] = $this->_helper->cleanData($parent_instance->getDescription());
|
207 |
+
$array_data['short_description'] = $this->_helper->cleanData($parent_instance->getShortDescription());
|
208 |
+
} else {
|
209 |
+
$array_data['product-url'] = $product_instance->getUrlInStore();
|
210 |
+
$array_data['description'] = $this->_helper->cleanData($product_instance->getDescription());
|
211 |
+
$array_data['short_description'] = $this->_helper->cleanData($product_instance->getShortDescription());
|
212 |
+
}
|
213 |
+
$array_data['parent_id'] = $parent_id;
|
214 |
+
// Product variation
|
215 |
+
$array_data['product_type'] = $product_type;
|
216 |
+
$array_data['product_variation'] = $variation_name;
|
217 |
+
$array_data['image_default'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' . $product_instance->getImage();
|
218 |
+
// Selected attributes to export with Frond End value of current shop
|
219 |
+
if(!empty($attributes_to_export)) {
|
220 |
+
foreach($attributes_to_export as $field => $attr) {
|
221 |
+
if(!in_array($field, $this->_excludes) && !isset($array_data[$field])) {
|
222 |
+
if($product_instance->getData($field) === null)
|
223 |
+
$array_data[$attr] = '';
|
224 |
+
else if($this->_config_model->get('performances/formatdata'))
|
225 |
+
$array_data[$attr] = $this->_helper->cleanData($product_instance->getResource()->getAttribute($field)->getFrontend()->getValue($product_instance), true);
|
226 |
+
else
|
227 |
+
$array_data[$attr] = $this->_helper->cleanData($product_instance->getResource()->getAttribute($field)->getFrontend()->getValue($product_instance));
|
228 |
+
}
|
229 |
+
}
|
230 |
+
}
|
231 |
+
// Get header of feed
|
232 |
+
if($first) {
|
233 |
+
$fields_header = array();
|
234 |
+
foreach($array_data as $name => $value) {
|
235 |
+
$fields_header[] = $name;
|
236 |
+
}
|
237 |
+
// Get content type if streamed feed
|
238 |
+
if($this->_stream)
|
239 |
+
header('Content-Type: ' . $feed->getContentType() . '; charset=utf-8');
|
240 |
+
$feed->setFields($fields_header);
|
241 |
+
$this->_write($feed->makeHeader());
|
242 |
+
$first = false;
|
243 |
+
}
|
244 |
+
$this->_write($feed->makeData($array_data, array('last' => $last)));
|
245 |
+
if(!$this->_stream) {
|
246 |
+
if($pi % 20 == 0)
|
247 |
+
echo date('Y-m-d h:i:s') .' - Export ' . $pi . ' products<br />';
|
248 |
+
flush();
|
249 |
+
}
|
250 |
+
$app = Mage::app();
|
251 |
+
if ($app != null) {
|
252 |
+
$cache = $app->getCache();
|
253 |
+
if ($cache != null)
|
254 |
+
$cache->clean();
|
255 |
+
}
|
256 |
+
// Fix Sébastien Ledan
|
257 |
+
$product->clearInstance();
|
258 |
+
$product_instance->clearInstance();
|
259 |
+
if($parent != null)
|
260 |
+
$parent->clearInstance();
|
261 |
+
if($parent_instance != null)
|
262 |
+
$parent_instance->clearInstance();
|
263 |
+
unset($array_data);
|
264 |
+
}
|
265 |
+
$this->_write($feed->makeFooter());
|
266 |
+
if(!$this->_stream) {
|
267 |
+
$this->_copyFile();
|
268 |
+
$store_code = Mage::app()->getStore($this->_id_store)->getCode();
|
269 |
+
Mage::app()->setCurrentStore($this->getCurrentStore());
|
270 |
+
$url_file = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'lengow' . DS . $store_code . DS . $this->_filename . '.' . $this->_format;
|
271 |
+
echo $this->_helper->__('Your feed is available here : %s' , '<a href="' . $url_file . '">' . $url_file . '</a>');
|
272 |
+
}
|
273 |
+
}
|
274 |
+
|
275 |
+
protected function _getProductsCollection($types = null,
|
276 |
+
$status = null,
|
277 |
+
$export_child = null,
|
278 |
+
$out_of_stock = null,
|
279 |
+
$selected_products = null,
|
280 |
+
$limit = null,
|
281 |
+
$offset = null,
|
282 |
+
$ids_product = null) {
|
283 |
+
// Filter types
|
284 |
+
if($types) {
|
285 |
+
$_types = explode(',', $types);
|
286 |
+
} else {
|
287 |
+
$_types = $this->_config_model->get('global/producttype');
|
288 |
+
$_types = explode(',', $_types);
|
289 |
+
}
|
290 |
+
if(is_null($selected_products))
|
291 |
+
$selected_products = $this->_config_model->onlySelectedProducts();
|
292 |
+
// Search product to export
|
293 |
+
$products = $this->_product_model
|
294 |
+
->getCollection()
|
295 |
+
->addAttributeToSelect('sku');
|
296 |
+
// Filter status
|
297 |
+
if($status == 1)
|
298 |
+
$products->addAttributeToFilter('status', 1);
|
299 |
+
else if($status == 2)
|
300 |
+
$products->addAttributeToFilter('status', 0);
|
301 |
+
$products->addStoreFilter($this->_id_store)
|
302 |
+
->addAttributeToFilter('type_id', array('in' => $_types));
|
303 |
+
// Export only selected products
|
304 |
+
if($selected_products) {
|
305 |
+
$products->addAttributeToFilter('lengow_product', 1);
|
306 |
+
}
|
307 |
+
// Filter out of stock
|
308 |
+
if(is_null($out_of_stock))
|
309 |
+
$out_of_stock = $this->_config_model->isExportSoldout();
|
310 |
+
$products->joinTable('cataloginventory/stock_item', 'product_id=entity_id', array('qty' => 'qty', 'is_in_stock' => 'is_in_stock'), $this->_getOutOfStockSQL($out_of_stock), 'inner');
|
311 |
+
// Ids product
|
312 |
+
if($ids_product) {
|
313 |
+
$ids_product = explode(',', $ids_product);
|
314 |
+
$products->addAttributeToFilter('entity_id', array('in' => $ids_product));
|
315 |
+
}
|
316 |
+
// Limit & Offset
|
317 |
+
if($limit) {
|
318 |
+
if($offset)
|
319 |
+
$products->getSelect()->limit($limit, $offset);
|
320 |
+
else
|
321 |
+
$products->getSelect()->limit($limit);
|
322 |
+
}
|
323 |
+
// Filter to hide products
|
324 |
+
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
|
325 |
+
$products->getSelect()
|
326 |
+
->distinct(true)
|
327 |
+
->group('entity_id');
|
328 |
+
return $products->getData();
|
329 |
+
}
|
330 |
+
|
331 |
+
/**
|
332 |
+
* Filter out of stock product
|
333 |
+
**/
|
334 |
+
protected function _getOutOfStockSQL($out_of_stock = false) {
|
335 |
+
// Filter product without stock
|
336 |
+
if(!$out_of_stock) {
|
337 |
+
$config = (int)Mage::getStoreConfigFlag(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK);
|
338 |
+
$sql = '({{table}}.`is_in_stock` = 1) '
|
339 |
+
. ' OR IF({{table}}.`use_config_manage_stock` = 1, ' . $config . ', {{table}}.`manage_stock`) = 0';
|
340 |
+
unset($config);
|
341 |
+
return $sql;
|
342 |
+
}
|
343 |
+
}
|
344 |
+
|
345 |
+
/**
|
346 |
+
* Return attributes to export
|
347 |
+
*/
|
348 |
+
protected function _getAttributesFromConfig() {
|
349 |
+
$attributes = $this->_config_model->getSelectedAttributes();
|
350 |
+
foreach($attributes as $name => $value)
|
351 |
+
self::$DEFAULT_FIELDS[$name] = $value;
|
352 |
+
return self::$DEFAULT_FIELDS;
|
353 |
+
}
|
354 |
+
|
355 |
+
/**
|
356 |
+
* Retourne les attributs matchés par le client
|
357 |
+
*/
|
358 |
+
protected function getAttributesFromConfig($exist = false) {
|
359 |
+
$attributes = $this->_config_model->getMappingAllAttributes();
|
360 |
+
if($exist) {
|
361 |
+
$product = Mage::getModel('catalog/product');
|
362 |
+
foreach ($attributes as $key=>$code) {
|
363 |
+
$attribute = $product->getResource()->getAttribute($code);
|
364 |
+
if($attribute instanceof Mage_Catalog_Model_Resource_Eav_Attribute && $attribute->getId() && $attribute->getFrontendInput() != 'weee') {
|
365 |
+
$attributes[$key] = $code;
|
366 |
+
}
|
367 |
+
}
|
368 |
+
}
|
369 |
+
return $attributes;
|
370 |
+
}
|
371 |
+
|
372 |
+
/**
|
373 |
+
* File generation
|
374 |
+
*/
|
375 |
+
|
376 |
+
protected function _write($data) {
|
377 |
+
if($this->_stream == false) {
|
378 |
+
if(!$this->_file) {
|
379 |
+
$this->_initFile();
|
380 |
+
}
|
381 |
+
$this->_file->streamLock();
|
382 |
+
$this->_file->streamWrite($data);
|
383 |
+
$this->_file->streamUnlock();
|
384 |
+
} else {
|
385 |
+
echo $data;
|
386 |
+
flush();
|
387 |
+
}
|
388 |
+
}
|
389 |
+
|
390 |
+
protected function _initFile() {
|
391 |
+
$this->_time = time();
|
392 |
+
$store_code = Mage::app()->getStore($this->_id_store)->getCode();
|
393 |
+
$file_path = Mage::getBaseDir('media') . DS . 'lengow' . DS . $store_code . DS;
|
394 |
+
$this->_file = new Varien_Io_File;
|
395 |
+
$this->_file->checkAndCreateFolder($file_path);
|
396 |
+
$this->_file->cd($file_path);
|
397 |
+
$this->_file->streamOpen($this->_filename . '.' . $this->_time . '.' . $this->_format, 'w+');
|
398 |
+
}
|
399 |
+
|
400 |
+
protected function _copyFile() {
|
401 |
+
$store_code = Mage::app()->getStore($this->_id_store)->getCode();
|
402 |
+
$file_path = Mage::getBaseDir('media') . DS . 'lengow' . DS . $store_code . DS;
|
403 |
+
copy($file_path . $this->_filename . '.' . $this->_time . '.' . $this->_format, $file_path . $this->_filename . '.' . $this->_format);
|
404 |
+
unlink($file_path . $this->_filename . '.' . $this->_time . '.' . $this->_format);
|
405 |
+
}
|
406 |
+
}
|
app/code/community/Lengow/Export/Model/Observer.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export model observer
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Export_Model_Observer {
|
12 |
+
|
13 |
+
public function cron($observer) {
|
14 |
+
$store_collection = Mage::getResourceModel('core/store_collection')
|
15 |
+
->addFieldToFilter('is_active', 1);
|
16 |
+
$exceptions = array();
|
17 |
+
foreach($store_collection as $store) {
|
18 |
+
try {
|
19 |
+
if(Mage::getStoreConfig('export/performances/active_cron', $store)) {
|
20 |
+
$generate = Mage::getSingleton('export/generate');
|
21 |
+
$format =Mage::getStoreConfig('export/data/format', $store);
|
22 |
+
$generate->exec($store->getId(), null, $format, null, null, null, null, null, false, false);
|
23 |
+
}
|
24 |
+
} catch (Exception $e) {
|
25 |
+
echo $e->getMessage() . "\n" . $e->getTraceAsString() . "\n";
|
26 |
+
}
|
27 |
+
}
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
|
31 |
+
}
|
app/code/community/Lengow/Export/Model/Shipping/Carrier/Lengow.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Lengow shipping model
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Profileolabs_Lengow
|
8 |
+
* @author kassim belghait
|
9 |
+
*/
|
10 |
+
class Lengow_Export_Model_Shipping_Carrier_Lengow
|
11 |
+
extends Mage_Shipping_Model_Carrier_Abstract
|
12 |
+
implements Mage_Shipping_Model_Carrier_Interface {
|
13 |
+
|
14 |
+
protected $_code = 'lengow';
|
15 |
+
protected $_isFixed = true;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* FreeShipping Rates Collector
|
19 |
+
*
|
20 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
21 |
+
* @return Mage_Shipping_Model_Rate_Result
|
22 |
+
*/
|
23 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
|
24 |
+
if (!$this->isActive()) {
|
25 |
+
return false;
|
26 |
+
}
|
27 |
+
$result = Mage::getModel('shipping/rate_result');
|
28 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
29 |
+
$method->setCarrier('lengow');
|
30 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
31 |
+
$method->setMethod('lengow');
|
32 |
+
$method->setMethodTitle($this->getConfigData('name'));
|
33 |
+
$method->setPrice($this->getSession()->getShippingPrice());
|
34 |
+
$method->setCost($this->getSession()->getShippingPrice());
|
35 |
+
$result->append($method);
|
36 |
+
return $result;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Processing additional validation to check is carrier applicable.
|
41 |
+
*
|
42 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
43 |
+
* @return Mage_Shipping_Model_Carrier_Abstract|Mage_Shipping_Model_Rate_Result_Error|boolean
|
44 |
+
*/
|
45 |
+
public function proccessAdditionalValidation(Mage_Shipping_Model_Rate_Request $request) {
|
46 |
+
if(Mage::getVersion() == '1.4.1.0')
|
47 |
+
return $this->isActive();
|
48 |
+
return parent::proccessAdditionalValidation($request);
|
49 |
+
}
|
50 |
+
|
51 |
+
public function getSession() {
|
52 |
+
return Mage::getSingleton('checkout/session');
|
53 |
+
}
|
54 |
+
|
55 |
+
public function isActive() {
|
56 |
+
if($this->getSession()->getIsLengow())
|
57 |
+
return true;
|
58 |
+
return false;
|
59 |
+
}
|
60 |
+
|
61 |
+
public function getAllowedMethods() {
|
62 |
+
return array('lengow'=>$this->getConfigData('name'));
|
63 |
+
}
|
64 |
+
|
65 |
+
}
|
app/code/community/Lengow/Export/Model/Source/.DS_Store
ADDED
Binary file
|
app/code/community/Lengow/Export/Model/Source/Attributes.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export model export source attributes
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Export_Model_Source_Attributes {
|
12 |
+
|
13 |
+
public function toOptionArray() {
|
14 |
+
$attributes = Mage::getSingleton('export/convert_parser_product')->getExternalAttributes();
|
15 |
+
array_unshift($attributes, array('value' => 'none' ,
|
16 |
+
'label' => Mage::helper('adminhtml')->__('Select attribut to map')));
|
17 |
+
return $attributes;
|
18 |
+
}
|
19 |
+
|
20 |
+
}
|
app/code/community/Lengow/Export/Model/Source/Types.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export model source types
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Export_Model_Source_Types {
|
12 |
+
|
13 |
+
public function toOptionArray() {
|
14 |
+
$attributes = Mage::getSingleton('export/convert_parser_product')->getExternalAttributes();
|
15 |
+
array_unshift($attributes, array('value' => 'none' ,
|
16 |
+
'label' => $this->__('Sélectionnez l\'attribut à mapper')));
|
17 |
+
return $attributes;
|
18 |
+
}
|
19 |
+
|
20 |
+
}
|
app/code/community/Lengow/Export/Model/System/Config/Backend/Apikey.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow Backend Model for Config Api key
|
4 |
+
* @category Lengow
|
5 |
+
* @package Lengow_Export
|
6 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
7 |
+
* @copyright 2013 Lengow SAS
|
8 |
+
*/
|
9 |
+
class Lengow_Export_Model_System_Config_Backend_Apikey extends Mage_Core_Model_Config_Data {
|
10 |
+
|
11 |
+
protected function _beforeSave() {
|
12 |
+
parent::_beforeSave();
|
13 |
+
if((boolean)$this->getFieldsetDataValue('enabled') && $this->getValue() == '')
|
14 |
+
Mage::throwException(Mage::helper('sync')->__('API Key (Token) is empty'));
|
15 |
+
if($this->isValueChanged()) {
|
16 |
+
/* @var $service Lengow_Export_Model_ManageOrders_Service */
|
17 |
+
$service = Mage::getSingleton('Lengow_Export/manageorders_service');
|
18 |
+
if((boolean)$this->getFieldsetDataValue('enabled') && !$service->checkApiKey($this->getValue()))
|
19 |
+
Mage::throwException(Mage::helper('sync')->__('API key (Token) not valid'));
|
20 |
+
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
}
|
app/code/community/Lengow/Export/Model/System/Config/Source/Category/Level.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export model system config source category level
|
4 |
+
* Level of deep category
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Export
|
8 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
9 |
+
* @copyright 2013 Lengow SAS
|
10 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
11 |
+
*/
|
12 |
+
class Lengow_Export_Model_System_Config_Source_Category_Level extends Mage_Core_Model_Config_Data {
|
13 |
+
|
14 |
+
public function toOptionArray() {
|
15 |
+
return array(
|
16 |
+
array('value' => 1,
|
17 |
+
'label' => 1),
|
18 |
+
array('value' => 2,
|
19 |
+
'label' => 2),
|
20 |
+
array('value' => 3,
|
21 |
+
'label' => 3),
|
22 |
+
array('value' => 4,
|
23 |
+
'label' => 4),
|
24 |
+
array('value' => 5,
|
25 |
+
'label' => 5),
|
26 |
+
array('value' => 6,
|
27 |
+
'label' => 6),
|
28 |
+
array('value' => 'all',
|
29 |
+
'label' => Mage::helper('adminhtml')->__('All')),
|
30 |
+
);
|
31 |
+
}
|
32 |
+
|
33 |
+
}
|
app/code/community/Lengow/Export/Model/System/Config/Source/Format.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export model systems config source format
|
4 |
+
* format of export
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Export
|
8 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
9 |
+
* @copyright 2013 Lengow SAS
|
10 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
11 |
+
*/
|
12 |
+
class Lengow_Export_Model_System_Config_Source_Format extends Mage_Core_Model_Config_Data {
|
13 |
+
|
14 |
+
public function toOptionArray() {
|
15 |
+
return array(
|
16 |
+
array('value' => 'csv',
|
17 |
+
'label' => 'csv'),
|
18 |
+
array('value' => 'xml',
|
19 |
+
'label' => 'xml'),
|
20 |
+
array('value' => 'json',
|
21 |
+
'label' => 'json'),
|
22 |
+
array('value' => 'yaml',
|
23 |
+
'label' => 'yaml'),
|
24 |
+
);
|
25 |
+
}
|
26 |
+
|
27 |
+
public function toSelectArray() {
|
28 |
+
$select = array();
|
29 |
+
foreach($this->toOptionArray() as $option) {
|
30 |
+
$select[$option['value']] = $option['label'];
|
31 |
+
}
|
32 |
+
return $select;
|
33 |
+
}
|
34 |
+
}
|
app/code/community/Lengow/Export/Model/System/Config/Source/Getattributes.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export model config
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Export_Model_System_Config_Source_Getattributes extends Mage_Core_Model_Config_Data {
|
12 |
+
|
13 |
+
public function toOptionArray() {
|
14 |
+
$attribute = Mage::getResourceModel('eav/entity_attribute_collection')
|
15 |
+
->setEntityTypeFilter(Mage::getModel('catalog/product')
|
16 |
+
->getResource()
|
17 |
+
->getTypeId());
|
18 |
+
$attributeArray = array();
|
19 |
+
foreach ($attribute as $option) {
|
20 |
+
$attributeArray[] = array(
|
21 |
+
'value' => $option->getAttributeCode(),
|
22 |
+
'label' => $option->getAttributeCode()
|
23 |
+
);
|
24 |
+
}
|
25 |
+
return $attributeArray;
|
26 |
+
}
|
27 |
+
|
28 |
+
}
|
app/code/community/Lengow/Export/Model/System/Config/Source/Images.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export model system config source count images
|
4 |
+
* Number of images to export
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Export
|
8 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
9 |
+
* @copyright 2013 Lengow SAS
|
10 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
11 |
+
*/
|
12 |
+
class Lengow_Export_Model_System_Config_Source_Images extends Mage_Core_Model_Config_Data {
|
13 |
+
|
14 |
+
public function toOptionArray() {
|
15 |
+
$array = array();
|
16 |
+
for($i = 5; $i <= 20; $i++) {
|
17 |
+
$array[] = array('value' => $i,
|
18 |
+
'label' => $i);
|
19 |
+
}
|
20 |
+
return $array;
|
21 |
+
}
|
22 |
+
|
23 |
+
public function toSelectArray() {
|
24 |
+
$select = array();
|
25 |
+
foreach($this->toOptionArray() as $option) {
|
26 |
+
$select[$option['value']] = $option['label'];
|
27 |
+
}
|
28 |
+
return $select;
|
29 |
+
}
|
30 |
+
|
31 |
+
}
|
app/code/community/Lengow/Export/Model/System/Config/Source/Status.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export model system config source status
|
4 |
+
* Status of product to export
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Export
|
8 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
9 |
+
* @copyright 2013 Lengow SAS
|
10 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
11 |
+
*/
|
12 |
+
class Lengow_Export_Model_System_Config_Source_Status extends Mage_Core_Model_Config_Data {
|
13 |
+
|
14 |
+
public function toOptionArray() {
|
15 |
+
return array(
|
16 |
+
array('value' => '1',
|
17 |
+
'label' => Mage::helper('adminhtml')->__('Enabled')),
|
18 |
+
array('value' => '2',
|
19 |
+
'label' => Mage::helper('adminhtml')->__('Disabled')),
|
20 |
+
array('value' => '1,2',
|
21 |
+
'label' => Mage::helper('adminhtml')->__('Enable') . ', ' . Mage::helper('adminhtml')->__('Disabled')),
|
22 |
+
);
|
23 |
+
}
|
24 |
+
|
25 |
+
public function toSelectArray() {
|
26 |
+
$select = array();
|
27 |
+
foreach($this->toOptionArray() as $option) {
|
28 |
+
$select[$option['value']] = $option['label'];
|
29 |
+
}
|
30 |
+
return $select;
|
31 |
+
}
|
32 |
+
|
33 |
+
}
|
app/code/community/Lengow/Export/Model/System/Config/Source/Types.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export model system config source types
|
4 |
+
* Types of product to export
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Export
|
8 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
9 |
+
* @copyright 2013 Lengow SAS
|
10 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
11 |
+
*/
|
12 |
+
class Lengow_Export_Model_System_Config_Source_Types extends Mage_Core_Model_Config_Data {
|
13 |
+
|
14 |
+
public function toOptionArray() {
|
15 |
+
return array(
|
16 |
+
array('value' => 'configurable',
|
17 |
+
'label' => Mage::helper('adminhtml')->__('Configurable')),
|
18 |
+
array('value' => 'simple',
|
19 |
+
'label' => Mage::helper('adminhtml')->__('Simple')),
|
20 |
+
array('value' => 'bundle',
|
21 |
+
'label' => Mage::helper('adminhtml')->__('Bundle')),
|
22 |
+
array('value' => 'grouped',
|
23 |
+
'label' => Mage::helper('adminhtml')->__('Grouped')),
|
24 |
+
array('value' => 'virtual',
|
25 |
+
'label' => Mage::helper('adminhtml')->__('Virtual')),
|
26 |
+
);
|
27 |
+
}
|
28 |
+
|
29 |
+
public function toSelectArray() {
|
30 |
+
$select = array();
|
31 |
+
foreach($this->toOptionArray() as $option) {
|
32 |
+
$select[$option['value']] = $option['label'];
|
33 |
+
}
|
34 |
+
return $select;
|
35 |
+
}
|
36 |
+
|
37 |
+
}
|
app/code/community/Lengow/Export/controllers/.DS_Store
ADDED
Binary file
|
app/code/community/Lengow/Export/controllers/Adminhtml/.DS_Store
ADDED
Binary file
|
app/code/community/Lengow/Export/controllers/Adminhtml/Lengow/ExportController.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow adminhtml export controller
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Export_Adminhtml_Lengow_ExportController extends Mage_Adminhtml_Controller_Action {
|
12 |
+
|
13 |
+
public function indexAction() {
|
14 |
+
$this->loadLayout();
|
15 |
+
$this->renderLayout();
|
16 |
+
return $this;
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Product grid for AJAX request
|
21 |
+
*/
|
22 |
+
public function gridAction() {
|
23 |
+
$this->loadLayout();
|
24 |
+
$this->getResponse()->setBody(
|
25 |
+
$this->getLayout()->createBlock('export/adminhtml_product_grid')->toHtml()
|
26 |
+
);
|
27 |
+
}
|
28 |
+
|
29 |
+
public function massPublishAction() {
|
30 |
+
$productIds = (array)$this->getRequest()->getParam('product');
|
31 |
+
$storeId = (int)$this->getRequest()->getParam('store', 0);
|
32 |
+
$publish = (int)$this->getRequest()->getParam('publish');
|
33 |
+
$resource = Mage::getResourceModel('catalog/product');
|
34 |
+
$entityTypeId = $resource->getEntityType()->getId();
|
35 |
+
try {
|
36 |
+
foreach ($productIds as $productId) {
|
37 |
+
$product = new Varien_Object(array('entity_id'=>$productId,
|
38 |
+
'id'=>$productId,
|
39 |
+
'entity_type_id'=>$entityTypeId,
|
40 |
+
'store_id'=>$storeId,
|
41 |
+
'lengow_product'=>$publish));
|
42 |
+
$resource->saveAttribute($product,'lengow_product');
|
43 |
+
|
44 |
+
}
|
45 |
+
$this->_getSession()->addSuccess(
|
46 |
+
$this->__('Total of %d record(s) were successfully updated', count($productIds))
|
47 |
+
);
|
48 |
+
}
|
49 |
+
catch (Mage_Core_Model_Exception $e) {
|
50 |
+
$this->_getSession()->addError($e->getMessage());
|
51 |
+
}
|
52 |
+
catch (Exception $e) {
|
53 |
+
$this->_getSession()->addException($e, $e->getMessage() . Mage::helper('export')->__('There was an error while updating product(s) publication'));
|
54 |
+
}
|
55 |
+
|
56 |
+
$this->_redirect('*/*/', array('store'=> $storeId));
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
protected function _getSession() {
|
61 |
+
return Mage::getSingleton('adminhtml/session');
|
62 |
+
}
|
63 |
+
|
64 |
+
}
|
app/code/community/Lengow/Export/controllers/FeedController.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export controller
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Export_FeedController extends Mage_Core_Controller_Front_Action {
|
12 |
+
|
13 |
+
public function indexAction() {
|
14 |
+
set_time_limit(0);
|
15 |
+
ini_set('memory_limit', '1G');
|
16 |
+
$mode = $this->getRequest()->getParam('mode');
|
17 |
+
$helper = Mage::helper('export/security');
|
18 |
+
if($helper->checkIp()) {
|
19 |
+
$this->_configModel = Mage::getSingleton('export/config');
|
20 |
+
try {
|
21 |
+
$this->loadLayout(false);
|
22 |
+
$this->renderLayout();
|
23 |
+
} catch (Exception $e) {
|
24 |
+
Mage::throwException($e);
|
25 |
+
}
|
26 |
+
$generate = Mage::getSingleton('export/generate');
|
27 |
+
$generate->setCurrentStore(Mage::app()->getStore()->getId());
|
28 |
+
$id_store = (integer) $this->getRequest()->getParam('store', Mage::app()->getStore()->getId());
|
29 |
+
Mage::app()->setCurrentStore($id_store);
|
30 |
+
$format = (string) $this->getRequest()->getParam('format', 'csv');
|
31 |
+
$types = $this->getRequest()->getParam('product_type', null);
|
32 |
+
$export_child = $this->getRequest()->getParam('export_child', null);
|
33 |
+
$status = $this->getRequest()->getParam('product_status', null);
|
34 |
+
$out_of_stock = $this->getRequest()->getParam('product_out_of_stock', null);
|
35 |
+
$selected_products = $this->getRequest()->getParam('selected_products', null);
|
36 |
+
$stream = $this->getRequest()->getParam('stream', null);
|
37 |
+
$limit = $this->getRequest()->getParam('limit', null);
|
38 |
+
$offset = $this->getRequest()->getParam('offset', null);
|
39 |
+
$ids_product = $this->getRequest()->getParam('ids_product', null);
|
40 |
+
if($locale = $this->getRequest()->getParam('locale', null)) {
|
41 |
+
// changing locale works!
|
42 |
+
Mage::app()->getLocale()->setLocale($locale);
|
43 |
+
// needed to add this
|
44 |
+
Mage::app()->getTranslator()->setLocale($locale);
|
45 |
+
// translation now works
|
46 |
+
Mage::app()->getTranslator()->init('frontend', true);
|
47 |
+
}
|
48 |
+
$generate->exec($id_store, $mode, $format, $types, $status, $export_child, $out_of_stock, $selected_products, $stream, $limit, $offset, $ids_product);
|
49 |
+
} else {
|
50 |
+
echo Mage::helper('export')->__('Unauthorised IP : %s', $_SERVER['REMOTE_ADDR']);
|
51 |
+
}
|
52 |
+
}
|
53 |
+
}
|
app/code/community/Lengow/Export/etc/config.xml
ADDED
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Lengow_Export>
|
5 |
+
<version>2.0.1.0</version>
|
6 |
+
</Lengow_Export>
|
7 |
+
</modules>
|
8 |
+
<admin>
|
9 |
+
<routers>
|
10 |
+
<export>
|
11 |
+
<use>admin</use>
|
12 |
+
<args>
|
13 |
+
<module>Lengow_Export</module>
|
14 |
+
<frontName>lengow</frontName>
|
15 |
+
</args>
|
16 |
+
</export>
|
17 |
+
<adminhtml>
|
18 |
+
<args>
|
19 |
+
<modules>
|
20 |
+
<export before="Mage_Adminhtml">Lengow_Export_Adminhtml</export>
|
21 |
+
</modules>
|
22 |
+
</args>
|
23 |
+
</adminhtml>
|
24 |
+
</routers>
|
25 |
+
</admin>
|
26 |
+
<global>
|
27 |
+
<models>
|
28 |
+
<export>
|
29 |
+
<class>Lengow_Export_Model</class>
|
30 |
+
<resourceModel>export_mysql4</resourceModel>
|
31 |
+
</export>
|
32 |
+
<export_mysql4>
|
33 |
+
<class>Lengow_Export_Model_Mysql4</class>
|
34 |
+
<entities>
|
35 |
+
<manageorders_log>
|
36 |
+
<table>lengow_log</table>
|
37 |
+
</manageorders_log>
|
38 |
+
</entities>
|
39 |
+
</export_mysql4>
|
40 |
+
</models>
|
41 |
+
<resources>
|
42 |
+
<export_setup>
|
43 |
+
<connection>
|
44 |
+
<use>core_setup</use>
|
45 |
+
</connection>
|
46 |
+
</export_setup>
|
47 |
+
<export_write>
|
48 |
+
<connection>
|
49 |
+
<use>core_write</use>
|
50 |
+
</connection>
|
51 |
+
</export_write>
|
52 |
+
<export_read>
|
53 |
+
<connection>
|
54 |
+
<use>core_read</use>
|
55 |
+
</connection>
|
56 |
+
</export_read>
|
57 |
+
</resources>
|
58 |
+
<blocks>
|
59 |
+
<export>
|
60 |
+
<class>Lengow_Export_Block</class>
|
61 |
+
</export>
|
62 |
+
</blocks>
|
63 |
+
<helpers>
|
64 |
+
<export>
|
65 |
+
<class>Lengow_Export_Helper</class>
|
66 |
+
</export>
|
67 |
+
</helpers>
|
68 |
+
</global>
|
69 |
+
<!--<frontend>
|
70 |
+
<routers>
|
71 |
+
<lengow>
|
72 |
+
<use>standard</use>
|
73 |
+
<args>
|
74 |
+
<module>Lengow_Export</module>
|
75 |
+
<frontName>lengow</frontName>
|
76 |
+
</args>
|
77 |
+
</lengow>
|
78 |
+
</routers>
|
79 |
+
<layout>
|
80 |
+
<updates>
|
81 |
+
<export>
|
82 |
+
<file>lengow.xml</file>
|
83 |
+
</export>
|
84 |
+
</updates>
|
85 |
+
</layout>
|
86 |
+
</frontend>-->
|
87 |
+
<adminhtml>
|
88 |
+
<translate>
|
89 |
+
<modules>
|
90 |
+
<Lengow_Export>
|
91 |
+
<files>
|
92 |
+
<default>Lengow_Connector.csv</default>
|
93 |
+
</files>
|
94 |
+
</Lengow_Export>
|
95 |
+
</modules>
|
96 |
+
</translate>
|
97 |
+
<menu>
|
98 |
+
<lengow>
|
99 |
+
<title>Lengow</title>
|
100 |
+
<sort_order>20</sort_order>
|
101 |
+
<children>
|
102 |
+
<export translate="title" module="export">
|
103 |
+
<title>Manage Products Export</title>
|
104 |
+
<action>adminhtml/lengow_export</action>
|
105 |
+
<sort_order>200</sort_order>
|
106 |
+
</export>
|
107 |
+
</children>
|
108 |
+
</lengow>
|
109 |
+
</menu>
|
110 |
+
<acl>
|
111 |
+
<resources>
|
112 |
+
<admin>
|
113 |
+
<children>
|
114 |
+
<system>
|
115 |
+
<children>
|
116 |
+
<config>
|
117 |
+
<children>
|
118 |
+
<export translate="title" module="export">
|
119 |
+
<title>Products</title>
|
120 |
+
</export>
|
121 |
+
</children>
|
122 |
+
</config>
|
123 |
+
</children>
|
124 |
+
</system>
|
125 |
+
<lengow translate="title" module="export">
|
126 |
+
<title>Lengow</title>
|
127 |
+
<sort_order>22</sort_order>
|
128 |
+
</lengow>
|
129 |
+
</children>
|
130 |
+
</admin>
|
131 |
+
</resources>
|
132 |
+
</acl>
|
133 |
+
</adminhtml>
|
134 |
+
<crontab>
|
135 |
+
<jobs>
|
136 |
+
<lengow_export_feed>
|
137 |
+
<schedule>
|
138 |
+
<cron_expr>* */4 * * *</cron_expr>
|
139 |
+
</schedule>
|
140 |
+
<run>
|
141 |
+
<model>export/observer::cron</model>
|
142 |
+
</run>
|
143 |
+
</lengow_export_feed>
|
144 |
+
</jobs>
|
145 |
+
</crontab>
|
146 |
+
<default>
|
147 |
+
<export>
|
148 |
+
<global>
|
149 |
+
<valid_ip></valid_ip>
|
150 |
+
<export_only_selected>0</export_only_selected>
|
151 |
+
<export_soldout>0</export_soldout>
|
152 |
+
<producttype>simple,configurable</producttype>
|
153 |
+
</global>
|
154 |
+
<data>
|
155 |
+
<default_shipping_delay>2</default_shipping_delay>
|
156 |
+
<default_shipping_price></default_shipping_price>
|
157 |
+
<default_shipping_method>flatrate_flatrate</default_shipping_method>
|
158 |
+
<shipping_price_based_on>FR</shipping_price_based_on>
|
159 |
+
<formatdata>0</formatdata>
|
160 |
+
<levelcategory>5</levelcategory>
|
161 |
+
<count_images>5</count_images>
|
162 |
+
</data>
|
163 |
+
<performances>
|
164 |
+
<usesavefile>0</usesavefile>
|
165 |
+
<active_cron>0</active_cron>
|
166 |
+
</performances>
|
167 |
+
</export>
|
168 |
+
</default>
|
169 |
+
</config>
|
app/code/community/Lengow/Export/etc/system.xml
ADDED
@@ -0,0 +1,243 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<lengow translate="label" module="export">
|
5 |
+
<label>Lengow</label>
|
6 |
+
<sort_order>210</sort_order>
|
7 |
+
</lengow>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<export translate="label" module="export">
|
11 |
+
<label>Export Configuration</label>
|
12 |
+
<tab>lengow</tab>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>90</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>1</show_in_store>
|
18 |
+
<groups>
|
19 |
+
<global translate="label comment">
|
20 |
+
<label>Global</label>
|
21 |
+
<show_in_default>1</show_in_default>
|
22 |
+
<show_in_website>1</show_in_website>
|
23 |
+
<show_in_store>1</show_in_store>
|
24 |
+
<sort_order>1</sort_order>
|
25 |
+
<fields>
|
26 |
+
<valid_ip>
|
27 |
+
<label>Ip authorised to export</label>
|
28 |
+
<comment><![CDATA[Authorized acces to catalog export by IP, separated by ;]]></comment>
|
29 |
+
<frontend_type>text</frontend_type>
|
30 |
+
<sort_order>6</sort_order>
|
31 |
+
<show_in_default>1</show_in_default>
|
32 |
+
<show_in_website>1</show_in_website>
|
33 |
+
<show_in_store>1</show_in_store>
|
34 |
+
</valid_ip>
|
35 |
+
<export_only_selected>
|
36 |
+
<label>Export only selected product</label>
|
37 |
+
<comment></comment>
|
38 |
+
<frontend_type>select</frontend_type>
|
39 |
+
<sort_order>9</sort_order>
|
40 |
+
<show_in_default>1</show_in_default>
|
41 |
+
<show_in_website>1</show_in_website>
|
42 |
+
<show_in_store>1</show_in_store>
|
43 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
44 |
+
</export_only_selected>
|
45 |
+
<export_soldout>
|
46 |
+
<label>Export product out of stock</label>
|
47 |
+
<comment></comment>
|
48 |
+
<frontend_type>select</frontend_type>
|
49 |
+
<sort_order>60</sort_order>
|
50 |
+
<show_in_default>1</show_in_default>
|
51 |
+
<show_in_website>1</show_in_website>
|
52 |
+
<show_in_store>1</show_in_store>
|
53 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
54 |
+
</export_soldout>
|
55 |
+
<producttype>
|
56 |
+
<label>Product type to export</label>
|
57 |
+
<comment></comment>
|
58 |
+
<frontend_type>multiselect</frontend_type>
|
59 |
+
<sort_order>70</sort_order>
|
60 |
+
<show_in_default>1</show_in_default>
|
61 |
+
<show_in_website>1</show_in_website>
|
62 |
+
<show_in_store>1</show_in_store>
|
63 |
+
<source_model>export/system_config_source_types</source_model>
|
64 |
+
</producttype>
|
65 |
+
<productstatus>
|
66 |
+
<label>Status of product to export</label>
|
67 |
+
<comment></comment>
|
68 |
+
<frontend_type>select</frontend_type>
|
69 |
+
<sort_order>80</sort_order>
|
70 |
+
<show_in_default>1</show_in_default>
|
71 |
+
<show_in_website>1</show_in_website>
|
72 |
+
<show_in_store>1</show_in_store>
|
73 |
+
<source_model>export/system_config_source_status</source_model>
|
74 |
+
</productstatus>
|
75 |
+
<!--<productchildren>
|
76 |
+
<label>Export child product</label>
|
77 |
+
<comment>Export child for configurable product</comment>
|
78 |
+
<frontend_type>select</frontend_type>
|
79 |
+
<sort_order>90</sort_order>
|
80 |
+
<show_in_default>1</show_in_default>
|
81 |
+
<show_in_website>1</show_in_website>
|
82 |
+
<show_in_store>1</show_in_store>
|
83 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
84 |
+
</productchildren>-->
|
85 |
+
</fields>
|
86 |
+
</global>
|
87 |
+
<data translate="label comment">
|
88 |
+
<label>Data</label>
|
89 |
+
<comment></comment>
|
90 |
+
<show_in_default>1</show_in_default>
|
91 |
+
<show_in_website>1</show_in_website>
|
92 |
+
<show_in_store>1</show_in_store>
|
93 |
+
<sort_order>2</sort_order>
|
94 |
+
<fields>
|
95 |
+
<levelcategory>
|
96 |
+
<label>Level max for category</label>
|
97 |
+
<comment></comment>
|
98 |
+
<frontend_type>select</frontend_type>
|
99 |
+
<sort_order>10</sort_order>
|
100 |
+
<show_in_default>1</show_in_default>
|
101 |
+
<show_in_website>1</show_in_website>
|
102 |
+
<show_in_store>1</show_in_store>
|
103 |
+
<source_model>export/system_config_source_category_level</source_model>
|
104 |
+
</levelcategory>
|
105 |
+
<parentsimages>
|
106 |
+
<label>Merge images with parents products if exist</label>
|
107 |
+
<comment></comment>
|
108 |
+
<frontend_type>select</frontend_type>
|
109 |
+
<sort_order>10</sort_order>
|
110 |
+
<show_in_default>1</show_in_default>
|
111 |
+
<show_in_website>1</show_in_website>
|
112 |
+
<show_in_store>1</show_in_store>
|
113 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
114 |
+
</parentsimages>
|
115 |
+
<formatdata>
|
116 |
+
<label>Convert data</label>
|
117 |
+
<comment><![CDATA[Replace spcecial chars with html chars]]></comment>
|
118 |
+
<frontend_type>select</frontend_type>
|
119 |
+
<sort_order>20</sort_order>
|
120 |
+
<show_in_default>1</show_in_default>
|
121 |
+
<show_in_website>1</show_in_website>
|
122 |
+
<show_in_store>1</show_in_store>
|
123 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
124 |
+
</formatdata>
|
125 |
+
<shipping_price_based_on>
|
126 |
+
<label>Country shipping</label>
|
127 |
+
<comment>Default country for shipping cost</comment>
|
128 |
+
<frontend_type>select</frontend_type>
|
129 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
130 |
+
<sort_order>30</sort_order>
|
131 |
+
<show_in_default>1</show_in_default>
|
132 |
+
<show_in_website>1</show_in_website>
|
133 |
+
<show_in_store>1</show_in_store>
|
134 |
+
</shipping_price_based_on>
|
135 |
+
<default_shipping_delay>
|
136 |
+
<label>Delay of shipping</label>
|
137 |
+
<comment></comment>
|
138 |
+
<frontend_type>text</frontend_type>
|
139 |
+
<sort_order>40</sort_order>
|
140 |
+
<show_in_default>1</show_in_default>
|
141 |
+
<show_in_website>1</show_in_website>
|
142 |
+
<show_in_store>1</show_in_store>
|
143 |
+
</default_shipping_delay>
|
144 |
+
<default_shipping_price>
|
145 |
+
<label>Shipping cost</label>
|
146 |
+
<comment>Default shipping cost if matching find</comment>
|
147 |
+
<frontend_type>text</frontend_type>
|
148 |
+
<sort_order>50</sort_order>
|
149 |
+
<show_in_default>1</show_in_default>
|
150 |
+
<show_in_website>1</show_in_website>
|
151 |
+
<show_in_store>1</show_in_store>
|
152 |
+
</default_shipping_price>
|
153 |
+
<default_shipping_method>
|
154 |
+
<label>Shipping method</label>
|
155 |
+
<comment>Default shipping method to calculate shipping cost</comment>
|
156 |
+
<frontend_type>select</frontend_type>
|
157 |
+
<source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
|
158 |
+
<sort_order>60</sort_order>
|
159 |
+
<show_in_default>1</show_in_default>
|
160 |
+
<show_in_website>1</show_in_website>
|
161 |
+
<show_in_store>1</show_in_store>
|
162 |
+
</default_shipping_method>
|
163 |
+
<format>
|
164 |
+
<label>Format</label>
|
165 |
+
<frontend_type>select</frontend_type>
|
166 |
+
<sort_order>10</sort_order>
|
167 |
+
<show_in_default>1</show_in_default>
|
168 |
+
<show_in_website>1</show_in_website>
|
169 |
+
<show_in_store>1</show_in_store>
|
170 |
+
<source_model>export/system_config_source_format</source_model>
|
171 |
+
</format>
|
172 |
+
<without_product_ordering>
|
173 |
+
<label>Stock without products ordering</label>
|
174 |
+
<frontend_type>select</frontend_type>
|
175 |
+
<sort_order>70</sort_order>
|
176 |
+
<show_in_default>1</show_in_default>
|
177 |
+
<show_in_website>1</show_in_website>
|
178 |
+
<show_in_store>1</show_in_store>
|
179 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
180 |
+
</without_product_ordering>
|
181 |
+
<count_images>
|
182 |
+
<label>Images max</label>
|
183 |
+
<frontend_type>select</frontend_type>
|
184 |
+
<sort_order>80</sort_order>
|
185 |
+
<show_in_default>1</show_in_default>
|
186 |
+
<show_in_website>1</show_in_website>
|
187 |
+
<show_in_store>1</show_in_store>
|
188 |
+
<source_model>export/system_config_source_images</source_model>
|
189 |
+
</count_images>
|
190 |
+
</fields>
|
191 |
+
</data>
|
192 |
+
<performances translate="label comment">
|
193 |
+
<label>Performances</label>
|
194 |
+
<show_in_default>1</show_in_default>
|
195 |
+
<show_in_website>1</show_in_website>
|
196 |
+
<show_in_store>1</show_in_store>
|
197 |
+
<sort_order>3</sort_order>
|
198 |
+
<fields>
|
199 |
+
<usesavefile>
|
200 |
+
<label>Save feed on file</label>
|
201 |
+
<comment><![CDATA[Save the feed on a file]]></comment>
|
202 |
+
<frontend_type>select</frontend_type>
|
203 |
+
<sort_order>40</sort_order>
|
204 |
+
<show_in_default>1</show_in_default>
|
205 |
+
<show_in_website>1</show_in_website>
|
206 |
+
<show_in_store>1</show_in_store>
|
207 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
208 |
+
</usesavefile>
|
209 |
+
<active_cron>
|
210 |
+
<label><![CDATA[Active cron]]></label>
|
211 |
+
<comment><![CDATA[Active the scheduled task for export your feed every 4h]]></comment>
|
212 |
+
<frontend_type>select</frontend_type>
|
213 |
+
<sort_order>60</sort_order>
|
214 |
+
<show_in_default>1</show_in_default>
|
215 |
+
<show_in_website>1</show_in_website>
|
216 |
+
<show_in_store>1</show_in_store>
|
217 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
218 |
+
</active_cron>
|
219 |
+
</fields>
|
220 |
+
</performances>
|
221 |
+
<!-- selection des attributs -->
|
222 |
+
<attributelist translate="label">
|
223 |
+
<label>Products attributes</label>
|
224 |
+
<show_in_default>1</show_in_default>
|
225 |
+
<show_in_website>1</show_in_website>
|
226 |
+
<show_in_store>1</show_in_store>
|
227 |
+
<sort_order>20</sort_order>
|
228 |
+
<fields>
|
229 |
+
<attributes translate="label">
|
230 |
+
<label>Select attributes to export</label>
|
231 |
+
<frontend_type>multiselect</frontend_type>
|
232 |
+
<source_model>export/system_config_source_getattributes</source_model>
|
233 |
+
<sort_order>4</sort_order>
|
234 |
+
<show_in_default>1</show_in_default>
|
235 |
+
<show_in_website>1</show_in_website>
|
236 |
+
<show_in_store>1</show_in_store>
|
237 |
+
</attributes>
|
238 |
+
</fields>
|
239 |
+
</attributelist>
|
240 |
+
</groups>
|
241 |
+
</export>
|
242 |
+
</sections>
|
243 |
+
</config>
|
app/code/community/Lengow/Feed/Block/Adminhtml/Feed.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Lengow grid products block
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Feed
|
8 |
+
* @author Romain Le Polh <romain@lengow.com>
|
9 |
+
* @copyright 2013 Lengow SAS
|
10 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
11 |
+
*/
|
12 |
+
class Lengow_Feed_Block_Adminhtml_Feed extends Mage_Adminhtml_Block_Widget_Container {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Set template
|
16 |
+
*/
|
17 |
+
public function __construct() {
|
18 |
+
parent::__construct();
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Prepare button and grid
|
23 |
+
*
|
24 |
+
* @return Mage_Adminhtml_Block_Catalog_Product
|
25 |
+
*/
|
26 |
+
protected function _prepareLayout() {
|
27 |
+
$this->_addButton('migrate', array(
|
28 |
+
'label' => Mage::helper('feed')->__('Migrate all selected feeds'),
|
29 |
+
'onclick' => 'form_grid_feed.submit()',
|
30 |
+
'class' => 'save'
|
31 |
+
));
|
32 |
+
$this->setChild('grid', $this->getLayout()->createBlock('feed/adminhtml_feed_grid', 'feed.grid'));
|
33 |
+
return parent::_prepareLayout();
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Render grid
|
38 |
+
*
|
39 |
+
* @return string
|
40 |
+
*/
|
41 |
+
public function getGridHtml() {
|
42 |
+
return $this->getChildHtml('grid');
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Check whether it is single store mode
|
47 |
+
*
|
48 |
+
* @return bool
|
49 |
+
*/
|
50 |
+
public function isSingleStoreMode() {
|
51 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
52 |
+
return false;
|
53 |
+
}
|
54 |
+
return true;
|
55 |
+
}
|
56 |
+
|
57 |
+
}
|
app/code/community/Lengow/Feed/Block/Adminhtml/Feed/Grid.php
ADDED
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Lengow grid feed
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Feed
|
8 |
+
* @author Romain Le Polh <romain@lengow.com>
|
9 |
+
* @copyright 2013 Lengow SAS
|
10 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
11 |
+
*/
|
12 |
+
class Lengow_Feed_Block_Adminhtml_Feed_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
13 |
+
|
14 |
+
protected $_data = array();
|
15 |
+
protected $_config_model;
|
16 |
+
|
17 |
+
public function __construct() {
|
18 |
+
parent::__construct();
|
19 |
+
$this->setId('feed');
|
20 |
+
$this->setDefaultSort('feed_id[]');
|
21 |
+
$this->setDefaultDir('asc');
|
22 |
+
$this->setSaveParametersInSession(true);
|
23 |
+
$this->setUseAjax(true);
|
24 |
+
$this->_filterVisibility = false;
|
25 |
+
$this->_pagerVisibility = false;
|
26 |
+
$this->_config_model = Mage::getSingleton('feed/config');
|
27 |
+
|
28 |
+
// Set datas
|
29 |
+
$this->setData('id_client', $this->_config_model->get('tracker/general/login'));
|
30 |
+
$this->setData('id_group', $this->_config_model->get('tracker/general/group'));
|
31 |
+
$this->setData('api_key', $this->_config_model->get('tracker/general/api_key'));
|
32 |
+
$this->setData('form_url', $this->getUrl('*/*/migrate', array('' => '')));
|
33 |
+
$this->setData('json_feed', $this->_config_model->get('feed/general/json_feed'));
|
34 |
+
|
35 |
+
}
|
36 |
+
|
37 |
+
protected function _getStore() {
|
38 |
+
$storeId = (int) $this->getRequest()->getParam('store', 0);
|
39 |
+
return Mage::app()->getStore($storeId);
|
40 |
+
}
|
41 |
+
|
42 |
+
protected function _prepareCollection() {
|
43 |
+
$connector = Mage::helper('feed/data')->getConnector($this->getData('id_client'), $this->getData('api_key'));
|
44 |
+
|
45 |
+
$args = array(
|
46 |
+
'idClient' => (integer) $this->getData('id_client'),
|
47 |
+
'idGroup' => (integer) $this->getData('id_group')
|
48 |
+
);
|
49 |
+
$feeds = $connector->api('getRootFeed', $args);
|
50 |
+
$collection = new Varien_Data_Collection();
|
51 |
+
$data_feeds = json_decode($this->getData('json_feed'));
|
52 |
+
|
53 |
+
if(!empty($feeds['feeds'])) {
|
54 |
+
foreach ($feeds['feeds'] as $key => $feed) {
|
55 |
+
|
56 |
+
$obj_feed = new Varien_Object();
|
57 |
+
|
58 |
+
$obj_feed->setData('id', $key);
|
59 |
+
$obj_feed->setData('name', $feed['name']);
|
60 |
+
$obj_feed->setData('url', $feed['url']);
|
61 |
+
|
62 |
+
if(isset($data_feeds->{$key})) {
|
63 |
+
$obj_feed->setData('selected_products', $data_feeds->{$key}->selected_products);
|
64 |
+
$obj_feed->setData('product_out_stock', $data_feeds->{$key}->product_out_stock);
|
65 |
+
$obj_feed->setData('product_type', $data_feeds->{$key}->product_type);
|
66 |
+
$obj_feed->setData('product_status', $data_feeds->{$key}->product_status);
|
67 |
+
$obj_feed->setData('product_child', $data_feeds->{$key}->product_child);
|
68 |
+
$obj_feed->setData('format', $data_feeds->{$key}->format);
|
69 |
+
} else {
|
70 |
+
// Apply default parameters
|
71 |
+
$obj_feed->setData('selected_products', $this->_config_model->get('export/global/export_only_selected'));
|
72 |
+
$obj_feed->setData('product_out_stock', $this->_config_model->get('export/global/export_soldout'));
|
73 |
+
$obj_feed->setData('product_type', explode(',', $this->_config_model->get('export/global/producttype')));
|
74 |
+
$obj_feed->setData('product_status', $this->_config_model->get('export/global/productstatus'));
|
75 |
+
$obj_feed->setData('product_child', $this->_config_model->get('export/global/productchildren'));
|
76 |
+
$obj_feed->setData('format', $this->_config_model->get('export/data/format'));
|
77 |
+
}
|
78 |
+
$collection->addItem($obj_feed);
|
79 |
+
}
|
80 |
+
} else {
|
81 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('feed')->__('Error API, please try to refresh the page.'));
|
82 |
+
}
|
83 |
+
$this->setCollection($collection);
|
84 |
+
parent::_prepareCollection();
|
85 |
+
}
|
86 |
+
|
87 |
+
protected function _prepareColumns() {
|
88 |
+
$this->addColumn('', array(
|
89 |
+
'width' => '20px',
|
90 |
+
'type' => 'checkbox',
|
91 |
+
'index' => 'id',
|
92 |
+
'filter' => false,
|
93 |
+
'sortable' => false,
|
94 |
+
'field_name' => 'feed_id[]',
|
95 |
+
));
|
96 |
+
$this->addColumn('id', array(
|
97 |
+
'header' => Mage::helper('feed')->__('Feed ID'),
|
98 |
+
'width' => '50px',
|
99 |
+
'index' => 'id',
|
100 |
+
'filter' => false,
|
101 |
+
'sortable' => false
|
102 |
+
));
|
103 |
+
$this->addColumn('name', array(
|
104 |
+
'header' => Mage::helper('feed')->__('Feed Name'),
|
105 |
+
'index' => 'name',
|
106 |
+
'filter' => false,
|
107 |
+
'sortable' => false,
|
108 |
+
));
|
109 |
+
$this->addColumn('url', array(
|
110 |
+
'header' => Mage::helper('feed')->__('Flux actuel'),
|
111 |
+
'index' => 'url',
|
112 |
+
'width' => '100px',
|
113 |
+
'filter' => false,
|
114 |
+
'sortable' => false,
|
115 |
+
'renderer' => 'feed/adminhtml_feed_renderer_url',
|
116 |
+
));
|
117 |
+
$this->addColumn('selected_products', array(
|
118 |
+
'header' => Mage::helper('feed')->__('Export only selected product'),
|
119 |
+
'index' => 'selected_products',
|
120 |
+
'type' => 'select',
|
121 |
+
'width' => '50px',
|
122 |
+
'options' => array(
|
123 |
+
1 => __('Yes'),
|
124 |
+
0 => __('No'),
|
125 |
+
),
|
126 |
+
'renderer' => 'feed/adminhtml_feed_renderer_select',
|
127 |
+
'filter' => false,
|
128 |
+
'sortable' => false,
|
129 |
+
));
|
130 |
+
$this->addColumn('product_out_stock', array(
|
131 |
+
'header' => Mage::helper('feed')->__('Export product out of stock'),
|
132 |
+
'index' => 'product_out_stock',
|
133 |
+
'options' => array(
|
134 |
+
1 => __('Yes'),
|
135 |
+
0 => __('No'),
|
136 |
+
),
|
137 |
+
'renderer' => 'feed/adminhtml_feed_renderer_select',
|
138 |
+
'filter' => false,
|
139 |
+
'sortable' => false,
|
140 |
+
));
|
141 |
+
$this->addColumn('product_type', array(
|
142 |
+
'header' => Mage::helper('feed')->__('Product type to export'),
|
143 |
+
'index' => 'product_type',
|
144 |
+
'options' => Mage::getModel('export/system_config_source_types')->toSelectArray(),
|
145 |
+
'renderer' => 'feed/adminhtml_feed_renderer_select',
|
146 |
+
'filter' => false,
|
147 |
+
'sortable' => false,
|
148 |
+
'multiple' => true,
|
149 |
+
));
|
150 |
+
$this->addColumn('product_status', array(
|
151 |
+
'header' => Mage::helper('feed')->__('Status of product to export'),
|
152 |
+
'index' => 'product_status',
|
153 |
+
'width' => '50px',
|
154 |
+
'options' => Mage::getModel('export/system_config_source_status')->toSelectArray(),
|
155 |
+
'filter' => false,
|
156 |
+
'sortable' => false,
|
157 |
+
'renderer' => 'feed/adminhtml_feed_renderer_select',
|
158 |
+
));
|
159 |
+
/*
|
160 |
+
$this->addColumn('product_child', array(
|
161 |
+
'header' => Mage::helper('feed')->__('Export child product'),
|
162 |
+
'index' => 'product_child',
|
163 |
+
'width' => '50px',
|
164 |
+
'options' => array(
|
165 |
+
1 => __('Yes'),
|
166 |
+
0 => __('No'),
|
167 |
+
),
|
168 |
+
'filter' => false,
|
169 |
+
'sortable' => false,
|
170 |
+
'renderer' => 'feed/adminhtml_feed_renderer_select',
|
171 |
+
));*/
|
172 |
+
$this->addColumn('format', array(
|
173 |
+
'header' => Mage::helper('feed')->__('Export format'),
|
174 |
+
'index' => 'format',
|
175 |
+
'width' => '50px',
|
176 |
+
'options' => Mage::getModel('export/system_config_source_format')->toSelectArray(),
|
177 |
+
'filter' => false,
|
178 |
+
'sortable' => false,
|
179 |
+
'renderer' => 'feed/adminhtml_feed_renderer_select',
|
180 |
+
));
|
181 |
+
$this->addColumn('action', array(
|
182 |
+
'header' => Mage::helper('feed')->__('Action'),
|
183 |
+
'width' => '120',
|
184 |
+
'align' => 'left',
|
185 |
+
'filter' => false,
|
186 |
+
'sortable' => false,
|
187 |
+
'renderer' => 'feed/adminhtml_feed_renderer_migrate',
|
188 |
+
));
|
189 |
+
return parent::_prepareColumns();
|
190 |
+
}
|
191 |
+
|
192 |
+
protected function _prepareMassaction() {
|
193 |
+
|
194 |
+
return $this;
|
195 |
+
}
|
196 |
+
|
197 |
+
public function getGridUrl() {
|
198 |
+
return $this->getUrl('*/*/grid', array('_current' => true));
|
199 |
+
}
|
200 |
+
|
201 |
+
public function getRowUrl($row) {
|
202 |
+
return '';
|
203 |
+
}
|
204 |
+
}
|
app/code/community/Lengow/Feed/Block/Adminhtml/Feed/Renderer/Migrate.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Lengow Feed Action Renderer
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Feed
|
8 |
+
* @author Romain Le Polh <romain@lengow.com>
|
9 |
+
* @copyright 2013 Lengow SAS
|
10 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
11 |
+
*/
|
12 |
+
class Lengow_Feed_Block_Adminhtml_Feed_Renderer_Migrate extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Renders grid column
|
16 |
+
*
|
17 |
+
* @param Varien_Object $row
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
public function render(Varien_Object $row) {
|
21 |
+
return sprintf('<button type="submit" class="scalable save" name="submit" value="%s">%s</button>',
|
22 |
+
$row->getData('id'),
|
23 |
+
Mage::helper('feed')->__('Migrate Feed'));
|
24 |
+
}
|
25 |
+
|
26 |
+
}
|
app/code/community/Lengow/Feed/Block/Adminhtml/Feed/Renderer/Select.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Lengow Feed Action Renderer
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Feed
|
8 |
+
* @author Romain Le Polh <romain@lengow.com>
|
9 |
+
* @copyright 2013 Lengow SAS
|
10 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
11 |
+
*/
|
12 |
+
class Lengow_Feed_Block_Adminhtml_Feed_Renderer_Select
|
13 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Renders grid column
|
17 |
+
*
|
18 |
+
* @param Varien_Object $row
|
19 |
+
* @return string
|
20 |
+
*/
|
21 |
+
public function render(Varien_Object $row)
|
22 |
+
{
|
23 |
+
$column = $this->getColumn();
|
24 |
+
$index = $column->getIndex();
|
25 |
+
$options = '';
|
26 |
+
|
27 |
+
$multiple = '';
|
28 |
+
$additional_name = '';
|
29 |
+
|
30 |
+
if($column->getMultiple() == true) {
|
31 |
+
$multiple = 'multiple';
|
32 |
+
$additional_name = '[]';
|
33 |
+
}
|
34 |
+
|
35 |
+
foreach($column->getOptions() as $key => $value) {
|
36 |
+
$selected = '';
|
37 |
+
|
38 |
+
if((string)$key === $row->getData($index))
|
39 |
+
$selected = 'selected="selected"';
|
40 |
+
elseif(is_array($row->getData($index)) && in_array($key, $row->getData($index)))
|
41 |
+
$selected = 'selected="selected"';
|
42 |
+
|
43 |
+
$options .= '<option value="' . $key . '" ' . $selected . ' >' . $value . '</option>';
|
44 |
+
}
|
45 |
+
|
46 |
+
return sprintf('<select name="%s[%s]%s" %s width="%s">%s</select>',
|
47 |
+
$column->getIndex(),
|
48 |
+
$row->getData('id'),
|
49 |
+
$additional_name,
|
50 |
+
$multiple,
|
51 |
+
$column->getWidth(),
|
52 |
+
$options);
|
53 |
+
}
|
54 |
+
}
|
app/code/community/Lengow/Feed/Block/Adminhtml/Feed/Renderer/Url.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Lengow Feed Action Renderer
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Feed
|
8 |
+
* @author Romain Le Polh <romain@lengow.com>
|
9 |
+
* @copyright 2013 Lengow SAS
|
10 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
11 |
+
*/
|
12 |
+
class Lengow_Feed_Block_Adminhtml_Feed_Renderer_Url extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Renders grid column
|
16 |
+
*
|
17 |
+
* @param Varien_Object $row
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
public function render(Varien_Object $row) {
|
21 |
+
$url = $row->getData('url');
|
22 |
+
echo '<a class="popup-link" target="_blank" data-link="' . $url . '" href="' . $url . '">' . Mage::helper('feed')->__('View feed') . '</a>';
|
23 |
+
}
|
24 |
+
|
25 |
+
}
|
app/code/community/Lengow/Feed/Helper/Data.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow Feed Helper
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Feed
|
7 |
+
* @author Romain Le Polh <romain@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Feed_Helper_Data extends Mage_Core_Helper_Abstract {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Get list of available export format
|
15 |
+
*
|
16 |
+
* @return array File format
|
17 |
+
*/
|
18 |
+
public function getArrayFormat() {
|
19 |
+
$format_array = Mage::getModel('export/system_config_source_format')->toOptionArray();
|
20 |
+
$formats = array();
|
21 |
+
foreach($format_array as $format) {
|
22 |
+
$formats[] = $format['value'];
|
23 |
+
}
|
24 |
+
return $formats;
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Get list of product type export
|
29 |
+
*
|
30 |
+
* @return array Product type
|
31 |
+
*/
|
32 |
+
public function getProductTypeFormat() {
|
33 |
+
$product_type_array = Mage::getModel('export/system_config_source_types')->toOptionArray();
|
34 |
+
$types = array();
|
35 |
+
foreach($product_type_array as $type) {
|
36 |
+
$types[] = $type['value'];
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Get Sync connector
|
42 |
+
*
|
43 |
+
* @return mixed Lengow connector object
|
44 |
+
*/
|
45 |
+
public function getConnector($id_client, $api_key) {
|
46 |
+
$connector = Mage::getSingleton('sync/connector');
|
47 |
+
$connector->init((integer) $id_client, $api_key);
|
48 |
+
return $connector;
|
49 |
+
}
|
50 |
+
|
51 |
+
}
|
app/code/community/Lengow/Feed/Model/Config.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Lengow dashboard model config
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Feed
|
8 |
+
* @author Romain Le Polh <romain@lengow.com>
|
9 |
+
* @copyright 2013 Lengow SAS
|
10 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
11 |
+
*/
|
12 |
+
class Lengow_Feed_Model_Config extends Varien_Object {
|
13 |
+
|
14 |
+
public function setStore($id_store) {
|
15 |
+
$this->_id_store = $id_store;
|
16 |
+
}
|
17 |
+
|
18 |
+
public function get($key) {
|
19 |
+
return Mage::getStoreConfig($key, $this->_id_store);
|
20 |
+
}
|
21 |
+
|
22 |
+
public function set($key, $value) {
|
23 |
+
return 1;
|
24 |
+
}
|
25 |
+
|
26 |
+
}
|
app/code/community/Lengow/Feed/Model/Feed.php
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Lengow Feed model
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Feed
|
8 |
+
* @author Romain Le Polh <romain@lengow.com>
|
9 |
+
* @copyright 2013 Lengow SAS
|
10 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
11 |
+
*/
|
12 |
+
class Lengow_Feed_Model_Feed extends Varien_Object {
|
13 |
+
|
14 |
+
protected $_id;
|
15 |
+
|
16 |
+
/**
|
17 |
+
*
|
18 |
+
* @var boolean Export only selected product
|
19 |
+
*/
|
20 |
+
protected $_selected_products;
|
21 |
+
|
22 |
+
/**
|
23 |
+
*
|
24 |
+
* @var boolean Export product out of stock
|
25 |
+
*/
|
26 |
+
protected $_product_out_stock;
|
27 |
+
|
28 |
+
/**
|
29 |
+
*
|
30 |
+
* @var string Product type to export
|
31 |
+
*/
|
32 |
+
protected $_product_type;
|
33 |
+
|
34 |
+
/**
|
35 |
+
*
|
36 |
+
* @var string Status of product to export
|
37 |
+
*/
|
38 |
+
protected $_product_status;
|
39 |
+
|
40 |
+
/**
|
41 |
+
*
|
42 |
+
* @var boolean Export product child
|
43 |
+
*/
|
44 |
+
protected $_product_child;
|
45 |
+
|
46 |
+
/**
|
47 |
+
*
|
48 |
+
* @var string Export Format
|
49 |
+
*/
|
50 |
+
protected $_format;
|
51 |
+
|
52 |
+
/**
|
53 |
+
*
|
54 |
+
* @var string Url feed
|
55 |
+
*/
|
56 |
+
protected $_url;
|
57 |
+
|
58 |
+
protected $_idClient;
|
59 |
+
protected $_idGroup;
|
60 |
+
protected $_api_key;
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Buid feed object
|
64 |
+
*
|
65 |
+
* @param integer $id
|
66 |
+
* @param boolean $selected_products
|
67 |
+
* @param boolean $product_out_stock
|
68 |
+
* @param string $product_type
|
69 |
+
* @param string $product_status
|
70 |
+
* @param boolean $product_child
|
71 |
+
* @param string $format
|
72 |
+
*/
|
73 |
+
public function __construct($args) {
|
74 |
+
$this->_id = $args['feed_id'];
|
75 |
+
$this->_selected_products = $args['selected_products'];
|
76 |
+
$this->_product_out_stock = $args['product_out_stock'];
|
77 |
+
$this->_product_type = Mage::helper('core')->jsonEncode($args['product_type']);
|
78 |
+
$this->_product_status = $args['product_status'];
|
79 |
+
//$this->_product_child = $args['product_child'];
|
80 |
+
$this->_format = $args['format'];
|
81 |
+
|
82 |
+
$this->_config_model = Mage::getSingleton('feed/config');
|
83 |
+
|
84 |
+
$this->_idClient = $this->_config_model->get('tracker/general/login');
|
85 |
+
$this->_idGroup = $this->_config_model->get('tracker/general/group');
|
86 |
+
$this->_api_key = $this->_config_model->get('tracker/general/api_key');
|
87 |
+
parent::__construct();
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Build url before update
|
92 |
+
*/
|
93 |
+
private function _buildUrl() {
|
94 |
+
$params = 'selected_products/' . $this->_selected_products;
|
95 |
+
$params .= '/product_out_stock/' . $this->_product_out_stock;
|
96 |
+
$params .= '/product_type/' . join(',', Mage::helper('core')->jsonDecode($this->_product_type));
|
97 |
+
$params .= '/product_status/' . $this->_product_status;
|
98 |
+
//$params .= '/product_child/' . $this->_product_child;
|
99 |
+
$params .= '/format/' . $this->_format;
|
100 |
+
$params .= '/store/' . Mage::app()->getStore()->getId();
|
101 |
+
|
102 |
+
$new_flow = Mage::getUrl('lengow/feed/index') . $params;
|
103 |
+
$this->_url = $new_flow;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Update feed on Lengow
|
108 |
+
*/
|
109 |
+
public function update() {
|
110 |
+
$this->_buildUrl();
|
111 |
+
$connector = Mage::helper('feed/data')->getConnector($this->_idClient, $this->_api_key);
|
112 |
+
$args = array(
|
113 |
+
'idClient' => $this->_idClient,
|
114 |
+
'idGroup' => $this->_idGroup,
|
115 |
+
'urlFlux' => $this->_url,
|
116 |
+
'idFlux' => $this->_id
|
117 |
+
);
|
118 |
+
return $connector->api('updateRootFeed', $args);
|
119 |
+
}
|
120 |
+
|
121 |
+
}
|
app/code/community/Lengow/Feed/controllers/Adminhtml/Lengow/FeedController.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow adminhtml export controller
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Feed
|
7 |
+
* @author Romain Le Polh <romain@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Feed_Adminhtml_Lengow_FeedController extends Mage_Adminhtml_Controller_Action {
|
12 |
+
|
13 |
+
public function indexAction() {
|
14 |
+
$this->loadLayout();
|
15 |
+
$this->renderLayout();
|
16 |
+
return $this;
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Product grid for AJAX request
|
21 |
+
*/
|
22 |
+
public function gridAction() {
|
23 |
+
$this->loadLayout();
|
24 |
+
$this->getResponse()->setBody(
|
25 |
+
$this->getLayout()->createBlock('feed/adminhtml_feed')->toHtml()
|
26 |
+
);
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function _getSession() {
|
30 |
+
return Mage::getSingleton('adminhtml/session');
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Migrate feed
|
35 |
+
*/
|
36 |
+
public function migrateAction() {
|
37 |
+
|
38 |
+
$feed_ids = $this->getRequest()->getParam('feed_id');
|
39 |
+
$selected_products = $this->getRequest()->getParam('selected_products');
|
40 |
+
$product_out_stock = $this->getRequest()->getParam('product_out_stock');
|
41 |
+
$product_type = $this->getRequest()->getParam('product_type');
|
42 |
+
$product_status = $this->getRequest()->getParam('product_status');
|
43 |
+
//$product_child = $this->getRequest()->getParam('product_child');
|
44 |
+
$format = $this->getRequest()->getParam('format');
|
45 |
+
|
46 |
+
if($this->getRequest()->getParam('submit')) {
|
47 |
+
$feed_ids = array($this->getRequest()->getParam('submit'));
|
48 |
+
}
|
49 |
+
|
50 |
+
$error = false;
|
51 |
+
$message = '';
|
52 |
+
$data_feeds = json_decode(Mage::getSingleton('feed/config')->get('feed/general/json_feed'));
|
53 |
+
|
54 |
+
foreach($feed_ids as $feed_id) {
|
55 |
+
|
56 |
+
$args = array(
|
57 |
+
'feed_id' => $feed_id,
|
58 |
+
'selected_products' => $selected_products[$feed_id],
|
59 |
+
'product_out_stock' => $product_out_stock[$feed_id],
|
60 |
+
'product_type' => $product_type[$feed_id],
|
61 |
+
'product_status' => $product_status[$feed_id],
|
62 |
+
//'product_child' => $product_child[$feed_id],
|
63 |
+
'format' => $format[$feed_id]);
|
64 |
+
|
65 |
+
$feed = Mage::getModel('feed/feed', $args);
|
66 |
+
if(!$feed->update()) {
|
67 |
+
$error = true;
|
68 |
+
$message .= Mage::helper('feed')->__('Error update feed %s', '#' . $feed_id . '<br />');
|
69 |
+
} else {
|
70 |
+
$data_feeds->{$feed_id} = $args;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
Mage::getConfig()->saveConfig('feed/general/json_feed', json_encode($data_feeds));
|
75 |
+
|
76 |
+
if($error)
|
77 |
+
Mage::getSingleton('core/session')->addError($message);
|
78 |
+
else
|
79 |
+
Mage::getSingleton('core/session')->addSuccess(Mage::helper('feed')->__('Update success'));
|
80 |
+
|
81 |
+
$this->_redirect('*/*/index');
|
82 |
+
}
|
83 |
+
|
84 |
+
}
|
app/code/community/Lengow/Feed/etc/config.xml
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Lengow_Feed>
|
5 |
+
<version>2.0.1.0</version>
|
6 |
+
</Lengow_Feed>
|
7 |
+
</modules>
|
8 |
+
<admin>
|
9 |
+
<routers>
|
10 |
+
<adminhtml>
|
11 |
+
<args>
|
12 |
+
<modules>
|
13 |
+
<feed before="Mage_Adminhtml">Lengow_Feed_Adminhtml</feed>
|
14 |
+
</modules>
|
15 |
+
</args>
|
16 |
+
</adminhtml>
|
17 |
+
</routers>
|
18 |
+
</admin>
|
19 |
+
<global>
|
20 |
+
<models>
|
21 |
+
<feed>
|
22 |
+
<class>Lengow_Feed_Model</class>
|
23 |
+
<resourceModel>feed_mysql4</resourceModel>
|
24 |
+
</feed>
|
25 |
+
<feed_mysql4>
|
26 |
+
<class>Lengow_Feed_Model_Mysql4</class>
|
27 |
+
<entities>
|
28 |
+
<manageorders_log>
|
29 |
+
<table>lengow_log</table>
|
30 |
+
</manageorders_log>
|
31 |
+
</entities>
|
32 |
+
</feed_mysql4>
|
33 |
+
</models>
|
34 |
+
<resources>
|
35 |
+
<feed_setup>
|
36 |
+
<connection>
|
37 |
+
<use>core_setup</use>
|
38 |
+
</connection>
|
39 |
+
</feed_setup>
|
40 |
+
<feed_write>
|
41 |
+
<connection>
|
42 |
+
<use>core_write</use>
|
43 |
+
</connection>
|
44 |
+
</feed_write>
|
45 |
+
<feed_read>
|
46 |
+
<connection>
|
47 |
+
<use>core_read</use>
|
48 |
+
</connection>
|
49 |
+
</feed_read>
|
50 |
+
</resources>
|
51 |
+
<blocks>
|
52 |
+
<feed>
|
53 |
+
<class>Lengow_Feed_Block</class>
|
54 |
+
</feed>
|
55 |
+
</blocks>
|
56 |
+
<helpers>
|
57 |
+
<feed>
|
58 |
+
<class>Lengow_Feed_Helper</class>
|
59 |
+
</feed>
|
60 |
+
</helpers>
|
61 |
+
</global>
|
62 |
+
<adminhtml>
|
63 |
+
<translate>
|
64 |
+
<modules>
|
65 |
+
<Lengow_Feed>
|
66 |
+
<files>
|
67 |
+
<default>Lengow_Connector.csv</default>
|
68 |
+
</files>
|
69 |
+
</Lengow_Feed>
|
70 |
+
</modules>
|
71 |
+
</translate>
|
72 |
+
<menu>
|
73 |
+
<lengow>
|
74 |
+
<title>Lengow</title>
|
75 |
+
<sort_order>20</sort_order>
|
76 |
+
<children>
|
77 |
+
<feed translate="title" module="feed">
|
78 |
+
<title>Manage Feeds</title>
|
79 |
+
<action>adminhtml/lengow_feed</action>
|
80 |
+
<sort_order>300</sort_order>
|
81 |
+
</feed>
|
82 |
+
</children>
|
83 |
+
</lengow>
|
84 |
+
</menu>
|
85 |
+
<acl>
|
86 |
+
<resources>
|
87 |
+
<admin>
|
88 |
+
<children>
|
89 |
+
<system>
|
90 |
+
<children>
|
91 |
+
<config>
|
92 |
+
<children>
|
93 |
+
<feed translate="title" module="feed">
|
94 |
+
<title>Products</title>
|
95 |
+
</feed>
|
96 |
+
</children>
|
97 |
+
</config>
|
98 |
+
</children>
|
99 |
+
</system>
|
100 |
+
<lengow translate="title" module="feed">
|
101 |
+
<title>Lengow</title>
|
102 |
+
<sort_order>22</sort_order>
|
103 |
+
</lengow>
|
104 |
+
</children>
|
105 |
+
</admin>
|
106 |
+
</resources>
|
107 |
+
</acl>
|
108 |
+
</adminhtml>
|
109 |
+
</config>
|
app/code/community/Lengow/Feed/etc/system.xml
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<lengow translate="label" module="feed">
|
5 |
+
<label>Lengow</label>
|
6 |
+
<sort_order>210</sort_order>
|
7 |
+
</lengow>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<feed translate="label" module="feed">
|
11 |
+
<label>Feed configuration</label>
|
12 |
+
<tab>lengow</tab>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>90</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>1</show_in_store>
|
18 |
+
<groups>
|
19 |
+
<general translate="label comment">
|
20 |
+
<label>Global</label>
|
21 |
+
<show_in_default>0</show_in_default>
|
22 |
+
<show_in_website>0</show_in_website>
|
23 |
+
<show_in_store>0</show_in_store>
|
24 |
+
<sort_order>1</sort_order>
|
25 |
+
<fields>
|
26 |
+
<json_feed>
|
27 |
+
<label>JSON Feed backup</label>
|
28 |
+
<comment><![CDATA[Backup of feed]]></comment>
|
29 |
+
<frontend_type>text</frontend_type>
|
30 |
+
<sort_order>6</sort_order>
|
31 |
+
<show_in_default>0</show_in_default>
|
32 |
+
<show_in_website>0</show_in_website>
|
33 |
+
<show_in_store>0</show_in_store>
|
34 |
+
</json_feed>
|
35 |
+
</fields>
|
36 |
+
</general>
|
37 |
+
</groups>
|
38 |
+
</feed>
|
39 |
+
</sections>
|
40 |
+
</config>
|
app/code/community/Lengow/Sync/.DS_Store
ADDED
Binary file
|
app/code/community/Lengow/Sync/Block/.DS_Store
ADDED
Binary file
|
app/code/community/Lengow/Sync/Block/Adminhtml/Import.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Lengow_Order_Block_Manageorders_Adminhtml_Sync extends Mage_Adminhtml_Block_Template {
|
3 |
+
|
4 |
+
public function getSyncOrdersUrl() {
|
5 |
+
return $this->getUrl('*/*/SyncOrders');
|
6 |
+
}
|
7 |
+
|
8 |
+
}
|
app/code/community/Lengow/Sync/Block/Adminhtml/Log.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow logs
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Block_Adminhtml_Log extends Mage_Adminhtml_Block_Widget_Grid_Container {
|
12 |
+
|
13 |
+
public function __construct() {
|
14 |
+
parent::__construct();
|
15 |
+
$this->_controller = 'adminhtml_log';
|
16 |
+
$this->_blockGroup = 'sync';
|
17 |
+
$this->_headerText = $this->__('Lengow logs');
|
18 |
+
$this->_removeButton('add');
|
19 |
+
$this->_addButton('deleteAll', array(
|
20 |
+
'label' => Mage::helper('sync')->__('Flush logs'),
|
21 |
+
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/delete') . '\')',
|
22 |
+
'class' => 'delete'
|
23 |
+
));
|
24 |
+
}
|
25 |
+
}
|
app/code/community/Lengow/Sync/Block/Adminhtml/Log/Grid.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow adminhtml log grid
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Block_Adminhtml_Log_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
12 |
+
|
13 |
+
public function __construct() {
|
14 |
+
parent::__construct();
|
15 |
+
$this->setId('sales_sync_log_grid');
|
16 |
+
$this->setUseAjax(true);
|
17 |
+
$this->setDefaultSort('date');
|
18 |
+
$this->setDefaultDir('DESC');
|
19 |
+
$this->setSaveParametersInSession(true);
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _prepareCollection() {
|
23 |
+
$collection = Mage::getModel('sync/log')->getCollection();
|
24 |
+
$this->setCollection($collection);
|
25 |
+
return parent::_prepareCollection();
|
26 |
+
}
|
27 |
+
|
28 |
+
protected function _prepareColumns() {
|
29 |
+
$this->addColumn('id', array(
|
30 |
+
'header'=> Mage::helper('sync')->__('ID'),
|
31 |
+
'width' => '80px',
|
32 |
+
'type' => 'text',
|
33 |
+
'index' => 'id',
|
34 |
+
));
|
35 |
+
$this->addColumn('date', array(
|
36 |
+
'header' => Mage::helper('sync')->__('Created at'),
|
37 |
+
'index' => 'date',
|
38 |
+
'type' => 'datetime',
|
39 |
+
'width' => '100px',
|
40 |
+
));
|
41 |
+
$this->addColumn('message', array(
|
42 |
+
'header' => Mage::helper('sync')->__('Message'),
|
43 |
+
'index' => 'message',
|
44 |
+
));
|
45 |
+
return parent::_prepareColumns();
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getGridUrl() {
|
49 |
+
return $this->getUrl('*/*/grid', array('_current'=>true));
|
50 |
+
}
|
51 |
+
|
52 |
+
}
|
app/code/community/Lengow/Sync/Block/Adminhtml/Order.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow grid products block
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Block_Adminhtml_Order extends Mage_Adminhtml_Block_Widget_Grid_Container {
|
12 |
+
|
13 |
+
public function __construct() {
|
14 |
+
parent::__construct();
|
15 |
+
$this->_controller = 'adminhtml_order';
|
16 |
+
$this->_blockGroup = 'sync';
|
17 |
+
$this->_headerText = $this->__('Lengow orders');
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Prepare button and grid
|
22 |
+
*
|
23 |
+
* @return Mage_Adminhtml_Block_Catalog_Product
|
24 |
+
*/
|
25 |
+
protected function _prepareLayout() {
|
26 |
+
$this->_removeButton('add');
|
27 |
+
$this->_addButton('import', array(
|
28 |
+
'label' => Mage::helper('catalog')->__('Manuel import'),
|
29 |
+
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/import') . '\')',
|
30 |
+
'class' => 'add'
|
31 |
+
));
|
32 |
+
return parent::_prepareLayout();
|
33 |
+
}
|
34 |
+
}
|
app/code/community/Lengow/Sync/Block/Adminhtml/Order/Grid.php
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow grid orders block grid
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Block_Adminhtml_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
12 |
+
|
13 |
+
protected $_withGrid = true;
|
14 |
+
|
15 |
+
public function __construct() {
|
16 |
+
parent::__construct();
|
17 |
+
$this->setId('sales_sync_order_grid');
|
18 |
+
$this->setUseAjax(true);
|
19 |
+
$this->setDefaultSort('created_at');
|
20 |
+
$this->setDefaultDir('DESC');
|
21 |
+
$this->setSaveParametersInSession(true);
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Retrieve collection class
|
26 |
+
*
|
27 |
+
* @return string
|
28 |
+
*/
|
29 |
+
protected function _getCollectionClass() {
|
30 |
+
$path = Mage::getBaseDir() .'/app/code/core/Mage/Sales/Model/Mysql4/Order/Grid/Collection.php';
|
31 |
+
if(file_exists($path))
|
32 |
+
return 'sales/order_grid_collection';
|
33 |
+
$this->_withGrid = false;
|
34 |
+
return 'sales/order_collection';
|
35 |
+
}
|
36 |
+
|
37 |
+
protected function _prepareCollection() {
|
38 |
+
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
39 |
+
$collection->addAttributeToFilter('from_lengow', array('gt' => 0));
|
40 |
+
if(!$this->_withGrid) {
|
41 |
+
$collection->addAttributeToSelect('*')
|
42 |
+
->joinAttribute('billing_firstname', 'order_address/firstname', 'billing_address_id', null, 'left')
|
43 |
+
->joinAttribute('billing_lastname', 'order_address/lastname', 'billing_address_id', null, 'left')
|
44 |
+
->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left')
|
45 |
+
->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left')
|
46 |
+
->addExpressionAttributeToSelect('billing_name',
|
47 |
+
'CONCAT({{billing_firstname}}, " ", {{billing_lastname}})',
|
48 |
+
array('billing_firstname', 'billing_lastname'))
|
49 |
+
->addExpressionAttributeToSelect('shipping_name',
|
50 |
+
'CONCAT({{shipping_firstname}}, IFNULL(CONCAT(\' \', {{shipping_lastname}}), \'\'))',
|
51 |
+
array('shipping_firstname', 'shipping_lastname'));
|
52 |
+
}
|
53 |
+
$this->setCollection($collection);
|
54 |
+
return parent::_prepareCollection();
|
55 |
+
}
|
56 |
+
|
57 |
+
protected function _prepareColumns() {
|
58 |
+
$this->addColumn('real_Sync_id', array(
|
59 |
+
'header'=> Mage::helper('sales')->__('Order #'),
|
60 |
+
'width' => '80px',
|
61 |
+
'type' => 'text',
|
62 |
+
'index' => 'increment_id',
|
63 |
+
));
|
64 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
65 |
+
$this->addColumn('store_id', array(
|
66 |
+
'header' => Mage::helper('sales')->__('Purchased From (Store)'),
|
67 |
+
'index' => 'store_id',
|
68 |
+
'type' => 'store',
|
69 |
+
'store_view'=> true,
|
70 |
+
'display_deleted' => true,
|
71 |
+
));
|
72 |
+
}
|
73 |
+
$this->addColumn('created_at', array(
|
74 |
+
'header' => Mage::helper('sales')->__('Purchased On'),
|
75 |
+
'index' => 'created_at',
|
76 |
+
'type' => 'datetime',
|
77 |
+
'width' => '100px',
|
78 |
+
));
|
79 |
+
$this->addColumn('billing_name', array(
|
80 |
+
'header' => Mage::helper('sales')->__('Bill to Name'),
|
81 |
+
'index' => 'billing_name',
|
82 |
+
));
|
83 |
+
$this->addColumn('shipping_name', array(
|
84 |
+
'header' => Mage::helper('sales')->__('Ship to Name'),
|
85 |
+
'index' => 'shipping_name',
|
86 |
+
));
|
87 |
+
$this->addColumn('base_grand_total', array(
|
88 |
+
'header' => Mage::helper('sales')->__('G.T. (Base)'),
|
89 |
+
'index' => 'base_grand_total',
|
90 |
+
'type' => 'currency',
|
91 |
+
'currency' => 'base_currency_code',
|
92 |
+
));
|
93 |
+
$this->addColumn('grand_total', array(
|
94 |
+
'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
|
95 |
+
'index' => 'grand_total',
|
96 |
+
'type' => 'currency',
|
97 |
+
'currency' => 'order_currency_code',
|
98 |
+
));
|
99 |
+
// Add datas from Lengow
|
100 |
+
$this->addColumn('order_id_lengow', array(
|
101 |
+
'header' => Mage::helper('sync')->__('Id lengow'),
|
102 |
+
'index' => 'order_id_lengow',
|
103 |
+
));
|
104 |
+
|
105 |
+
$this->addColumn('marketplace_lengow', array(
|
106 |
+
'header' => Mage::helper('sync')->__('Marketplace'),
|
107 |
+
'index' => 'marketplace_lengow',
|
108 |
+
));
|
109 |
+
|
110 |
+
$this->addColumn('fees_lengow', array(
|
111 |
+
'header'=> Mage::helper('sync')->__('Fees'),
|
112 |
+
'type' => 'currency',
|
113 |
+
'index' => 'fees_lengow',
|
114 |
+
'currency' => 'base_currency_code',
|
115 |
+
));
|
116 |
+
// End datas from Lengow
|
117 |
+
$this->addColumn('status', array(
|
118 |
+
'header' => Mage::helper('sales')->__('Status'),
|
119 |
+
'index' => 'status',
|
120 |
+
'type' => 'options',
|
121 |
+
'width' => '70px',
|
122 |
+
'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
|
123 |
+
));
|
124 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
|
125 |
+
$this->addColumn('action',
|
126 |
+
array(
|
127 |
+
'header' => Mage::helper('sales')->__('Action'),
|
128 |
+
'width' => '50px',
|
129 |
+
'type' => 'action',
|
130 |
+
'getter' => 'getId',
|
131 |
+
'actions' => array(
|
132 |
+
array(
|
133 |
+
'caption' => Mage::helper('sales')->__('View'),
|
134 |
+
'url' => array('base'=>'adminhtml/sales_order/view'),
|
135 |
+
'field' => 'order_id'
|
136 |
+
)
|
137 |
+
),
|
138 |
+
'filter' => false,
|
139 |
+
'sortable' => false,
|
140 |
+
'index' => 'stores',
|
141 |
+
'is_system' => true,
|
142 |
+
));
|
143 |
+
}
|
144 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
|
145 |
+
$this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML'));
|
146 |
+
return parent::_prepareColumns();
|
147 |
+
}
|
148 |
+
|
149 |
+
protected function _prepareMassaction() {
|
150 |
+
$this->setMassactionIdField('entity_id');
|
151 |
+
$this->getMassactionBlock()->setFormFieldName('order_ids');
|
152 |
+
$this->getMassactionBlock()->setUseSelectAll(false);
|
153 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) {
|
154 |
+
$this->getMassactionBlock()->addItem('cancel_order', array(
|
155 |
+
'label'=> Mage::helper('sales')->__('Cancel'),
|
156 |
+
'url' => $this->getUrl('adminhtml/sales_order/massCancel'),
|
157 |
+
));
|
158 |
+
}
|
159 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) {
|
160 |
+
$this->getMassactionBlock()->addItem('hold_order', array(
|
161 |
+
'label'=> Mage::helper('sales')->__('Hold'),
|
162 |
+
'url' => $this->getUrl('adminhtml/sales_order/massHold'),
|
163 |
+
));
|
164 |
+
}
|
165 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) {
|
166 |
+
$this->getMassactionBlock()->addItem('unhold_order', array(
|
167 |
+
'label'=> Mage::helper('sales')->__('Unhold'),
|
168 |
+
'url' => $this->getUrl('adminhtml/sales_order/massUnhold'),
|
169 |
+
));
|
170 |
+
}
|
171 |
+
$this->getMassactionBlock()->addItem('pdfinvoices_order', array(
|
172 |
+
'label'=> Mage::helper('sales')->__('Print Invoices'),
|
173 |
+
'url' => $this->getUrl('adminhtml/sales_order/pdfinvoices'),
|
174 |
+
));
|
175 |
+
$this->getMassactionBlock()->addItem('pdfshipments_order', array(
|
176 |
+
'label'=> Mage::helper('sales')->__('Print Packingslips'),
|
177 |
+
'url' => $this->getUrl('adminhtml/sales_order/pdfshipments'),
|
178 |
+
));
|
179 |
+
$this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
|
180 |
+
'label'=> Mage::helper('sales')->__('Print Credit Memos'),
|
181 |
+
'url' => $this->getUrl('adminhtml/sales_order/pdfcreditmemos'),
|
182 |
+
));
|
183 |
+
$this->getMassactionBlock()->addItem('pdfdocs_order', array(
|
184 |
+
'label'=> Mage::helper('sales')->__('Print All'),
|
185 |
+
'url' => $this->getUrl('adminhtml/sales_order/pdfdocs'),
|
186 |
+
));
|
187 |
+
return $this;
|
188 |
+
}
|
189 |
+
|
190 |
+
public function getRowUrl($row) {
|
191 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
|
192 |
+
return $this->getUrl('adminhtml/sales_order/view', array('order_id' => $row->getId()));
|
193 |
+
}
|
194 |
+
return false;
|
195 |
+
}
|
196 |
+
|
197 |
+
public function getGridUrl() {
|
198 |
+
return $this->getUrl('*/*/grid', array('_current'=>true));
|
199 |
+
}
|
200 |
+
|
201 |
+
}
|
app/code/community/Lengow/Sync/Block/Adminhtml/Order/Tab.php
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow select products block
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Romain Le Pohl <romain@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Block_Adminhtml_Order_Tab extends Mage_Adminhtml_Block_Sales_Order_Abstract
|
12 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface {
|
13 |
+
|
14 |
+
protected function _construct() {
|
15 |
+
$this->setTemplate('lengow/sales/order/tab/info.phtml');
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Retrieve order model instance
|
20 |
+
*
|
21 |
+
* @return Mage_Sales_Model_Order
|
22 |
+
*/
|
23 |
+
public function getOrder() {
|
24 |
+
return Mage::registry('current_order');
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Retrieve source model instance
|
29 |
+
*
|
30 |
+
* @return Mage_Sales_Model_Order
|
31 |
+
*/
|
32 |
+
public function getSource() {
|
33 |
+
return $this->getOrder();
|
34 |
+
}
|
35 |
+
|
36 |
+
|
37 |
+
public function getTabLabel() {
|
38 |
+
return Mage::helper('sales')->__('Lengow');
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getTabTitle() {
|
42 |
+
return Mage::helper('sales')->__('Lengow');
|
43 |
+
}
|
44 |
+
|
45 |
+
public function canShowTab() {
|
46 |
+
return true;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function isHidden() {
|
50 |
+
return false;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Get fields array
|
55 |
+
*
|
56 |
+
* @return Array
|
57 |
+
*/
|
58 |
+
public function getFields() {
|
59 |
+
$fields = array();
|
60 |
+
$order = $this->getOrder();
|
61 |
+
|
62 |
+
$fields[] = array(
|
63 |
+
'label' => Mage::helper('sync')->__('Lengow order ID'),
|
64 |
+
'value' => $order->getData('order_id_lengow'),
|
65 |
+
);
|
66 |
+
$fields[] = array(
|
67 |
+
'label' => Mage::helper('sync')->__('Feed ID'),
|
68 |
+
'value' => $order->getData('feed_id_lengow'),
|
69 |
+
);
|
70 |
+
$fields[] = array(
|
71 |
+
'label' => Mage::helper('sync')->__('Marketplace'),
|
72 |
+
'value' => $order->getData('marketplace_lengow'),
|
73 |
+
);
|
74 |
+
$fields[] = array(
|
75 |
+
'label' => Mage::helper('sync')->__('Total paid'),
|
76 |
+
'value' => $order->getData('total_paid_lengow'),
|
77 |
+
);
|
78 |
+
$fields[] = array(
|
79 |
+
'label' => Mage::helper('sync')->__('Carrier'),
|
80 |
+
'value' => $order->getData('carrier_lengow'),
|
81 |
+
);
|
82 |
+
$fields[] = array(
|
83 |
+
'label' => Mage::helper('sync')->__('Carrier method'),
|
84 |
+
'value' => $order->getData('carrier_method_lengow'),
|
85 |
+
);
|
86 |
+
$fields[] = array(
|
87 |
+
'label' => Mage::helper('sync')->__('Message'),
|
88 |
+
'value' => $order->getData('message_lengow'),
|
89 |
+
);
|
90 |
+
$fields[] = array(
|
91 |
+
'label' => Mage::helper('sync')->__('Json Node'),
|
92 |
+
'value' => '<textarea disabled="disabled">' . $order->getData('xml_node_lengow') . '</textarea>',
|
93 |
+
);
|
94 |
+
|
95 |
+
return $fields;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Check if is a Lengow order
|
100 |
+
*
|
101 |
+
* @return boolean
|
102 |
+
*/
|
103 |
+
public function isLengowOrder() {
|
104 |
+
return $this->getOrder()->getData('from_lengow');
|
105 |
+
}
|
106 |
+
}
|
app/code/community/Lengow/Sync/Block/Payment/Info/Purchaseorder.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow sync block payment info purchaseorder
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Block_Payment_Info_Purchaseorder extends Mage_Payment_Block_Info {
|
12 |
+
|
13 |
+
protected function _construct() {
|
14 |
+
parent::_construct();
|
15 |
+
$this->setTemplate('lengow/sales/payment/info/purchaseorder.phtml');
|
16 |
+
}
|
17 |
+
|
18 |
+
}
|
app/code/community/Lengow/Sync/Helper/Data.php
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow sync helper data
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Helper_Data extends Mage_Core_Helper_Abstract {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Transform SimpleXMLElement to associative array
|
15 |
+
* SimpleXMLElement must be conform structure, generated by assocToXml()
|
16 |
+
*
|
17 |
+
* @param SimpleXMLElement $xml
|
18 |
+
* @return array
|
19 |
+
*/
|
20 |
+
public function xmlToAssoc(SimpleXMLElement $xml) {
|
21 |
+
$array = array();
|
22 |
+
foreach ($xml as $key => $value) {
|
23 |
+
$array[$key] = trim((string)$value);
|
24 |
+
if (empty($array[$key]) && !empty($value))
|
25 |
+
$array[$key] = self::xmlToAssoc($value);
|
26 |
+
else
|
27 |
+
$array[$key] = (string)$value;
|
28 |
+
}
|
29 |
+
return $array;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Returns the node and children as an array
|
34 |
+
* values ares trimed
|
35 |
+
*
|
36 |
+
* @param bool $isCanonical - whether to ignore attributes
|
37 |
+
* @return array|string
|
38 |
+
*/
|
39 |
+
public function asArray(SimpleXMLElement $xml,$isCanonical = true) {
|
40 |
+
$result = array();
|
41 |
+
if (!$isCanonical) {
|
42 |
+
// add attributes
|
43 |
+
foreach ($xml->attributes() as $attributeName => $attribute) {
|
44 |
+
if ($attribute) {
|
45 |
+
$result['@'][$attributeName] = trim((string)$attribute);
|
46 |
+
}
|
47 |
+
}
|
48 |
+
}
|
49 |
+
// add children values
|
50 |
+
if ($xml->hasChildren()) {
|
51 |
+
foreach ($xml->children() as $childName => $child) {
|
52 |
+
if(!$child->hasChildren())
|
53 |
+
$result[$childName] = $this->asArray($child,$isCanonical);
|
54 |
+
else
|
55 |
+
$result[$childName][] = $this->asArray($child,$isCanonical);
|
56 |
+
}
|
57 |
+
} else {
|
58 |
+
if (empty($result)) {
|
59 |
+
// return as string, if nothing was found
|
60 |
+
$result = trim((string) $xml);
|
61 |
+
} else {
|
62 |
+
// value has zero key element
|
63 |
+
$result[0] = trim((string) $xml);
|
64 |
+
}
|
65 |
+
}
|
66 |
+
return $result;
|
67 |
+
}
|
68 |
+
|
69 |
+
public function log($message, $id_order = null) {
|
70 |
+
$log_model = Mage::getModel('sync/log');
|
71 |
+
$log_model->log($message, $id_order);
|
72 |
+
return $this;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Clean None utf-8 characters
|
77 |
+
* @param string $value
|
78 |
+
* @return string $value
|
79 |
+
*/
|
80 |
+
public function cleanNotUtf8($value) {
|
81 |
+
$value = Mage::helper('core/string')->cleanString($value);
|
82 |
+
//reject overly long 2 byte sequences, as well as characters above U+10000 and replace with blank
|
83 |
+
$value = preg_replace('/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]'.
|
84 |
+
'|[\x00-\x7F][\x80-\xBF]+'.
|
85 |
+
'|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*'.
|
86 |
+
'|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})'.
|
87 |
+
'|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S',
|
88 |
+
'', $value );
|
89 |
+
//reject overly long 3 byte sequences and UTF-16 surrogates and replace with blank
|
90 |
+
$value = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]'.
|
91 |
+
'|\xED[\xA0-\xBF][\x80-\xBF]/S','', $value );
|
92 |
+
/*$value = preg_replace("/([\x80-\xFF])/e",
|
93 |
+
"chr(0xC0|ord('\\1')>>6).chr(0x80|ord('\\1')&0x3F)",
|
94 |
+
$value);*/
|
95 |
+
$value = str_replace(chr(31),"", $value);
|
96 |
+
$value = str_replace(chr(30),"", $value);
|
97 |
+
$value = str_replace(chr(29),"", $value);
|
98 |
+
$value = str_replace(chr(28),"", $value);
|
99 |
+
//$value = iconv("UTF-8","UTF-8//IGNORE",$value);
|
100 |
+
return $value;
|
101 |
+
}
|
102 |
+
|
103 |
+
}
|
app/code/community/Lengow/Sync/Model/.DS_Store
ADDED
Binary file
|
app/code/community/Lengow/Sync/Model/Config.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow sync model config
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Model_Config extends Varien_Object {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Config key "Debug mode"
|
15 |
+
*/
|
16 |
+
const DEBUG_MODE = 'orders/debug';
|
17 |
+
|
18 |
+
const MP_CONF_LENGOW = 'http://kml.lengow.com/mp.xml';
|
19 |
+
|
20 |
+
protected $_id_store;
|
21 |
+
|
22 |
+
public static $ADDRESS_ATTRIBUTES = array(
|
23 |
+
'prefix' => 'na',
|
24 |
+
'firstname' => 'firstname',
|
25 |
+
'middlename' => 'na',
|
26 |
+
'lastname' => 'lastname',
|
27 |
+
'suffix' => 'na',
|
28 |
+
'company' => 'society',
|
29 |
+
'street' => array('address', 'address_2', 'address_complement'),
|
30 |
+
'city' => 'city',
|
31 |
+
'country_id' => 'country',
|
32 |
+
'region' => 'na',
|
33 |
+
'region_id' => 'na',
|
34 |
+
'postcode' => 'zipcode',
|
35 |
+
'telephone' => 'phone_home',
|
36 |
+
'fax' => 'phone_office',
|
37 |
+
'vat_id' => 'na',
|
38 |
+
);
|
39 |
+
|
40 |
+
public function setStore($id_store) {
|
41 |
+
$this->_id_store = $id_store;
|
42 |
+
return $this;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function getConfig($key) {
|
46 |
+
return Mage::getStoreConfig($key, $this->_id_store);
|
47 |
+
}
|
48 |
+
|
49 |
+
public function get($key) {
|
50 |
+
return Mage::getStoreConfig('sync/' . $key, $this->_id_store);
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Map Magento address attribute codes with Neteven ones
|
55 |
+
*
|
56 |
+
* @param string $attributeCode
|
57 |
+
* @return mixed
|
58 |
+
*/
|
59 |
+
public function getMappedAddressAttributeCode($attribute_code) {
|
60 |
+
return self::$ADDRESS_ATTRIBUTES[$attribute_code];
|
61 |
+
}
|
62 |
+
|
63 |
+
public function getOrderState($lengow) {
|
64 |
+
switch ($lengow) {
|
65 |
+
case 'new':
|
66 |
+
return Mage_Sales_Model_Order::STATE_NEW;
|
67 |
+
break;
|
68 |
+
case 'processing':
|
69 |
+
return Mage_Sales_Model_Order::STATE_PROCESSING;
|
70 |
+
break;
|
71 |
+
case 'shipped':
|
72 |
+
return Mage_Sales_Model_Order::STATE_COMPLETE;
|
73 |
+
break;
|
74 |
+
case 'canceled':
|
75 |
+
return Mage_Sales_Model_Order::STATE_CANCELED;
|
76 |
+
break;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Is debug mode
|
82 |
+
*
|
83 |
+
* @return boolean
|
84 |
+
*/
|
85 |
+
public function isDebugMode() {
|
86 |
+
return $this->get(self::DEBUG_MODE);
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Check and update xml of marketplace's configuration.
|
91 |
+
*
|
92 |
+
* @return boolean.
|
93 |
+
*/
|
94 |
+
public function updateMarketPlaceConfiguration() {
|
95 |
+
if ($xml = fopen(self::MP_CONF_LENGOW, 'r')) {
|
96 |
+
$markeplace = Mage::getModel('sync/marketplace');
|
97 |
+
$handle = fopen(Mage::getModuleDir('etc', 'Lengow_Sync') . DS . $markeplace::$XML_MARKETPLACES . '', 'w');
|
98 |
+
stream_copy_to_stream($xml, $handle);
|
99 |
+
fclose($handle);
|
100 |
+
Mage::getModel('core/config')->saveConfig('sync/hidden/last_synchro', date('Y-m-d'));
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
app/code/community/Lengow/Sync/Model/Connector.php
ADDED
@@ -0,0 +1,299 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright 2013 Lengow.
|
5 |
+
*
|
6 |
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
7 |
+
* not use this file except in compliance with the License. You may obtain
|
8 |
+
* a copy of the License at
|
9 |
+
*
|
10 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11 |
+
*
|
12 |
+
* Unless required by applicable law or agreed to in writing, software
|
13 |
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14 |
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15 |
+
* License for the specific language governing permissions and limitations
|
16 |
+
* under the License.
|
17 |
+
*/
|
18 |
+
|
19 |
+
if (!function_exists('curl_init')) {
|
20 |
+
throw new Lengow_Sync_Model_Connector_Exception('Lengow needs the CURL PHP extension.', -1);
|
21 |
+
}
|
22 |
+
if (!function_exists('json_decode')) {
|
23 |
+
throw new Lengow_Sync_Model_Connector_Exception('Lengow needs the JSON PHP extension.', -2);
|
24 |
+
}
|
25 |
+
if (!function_exists('simplexml_load_string')) {
|
26 |
+
throw new Lengow_Sync_Model_Connector_Exception('Lengow needs the SIMPLE XML PHP extension.', -3);
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* The Lengow connector API.
|
31 |
+
*
|
32 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
33 |
+
* @copyright 2013 Lengow SAS
|
34 |
+
*/
|
35 |
+
class Lengow_Sync_Model_Connector {
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Version.
|
39 |
+
*/
|
40 |
+
const VERSION = '1.0.1';
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Error.
|
44 |
+
*/
|
45 |
+
public $error;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Default options for curl.
|
49 |
+
*/
|
50 |
+
public static $CURL_OPTS = array(
|
51 |
+
CURLOPT_CONNECTTIMEOUT => 10,
|
52 |
+
CURLOPT_RETURNTRANSFER => true,
|
53 |
+
CURLOPT_TIMEOUT => 60,
|
54 |
+
CURLOPT_USERAGENT => 'lengow-api-1.0',
|
55 |
+
);
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Lengow webservices domains.
|
59 |
+
*/
|
60 |
+
public static $DOMAIN_LENGOW = array(
|
61 |
+
'solution' => array('protocol' => 'https',
|
62 |
+
'url' => 'solution.lengow.com',
|
63 |
+
'format' => 'json'),
|
64 |
+
'api' => array('protocol' => 'http',
|
65 |
+
'url' => 'api.lengow.com',
|
66 |
+
'format' => 'xml'),
|
67 |
+
'statistics' => array('protocol' => 'http',
|
68 |
+
'url' => 'statistics.lengow.com',
|
69 |
+
'format' => 'xml'),
|
70 |
+
);
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Lengow methods API.
|
74 |
+
*/
|
75 |
+
public static $API_METHODS_LENGOW = array(
|
76 |
+
'getListingFeeds' => array('service' => 'solution'),
|
77 |
+
'updateFeed' => array('service' => 'solution'),
|
78 |
+
'getHistoryFeed' => array('service' => 'solution'),
|
79 |
+
'updateInformationsClient' => array('service' => 'solution'),
|
80 |
+
'getListingGroups' => array('service' => 'solution'),
|
81 |
+
'createGroup' => array('service' => 'solution'),
|
82 |
+
'updateGroup' => array('service' => 'solution'),
|
83 |
+
'getListingVip' => array('service' => 'solution'),
|
84 |
+
'createVip' => array('service' => 'solution'),
|
85 |
+
'updateVip' => array('service' => 'solution'),
|
86 |
+
'getLeads' => array('service' => 'solution'),
|
87 |
+
'statusLead' => array('service' => 'solution'),
|
88 |
+
'updatePrestaInternalOrderId' => array('service' => 'solution'),
|
89 |
+
'updateTrackingMagento' => array('service' => 'solution'),
|
90 |
+
'updateRootFeed' => array('service' => 'solution'),
|
91 |
+
'getRootFeed' => array('service' => 'solution'),
|
92 |
+
'updateEcommerceSolution' => array('service' => 'solution'),
|
93 |
+
'getInternalOrderId' => array('service' => 'solution'),
|
94 |
+
'statistics' => array('service' => 'statistics'),
|
95 |
+
'commands' => array('service' => 'api'),
|
96 |
+
);
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Lengow token.
|
100 |
+
*/
|
101 |
+
public $token;
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Lengow ID customer.
|
105 |
+
*/
|
106 |
+
public $id_customer;
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Make a new Lengow API Connector.
|
110 |
+
*
|
111 |
+
* @param integer $id_customer Your customer ID.
|
112 |
+
* @param varchar $token Your token Lengow API.
|
113 |
+
*/
|
114 |
+
public function init($id_customer, $token) {
|
115 |
+
try {
|
116 |
+
if (is_integer($id_customer))
|
117 |
+
$this->id_customer = $id_customer;
|
118 |
+
else
|
119 |
+
throw new Lengow_Sync_Model_Connector_Exception('Error Lengow Customer ID', 1);
|
120 |
+
if (strlen($token) > 10)
|
121 |
+
$this->token = $token;
|
122 |
+
else
|
123 |
+
throw new Lengow_Sync_Model_Connector_Exception('Error Lengow Token API', 2);
|
124 |
+
} catch (Lengow_Sync_Model_Connector_Exception $e) {
|
125 |
+
$this->error = $e;
|
126 |
+
return false;
|
127 |
+
}
|
128 |
+
return true;
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* The API method.
|
133 |
+
*
|
134 |
+
* @param varchar $method Lengow method API call.
|
135 |
+
* @param varchar $array Lengow method API parameters
|
136 |
+
*
|
137 |
+
* @return array The formated data response
|
138 |
+
*/
|
139 |
+
public function api($method, $array) {
|
140 |
+
try {
|
141 |
+
if(!$api = $this->_getMethod($method))
|
142 |
+
throw new Lengow_Sync_Model_Connector_Exception('Error unknow method API', 3);
|
143 |
+
else
|
144 |
+
$data = $this->_callAction($api['service'], $method, $array);
|
145 |
+
} catch (Lengow_Sync_Model_Connector_Exception $e) {
|
146 |
+
return $e->getMessage();
|
147 |
+
}
|
148 |
+
return $data;
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Call the Lengow service with accepted method.
|
153 |
+
*
|
154 |
+
* @param varchar $service Lengow service name
|
155 |
+
* @param varchar $method Lengow method API call.
|
156 |
+
* @param varchar $array Lengow method API parameters
|
157 |
+
*
|
158 |
+
* @return array The formated data response
|
159 |
+
*/
|
160 |
+
private function _callAction($service, $method, $array) {
|
161 |
+
switch ($service) {
|
162 |
+
case 'solution' :
|
163 |
+
$url = $this->_getUrlService($service, $method, $array);
|
164 |
+
break;
|
165 |
+
case 'api' :
|
166 |
+
$url = $this->_getUrlOrders($service, $array);
|
167 |
+
break;
|
168 |
+
case 'statistics' :
|
169 |
+
$url = $this->_getUrlStatistics($service, $array);
|
170 |
+
break;
|
171 |
+
}
|
172 |
+
$result = $this->_makeRequest($url);
|
173 |
+
return $this->_format($result, self::$DOMAIN_LENGOW[$service]['format']);
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Makes the Service API Url.
|
178 |
+
*
|
179 |
+
* @param string $service The URL to make the request to
|
180 |
+
* @param string $array The array of query parameters
|
181 |
+
*
|
182 |
+
* @return string The url
|
183 |
+
*/
|
184 |
+
private function _getUrlService($service, $method, $array) {
|
185 |
+
$url = self::$DOMAIN_LENGOW[$service]['protocol']
|
186 |
+
. '://'
|
187 |
+
. self::$DOMAIN_LENGOW[$service]['url']
|
188 |
+
. '/wsdl/connector/call.json?'
|
189 |
+
. 'token=' . $this->token
|
190 |
+
. '&idClient=' . $this->id_customer
|
191 |
+
. '&method=' . $method
|
192 |
+
. '&array=' . urlencode(serialize($array));
|
193 |
+
return $url;
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Makes the Orders API Url.
|
198 |
+
*
|
199 |
+
* @param string $service The URL to make the request to
|
200 |
+
* @param string $array The array of query parameters
|
201 |
+
*
|
202 |
+
* @return string The url
|
203 |
+
*/
|
204 |
+
private function _getUrlOrders($service, $array) {
|
205 |
+
$url = self::$DOMAIN_LENGOW[$service]['protocol']
|
206 |
+
. '://'
|
207 |
+
. self::$DOMAIN_LENGOW[$service]['url'] . '/'
|
208 |
+
. 'v2/'
|
209 |
+
. $array['dateFrom'] . '/'
|
210 |
+
. $array['dateTo'] . '/'
|
211 |
+
. $this->id_customer .'/'
|
212 |
+
. $array['id_group'] .'/'
|
213 |
+
. (isset($array['id']) && !empty($array['id']) ? $array['id'] : 'orders')
|
214 |
+
. '/commands/'
|
215 |
+
. (isset($array['state']) && !empty($array['state']) ? $array['state'] . '/' : '');
|
216 |
+
return $url;
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Makes the Statisctics API Url.
|
221 |
+
*
|
222 |
+
* @param string $service The URL to make the request to
|
223 |
+
* @param string $array The array of query parameters
|
224 |
+
*
|
225 |
+
* @return string The url
|
226 |
+
*/
|
227 |
+
private function _getUrlStatistics($service, $array) {
|
228 |
+
$url = self::$DOMAIN_LENGOW[$service]['protocol']
|
229 |
+
. '://'
|
230 |
+
. self::$DOMAIN_LENGOW[$service]['url']
|
231 |
+
. $array['dateFrom'] . '/'
|
232 |
+
. $array['dateTo'] . '/'
|
233 |
+
. $this->id_customer .'/'
|
234 |
+
. $array['id']
|
235 |
+
. '/total-All/';
|
236 |
+
return $url;
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Get the method of Lengow API if exist.
|
241 |
+
*
|
242 |
+
* @param string $method The method's name
|
243 |
+
*
|
244 |
+
* @return string The method with service
|
245 |
+
*/
|
246 |
+
private function _getMethod($method) {
|
247 |
+
if(self::$API_METHODS_LENGOW[$method])
|
248 |
+
return self::$API_METHODS_LENGOW[$method];
|
249 |
+
else
|
250 |
+
return false;
|
251 |
+
}
|
252 |
+
|
253 |
+
/**
|
254 |
+
* Format data with good format.
|
255 |
+
*
|
256 |
+
* @param string $data the data's response of method request
|
257 |
+
* @param string $format the return format
|
258 |
+
*
|
259 |
+
* @return string Data formated
|
260 |
+
*/
|
261 |
+
private function _format($data, $format) {
|
262 |
+
switch($format) {
|
263 |
+
case 'xml' :
|
264 |
+
return simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA);
|
265 |
+
case 'json' :
|
266 |
+
return json_decode($data, true);
|
267 |
+
}
|
268 |
+
return null;
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Makes an HTTP request.
|
273 |
+
*
|
274 |
+
* @param string $url The URL to make the request to
|
275 |
+
*
|
276 |
+
* @return string The response text
|
277 |
+
*/
|
278 |
+
protected function _makeRequest($url) {
|
279 |
+
Mage::helper('sync/data')->log('Connector ' . $url);
|
280 |
+
$ch = curl_init();
|
281 |
+
// Options
|
282 |
+
$opts = self::$CURL_OPTS;
|
283 |
+
$opts[CURLOPT_URL] = $url;
|
284 |
+
// Exectute url request
|
285 |
+
curl_setopt_array($ch, $opts);
|
286 |
+
$result = curl_exec($ch);
|
287 |
+
if ($result === false) {
|
288 |
+
Mage::helper('sync/data')->log('Connector Error (' . curl_error($ch) . ')' . $result);
|
289 |
+
throw new Lengow_Sync_Model_Connector_Exception(
|
290 |
+
array('message' => curl_error($ch),
|
291 |
+
'type' => 'CurlException',
|
292 |
+
),
|
293 |
+
curl_errno($ch)
|
294 |
+
);
|
295 |
+
}
|
296 |
+
curl_close($ch);
|
297 |
+
return $result;
|
298 |
+
}
|
299 |
+
}
|
app/code/community/Lengow/Sync/Model/Connector/Exception.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Thrown when an API call returns an exception.
|
4 |
+
*
|
5 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
6 |
+
*/
|
7 |
+
class Lengow_Sync_Model_Connector_Exception extends Exception {
|
8 |
+
|
9 |
+
/**
|
10 |
+
* The result from the API server that represents the exception information.
|
11 |
+
*/
|
12 |
+
protected $result;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Make a new API Exception with the given result.
|
16 |
+
*
|
17 |
+
* @param array $result The error result
|
18 |
+
*/
|
19 |
+
public function __construct($result, $noerror) {
|
20 |
+
$this->result = $result;
|
21 |
+
if(is_array($result))
|
22 |
+
$msg = $result['message'];
|
23 |
+
else
|
24 |
+
$msg = $result;
|
25 |
+
parent::__construct($msg, $noerror);
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Return the associated result object returned by the API server.
|
30 |
+
*
|
31 |
+
* @return array The result from the API server
|
32 |
+
*/
|
33 |
+
public function getResult() {
|
34 |
+
return $this->result;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Returns the associated type for the error.
|
39 |
+
*
|
40 |
+
* @return string
|
41 |
+
*/
|
42 |
+
public function getType() {
|
43 |
+
if(isset($this->result['type']))
|
44 |
+
return $this->result['type'];
|
45 |
+
return 'Lengow_Sync_Model_Connector_Exception';
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* To make debugging easier.
|
50 |
+
*
|
51 |
+
* @return string The string representation of the error
|
52 |
+
*/
|
53 |
+
public function __toString() {
|
54 |
+
if(isset($this->result['message']))
|
55 |
+
return $this->result['message'];
|
56 |
+
return $this->message;
|
57 |
+
}
|
58 |
+
}
|
app/code/community/Lengow/Sync/Model/Customer/Customer.php
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow sync model customer
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Model_Customer_Customer extends Mage_Customer_Model_Customer {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Convert xml node to customer model
|
15 |
+
*
|
16 |
+
* @param $xml_node SimpleXMLElement
|
17 |
+
*/
|
18 |
+
public function setFromNode(SimpleXMLElement $xml_node) {
|
19 |
+
$array = Mage::helper('sync')->xmlToAssoc($xml_node);
|
20 |
+
if(empty($array['billing_address']['billing_email']))
|
21 |
+
$array['billing_address']['billing_email'] = 'no-mail-' . $array['order_id'] . '@' . $array['marketplace'] . '.com';
|
22 |
+
if(empty($array['billing_address']['billing_firstname']))
|
23 |
+
$array['billing_address']['billing_firstname'] = '__';
|
24 |
+
$this->setWebsiteId(Mage::app()->getDefaultStoreView()->getWebsiteId())
|
25 |
+
->loadByEmail($array['billing_address']['billing_email']);
|
26 |
+
if(!$this->getId()) {
|
27 |
+
$this->setImportMode(true);
|
28 |
+
$this->setWebsiteId(Mage::app()->getDefaultStoreView()->getWebsiteId());
|
29 |
+
$this->setConfirmation(null);
|
30 |
+
$this->setForceConfirmed(true);
|
31 |
+
$this->setPasswordHash($this->hashPassword($this->generatePassword(8)));
|
32 |
+
$this->setFromLengow(1);
|
33 |
+
}
|
34 |
+
// Billing address
|
35 |
+
$billing_address = $this->convertAddress($array['billing_address']);
|
36 |
+
$this->addAddress($billing_address);
|
37 |
+
// Shipping address
|
38 |
+
$shipping_address = $this->convertAddress($array['delivery_address'], 'shipping');
|
39 |
+
$this->addAddress($shipping_address);
|
40 |
+
Mage::helper('core')->copyFieldset('lengow_convert_billing_address', 'to_customer', $array['billing_address'], $this);
|
41 |
+
$this->save();
|
42 |
+
return $this;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Convert xml node to customer address model
|
47 |
+
*
|
48 |
+
* @param array $data
|
49 |
+
* @return Mage_Customer_Model_Address
|
50 |
+
*/
|
51 |
+
public function convertAddress(array $data, $type = 'billing') {
|
52 |
+
$address = Mage::getModel('customer/address');
|
53 |
+
$address->setId(null);
|
54 |
+
$address->setIsDefaultBilling(true);
|
55 |
+
$address->setIsDefaultShipping(false);
|
56 |
+
if($type == 'shipping') {
|
57 |
+
$address->setIsDefaultBilling(false);
|
58 |
+
$address->setIsDefaultShipping(true);
|
59 |
+
}
|
60 |
+
Mage::helper('core')->copyFieldset('lengow_convert_' . $type . '_address', 'to_' . $type . '_address', $data, $address);
|
61 |
+
// Fix address 2
|
62 |
+
if($type == 'shipping')
|
63 |
+
$type = 'delivery';
|
64 |
+
$address_1 = $data[$type . '_address'];
|
65 |
+
$address_2 = $data[$type . '_address_2'];
|
66 |
+
if(!empty($address_2))
|
67 |
+
$address_1 = $address_1 . "\n" . $address_2;
|
68 |
+
$address_3 = $data[$type . '_address_complement'];
|
69 |
+
if(!empty($address_3))
|
70 |
+
$address_1 = $address_1 . "\n" . $address_3;
|
71 |
+
$address->setStreet($address_1);
|
72 |
+
$tel_1 = $data[$type . '_phone_office'];
|
73 |
+
$tel_2 = $data[$type . '_phone_mobile'];
|
74 |
+
// Fix tel
|
75 |
+
if(!empty($tel_1))
|
76 |
+
$address->setFax($tel_1);
|
77 |
+
else if(!empty($tel_2))
|
78 |
+
$address->setFax($tel_2);
|
79 |
+
$codeRegion = substr(str_pad($address->getPostcode(), 5, '0', STR_PAD_LEFT), 0, 2);
|
80 |
+
$id_region = Mage::getModel('directory/region')->getCollection()
|
81 |
+
->addRegionCodeFilter($codeRegion)
|
82 |
+
->addCountryFilter($address->getCountry())
|
83 |
+
->getFirstItem()
|
84 |
+
->getId();
|
85 |
+
$address->setRegionId($id_region);
|
86 |
+
return $address;
|
87 |
+
}
|
88 |
+
}
|
app/code/community/Lengow/Sync/Model/Import.php
ADDED
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow sync model import
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Model_Import extends Varien_Object {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var Mage_Sales_Model_Quote
|
15 |
+
*/
|
16 |
+
protected $_quote = null;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var Mage_Customer_Model_Customer
|
20 |
+
*/
|
21 |
+
protected $_customer = null;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Config Data of Module Manageorders
|
25 |
+
* @var Profileolabs_Lengow_Model_Manageorders_Config
|
26 |
+
*/
|
27 |
+
protected $_config = null;
|
28 |
+
|
29 |
+
protected $_ordersIdsImported = array();
|
30 |
+
|
31 |
+
protected $_orderIdsAlreadyImported = array();
|
32 |
+
|
33 |
+
protected $_result;
|
34 |
+
|
35 |
+
protected $_resultSendOrder = "";
|
36 |
+
|
37 |
+
protected $_isUnderVersion14 = null;
|
38 |
+
/**
|
39 |
+
* Product model
|
40 |
+
*
|
41 |
+
* @var Mage_Catalog_Model_Product
|
42 |
+
*/
|
43 |
+
protected $_productModel;
|
44 |
+
|
45 |
+
protected $store_id = 0;
|
46 |
+
|
47 |
+
protected $_helper;
|
48 |
+
|
49 |
+
public static $import_start = false;
|
50 |
+
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Construct the import manager
|
54 |
+
*
|
55 |
+
* @param $command varchar The command of import
|
56 |
+
* @param mixed
|
57 |
+
*/
|
58 |
+
public function exec($command = 'orders', $args = array()) {
|
59 |
+
switch ($command) {
|
60 |
+
case 'orders':
|
61 |
+
return $this->_importOrders($args);
|
62 |
+
default:
|
63 |
+
return $this->_importOrders($args);
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Makes the Orders API Url.
|
69 |
+
*
|
70 |
+
* @param array $args The arguments to request at the API
|
71 |
+
*/
|
72 |
+
protected function _importOrders($args = array()) {
|
73 |
+
if(Mage::app()->getStore()->getCode() != 'admin')
|
74 |
+
Mage::app()->setCurrentStore('admin');
|
75 |
+
$this->_helper = Mage::helper('sync/data');
|
76 |
+
$this->_config = Mage::getSingleton('sync/config');
|
77 |
+
$this->_checkVersionMarketplaceXML();
|
78 |
+
$connector = Mage::getSingleton('sync/connector');
|
79 |
+
self::$import_start = true;
|
80 |
+
$count_orders_updated = 0;
|
81 |
+
$count_orders_added = 0;
|
82 |
+
$connector->init((integer) $this->_config->getConfig('tracker/general/login'),
|
83 |
+
$this->_config->getConfig('tracker/general/api_key'));
|
84 |
+
$orders = $connector->api('commands', array('dateFrom' => $args['dateFrom'],
|
85 |
+
'dateTo' => $args['dateTo'],
|
86 |
+
'id_group' => $this->_config->getConfig('tracker/general/group'),
|
87 |
+
'state' => 'plugin'));
|
88 |
+
if(!is_object($orders)) {
|
89 |
+
$this->_helper->log('Error on lengow webservice');
|
90 |
+
return false;
|
91 |
+
} else {
|
92 |
+
$find_count_orders = count($orders->orders->order);
|
93 |
+
$this->_helper->log('Find ' . $find_count_orders . ' order' . ($find_count_orders > 1 ? 's' : ''));
|
94 |
+
}
|
95 |
+
//LengowCore::debug($orders);
|
96 |
+
$count_orders = (integer) $orders->orders_count->count_total;
|
97 |
+
if($count_orders == 0) {
|
98 |
+
$this->_helper->log('No orders to import between ' . $args['dateFrom'] . ' and ' . $args['dateTo'], $this->force_log_output);
|
99 |
+
return false;
|
100 |
+
}
|
101 |
+
$model_order = Mage::getModel('sync/order');
|
102 |
+
foreach($orders->orders->order as $key => $data) {
|
103 |
+
$lengow_order = $data;
|
104 |
+
$lengow_order_id = (string) $lengow_order->order_id;
|
105 |
+
if($this->_config->isDebugMode()) {
|
106 |
+
$lengow_order_id = $lengow_order_id . time();
|
107 |
+
}
|
108 |
+
$marketplace = Mage::getModel('sync/marketplace');
|
109 |
+
$marketplace->set((string) $lengow_order->marketplace);
|
110 |
+
$id_flux = (integer) $lengow_order->idFlux;
|
111 |
+
if((string) $lengow_order->order_status->marketplace == '') {
|
112 |
+
$this->_helper->log('Order ' . $lengow_order_id . ' : no order\'s status');
|
113 |
+
continue;
|
114 |
+
}
|
115 |
+
if((integer) $lengow_order->tracking_informations->tracking_deliveringByMarketPlace == 1) {
|
116 |
+
$this->_helper->log('Order ' . $lengow_order_id . ' : delivry by the marketplace (' . $lengow_order->marketplace . ')');
|
117 |
+
continue;
|
118 |
+
}
|
119 |
+
if($model_order->isAlreadyImported($lengow_order_id, $id_flux)) {
|
120 |
+
$this->_helper->log('Order ' . $lengow_order_id . ' : already imported');
|
121 |
+
$order_imported = $model_order->getOrderByIdLengow($lengow_order_id, $id_flux);
|
122 |
+
$lengow_status = (string) $lengow_order->order_status->lengow;
|
123 |
+
$this->_config->getOrderState($lengow_status);
|
124 |
+
// Update status' order only if in process or shipped
|
125 |
+
if($order_imported->getState() != $this->_config->getOrderState($lengow_status)) {
|
126 |
+
// Change state process to shipped
|
127 |
+
if($order_imported->getState() == $this->_config->getOrderState('processing')
|
128 |
+
&& $lengow_order->order_status->lengow == 'shipped') {
|
129 |
+
$order_imported->toShip($order,
|
130 |
+
(string) $lengow_order->tracking_informations->tracking_carrier,
|
131 |
+
(string) $lengow_order->tracking_informations->tracking_method,
|
132 |
+
(string) $lengow_order->tracking_informations->tracking_number);
|
133 |
+
$this->_helper->log('Order ' . $lengow_order_id . ' : update state to shipped');
|
134 |
+
$count_orders_updated++;
|
135 |
+
} else if(($order_imported->current_state == $this->_config->getOrderState('process') // Change state process or shipped to cancel
|
136 |
+
|| $order_imported->current_state == $this->_config->getOrderState('shipped'))
|
137 |
+
&& $lengow_order->order_status->lengow == 'canceled') {
|
138 |
+
$lengow_order->toCancel();
|
139 |
+
$this->_helper->log('Order ' . $lengow_order_id . ' : update state to cancel');
|
140 |
+
$count_orders_updated++;
|
141 |
+
}
|
142 |
+
}
|
143 |
+
} else {
|
144 |
+
// Import only process order or shipped order and not imported with previous module
|
145 |
+
$lengow_order_state = (string) $lengow_order->order_status->marketplace;
|
146 |
+
$id_order_magento = (string) $lengow_order->order_external_id;
|
147 |
+
if(($marketplace->getStateLengow($lengow_order_state) == 'processing'
|
148 |
+
|| $marketplace->getStateLengow($lengow_order_state) == 'shipped') && !$id_order_magento) {
|
149 |
+
////try {
|
150 |
+
$order = Mage::getModel('sync/order');
|
151 |
+
// Create or Update customer with addresses
|
152 |
+
$customer = Mage::getModel('sync/customer_customer');
|
153 |
+
$customer->setFromNode($data);
|
154 |
+
// Create quote
|
155 |
+
if(!$quote = $order->createQuote($data, $customer)) {
|
156 |
+
$this->_helper->log('Order ' . $lengow_order_id . ' : create order fail');
|
157 |
+
continue;
|
158 |
+
}
|
159 |
+
// Create order
|
160 |
+
$order = $order->makeOrder($data, $quote);
|
161 |
+
if($order) {
|
162 |
+
// Sync to lengow
|
163 |
+
if(!$this->_config->isDebugMode()) {
|
164 |
+
$orders = $connector->api('getInternalOrderId', array(
|
165 |
+
'idClient' => (integer) $this->_config->getConfig('tracker/general/login'),
|
166 |
+
'idFlux' => $this->_config->getConfig('tracker/general/api_key'),
|
167 |
+
'Marketplace' => (string) $lengow_order->marketplace,
|
168 |
+
'idCommandeMP' => $lengow_order_id,
|
169 |
+
'idCommandeMage' => $order->getId(),
|
170 |
+
'statutCommandeMP' => (string) $lengow_order->order_status->lengow,
|
171 |
+
'statutCommandeMage' => $order->getState(),
|
172 |
+
'idQuoteMage' => $quote->getId(),
|
173 |
+
'Message' => 'Import depuis: ' . (string) $lengow_order->marketplace . '<br/>idOrder: '.$lengow_order_id,
|
174 |
+
'type' => 'Magento'
|
175 |
+
));
|
176 |
+
$this->_helper->log('Order ' . $lengow_order_id . ' : sync with Lengow (Order ' . $order->getId() . ')');
|
177 |
+
}
|
178 |
+
$count_orders_added++;
|
179 |
+
$this->_helper->log('Order ' . $lengow_order_id . ' : import success (' . $order->getId() . ')');
|
180 |
+
}
|
181 |
+
// Clear session
|
182 |
+
Mage::getSingleton('checkout/session')->clear();
|
183 |
+
////*} catch(Exception $e) {
|
184 |
+
//$this->_helper->log($e->getMessage(),$orderLw['IdOrder']);
|
185 |
+
//Erase session for the next order
|
186 |
+
//$this->getSession()->clear();
|
187 |
+
|
188 |
+
//}*////
|
189 |
+
} else {
|
190 |
+
if($id_order_magento) {
|
191 |
+
$this->_helper->log('Order ' . $lengow_order_id . ' : already imported in Magento with order ID ' . $id_order_magento);
|
192 |
+
} else {
|
193 |
+
$this->_helper->log('Order ' . $lengow_order_id . ' : order\'s status not available to import');
|
194 |
+
}
|
195 |
+
}
|
196 |
+
}
|
197 |
+
}
|
198 |
+
self::$import_start = false;
|
199 |
+
return array('new' => $count_orders_added,
|
200 |
+
'update' => $count_orders_updated);
|
201 |
+
}
|
202 |
+
|
203 |
+
private function _checkVersionMarketplaceXML() {
|
204 |
+
$mp_update = $this->_config->get('hidden/last_synchro');
|
205 |
+
if (!$mp_update || !$mp_update == '0000-00-00' ||$mp_update != date('Y-m-d'))
|
206 |
+
$this->_config->updateMarketPlaceConfiguration();
|
207 |
+
}
|
208 |
+
|
209 |
+
}
|
app/code/community/Lengow/Sync/Model/Log.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow sync model log
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Model_Log extends Mage_Core_Model_Abstract {
|
12 |
+
|
13 |
+
protected function _construct() {
|
14 |
+
$this->_init('sync/log');
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Save message event
|
19 |
+
* @param $message string
|
20 |
+
* @param $id_order int
|
21 |
+
*/
|
22 |
+
public function log($message, $id_order = null) {
|
23 |
+
$order_message = '';
|
24 |
+
if(!is_null($id_order)) {
|
25 |
+
$order_message = Mage::helper('sync')->__('ID Order') . ' Lengow #' . $id_order . ' ';
|
26 |
+
}
|
27 |
+
$message = $order_message . $message;
|
28 |
+
$this->setMessage($message);
|
29 |
+
return $this->save();
|
30 |
+
}
|
31 |
+
|
32 |
+
}
|
app/code/community/Lengow/Sync/Model/Marketplace.php
ADDED
@@ -0,0 +1,264 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright 2013 Lengow.
|
5 |
+
*
|
6 |
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
7 |
+
* not use this file except in compliance with the License. You may obtain
|
8 |
+
* a copy of the License at
|
9 |
+
*
|
10 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11 |
+
*
|
12 |
+
* Unless required by applicable law or agreed to in writing, software
|
13 |
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14 |
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15 |
+
* License for the specific language governing permissions and limitations
|
16 |
+
* under the License.
|
17 |
+
*/
|
18 |
+
|
19 |
+
|
20 |
+
/**
|
21 |
+
* The Lengow Marketplace Class.
|
22 |
+
*
|
23 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
24 |
+
* @copyright 2013 Lengow SAS
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Lengow_Sync_Model_Marketplace {
|
28 |
+
|
29 |
+
public static $XML_MARKETPLACES = 'marketplaces.xml';
|
30 |
+
public static $DOM;
|
31 |
+
public static $VALID_ACTIONS = array(
|
32 |
+
// 'accept' ,
|
33 |
+
'shipped' ,
|
34 |
+
'refuse' ,
|
35 |
+
'link' ,
|
36 |
+
);
|
37 |
+
public static $WSDL_LINK_ORDER = 'https://wsdl.lengow.com/wsdl/link/#MP#/#ID_CLIENT#/#ID_FLUX#/#ORDER_ID#/#INTERNAL_ORDER_ID#/update.xml';
|
38 |
+
public $name;
|
39 |
+
public $object;
|
40 |
+
public $is_loaded = false;
|
41 |
+
public $states_lengow = array();
|
42 |
+
public $states = array();
|
43 |
+
public $actions = array();
|
44 |
+
protected $_config;
|
45 |
+
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Construct a new Markerplace instance with xml configuration.
|
49 |
+
*
|
50 |
+
* @param string $name The name of the marketplace
|
51 |
+
*/
|
52 |
+
public function set($name) {
|
53 |
+
$this->_helper = Mage::helper('sync/data');
|
54 |
+
$this->_loadXml();
|
55 |
+
$this->name = strtolower($name);
|
56 |
+
$object = self::$DOM->xpath('/marketplaces/marketplace[@name=\'' . $this->name . '\']');
|
57 |
+
if(!empty($object)) {
|
58 |
+
$this->object = $object[0];
|
59 |
+
$this->api_url = (string) $this->object->api;
|
60 |
+
foreach($this->object->states->state as $state) {
|
61 |
+
$this->states_lengow[(string) $state['name']] = (string) $state->lengow;
|
62 |
+
$this->states[(string) $state->lengow] = (string) $state['name'];
|
63 |
+
if(isset($state->actions)) {
|
64 |
+
foreach($state->actions->action as $action) {
|
65 |
+
$this->actions[(string) $action['type']] = array();
|
66 |
+
$this->actions[(string) $action['type']]['name'] = (string) $action;
|
67 |
+
$params = self::$DOM->xpath('/marketplaces/marketplace[@name=\'' . $this->name . '\']/additional_params/param[@usedby=\'' . (string) $action['type']. '\']');
|
68 |
+
if(count($params)) {
|
69 |
+
foreach($params as $param) {
|
70 |
+
$this->actions[(string) $action['type']]['params'][(string) $param->type]['name'] = (string) $param->name;
|
71 |
+
if(isset($param->accepted_values))
|
72 |
+
$this->actions[(string) $action['type']]['params'][(string) $param->type]['accepted_values'] = $param->accepted_values->value;
|
73 |
+
}
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
$this->is_loaded = true;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* If marketplace exist in xml configuration file
|
84 |
+
*
|
85 |
+
* @return boolean
|
86 |
+
*/
|
87 |
+
public function isLoaded() {
|
88 |
+
return $this->is_loaded;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Get the real lengow's state
|
93 |
+
*
|
94 |
+
* @param string $name The marketplace state
|
95 |
+
*
|
96 |
+
* @return string The lengow state
|
97 |
+
*/
|
98 |
+
public function getStateLengow($name) {
|
99 |
+
return $this->states_lengow[$name];
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Get the marketplace's state
|
104 |
+
*
|
105 |
+
* @param string $name The lengow state
|
106 |
+
*
|
107 |
+
* @return string The marketplace state
|
108 |
+
*/
|
109 |
+
public function getState($name) {
|
110 |
+
return $this->states[$name];
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Get the action with parameters
|
115 |
+
*
|
116 |
+
* @param string $name The action's name
|
117 |
+
*
|
118 |
+
* @return array
|
119 |
+
*/
|
120 |
+
public function getAction($name) {
|
121 |
+
return $this->actions[$name];
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* If action exist
|
126 |
+
*
|
127 |
+
* @param string $name The marketplace state
|
128 |
+
*
|
129 |
+
* @return boolean
|
130 |
+
*/
|
131 |
+
public function isAction($name) {
|
132 |
+
return isset($this->actions[$name]) ? true : false;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Call the Lengow WSDL for current marketplace
|
137 |
+
*
|
138 |
+
* @param string $action The name of the action
|
139 |
+
* @param string $id_feed The flux ID
|
140 |
+
* @param Mage_Sales_Model_Order $order The order
|
141 |
+
* @param string $args An array of arguments
|
142 |
+
*/
|
143 |
+
public function wsdl($action, $id_feed, Mage_Sales_Model_Order $order, Mage_Sales_Model_Order_Shipment $shipment, $args = array()) {
|
144 |
+
if(!in_array($action, self::$VALID_ACTIONS))
|
145 |
+
return false;
|
146 |
+
if(!$this->isAction($action))
|
147 |
+
return false;
|
148 |
+
$call_url = false;
|
149 |
+
switch($action) {
|
150 |
+
case 'shipped' :
|
151 |
+
$call_url = $this->api_url;
|
152 |
+
$call_url = str_replace('#ID_FLUX#', $id_feed, $call_url);
|
153 |
+
$call_url = str_replace('#ORDER_ID#', $order->getData('order_id_lengow'), $call_url);
|
154 |
+
$action_array = $this->getAction($action);
|
155 |
+
$action_callback = $action_array['name'];
|
156 |
+
$call_url = str_replace('#ACTION#', $action_callback, $call_url);
|
157 |
+
if(isset($action_array['params'])) {
|
158 |
+
$gets = array();
|
159 |
+
foreach($action_array['params'] as $type => $param) {
|
160 |
+
switch($type) {
|
161 |
+
case 'tracking' :
|
162 |
+
$trackings = $shipment->getAllTracks();
|
163 |
+
if(!empty($trackings)) {
|
164 |
+
$first_track = $trackings[0];
|
165 |
+
$gets[] = $param['name'] . '=' . $first_track->getNumber();
|
166 |
+
}
|
167 |
+
break;
|
168 |
+
case 'carrier' :
|
169 |
+
$trackings = $shipment->getAllTracks();
|
170 |
+
if(!empty($trackings)) {
|
171 |
+
$first_track = $trackings[0];
|
172 |
+
$gets[] = $param['name'] . '=' . $first_track->getCarrierCode();
|
173 |
+
}
|
174 |
+
break;
|
175 |
+
case 'tracking_url' :
|
176 |
+
break;
|
177 |
+
case 'shipping_price' :
|
178 |
+
$gets[] = $param['name'] . '=' . $order->getShippingInclTax();
|
179 |
+
break;
|
180 |
+
}
|
181 |
+
}
|
182 |
+
if(count($gets) > 0)
|
183 |
+
$call_url .= '?' . implode('&', $gets);
|
184 |
+
}
|
185 |
+
break;
|
186 |
+
case 'refuse' :
|
187 |
+
$call_url = $this->api_url;
|
188 |
+
$call_url = str_replace('#ID_FLUX#', $id_feed, $call_url);
|
189 |
+
$call_url = str_replace('#ORDER_ID#', $order->getData('order_id_lengow'), $call_url);
|
190 |
+
$action_array = $this->getAction($action);
|
191 |
+
$action_callback = $action_array['name'];
|
192 |
+
$call_url = str_replace('#ACTION#', $action_callback, $call_url);
|
193 |
+
if(isset($action_array['params'])) {
|
194 |
+
$gets = array();
|
195 |
+
foreach($action_array['params'] as $type => $param) {
|
196 |
+
switch($type) {
|
197 |
+
case 'refused_reason' :
|
198 |
+
break;
|
199 |
+
}
|
200 |
+
}
|
201 |
+
if(count($gets) > 0)
|
202 |
+
$call_url .= '?' . implode('&', $gets);
|
203 |
+
}
|
204 |
+
break;
|
205 |
+
case 'link' :
|
206 |
+
$call_url = self::$WSDL_LINK_ORDER;
|
207 |
+
$call_url = str_replace('#MP#', $this->name, $call_url);
|
208 |
+
$call_url = str_replace('#ID_CLIENT#', $args['id_client'], $call_url);
|
209 |
+
$call_url = str_replace('#ID_FLUX#', $id_feed, $call_url);
|
210 |
+
$call_url = str_replace('#ORDER_ID#', $order->getData('order_id_lengow'), $call_url);
|
211 |
+
$call_url = str_replace('#INTERNAL_ORDER_ID#', $order->getData('entity_id'), $call_url);
|
212 |
+
|
213 |
+
}
|
214 |
+
try {
|
215 |
+
if($call_url) {
|
216 |
+
if(!Mage::getSingleton('sync/config')->isDebugMode()) {
|
217 |
+
$this->_makeRequest($call_url);
|
218 |
+
}
|
219 |
+
Mage::helper('sync')->log('Order ' . $order->getData('order_id_lengow') . ' : call Lengow WSDL ' . $call_url);
|
220 |
+
}
|
221 |
+
} catch(Lengow_Sync_Model_Marketplace_Exception $e) {
|
222 |
+
Mage::helper('sync')->log('Order ' . $order->getData('order_id_lengow') . ' : call error WSDL ' . $call_url);
|
223 |
+
Mage::helper('sync')->log('Order ' . $order->getData('order_id_lengow') . ' : exception ' . $e->getMessage());
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Load the xml configuration of all marketplaces
|
229 |
+
*/
|
230 |
+
private function _loadXml() {
|
231 |
+
if(!self::$DOM) {
|
232 |
+
self::$DOM = simplexml_load_file(Mage::getModuleDir('etc', 'Lengow_Sync') . DS . self::$XML_MARKETPLACES);
|
233 |
+
}
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Makes an HTTP request.
|
238 |
+
*
|
239 |
+
* @param string $url The URL to make the request to
|
240 |
+
*
|
241 |
+
* @return string The response text
|
242 |
+
*/
|
243 |
+
protected function _makeRequest($url) {
|
244 |
+
$ch = curl_init();
|
245 |
+
// Options
|
246 |
+
$connector = Mage::getSingleton('sync/connector');
|
247 |
+
$opts = $connector::$CURL_OPTS;
|
248 |
+
$opts[CURLOPT_URL] = $url;
|
249 |
+
// Exectute url request
|
250 |
+
curl_setopt_array($ch, $opts);
|
251 |
+
$result = curl_exec($ch);
|
252 |
+
if ($result === false) {
|
253 |
+
throw new Lengow_Sync_Model_Marketplace_Exception(
|
254 |
+
array('message' => curl_error($ch),
|
255 |
+
'type' => 'CurlException',
|
256 |
+
),
|
257 |
+
curl_errno($ch)
|
258 |
+
);
|
259 |
+
}
|
260 |
+
curl_close($ch);
|
261 |
+
return $result;
|
262 |
+
}
|
263 |
+
|
264 |
+
}
|
app/code/community/Lengow/Sync/Model/Marketplace/Exception.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Thrown when an WSDL call returns an exception.
|
5 |
+
*
|
6 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
7 |
+
*/
|
8 |
+
class Lengow_Sync_Model_Marketplace_Exception extends Exception {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* The result from the WSDL server that represents the exception information.
|
12 |
+
*/
|
13 |
+
protected $result;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Make a new WSDL Exception with the given result.
|
17 |
+
*
|
18 |
+
* @param array $result The error result
|
19 |
+
*/
|
20 |
+
public function __construct($result, $noerror) {
|
21 |
+
$this->result = $result;
|
22 |
+
if(is_array($result))
|
23 |
+
$msg = $result['message'];
|
24 |
+
else
|
25 |
+
$msg = $result;
|
26 |
+
parent::__construct($msg, $noerror);
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Return the associated result object returned by the WSDL server.
|
31 |
+
*
|
32 |
+
* @return array The result from the WSDL server
|
33 |
+
*/
|
34 |
+
public function getResult() {
|
35 |
+
return $this->result;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Returns the associated type for the error.
|
40 |
+
*
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
public function getType() {
|
44 |
+
if(isset($this->result['type']))
|
45 |
+
return $this->result['type'];
|
46 |
+
return 'Lengow_Sync_Model_Marketplace_Exception';
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* To make debugging easier.
|
51 |
+
*
|
52 |
+
* @return string The string representation of the error
|
53 |
+
*/
|
54 |
+
public function __toString() {
|
55 |
+
if(isset($this->result['message']))
|
56 |
+
return $this->result['message'];
|
57 |
+
return $this->message;
|
58 |
+
}
|
59 |
+
}
|
app/code/community/Lengow/Sync/Model/Mysql4/.DS_Store
ADDED
Binary file
|
app/code/community/Lengow/Sync/Model/Mysql4/Log.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow sync model mysql4 log
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Model_Mysql4_Log extends Mage_Core_Model_Mysql4_Abstract {
|
12 |
+
|
13 |
+
protected function _construct() {
|
14 |
+
$this->_init('sync/log', 'id');
|
15 |
+
}
|
16 |
+
}
|
app/code/community/Lengow/Sync/Model/Mysql4/Log/Collection.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow sync model mysql4 log collection
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Model_Mysql4_Log_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
12 |
+
|
13 |
+
protected function _construct() {
|
14 |
+
$this->_init('sync/log');
|
15 |
+
}
|
16 |
+
}
|
app/code/community/Lengow/Sync/Model/Observer.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow sync model observer
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Model_Observer {
|
12 |
+
|
13 |
+
public function import($observer) {
|
14 |
+
try {
|
15 |
+
$_config = Mage::getSingleton('sync/config');
|
16 |
+
if($_config->getConfig('sync/orders/cron')) {
|
17 |
+
$import = Mage::getModel('sync/import');
|
18 |
+
$days = Mage::getModel('sync/config')->setStore(Mage::app()->getStore()->getId())
|
19 |
+
->getConfig('sync/orders/period');
|
20 |
+
$date_from = date('Y-m-d', strtotime(date('Y-m-d') . '-' . $days . 'days'));
|
21 |
+
$date_to = date('Y-m-d');
|
22 |
+
$import = Mage::getModel('sync/import');
|
23 |
+
$result = $import->exec('orders', array('dateFrom' => $date_from,
|
24 |
+
'dateTo' => $date_to));
|
25 |
+
}
|
26 |
+
} catch (Exception $e) {
|
27 |
+
Mage::throwException($e);
|
28 |
+
}
|
29 |
+
return $this;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function salesOrderShipmentSaveAfter(Varien_Event_Observer $observer) {
|
33 |
+
$shipment = $observer->getEvent()->getShipment();
|
34 |
+
$order = $shipment->getOrder();
|
35 |
+
if($order->getData('from_lengow') == 1) {
|
36 |
+
$marketplace = Mage::getModel('sync/marketplace');
|
37 |
+
$marketplace->set($order->getMarketplaceLengow());
|
38 |
+
if ($order->getState() == Mage::getSingleton('sync/config')->getOrderState('processing')) {
|
39 |
+
Mage::helper('sync')->log('WDSL : send tracking to ' . $order->getData('marketplace_lengow') . ' - ' . $order->getData('feed_id_lengow') . ' - ' . $order->getData('order_id_lengow'));
|
40 |
+
$marketplace->wsdl('shipped', $order->getData('feed_id_lengow'), $order, $shipment);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
return $this;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function salesOrderPaymentCancel(Varien_Event_Observer $observer) {
|
47 |
+
$payment = $observer->getEvent()->getPayment();
|
48 |
+
$order = $payment->getOrder();
|
49 |
+
if($order->getData('from_lengow') == 1) {
|
50 |
+
$marketplace = Mage::getModel('sync/marketplace');
|
51 |
+
$marketplace->set($order->getMarketplaceLengow());
|
52 |
+
if ($order->getState() == Mage::getSingleton('sync/config')->getOrderState('processing')) {
|
53 |
+
Mage::helper('sync')->log('WDSL : send cancel to ' . $order->getData('marketplace_lengow') . ' - ' . $order->getData('feed_id_lengow') . ' - ' . $order->getData('order_id_lengow'));
|
54 |
+
$marketplace->wsdl('refuse', $order->getData('feed_id_lengow'), $order);
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
public function salesOrderSaveCommitAfter(Varien_Event_Observer $observer) {
|
60 |
+
$order = $observer->getEvent();
|
61 |
+
if($order->getData('from_lengow') == 1) {
|
62 |
+
$marketplace = Mage::getModel('sync/marketplace');
|
63 |
+
$marketplace->set($order->getMarketplaceLengow());
|
64 |
+
if ($order->getState() == self::STATE_COMPLETE && $order->getState() == Mage::getSingleton('sync/config')->getOrderState('processing')) {
|
65 |
+
Mage::helper('sync')->log('WDSL : send cancel to ' . $order->getData('marketplace_lengow') . ' - ' . $order->getData('feed_id_lengow') . ' - ' . $order->getData('order_id_lengow'));
|
66 |
+
$marketplace->wsdl('shipped', $order->getData('feed_id_lengow'), $order);
|
67 |
+
}
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
}
|
app/code/community/Lengow/Sync/Model/Order.php
ADDED
@@ -0,0 +1,374 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow sync model order
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Model_Order extends Mage_Sales_Model_Order {
|
12 |
+
|
13 |
+
protected $_countryCollection;
|
14 |
+
protected $_config;
|
15 |
+
|
16 |
+
protected $_canInvoice = false;
|
17 |
+
protected $_canShip = false;
|
18 |
+
protected $_canCancel = false;
|
19 |
+
protected $_canRefund = false;
|
20 |
+
|
21 |
+
protected $_hasInvoices = false;
|
22 |
+
protected $_hasShipments = false;
|
23 |
+
protected $_isCanceled = false;
|
24 |
+
protected $_isRefunded = false;
|
25 |
+
|
26 |
+
public function isAlreadyImported($id_lengow, $id_flux) {
|
27 |
+
$order = Mage::getModel('sales/order')->getCollection()
|
28 |
+
->addAttributeToFilter('order_id_lengow', $id_lengow)
|
29 |
+
->addAttributeToSelect('order_id_lengow');
|
30 |
+
if(count($order) > 0)
|
31 |
+
return true;
|
32 |
+
else
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getOrderByIdLengow($id_lengow, $id_flux) {
|
37 |
+
$order = Mage::getModel('sales/order')->getCollection()
|
38 |
+
->addAttributeToFilter('order_id_lengow', $id_lengow)
|
39 |
+
->addAttributeToSelect('entity_id')
|
40 |
+
->getData();
|
41 |
+
if(count($order))
|
42 |
+
return Mage::getModel('sync/order')->load($order[0]);
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Retrieve config singleton
|
47 |
+
*
|
48 |
+
* @return Lengow_Sync_Model_Config
|
49 |
+
*/
|
50 |
+
public function getConfig() {
|
51 |
+
if(is_null($this->_config)) {
|
52 |
+
$this->_config = Mage::getSingleton('sync/config');
|
53 |
+
}
|
54 |
+
return $this->_config;
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Create quote
|
59 |
+
*
|
60 |
+
* @param Varien_Object $lengowItem
|
61 |
+
*/
|
62 |
+
public function createQuote(SimpleXMLelement $data, Lengow_Sync_Model_Customer_Customer $customer) {
|
63 |
+
$quote = new Mage_Sales_Model_Quote();
|
64 |
+
$quote->setIsMultiShipping(false)
|
65 |
+
//->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_GUEST)
|
66 |
+
->setCustomerId($customer->getId())
|
67 |
+
->setCustomerEmail($customer->getEmail())
|
68 |
+
->setCustomerIsGuest(false)
|
69 |
+
//->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID)
|
70 |
+
->setStore(Mage::app()->getDefaultStoreView());
|
71 |
+
// Add products to quote with data from Lengow
|
72 |
+
foreach($data->cart->products->product as $lengow_product) {
|
73 |
+
if(!$quote = $this->addItemToQuote($lengow_product, $quote, (string) $data->order_id)) {
|
74 |
+
return false;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
// Set billing Address
|
78 |
+
$billing_address = $quote->getBillingAddress();
|
79 |
+
$billing_address->setShouldIgnoreValidation(true);
|
80 |
+
$customer_billing_address = Mage::getModel('customer/address')->load($customer->getDefaultBilling());
|
81 |
+
$billing_address->importCustomerAddress($customer_billing_address)->setSaveInAddressBook(0);
|
82 |
+
// Set shipping Address
|
83 |
+
$shipping_address = $quote->getShippingAddress();
|
84 |
+
$shipping_address->setShouldIgnoreValidation(true);
|
85 |
+
$customerAddressShipping = Mage::getModel('customer/address')->load($customer->getDefaultShipping());
|
86 |
+
$shipping_address->importCustomerAddress($customerAddressShipping)->setSaveInAddressBook(0);
|
87 |
+
$shipping_address->setSameAsBilling(0);
|
88 |
+
// Create Shipment
|
89 |
+
$shipping_cost = (float) $data->order_processing_fee + (float) $data->order_shipping;
|
90 |
+
if(!Mage::getSingleton('tax/config')->shippingPriceIncludesTax($quote->getStore())) {
|
91 |
+
$pseudo_product = new Varien_Object();
|
92 |
+
$pseudo_product->setTaxClassId(Mage::getSingleton('tax/config')->getShippingTaxClass($quote->getStore()));
|
93 |
+
$shipping_cost = Mage::helper('tax')->getPrice(
|
94 |
+
$pseudo_product,
|
95 |
+
$shipping_cost,
|
96 |
+
false,
|
97 |
+
$shipping_address,
|
98 |
+
$billing_address,
|
99 |
+
null,
|
100 |
+
$quote->getStore(),
|
101 |
+
true
|
102 |
+
);
|
103 |
+
}
|
104 |
+
Mage::getSingleton('checkout/session')
|
105 |
+
->setShippingPrice($shipping_cost)
|
106 |
+
->setIsFromlengow(true);
|
107 |
+
$quote->getShippingAddress()
|
108 |
+
->setShippingMethod('lengow_lengow')
|
109 |
+
->setCollectShippingRates(true)
|
110 |
+
->collectShippingRates();
|
111 |
+
// Create Payment
|
112 |
+
$quote->getShippingAddress()
|
113 |
+
->setPaymentMethod('lengow');
|
114 |
+
$payment = $quote->getPayment();
|
115 |
+
$payment->importData(array('method' => 'lengow' ,
|
116 |
+
'marketplace' => (string) $data->marketplace . ' - ' . (string) $data->order_payment->payment_type ));
|
117 |
+
// Create quote
|
118 |
+
$quote->collectTotals();
|
119 |
+
$quote->save();
|
120 |
+
return $quote;
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Add item to quote
|
125 |
+
*
|
126 |
+
* @param Varien_Object $lengowItem
|
127 |
+
* @param Mage_Sales_Mode_Quote
|
128 |
+
* @return Mage_Sales_Mode_Quote
|
129 |
+
*/
|
130 |
+
public function addItemToQuote(SimpleXMLelement $lengow_product, Mage_Sales_Model_Quote $quote, $order_id) {
|
131 |
+
// TODO add while
|
132 |
+
$quote->setIsSuperMode(true);
|
133 |
+
$product_model = Mage::getModel('catalog/product');
|
134 |
+
$sku = (string) $lengow_product->sku;
|
135 |
+
$sku = str_replace('\_', '_', $sku);
|
136 |
+
$product = $product_model->load($product_model->getIdBySku($sku));
|
137 |
+
if(!$product->getId()) {
|
138 |
+
$sku = (string) $lengow_product->idMP;
|
139 |
+
$sku = str_replace('\_', '_', $sku);
|
140 |
+
$product = $product_model->load($product_model->getIdBySku($sku));
|
141 |
+
if(!$product->getId()) {
|
142 |
+
$sku = (string) $lengow_product->idLengow;
|
143 |
+
$sku = str_replace('\_', '_', $sku);
|
144 |
+
$product = $product_model->load($product_model->getIdBySku($sku));
|
145 |
+
if(!$product->getId()) {
|
146 |
+
$sku = (string) $lengow_product->sku;
|
147 |
+
$sku = str_replace('\_', '_', $sku);
|
148 |
+
$product = $product_model->load($sku);
|
149 |
+
if(!$product->getId()) {
|
150 |
+
$sku = (string) $lengow_product->idMP;
|
151 |
+
$sku = str_replace('\_', '_', $sku);
|
152 |
+
$product = $product_model->load($sku);
|
153 |
+
if(!$product->getId()) {
|
154 |
+
$sku = (string) $lengow_product->idLengow;
|
155 |
+
$sku = str_replace('\_', '_', $sku);
|
156 |
+
$product = $product_model->load($sku);
|
157 |
+
if(!$product->getId()) {
|
158 |
+
Mage::helper('sync')->log('Order ' . $order_id . ' : Product ' . (string) $lengow_product->sku . ' doesn\'t exist');
|
159 |
+
return false;
|
160 |
+
}
|
161 |
+
}
|
162 |
+
}
|
163 |
+
}
|
164 |
+
}
|
165 |
+
}
|
166 |
+
$quote_item = Mage::getModel('sync/quote_item');
|
167 |
+
$quote_item
|
168 |
+
->setProduct($product)
|
169 |
+
->setPrice((float) $lengow_product->price_unit)
|
170 |
+
->setCustomPrice((float) $lengow_product->price_unit)
|
171 |
+
->setOriginalCustomPrice((float) $lengow_product->price_unit)
|
172 |
+
->setQuote($quote)
|
173 |
+
->setQty((integer) $lengow_product->quantity)
|
174 |
+
->initPrice((float) $lengow_product->price_unit);
|
175 |
+
/*if($lengow_product->ecotax > 0) {
|
176 |
+
$quote_item->setWeeeTaxApplied($lengow_product->ecotax)
|
177 |
+
->WeeeTaxAppliedAmount($lengow_product->ecotax)
|
178 |
+
->WeeeTaxAppliedRowAmount($lengow_product->ecotax)
|
179 |
+
->BaseWeeeTaxAppliedAmount($lengow_product->ecotax)
|
180 |
+
->BaseWeeeTaxAppliedRowAmnt($lengow_product->ecotax);
|
181 |
+
}*/
|
182 |
+
$title_from_lengow = $this->getConfig()->setStore($quote->getStore()->getStoreId())->get('orders/title');
|
183 |
+
if($title_from_lengow)
|
184 |
+
$quote_item->setName((string) $lengow_product->title);
|
185 |
+
$quote->addItem($quote_item);
|
186 |
+
return $quote;
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Create order
|
191 |
+
*
|
192 |
+
* @param Mage_Sales_Model_Quote
|
193 |
+
* @return Mage_Sales_Model_Order
|
194 |
+
*/
|
195 |
+
public function makeOrder(SimpleXMLelement $data, Mage_Sales_Model_Quote $quote) {
|
196 |
+
try {
|
197 |
+
$order = false;
|
198 |
+
$store = $quote->getStore();
|
199 |
+
$grand_total = 0;
|
200 |
+
if (!Mage::helper('tax')->priceIncludesTax($store)) {
|
201 |
+
$grand_total = $quote->getGrandTotal();
|
202 |
+
}
|
203 |
+
$quote->setGrandTotal((float) $data->order_amount);
|
204 |
+
$quote->setBaseGrandTotal((float) $data->order_amount);
|
205 |
+
$additional_data = array('from_lengow' => true ,
|
206 |
+
'marketplace_lengow' => (string) $data->marketplace ,
|
207 |
+
'fees_lengow' => (float) $data->order_commission ,
|
208 |
+
'order_id_lengow' => (string) $data->order_id ,
|
209 |
+
'feed_id_lengow' => (integer) $data->idFlux ,
|
210 |
+
'xml_node_lengow' => Mage::helper('Core')->jsonEncode($data) ,
|
211 |
+
'message_lengow' => (string) $data->order_comments ,
|
212 |
+
'total_paid_lengow' => (float) $data->order_amount ,
|
213 |
+
'carrier_lengow' => (string) $data->tracking_informations->tracking_carrier ,
|
214 |
+
'carrier_method_lengow' => (string) $data->tracking_informations->tracking_method ,
|
215 |
+
);
|
216 |
+
$service = Mage::getModel('sales/service_quote', $quote);
|
217 |
+
$service->setOrderData($additional_data);
|
218 |
+
$order = false;
|
219 |
+
if(method_exists($service, 'submitAll')) {
|
220 |
+
$service->submitAll();
|
221 |
+
$order = $service->getOrder();
|
222 |
+
} else {
|
223 |
+
$order = $service->submit();
|
224 |
+
}
|
225 |
+
$order->setIsFromLengow(true)
|
226 |
+
->save();
|
227 |
+
// Re-ajuste cents
|
228 |
+
// Conversion Tax Include > Tax Exclude > Tax Include maybe make 0.01 amount error
|
229 |
+
if (!Mage::helper('tax')->priceIncludesTax($store)) {
|
230 |
+
|
231 |
+
if($order->getBaseShippingInclTax() != (float) $data->order_shipping) {
|
232 |
+
$order->setBaseShippingInclTax((float) $data->order_shipping);
|
233 |
+
}
|
234 |
+
if($grand_total != (float) $data->order_amount) {
|
235 |
+
$order->setGrandTotal((float) $data->order_amount);
|
236 |
+
$order->setBaseGrandTotal((float) $data->order_amount);
|
237 |
+
$diff = (((float) $data->order_amount) - $grand_total);
|
238 |
+
$order->setTaxAmount($order->getTaxAmount() + $diff);
|
239 |
+
}
|
240 |
+
$order->save();
|
241 |
+
}
|
242 |
+
$order = $this->toInvoice($order);
|
243 |
+
} catch (Exception $e){
|
244 |
+
Mage::helper('sync')->log('Error create order : ' . $e->getMessage());
|
245 |
+
}
|
246 |
+
return $order;
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* Create invoice
|
251 |
+
*
|
252 |
+
* @param Mage_Sales_Model_Order
|
253 |
+
* @return Lengow_Sync_Model_Order
|
254 |
+
*/
|
255 |
+
public function toInvoice(Mage_Sales_Model_Order $order) {
|
256 |
+
if($order->canInvoice()) {
|
257 |
+
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
258 |
+
if($invoice) {
|
259 |
+
$invoice->register();
|
260 |
+
$invoice->getOrder()->setIsInProcess(true);
|
261 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
262 |
+
->addObject($invoice)
|
263 |
+
->addObject($invoice->getOrder());
|
264 |
+
$transactionSave->save();
|
265 |
+
$this->_hasInvoices = true;
|
266 |
+
}
|
267 |
+
}
|
268 |
+
return $order;
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Ship order
|
273 |
+
*
|
274 |
+
* @param Mage_Sales_Model_Order
|
275 |
+
* @return Lengow_Sync_Model_Order
|
276 |
+
*/
|
277 |
+
public function toShip($order, $carrier = null, $title = '', $tracking = '') {
|
278 |
+
if($this->_canShip && $order->canShip()) {
|
279 |
+
$shipment = Mage::getModel('sales/service_order', $order)->prepareShipment();
|
280 |
+
if($shipment) {
|
281 |
+
$shipment->register();
|
282 |
+
$shipment->getOrder()->setIsInProcess(true);
|
283 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
284 |
+
->addObject($shipment)
|
285 |
+
->addObject($shipment->getOrder());
|
286 |
+
$transactionSave->save();
|
287 |
+
$this->_hasShipments = true;
|
288 |
+
// Add tracking information
|
289 |
+
if($tracking)
|
290 |
+
$ship = Mage::getModel('sales/order_shipment_api')
|
291 |
+
->addTrack($shipment->getIncrementId() ,
|
292 |
+
$carrier ,
|
293 |
+
$title ,
|
294 |
+
$tracking);
|
295 |
+
}
|
296 |
+
}
|
297 |
+
return $this;
|
298 |
+
}
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Cancel order
|
302 |
+
*
|
303 |
+
* @param Mage_Sales_Model_Order
|
304 |
+
* @return Lengow_Sync_Model_Order
|
305 |
+
*/
|
306 |
+
public function toCancel(Lengow_Sync_Model_Order $order) {
|
307 |
+
if($this->_canCancel) {
|
308 |
+
$order->cancel();
|
309 |
+
$this->_isCanceled = true;
|
310 |
+
}
|
311 |
+
|
312 |
+
return $this;
|
313 |
+
}
|
314 |
+
|
315 |
+
/**
|
316 |
+
* Refund order
|
317 |
+
*
|
318 |
+
* @param Mage_Sales_Model_Order
|
319 |
+
* @return Lengow_Sync_Model_Order
|
320 |
+
*/
|
321 |
+
public function toRefund(Lengow_Sync_Model_Order $order) {
|
322 |
+
if($this->_canRefund && $order->canCreditmemo()) {
|
323 |
+
$invoice_id = $order->getInvoiceCollection()->getFirstItem()->getId();
|
324 |
+
if(!$invoice_id) {
|
325 |
+
return $this;
|
326 |
+
}
|
327 |
+
$invoice = Mage::getModel('sales/order_invoice')->load($invoice_id)->setOrder($order);
|
328 |
+
$service = Mage::getModel('sales/service_order', $order);
|
329 |
+
$creditmemo = $service->prepareInvoiceCreditmemo($invoice);
|
330 |
+
$backToStock = array();
|
331 |
+
foreach($order->getAllItems() as $item) {
|
332 |
+
$backToStock[$item->getId()] = true;
|
333 |
+
}
|
334 |
+
// Process back to stock flags
|
335 |
+
foreach ($creditmemo->getAllItems() as $creditmemoItem) {
|
336 |
+
$orderItem = $creditmemoItem->getOrderItem();
|
337 |
+
$parentId = $orderItem->getParentItemId();
|
338 |
+
if (Mage::helper('cataloginventory')->isAutoReturnEnabled()) {
|
339 |
+
$creditmemoItem->setBackToStock(true);
|
340 |
+
} else {
|
341 |
+
$creditmemoItem->setBackToStock(false);
|
342 |
+
}
|
343 |
+
}
|
344 |
+
$creditmemo->register();
|
345 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
346 |
+
->addObject($creditmemo)
|
347 |
+
->addObject($creditmemo->getOrder());
|
348 |
+
if ($creditmemo->getInvoice()) {
|
349 |
+
$transactionSave->addObject($creditmemo->getInvoice());
|
350 |
+
}
|
351 |
+
$transactionSave->save();
|
352 |
+
$this->_isRefunded = true;
|
353 |
+
}
|
354 |
+
return $this;
|
355 |
+
}
|
356 |
+
|
357 |
+
/**
|
358 |
+
* Retrieve country id based on country name
|
359 |
+
*
|
360 |
+
* @param string $country_name
|
361 |
+
* @return string
|
362 |
+
*/
|
363 |
+
protected function _getCountryId($country_name) {
|
364 |
+
if(is_null($this->_countryCollection)) {
|
365 |
+
$this->_countryCollection = Mage::getResourceModel('directory/country_collection')->toOptionArray();
|
366 |
+
}
|
367 |
+
foreach($this->_countryCollection as $country) {
|
368 |
+
if(strtolower($country['label']) == strtolower($country_name)) {
|
369 |
+
return $country['value'];
|
370 |
+
}
|
371 |
+
}
|
372 |
+
return $country_name;
|
373 |
+
}
|
374 |
+
}
|
app/code/community/Lengow/Sync/Model/Payment/.DS_Store
ADDED
Binary file
|
app/code/community/Lengow/Sync/Model/Payment/Method/Lengow.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow adminhtml export controller
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Model_Payment_Method_Lengow extends Mage_Payment_Model_Method_Abstract {
|
12 |
+
|
13 |
+
protected $_code = 'lengow';
|
14 |
+
protected $_infoBlockType = 'sync/payment_info_purchaseorder';
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Assign data to info model instance
|
18 |
+
*
|
19 |
+
* @param mixed $data
|
20 |
+
* @return Profileolabs_Lengow_Model_Manageorders_Payment_Method_Purchaseorder
|
21 |
+
*/
|
22 |
+
public function assignData($data) {
|
23 |
+
if (!($data instanceof Varien_Object)) {
|
24 |
+
$data = new Varien_Object($data);
|
25 |
+
}
|
26 |
+
$this->getInfoInstance()->setAdditionalData($data->getMarketplace());
|
27 |
+
return $this;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Check whether payment method can be used
|
32 |
+
* @param Mage_Sales_Model_Quote
|
33 |
+
* @return bool
|
34 |
+
*/
|
35 |
+
public function isAvailable($quote = null) {
|
36 |
+
if(Mage::getSingleton('checkout/session')->getIsFromlengow())
|
37 |
+
return true;
|
38 |
+
return false;
|
39 |
+
}
|
40 |
+
}
|
app/code/community/Lengow/Sync/Model/Quote/Item.php
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow sync model order
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Model_Quote_Item extends Mage_Sales_Model_Quote_Item {
|
12 |
+
|
13 |
+
public function initPrice($value) {
|
14 |
+
$store = $this->getQuote()->getStore();
|
15 |
+
if (!Mage::helper('tax')->priceIncludesTax($store)) {
|
16 |
+
$bAddress = $this->getQuote()->getBillingAddress();
|
17 |
+
$sAddress = $this->getQuote()->getShippingAddress();
|
18 |
+
$address = $this->getAddress();
|
19 |
+
if ($address) {
|
20 |
+
switch ($address->getAddressType()) {
|
21 |
+
case Mage_Sales_Model_Quote_Address::TYPE_BILLING:
|
22 |
+
$bAddress = $address;
|
23 |
+
break;
|
24 |
+
case Mage_Sales_Model_Quote_Address::TYPE_SHIPPING:
|
25 |
+
$sAddress = $address;
|
26 |
+
break;
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
if ($this->getProduct()->getIsVirtual()) {
|
31 |
+
$sAddress = $bAddress;
|
32 |
+
}
|
33 |
+
|
34 |
+
$priceExcludingTax = Mage::helper('tax')->getPrice(
|
35 |
+
$this->getProduct()->setTaxPercent(null),
|
36 |
+
$value,
|
37 |
+
false,
|
38 |
+
$sAddress,
|
39 |
+
$bAddress,
|
40 |
+
$this->getQuote()->getCustomerTaxClassId(),
|
41 |
+
$store,
|
42 |
+
true
|
43 |
+
);
|
44 |
+
$this->setCustomPrice($priceExcludingTax);
|
45 |
+
$this->setOriginalCustomPrice($priceExcludingTax);
|
46 |
+
$this->setOriginalPrice($priceExcludingTax);
|
47 |
+
|
48 |
+
$priceIncludingTax = Mage::helper('tax')->getPrice(
|
49 |
+
$this->getProduct()->setTaxPercent(null),
|
50 |
+
$value,
|
51 |
+
true,
|
52 |
+
$sAddress,
|
53 |
+
$bAddress,
|
54 |
+
$this->getQuote()->getCustomerTaxClassId(),
|
55 |
+
$store,
|
56 |
+
true
|
57 |
+
);
|
58 |
+
|
59 |
+
$qty = $this->getQty();
|
60 |
+
if ($this->getParentItem()) {
|
61 |
+
$qty = $qty*$this->getParentItem()->getQty();
|
62 |
+
}
|
63 |
+
|
64 |
+
if (Mage::helper('tax')->displayCartPriceInclTax($store)) {
|
65 |
+
$rowTotal = $value*$qty;
|
66 |
+
$rowTotalExcTax = Mage::helper('tax')->getPrice(
|
67 |
+
$this->getProduct()->setTaxPercent(null),
|
68 |
+
$rowTotal,
|
69 |
+
false,
|
70 |
+
$sAddress,
|
71 |
+
$bAddress,
|
72 |
+
$this->getQuote()->getCustomerTaxClassId(),
|
73 |
+
$store,
|
74 |
+
true
|
75 |
+
);
|
76 |
+
$rowTotalIncTax = Mage::helper('tax')->getPrice(
|
77 |
+
$this->getProduct()->setTaxPercent(null),
|
78 |
+
$rowTotal,
|
79 |
+
true,
|
80 |
+
$sAddress,
|
81 |
+
$bAddress,
|
82 |
+
$this->getQuote()->getCustomerTaxClassId(),
|
83 |
+
$store,
|
84 |
+
true
|
85 |
+
);
|
86 |
+
$totalBaseTax = $rowTotalIncTax-$rowTotalExcTax;
|
87 |
+
$this->setBaseRowTotal($rowTotal);
|
88 |
+
$this->setBaseRowTotalInclTax($rowTotal);
|
89 |
+
}
|
90 |
+
else {
|
91 |
+
$taxAmount = $priceIncludingTax - $priceExcludingTax;
|
92 |
+
$this->setTaxPercent($this->getProduct()->getTaxPercent());
|
93 |
+
$totalBaseTax = $taxAmount*$qty;
|
94 |
+
}
|
95 |
+
|
96 |
+
$totalTax = $this->getStore()->convertPrice($totalBaseTax);
|
97 |
+
$this->setTaxBeforeDiscount($totalTax);
|
98 |
+
$this->setBaseTaxBeforeDiscount($totalBaseTax);
|
99 |
+
|
100 |
+
$this->setTaxAmount($totalTax);
|
101 |
+
$this->setBaseTaxAmount($totalBaseTax);
|
102 |
+
$this->setBaseOriginalPrice($priceExcludingTax);
|
103 |
+
$this->setTaxAmount($totalTax);
|
104 |
+
$this->setPrice($priceExcludingTax);
|
105 |
+
return $this;
|
106 |
+
} else {
|
107 |
+
return $this;
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
}
|
app/code/community/Lengow/Sync/Model/Shipping/Carrier/Lengow.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow sync model shipping carrier lengow
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Model_Shipping_Carrier_Lengow extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface {
|
12 |
+
|
13 |
+
protected $_code = 'lengow';
|
14 |
+
protected $_isFixed = true;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* FreeShipping Rates Collector
|
18 |
+
*
|
19 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
20 |
+
* @return Mage_Shipping_Model_Rate_Result
|
21 |
+
*/
|
22 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
|
23 |
+
if (!$this->isActive()) {
|
24 |
+
return false;
|
25 |
+
}
|
26 |
+
$result = Mage::getModel('shipping/rate_result');
|
27 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
28 |
+
$method->setCarrier('lengow');
|
29 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
30 |
+
$method->setMethod('lengow');
|
31 |
+
$method->setMethodTitle($this->getConfigData('name'));
|
32 |
+
$method->setPrice($this->getSession()->getShippingPrice());
|
33 |
+
$method->setCost($this->getSession()->getShippingPrice());
|
34 |
+
$result->append($method);
|
35 |
+
return $result;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Processing additional validation to check is carrier applicable.
|
40 |
+
*
|
41 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
42 |
+
* @return Mage_Shipping_Model_Carrier_Abstract|Mage_Shipping_Model_Rate_Result_Error|boolean
|
43 |
+
*/
|
44 |
+
public function proccessAdditionalValidation(Mage_Shipping_Model_Rate_Request $request) {
|
45 |
+
if(Mage::getVersion() == '1.4.1.0')
|
46 |
+
return $this->isActive();
|
47 |
+
return parent::proccessAdditionalValidation($request);
|
48 |
+
}
|
49 |
+
|
50 |
+
public function getSession() {
|
51 |
+
return Mage::getSingleton('checkout/session');
|
52 |
+
}
|
53 |
+
|
54 |
+
public function isActive() {
|
55 |
+
if($this->getSession()->getIsFromlengow())
|
56 |
+
return true;
|
57 |
+
return false;
|
58 |
+
}
|
59 |
+
|
60 |
+
public function getAllowedMethods() {
|
61 |
+
return array('lengow' => $this->getConfigData('name'));
|
62 |
+
}
|
63 |
+
|
64 |
+
}
|
app/code/community/Lengow/Sync/controllers/.DS_Store
ADDED
Binary file
|
app/code/community/Lengow/Sync/controllers/Adminhtml/.DS_Store
ADDED
Binary file
|
app/code/community/Lengow/Sync/controllers/Adminhtml/Lengow/LogController.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow adminhtml log controller
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Adminhtml_Lengow_LogController extends Mage_Adminhtml_Controller_Action {
|
12 |
+
|
13 |
+
protected function _initAction() {
|
14 |
+
$this->loadLayout()
|
15 |
+
->_setActiveMenu('lengow/log')
|
16 |
+
->_addBreadcrumb(Mage::helper('sync')->__('Lengow orders'), Mage::helper('sync')->__('Lengow orders'));
|
17 |
+
return $this;
|
18 |
+
}
|
19 |
+
|
20 |
+
public function indexAction() {
|
21 |
+
$this->_initAction()
|
22 |
+
->renderLayout();
|
23 |
+
return $this;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function deleteAction() {
|
27 |
+
$collection = Mage::getModel('sync/log')->getCollection();
|
28 |
+
foreach($collection as $log)
|
29 |
+
$log->delete();
|
30 |
+
$this->_getSession()->addSuccess(Mage::helper('Lengow_Order')->__('Log is empty'));
|
31 |
+
$this->_redirect('*/*/index');
|
32 |
+
|
33 |
+
}
|
34 |
+
|
35 |
+
public function gridAction() {
|
36 |
+
$this->getResponse()->setBody($this->getLayout()->createBlock('sync/adminhtml_log_grid')->toHtml());
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
|
40 |
+
}
|
app/code/community/Lengow/Sync/controllers/Adminhtml/Lengow/OrderController.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow adminhtml sync order controller
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_Adminhtml_Lengow_OrderController extends Mage_Adminhtml_Controller_Action {
|
12 |
+
|
13 |
+
protected function _initAction() {
|
14 |
+
$this->loadLayout()
|
15 |
+
->_setActiveMenu('lengow/order')
|
16 |
+
->_addBreadcrumb(Mage::helper('sync')->__('Lengow manage orders'), Mage::helper('sync')->__('Lengow orders'));
|
17 |
+
return $this;
|
18 |
+
}
|
19 |
+
|
20 |
+
|
21 |
+
public function indexAction() {
|
22 |
+
$this->_initAction()
|
23 |
+
->renderLayout();
|
24 |
+
return $this;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function gridAction() {
|
28 |
+
$this->getResponse()->setBody(
|
29 |
+
$this->getLayout()->createBlock('sync/adminhtml_order_grid')->toHtml()
|
30 |
+
);
|
31 |
+
return $this;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Export order grid to CSV format
|
36 |
+
*/
|
37 |
+
public function exportCsvAction() {
|
38 |
+
$filename = 'orders_lengow.csv';
|
39 |
+
$grid = $this->getLayout()->createBlock('sync/adminhtml_order_grid');
|
40 |
+
$this->_prepareDownloadResponse($filename, $grid->getCsvFile());
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Export order grid to Excel XML format
|
45 |
+
*/
|
46 |
+
public function exportExcelAction() {
|
47 |
+
$filename = 'orders_lengow.xml';
|
48 |
+
$grid = $this->getLayout()->createBlock('sync/adminhtml_order_grid');
|
49 |
+
$this->_prepareDownloadResponse($filename, $grid->getExcelFile($filename));
|
50 |
+
}
|
51 |
+
|
52 |
+
public function importAction() {
|
53 |
+
try {
|
54 |
+
$days = Mage::getModel('sync/config')->setStore(Mage::app()->getStore()->getId())
|
55 |
+
->getConfig('sync/orders/period');
|
56 |
+
$date_from = date('Y-m-d', strtotime(date('Y-m-d') . '-' . $days . 'days'));
|
57 |
+
$date_to = date('Y-m-d');
|
58 |
+
$import = Mage::getModel('sync/import');
|
59 |
+
$result = $import->exec('orders', array('dateFrom' => $date_from,
|
60 |
+
'dateTo' => $date_to));
|
61 |
+
if($result['new'] > 0)
|
62 |
+
$this->_getSession()->addSuccess(Mage::helper('sync')->__('%d orders are imported', $result['new']));
|
63 |
+
if($result['update'] > 0)
|
64 |
+
$this->_getSession()->addSuccess(Mage::helper('sync')->__('%d orders are updated', $result['update']));
|
65 |
+
if($result['new'] == 0 && $result['update'] == 0)
|
66 |
+
$this->_getSession()->addSuccess(Mage::helper('sync')->__('No order available to import'));
|
67 |
+
} catch(Exception $e) {
|
68 |
+
$this->_getSession()->addError($e->getMessage());
|
69 |
+
}
|
70 |
+
$this->_redirect("*/*/index");
|
71 |
+
}
|
72 |
+
|
73 |
+
}
|
app/code/community/Lengow/Sync/controllers/ApiController.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow export controller
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Export
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Sync_ApiController extends Mage_Core_Controller_Front_Action {
|
12 |
+
|
13 |
+
public function indexAction() {
|
14 |
+
echo 'Please specify an action';
|
15 |
+
}
|
16 |
+
|
17 |
+
public function taxAction() {
|
18 |
+
$helper = Mage::helper('export/security');
|
19 |
+
if($helper->checkIp()) {
|
20 |
+
$id_order = $this->getRequest()->getParam('id');
|
21 |
+
$new_tax = $this->getRequest()->getParam('rate');
|
22 |
+
if($order = Mage::getModel('sales/order')->load($id_order)) {
|
23 |
+
if($order->hasFromLengow()) {
|
24 |
+
$this->_rebuildOrder($order);
|
25 |
+
}
|
26 |
+
} else {
|
27 |
+
echo 'Order not find';
|
28 |
+
}
|
29 |
+
} else {
|
30 |
+
echo 'Unauthorised ip : ' . $_SERVER['REMOTE_ADDR'];
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
private function _rebuildOrder($order) {
|
35 |
+
print_r($order->debug());
|
36 |
+
// Caculate Items
|
37 |
+
$items = $order->getItems();
|
38 |
+
print_r($items);
|
39 |
+
// Calculate Order
|
40 |
+
/*$priceExcludingTax = Mage::helper('tax')->getPrice(
|
41 |
+
$this->getProduct()->setTaxPercent(null),
|
42 |
+
$value,
|
43 |
+
false,
|
44 |
+
$sAddress,
|
45 |
+
$bAddress,
|
46 |
+
$this->getQuote()->getCustomerTaxClassId(),
|
47 |
+
$store,
|
48 |
+
true
|
49 |
+
);*/
|
50 |
+
}
|
51 |
+
|
52 |
+
private function _rebuildInvoice($order) {
|
53 |
+
|
54 |
+
}
|
55 |
+
}
|
app/code/community/Lengow/Sync/etc/config.xml
ADDED
@@ -0,0 +1,269 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Lengow_Sync>
|
5 |
+
<version>2.0.1.0</version>
|
6 |
+
</Lengow_Sync>
|
7 |
+
</modules>
|
8 |
+
<admin>
|
9 |
+
<routers>
|
10 |
+
<sync>
|
11 |
+
<use>admin</use>
|
12 |
+
<args>
|
13 |
+
<module>Lengow_Sync</module>
|
14 |
+
<frontName>lengows</frontName>
|
15 |
+
</args>
|
16 |
+
</sync>
|
17 |
+
<adminhtml>
|
18 |
+
<args>
|
19 |
+
<modules>
|
20 |
+
<Lengow_Sync before="Mage_Adminhtml">Lengow_Sync_Adminhtml</Lengow_Sync>
|
21 |
+
</modules>
|
22 |
+
</args>
|
23 |
+
</adminhtml>
|
24 |
+
</routers>
|
25 |
+
</admin>
|
26 |
+
<global>
|
27 |
+
<models>
|
28 |
+
<sync>
|
29 |
+
<class>Lengow_Sync_Model</class>
|
30 |
+
<resourceModel>sync_mysql4</resourceModel>
|
31 |
+
</sync>
|
32 |
+
<sync_mysql4>
|
33 |
+
<class>Lengow_Sync_Model_Mysql4</class>
|
34 |
+
<entities>
|
35 |
+
<log>
|
36 |
+
<table>lengow_log</table>
|
37 |
+
</log>
|
38 |
+
</entities>
|
39 |
+
</sync_mysql4>
|
40 |
+
</models>
|
41 |
+
<resources>
|
42 |
+
<lengow_setup>
|
43 |
+
<setup>
|
44 |
+
<module>Lengow_Sync</module>
|
45 |
+
<class>Mage_Sales_Model_Mysql4_Setup</class>
|
46 |
+
</setup>
|
47 |
+
<connection>
|
48 |
+
<use>core_setup</use>
|
49 |
+
</connection>
|
50 |
+
</lengow_setup>
|
51 |
+
<sync_write>
|
52 |
+
<connection>
|
53 |
+
<use>core_write</use>
|
54 |
+
</connection>
|
55 |
+
</sync_write>
|
56 |
+
<sync_read>
|
57 |
+
<connection>
|
58 |
+
<use>core_read</use>
|
59 |
+
</connection>
|
60 |
+
</sync_read>
|
61 |
+
</resources>
|
62 |
+
<blocks>
|
63 |
+
<sync>
|
64 |
+
<class>Lengow_Sync_Block</class>
|
65 |
+
</sync>
|
66 |
+
</blocks>
|
67 |
+
<helpers>
|
68 |
+
<sync>
|
69 |
+
<class>Lengow_Sync_Helper</class>
|
70 |
+
</sync>
|
71 |
+
</helpers>
|
72 |
+
<events>
|
73 |
+
<sales_order_shipment_save_after>
|
74 |
+
<observers>
|
75 |
+
<lengow_shipment_save_after>
|
76 |
+
<class>Lengow_Sync_Model_Observer</class>
|
77 |
+
<method>salesOrderShipmentSaveAfter</method>
|
78 |
+
</lengow_shipment_save_after>
|
79 |
+
</observers>
|
80 |
+
</sales_order_shipment_save_after>
|
81 |
+
<sales_order_payment_cancel>
|
82 |
+
<observers>
|
83 |
+
<lengow_payment_cancel>
|
84 |
+
<class>Lengow_Sync_Model_Observer</class>
|
85 |
+
<method>salesOrderPaymentCancel</method>
|
86 |
+
</lengow_payment_cancel>
|
87 |
+
</observers>
|
88 |
+
</sales_order_payment_cancel>
|
89 |
+
<sales_order_save_commit_after>
|
90 |
+
<observers>
|
91 |
+
<lengow_order_save_commit_after>
|
92 |
+
<class>Lengow_Sync_Model_Observer</class>
|
93 |
+
<method>salesOrderSaveCommitAfter</method>
|
94 |
+
</lengow_order_save_commit_after>
|
95 |
+
</observers>
|
96 |
+
</sales_order_save_commit_after>
|
97 |
+
</events>
|
98 |
+
<fieldsets>
|
99 |
+
<lengow_convert_billing_address>
|
100 |
+
<billing_society>
|
101 |
+
<to_customer>company</to_customer>
|
102 |
+
<to_billing_address>company</to_billing_address>
|
103 |
+
</billing_society>
|
104 |
+
<billing_lastname>
|
105 |
+
<to_customer>lastname</to_customer>
|
106 |
+
<to_billing_address>lastname</to_billing_address>
|
107 |
+
</billing_lastname>
|
108 |
+
<billing_firstname>
|
109 |
+
<to_customer>firstname</to_customer>
|
110 |
+
<to_billing_address>firstname</to_billing_address>
|
111 |
+
</billing_firstname>
|
112 |
+
<billing_email>
|
113 |
+
<to_customer>email</to_customer>
|
114 |
+
<to_billing_address>email</to_billing_address>
|
115 |
+
</billing_email>
|
116 |
+
<billing_phone_home>
|
117 |
+
<to_billing_address>telephone</to_billing_address>
|
118 |
+
</billing_phone_home>
|
119 |
+
<billing_address>
|
120 |
+
<to_billing_address>street_full</to_billing_address>
|
121 |
+
</billing_address>
|
122 |
+
<billing_zipcode>
|
123 |
+
<to_billing_address>postcode</to_billing_address>
|
124 |
+
</billing_zipcode>
|
125 |
+
<billing_city>
|
126 |
+
<to_billing_address>city</to_billing_address>
|
127 |
+
</billing_city>
|
128 |
+
<billing_country_iso>
|
129 |
+
<to_billing_address>country_id</to_billing_address>
|
130 |
+
</billing_country_iso>
|
131 |
+
</lengow_convert_billing_address>
|
132 |
+
<lengow_convert_shipping_address>
|
133 |
+
<delivery_society>
|
134 |
+
<to_shipping_address>company</to_shipping_address>
|
135 |
+
</delivery_society>
|
136 |
+
<delivery_lastname>
|
137 |
+
<to_shipping_address>lastname</to_shipping_address>
|
138 |
+
</delivery_lastname>
|
139 |
+
<delivery_firstname>
|
140 |
+
<to_shipping_address>firstname</to_shipping_address>
|
141 |
+
</delivery_firstname>
|
142 |
+
<delivery_email>
|
143 |
+
<to_shipping_address>email</to_shipping_address>
|
144 |
+
</delivery_email>
|
145 |
+
<delivery_phone_home>
|
146 |
+
<to_shipping_address>telephone</to_shipping_address>
|
147 |
+
</delivery_phone_home>
|
148 |
+
<delivery_address>
|
149 |
+
<to_shipping_address>street_full</to_shipping_address>
|
150 |
+
</delivery_address>
|
151 |
+
<delivery_zipcode>
|
152 |
+
<to_shipping_address>postcode</to_shipping_address>
|
153 |
+
</delivery_zipcode>
|
154 |
+
<delivery_city>
|
155 |
+
<to_shipping_address>city</to_shipping_address>
|
156 |
+
</delivery_city>
|
157 |
+
<delivery_country_iso>
|
158 |
+
<to_shipping_address>country_id</to_shipping_address>
|
159 |
+
</delivery_country_iso>
|
160 |
+
</lengow_convert_shipping_address>
|
161 |
+
</fieldsets>
|
162 |
+
</global>
|
163 |
+
<adminhtml>
|
164 |
+
<translate>
|
165 |
+
<modules>
|
166 |
+
<Lengow_Sync>
|
167 |
+
<files>
|
168 |
+
<default>Lengow_Connector.csv</default>
|
169 |
+
</files>
|
170 |
+
</Lengow_Sync>
|
171 |
+
</modules>
|
172 |
+
</translate>
|
173 |
+
<menu>
|
174 |
+
<lengow>
|
175 |
+
<title>Lengow</title>
|
176 |
+
<sort_order>20</sort_order>
|
177 |
+
<children>
|
178 |
+
<sync translate="title" module="sync">
|
179 |
+
<title>Manage Orders</title>
|
180 |
+
<action>adminhtml/lengow_order</action>
|
181 |
+
<sort_order>200</sort_order>
|
182 |
+
</sync>
|
183 |
+
<log translate="title" module="sync">
|
184 |
+
<title>Logs</title>
|
185 |
+
<action>adminhtml/lengow_log</action>
|
186 |
+
<sort_order>400</sort_order>
|
187 |
+
</log>
|
188 |
+
</children>
|
189 |
+
</lengow>
|
190 |
+
</menu>
|
191 |
+
<acl>
|
192 |
+
<resources>
|
193 |
+
<admin>
|
194 |
+
<children>
|
195 |
+
<system>
|
196 |
+
<children>
|
197 |
+
<config>
|
198 |
+
<children>
|
199 |
+
<sync translate="title" module="sync">
|
200 |
+
<title>Manage orders</title>
|
201 |
+
</sync>
|
202 |
+
</children>
|
203 |
+
</config>
|
204 |
+
</children>
|
205 |
+
</system>
|
206 |
+
<lengow translate="title" module="sync">
|
207 |
+
<title>Lengow</title>
|
208 |
+
<sort_order>22</sort_order>
|
209 |
+
</lengow>
|
210 |
+
</children>
|
211 |
+
</admin>
|
212 |
+
</resources>
|
213 |
+
</acl>
|
214 |
+
</adminhtml>
|
215 |
+
<crontab>
|
216 |
+
<jobs>
|
217 |
+
<sync_orders_lengow>
|
218 |
+
<schedule>
|
219 |
+
<cron_expr>*/30 * * * *</cron_expr>
|
220 |
+
</schedule>
|
221 |
+
<run>
|
222 |
+
<model>sync/observer::import</model>
|
223 |
+
</run>
|
224 |
+
</sync_orders_lengow>
|
225 |
+
</jobs>
|
226 |
+
</crontab>
|
227 |
+
<default>
|
228 |
+
<tracker>
|
229 |
+
<general>
|
230 |
+
<api_key></api_key>
|
231 |
+
</general>
|
232 |
+
</tracker>
|
233 |
+
<sync>
|
234 |
+
<orders>
|
235 |
+
<period>3</period>
|
236 |
+
</orders>
|
237 |
+
<hidden>
|
238 |
+
<last_synchro>0000-00-00</last_synchro>
|
239 |
+
</hidden>
|
240 |
+
</sync>
|
241 |
+
<payment>
|
242 |
+
<lengow>
|
243 |
+
<active>1</active>
|
244 |
+
<model>sync/payment_method_lengow</model>
|
245 |
+
<order_status>pending</order_status>
|
246 |
+
<title>Lengow Payment</title>
|
247 |
+
<allowspecific>0</allowspecific>
|
248 |
+
<group>offline</group>
|
249 |
+
</lengow>
|
250 |
+
<lengow_purchaseorder>
|
251 |
+
<active>1</active>
|
252 |
+
<model>sync/payment_method_lengow</model>
|
253 |
+
<order_status>new</order_status>
|
254 |
+
<title>Lengow Payment (version 1.x)</title>
|
255 |
+
<allowspecific>0</allowspecific>
|
256 |
+
<group>offline</group>
|
257 |
+
</lengow_purchaseorder>
|
258 |
+
</payment>
|
259 |
+
<carriers>
|
260 |
+
<lengow translate="name title" module="sync">
|
261 |
+
<active>1</active>
|
262 |
+
<sallowspecific>0</sallowspecific>
|
263 |
+
<model>sync/shipping_carrier_lengow</model>
|
264 |
+
<name>Shipping from marketplace</name>
|
265 |
+
<title>Lengow</title>
|
266 |
+
</lengow>
|
267 |
+
</carriers>
|
268 |
+
</default>
|
269 |
+
</config>
|
app/code/community/Lengow/Sync/etc/marketplaces.xml
ADDED
@@ -0,0 +1,715 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2 |
+
<marketplaces created="2013-07-24 12:00:00">
|
3 |
+
<marketplace name="rueducommerce">
|
4 |
+
<api>https://wsdl.lengow.com/wsdl/rdc/#ID_FLUX#/#ORDER_ID#/#ACTION#.xml</api>
|
5 |
+
<states>
|
6 |
+
<state name="NEW">
|
7 |
+
<actions>
|
8 |
+
<action type="accept">acceptOrder</action>
|
9 |
+
<action type="refuse">refuseOrder</action>
|
10 |
+
<action type="restock">restockingOrder</action>
|
11 |
+
</actions>
|
12 |
+
<lengow>new</lengow>
|
13 |
+
</state>
|
14 |
+
<state name="processing">
|
15 |
+
<actions>
|
16 |
+
<action type="shipped">shippedOrder</action>
|
17 |
+
<action type="refuse">refuseOrder</action>
|
18 |
+
</actions>
|
19 |
+
<lengow>processing</lengow>
|
20 |
+
</state>
|
21 |
+
<state name="shipped">
|
22 |
+
<actions>
|
23 |
+
<action type="refuse">refuseOrder</action>
|
24 |
+
</actions>
|
25 |
+
<lengow>shipped</lengow>
|
26 |
+
</state>
|
27 |
+
<state name="cancelled">
|
28 |
+
<lengow>canceled</lengow>
|
29 |
+
</state>
|
30 |
+
<state name="restocking">
|
31 |
+
<lengow>canceled</lengow>
|
32 |
+
</state>
|
33 |
+
</states>
|
34 |
+
<additional_params>
|
35 |
+
<param usedby="shipped">
|
36 |
+
<type>tracking</type>
|
37 |
+
<name>TrackingColis</name>
|
38 |
+
</param>
|
39 |
+
<param usedby="refused">
|
40 |
+
<type>refused_reason</type>
|
41 |
+
<name>motifRefus</name>
|
42 |
+
<accepted_values>
|
43 |
+
<value>replacement</value>
|
44 |
+
<value>return</value>
|
45 |
+
<value>not_delivered</value>
|
46 |
+
<value>cancelled_by_customer</value>
|
47 |
+
<value>out_of_stock</value>
|
48 |
+
<value>address_not_exists</value>
|
49 |
+
<value>other</value>
|
50 |
+
</accepted_values>
|
51 |
+
</param>
|
52 |
+
</additional_params>
|
53 |
+
</marketplace>
|
54 |
+
<marketplace name="fnac">
|
55 |
+
<api>https://wsdl.lengow.com/wsdl/fnac/#ID_FLUX#/#ORDER_ID#/#ACTION#.xml</api>
|
56 |
+
<states>
|
57 |
+
<state name="Created">
|
58 |
+
<actions>
|
59 |
+
<action type="accept">acceptOrder</action>
|
60 |
+
<action type="refuse">refuseOrder</action>
|
61 |
+
</actions>
|
62 |
+
<lengow>new</lengow>
|
63 |
+
</state>
|
64 |
+
<state name="ToAccept">
|
65 |
+
<actions>
|
66 |
+
<action type="accept">acceptOrder</action>
|
67 |
+
<action type="refuse">refuseOrder</action>
|
68 |
+
</actions>
|
69 |
+
<lengow>new</lengow>
|
70 |
+
</state>
|
71 |
+
<state name="Accepted">
|
72 |
+
<lengow>new</lengow>
|
73 |
+
</state>
|
74 |
+
<state name="ToShip">
|
75 |
+
<actions>
|
76 |
+
<action type="shipped">Shipped</action>
|
77 |
+
<action type="refuse">refuseOrder</action>
|
78 |
+
</actions>
|
79 |
+
<lengow>processing</lengow>
|
80 |
+
</state>
|
81 |
+
<state name="Refunded">
|
82 |
+
<lengow>canceled</lengow>
|
83 |
+
</state>
|
84 |
+
<state name="NotReceived">
|
85 |
+
<lengow>shipped</lengow>
|
86 |
+
</state>
|
87 |
+
<state name="Shipped">
|
88 |
+
<lengow>shipped</lengow>
|
89 |
+
</state>
|
90 |
+
<state name="Received">
|
91 |
+
<lengow>shipped</lengow>
|
92 |
+
</state>
|
93 |
+
<state name="Cancelled">
|
94 |
+
<lengow>canceled</lengow>
|
95 |
+
</state>
|
96 |
+
<state name="Refused">
|
97 |
+
<lengow>canceled</lengow>
|
98 |
+
</state>
|
99 |
+
</states>
|
100 |
+
<additional_params>
|
101 |
+
<param usedby="shipped">
|
102 |
+
<type>tracking</type>
|
103 |
+
<name>trackingColis</name>
|
104 |
+
</param>
|
105 |
+
<param usedby="shipped">
|
106 |
+
<type>carrier</type>
|
107 |
+
<name>transporteurColis</name>
|
108 |
+
</param>
|
109 |
+
</additional_params>
|
110 |
+
</marketplace>
|
111 |
+
<marketplace name="priceminister">
|
112 |
+
<api>https://wsdl.lengow.com/wsdl/priceminister/#ID_FLUX#/#ORDER_ID#/#ACTION#.xml</api>
|
113 |
+
<states>
|
114 |
+
<state name="New">
|
115 |
+
<actions>
|
116 |
+
<action type="accept">accept</action>
|
117 |
+
<action type="shipped">acceptOrder</action>
|
118 |
+
<action type="refuse">refuseOrder</action>
|
119 |
+
</actions>
|
120 |
+
<lengow>new</lengow>
|
121 |
+
</state>
|
122 |
+
<state name="Accept">
|
123 |
+
<lengow>processing</lengow>
|
124 |
+
</state>
|
125 |
+
<state name="acceptsale">
|
126 |
+
<lengow>processing</lengow>
|
127 |
+
</state>
|
128 |
+
<state name="Shipped">
|
129 |
+
<lengow>shipped</lengow>
|
130 |
+
</state>
|
131 |
+
<state name="refusesale">
|
132 |
+
<lengow>canceled</lengow>
|
133 |
+
</state>
|
134 |
+
<state name="CLOSED">
|
135 |
+
<lengow>shipped</lengow>
|
136 |
+
</state>
|
137 |
+
</states>
|
138 |
+
<additional_params>
|
139 |
+
<param usedby="shipped">
|
140 |
+
<type>tracking</type>
|
141 |
+
<name>TrackingColis</name>
|
142 |
+
</param>
|
143 |
+
<param usedby="shipped">
|
144 |
+
<type>carrier</type>
|
145 |
+
<name>Transporteur</name>
|
146 |
+
<accepted_values>
|
147 |
+
<value default="true">Colissimo</value>
|
148 |
+
<value>So Colissimo</value>
|
149 |
+
<value>CHRONOPOST</value>
|
150 |
+
<value>TNT</value>
|
151 |
+
<value>UPS</value>
|
152 |
+
<value>Fedex</value>
|
153 |
+
<value>Tatex</value>
|
154 |
+
<value>GLS</value>
|
155 |
+
<value>DHL</value>
|
156 |
+
<value>Courrier Suivi</value>
|
157 |
+
</accepted_values>
|
158 |
+
</param>
|
159 |
+
</additional_params>
|
160 |
+
</marketplace>
|
161 |
+
<marketplace name="amazon">
|
162 |
+
<api>https://wsdl.lengow.com/wsdl/amazon/#ID_FLUX#/#ORDER_ID#/#ACTION#.xml</api>
|
163 |
+
<states>
|
164 |
+
<state name="new">
|
165 |
+
<actions>
|
166 |
+
<action type="accept">accept</action>
|
167 |
+
<action type="refuse">refuseOrder</action>
|
168 |
+
</actions>
|
169 |
+
<lengow>new</lengow>
|
170 |
+
</state>
|
171 |
+
<state name="accept">
|
172 |
+
<actions>
|
173 |
+
<action type="shipped">acceptOrder</action>
|
174 |
+
<action type="refuse">refuseOrder</action>
|
175 |
+
</actions>
|
176 |
+
<lengow>processing</lengow>
|
177 |
+
</state>
|
178 |
+
<state name="processing">
|
179 |
+
<lengow>processing</lengow>
|
180 |
+
</state>
|
181 |
+
<state name="accepted">
|
182 |
+
<actions>
|
183 |
+
<action type="accept">accept</action>
|
184 |
+
<action type="refuse">refuseOrder</action>
|
185 |
+
</actions>
|
186 |
+
<lengow>shipped</lengow>
|
187 |
+
</state>
|
188 |
+
<state name="shipped">
|
189 |
+
<lengow>shipped</lengow>
|
190 |
+
</state>
|
191 |
+
<state name="refused">
|
192 |
+
<lengow>canceled</lengow>
|
193 |
+
</state>
|
194 |
+
<state name="refusesale">
|
195 |
+
<lengow>canceled</lengow>
|
196 |
+
</state>
|
197 |
+
<state name="canceled">
|
198 |
+
<lengow>canceled</lengow>
|
199 |
+
</state>
|
200 |
+
<state name="old">
|
201 |
+
<lengow>shipped</lengow>
|
202 |
+
</state>
|
203 |
+
</states>
|
204 |
+
<additional_params>
|
205 |
+
<param usedby="shipped">
|
206 |
+
<type>tracking</type>
|
207 |
+
<name>colis_idTracking</name>
|
208 |
+
</param>
|
209 |
+
<param usedby="shipped">
|
210 |
+
<type>carrier</type>
|
211 |
+
<name>transporteur</name>
|
212 |
+
</param>
|
213 |
+
</additional_params>
|
214 |
+
</marketplace>
|
215 |
+
<marketplace name="ebay">
|
216 |
+
<api>https://wsdl.lengow.com/wsdl/ebay/#ID_FLUX#/#ORDER_ID#/#ACTION#.xml</api>
|
217 |
+
<states>
|
218 |
+
<state name="New">
|
219 |
+
<lengow>new</lengow>
|
220 |
+
</state>
|
221 |
+
<state name="ToShip">
|
222 |
+
<actions>
|
223 |
+
<action type="shipped">shippedOrder</action>
|
224 |
+
</actions>
|
225 |
+
<lengow>processing</lengow>
|
226 |
+
</state>
|
227 |
+
<state name="Shipped">
|
228 |
+
<lengow>shipped</lengow>
|
229 |
+
</state>
|
230 |
+
</states>
|
231 |
+
<additional_params>
|
232 |
+
<param usedby="shipped">
|
233 |
+
<type>tracking</type>
|
234 |
+
<name>TrackingColis</name>
|
235 |
+
</param>
|
236 |
+
</additional_params>
|
237 |
+
</marketplace>
|
238 |
+
<marketplace name="cdiscount">
|
239 |
+
<api>https://wsdl.lengow.com/wsdl/cdiscount/#ID_FLUX#/#ORDER_ID#/#ACTION#.xml</api>
|
240 |
+
<states>
|
241 |
+
<state name="WaintingForSellerAcceptation">
|
242 |
+
<actions>
|
243 |
+
<action type="accept">acceptOrder</action>
|
244 |
+
<action type="refuse">refuseOrder</action>
|
245 |
+
</actions>
|
246 |
+
<lengow>new</lengow>
|
247 |
+
</state>
|
248 |
+
<state name="AcceptedBySeller">
|
249 |
+
<lengow>new</lengow>
|
250 |
+
</state>
|
251 |
+
<state name="PaymentinProgress">
|
252 |
+
<lengow>new</lengow>
|
253 |
+
</state>
|
254 |
+
<state name="ValidatedFianet">
|
255 |
+
<lengow>new</lengow>
|
256 |
+
</state>
|
257 |
+
<state name="WaitingForShipmentAcceptation">
|
258 |
+
<actions>
|
259 |
+
<action type="shipped">shippedOrder</action>
|
260 |
+
<action type="refuse">refuseShipment</action>
|
261 |
+
</actions>
|
262 |
+
<lengow>processing</lengow>
|
263 |
+
</state>
|
264 |
+
<state name="Shipped">
|
265 |
+
<lengow>shipped</lengow>
|
266 |
+
</state>
|
267 |
+
<state name="">
|
268 |
+
<lengow>canceled</lengow>
|
269 |
+
</state>
|
270 |
+
<state name="ShipmentRefusedBySeller">
|
271 |
+
<lengow>canceled</lengow>
|
272 |
+
</state>
|
273 |
+
<state name="PaymentRefused">
|
274 |
+
<lengow>canceled</lengow>
|
275 |
+
</state>
|
276 |
+
<state name="CancelledByCustomer">
|
277 |
+
<lengow>canceled</lengow>
|
278 |
+
</state>
|
279 |
+
<state name="RefusedNotShipment">
|
280 |
+
<lengow>canceled</lengow>
|
281 |
+
</state>
|
282 |
+
<state name="AutomaticCancellation">
|
283 |
+
<lengow>canceled</lengow>
|
284 |
+
</state>
|
285 |
+
<state name="RefusedBySeller">
|
286 |
+
<lengow>canceled</lengow>
|
287 |
+
</state>
|
288 |
+
</states>
|
289 |
+
<additional_params>
|
290 |
+
<param usedby="shipped">
|
291 |
+
<type>tracking</type>
|
292 |
+
<name>TrackingColis</name>
|
293 |
+
</param>
|
294 |
+
<param usedby="shipped">
|
295 |
+
<type>carrier</type>
|
296 |
+
<name>Transporteur</name>
|
297 |
+
<accepted_values>
|
298 |
+
<value label="La Poste">LAPOSTE</value>
|
299 |
+
<value label="DHL">DHL</value>
|
300 |
+
<value label="Fedex">FEDEX</value>
|
301 |
+
<value label="GLS">GLS</value>
|
302 |
+
<value label="UPS">UPS</value>
|
303 |
+
<value label="TAT Express">TAT</value>
|
304 |
+
<value label="TNT">TNT</value>
|
305 |
+
<value label="Mondial Relay">MONDIALRELAY</value>
|
306 |
+
<value label="SERNAM">SERNAM</value>
|
307 |
+
<value label="Geodis Calberson">GEODISCALBERSON</value>
|
308 |
+
<value label="France Express">FRANCEEXPRESS</value>
|
309 |
+
<value label="SDEN">FRANCSDENEEXPRESS</value>
|
310 |
+
<value label="CHRONOPOST">Chronopost</value>
|
311 |
+
<value label="TATEX">TATEX</value>
|
312 |
+
<value label="SCHENKER JOYAU">SCHENKER_JOYAU</value>
|
313 |
+
<value label="Relais colis">Relais_colis</value>
|
314 |
+
<value label="Gefco">Gefco</value>
|
315 |
+
<value label="MORY">MORY</value>
|
316 |
+
<value label="Heppner">Heppner</value>
|
317 |
+
<value label="Exapaq">Exapaq</value>
|
318 |
+
<value label="Mazet">Mazet</value>
|
319 |
+
<value label="SIC EXPRESS">SICEXPRESS</value>
|
320 |
+
<value label="TMB">TMB</value>
|
321 |
+
</accepted_values>
|
322 |
+
</param>
|
323 |
+
<param usedby="shipped">
|
324 |
+
<type>tracking_url</type>
|
325 |
+
<name>TrackingUrl</name>
|
326 |
+
</param>
|
327 |
+
</additional_params>
|
328 |
+
</marketplace>
|
329 |
+
<marketplace name="laredoute">
|
330 |
+
<api>https://wsdl.lengow.com/wsdl/laredoute/#ID_FLUX#/#ORDER_ID#/#ACTION#.xml</api>
|
331 |
+
<apibyline>https://wsdl.lengow.com/wsdl/laredoute/#ID_FLUX#/#ORDER_ID#/#ORDER_LINE_ID#/#QTY_TO_REFUND#/#FDP#/#ACTION#.xml</apibyline>
|
332 |
+
<states>
|
333 |
+
<state name="ToCancel">
|
334 |
+
<actions>
|
335 |
+
<action type="cancel">cancelOrder</action>
|
336 |
+
</actions>
|
337 |
+
<lengow>new</lengow>
|
338 |
+
</state>
|
339 |
+
<state name="Created">
|
340 |
+
<actions>
|
341 |
+
<action type="accept">acceptOrder</action>
|
342 |
+
<action type="refuse">refuseOrder</action>
|
343 |
+
</actions>
|
344 |
+
<lengow>new</lengow>
|
345 |
+
</state>
|
346 |
+
<state name="Accepted">
|
347 |
+
<lengow>new</lengow>
|
348 |
+
</state>
|
349 |
+
<state name="ToShip">
|
350 |
+
<actions>
|
351 |
+
<action type="shipped">shippedOrder</action>
|
352 |
+
<action type="refund">refundOrder</action>
|
353 |
+
<action type="refundLine" usedbyline="true">refundOrder</action>
|
354 |
+
</actions>
|
355 |
+
<lengow>processing</lengow>
|
356 |
+
</state>
|
357 |
+
<state name="ToCancel">
|
358 |
+
<lengow>processing</lengow>
|
359 |
+
</state>
|
360 |
+
<state name="Shipped">
|
361 |
+
<actions>
|
362 |
+
<action type="refund">refundOrder</action>
|
363 |
+
<action type="refundLine" usedbyline="true">refundOrder</action>
|
364 |
+
</actions>
|
365 |
+
<lengow>shipped</lengow>
|
366 |
+
</state>
|
367 |
+
<state name="Refunded">
|
368 |
+
<lengow>canceled</lengow>
|
369 |
+
</state>
|
370 |
+
<state name="Cancelled">
|
371 |
+
<lengow>canceled</lengow>
|
372 |
+
</state>
|
373 |
+
<state name="Refused">
|
374 |
+
<lengow>canceled</lengow>
|
375 |
+
</state>
|
376 |
+
</states>
|
377 |
+
<additional_params>
|
378 |
+
<param usedby="shipped">
|
379 |
+
<type>tracking</type>
|
380 |
+
<name>TrackingColis</name>
|
381 |
+
</param>
|
382 |
+
<param usedby="shipped">
|
383 |
+
<type>carrier</type>
|
384 |
+
<name>Transporteur</name>
|
385 |
+
</param>
|
386 |
+
<param usedby="shipped">
|
387 |
+
<type>tracking_url</type>
|
388 |
+
<name>url</name>
|
389 |
+
</param>
|
390 |
+
<param usedby="shipped" usedbyline="true">
|
391 |
+
<type>shipping_price</type>
|
392 |
+
<name>fdp</name>
|
393 |
+
</param>
|
394 |
+
<param usedby="shipped" usedbyline="true">
|
395 |
+
<type>order_line</type>
|
396 |
+
<name>orderlineid</name>
|
397 |
+
</param>
|
398 |
+
<param usedby="shipped" usedbyline="true">
|
399 |
+
<type>quantity</type>
|
400 |
+
<name>qty</name>
|
401 |
+
</param>
|
402 |
+
</additional_params>
|
403 |
+
</marketplace>
|
404 |
+
<marketplace name="frenchplace">
|
405 |
+
<api>https://wsdl.lengow.com/wsdl/frenchplace/#ID_FLUX#/#ORDER_ID#/#ACTION#.xml</api>
|
406 |
+
<states>
|
407 |
+
<state name="new">
|
408 |
+
<actions>
|
409 |
+
<action type="accept">acceptOrder</action>
|
410 |
+
<action type="refuse">refuseOrder</action>
|
411 |
+
</actions>
|
412 |
+
<lengow>new</lengow>
|
413 |
+
</state>
|
414 |
+
<state name="Accepted">
|
415 |
+
<lengow>processing</lengow>
|
416 |
+
</state>
|
417 |
+
<state name="shipped">
|
418 |
+
<lengow>shipped</lengow>
|
419 |
+
</state>
|
420 |
+
<state name="Accepted">
|
421 |
+
<lengow>canceled</lengow>
|
422 |
+
</state>
|
423 |
+
</states>
|
424 |
+
<additional_params>
|
425 |
+
<param usedby="shipped">
|
426 |
+
<type>tracking</type>
|
427 |
+
<name>TrackingColis</name>
|
428 |
+
</param>
|
429 |
+
<param usedby="shipped">
|
430 |
+
<type>carrier</type>
|
431 |
+
<name>Transporteur</name>
|
432 |
+
</param>
|
433 |
+
</additional_params>
|
434 |
+
</marketplace>
|
435 |
+
<marketplace name="greenrepublic">
|
436 |
+
<api>https://wsdl.lengow.com/wsdl/greenrepublic/#ID_FLUX#/#ORDER_ID#/#ACTION#.xml</api>
|
437 |
+
<states>
|
438 |
+
<state name="new">
|
439 |
+
<actions>
|
440 |
+
<action type="refuse">refuseOrder</action>
|
441 |
+
</actions>
|
442 |
+
<lengow>new</lengow>
|
443 |
+
</state>
|
444 |
+
<state name="pending_payment">
|
445 |
+
<lengow>processing</lengow>
|
446 |
+
</state>
|
447 |
+
<state name="processing">
|
448 |
+
<actions>
|
449 |
+
<action type="shipped">shippedOrder</action>
|
450 |
+
</actions>
|
451 |
+
<lengow>processing</lengow>
|
452 |
+
</state>
|
453 |
+
<state name="holded">
|
454 |
+
<lengow>processing</lengow>
|
455 |
+
</state>
|
456 |
+
<state name="in">
|
457 |
+
<lengow>processing</lengow>
|
458 |
+
</state>
|
459 |
+
<state name="payment_review">
|
460 |
+
<lengow>processing</lengow>
|
461 |
+
</state>
|
462 |
+
<state name="complete">
|
463 |
+
<lengow>shipped</lengow>
|
464 |
+
</state>
|
465 |
+
<state name="canceled">
|
466 |
+
<lengow>canceled</lengow>
|
467 |
+
</state>
|
468 |
+
</states>
|
469 |
+
<additional_params>
|
470 |
+
<param usedby="shipped">
|
471 |
+
<type>tracking</type>
|
472 |
+
<name>TrackingColis</name>
|
473 |
+
</param>
|
474 |
+
<param usedby="shipped">
|
475 |
+
<type>carrier</type>
|
476 |
+
<name>Transporteur</name>
|
477 |
+
<accepted_values>
|
478 |
+
<value>sc_calberson</value>
|
479 |
+
<value>sc_fedex</value>
|
480 |
+
<value>sc_relaypoint</value>
|
481 |
+
<value>sc_gls</value>
|
482 |
+
<value>sc_chronopost</value>
|
483 |
+
<value>sc_tnt</value>
|
484 |
+
<value>sc_dhl</value>
|
485 |
+
<value default="true">sc_colissimo</value>
|
486 |
+
<value>sc_export3j</value>
|
487 |
+
</accepted_values>
|
488 |
+
</param>
|
489 |
+
</additional_params>
|
490 |
+
</marketplace>
|
491 |
+
<marketplace name="babyssima">
|
492 |
+
<api>https://wsdl.lengow.com/wsdl/babyssima/#ID_FLUX#/#ORDER_ID#/#ACTION#.xml</api>
|
493 |
+
<states>
|
494 |
+
<state name="new">
|
495 |
+
<actions>
|
496 |
+
<action type="refuse">refuseOrder</action>
|
497 |
+
</actions>
|
498 |
+
<lengow>new</lengow>
|
499 |
+
</state>
|
500 |
+
<state name="processing">
|
501 |
+
<actions>
|
502 |
+
<action type="shipped">shippedOrder</action>
|
503 |
+
</actions>
|
504 |
+
<lengow>processing</lengow>
|
505 |
+
</state>
|
506 |
+
<state name="complete">
|
507 |
+
<lengow>shipped</lengow>
|
508 |
+
</state>
|
509 |
+
<state name="canceled">
|
510 |
+
<lengow>canceled</lengow>
|
511 |
+
</state>
|
512 |
+
</states>
|
513 |
+
<additional_params>
|
514 |
+
<param usedby="shipped">
|
515 |
+
<type>tracking</type>
|
516 |
+
<name>TrackingColis</name>
|
517 |
+
</param>
|
518 |
+
<param usedby="shipped">
|
519 |
+
<type>carrier</type>
|
520 |
+
<name>Transporteur</name>
|
521 |
+
</param>
|
522 |
+
</additional_params>
|
523 |
+
</marketplace>
|
524 |
+
<marketplace name="monechelle">
|
525 |
+
<api>https://wsdl.lengow.com/wsdl/monechelle/#ID_FLUX#/#ORDER_ID#/#ACTION#.xml</api>
|
526 |
+
<states>
|
527 |
+
<state name="new">
|
528 |
+
<actions>
|
529 |
+
<action type="refuse">refuseOrder</action>
|
530 |
+
<action type="accept">acceptOrder</action>
|
531 |
+
</actions>
|
532 |
+
<lengow>processing</lengow>
|
533 |
+
</state>
|
534 |
+
<state name="accepted">
|
535 |
+
<lengow>shipped</lengow>
|
536 |
+
</state>
|
537 |
+
<state name="refused">
|
538 |
+
<lengow>canceled</lengow>
|
539 |
+
</state>
|
540 |
+
</states>
|
541 |
+
<additional_params>
|
542 |
+
<param usedby="shipped">
|
543 |
+
<type>tracking</type>
|
544 |
+
<name>TrackingColis</name>
|
545 |
+
</param>
|
546 |
+
<param usedby="shipped">
|
547 |
+
<type>carrier</type>
|
548 |
+
<name>Transporteur</name>
|
549 |
+
</param>
|
550 |
+
</additional_params>
|
551 |
+
</marketplace>
|
552 |
+
<marketplace name="brandalley">
|
553 |
+
<api>https://wsdl.lengow.com/wsdl/brandalley/#ID_FLUX#/#ORDER_ID#/#ACTION#.xml</api>
|
554 |
+
<states>
|
555 |
+
<state name="new">
|
556 |
+
<actions>
|
557 |
+
<action type="refuse">refuseOrder</action>
|
558 |
+
<action type="accept">acceptOrder</action>
|
559 |
+
</actions>
|
560 |
+
<lengow>processing</lengow>
|
561 |
+
</state>
|
562 |
+
<state name="accepted">
|
563 |
+
<lengow>shipped</lengow>
|
564 |
+
</state>
|
565 |
+
<state name="cancel">
|
566 |
+
<lengow>canceled</lengow>
|
567 |
+
</state>
|
568 |
+
</states>
|
569 |
+
</marketplace>
|
570 |
+
<marketplace name="pixplace">
|
571 |
+
<states>
|
572 |
+
<state name="accepted">
|
573 |
+
<lengow>processing</lengow>
|
574 |
+
</state>
|
575 |
+
<state name="processing">
|
576 |
+
<lengow>processing</lengow>
|
577 |
+
</state>
|
578 |
+
<state name="NotReceived">
|
579 |
+
<lengow>processing</lengow>
|
580 |
+
</state>
|
581 |
+
<state name="Cancelled">
|
582 |
+
<lengow>canceled</lengow>
|
583 |
+
</state>
|
584 |
+
<state name="Refused">
|
585 |
+
<lengow>canceled</lengow>
|
586 |
+
</state>
|
587 |
+
<state name="Refunded">
|
588 |
+
<lengow>canceled</lengow>
|
589 |
+
</state>
|
590 |
+
</states>
|
591 |
+
</marketplace>
|
592 |
+
<marketplace name="leoo">
|
593 |
+
<states>
|
594 |
+
<state name="Confirmé">
|
595 |
+
<lengow>processing</lengow>
|
596 |
+
</state>
|
597 |
+
<state name="Expédié">
|
598 |
+
<lengow>shipped</lengow>
|
599 |
+
</state>
|
600 |
+
<state name="Annulation">
|
601 |
+
<lengow>canceled</lengow>
|
602 |
+
</state>
|
603 |
+
</states>
|
604 |
+
</marketplace>
|
605 |
+
<marketplace name="lechouchou">
|
606 |
+
<api>https://wsdl.lengow.com/wsdl/lechouchou/#ID_FLUX#/#ORDER_ID#/#ACTION#.xml</api>
|
607 |
+
<states>
|
608 |
+
<state name="new">
|
609 |
+
<lengow>new</lengow>
|
610 |
+
<actions>
|
611 |
+
<action type="accept">accepted</action>
|
612 |
+
<action type="refuse">refused</action>
|
613 |
+
</actions>
|
614 |
+
</state>
|
615 |
+
<state name="processing">
|
616 |
+
<actions>
|
617 |
+
<action type="shipped">shipped</action>
|
618 |
+
<action type="refuse">refused</action>
|
619 |
+
</actions>
|
620 |
+
<lengow>processing</lengow>
|
621 |
+
</state>
|
622 |
+
<state name="accept">
|
623 |
+
<lengow>shipped</lengow>
|
624 |
+
</state>
|
625 |
+
<state name="refused">
|
626 |
+
<lengow>canceled</lengow>
|
627 |
+
</state>
|
628 |
+
</states>
|
629 |
+
<additional_params>
|
630 |
+
<param usedby="shipped">
|
631 |
+
<type>tracking</type>
|
632 |
+
<name>TrackingColis</name>
|
633 |
+
</param>
|
634 |
+
</additional_params>
|
635 |
+
</marketplace>
|
636 |
+
<marketplace name="leoo">
|
637 |
+
<states>
|
638 |
+
<state name="Confirmé">
|
639 |
+
<lengow>processing</lengow>
|
640 |
+
</state>
|
641 |
+
<state name="Expédié">
|
642 |
+
<lengow>shipped</lengow>
|
643 |
+
</state>
|
644 |
+
<state name="Annulation">
|
645 |
+
<lengow>canceled</lengow>
|
646 |
+
</state>
|
647 |
+
</states>
|
648 |
+
</marketplace>
|
649 |
+
<marketplace name="discounteo">
|
650 |
+
<api>https://wsdl.lengow.com/wsdl/discounteo/#ID_FLUX#/#ORDER_ID#/#ACTION#.xml</api>
|
651 |
+
<states>
|
652 |
+
<state name="new">
|
653 |
+
<lengow>new</lengow>
|
654 |
+
</state>
|
655 |
+
<state name="processing">
|
656 |
+
<actions>
|
657 |
+
<action type="shipped">shipped</action>
|
658 |
+
<action type="refuse">refused</action>
|
659 |
+
</actions>
|
660 |
+
<lengow>processing</lengow>
|
661 |
+
</state>
|
662 |
+
<state name="shipped">
|
663 |
+
<lengow>shipped</lengow>
|
664 |
+
</state>
|
665 |
+
<state name="refused">
|
666 |
+
<lengow>canceled</lengow>
|
667 |
+
</state>
|
668 |
+
</states>
|
669 |
+
<additional_params>
|
670 |
+
<param usedby="shipped">
|
671 |
+
<type>tracking</type>
|
672 |
+
<name>TrackingColis</name>
|
673 |
+
</param>
|
674 |
+
<param usedby="shipped">
|
675 |
+
<type>carrier</type>
|
676 |
+
<name>Transporteur</name>
|
677 |
+
</param>
|
678 |
+
</additional_params>
|
679 |
+
</marketplace>
|
680 |
+
<marketplace name="ecopresto">
|
681 |
+
<api>https://wsdl.lengow.com/wsdl/ecopresto/#ID_FLUX#/#ORDER_ID#/#ACTION#.xml</api>
|
682 |
+
<states>
|
683 |
+
<state name="new">
|
684 |
+
<lengow>new</lengow>
|
685 |
+
</state>
|
686 |
+
<state name="processing">
|
687 |
+
<actions>
|
688 |
+
<action type="shipped">shipped</action>
|
689 |
+
</actions>
|
690 |
+
<lengow>processing</lengow>
|
691 |
+
</state>
|
692 |
+
<state name="shipped">
|
693 |
+
<lengow>shipped</lengow>
|
694 |
+
</state>
|
695 |
+
<state name="refused">
|
696 |
+
<lengow>canceled</lengow>
|
697 |
+
</state>
|
698 |
+
</states>
|
699 |
+
<additional_params>
|
700 |
+
<param usedby="shipped">
|
701 |
+
<type>tracking</type>
|
702 |
+
<name>TrackingColis</name>
|
703 |
+
</param>
|
704 |
+
<param usedby="shipped">
|
705 |
+
<type>carrier</type>
|
706 |
+
<name>TrackingCarrier</name>
|
707 |
+
<accepted_values>
|
708 |
+
<value label="Divers" default="true">1</value>
|
709 |
+
<value label="Colissimo">2</value>
|
710 |
+
<value label="Lettre Max">3</value>
|
711 |
+
</accepted_values>
|
712 |
+
</param>
|
713 |
+
</additional_params>
|
714 |
+
</marketplace>
|
715 |
+
</marketplaces>
|
app/code/community/Lengow/Sync/etc/system.xml
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<lengow translate="label" module="sync">
|
5 |
+
<label>Lengow</label>
|
6 |
+
<sort_order>210</sort_order>
|
7 |
+
</lengow>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<sync translate="label" module="sync">
|
11 |
+
<label>Manage Orders</label>
|
12 |
+
<tab>lengow</tab>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>110</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>1</show_in_store>
|
18 |
+
<groups>
|
19 |
+
<orders translate="label" module="sync">
|
20 |
+
<label>Manage Orders</label>
|
21 |
+
<show_in_default>1</show_in_default>
|
22 |
+
<show_in_website>1</show_in_website>
|
23 |
+
<show_in_store>1</show_in_store>
|
24 |
+
<sort_order>1</sort_order>
|
25 |
+
<fields>
|
26 |
+
<period>
|
27 |
+
<label>Import orders from x days</label>
|
28 |
+
<sort_order>21</sort_order>
|
29 |
+
<show_in_default>1</show_in_default>
|
30 |
+
<show_in_website>1</show_in_website>
|
31 |
+
<show_in_store>1</show_in_store>
|
32 |
+
<comment>Choose period for Sync order</comment>
|
33 |
+
</period>
|
34 |
+
<cron>
|
35 |
+
<label>Auto import</label>
|
36 |
+
<frontend_type>select</frontend_type>
|
37 |
+
<sort_order>22</sort_order>
|
38 |
+
<show_in_default>1</show_in_default>
|
39 |
+
<show_in_website>1</show_in_website>
|
40 |
+
<show_in_store>1</show_in_store>
|
41 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
42 |
+
<comment>Enable import every 30 minutes</comment>
|
43 |
+
</cron>
|
44 |
+
<title>
|
45 |
+
<label>Import with product's title from Lengow</label>
|
46 |
+
<comment>Import an order with the product's name from marketplace</comment>
|
47 |
+
<frontend_type>select</frontend_type>
|
48 |
+
<sort_order>23</sort_order>
|
49 |
+
<show_in_default>1</show_in_default>
|
50 |
+
<show_in_website>1</show_in_website>
|
51 |
+
<show_in_store>1</show_in_store>
|
52 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
53 |
+
</title>
|
54 |
+
<debug>
|
55 |
+
<label>Debug mode</label>
|
56 |
+
<frontend_type>select</frontend_type>
|
57 |
+
<sort_order>24</sort_order>
|
58 |
+
<show_in_default>1</show_in_default>
|
59 |
+
<show_in_website>1</show_in_website>
|
60 |
+
<show_in_store>1</show_in_store>
|
61 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
62 |
+
<comment>Only for preproduction's mode : no sync orders with Lengow, import orders every time</comment>
|
63 |
+
</debug>
|
64 |
+
</fields>
|
65 |
+
</orders>
|
66 |
+
<hidden translate="label" module="sync">
|
67 |
+
<label>Hidden fields</label>
|
68 |
+
<show_in_default>0</show_in_default>
|
69 |
+
<show_in_website>0</show_in_website>
|
70 |
+
<show_in_store>0</show_in_store>
|
71 |
+
<sort_order>1</sort_order>
|
72 |
+
<fields>
|
73 |
+
<last_synchro>
|
74 |
+
<label>Date of marketplace.xml sync</label>
|
75 |
+
<sort_order>1</sort_order>
|
76 |
+
<show_in_default>0</show_in_default>
|
77 |
+
<show_in_website>0</show_in_website>
|
78 |
+
<show_in_store>0</show_in_store>
|
79 |
+
<comment>Last date of marketplace.xml synchronisation</comment>
|
80 |
+
</last_synchro>
|
81 |
+
</fields>
|
82 |
+
</hidden>
|
83 |
+
</groups>
|
84 |
+
</sync>
|
85 |
+
</sections>
|
86 |
+
</config>
|
app/code/community/Lengow/Sync/sql/lengow_setup/mysql4-install-2.0.0.0.php
ADDED
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category Lengow
|
5 |
+
* @package Lengow_Sync
|
6 |
+
* @author Romain Le Polh <romain@lengow.com>
|
7 |
+
* @copyright 2013 Lengow SAS
|
8 |
+
*/
|
9 |
+
|
10 |
+
$installer = $this;
|
11 |
+
$installer->startSetup();
|
12 |
+
|
13 |
+
/*
|
14 |
+
* Add customer infos
|
15 |
+
* - from_lengow @boolean
|
16 |
+
*/
|
17 |
+
$customer_entity_id = $installer->getEntityTypeId('customer');
|
18 |
+
$from_lengow = $installer->getAttribute($customer_entity_id, 'from_lengow');
|
19 |
+
if(!$from_lengow) {
|
20 |
+
$installer->addAttribute('customer', 'from_lengow', array(
|
21 |
+
'type' => 'int',
|
22 |
+
'label' => 'From Lengow ',
|
23 |
+
'visible' => true,
|
24 |
+
'required' => false,
|
25 |
+
'unique' => false,
|
26 |
+
'sort_order' => 700,
|
27 |
+
'default' => 0,
|
28 |
+
'input' => 'select',
|
29 |
+
'source' => 'eav/entity_attribute_source_boolean',
|
30 |
+
));
|
31 |
+
$usedInForms = array(
|
32 |
+
'adminhtml_customer',
|
33 |
+
);
|
34 |
+
$attribute = Mage::getSingleton('eav/config')->getAttribute('customer', 'from_lengow');
|
35 |
+
$attribute->setData('used_in_forms', $usedInForms);
|
36 |
+
$attribute->setData('sort_order', 700);
|
37 |
+
$attribute->save();
|
38 |
+
}
|
39 |
+
|
40 |
+
/*
|
41 |
+
* Add order infos
|
42 |
+
* - lengow_Sync_id - string
|
43 |
+
* - feed_id_lengow - integer
|
44 |
+
* - marketplace_lengow - string
|
45 |
+
* - total_paid_lengow - float
|
46 |
+
* - carrier - string
|
47 |
+
* - message - string
|
48 |
+
* - xml_node - string
|
49 |
+
* - from_lengow - boolean
|
50 |
+
*/
|
51 |
+
$order_entity_id = $installer->getEntityTypeId('order');
|
52 |
+
|
53 |
+
$list_attribute = array();
|
54 |
+
$list_attribute[] = array(
|
55 |
+
'name' => 'from_lengow',
|
56 |
+
'label' => 'From Lengow',
|
57 |
+
'type' => 'int',
|
58 |
+
'input' => 'select',
|
59 |
+
'source' => 'eav/entity_attribute_source_boolean',
|
60 |
+
'default' => 0,
|
61 |
+
'grid' => true,
|
62 |
+
);
|
63 |
+
$list_attribute[] = array(
|
64 |
+
'name' => 'order_id_lengow',
|
65 |
+
'label' => 'Lengow order ID',
|
66 |
+
'type' => 'text',
|
67 |
+
'input' => 'text',
|
68 |
+
'source' => '',
|
69 |
+
'default' => '',
|
70 |
+
'grid' => true,
|
71 |
+
);
|
72 |
+
$list_attribute[] = array(
|
73 |
+
'name' => 'fees_lengow',
|
74 |
+
'label' => 'Fees',
|
75 |
+
'type' => 'float',
|
76 |
+
'input' => 'text',
|
77 |
+
'source' => '',
|
78 |
+
'default' => 0,
|
79 |
+
'grid' => true,
|
80 |
+
);
|
81 |
+
$list_attribute[] = array(
|
82 |
+
'name' => 'xml_node_lengow',
|
83 |
+
'label' => 'XML Node',
|
84 |
+
'type' => 'text',
|
85 |
+
'input' => 'text',
|
86 |
+
'source' => '',
|
87 |
+
'default' => '',
|
88 |
+
'grid' => false,
|
89 |
+
);
|
90 |
+
$list_attribute[] = array(
|
91 |
+
'name' => 'feed_id_lengow',
|
92 |
+
'label' => 'Feed ID',
|
93 |
+
'type' => 'float',
|
94 |
+
'input' => 'text',
|
95 |
+
'source' => '',
|
96 |
+
'default' => 0,
|
97 |
+
'grid' => false,
|
98 |
+
);
|
99 |
+
$list_attribute[] = array(
|
100 |
+
'name' => 'message_lengow',
|
101 |
+
'label' => 'Message',
|
102 |
+
'type' => 'text',
|
103 |
+
'input' => 'text',
|
104 |
+
'source' => '',
|
105 |
+
'default' => '',
|
106 |
+
'grid' => false,
|
107 |
+
);
|
108 |
+
$list_attribute[] = array(
|
109 |
+
'name' => 'marketplace_lengow',
|
110 |
+
'label' => 'marketplace',
|
111 |
+
'type' => 'text',
|
112 |
+
'input' => 'text',
|
113 |
+
'source' => '',
|
114 |
+
'default' => '',
|
115 |
+
'grid' => true,
|
116 |
+
);
|
117 |
+
$list_attribute[] = array(
|
118 |
+
'name' => 'total_paid_lengow',
|
119 |
+
'label' => 'Total Paid',
|
120 |
+
'type' => 'text',
|
121 |
+
'input' => 'text',
|
122 |
+
'source' => '',
|
123 |
+
'default' => '',
|
124 |
+
'grid' => false,
|
125 |
+
);
|
126 |
+
|
127 |
+
foreach($list_attribute as $attr) {
|
128 |
+
$order_attribute = $installer->getAttribute($order_entity_id, $attr['name']);
|
129 |
+
if(!$order_attribute) {
|
130 |
+
$installer->addAttribute('order', $attr['name'], array(
|
131 |
+
'name' => $attr['name'],
|
132 |
+
'label' => $attr['label'],
|
133 |
+
'type' => $attr['type'],
|
134 |
+
'visible' => true,
|
135 |
+
'required' => false,
|
136 |
+
'unique' => false,
|
137 |
+
'filterable' => 1,
|
138 |
+
'sort_order' => 700,
|
139 |
+
'default' => $attr['default'],
|
140 |
+
'input' => $attr['input'],
|
141 |
+
'source' => $attr['source'],
|
142 |
+
'grid' => $attr['grid'],
|
143 |
+
));
|
144 |
+
}
|
145 |
+
$usedInForms = array(
|
146 |
+
'adminhtml_order',
|
147 |
+
);
|
148 |
+
}
|
149 |
+
|
150 |
+
$installer->endSetup();
|
151 |
+
|
152 |
+
$installer = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
|
153 |
+
|
154 |
+
$entity_id = $installer->getEntityTypeId('catalog_product');
|
155 |
+
$attribute = $installer->getAttribute($entity_id,'lengow_product');
|
156 |
+
|
157 |
+
if(!$attribute)
|
158 |
+
$installer->addAttribute('catalog_product', 'lengow_product', array(
|
159 |
+
'type' => 'int',
|
160 |
+
'backend' => '',
|
161 |
+
'frontend' => '',
|
162 |
+
'label' => 'Publish on Lengow',
|
163 |
+
'input' => 'boolean',
|
164 |
+
'global' => 1,
|
165 |
+
'visible' => 1,
|
166 |
+
'required' => 0,
|
167 |
+
'user_defined' => 1,
|
168 |
+
'default' => 1,
|
169 |
+
'searchable' => 0,
|
170 |
+
'filterable' => 0,
|
171 |
+
'comparable' => 0,
|
172 |
+
'visible_on_front' => 1,
|
173 |
+
'unique' => 0,
|
174 |
+
'used_in_product_listing' => 1
|
175 |
+
));
|
176 |
+
// TODO use Mage ORM
|
177 |
+
$installer->run(
|
178 |
+
"CREATE TABLE IF NOT EXISTS `{$this->getTable('lengow_log')}` (
|
179 |
+
`id` int(11) NOT NULL auto_increment,
|
180 |
+
`date` timestamp NOT NULL default CURRENT_TIMESTAMP,
|
181 |
+
`message` text NOT NULL,
|
182 |
+
PRIMARY KEY (`id`)
|
183 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
|
184 |
+
|
185 |
+
$installer->endSetup();
|
app/code/community/Lengow/Sync/sql/lengow_setup/mysql4-upgrade-2.0.0.0-2.0.0.1.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category Lengow
|
5 |
+
* @package Lengow_Sync
|
6 |
+
* @author Ludovic DRIN <romain@lengow.com>
|
7 |
+
* @copyright 2013 Lengow SAS
|
8 |
+
*/
|
9 |
+
|
10 |
+
$installer = $this;
|
11 |
+
$installer->startSetup();
|
12 |
+
|
13 |
+
/*
|
14 |
+
* Add order infos
|
15 |
+
* - carrier - string
|
16 |
+
*/
|
17 |
+
$order_entity_id = $installer->getEntityTypeId('order');
|
18 |
+
|
19 |
+
$list_attribute[] = array(
|
20 |
+
'name' => 'carrier_lengow',
|
21 |
+
'label' => 'Carrier',
|
22 |
+
'type' => 'text',
|
23 |
+
'input' => 'text',
|
24 |
+
'source' => '',
|
25 |
+
'default' => '',
|
26 |
+
'grid' => false,
|
27 |
+
);
|
28 |
+
|
29 |
+
$list_attribute[] = array(
|
30 |
+
'name' => 'carrier_method_lengow',
|
31 |
+
'label' => 'Carrier method',
|
32 |
+
'type' => 'text',
|
33 |
+
'input' => 'text',
|
34 |
+
'source' => '',
|
35 |
+
'default' => '',
|
36 |
+
'grid' => false,
|
37 |
+
);
|
38 |
+
|
39 |
+
foreach($list_attribute as $attr) {
|
40 |
+
$order_attribute = $installer->getAttribute($order_entity_id, $attr['name']);
|
41 |
+
if(!$order_attribute) {
|
42 |
+
$installer->addAttribute('order', $attr['name'], array(
|
43 |
+
'name' => $attr['name'],
|
44 |
+
'label' => $attr['label'],
|
45 |
+
'type' => $attr['type'],
|
46 |
+
'visible' => true,
|
47 |
+
'required' => false,
|
48 |
+
'unique' => false,
|
49 |
+
'filterable' => 1,
|
50 |
+
'sort_order' => 700,
|
51 |
+
'default' => $attr['default'],
|
52 |
+
'input' => $attr['input'],
|
53 |
+
'source' => $attr['source'],
|
54 |
+
'grid' => $attr['grid'],
|
55 |
+
));
|
56 |
+
}
|
57 |
+
$usedInForms = array(
|
58 |
+
'adminhtml_order',
|
59 |
+
);
|
60 |
+
}
|
61 |
+
|
62 |
+
$installer->endSetup();
|
app/code/community/Lengow/Tracker/Block/.DS_Store
ADDED
Binary file
|
app/code/community/Lengow/Tracker/Block/Adminhtml/System/Config/Check.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright 2013 Lengow.
|
5 |
+
*
|
6 |
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
7 |
+
* not use this file except in compliance with the License. You may obtain
|
8 |
+
* a copy of the License at
|
9 |
+
*
|
10 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11 |
+
*
|
12 |
+
* Unless required by applicable law or agreed to in writing, software
|
13 |
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14 |
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15 |
+
* License for the specific language governing permissions and limitations
|
16 |
+
* under the License.
|
17 |
+
*/
|
18 |
+
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Lengow_Tracker_Block_Adminhtml_System_Config_Check
|
22 |
+
*
|
23 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
24 |
+
* @copyright 2014 Lengow SAS
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Lengow_Tracker_Block_Adminhtml_System_Config_Check extends Mage_Adminhtml_Block_Template implements Varien_Data_Form_Element_Renderer_Interface {
|
28 |
+
|
29 |
+
protected $_element;
|
30 |
+
|
31 |
+
protected function _construct() {
|
32 |
+
$this->setTemplate('widget/form/renderer/fieldset.phtml');
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getElement() {
|
36 |
+
return $this->_element;
|
37 |
+
}
|
38 |
+
/**
|
39 |
+
* Generate html for button
|
40 |
+
*
|
41 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
42 |
+
* @return string $html
|
43 |
+
* @see Mage_Adminhtml_Block_System_Config_Form_Field::_getElementHtml()
|
44 |
+
*/
|
45 |
+
public function render(Varien_Data_Form_Element_Abstract $element) {
|
46 |
+
$html = $this->getLayout()->createBlock('tracker/adminhtml_system_config_check_point', 'lengow_checkpoint')
|
47 |
+
->toHtml();
|
48 |
+
$element->setHtmlContent($html);
|
49 |
+
$this->_element = $element;
|
50 |
+
return $this->toHtml();
|
51 |
+
}
|
52 |
+
}
|
app/code/community/Lengow/Tracker/Block/Adminhtml/System/Config/Check/Point.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Copyright 2013 Lengow.
|
5 |
+
*
|
6 |
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
7 |
+
* not use this file except in compliance with the License. You may obtain
|
8 |
+
* a copy of the License at
|
9 |
+
*
|
10 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11 |
+
*
|
12 |
+
* Unless required by applicable law or agreed to in writing, software
|
13 |
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
14 |
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
15 |
+
* License for the specific language governing permissions and limitations
|
16 |
+
* under the License.
|
17 |
+
*/
|
18 |
+
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Lengow_Tracker_Block_Adminhtml_System_Config_Check_Point
|
22 |
+
*
|
23 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
24 |
+
* @copyright 2014 Lengow SAS
|
25 |
+
*/
|
26 |
+
|
27 |
+
class Lengow_Tracker_Block_Adminhtml_System_Config_Check_Point extends Mage_Adminhtml_Block_Template {
|
28 |
+
|
29 |
+
protected $_element;
|
30 |
+
|
31 |
+
protected $_helper;
|
32 |
+
|
33 |
+
public function __construct() {
|
34 |
+
$this->setTemplate('lengow/check/point.phtml');
|
35 |
+
$this->_helper = Mage::helper('tracker/check');
|
36 |
+
parent::_construct();
|
37 |
+
}
|
38 |
+
|
39 |
+
public function getVersion() {
|
40 |
+
return $this->_helper->getVersion();
|
41 |
+
}
|
42 |
+
|
43 |
+
public function isLastVersion() {
|
44 |
+
return $this->_helper->checkPluginVersion($this->_helper->getVersion());
|
45 |
+
}
|
46 |
+
|
47 |
+
public function getLastVersion() {
|
48 |
+
return $this->_helper->getLastVersion();
|
49 |
+
}
|
50 |
+
|
51 |
+
public function getRealIP() {
|
52 |
+
return $this->_helper->getRealIP();
|
53 |
+
}
|
54 |
+
|
55 |
+
}
|
app/code/community/Lengow/Tracker/Block/Tag/Capsule.php
ADDED
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Lengow_Tracker Tracking Block Capsule
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Tracker
|
8 |
+
* @author Romain Le Polh <romain@lengow.com>
|
9 |
+
*/
|
10 |
+
class Lengow_Tracker_Block_Tag_Capsule extends Mage_Core_Block_Template {
|
11 |
+
|
12 |
+
protected $_data = array();
|
13 |
+
|
14 |
+
const LENGOW_TRACK_HOMEPAGE = 'homepage';
|
15 |
+
const LENGOW_TRACK_PAGE = 'page';
|
16 |
+
const LENGOW_TRACK_PAGE_LIST = 'listepage';
|
17 |
+
const LENGOW_TRACK_PAGE_PAYMENT = 'payment';
|
18 |
+
const LENGOW_TRACK_PAGE_CART = 'basket';
|
19 |
+
const LENGOW_TRACK_PAGE_LEAD = 'lead';
|
20 |
+
const LENGOW_TRACK_PAGE_CONFIRMATION = 'confirmation';
|
21 |
+
|
22 |
+
static private $_CURRENT_PAGE_TYPE = 'page';
|
23 |
+
static private $_USE_SSL = false;
|
24 |
+
static private $_ID_ORDER = '';
|
25 |
+
static private $_ORDER_TOTAL = '';
|
26 |
+
static private $_IDS_PRODUCTS = '';
|
27 |
+
static private $_IDS_PRODUCTS_CART = '';
|
28 |
+
static private $_ID_CATEGORY = '';
|
29 |
+
|
30 |
+
public function __construct() {
|
31 |
+
$this->setData('config_model', Mage::getSingleton('tracker/config'));
|
32 |
+
$this->setData('capsule_model', Mage::getSingleton('tracker/capsule'));
|
33 |
+
$this->setData('id_client', $this->getData('config_model')->get('general/login'));
|
34 |
+
$this->setData('id_group', $this->getData('config_model')->get('general/group'));
|
35 |
+
$this->setData('current_view', Mage::app()->getRequest()->getActionName());
|
36 |
+
}
|
37 |
+
|
38 |
+
protected function _prepareLayout() {
|
39 |
+
parent::_prepareLayout();
|
40 |
+
|
41 |
+
// Page type
|
42 |
+
$current_module = Mage::app()->getFrontController()->getRequest()->getModuleName();
|
43 |
+
$current_controller = Mage::app()->getFrontController()->getRequest()->getControllerName();
|
44 |
+
$current_action = '';
|
45 |
+
|
46 |
+
if ($current_module == 'catalog') {
|
47 |
+
if ($current_controller == 'category')
|
48 |
+
self::$_CURRENT_PAGE_TYPE = self::LENGOW_TRACK_PAGE_LIST;
|
49 |
+
else if ($current_controller == 'product')
|
50 |
+
self::$_CURRENT_PAGE_TYPE = self::LENGOW_TRACK_PAGE;
|
51 |
+
} else if ($current_module == 'checkout') {
|
52 |
+
|
53 |
+
$current_action = Mage::app()->getRequest()->getActionName();
|
54 |
+
|
55 |
+
if ($current_action == 'success')
|
56 |
+
self::$_CURRENT_PAGE_TYPE = self::LENGOW_TRACK_PAGE_CONFIRMATION;
|
57 |
+
else if ($current_controller == 'cart')
|
58 |
+
self::$_CURRENT_PAGE_TYPE = self::LENGOW_TRACK_PAGE_CART;
|
59 |
+
else if ($current_controller == 'onepage')
|
60 |
+
self::$_CURRENT_PAGE_TYPE = self::LENGOW_TRACK_PAGE;
|
61 |
+
}
|
62 |
+
|
63 |
+
// Order total
|
64 |
+
if (self::$_CURRENT_PAGE_TYPE == self::LENGOW_TRACK_PAGE_CART ||
|
65 |
+
self::$_CURRENT_PAGE_TYPE == self::LENGOW_TRACK_PAGE_PAYMENT ||
|
66 |
+
$current_module == 'checkout' && $current_action != 'success') {
|
67 |
+
$quote = Mage::getModel('checkout/cart')->getQuote();
|
68 |
+
self::$_ORDER_TOTAL = round($quote->getGrandTotal(), 2);
|
69 |
+
} else if (self::$_CURRENT_PAGE_TYPE == self::LENGOW_TRACK_PAGE_CONFIRMATION) {
|
70 |
+
$order_id = Mage::getSingleton('checkout/session')->getLastOrderId();
|
71 |
+
$order = Mage::getModel('sales/order')->load($order_id);
|
72 |
+
self::$_ORDER_TOTAL = round($order->getGrandTotal(), 2);
|
73 |
+
}
|
74 |
+
|
75 |
+
// Order id - Lead / Payment / Confirmation
|
76 |
+
if (self::$_CURRENT_PAGE_TYPE == self::LENGOW_TRACK_PAGE_CONFIRMATION) {
|
77 |
+
self::$_ID_ORDER = Mage::getSingleton('checkout/session')->getLastOrderId();
|
78 |
+
}
|
79 |
+
|
80 |
+
// Ids Products - Page / Listpage / Basket / Payment / Confirmation
|
81 |
+
if (self::$_CURRENT_PAGE_TYPE == self::LENGOW_TRACK_PAGE_CART ||
|
82 |
+
self::$_CURRENT_PAGE_TYPE == self::LENGOW_TRACK_PAGE_PAYMENT ||
|
83 |
+
$current_module == 'checkout' && $current_action != 'success') {
|
84 |
+
// Get current quote
|
85 |
+
$quote = Mage::getModel('checkout/cart')->getQuote();
|
86 |
+
self::$_IDS_PRODUCTS = $this->getData('capsule_model')->getIdsProducts($quote);
|
87 |
+
} else if(self::$_CURRENT_PAGE_TYPE == self::LENGOW_TRACK_PAGE_LIST) {
|
88 |
+
self::$_IDS_PRODUCTS = $this->_getCurrentProductsIds();
|
89 |
+
} else if(self::$_CURRENT_PAGE_TYPE == self::LENGOW_TRACK_PAGE) {
|
90 |
+
self::$_IDS_PRODUCTS = $this->_getCurrentProductId();
|
91 |
+
} else if (self::$_CURRENT_PAGE_TYPE == self::LENGOW_TRACK_PAGE_CONFIRMATION) {
|
92 |
+
// Get last order
|
93 |
+
$order_id = Mage::getSingleton('checkout/session')->getLastOrderId();
|
94 |
+
$order = Mage::getModel('sales/order')->load($order_id);
|
95 |
+
self::$_IDS_PRODUCTS = $this->getData('capsule_model')->getIdsProducts($order);
|
96 |
+
}
|
97 |
+
|
98 |
+
// List product in basket - Basket - Confirmation
|
99 |
+
if (self::$_CURRENT_PAGE_TYPE == self::LENGOW_TRACK_PAGE_CART ||
|
100 |
+
$current_module == 'checkout' && $current_action != 'success') {
|
101 |
+
$quote = Mage::getModel('checkout/cart')->getQuote();
|
102 |
+
self::$_IDS_PRODUCTS_CART = $this->getData('capsule_model')->getProductsCart($quote);
|
103 |
+
} else if (self::$_CURRENT_PAGE_TYPE == self::LENGOW_TRACK_PAGE_CONFIRMATION) {
|
104 |
+
$order_id = Mage::getSingleton('checkout/session')->getLastOrderId();
|
105 |
+
$order = Mage::getModel('sales/order')->load($order_id);
|
106 |
+
self::$_IDS_PRODUCTS_CART = $this->getData('capsule_model')->getProductsCart($order);
|
107 |
+
}
|
108 |
+
|
109 |
+
// Id categorie
|
110 |
+
if (self::$_CURRENT_PAGE_TYPE == self::LENGOW_TRACK_PAGE_LIST)
|
111 |
+
self::$_ID_CATEGORY = Mage::registry('current_category')->getName();
|
112 |
+
|
113 |
+
// Use SSL
|
114 |
+
if (isset($_SERVER['HTTPS']) && $_SERVER['https'] == 'on')
|
115 |
+
self::$_USE_SSL = true;
|
116 |
+
|
117 |
+
// Assign data
|
118 |
+
$this->setData('type_page', self::$_CURRENT_PAGE_TYPE);
|
119 |
+
$this->setData('id_order', self::$_ID_ORDER);
|
120 |
+
$this->setData('order_total', self::$_ORDER_TOTAL);
|
121 |
+
$this->setData('id_category', self::$_ID_CATEGORY);
|
122 |
+
$this->setData('ids_products', self::$_IDS_PRODUCTS);
|
123 |
+
$this->setData('list_products', self::$_IDS_PRODUCTS_CART);
|
124 |
+
$this->setData('use_ssl', self::$_USE_SSL == true ? 'true' : 'false');
|
125 |
+
$this->setData('controller', $current_controller);
|
126 |
+
$this->setData('module', $current_module);
|
127 |
+
$this->setData('current_action', $current_action);
|
128 |
+
|
129 |
+
$this->setTemplate('lengow/tracker/tagcapsule.phtml');
|
130 |
+
return $this;
|
131 |
+
}
|
132 |
+
|
133 |
+
protected function _getCurrentProductId() {
|
134 |
+
if($product = Mage::registry('product'))
|
135 |
+
return $product->getSku();
|
136 |
+
return '';
|
137 |
+
}
|
138 |
+
|
139 |
+
protected function _getCurrentProductsIds() {
|
140 |
+
$ids = array();
|
141 |
+
$products = $this->_getProductCollection()->getData();
|
142 |
+
if($products) {
|
143 |
+
foreach ($products as $product) {
|
144 |
+
$ids[] = $product['sku'];
|
145 |
+
}
|
146 |
+
}
|
147 |
+
return implode('|', $ids);
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Retrieve loaded category collection
|
152 |
+
*
|
153 |
+
* @return Mage_Eav_Model_Entity_Collection_Abstract
|
154 |
+
*/
|
155 |
+
protected function _getProductCollection() {
|
156 |
+
if (is_null($this->_productCollection)) {
|
157 |
+
$layer = $this->getLayer();
|
158 |
+
/* @var $layer Mage_Catalog_Model_Layer */
|
159 |
+
if ($this->getShowRootCategory()) {
|
160 |
+
$this->setCategoryId(Mage::app()->getStore()->getRootCategoryId());
|
161 |
+
}
|
162 |
+
|
163 |
+
// if this is a product view page
|
164 |
+
if (Mage::registry('product')) {
|
165 |
+
// get collection of categories this product is associated with
|
166 |
+
$categories = Mage::registry('product')->getCategoryCollection()
|
167 |
+
->setPage(1, 1)
|
168 |
+
->load();
|
169 |
+
// if the product is associated with any category
|
170 |
+
if ($categories->count()) {
|
171 |
+
// show products from this category
|
172 |
+
$this->setCategoryId(current($categories->getIterator()));
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
$origCategory = null;
|
177 |
+
if ($this->getCategoryId()) {
|
178 |
+
$category = Mage::getModel('catalog/category')->load($this->getCategoryId());
|
179 |
+
if ($category->getId()) {
|
180 |
+
$origCategory = $layer->getCurrentCategory();
|
181 |
+
$layer->setCurrentCategory($category);
|
182 |
+
$this->addModelTags($category);
|
183 |
+
}
|
184 |
+
}
|
185 |
+
$this->_productCollection = $layer->getProductCollection();
|
186 |
+
|
187 |
+
$this->prepareSortableFieldsByCategory($layer->getCurrentCategory());
|
188 |
+
|
189 |
+
if ($origCategory) {
|
190 |
+
$layer->setCurrentCategory($origCategory);
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
194 |
+
return $this->_productCollection;
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Get catalog layer model
|
199 |
+
*
|
200 |
+
* @return Mage_Catalog_Model_Layer
|
201 |
+
*/
|
202 |
+
public function getLayer() {
|
203 |
+
$layer = Mage::registry('current_layer');
|
204 |
+
if ($layer) {
|
205 |
+
return $layer;
|
206 |
+
}
|
207 |
+
return Mage::getSingleton('catalog/layer');
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Prepare Sort By fields from Category Data
|
212 |
+
*
|
213 |
+
* @param Mage_Catalog_Model_Category $category
|
214 |
+
* @return Mage_Catalog_Block_Product_List
|
215 |
+
*/
|
216 |
+
public function prepareSortableFieldsByCategory($category) {
|
217 |
+
if (!$this->getAvailableOrders()) {
|
218 |
+
$this->setAvailableOrders($category->getAvailableSortByOptions());
|
219 |
+
}
|
220 |
+
$availableOrders = $this->getAvailableOrders();
|
221 |
+
if (!$this->getSortBy()) {
|
222 |
+
if ($categorySortBy = $category->getDefaultSortBy()) {
|
223 |
+
if (!$availableOrders) {
|
224 |
+
$availableOrders = $this->_getConfig()->getAttributeUsedForSortByArray();
|
225 |
+
}
|
226 |
+
if (isset($availableOrders[$categorySortBy])) {
|
227 |
+
$this->setSortBy($categorySortBy);
|
228 |
+
}
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
return $this;
|
233 |
+
}
|
234 |
+
}
|
app/code/community/Lengow/Tracker/Block/Tag/Simple.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Lengow_Tracker Tracking Block Simple
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Tracker
|
8 |
+
* @author Romain Le Polh <romain@lengow.com>
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Lengow_Tracker_Block_Tag_Simple extends Mage_Core_Block_Template {
|
12 |
+
|
13 |
+
protected $_config_model;
|
14 |
+
protected $_id_client;
|
15 |
+
protected $_id_group;
|
16 |
+
protected $_id_order;
|
17 |
+
protected $_total_paid;
|
18 |
+
protected $_mode_paiement;
|
19 |
+
protected $_ids_products;
|
20 |
+
|
21 |
+
public function __construct() {
|
22 |
+
$this->_config_model = Mage::getSingleton('tracker/config');
|
23 |
+
$this->_id_client = $this->_config_model->get('general/login');
|
24 |
+
$this->_id_group = $this->_config_model->get('general/group');
|
25 |
+
}
|
26 |
+
|
27 |
+
protected function _prepareLayout() {
|
28 |
+
parent::_prepareLayout();
|
29 |
+
$tracker_model = Mage::getSingleton('tracker/tracker');
|
30 |
+
if(Mage::app()->getRequest()->getActionName() == 'success') {
|
31 |
+
$order_id = Mage::getSingleton('checkout/session')->getLastOrderId();
|
32 |
+
$order = Mage::getModel('sales/order')->load($order_id);
|
33 |
+
$this->_mode_paiement = $order->getPayment()->getMethodInstance()->getCode();
|
34 |
+
$this->_id_order = $order_id;
|
35 |
+
$this->_total_paid = $order->getGrandTotal();
|
36 |
+
$this->_ids_products = $tracker_model->getIdsProducts($order);
|
37 |
+
$this->setTemplate('lengow/tracker/simpletag.phtml');
|
38 |
+
}
|
39 |
+
return $this;
|
40 |
+
}
|
41 |
+
|
42 |
+
}
|
app/code/community/Lengow/Tracker/Block/Tracker.php
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Lengow_Tracker Tracking Block
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Tracker
|
8 |
+
* @author Romain Le Polh <romain@lengow.com>
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Lengow_Tracker_Block_Tracker extends Mage_Core_Block_Template {
|
12 |
+
|
13 |
+
const URI_TAG_CAPSULE = 'https://tracking.lengow.com/tagcapsule.js';
|
14 |
+
const BLOCK_SIMPLE = 'tracker/tag_simple';
|
15 |
+
const BLOCK_CAPSULE = 'tracker/tag_capsule';
|
16 |
+
|
17 |
+
protected $_id_client;
|
18 |
+
protected $_id_group;
|
19 |
+
protected $_tag;
|
20 |
+
|
21 |
+
protected function _construct() {
|
22 |
+
$config_model = Mage::getSingleton('tracker/config');
|
23 |
+
|
24 |
+
$this->_id_client = $config_model->get('general/login');
|
25 |
+
$this->_id_group = $config_model->get('general/group');
|
26 |
+
$this->_tag = $config_model->get('tag/type');
|
27 |
+
|
28 |
+
}
|
29 |
+
|
30 |
+
protected function _prepareLayout()
|
31 |
+
{
|
32 |
+
parent::_prepareLayout();
|
33 |
+
if($this->_tag == 'tagcapsule')
|
34 |
+
$this->setChild('tracker', $this->getLayout()->createBlock(self::BLOCK_CAPSULE, 'tag_capsule'));
|
35 |
+
elseif($this->_tag == 'simpletag')
|
36 |
+
$this->setChild('tracker', $this->getLayout()->createBlock(self::BLOCK_SIMPLE, 'simple_tag'));
|
37 |
+
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Prepare and return block's html output
|
43 |
+
*
|
44 |
+
* @return string
|
45 |
+
*/
|
46 |
+
protected function _toHtml() {
|
47 |
+
return parent::_toHtml();
|
48 |
+
}
|
49 |
+
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Retrieve Page Type
|
55 |
+
*
|
56 |
+
* @return string
|
57 |
+
*/
|
58 |
+
public function getPage() {
|
59 |
+
if (!$this->hasData('page')) {
|
60 |
+
|
61 |
+
$this->setPage('page'); //by default
|
62 |
+
|
63 |
+
$handles = $this->getLayout()->getUpdate()->getHandles();
|
64 |
+
|
65 |
+
if (in_array('cms_index_index', $handles))
|
66 |
+
$this->setPage('homepage');
|
67 |
+
|
68 |
+
if (in_array('checkout_onepage_success', $handles))
|
69 |
+
$this->setPage('confirmation');
|
70 |
+
|
71 |
+
if (in_array('catalog_category_view', $handles))
|
72 |
+
$this->setPage('listepage');
|
73 |
+
|
74 |
+
if (in_array('checkout_cart_index', $handles))
|
75 |
+
$this->setPage('basket');
|
76 |
+
}
|
77 |
+
return $this->getData('page');
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Retrieve if SSL is used for display tag capsule
|
82 |
+
*
|
83 |
+
* @return string
|
84 |
+
*/
|
85 |
+
public function useSSL() {
|
86 |
+
if (!$this->hasData('use_ssl')) {
|
87 |
+
$this->setUseSsl(Mage::getStoreConfig('lengow_export/general/ssl_tagcapsule'));
|
88 |
+
}
|
89 |
+
return $this->getData('use_ssl') == true ? 'true' : 'false';
|
90 |
+
}
|
91 |
+
|
92 |
+
}
|
app/code/community/Lengow/Tracker/Helper/Check.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow sync helper data
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Tracker
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2014 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Tracker_Helper_Check extends Mage_Core_Helper_Abstract {
|
12 |
+
|
13 |
+
const PLUGIN_NAME = 'magento';
|
14 |
+
|
15 |
+
const URI_TAG_CAPSULE = 'plugins.xml';
|
16 |
+
|
17 |
+
const LENGOW_PLUGINS_VERSION = 'http://kml.lengow.com/plugins.xml';
|
18 |
+
|
19 |
+
protected $_dom;
|
20 |
+
|
21 |
+
public function getVersion() {
|
22 |
+
$this->updatePluginsVersion();
|
23 |
+
return (string) Mage::getConfig()->getNode()->modules->Lengow_Tracker->version;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function getLastVersion() {
|
27 |
+
$this->_loadDom();
|
28 |
+
// Compare version
|
29 |
+
$object = $this->_dom->xpath('/plugins/plugin[@name=\'' . self::PLUGIN_NAME . '\']');
|
30 |
+
if(!empty($object))
|
31 |
+
return $object[0]->version;
|
32 |
+
else
|
33 |
+
return 'NULL';
|
34 |
+
}
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Check and update xml of plugins version
|
39 |
+
*
|
40 |
+
* @return boolean
|
41 |
+
*/
|
42 |
+
public static function updatePluginsVersion() {
|
43 |
+
$mp_update = Mage::getModel('tracker/config')->get('hidden/last_synchro');
|
44 |
+
if (!$mp_update || !$mp_update == '0000-00-00' ||$mp_update != date('Y-m-d')) {
|
45 |
+
$sep = DS;
|
46 |
+
if ($xml = fopen(self::LENGOW_PLUGINS_VERSION, 'r')) {
|
47 |
+
$handle = fopen(Mage::getModuleDir('etc', 'Lengow_Tracker') . DS . self::URI_TAG_CAPSULE . '', 'w');
|
48 |
+
stream_copy_to_stream($xml, $handle);
|
49 |
+
fclose($handle);
|
50 |
+
Mage::getModel('core/config')->saveConfig('tracker/hidden/last_synchro', date('Y-m-d'));
|
51 |
+
}
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Check module version
|
57 |
+
*
|
58 |
+
* @return boolean true if up to date, false if old version currently installed
|
59 |
+
*/
|
60 |
+
public function checkPluginVersion($current_version = null) {
|
61 |
+
if($current_version == null)
|
62 |
+
return false;
|
63 |
+
$this->_loadDom();
|
64 |
+
// Compare version
|
65 |
+
$object = $this->_dom->xpath('/plugins/plugin[@name=\'' . self::PLUGIN_NAME . '\']');
|
66 |
+
if(!empty($object)) {
|
67 |
+
$plugin = $object[0];
|
68 |
+
if(version_compare($current_version, $plugin->version, '<')) {
|
69 |
+
return false;
|
70 |
+
} else {
|
71 |
+
return true;
|
72 |
+
}
|
73 |
+
}
|
74 |
+
return true;
|
75 |
+
}
|
76 |
+
|
77 |
+
public function getRealIP() {
|
78 |
+
return $_SERVER['REMOTE_ADDR'];
|
79 |
+
}
|
80 |
+
|
81 |
+
private function _loadDom() {
|
82 |
+
if(!$this->_dom)
|
83 |
+
$this->_dom = simplexml_load_file(Mage::getModuleDir('etc', 'Lengow_Tracker') . DS . self::URI_TAG_CAPSULE );
|
84 |
+
}
|
85 |
+
|
86 |
+
}
|
app/code/community/Lengow/Tracker/Helper/Data.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Lengow sync helper data
|
4 |
+
*
|
5 |
+
* @category Lengow
|
6 |
+
* @package Lengow_Sync
|
7 |
+
* @author Ludovic Drin <ludovic@lengow.com>
|
8 |
+
* @copyright 2013 Lengow SAS
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
*/
|
11 |
+
class Lengow_Tracker_Helper_Data extends Mage_Core_Helper_Abstract {
|
12 |
+
|
13 |
+
}
|
app/code/community/Lengow/Tracker/Model/Capsule.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Lengow tracker model tracker
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Tracker
|
8 |
+
* @author Romain Le Polh <romain@lengow.com>
|
9 |
+
* @copyright 2013 Lengow SAS
|
10 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
11 |
+
*/
|
12 |
+
class Lengow_Tracker_Model_Capsule extends Lengow_Tracker_Model_Tracker {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Return product quote or order
|
16 |
+
*
|
17 |
+
* @param $quote Order or Quote
|
18 |
+
* @return string i(n)=(id_product_n)&p(n)=(unit_price_n)&q(n)=(quantity_n)
|
19 |
+
*/
|
20 |
+
public function getProductsCart($quote) {
|
21 |
+
if($quote instanceof Mage_Sales_Model_Quote || $quote instanceof Mage_Sales_Model_Order) {
|
22 |
+
$quote_items = $quote->getAllVisibleItems();
|
23 |
+
$list_products = array();
|
24 |
+
$i = 1;
|
25 |
+
foreach($quote_items as $item) {
|
26 |
+
$str = 'i'.$i.'='.$item->getSku();
|
27 |
+
$str .= '&p'.$i.'='.$item->getPrice();
|
28 |
+
$str .= '&q'.$i.'='.$item->getQty();
|
29 |
+
$list_products[] = $str;
|
30 |
+
$i++;
|
31 |
+
}
|
32 |
+
return implode('&', $list_products);
|
33 |
+
}
|
34 |
+
return;
|
35 |
+
}
|
36 |
+
|
37 |
+
}
|
app/code/community/Lengow/Tracker/Model/Config.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Lengow export model config
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Tracker
|
8 |
+
* @author Romain Le Polh <romain@lengow.com>
|
9 |
+
* @copyright 2013 Lengow SAS
|
10 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
11 |
+
*/
|
12 |
+
class Lengow_Tracker_Model_Config extends Varien_Object {
|
13 |
+
|
14 |
+
public function setStore($id_store) {
|
15 |
+
$this->_id_store = $id_store;
|
16 |
+
}
|
17 |
+
|
18 |
+
public function get($key) {
|
19 |
+
return Mage::getStoreConfig('tracker/' . $key, $this->_id_store);
|
20 |
+
}
|
21 |
+
|
22 |
+
}
|
app/code/community/Lengow/Tracker/Model/System/Config/Source/Tracker.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Lengow_Tracker_Model_System_Config_Source_Tracker extends Mage_Core_Model_Config_Data {
|
4 |
+
|
5 |
+
public function toOptionArray() {
|
6 |
+
return array(
|
7 |
+
array('value' => 'none', 'label' => Mage::helper('adminhtml')->__('Aucun')),
|
8 |
+
array('value' => 'simpletag', 'label' => Mage::helper('adminhtml')->__('SimpleTag')),
|
9 |
+
array('value' => 'tagcapsule', 'label' => Mage::helper('adminhtml')->__('TagCapsule')),
|
10 |
+
);
|
11 |
+
}
|
12 |
+
|
13 |
+
}
|
app/code/community/Lengow/Tracker/Model/Tracker.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Lengow tracker model tracker
|
5 |
+
*
|
6 |
+
* @category Lengow
|
7 |
+
* @package Lengow_Export
|
8 |
+
* @author Romain Le Polh <romain@lengow.com>
|
9 |
+
* @copyright 2013 Lengow SAS
|
10 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
11 |
+
*/
|
12 |
+
class Lengow_Tracker_Model_Tracker extends Varien_Object {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Return list of order's items id
|
16 |
+
*
|
17 |
+
* @param $order Mage_Sales_Model_Order
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
public function getIdsProducts($quote) {
|
21 |
+
if($quote instanceof Mage_Sales_Model_Order || $quote instanceof Mage_Sales_Model_Quote) {
|
22 |
+
$quote_items = $quote->getAllVisibleItems();
|
23 |
+
$ids = array();
|
24 |
+
foreach($quote_items as $item) {
|
25 |
+
$ids[] = $item->getSku();
|
26 |
+
}
|
27 |
+
return implode('|', $ids);
|
28 |
+
}
|
29 |
+
return false;
|
30 |
+
}
|
31 |
+
|
32 |
+
}
|
app/code/community/Lengow/Tracker/etc/.DS_Store
ADDED
Binary file
|
app/code/community/Lengow/Tracker/etc/config.xml
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Lengow_Tracker>
|
5 |
+
<version>2.0.1.0</version>
|
6 |
+
</Lengow_Tracker>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<tracker>
|
11 |
+
<class>Lengow_Tracker_Model</class>
|
12 |
+
</tracker>
|
13 |
+
</models>
|
14 |
+
<blocks>
|
15 |
+
<tracker>
|
16 |
+
<class>Lengow_Tracker_Block</class>
|
17 |
+
</tracker>
|
18 |
+
</blocks>
|
19 |
+
<helpers>
|
20 |
+
<tracker>
|
21 |
+
<class>Lengow_Tracker_Helper</class>
|
22 |
+
</tracker>
|
23 |
+
</helpers>
|
24 |
+
<resources>
|
25 |
+
<tracker_setup>
|
26 |
+
<setup>
|
27 |
+
<module>Lengow_Tracker</module>
|
28 |
+
</setup>
|
29 |
+
<connection>
|
30 |
+
<use>core_setup</use>
|
31 |
+
</connection>
|
32 |
+
</tracker_setup>
|
33 |
+
<tracker_write>
|
34 |
+
<connection>
|
35 |
+
<use>core_write</use>
|
36 |
+
</connection>
|
37 |
+
</tracker_write>
|
38 |
+
<tracker_read>
|
39 |
+
<connection>
|
40 |
+
<use>core_read</use>
|
41 |
+
</connection>
|
42 |
+
</tracker_read>
|
43 |
+
</resources>
|
44 |
+
</global>
|
45 |
+
<admin>
|
46 |
+
<routers>
|
47 |
+
<adminhtml>
|
48 |
+
<args>
|
49 |
+
<modules>
|
50 |
+
<tracker before="Mage_Adminhtml">Lengow_Tracker_Adminhtml</tracker>
|
51 |
+
</modules>
|
52 |
+
</args>
|
53 |
+
</adminhtml>
|
54 |
+
</routers>
|
55 |
+
</admin>
|
56 |
+
<frontend>
|
57 |
+
<routers>
|
58 |
+
<lengow>
|
59 |
+
<use>standard</use>
|
60 |
+
<args>
|
61 |
+
<module>Lengow_Tracker</module>
|
62 |
+
<frontName>lengow</frontName>
|
63 |
+
</args>
|
64 |
+
</lengow>
|
65 |
+
</routers>
|
66 |
+
<layout>
|
67 |
+
<updates>
|
68 |
+
<tracker>
|
69 |
+
<file>lengow.xml</file>
|
70 |
+
</tracker>
|
71 |
+
</updates>
|
72 |
+
</layout>
|
73 |
+
</frontend>
|
74 |
+
<adminhtml>
|
75 |
+
<layout>
|
76 |
+
<updates>
|
77 |
+
<lengow>
|
78 |
+
<file>lengow.xml</file>
|
79 |
+
</lengow>
|
80 |
+
</updates>
|
81 |
+
</layout>
|
82 |
+
<translate>
|
83 |
+
<modules>
|
84 |
+
<Lengow_Tracker>
|
85 |
+
<files>
|
86 |
+
<default>Lengow_Connector.csv</default>
|
87 |
+
</files>
|
88 |
+
</Lengow_Tracker>
|
89 |
+
</modules>
|
90 |
+
</translate>
|
91 |
+
<acl>
|
92 |
+
<resources>
|
93 |
+
<admin>
|
94 |
+
<children>
|
95 |
+
<system>
|
96 |
+
<children>
|
97 |
+
<config>
|
98 |
+
<children>
|
99 |
+
<tracker translate="title" module="tracker">
|
100 |
+
<title>Products</title>
|
101 |
+
</tracker>
|
102 |
+
</children>
|
103 |
+
</config>
|
104 |
+
</children>
|
105 |
+
</system>
|
106 |
+
</children>
|
107 |
+
</admin>
|
108 |
+
</resources>
|
109 |
+
</acl>
|
110 |
+
</adminhtml>
|
111 |
+
</config>
|
app/code/community/Lengow/Tracker/etc/plugins.xml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2 |
+
<plugins>
|
3 |
+
<plugin name="prestashop">
|
4 |
+
<version>2.0.4.1</version>
|
5 |
+
<release_date>2014-01-30</release_date>
|
6 |
+
</plugin>
|
7 |
+
<plugin name="magento">
|
8 |
+
<version>2.0.1</version>
|
9 |
+
<release_date>2014-01-30</release_date>
|
10 |
+
</plugin>
|
11 |
+
</plugins>
|
app/code/community/Lengow/Tracker/etc/system.xml
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<lengow translate="label" module="tracker">
|
5 |
+
<label>Lengow</label>
|
6 |
+
<sort_order>210</sort_order>
|
7 |
+
</lengow>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<tracker translate="label" module="tracker">
|
11 |
+
<label>Customer Account</label>
|
12 |
+
<tab>lengow</tab>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>89</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>1</show_in_store>
|
18 |
+
<groups>
|
19 |
+
<check translate="label, comment">
|
20 |
+
<label/>
|
21 |
+
<frontend_type>note</frontend_type>
|
22 |
+
<frontend_model>Lengow_Tracker_Block_Adminhtml_System_Config_Check</frontend_model>
|
23 |
+
<sort_order>-1</sort_order>
|
24 |
+
<show_in_default>1</show_in_default>
|
25 |
+
<show_in_website>0</show_in_website>
|
26 |
+
<show_in_store>0</show_in_store>
|
27 |
+
</check>
|
28 |
+
<general translate="label, comment">
|
29 |
+
<label>Lengow API and TagCapsule</label>
|
30 |
+
<show_in_default>1</show_in_default>
|
31 |
+
<show_in_website>1</show_in_website>
|
32 |
+
<show_in_store>1</show_in_store>
|
33 |
+
<sort_order>1</sort_order>
|
34 |
+
<fields>
|
35 |
+
<login>
|
36 |
+
<label>Customer ID</label>
|
37 |
+
<comment>Your Customer ID of Lengow</comment>
|
38 |
+
<frontend_type>text</frontend_type>
|
39 |
+
<sort_order>3</sort_order>
|
40 |
+
<show_in_default>1</show_in_default>
|
41 |
+
<show_in_website>1</show_in_website>
|
42 |
+
<show_in_store>1</show_in_store>
|
43 |
+
</login>
|
44 |
+
<group>
|
45 |
+
<label>Group ID</label>
|
46 |
+
<comment>Your Group ID of Lengow</comment>
|
47 |
+
<frontend_type>text</frontend_type>
|
48 |
+
<sort_order>5</sort_order>
|
49 |
+
<show_in_default>1</show_in_default>
|
50 |
+
<show_in_website>1</show_in_website>
|
51 |
+
<show_in_store>1</show_in_store>
|
52 |
+
</group>
|
53 |
+
<api_key>
|
54 |
+
<label>Token API</label>
|
55 |
+
<frontend_type>text</frontend_type>
|
56 |
+
<sort_order>20</sort_order>
|
57 |
+
<show_in_default>1</show_in_default>
|
58 |
+
<show_in_website>0</show_in_website>
|
59 |
+
<show_in_store>0</show_in_store>
|
60 |
+
</api_key>
|
61 |
+
</fields>
|
62 |
+
</general>
|
63 |
+
<tag translate="label, comment">
|
64 |
+
<label>TagCapsule</label>
|
65 |
+
<show_in_default>1</show_in_default>
|
66 |
+
<show_in_website>1</show_in_website>
|
67 |
+
<show_in_store>1</show_in_store>
|
68 |
+
<sort_order>2</sort_order>
|
69 |
+
<fields>
|
70 |
+
<type>
|
71 |
+
<label>Tracker Type</label>
|
72 |
+
<frontend_type>select</frontend_type>
|
73 |
+
<source_model>Lengow_Tracker_Model_System_Config_Source_Tracker</source_model>
|
74 |
+
<sort_order>3</sort_order>
|
75 |
+
<show_in_default>1</show_in_default>
|
76 |
+
<show_in_website>1</show_in_website>
|
77 |
+
<show_in_store>1</show_in_store>
|
78 |
+
</type>
|
79 |
+
</fields>
|
80 |
+
</tag>
|
81 |
+
<hidden translate="label, comment">
|
82 |
+
<label>Hidden fields</label>
|
83 |
+
<show_in_default>0</show_in_default>
|
84 |
+
<show_in_website>0</show_in_website>
|
85 |
+
<show_in_store>0</show_in_store>
|
86 |
+
<sort_order>1</sort_order>
|
87 |
+
<fields>
|
88 |
+
<last_synchro>
|
89 |
+
<label>Date of plugins.xml synchro</label>
|
90 |
+
<sort_order>1</sort_order>
|
91 |
+
<show_in_default>0</show_in_default>
|
92 |
+
<show_in_website>0</show_in_website>
|
93 |
+
<show_in_store>0</show_in_store>
|
94 |
+
<comment>Last date of plugins.xml synchronisation</comment>
|
95 |
+
</last_synchro>
|
96 |
+
</fields>
|
97 |
+
</hidden>
|
98 |
+
</groups>
|
99 |
+
</tracker>
|
100 |
+
</sections>
|
101 |
+
</config>
|
app/code/local/Lengow/Export/Helper/Data.php
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Lengow_Export_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
-
{
|
4 |
-
}
|
|
|
|
|
|
|
|
app/code/local/Lengow/Export/Model/Observer.php
DELETED
File without changes
|
app/code/local/Lengow/Export/Model/Products.php
DELETED
@@ -1,96 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Lengow_Model_Products extends Mage_Core_Model_Abstract {
|
4 |
-
|
5 |
-
public function getProducts() {
|
6 |
-
$products = Mage::getResourceModel('catalog/product_collection')
|
7 |
-
->addAttributeToFilter('status',1)
|
8 |
-
->addAttributeToFilter('visibility',array('in'=>array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)))
|
9 |
-
->addAttributeToFilter('price',array('neq'=>0))
|
10 |
-
->addAttributeToSelect('name')
|
11 |
-
->addAttributeToSelect('weight')
|
12 |
-
->addAttributeToSelect('sku')
|
13 |
-
->addAttributeToSelect('price')
|
14 |
-
->addAttributeToSelect('special_price')
|
15 |
-
->addAttributeToSelect('small_image')
|
16 |
-
->addAttributeToSelect(Mage::getStoreConfig('lengow/flux/description'))
|
17 |
-
->addStoreFilter();
|
18 |
-
|
19 |
-
$attributes = explode(',',Mage::getStoreConfig('lengow/flux/attributes'));
|
20 |
-
foreach($attributes as $a) $products->addAttributeToSelect($a);
|
21 |
-
|
22 |
-
if(Mage::getStoreConfig('lengow/flux/debug_flux')) $products->setPageSize(10);
|
23 |
-
|
24 |
-
return $products;
|
25 |
-
}
|
26 |
-
|
27 |
-
public function f($tagName,$content,$data=0) {
|
28 |
-
$result = '<'.$tagName.'>';
|
29 |
-
if($data) $result .= '<![CDATA[';
|
30 |
-
$result .= preg_replace('(^'.Mage::helper('lengow')->__('No').'$)','',trim($content));
|
31 |
-
if($data) $result .= ']]>';
|
32 |
-
$result .= '</'.$tagName.'>';
|
33 |
-
return $result;
|
34 |
-
}
|
35 |
-
|
36 |
-
public function getQty($id,$qty=0) {
|
37 |
-
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($id);
|
38 |
-
if($stockItem->getManageStock()) {
|
39 |
-
if($stockItem->getIsInStock()) {
|
40 |
-
$qty = intval($stockItem->getQty());
|
41 |
-
$qty = ($qty <= 0) ? 0 : $qty;
|
42 |
-
}
|
43 |
-
} else {
|
44 |
-
$qty = 100;
|
45 |
-
}
|
46 |
-
return $qty;
|
47 |
-
}
|
48 |
-
|
49 |
-
public function getWeight($weight,$tablerates) {
|
50 |
-
$shipping_amount = 0;
|
51 |
-
|
52 |
-
if($tablerates && $tablerates instanceof Mage_Shipping_Model_Mysql4_Carrier_Tablerate_Collection) {
|
53 |
-
foreach($tablerates as $t) {
|
54 |
-
if($weight <= $t->getConditionValue()) $shipping_amount = $t->getPrice();
|
55 |
-
}
|
56 |
-
} else {
|
57 |
-
$shipping_amount = preg_replace('(\,+)','.',trim(Mage::getStoreConfig('lengow/flux/ship')));
|
58 |
-
if(!is_numeric($shipping_amount)) $shipping_amount = 0;
|
59 |
-
}
|
60 |
-
return $shipping_amount;
|
61 |
-
}
|
62 |
-
|
63 |
-
public function getTablerates() {
|
64 |
-
return Mage::getResourceModel('shipping/carrier_tablerate_collection')->setOrder('condition_value','desc');
|
65 |
-
}
|
66 |
-
|
67 |
-
public function getIsStock($qty) {
|
68 |
-
return ($qty > 0) ? Mage::helper('lengow')->__('In Stock') : Mage::helper('lengow')->__('Out of Stock');
|
69 |
-
}
|
70 |
-
|
71 |
-
public function getLivraison($qty) {
|
72 |
-
return ($qty > 0) ? Mage::getStoreConfig('lengow/flux/days_in') : Mage::getStoreConfig('lengow/flux/days_out');
|
73 |
-
}
|
74 |
-
|
75 |
-
public function getCategoriesAsArray($categories,$parent='',&$cats=array()) {
|
76 |
-
foreach($categories as $c) {
|
77 |
-
$cats[$c['entity_id']] = $parent.$c['name'];
|
78 |
-
if(isset($c['children_nodes'])) {
|
79 |
-
$this->getCategoriesAsArray($c['children_nodes'],$parent.$c['name'].'||',$cats);
|
80 |
-
}
|
81 |
-
}
|
82 |
-
return $cats;
|
83 |
-
}
|
84 |
-
|
85 |
-
public function getProductsCategories($product,$sc) {
|
86 |
-
$categories = $product->getCategoryIds();
|
87 |
-
$result = array();
|
88 |
-
if(count($categories)) {
|
89 |
-
if(isset($sc[$categories[(count($categories)-1)]])) $result = explode('||',$sc[$categories[(count($categories)-1)]]);
|
90 |
-
}
|
91 |
-
return $result;
|
92 |
-
}
|
93 |
-
|
94 |
-
public function getStore() { return Mage::app()->getStore(); }
|
95 |
-
|
96 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Lengow/Export/Model/System/Config/Source/Attributes.php
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Lengow_Model_System_Config_Source_Attributes {
|
4 |
-
|
5 |
-
public function toOptionArray() {
|
6 |
-
|
7 |
-
$attribute = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId());
|
8 |
-
$attributeArray = array();
|
9 |
-
|
10 |
-
foreach ($attribute as $option) {
|
11 |
-
if($option->getIsUserDefined() && $option->getFrontendLabel()) {
|
12 |
-
$attributeArray[] = array('value'=>$option->getAttributeCode(),'label'=>$option->getAttributeCode());
|
13 |
-
}
|
14 |
-
}
|
15 |
-
|
16 |
-
return $attributeArray;
|
17 |
-
}
|
18 |
-
|
19 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Lengow/Export/Model/System/Config/Source/Categories.php
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Lengow_Export_Model_System_Config_Source_Categories {
|
4 |
-
|
5 |
-
public function toOptionArray() {
|
6 |
-
|
7 |
-
$attribute = Mage::getResourceModel('eav/entity_attribute_collection')->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId());
|
8 |
-
$attributeArray = array();
|
9 |
-
|
10 |
-
foreach ($attribute as $option) {
|
11 |
-
if($option->getIsUserDefined() && $option->getFrontendLabel()) {
|
12 |
-
$attributeArray[] = array('value'=>$option->getAttributeCode(),'label'=>$option->getAttributeCode());
|
13 |
-
}
|
14 |
-
}
|
15 |
-
|
16 |
-
return $attributeArray;
|
17 |
-
}
|
18 |
-
|
19 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Lengow/Export/Model/System/Config/Source/Description.php
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Lengow_Model_System_Config_Source_Description {
|
4 |
-
|
5 |
-
public function toOptionArray() {
|
6 |
-
return array(
|
7 |
-
array('value'=>'short_description', 'label'=>Mage::helper('lengow')->__('Short Description')),
|
8 |
-
array('value'=>'description', 'label'=>Mage::helper('lengow')->__('Description')),
|
9 |
-
array('value'=>'meta_description', 'label'=>Mage::helper('lengow')->__('Meta Description')),
|
10 |
-
);
|
11 |
-
}
|
12 |
-
|
13 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Lengow/Export/Model/System/Config/Source/Price.php
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Lengow_Model_System_Config_Source_Price {
|
4 |
-
|
5 |
-
public function toOptionArray() {
|
6 |
-
return array(
|
7 |
-
array('value'=>1, 'label'=>Mage::helper('lengow')->__('HT')),
|
8 |
-
array('value'=>0, 'label'=>Mage::helper('lengow')->__('TTC')),
|
9 |
-
);
|
10 |
-
}
|
11 |
-
|
12 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Lengow/Export/controllers/IndexController.php
DELETED
@@ -1,165 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Lengow_Export_IndexController extends Mage_Core_Controller_Front_Action
|
4 |
-
{
|
5 |
-
public function IndexAction()
|
6 |
-
{
|
7 |
-
if(@!isset($_GET['storeID']))
|
8 |
-
$store= 0;
|
9 |
-
else
|
10 |
-
$store=$_GET['storeID'];
|
11 |
-
$this->GetHeader($this->getContent($_GET['format'],$store),$_GET['format']);
|
12 |
-
}
|
13 |
-
|
14 |
-
protected function GetHeader($content, $format = 'csv', $contentType = 'text/plain', $contentLength = null)
|
15 |
-
{
|
16 |
-
if( ($format =='csv') || ($format =='txt'))
|
17 |
-
$contentType='text/plain';
|
18 |
-
elseif($format =='xml')
|
19 |
-
$contentType='text/xml';
|
20 |
-
else
|
21 |
-
exit();
|
22 |
-
$this->getResponse()
|
23 |
-
->setHttpResponseCode(200)
|
24 |
-
->setHeader('Pragma', 'public', true)
|
25 |
-
->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
|
26 |
-
->setHeader('Content-type', $contentType, true)
|
27 |
-
->setHeader('Content-Length', strlen($content))
|
28 |
-
->setBody($content);
|
29 |
-
}
|
30 |
-
|
31 |
-
public function getContent($contentType = 'csv', $storeID = 0)
|
32 |
-
{
|
33 |
-
set_time_limit(0);
|
34 |
-
ini_set('memory_limit', '256M');
|
35 |
-
ini_set('display_errors', 1);
|
36 |
-
error_reporting(E_ALL ^ E_NOTICE);
|
37 |
-
|
38 |
-
require_once 'app/Mage.php';
|
39 |
-
Mage::app('default');
|
40 |
-
try
|
41 |
-
{
|
42 |
-
$products = Mage::getModel('catalog/product')->getCollection();
|
43 |
-
// $products
|
44 |
-
if($storeID != 0)
|
45 |
-
{
|
46 |
-
$products->addStoreFilter($storeID);
|
47 |
-
$products->joinAttribute('description', 'catalog_product/description', 'entity_id', null, 'inner', $storeID);
|
48 |
-
}
|
49 |
-
$products->addAttributeToFilter('status', 1);//enabled
|
50 |
-
$products->addAttributeToFilter('visibility', 4);//catalog, search
|
51 |
-
$products->addAttributeToSelect('*');
|
52 |
-
$prodIds=$products->getAllIds();
|
53 |
-
|
54 |
-
//$product = Mage::getModel('catalog/product');
|
55 |
-
$heading = array('ID','WEIGHT','MANUFACTURER','NAME','DESCRIPTION','PRICE','PRICE_PROMO','PROMO_FROM','PROMO_TO','STOCK','QUANTITY','URL','IMAGE','FDP','CATEGORY');
|
56 |
-
|
57 |
-
//setEntityTypeFilter(4) => Product Entity
|
58 |
-
$attributesInfo = Mage::getResourceModel('eav/entity_attribute_collection')
|
59 |
-
->setEntityTypeFilter(4)
|
60 |
-
->addSetInfo()
|
61 |
-
->getData();
|
62 |
-
foreach($attributesInfo as $attribute)
|
63 |
-
{
|
64 |
-
$code = $attribute['attribute_code'];
|
65 |
-
$is_user_defined = $attribute['is_user_defined'];
|
66 |
-
if($is_user_defined==1)
|
67 |
-
{
|
68 |
-
if(!in_array('ATT_'.strtoupper($code), $heading))
|
69 |
-
{
|
70 |
-
array_push($heading, 'ATT_'.strtoupper($code));
|
71 |
-
}
|
72 |
-
}
|
73 |
-
}
|
74 |
-
if( ($contentType =='csv') || ($contentType =='txt'))
|
75 |
-
{
|
76 |
-
$feed_line=implode("|", $heading)."\r\n";
|
77 |
-
}
|
78 |
-
elseif($contentType =='xml')
|
79 |
-
{
|
80 |
-
$feed_line='<?xml version="1.0" encoding="utf-8"?>'.PHP_EOL.'<catalog>'.PHP_EOL;
|
81 |
-
}
|
82 |
-
else
|
83 |
-
{
|
84 |
-
exit();
|
85 |
-
}
|
86 |
-
$buffer = $feed_line;
|
87 |
-
|
88 |
-
foreach($prodIds as $productId)
|
89 |
-
{
|
90 |
-
$product = Mage::getModel('catalog/product');
|
91 |
-
$product->load($productId);
|
92 |
-
|
93 |
-
$product_data = array();
|
94 |
-
$product_data['sku']=$product->getSku();
|
95 |
-
$product_data['weight']=$product->getWeight();
|
96 |
-
$product_data['brand']=$product->getResource()->getAttribute('manufacturer')->getFrontend()->getValue($product);
|
97 |
-
$product_data['title']=$product->getName();
|
98 |
-
$product_data['description']=$product->getDescription();
|
99 |
-
$product_data['price']=$product->getPrice();
|
100 |
-
$product_data['specialprice']=$product->getSpecialPrice();
|
101 |
-
$product_data['promo_from']=$product->getSpecialFromDate();
|
102 |
-
$product_data['promo_to']=$product->getSpecialToDate();
|
103 |
-
$product_data['availability']=$product->getStockItem()->getIsInStock();
|
104 |
-
$product_data['stock_descrip']=(int)$product->getStockItem()->getQty();
|
105 |
-
$product_data['link']=$product->getProductUrl();
|
106 |
-
$product_data['image_link']=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$product->getImage();
|
107 |
-
|
108 |
-
$product_data['shipping_rate']='voir site';
|
109 |
-
//GESTION DE LA CATEGORIE
|
110 |
-
$product_type = '';
|
111 |
-
foreach($product->getCategoryIds() as $_categoryId)
|
112 |
-
{
|
113 |
-
$category = Mage::getModel('catalog/category')->load($_categoryId);
|
114 |
-
$product_type .= $category->getName().' > ';
|
115 |
-
}
|
116 |
-
$product_data['category']=rtrim($product_type,' > ');
|
117 |
-
|
118 |
-
foreach($attributesInfo as $attribute)
|
119 |
-
{
|
120 |
-
$code = $attribute['attribute_code'];
|
121 |
-
$is_user_defined = $attribute['is_user_defined'];
|
122 |
-
if($is_user_defined==1)
|
123 |
-
{
|
124 |
-
$value = $product->getResource()->getAttribute($code)->getFrontend()->getValue($product);
|
125 |
-
// echo "code:".($code)." - value:".$value."\n";
|
126 |
-
$product_data[$code]=$value;
|
127 |
-
}
|
128 |
-
}
|
129 |
-
|
130 |
-
foreach($product_data as $k=>$val)
|
131 |
-
{
|
132 |
-
$bad=array('"',"\r\n","\n","\r","\t");
|
133 |
-
$good=array(""," "," "," ","");
|
134 |
-
$product_data[$k] = '"'.str_replace($bad,$good,$val).'"';
|
135 |
-
}
|
136 |
-
|
137 |
-
if( ($contentType =='csv') || ($contentType =='txt'))
|
138 |
-
{
|
139 |
-
$feed_line = implode("|", $product_data)."\r\n";
|
140 |
-
}
|
141 |
-
elseif($contentType =='xml')
|
142 |
-
{
|
143 |
-
$feed_line = '<product> ';
|
144 |
-
foreach($product_data as $k=>$val)
|
145 |
-
{
|
146 |
-
$feed_line .= '<'.$k.'><![CDATA['.$val.']]></'.$k.'>'.PHP_EOL;
|
147 |
-
}
|
148 |
-
$feed_line .= '</product>'.PHP_EOL;
|
149 |
-
}
|
150 |
-
else
|
151 |
-
exit();
|
152 |
-
$buffer .= $feed_line;
|
153 |
-
unset($product_data);
|
154 |
-
unset($product);
|
155 |
-
}
|
156 |
-
if($contentType == 'xml')
|
157 |
-
$buffer .='</catalog>';
|
158 |
-
return $buffer;
|
159 |
-
}
|
160 |
-
catch(Exception $e)
|
161 |
-
{
|
162 |
-
die($e->getMessage());
|
163 |
-
}
|
164 |
-
}
|
165 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Lengow/Export/etc/config.xml
DELETED
@@ -1,55 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<modules>
|
4 |
-
<Lengow_Export>
|
5 |
-
<version>1.0.0</version>
|
6 |
-
<depends>
|
7 |
-
<!-- no dependencies -->
|
8 |
-
</depends>
|
9 |
-
</Lengow_Export>
|
10 |
-
</modules>
|
11 |
-
|
12 |
-
<global>
|
13 |
-
<helpers>
|
14 |
-
<export>
|
15 |
-
<class>Lengow_Export_Helper</class>
|
16 |
-
</export>
|
17 |
-
</helpers>
|
18 |
-
</global>
|
19 |
-
|
20 |
-
<frontend>
|
21 |
-
<routers>
|
22 |
-
<export>
|
23 |
-
<use>standard</use>
|
24 |
-
<args>
|
25 |
-
<module>Lengow_Export</module>
|
26 |
-
<frontName>export</frontName>
|
27 |
-
</args>
|
28 |
-
</export>
|
29 |
-
</routers>
|
30 |
-
</frontend>
|
31 |
-
<adminhtml>
|
32 |
-
<acl>
|
33 |
-
<resources>
|
34 |
-
<all>
|
35 |
-
<title>Allow Everything</title>
|
36 |
-
</all>
|
37 |
-
<admin>
|
38 |
-
<children>
|
39 |
-
<system>
|
40 |
-
<children>
|
41 |
-
<config>
|
42 |
-
<children>
|
43 |
-
<export>
|
44 |
-
<title>LENGOW - Export Catalogue produit</title>
|
45 |
-
</export>
|
46 |
-
</children>
|
47 |
-
</config>
|
48 |
-
</children>
|
49 |
-
</system>
|
50 |
-
</children>
|
51 |
-
</admin>
|
52 |
-
</resources>
|
53 |
-
</acl>
|
54 |
-
</adminhtml>
|
55 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Lengow/Export/etc/system.xml
DELETED
@@ -1,41 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<tabs>
|
4 |
-
<lengow translate="label" module="export">
|
5 |
-
<label>Solution Lengow</label>
|
6 |
-
<sort_order>100</sort_order>
|
7 |
-
</lengow>
|
8 |
-
</tabs>
|
9 |
-
|
10 |
-
<sections>
|
11 |
-
<export translate="label" module="export">
|
12 |
-
<label>Exportez votre Catalogue</label>
|
13 |
-
<tab>lengow</tab>
|
14 |
-
<frontend_type>text</frontend_type>
|
15 |
-
<sort_order>910</sort_order>
|
16 |
-
<show_in_default>1</show_in_default>
|
17 |
-
<show_in_website>1</show_in_website>
|
18 |
-
<show_in_store>1</show_in_store>
|
19 |
-
<groups>
|
20 |
-
<url translate="label">
|
21 |
-
<label>Exportez votre catalogue produits :</label>
|
22 |
-
<comment>
|
23 |
-
<![CDATA[<b>URL de votre catalogue produit :</b> <br /><br />
|
24 |
-
• Format CSV : <span style="font-family:Courier;font-size:11px">http://www.votre-boutique.com/index.php/export/index?format=csv</span><br />
|
25 |
-
• Format XML : <span style="font-family:Courier;font-size:11px">http://www.votre-boutique.com/index.php/export/index?format=xml</span><br />
|
26 |
-
<br />
|
27 |
-
<br />
|
28 |
-
<b>Multi Store :</b>
|
29 |
-
<br />
|
30 |
-
<br />
|
31 |
-
Dans le cas d'un multi store, vous pouvez exporter séparement les catalogues en ajoutant la variable storeID à la fin de l'url catalogue, storeID correspondant à l'identifiant de votre store.
|
32 |
-
<br />exemple : <span style="font-family:Courier;font-size:11px">http://www.votre-boutique.com/index.php/export/index?format=csv<span style="color:red">&storeID=2</span></span>]]>
|
33 |
-
</comment>
|
34 |
-
<sort_order>200</sort_order>
|
35 |
-
<show_in_default>1</show_in_default>
|
36 |
-
<show_in_website>1</show_in_website>
|
37 |
-
</url>
|
38 |
-
</groups>
|
39 |
-
</export>
|
40 |
-
</sections>
|
41 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Lengow/Information/Helper/Data.php
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Lengow_Information_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
-
{
|
4 |
-
}
|
|
|
|
|
|
|
|
app/code/local/Lengow/Information/etc/config.xml
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<modules>
|
4 |
-
<Lengow_Information>
|
5 |
-
<version>1.0.0</version>
|
6 |
-
<depends>
|
7 |
-
<!-- no dependencies -->
|
8 |
-
</depends>
|
9 |
-
</Lengow_Information>
|
10 |
-
</modules>
|
11 |
-
<global>
|
12 |
-
<helpers>
|
13 |
-
<information>
|
14 |
-
<class>Lengow_Information_Helper</class>
|
15 |
-
</information>
|
16 |
-
</helpers>
|
17 |
-
</global>
|
18 |
-
|
19 |
-
<adminhtml>
|
20 |
-
<acl>
|
21 |
-
<resources>
|
22 |
-
<all>
|
23 |
-
<title>Allow Everything</title>
|
24 |
-
</all>
|
25 |
-
<admin>
|
26 |
-
<children>
|
27 |
-
<system>
|
28 |
-
<children>
|
29 |
-
<config>
|
30 |
-
<children>
|
31 |
-
<information>
|
32 |
-
<title>LENGOW - Export Information</title>
|
33 |
-
</information>
|
34 |
-
</children>
|
35 |
-
</config>
|
36 |
-
</children>
|
37 |
-
</system>
|
38 |
-
</children>
|
39 |
-
</admin>
|
40 |
-
</resources>
|
41 |
-
</acl>
|
42 |
-
</adminhtml>
|
43 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/Lengow/Information/etc/system.xml
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<tabs>
|
4 |
-
<lengow translate="label" module="information">
|
5 |
-
<label>Solution Lengow</label>
|
6 |
-
<sort_order>100</sort_order>
|
7 |
-
</lengow>
|
8 |
-
</tabs>
|
9 |
-
|
10 |
-
<sections>
|
11 |
-
<information translate="label" module="information">
|
12 |
-
<label>Informations Lengow</label>
|
13 |
-
<tab>lengow</tab>
|
14 |
-
<frontend_type>text</frontend_type>
|
15 |
-
<sort_order>110</sort_order>
|
16 |
-
<show_in_default>1</show_in_default>
|
17 |
-
<show_in_website>1</show_in_website>
|
18 |
-
<show_in_store>1</show_in_store>
|
19 |
-
<groups>
|
20 |
-
<info translate="label">
|
21 |
-
<label>Informations :</label>
|
22 |
-
<comment>
|
23 |
-
<![CDATA[<b>Lengow</b> est une solution SaaS permettant à un e-commerçant d'optimiser ses catalogues produits vers les comparateurs de prix, régies d'affiliation mais aussi marketplaces et sites de Cashback.<br>
|
24 |
-
<br>Le principe est que la solution récupère le catalogue produits du marchand, configure, optimise et tracke les informations des campagnes marchandes afin de restituer à l'e-commerçant les statistiques sous forme de tableaux de bords et graphiques.
|
25 |
-
<br>Ce processus permet aux e-commerçants d'optimiser leurs flux et leurs coûts d'acquisition sur chaque support de diffusion.
|
26 |
-
<br clear="all">
|
27 |
-
<br clear="all">
|
28 |
-
<a href="http://www.lengow.com" target="_blank"><img src="http://www.lengow.com/view/images/logo_transparant.png" alt="Solution Lengow" border="0"></a>
|
29 |
-
]]>
|
30 |
-
</comment>
|
31 |
-
<sort_order>200</sort_order>
|
32 |
-
<show_in_default>1</show_in_default>
|
33 |
-
<show_in_website>1</show_in_website>
|
34 |
-
</info>
|
35 |
-
</groups>
|
36 |
-
</information>
|
37 |
-
</sections>
|
38 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/adminhtml/default/default/layout/lengow.xml
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addItem">
|
6 |
+
<type>skin_js</type>
|
7 |
+
<name>lengow/js/charts.min.js</name>
|
8 |
+
</action>
|
9 |
+
<action method="addItem">
|
10 |
+
<type>skin_css</type>
|
11 |
+
<name>lengow/css/admin.css</name>
|
12 |
+
</action>
|
13 |
+
</reference>
|
14 |
+
</default>
|
15 |
+
|
16 |
+
<adminhtml_lengow_order_index>
|
17 |
+
<reference name="content">
|
18 |
+
<block type="sync/adminhtml_order" name="manageorders.order.grid.container"></block>
|
19 |
+
</reference>
|
20 |
+
</adminhtml_lengow_order_index>
|
21 |
+
<adminhtml_lengow_log_index>
|
22 |
+
<reference name="content">
|
23 |
+
<block type="sync/adminhtml_log" name="manageorders.log.grid.container"></block>
|
24 |
+
</reference>
|
25 |
+
</adminhtml_lengow_log_index>
|
26 |
+
<adminhtml_lengow_export_index>
|
27 |
+
<reference name="head">
|
28 |
+
<action method="setTitle" translate="title">
|
29 |
+
<title>Lengow Manage Products</title>
|
30 |
+
</action>
|
31 |
+
</reference>
|
32 |
+
<reference name="content">
|
33 |
+
<block type="export/adminhtml_product" name="product.grid" template="lengow/export/product.phtml">
|
34 |
+
<block type="adminhtml/store_switcher" name="store_switcher" as="store_switcher">
|
35 |
+
<action method="setUseConfirm">
|
36 |
+
<params>0</params>
|
37 |
+
</action>
|
38 |
+
</block>
|
39 |
+
</block>
|
40 |
+
</reference>
|
41 |
+
</adminhtml_lengow_export_index>
|
42 |
+
|
43 |
+
<adminhtml_lengow_feed_index>
|
44 |
+
<reference name="head">
|
45 |
+
<action method="setTitle" translate="title">
|
46 |
+
<title>Lengow Manage Feed</title>
|
47 |
+
</action>
|
48 |
+
<action method="addJs"><script>prototype/tooltip.js</script></action>
|
49 |
+
<action method="addJs"><script>scriptaculous/scriptaculous.js</script></action>
|
50 |
+
<action method="addItem">
|
51 |
+
<type>js_css</type>
|
52 |
+
<name>prototype/windows/themes/default.css</name>
|
53 |
+
</action>
|
54 |
+
</reference>
|
55 |
+
<reference name="content">
|
56 |
+
<block type="feed/adminhtml_feed" name="feed.grid" template="lengow/feed/grid.phtml">
|
57 |
+
<block type="adminhtml/store_switcher" name="store_switcher" as="store_switcher">
|
58 |
+
<action method="setUseConfirm">
|
59 |
+
<params>0</params>
|
60 |
+
</action>
|
61 |
+
</block>
|
62 |
+
</block>
|
63 |
+
</reference>
|
64 |
+
</adminhtml_lengow_feed_index>
|
65 |
+
|
66 |
+
<adminhtml_sales_order_view>
|
67 |
+
<reference name="sales_order_tabs">
|
68 |
+
<action method="addTab">
|
69 |
+
<name>TAB_NAME</name>
|
70 |
+
<block>sync/adminhtml_order_tab</block>
|
71 |
+
</action>
|
72 |
+
</reference>
|
73 |
+
</adminhtml_sales_order_view>
|
74 |
+
|
75 |
+
</layout>
|
app/design/adminhtml/default/default/template/lengow/.DS_Store
ADDED
Binary file
|
app/design/adminhtml/default/default/template/lengow/check/point.phtml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<legend><?php echo __('Check your configuration'); ?></legend>
|
2 |
+
<table cellspacing="0" class="form-list">
|
3 |
+
<colgroup class="label"></colgroup>
|
4 |
+
<colgroup class="value"></colgroup>
|
5 |
+
<colgroup class="scope-label"></colgroup>
|
6 |
+
<colgroup class=""></colgroup>
|
7 |
+
<tbody>
|
8 |
+
<tr id="row_update_module">
|
9 |
+
<td class="label">
|
10 |
+
<label for="update_module"><?php echo __('Module\'s version'); ?></label>
|
11 |
+
</td>
|
12 |
+
<td class="value">
|
13 |
+
<?php echo $this->getVersion(); ?>
|
14 |
+
<?php if($this->isLastVersion()): ?>
|
15 |
+
<span class="lengow-check lengow-updated"><?php echo __('Your module is already updated'); ?></span>
|
16 |
+
<?php else: ?>
|
17 |
+
<span class="lengow-check lengow-must-be-updated"><?php echo __('There is a new version %s of Lengow Module, please update it on your Magento Connect Manager !', $this->getLastVersion()); ?></span>
|
18 |
+
<?php endif; ?>
|
19 |
+
</td>
|
20 |
+
</tr>
|
21 |
+
<tr id="row_ip_service">
|
22 |
+
<td class="label">
|
23 |
+
<label for="ip_service"><?php echo __('IP of your server'); ?></label>
|
24 |
+
</td>
|
25 |
+
<td class="value">
|
26 |
+
<?php echo $this->getRealIP(); ?>
|
27 |
+
<p class="note">
|
28 |
+
<?php echo __('Make sure your website IP (%s) address is filled in your Lengow Dashboard.', $this->getRealIP()); ?> <a href="https://solution.lengow.com/api/" target="_blank"><?php echo __('Click here to update it'); ?></a>
|
29 |
+
</p>
|
30 |
+
</td>
|
31 |
+
</tr>
|
32 |
+
</tbody>
|
33 |
+
</table>
|
app/design/adminhtml/default/default/template/lengow/dashboard/charts.phtml
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
2 |
+
<script type="text/javascript">
|
3 |
+
$.noConflict();
|
4 |
+
;jQuery(document).ready(function($) {
|
5 |
+
function lengowLoadStats(key) {
|
6 |
+
var ctx = $("#lengow-stats").get(0).getContext("2d");
|
7 |
+
var data = {
|
8 |
+
labels: data_stats[key].evolution_libelle,
|
9 |
+
datasets: [
|
10 |
+
{
|
11 |
+
fillColor: "rgba(151,187,205,0.5)",
|
12 |
+
strokeColor: "rgba(151,187,205,1)",
|
13 |
+
pointColor: "rgba(151,187,205,1)",
|
14 |
+
pointStrokeColor: "#fff",
|
15 |
+
data: data_stats[key].evolution_values
|
16 |
+
}
|
17 |
+
]
|
18 |
+
};
|
19 |
+
new Chart(ctx).Line(data);
|
20 |
+
}
|
21 |
+
// admin dashboard
|
22 |
+
$('#table-feeds').hide();
|
23 |
+
$('#lengow-info').hide();
|
24 |
+
var lengowAPI = 'https://solution.lengow.com/routine/PrestaShop/dashboard_plugin_v2.php?token=<?php echo $this->getData('api_key'); ?>&idClient=<?php echo $this->getData('id_client'); ?>&idGroup=<?php echo $this->getData('id_group'); ?>&callback=?',
|
25 |
+
table_feeds = '',
|
26 |
+
select = '',
|
27 |
+
data_stats = {};
|
28 |
+
$.getJSON(lengowAPI, function(json) {
|
29 |
+
if (json.return == 'ok') {
|
30 |
+
data_stats = json.stats;
|
31 |
+
$('#lengow-load').hide();
|
32 |
+
$.each(json.feeds, function(key, val){
|
33 |
+
table_feeds += '<tr>'
|
34 |
+
+ '<td>' + json.feeds[key].id + '</td>'
|
35 |
+
+ '<td>' + json.feeds[key].type + '</td>'
|
36 |
+
+ '<td>' + json.feeds[key].diffuseur + '</td>'
|
37 |
+
+ '<td>' + json.feeds[key].nom + '</td>'
|
38 |
+
+ '<td>' + json.feeds[key].nbProduit + '</td>'
|
39 |
+
+ '<td>' + json.feeds[key].nbProduitActif + '</td>'
|
40 |
+
+ '</th>';
|
41 |
+
});
|
42 |
+
select = '<select name="lengow-change" id="lengow-change">';
|
43 |
+
$.each(json.stats, function(key, val){
|
44 |
+
select += '<option value="' + key + '">' + json.stats[key].name + '</option>';
|
45 |
+
});
|
46 |
+
select += '</select>';
|
47 |
+
$('#table-feeds tbody').html(table_feeds);
|
48 |
+
$('#table-feeds').show();
|
49 |
+
$('#lengow-info').show();
|
50 |
+
$('#lengow-change-select').html(select);
|
51 |
+
$('#lengow-root').html('<canvas id="lengow-stats" width="587" height="400"></canvas>');
|
52 |
+
$('#lengow-change').change(function() {
|
53 |
+
var selected = $('#lengow-change').val();
|
54 |
+
lengowLoadStats(selected);
|
55 |
+
});
|
56 |
+
lengowLoadStats(0);
|
57 |
+
}
|
58 |
+
});
|
59 |
+
});
|
60 |
+
</script>
|
61 |
+
<div style="margin: 20px;">
|
62 |
+
|
63 |
+
<div id="lengow-load"><?php echo __('Dashboard Lengow'); ?></div>
|
64 |
+
|
65 |
+
<div class="switcher a-right" style="padding:5px 10px;" id="lengow-change-select"></div>
|
66 |
+
|
67 |
+
<div id="lengow-info">
|
68 |
+
<div id="lengow-root"></div>
|
69 |
+
</div>
|
70 |
+
|
71 |
+
<br />
|
72 |
+
<table id="table-feeds">
|
73 |
+
<thead>
|
74 |
+
<tr>
|
75 |
+
<th><span><?php echo __('ID'); ?></span></th>
|
76 |
+
<th><span><?php echo __('Type'); ?></span></th>
|
77 |
+
<th><span><?php echo __('Supplier'); ?></span></th>
|
78 |
+
<th><span><?php echo __('Name'); ?></span></th>
|
79 |
+
<th><span><?php echo __('Products'); ?></span></th>
|
80 |
+
<th><span><?php echo __('Enable\'s products'); ?></span></th>
|
81 |
+
</tr>
|
82 |
+
</thead>
|
83 |
+
<tbody></tbody>
|
84 |
+
</table>
|
85 |
+
|
86 |
+
</div>
|
app/design/adminhtml/default/default/template/lengow/export/.DS_Store
ADDED
Binary file
|
app/design/adminhtml/default/default/template/lengow/export/product.phtml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @var $this Profileolabs_Lengow_Block_Export_Adminhtml_Product
|
4 |
+
* @see Profileolabs_Lengow_Block_Export_Adminhtml_Product
|
5 |
+
*/
|
6 |
+
?>
|
7 |
+
<div class="content-header">
|
8 |
+
<table cellspacing="0">
|
9 |
+
<tr>
|
10 |
+
<td style="width:50%;"><h3 class="icon-head head-products"><?php echo Mage::helper('export')->__('Select products to export') ?></h3></td>
|
11 |
+
<td class="a-right">
|
12 |
+
<?php echo $this->getButtonsHtml() ?>
|
13 |
+
</td>
|
14 |
+
</tr>
|
15 |
+
</table>
|
16 |
+
</div>
|
17 |
+
<?php if( !$this->isSingleStoreMode() ): ?>
|
18 |
+
<?php echo $this->getChildHtml('store_switcher');?>
|
19 |
+
<?php endif;?>
|
20 |
+
<div>
|
21 |
+
<?php echo $this->getGridHtml() ?>
|
22 |
+
</div>
|
app/design/adminhtml/default/default/template/lengow/feed/grid.phtml
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @var $this Lengow_Feed_Block_Adminhtml_Feed
|
4 |
+
* @see Lengow_Feed
|
5 |
+
*/
|
6 |
+
?>
|
7 |
+
<div class="content-header">
|
8 |
+
<table cellspacing="0">
|
9 |
+
<tr>
|
10 |
+
<td style="width:50%;">
|
11 |
+
<h3 class="icon-head head-products">
|
12 |
+
<?php echo Mage::helper('feed')->__('Feeds management') ?>
|
13 |
+
</h3>
|
14 |
+
</td>
|
15 |
+
<td class="a-right">
|
16 |
+
<?php echo $this->getButtonsHtml() ?>
|
17 |
+
</td>
|
18 |
+
</tr>
|
19 |
+
</table>
|
20 |
+
</div>
|
21 |
+
<?php if (!$this->isSingleStoreMode()): ?>
|
22 |
+
<?php echo $this->getChildHtml('store_switcher'); ?>
|
23 |
+
<?php endif; ?>
|
24 |
+
<div>
|
25 |
+
<form method="post" id="form_grid_feed" action="<?php echo $this->getUrl('*/*/migrate', array('' => '')); ?>">
|
26 |
+
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
|
27 |
+
<?php echo $this->getGridHtml() ?>
|
28 |
+
</form>
|
29 |
+
</div>
|
30 |
+
<style>
|
31 |
+
.tooltip {
|
32 |
+
color: #000;
|
33 |
+
background: #fff;
|
34 |
+
border: 2px solid #ea7601;
|
35 |
+
padding: 10px;
|
36 |
+
overflow: visible;
|
37 |
+
}
|
38 |
+
.tooltip .toolbar {
|
39 |
+
background: #0F6788;
|
40 |
+
font: italic 17px Georgia, serif;
|
41 |
+
}
|
42 |
+
.tooltip .title { padding: 5px; }
|
43 |
+
.tooltip .content {
|
44 |
+
background: dodgerblue;
|
45 |
+
font: 11px Arial, Helvetica, sans-serif;
|
46 |
+
padding: 5px;
|
47 |
+
}
|
48 |
+
</style>
|
49 |
+
<script type="text/javascript">
|
50 |
+
document.observe("dom:loaded", function() {
|
51 |
+
$$('.popup-link').each(function(element) {
|
52 |
+
new Tooltip(element, element.readAttribute('data-link'));
|
53 |
+
})
|
54 |
+
});
|
55 |
+
</script>
|
app/design/adminhtml/default/default/template/lengow/sales/.DS_Store
ADDED
Binary file
|
app/design/adminhtml/default/default/template/lengow/sales/order/tab/info.phtml
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @var $this Profileolabs_Lengow_Block_Export_Adminhtml_Product
|
4 |
+
* @see Profileolabs_Lengow_Block_Export_Adminhtml_Product
|
5 |
+
*/
|
6 |
+
?>
|
7 |
+
<?php
|
8 |
+
$fields = $this->getFields();
|
9 |
+
?>
|
10 |
+
<div class="entry-edit">
|
11 |
+
<div class="entry-edit-head">
|
12 |
+
<h4 class="icon-head head-account">Lengow information</h4>
|
13 |
+
</div>
|
14 |
+
</div>
|
15 |
+
<div class="fieldset">
|
16 |
+
<?php
|
17 |
+
if($this->isLengowOrder()) {
|
18 |
+
?>
|
19 |
+
<table cellspacing="0" class="form-list">
|
20 |
+
<tbody>
|
21 |
+
<?php
|
22 |
+
foreach($fields as $field) {
|
23 |
+
?>
|
24 |
+
<tr>
|
25 |
+
<td class="label">
|
26 |
+
<label><?php echo $field['label']; ?></label>
|
27 |
+
</td>
|
28 |
+
<td class="value">
|
29 |
+
<label><?php echo $field['value']; ?></label>
|
30 |
+
</td>
|
31 |
+
</tr>
|
32 |
+
<?php
|
33 |
+
}
|
34 |
+
?>
|
35 |
+
</tbody>
|
36 |
+
</table>
|
37 |
+
<?php
|
38 |
+
} else {
|
39 |
+
echo '<p>'.$this->__('This order doesn\'t come from Lengow').'</p>';
|
40 |
+
}
|
41 |
+
?>
|
42 |
+
</div>
|
app/design/adminhtml/default/default/template/lengow/sales/payment/info/purchaseorder.phtml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_default
|
23 |
+
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<p><?php echo $this->__($this->getMethod()->getTitle()) ?></p>
|
28 |
+
<p><?php echo $this->__('Marketplace: <strong>%s</strong>', $this->htmlEscape($this->getInfo()->getAdditionalData())) ?></p>
|
app/design/frontend/base/default/layout/lengow.xml
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addItem">
|
6 |
+
<type>skin_js</type>
|
7 |
+
<name>lengow/tracker.js</name>
|
8 |
+
</action>
|
9 |
+
</reference>
|
10 |
+
<reference name="before_body_end">
|
11 |
+
<block type="tracker/tracker" name="lengow_tracker" template="lengow/tracker/tag.phtml" />
|
12 |
+
</reference>
|
13 |
+
</default>
|
14 |
+
</layout>
|
app/design/frontend/base/default/template/lengow/tracker/simpletag.phtml
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<!-- Tag_Lengow -->
|
2 |
+
<img src="https://tracking.lengow.com/lead.php?idClient=<?php echo $this->_id_client; ?>&idGroup=<?php echo $this->_id_group; ?>&price=<?php echo $this->_total_paid; ?>&idCommande=<?php echo $this->_id_order; ?>&modePaiement=<?php echo $this->_mode_paiement; ?>&listingProduit=<?php echo $this->_ids_products; ?>" alt="" style="width: 1px; height: 1px; border: none;" />
|
3 |
+
<img src="https://tracking.lengow.com/leadValidation.php?idClient=<?php echo $this->_id_client; ?>&idGroup=<?php echo $this->_id_group; ?>&idCommande=<?php echo $this->_id_order; ?>" alt="" style="width: 1px; height: 1px; border: none;" />
|
4 |
+
<!-- /Tag_Lengow -->
|
app/design/frontend/base/default/template/lengow/tracker/tag.phtml
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
echo $this->getChildHtml('tracker');
|
app/design/frontend/base/default/template/lengow/tracker/tagcapsule.phtml
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!-- Tag_Lengow -->
|
2 |
+
<?php
|
3 |
+
if ($this->getData('controller') == 'onepage' && $this->getData('current_action') == 'success') {
|
4 |
+
?>
|
5 |
+
<script type="text/javascript">
|
6 |
+
page = 'payment'; // #TYPE DE PAGE#
|
7 |
+
order_amt = '<?php echo $this->getData('order_total'); ?>'; // #MONTANT COMMANDE#
|
8 |
+
order_id = '<?php echo $this->getData('id_order'); ?>'; // #ID COMMANDE#
|
9 |
+
product_ids = '<?php echo $this->getData('ids_products'); ?>'; // #ID PRODUCT#
|
10 |
+
basket_products = '<?php echo $this->getData('list_products'); ?>'; // #LISTING PRODUCTS IN BASKET#
|
11 |
+
ssl = '<?php echo $this->getData('use_ssl'); ?>';
|
12 |
+
id_categorie = '<?php echo $this->getData('id_category'); ?>'; // #ID CATEGORIE EN COURS#
|
13 |
+
</script>
|
14 |
+
<script type="text/javascript" src="https://tracking.lengow.com/tagcapsule.js?lengow_id=<?php echo $this->getData('id_client'); ?>&idGroup=<?php echo $this->getData('id_group'); ?>"></script>
|
15 |
+
<?php
|
16 |
+
}
|
17 |
+
?>
|
18 |
+
<div id="lengow_tracker">
|
19 |
+
<script type="text/javascript">
|
20 |
+
var page = '<?php echo $this->getData('type_page'); ?>'; // #TYPE DE PAGE#
|
21 |
+
var order_amt = '<?php echo $this->getData('order_total'); ?>'; // #MONTANT COMMANDE#
|
22 |
+
var order_id = '<?php echo $this->getData('id_order'); ?>'; // #ID COMMANDE#
|
23 |
+
var product_ids = '<?php echo $this->getData('ids_products'); ?>'; // #ID PRODUCT#
|
24 |
+
var basket_products = '<?php echo $this->getData('list_products'); ?>'; // #LISTING PRODUCTS IN BASKET#
|
25 |
+
var ssl = '<?php echo $this->getData('use_ssl'); ?>';
|
26 |
+
var id_categorie = '<?php echo $this->getData('id_category'); ?>'; // #ID CATEGORIE EN COURS#
|
27 |
+
</script>
|
28 |
+
</div>
|
29 |
+
<script id="url_script" type="text/javascript" src="https://tracking.lengow.com/tagcapsule.js?lengow_id=<?php echo $this->getData('id_client'); ?>&idGroup=<?php echo $this->getData('id_group'); ?>"></script>
|
30 |
+
|
31 |
+
<!-- /Tag_Lengow -->
|
app/etc/modules/Lengow_All.xml
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<modules>
|
4 |
-
<Lengow_Export>
|
5 |
-
<active>true</active>
|
6 |
-
<codePool>local</codePool>
|
7 |
-
</Lengow_Export>
|
8 |
-
</modules>
|
9 |
-
<modules>
|
10 |
-
<Lengow_Information>
|
11 |
-
<active>true</active>
|
12 |
-
<codePool>local</codePool>
|
13 |
-
</Lengow_Information>
|
14 |
-
</modules>
|
15 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/etc/modules/Lengow_Connector.xml
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Copyright 2013 Lengow.
|
6 |
+
*
|
7 |
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
8 |
+
* not use this file except in compliance with the License. You may obtain
|
9 |
+
* a copy of the License at
|
10 |
+
*
|
11 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12 |
+
*
|
13 |
+
* Unless required by applicable law or agreed to in writing, software
|
14 |
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15 |
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16 |
+
* License for the specific language governing permissions and limitations
|
17 |
+
* under the License.
|
18 |
+
*
|
19 |
+
|
20 |
+
* @category Lengow
|
21 |
+
* @package Lengow_All
|
22 |
+
* @copyright Copyright (c) 2013 Lengow SAS (http://www.lengow.com)
|
23 |
+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
24 |
+
*/
|
25 |
+
-->
|
26 |
+
<config>
|
27 |
+
<modules>
|
28 |
+
<Lengow_Export>
|
29 |
+
<active>true</active>
|
30 |
+
<codePool>community</codePool>
|
31 |
+
<depends>
|
32 |
+
<Mage_Catalog />
|
33 |
+
<Mage_CatalogInventory />
|
34 |
+
<Lengow_Tracker />
|
35 |
+
</depends>
|
36 |
+
</Lengow_Export>
|
37 |
+
<Lengow_Sync>
|
38 |
+
<active>true</active>
|
39 |
+
<codePool>community</codePool>
|
40 |
+
<depends>
|
41 |
+
<Mage_Catalog />
|
42 |
+
<Mage_CatalogInventory />
|
43 |
+
<Mage_Sales />
|
44 |
+
<Lengow_Tracker />
|
45 |
+
<Lengow_Export />
|
46 |
+
</depends>
|
47 |
+
</Lengow_Sync>
|
48 |
+
<Lengow_Tracker>
|
49 |
+
<active>true</active>
|
50 |
+
<codePool>community</codePool>
|
51 |
+
<depends>
|
52 |
+
<Mage_Catalog />
|
53 |
+
<Mage_CatalogInventory />
|
54 |
+
<Mage_Sales />
|
55 |
+
</depends>
|
56 |
+
</Lengow_Tracker>
|
57 |
+
<Lengow_Dashboard>
|
58 |
+
<active>true</active>
|
59 |
+
<codePool>community</codePool>
|
60 |
+
<depends>
|
61 |
+
<Mage_Adminhtml />
|
62 |
+
</depends>
|
63 |
+
</Lengow_Dashboard>
|
64 |
+
<Lengow_Feed>
|
65 |
+
<active>true</active>
|
66 |
+
<codePool>community</codePool>
|
67 |
+
<depends>
|
68 |
+
<Mage_Adminhtml />
|
69 |
+
</depends>
|
70 |
+
</Lengow_Feed>
|
71 |
+
</modules>
|
72 |
+
</config>
|
app/locale/en_US/Lengow_Export.csv
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
"Solution Lengow","Solution Lengow"
|
2 |
-
"Export your product catalog","Export your product catalog"
|
3 |
-
"URL of your Product Catalog","URL of your Product Catalog"
|
4 |
-
"Export your product catalog to Lengow.","Export your product catalog to Lengow."
|
|
|
|
|
|
|
|
app/locale/en_US/Lengow_Information.csv
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
"Solution Lengow","Solution Lengow"
|
2 |
-
"Lengow Informations","Lengow Informations"
|
3 |
-
"Informations :","Informations :"
|
|
|
|
|
|
app/locale/fr_FR/Lengow_Connector.csv
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Anglais","Français"
|
2 |
+
"Export Configuration","Configuration de l'export"
|
3 |
+
"Global","Global"
|
4 |
+
"Ip authorised to export","Ip autorisée pour l'export"
|
5 |
+
"Authorized acces to catalog export by IP, separated by ;","Autoriser l'accès de l'export du catalogue aux IPs séparées par des ;"
|
6 |
+
"Export only selected product","Exporter uniquement les produits sélectionnés"
|
7 |
+
"Export product out of stock","Exporter les produits sans stock"
|
8 |
+
"Product type to export","Type de produit à exporter"
|
9 |
+
"Status of product to export","Statut des produits à exporter"
|
10 |
+
"Level max for category","Niveau maximum de profondeur de catégorie"
|
11 |
+
"Merge images with parents products if exist","Fusionner les images avec les parents si ils existent"
|
12 |
+
"Convert data","Convertir les données"
|
13 |
+
"Replace spcecial chars with html chars","Remplacer les caractères spéciaux par des caractères html"
|
14 |
+
"Country shipping","Pays de livraison par défaut"
|
15 |
+
"Delay of shipping","Délais de livraison"
|
16 |
+
"Shipping cost","Frais de la livraison"
|
17 |
+
"Default shipping cost if matching find","Coût par défaut de la livraison si aucune correspondance n'est trouvée"
|
18 |
+
"Shipping method","Méthode de transport"
|
19 |
+
"Default shipping method to calculate shipping cost","Méthode de transport par défaut pour calculer les frais d'envois"
|
20 |
+
"Format","Format"
|
21 |
+
"Performances","Performances"
|
22 |
+
"Save feed on file","Sauvegarder le flux dans un fichier"
|
23 |
+
"Save the feed on a file","Sauvegarder votre flux dans un fichier"
|
24 |
+
"Active cron","Activer la tâche planifiée"
|
25 |
+
"Active the scheduled task for export your feed every 4h","Activer la tache planifiée de l'export toutes les 4h"
|
26 |
+
"Products attributes","Attributs produits"
|
27 |
+
"Select attributes to export","Sélectionner les attributs produits à exporter"
|
28 |
+
"Manage Products Export","Gestion des produits"
|
29 |
+
"Products","Produits"
|
30 |
+
"Feed configuration","Gestion des flux"
|
31 |
+
"Manage Orders","Gestion des commandes"
|
32 |
+
"Import orders from x days","Importer les commandes depuis x jours"
|
33 |
+
"Choose period for Sync order","Sélectionner une période "
|
34 |
+
"Auto import","Import automatique"
|
35 |
+
"Enable import every 30 minutes","Activer l'import automatique toutes les 30 min"
|
36 |
+
"Debug mode","Mode debug"
|
37 |
+
"Only for preproduction's mode : no sync orders with Lengow, import orders every time","Seulement pour un environnement de préproduction : ne synchronise pas les commandes avec Lengow et permet d'importer plusieurs fois une même nouvelle commande"
|
38 |
+
"Logs","Logs"
|
39 |
+
"Customer Account","Compte utilisateur"
|
40 |
+
"Lengow API and TagCapsule","Lengow API et TagCapsule"
|
41 |
+
"Customer ID","IdClient"
|
42 |
+
"Your Customer ID of Lengow","Votre ID client Lengow"
|
43 |
+
"Group ID","IdGroup"
|
44 |
+
"Your Group ID of Lengow","Votre ID groupe Lengow"
|
45 |
+
"Token API","Token API"
|
46 |
+
"Tracker Type","Type de tracker"
|
47 |
+
"Dashboard Lengow","Dashboard Lengow"
|
48 |
+
"ID","ID"
|
49 |
+
"Type","Type"
|
50 |
+
"Supplier","Diffuseur"
|
51 |
+
"Name","Nom"
|
52 |
+
"Products","Produits"
|
53 |
+
"Enable's products","Produits actifs"
|
54 |
+
"Select products to export","Sélectionner les produits actifs"
|
55 |
+
"Feeds management","Gestion des flux"
|
56 |
+
"Lengow information","Information Lengow"
|
57 |
+
"This order doesn't come from Lengow","Cette commande ne proviens pas de Lengow"
|
58 |
+
"Marketplace","Marketplace"
|
59 |
+
"Name","Nom"
|
60 |
+
"Name In %s","Nom dans %s"
|
61 |
+
"Type","Type"
|
62 |
+
"Attrib. Set Name","Nom attribut"
|
63 |
+
"SKU","Ref"
|
64 |
+
"Price","Prix"
|
65 |
+
"Qty","Qty"
|
66 |
+
"Visibility","Visibilité"
|
67 |
+
"Status","Statut"
|
68 |
+
"Publish on Lengow","Publié sur Lengow"
|
69 |
+
"Yes","Oui"
|
70 |
+
"No","Non"
|
71 |
+
"Websites","Sites web"
|
72 |
+
"Change publication","Changer la publication"
|
73 |
+
"Publication","Publication"
|
74 |
+
"There was an error while updating product(s) publication","Il y a une erreur lors de la mise à jour de la publication du/des produit(s)"
|
75 |
+
"Total of %d record(s) were successfully updated","%d produits ont été mis à jour"
|
76 |
+
"Unauthorised IP : %s","IP non autorisée : %s"
|
77 |
+
"Migrate Feed","Migrer le flux"
|
78 |
+
"Select attribut to map","Selectionner un attribut à mapper"
|
79 |
+
"API Key (Token) is empty","Le token API est vide"
|
80 |
+
"All","Tous"
|
81 |
+
"Enabled","Activé"
|
82 |
+
"Disabled","Désactivé"
|
83 |
+
"Configurable","Configurable"
|
84 |
+
"Simple","Simple"
|
85 |
+
"Bundle","Packagé"
|
86 |
+
"Grouped","Groupé"
|
87 |
+
"Virtual","Virtuel"
|
88 |
+
"Your feed is available here : %s","Votre flux est disponible ici : %s"
|
89 |
+
"View feed","Voir le flux"
|
90 |
+
"Feed ID","ID Flux"
|
91 |
+
"Feed Name","Nom du flux"
|
92 |
+
"Current Feed","Flux actuel"
|
93 |
+
"Export only selected product","Exporter seulement les produits sélectionnés"
|
94 |
+
"Export product out of stock","Exporter les produits sans stock"
|
95 |
+
"Product type to export","Type de produit à exporter"
|
96 |
+
"Status of product to export","Statut des produits à exporter"
|
97 |
+
"Format export","Format de l'export"
|
98 |
+
"Action","Action"
|
99 |
+
"Migrate all selected feeds","Migrer tous les flux"
|
100 |
+
"Update success","Mise à jour réussi"
|
101 |
+
"Error update feed %s","Erreur dans la mise à jour du flux %s"
|
102 |
+
"Created at","Date création"
|
103 |
+
"Message","Message"
|
104 |
+
"Order #","Commande #"
|
105 |
+
"Purchased From (Store)","Acheté sur (Magasin)"
|
106 |
+
"Bill to Name","Nom (Fact.)"
|
107 |
+
"Ship to Name","Nom (Livr.)"
|
108 |
+
"G.T. (Base)","Montant total
|
109 |
+
(Devise de base)"
|
110 |
+
"G.T. (Purchased)","Montant total (Devise de la commande)"
|
111 |
+
"ID lengow","Id lengow"
|
112 |
+
"Marketplace","Marketplace"
|
113 |
+
"Fees","Coût"
|
114 |
+
"Status","Statut"
|
115 |
+
"Action","Action"
|
116 |
+
"View","Voir"
|
117 |
+
"CSV","CSV"
|
118 |
+
"Cancel","Annuler"
|
119 |
+
"Hold","Bloquer"
|
120 |
+
"Print Invoices","Imprimer les factures"
|
121 |
+
"Print Packingslips","Imprimer les bordereaux de livraison"
|
122 |
+
"Print Credit Memos","Imprimer les avoirs"
|
123 |
+
"Print All","Tout imprimer"
|
124 |
+
"Lengow order ID","ID Commande Lengow"
|
125 |
+
"Feed ID","ID Flux"
|
126 |
+
"Total paid","Total payé"
|
127 |
+
"Carrier","Transporteur"
|
128 |
+
"Carrier method","Méthode de transport"
|
129 |
+
"Json Node","Noeud Json"
|
130 |
+
"Flush logs","Vider les logs"
|
131 |
+
"Manuel import","Import manuel"
|
132 |
+
"Lengow orders","Commandes Lengow"
|
133 |
+
"Log is empty","Les logs sont vide"
|
134 |
+
"%d orders are imported","%d commandes ont été importées"
|
135 |
+
"%d orders are updated","%d commande ont été mises à jour"
|
136 |
+
"No order available to import","Aucune commande n'est disponible à l'import"
|
app/locale/fr_FR/Lengow_Export.csv
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
"Solution Lengow","Solution Lengow"
|
2 |
-
"Export your product catalog","Exportez votre Catalogue"
|
3 |
-
"URL of your Product Catalog","URL de votre catalogue produit"
|
4 |
-
"Export your product catalog to Lengow.","Exportez votre catalogue produits vers la solution Lengow."
|
|
|
|
|
|
|
|
app/locale/fr_FR/Lengow_Information.csv
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
"Solution Lengow","Solution Lengow"
|
2 |
-
"Lengow Informations","Informations Lengow"
|
3 |
-
"Informations :","Informations :"
|
|
|
|
|
|
package.xml
CHANGED
@@ -1,38 +1,19 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Lengow_Export</name>
|
4 |
-
<version>
|
5 |
<stability>stable</stability>
|
6 |
-
<license
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
<description>
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
<
|
15 |
-
|
16 |
-
|
17 |
-
Version 1.1.4
|
18 |
-
- correction gestion des attributs
|
19 |
-
|
20 |
-
|
21 |
-
Version 1.1.2
|
22 |
-
-gestion des attributs
|
23 |
-
|
24 |
-
Version 1.1.1
|
25 |
-
-Fix Bug with XML cdata
|
26 |
-
|
27 |
-
Version 1.1.0
|
28 |
-
-Fix Bug with setHeader
|
29 |
-
|
30 |
-
Version 1.0.0
|
31 |
-
-1st release</notes>
|
32 |
-
<authors><author><name>Lengow</name><user>auto-converted</user><email>technique@lengow.com</email></author></authors>
|
33 |
-
<date>2010-12-16</date>
|
34 |
-
<time>08:26:05</time>
|
35 |
-
<contents><target name="magelocale"><dir name="en_US"><file name="Lengow_Export.csv" hash="abeaea80f731b4fa350091e0807cdbee"/><file name="Lengow_Information.csv" hash="86986a0717caed093e4178acf407f26c"/></dir><dir name="fr_FR"><file name="Lengow_Export.csv" hash="0bc75b767e6a51b07748f2362ff3f6f2"/><file name="Lengow_Information.csv" hash="cab993c6e862f67cef4a05229cbb2026"/></dir></target><target name="magelocal"><dir name="Lengow"><dir name="Export"><dir name="controllers"><file name="IndexController.php" hash="dff5e2b3895775496697d75c1d426714"/></dir><dir name="etc"><file name="config.xml" hash="8210a1ad7fd08092b95a55de0498092c"/><file name="system.xml" hash="da7eb0bc7e16b26bae938a79fe4f5e05"/></dir><dir name="Helper"><file name="Data.php" hash="9bb8759af094885106efb1a53fe98b07"/></dir><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Attributes.php" hash="9f77f955ec55e525a7489fcebc46fb71"/><file name="Categories.php" hash="9c2df4085d47dd5efec5b4cc2c2e501f"/><file name="Description.php" hash="00ea124c5ead43903076469afc58af60"/><file name="Price.php" hash="26765d4e51892c55dd6f6c9c28b3b2e6"/></dir></dir></dir><file name="Observer.php" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="Products.php" hash="fedba3d66954d8a8100628a2328ae8f8"/></dir></dir><dir name="Information"><dir name="etc"><file name="config.xml" hash="c83d19a3acd4186b7b2ea4f92abc8104"/><file name="system.xml" hash="e16fa28f8249be84adf447c099adeb95"/></dir><dir name="Helper"><file name="Data.php" hash="8063a9cfe2cf944b1d1a6ac65a6b57d0"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Lengow_All.xml" hash="d212244e63e3d5dd55d33981a9d725bf"/></dir></target></contents>
|
36 |
<compatible/>
|
37 |
-
<dependencies
|
38 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Lengow_Export</name>
|
4 |
+
<version>2.0.1.0</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license>GPL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>New module of Lengow</summary>
|
10 |
+
<description>New module of Lengow.
|
11 |
+
Export your catalog, import your orders from all Marketplaces.</description>
|
12 |
+
<notes>New version of Lengow's Connector</notes>
|
13 |
+
<authors><author><name>Ludovic</name><user>ludo</user><email>ludovic@lengow.com</email></author><author><name>Romain</name><user>romain</user><email>romain@lengow.com</email></author></authors>
|
14 |
+
<date>2014-02-11</date>
|
15 |
+
<time>15:38:17</time>
|
16 |
+
<contents><target name="magecommunity"><dir name="Lengow"><dir name="Dashboard"><dir name="Block"><dir name="Adminhtml"><dir name="Dashboard"><file name="Charts.php" hash="dae1bbed1ede93b06f62589e93857396"/><file name="Diagrams.php" hash="001995ea1916ca192021ba52c155a466"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="7129af0e9ab390e0695f84865a02fdb5"/></dir><dir name="Model"><file name="Config.php" hash="9ac1d092bffd109f02518885f89142c7"/></dir><dir name="etc"><file name="config.xml" hash="4f6016d050b7b667ddb3c292b4008334"/></dir></dir><dir name="Export"><dir name="Block"><dir name="Adminhtml"><dir name="Product"><file name="Grid.php" hash="d2b5d56eacd6f3edd45a5fe90c785bbe"/></dir><file name="Product.php" hash="eb02c6d91aaa59cb8235ac0703a16297"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Helper"><file name="Data.php" hash="837edcfbf4d83096f5a23339a11ae9c0"/><file name="Security.php" hash="3ad6b6925ef05884a1501afa6e64a685"/></dir><dir name="Model"><dir name="Catalog"><file name="Product.php" hash="d46788333955a02db904e3d5bb342a30"/></dir><file name="Config.php" hash="5335535993d0fc1d13da0c6be56ea1e6"/><dir name="Convert"><dir name="Parser"><file name="Product.php" hash="bc664380ca9d37256460613ecdbd8f92"/></dir></dir><dir name="Export"><dir name="Rewrite"><dir name="Catalog"><file name="Config.php" hash="e192cd30c6ed7e4cc370953c3ecd2367"/></dir></dir></dir><dir name="Feed"><file name="Abstract.php" hash="ed13409ab1c507b48b9460c8886bef8d"/><file name="Csv.php" hash="0d5efb78f25e58d4b638af54d83fa0bd"/><file name="Json.php" hash="4df743bce6647eea36d2677ab7f6a9a8"/><file name="Xml.php" hash="dee5abfe1fa6f066a89a7de9ca3c9f3e"/><file name="Yaml.php" hash="f0c24bd481039c4fc13fa26ef7a4d1b9"/></dir><file name="Generate.php" hash="ee703e20c527e06e2895b56dbcb41937"/><file name="Observer.php" hash="ee7e08f93e78d06b035060e29c67d82f"/><dir name="Shipping"><dir name="Carrier"><file name="Lengow.php" hash="685809c2367ec3509ecbf9f4d07f4661"/></dir></dir><dir name="Source"><file name="Attributes.php" hash="95b485a452aee5b27af0af618211f13c"/><file name="Types.php" hash="6b125e9e5c0dfd5c93cf304441ed47ac"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Apikey.php" hash="111617eb86ef8dd7374efa0d4eabf781"/></dir><dir name="Source"><dir name="Category"><file name="Level.php" hash="b35d3367815682e0ed2827ae8c722e9a"/></dir><file name="Format.php" hash="fd069f484cc3ae0d914fb7a965789d9f"/><file name="Getattributes.php" hash="9ed9accf926ee7ad15a361d45eae5ff6"/><file name="Images.php" hash="e6ec93f301599ea91d69a1f4847e240d"/><file name="Status.php" hash="c848476436a961877def6ae5ea0b16d8"/><file name="Types.php" hash="56de65acbb13ee5425b95cc5f9c3f2d2"/></dir></dir></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Lengow"><file name="ExportController.php" hash="29127de9817945fc672af40b3f2961f3"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name="FeedController.php" hash="e8fe620214eb352ff4d7cfbb06547a33"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="etc"><file name="config.xml" hash="153123fac7e379f12ede4d1ae3183605"/><file name="system.xml" hash="6b727a67ec4c912883769b77f695eb59"/></dir></dir><dir name="Feed"><dir name="Block"><dir name="Adminhtml"><dir name="Feed"><file name="Grid.php" hash="164d0069752cf6327128e2da873c6466"/><dir name="Renderer"><file name="Migrate.php" hash="e59d5a72241165ec1c8194fc257d6e11"/><file name="Select.php" hash="78808e9061b7a5aa73c2273f18bc0746"/><file name="Url.php" hash="c9060f99ffa7f47140392c4392f793e7"/></dir></dir><file name="Feed.php" hash="96aa5aa6ed7c9e4a708df5b391621421"/></dir></dir><dir name="Helper"><file name="Data.php" hash="23ab67ab3d66ce8c35cfe9c8bff76f76"/></dir><dir name="Model"><file name="Config.php" hash="7487c73a3fe292614c9f4a2b66d8a664"/><file name="Feed.php" hash="75e01d41749b61db15f2603ed00f09a4"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Lengow"><file name="FeedController.php" hash="7a5f760a1768ddd6dca7b04affb1681f"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="98bbd3fef1e7b153177127c5bf443e03"/><file name="system.xml" hash="22ba605f2529396e4edb41c5ec8e65e6"/></dir></dir><dir name="Sync"><dir name="Block"><dir name="Adminhtml"><file name="Import.php" hash="832bc82dde18ae4bc886933b28f41885"/><dir name="Log"><file name="Grid.php" hash="ca9a55f848bccb6e8a34e0217cf905f5"/></dir><file name="Log.php" hash="c8434ba0a97fb13c25fbfbc4f1841b53"/><dir name="Order"><file name="Grid.php" hash="f5423e0e9f88c29a39e494e8ce72c0e1"/><file name="Tab.php" hash="4c913f7d42506bd3e60e10a5142d9b8a"/></dir><file name="Order.php" hash="2ddb7553c4c67faf0bae5bbbe1be16fe"/></dir><dir name="Payment"><dir name="Info"><file name="Purchaseorder.php" hash="72bbeb480299903b16e505ffdd5d73fe"/></dir></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Helper"><file name="Data.php" hash="05e0c035a6400f6b4b56b33e6bbf424d"/></dir><dir name="Model"><file name="Config.php" hash="e356e499cd34db77a17954fb52443a4f"/><dir name="Connector"><file name="Exception.php" hash="de1fa1b69e24fe7b976c03f1ed1ca7f7"/></dir><file name="Connector.php" hash="63b645168b51d6cbb0cf748f3159d35e"/><dir name="Customer"><file name="Customer.php" hash="e195621601071a4f15d0724839e9aaaa"/></dir><file name="Import.php" hash="4a7e3d1c3c7dba329987afd34d7e9479"/><file name="Log.php" hash="3dd56825227289f380bf5c0e2f8e848e"/><dir name="Marketplace"><file name="Exception.php" hash="bd7ab8db94e241d022cd6e467e8596ec"/></dir><file name="Marketplace.php" hash="46606a1e2b253c603996c794f94b4309"/><dir name="Mysql4"><dir name="Log"><file name="Collection.php" hash="e3c7a389004afa2a116560e5501cb9fa"/></dir><file name="Log.php" hash="3cc46747828dc075638b115cb8bdbf68"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name="Observer.php" hash="b798657837ade214c3bf3e8a4b53ec64"/><file name="Order.php" hash="dbeee1bd9de5c9509d232de3c02d0e5d"/><dir name="Payment"><dir name="Method"><file name="Lengow.php" hash="41344a615275c14d06707ed63ec58e59"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Quote"><file name="Item.php" hash="5ac5bd4bdfceacabb6d090eaf724c0f4"/></dir><dir name="Shipping"><dir name="Carrier"><file name="Lengow.php" hash="64627df21b7d1d089ce7caa6fb3837a9"/></dir></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Lengow"><file name="LogController.php" hash="2eb76e322af63ee3639364ec4bb44017"/><file name="OrderController.php" hash="6d348a79987f24919d32beb454fa9b13"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name="ApiController.php" hash="4760695213bf840c18c8473b43304fda"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="etc"><file name="config.xml" hash="002ddde4cab11cd48d9cfece51478bd2"/><file name="marketplaces.xml" hash="a6a940eb5ae454fa4a373493a4d3d17f"/><file name="system.xml" hash="be59409e1daec954eeb3b9422fa01b9f"/></dir><dir name="sql"><dir name="lengow_setup"><file name="mysql4-install-2.0.0.0.php" hash="ec6f4fbc56eb98d2439d9e53a6d5906f"/><file name="mysql4-upgrade-2.0.0.0-2.0.0.1.php" hash="8a452156d98da3e2508e7e67fd6b3006"/></dir></dir><file name=".DS_Store" hash="dc971dc7108101d485bfc11f9d1bd4c0"/></dir><dir name="Tracker"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Check"><file name="Point.php" hash="b1b7be8e668e789ddfa26a615b4a5040"/></dir><file name="Check.php" hash="bc55760cc20b6ef21bf894f49454ea1e"/></dir></dir></dir><dir name="Tag"><file name="Capsule.php" hash="5e7bd8c4a7cab7245909cc22cf705f3f"/><file name="Simple.php" hash="5cae14470caf8393ed8eaf0b7b006996"/></dir><file name="Tracker.php" hash="b12dc4b32f1de2fb396620f317ce63bb"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Helper"><file name="Check.php" hash="cb25e508ce65cdfacef25de6084ae732"/><file name="Data.php" hash="e526694354fe760f266bf925e5e4ac39"/></dir><dir name="Model"><file name="Capsule.php" hash="36210d0a6808cff703abb5ccad12530e"/><file name="Config.php" hash="d475fd6dd049ed712f69e4a1bfc2036c"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Tracker.php" hash="8fdc4f1d9f02300525aeb295e9cd3dfc"/></dir></dir></dir><file name="Tracker.php" hash="51ebd82f9b572eb1242adf8aab7702d3"/></dir><dir name="etc"><file name="config.xml" hash="b9cff080c5e98ea335f95b8a21f44d62"/><file name="plugins.xml" hash="23cf26b5a39cf6fda8d12f27772ba5a4"/><file name="system.xml" hash="dbb8f083e9eceeb8ff47f71ba6cbf8a2"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="lengow.xml" hash="8bd6d3c25e5911481a5f105fe55833f1"/></dir><dir name="template"><dir name="lengow"><dir name="check"><file name="point.phtml" hash="5757a62a62b955327936ac9785fb5f31"/></dir><dir name="dashboard"><file name="charts.phtml" hash="7eaa1f13a48c401ca12aec27ebd48826"/></dir><dir name="export"><file name="product.phtml" hash="fcab2dbf0f9ff81992d9b1e75cc1b5c5"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="feed"><file name="grid.phtml" hash="7e965f793beb4847fad559506865a35e"/></dir><dir name="sales"><dir name="order"><dir name="tab"><file name="info.phtml" hash="fd76ca51399fd00b52f8430acce8555c"/></dir></dir><dir name="payment"><dir name="info"><file name="purchaseorder.phtml" hash="8e9e7a287ef57fe72023e28747fb0864"/></dir></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="lengow.xml" hash="6c936eef50a6394cbb5fce30f2f216d9"/></dir><dir name="template"><dir name="lengow"><dir name="tracker"><file name="simpletag.phtml" hash="2b761f6da02185a6931b30fddd679d64"/><file name="tag.phtml" hash="619f7bc6fe20c3dd6c1d82cdf12811b5"/><file name="tagcapsule.phtml" hash="2916e7693ef8ec9fcce5f5a8079d2beb"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="fr_FR"><file name="Lengow_Connector.csv" hash="2a201fc56652d7dcd61ab2a28a17580d"/></dir></target><target name="mageetc"><dir name="modules"><file name="Lengow_Connector.xml" hash="34b39beecc725740ea1e0bc8d339287a"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="lengow"><dir name="css"><file name="admin.css" hash="aa78dc26e735d8110b88d9974f72a502"/></dir><dir name="js"><file name="charts.min.js" hash="6806368c6a0bf73a5236b452fd5c2332"/><file name="tracker.js" hash="6402a4fbbb81a3b0587ec8c4c375e0a0"/></dir></dir></dir></dir></dir></target></contents>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
<compatible/>
|
18 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
</package>
|
skin/adminhtml/default/default/lengow/css/admin.css
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* lengow admin css */
|
2 |
+
#table-feeds, #lengow-info {
|
3 |
+
border:1px solid #ccc;
|
4 |
+
padding: 0px;
|
5 |
+
border-spacing: 0px;
|
6 |
+
border-radius:3px;
|
7 |
+
background-color:#fff;
|
8 |
+
width: 100%;
|
9 |
+
border-collapse: collapse;
|
10 |
+
}
|
11 |
+
|
12 |
+
#table-feeds thead span {
|
13 |
+
background-image: -moz-linear-gradient(center top , #F9F9F9, #ECECEC);
|
14 |
+
background: -webkit-gradient(linear, center top ,center bottom, from(#F9F9F9), to(#ECECEC)) repeat scroll 0 0 transparent;
|
15 |
+
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#F9F9F9', endColorstr='#ECECEC'); /* IE6 & IE7 */
|
16 |
+
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#F9F9F9', endColorstr='#ECECEC')"; /* IE8 */
|
17 |
+
color: #000;
|
18 |
+
text-shadow: 0 1px 0 #fff;
|
19 |
+
line-height: 35px;
|
20 |
+
display: block;
|
21 |
+
height: 39px;
|
22 |
+
border-left: none;
|
23 |
+
border-right: none;
|
24 |
+
}
|
25 |
+
|
26 |
+
#table-feeds thead span.first { text-align: center; }
|
27 |
+
|
28 |
+
#table-feeds thead span.last { }
|
29 |
+
|
30 |
+
#table-feeds thead th { margin: 0; }
|
31 |
+
|
32 |
+
#table-feeds tbody td { height: 35px;margin: 0; }
|
33 |
+
|
34 |
+
#table-feeds tbody tr:nth-child(even) { background-color: #EFEFEF; }
|
35 |
+
|
36 |
+
#lengow-info h5 {
|
37 |
+
background-image: -moz-linear-gradient(center top , #F9F9F9, #ECECEC);
|
38 |
+
background: -webkit-gradient(linear, center top ,center bottom, from(#F9F9F9), to(#ECECEC)) repeat scroll 0 0 transparent;
|
39 |
+
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#F9F9F9', endColorstr='#ECECEC'); /* IE6 & IE7 */
|
40 |
+
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#F9F9F9', endColorstr='#ECECEC')"; /* IE8 */
|
41 |
+
color: #000;
|
42 |
+
margin: 0;
|
43 |
+
line-height: 29px;
|
44 |
+
padding-left: 15px;
|
45 |
+
font-size: 12pt;
|
46 |
+
font-weight: normal;
|
47 |
+
display:block;
|
48 |
+
}
|
49 |
+
|
50 |
+
|
51 |
+
|
52 |
+
.process-icon-importlengow { background-image: url('../img/process-icon-export-csv.png'); }
|
53 |
+
|
54 |
+
.lengow-margin, .lengow-margin a, .lengow-margin p { font-size: 1em; }
|
55 |
+
|
56 |
+
.lengow-no { color: red; }
|
57 |
+
.lengow-yes { color: green; }
|
58 |
+
|
59 |
+
.lengow-select { min-width: 300px; }
|
60 |
+
|
61 |
+
.lengow-check {
|
62 |
+
display: inline-block;
|
63 |
+
padding: 6px 12px;
|
64 |
+
margin-bottom: 0;
|
65 |
+
font-size: 14px;
|
66 |
+
font-weight: normal;
|
67 |
+
line-height: 1.428571429;
|
68 |
+
text-align: center;
|
69 |
+
white-space: nowrap;
|
70 |
+
vertical-align: middle;
|
71 |
+
cursor: pointer;
|
72 |
+
background-image: none;
|
73 |
+
border: 1px solid transparent;
|
74 |
+
border-radius: 4px;
|
75 |
+
-webkit-user-select: none;
|
76 |
+
}
|
77 |
+
|
78 |
+
.lengow-updated {
|
79 |
+
margin-top: 5px;
|
80 |
+
margin-bottom: 5px;
|
81 |
+
color: #ffffff;
|
82 |
+
background-color: #5cb85c;
|
83 |
+
border-color: #4cae4c;
|
84 |
+
}
|
85 |
+
.lengow-must-be-updated {
|
86 |
+
color: #ffffff;
|
87 |
+
background-color: #d2322d;
|
88 |
+
border-color: #ac2925;
|
89 |
+
}
|
skin/adminhtml/default/default/lengow/js/charts.min.js
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var Chart=function(s){function v(a,c,b){a=A((a-c.graphMin)/(c.steps*c.stepValue),1,0);return b*c.steps*a}function x(a,c,b,e){function h(){g+=f;var k=a.animation?A(d(g),null,0):1;e.clearRect(0,0,q,u);a.scaleOverlay?(b(k),c()):(c(),b(k));if(1>=g)D(h);else if("function"==typeof a.onAnimationComplete)a.onAnimationComplete()}var f=a.animation?1/A(a.animationSteps,Number.MAX_VALUE,1):1,d=B[a.animationEasing],g=a.animation?0:1;"function"!==typeof c&&(c=function(){});D(h)}function C(a,c,b,e,h,f){var d;a=
|
2 |
+
Math.floor(Math.log(e-h)/Math.LN10);h=Math.floor(h/(1*Math.pow(10,a)))*Math.pow(10,a);e=Math.ceil(e/(1*Math.pow(10,a)))*Math.pow(10,a)-h;a=Math.pow(10,a);for(d=Math.round(e/a);d<b||d>c;)a=d<b?a/2:2*a,d=Math.round(e/a);c=[];z(f,c,d,h,a);return{steps:d,stepValue:a,graphMin:h,labels:c}}function z(a,c,b,e,h){if(a)for(var f=1;f<b+1;f++)c.push(E(a,{value:(e+h*f).toFixed(0!=h%1?h.toString().split(".")[1].length:0)}))}function A(a,c,b){return!isNaN(parseFloat(c))&&isFinite(c)&&a>c?c:!isNaN(parseFloat(b))&&
|
3 |
+
isFinite(b)&&a<b?b:a}function y(a,c){var b={},e;for(e in a)b[e]=a[e];for(e in c)b[e]=c[e];return b}function E(a,c){var b=!/\W/.test(a)?F[a]=F[a]||E(document.getElementById(a).innerHTML):new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+a.replace(/[\r\t\n]/g," ").split("<%").join("\t").replace(/((^|%>)[^\t]*)'/g,"$1\r").replace(/\t=(.*?)%>/g,"',$1,'").split("\t").join("');").split("%>").join("p.push('").split("\r").join("\\'")+"');}return p.join('');");return c?
|
4 |
+
b(c):b}var r=this,B={linear:function(a){return a},easeInQuad:function(a){return a*a},easeOutQuad:function(a){return-1*a*(a-2)},easeInOutQuad:function(a){return 1>(a/=0.5)?0.5*a*a:-0.5*(--a*(a-2)-1)},easeInCubic:function(a){return a*a*a},easeOutCubic:function(a){return 1*((a=a/1-1)*a*a+1)},easeInOutCubic:function(a){return 1>(a/=0.5)?0.5*a*a*a:0.5*((a-=2)*a*a+2)},easeInQuart:function(a){return a*a*a*a},easeOutQuart:function(a){return-1*((a=a/1-1)*a*a*a-1)},easeInOutQuart:function(a){return 1>(a/=0.5)?
|
5 |
+
0.5*a*a*a*a:-0.5*((a-=2)*a*a*a-2)},easeInQuint:function(a){return 1*(a/=1)*a*a*a*a},easeOutQuint:function(a){return 1*((a=a/1-1)*a*a*a*a+1)},easeInOutQuint:function(a){return 1>(a/=0.5)?0.5*a*a*a*a*a:0.5*((a-=2)*a*a*a*a+2)},easeInSine:function(a){return-1*Math.cos(a/1*(Math.PI/2))+1},easeOutSine:function(a){return 1*Math.sin(a/1*(Math.PI/2))},easeInOutSine:function(a){return-0.5*(Math.cos(Math.PI*a/1)-1)},easeInExpo:function(a){return 0==a?1:1*Math.pow(2,10*(a/1-1))},easeOutExpo:function(a){return 1==
|
6 |
+
a?1:1*(-Math.pow(2,-10*a/1)+1)},easeInOutExpo:function(a){return 0==a?0:1==a?1:1>(a/=0.5)?0.5*Math.pow(2,10*(a-1)):0.5*(-Math.pow(2,-10*--a)+2)},easeInCirc:function(a){return 1<=a?a:-1*(Math.sqrt(1-(a/=1)*a)-1)},easeOutCirc:function(a){return 1*Math.sqrt(1-(a=a/1-1)*a)},easeInOutCirc:function(a){return 1>(a/=0.5)?-0.5*(Math.sqrt(1-a*a)-1):0.5*(Math.sqrt(1-(a-=2)*a)+1)},easeInElastic:function(a){var c=1.70158,b=0,e=1;if(0==a)return 0;if(1==(a/=1))return 1;b||(b=0.3);e<Math.abs(1)?(e=1,c=b/4):c=b/(2*
|
7 |
+
Math.PI)*Math.asin(1/e);return-(e*Math.pow(2,10*(a-=1))*Math.sin((1*a-c)*2*Math.PI/b))},easeOutElastic:function(a){var c=1.70158,b=0,e=1;if(0==a)return 0;if(1==(a/=1))return 1;b||(b=0.3);e<Math.abs(1)?(e=1,c=b/4):c=b/(2*Math.PI)*Math.asin(1/e);return e*Math.pow(2,-10*a)*Math.sin((1*a-c)*2*Math.PI/b)+1},easeInOutElastic:function(a){var c=1.70158,b=0,e=1;if(0==a)return 0;if(2==(a/=0.5))return 1;b||(b=1*0.3*1.5);e<Math.abs(1)?(e=1,c=b/4):c=b/(2*Math.PI)*Math.asin(1/e);return 1>a?-0.5*e*Math.pow(2,10*
|
8 |
+
(a-=1))*Math.sin((1*a-c)*2*Math.PI/b):0.5*e*Math.pow(2,-10*(a-=1))*Math.sin((1*a-c)*2*Math.PI/b)+1},easeInBack:function(a){return 1*(a/=1)*a*(2.70158*a-1.70158)},easeOutBack:function(a){return 1*((a=a/1-1)*a*(2.70158*a+1.70158)+1)},easeInOutBack:function(a){var c=1.70158;return 1>(a/=0.5)?0.5*a*a*(((c*=1.525)+1)*a-c):0.5*((a-=2)*a*(((c*=1.525)+1)*a+c)+2)},easeInBounce:function(a){return 1-B.easeOutBounce(1-a)},easeOutBounce:function(a){return(a/=1)<1/2.75?1*7.5625*a*a:a<2/2.75?1*(7.5625*(a-=1.5/2.75)*
|
9 |
+
a+0.75):a<2.5/2.75?1*(7.5625*(a-=2.25/2.75)*a+0.9375):1*(7.5625*(a-=2.625/2.75)*a+0.984375)},easeInOutBounce:function(a){return 0.5>a?0.5*B.easeInBounce(2*a):0.5*B.easeOutBounce(2*a-1)+0.5}},q=s.canvas.width,u=s.canvas.height;window.devicePixelRatio&&(s.canvas.style.width=q+"px",s.canvas.style.height=u+"px",s.canvas.height=u*window.devicePixelRatio,s.canvas.width=q*window.devicePixelRatio,s.scale(window.devicePixelRatio,window.devicePixelRatio));this.PolarArea=function(a,c){r.PolarArea.defaults={scaleOverlay:!0,
|
10 |
+
scaleOverride:!1,scaleSteps:null,scaleStepWidth:null,scaleStartValue:null,scaleShowLine:!0,scaleLineColor:"rgba(0,0,0,.1)",scaleLineWidth:1,scaleShowLabels:!0,scaleLabel:"<%=value%>",scaleFontFamily:"'Arial'",scaleFontSize:12,scaleFontStyle:"normal",scaleFontColor:"#666",scaleShowLabelBackdrop:!0,scaleBackdropColor:"rgba(255,255,255,0.75)",scaleBackdropPaddingY:2,scaleBackdropPaddingX:2,segmentShowStroke:!0,segmentStrokeColor:"#fff",segmentStrokeWidth:2,animation:!0,animationSteps:100,animationEasing:"easeOutBounce",
|
11 |
+
animateRotate:!0,animateScale:!1,onAnimationComplete:null};var b=c?y(r.PolarArea.defaults,c):r.PolarArea.defaults;return new G(a,b,s)};this.Radar=function(a,c){r.Radar.defaults={scaleOverlay:!1,scaleOverride:!1,scaleSteps:null,scaleStepWidth:null,scaleStartValue:null,scaleShowLine:!0,scaleLineColor:"rgba(0,0,0,.1)",scaleLineWidth:1,scaleShowLabels:!1,scaleLabel:"<%=value%>",scaleFontFamily:"'Arial'",scaleFontSize:12,scaleFontStyle:"normal",scaleFontColor:"#666",scaleShowLabelBackdrop:!0,scaleBackdropColor:"rgba(255,255,255,0.75)",
|
12 |
+
scaleBackdropPaddingY:2,scaleBackdropPaddingX:2,angleShowLineOut:!0,angleLineColor:"rgba(0,0,0,.1)",angleLineWidth:1,pointLabelFontFamily:"'Arial'",pointLabelFontStyle:"normal",pointLabelFontSize:12,pointLabelFontColor:"#666",pointDot:!0,pointDotRadius:3,pointDotStrokeWidth:1,datasetStroke:!0,datasetStrokeWidth:2,datasetFill:!0,animation:!0,animationSteps:60,animationEasing:"easeOutQuart",onAnimationComplete:null};var b=c?y(r.Radar.defaults,c):r.Radar.defaults;return new H(a,b,s)};this.Pie=function(a,
|
13 |
+
c){r.Pie.defaults={segmentShowStroke:!0,segmentStrokeColor:"#fff",segmentStrokeWidth:2,animation:!0,animationSteps:100,animationEasing:"easeOutBounce",animateRotate:!0,animateScale:!1,onAnimationComplete:null};var b=c?y(r.Pie.defaults,c):r.Pie.defaults;return new I(a,b,s)};this.Doughnut=function(a,c){r.Doughnut.defaults={segmentShowStroke:!0,segmentStrokeColor:"#fff",segmentStrokeWidth:2,percentageInnerCutout:50,animation:!0,animationSteps:100,animationEasing:"easeOutBounce",animateRotate:!0,animateScale:!1,
|
14 |
+
onAnimationComplete:null};var b=c?y(r.Doughnut.defaults,c):r.Doughnut.defaults;return new J(a,b,s)};this.Line=function(a,c){r.Line.defaults={scaleOverlay:!1,scaleOverride:!1,scaleSteps:null,scaleStepWidth:null,scaleStartValue:null,scaleLineColor:"rgba(0,0,0,.1)",scaleLineWidth:1,scaleShowLabels:!0,scaleLabel:"<%=value%>",scaleFontFamily:"'Arial'",scaleFontSize:12,scaleFontStyle:"normal",scaleFontColor:"#666",scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,bezierCurve:!0,
|
15 |
+
pointDot:!0,pointDotRadius:4,pointDotStrokeWidth:2,datasetStroke:!0,datasetStrokeWidth:2,datasetFill:!0,animation:!0,animationSteps:60,animationEasing:"easeOutQuart",onAnimationComplete:null};var b=c?y(r.Line.defaults,c):r.Line.defaults;return new K(a,b,s)};this.Bar=function(a,c){r.Bar.defaults={scaleOverlay:!1,scaleOverride:!1,scaleSteps:null,scaleStepWidth:null,scaleStartValue:null,scaleLineColor:"rgba(0,0,0,.1)",scaleLineWidth:1,scaleShowLabels:!0,scaleLabel:"<%=value%>",scaleFontFamily:"'Arial'",
|
16 |
+
scaleFontSize:12,scaleFontStyle:"normal",scaleFontColor:"#666",scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,barShowStroke:!0,barStrokeWidth:2,barValueSpacing:5,barDatasetSpacing:1,animation:!0,animationSteps:60,animationEasing:"easeOutQuart",onAnimationComplete:null};var b=c?y(r.Bar.defaults,c):r.Bar.defaults;return new L(a,b,s)};var G=function(a,c,b){var e,h,f,d,g,k,j,l,m;g=Math.min.apply(Math,[q,u])/2;g-=Math.max.apply(Math,[0.5*c.scaleFontSize,0.5*c.scaleLineWidth]);
|
17 |
+
d=2*c.scaleFontSize;c.scaleShowLabelBackdrop&&(d+=2*c.scaleBackdropPaddingY,g-=1.5*c.scaleBackdropPaddingY);l=g;d=d?d:5;e=Number.MIN_VALUE;h=Number.MAX_VALUE;for(f=0;f<a.length;f++)a[f].value>e&&(e=a[f].value),a[f].value<h&&(h=a[f].value);f=Math.floor(l/(0.66*d));d=Math.floor(0.5*(l/d));m=c.scaleShowLabels?c.scaleLabel:null;c.scaleOverride?(j={steps:c.scaleSteps,stepValue:c.scaleStepWidth,graphMin:c.scaleStartValue,labels:[]},z(m,j.labels,j.steps,c.scaleStartValue,c.scaleStepWidth)):j=C(l,f,d,e,h,
|
18 |
+
m);k=g/j.steps;x(c,function(){for(var a=0;a<j.steps;a++)if(c.scaleShowLine&&(b.beginPath(),b.arc(q/2,u/2,k*(a+1),0,2*Math.PI,!0),b.strokeStyle=c.scaleLineColor,b.lineWidth=c.scaleLineWidth,b.stroke()),c.scaleShowLabels){b.textAlign="center";b.font=c.scaleFontStyle+" "+c.scaleFontSize+"px "+c.scaleFontFamily;var e=j.labels[a];if(c.scaleShowLabelBackdrop){var d=b.measureText(e).width;b.fillStyle=c.scaleBackdropColor;b.beginPath();b.rect(Math.round(q/2-d/2-c.scaleBackdropPaddingX),Math.round(u/2-k*(a+
|
19 |
+
1)-0.5*c.scaleFontSize-c.scaleBackdropPaddingY),Math.round(d+2*c.scaleBackdropPaddingX),Math.round(c.scaleFontSize+2*c.scaleBackdropPaddingY));b.fill()}b.textBaseline="middle";b.fillStyle=c.scaleFontColor;b.fillText(e,q/2,u/2-k*(a+1))}},function(e){var d=-Math.PI/2,g=2*Math.PI/a.length,f=1,h=1;c.animation&&(c.animateScale&&(f=e),c.animateRotate&&(h=e));for(e=0;e<a.length;e++)b.beginPath(),b.arc(q/2,u/2,f*v(a[e].value,j,k),d,d+h*g,!1),b.lineTo(q/2,u/2),b.closePath(),b.fillStyle=a[e].color,b.fill(),
|
20 |
+
c.segmentShowStroke&&(b.strokeStyle=c.segmentStrokeColor,b.lineWidth=c.segmentStrokeWidth,b.stroke()),d+=h*g},b)},H=function(a,c,b){var e,h,f,d,g,k,j,l,m;a.labels||(a.labels=[]);g=Math.min.apply(Math,[q,u])/2;d=2*c.scaleFontSize;for(e=l=0;e<a.labels.length;e++)b.font=c.pointLabelFontStyle+" "+c.pointLabelFontSize+"px "+c.pointLabelFontFamily,h=b.measureText(a.labels[e]).width,h>l&&(l=h);g-=Math.max.apply(Math,[l,1.5*(c.pointLabelFontSize/2)]);g-=c.pointLabelFontSize;l=g=A(g,null,0);d=d?d:5;e=Number.MIN_VALUE;
|
21 |
+
h=Number.MAX_VALUE;for(f=0;f<a.datasets.length;f++)for(m=0;m<a.datasets[f].data.length;m++)a.datasets[f].data[m]>e&&(e=a.datasets[f].data[m]),a.datasets[f].data[m]<h&&(h=a.datasets[f].data[m]);f=Math.floor(l/(0.66*d));d=Math.floor(0.5*(l/d));m=c.scaleShowLabels?c.scaleLabel:null;c.scaleOverride?(j={steps:c.scaleSteps,stepValue:c.scaleStepWidth,graphMin:c.scaleStartValue,labels:[]},z(m,j.labels,j.steps,c.scaleStartValue,c.scaleStepWidth)):j=C(l,f,d,e,h,m);k=g/j.steps;x(c,function(){var e=2*Math.PI/
|
22 |
+
a.datasets[0].data.length;b.save();b.translate(q/2,u/2);if(c.angleShowLineOut){b.strokeStyle=c.angleLineColor;b.lineWidth=c.angleLineWidth;for(var d=0;d<a.datasets[0].data.length;d++)b.rotate(e),b.beginPath(),b.moveTo(0,0),b.lineTo(0,-g),b.stroke()}for(d=0;d<j.steps;d++){b.beginPath();if(c.scaleShowLine){b.strokeStyle=c.scaleLineColor;b.lineWidth=c.scaleLineWidth;b.moveTo(0,-k*(d+1));for(var f=0;f<a.datasets[0].data.length;f++)b.rotate(e),b.lineTo(0,-k*(d+1));b.closePath();b.stroke()}c.scaleShowLabels&&
|
23 |
+
(b.textAlign="center",b.font=c.scaleFontStyle+" "+c.scaleFontSize+"px "+c.scaleFontFamily,b.textBaseline="middle",c.scaleShowLabelBackdrop&&(f=b.measureText(j.labels[d]).width,b.fillStyle=c.scaleBackdropColor,b.beginPath(),b.rect(Math.round(-f/2-c.scaleBackdropPaddingX),Math.round(-k*(d+1)-0.5*c.scaleFontSize-c.scaleBackdropPaddingY),Math.round(f+2*c.scaleBackdropPaddingX),Math.round(c.scaleFontSize+2*c.scaleBackdropPaddingY)),b.fill()),b.fillStyle=c.scaleFontColor,b.fillText(j.labels[d],0,-k*(d+
|
24 |
+
1)))}for(d=0;d<a.labels.length;d++){b.font=c.pointLabelFontStyle+" "+c.pointLabelFontSize+"px "+c.pointLabelFontFamily;b.fillStyle=c.pointLabelFontColor;var f=Math.sin(e*d)*(g+c.pointLabelFontSize),h=Math.cos(e*d)*(g+c.pointLabelFontSize);b.textAlign=e*d==Math.PI||0==e*d?"center":e*d>Math.PI?"right":"left";b.textBaseline="middle";b.fillText(a.labels[d],f,-h)}b.restore()},function(d){var e=2*Math.PI/a.datasets[0].data.length;b.save();b.translate(q/2,u/2);for(var g=0;g<a.datasets.length;g++){b.beginPath();
|
25 |
+
b.moveTo(0,d*-1*v(a.datasets[g].data[0],j,k));for(var f=1;f<a.datasets[g].data.length;f++)b.rotate(e),b.lineTo(0,d*-1*v(a.datasets[g].data[f],j,k));b.closePath();b.fillStyle=a.datasets[g].fillColor;b.strokeStyle=a.datasets[g].strokeColor;b.lineWidth=c.datasetStrokeWidth;b.fill();b.stroke();if(c.pointDot){b.fillStyle=a.datasets[g].pointColor;b.strokeStyle=a.datasets[g].pointStrokeColor;b.lineWidth=c.pointDotStrokeWidth;for(f=0;f<a.datasets[g].data.length;f++)b.rotate(e),b.beginPath(),b.arc(0,d*-1*
|
26 |
+
v(a.datasets[g].data[f],j,k),c.pointDotRadius,2*Math.PI,!1),b.fill(),b.stroke()}b.rotate(e)}b.restore()},b)},I=function(a,c,b){for(var e=0,h=Math.min.apply(Math,[u/2,q/2])-5,f=0;f<a.length;f++)e+=a[f].value;x(c,null,function(d){var g=-Math.PI/2,f=1,j=1;c.animation&&(c.animateScale&&(f=d),c.animateRotate&&(j=d));for(d=0;d<a.length;d++){var l=j*a[d].value/e*2*Math.PI;b.beginPath();b.arc(q/2,u/2,f*h,g,g+l);b.lineTo(q/2,u/2);b.closePath();b.fillStyle=a[d].color;b.fill();c.segmentShowStroke&&(b.lineWidth=
|
27 |
+
c.segmentStrokeWidth,b.strokeStyle=c.segmentStrokeColor,b.stroke());g+=l}},b)},J=function(a,c,b){for(var e=0,h=Math.min.apply(Math,[u/2,q/2])-5,f=h*(c.percentageInnerCutout/100),d=0;d<a.length;d++)e+=a[d].value;x(c,null,function(d){var k=-Math.PI/2,j=1,l=1;c.animation&&(c.animateScale&&(j=d),c.animateRotate&&(l=d));for(d=0;d<a.length;d++){var m=l*a[d].value/e*2*Math.PI;b.beginPath();b.arc(q/2,u/2,j*h,k,k+m,!1);b.arc(q/2,u/2,j*f,k+m,k,!0);b.closePath();b.fillStyle=a[d].color;b.fill();c.segmentShowStroke&&
|
28 |
+
(b.lineWidth=c.segmentStrokeWidth,b.strokeStyle=c.segmentStrokeColor,b.stroke());k+=m}},b)},K=function(a,c,b){var e,h,f,d,g,k,j,l,m,t,r,n,p,s=0;g=u;b.font=c.scaleFontStyle+" "+c.scaleFontSize+"px "+c.scaleFontFamily;t=1;for(d=0;d<a.labels.length;d++)e=b.measureText(a.labels[d]).width,t=e>t?e:t;q/a.labels.length<t?(s=45,q/a.labels.length<Math.cos(s)*t?(s=90,g-=t):g-=Math.sin(s)*t):g-=c.scaleFontSize;d=c.scaleFontSize;g=g-5-d;e=Number.MIN_VALUE;h=Number.MAX_VALUE;for(f=0;f<a.datasets.length;f++)for(l=
|
29 |
+
0;l<a.datasets[f].data.length;l++)a.datasets[f].data[l]>e&&(e=a.datasets[f].data[l]),a.datasets[f].data[l]<h&&(h=a.datasets[f].data[l]);f=Math.floor(g/(0.66*d));d=Math.floor(0.5*(g/d));l=c.scaleShowLabels?c.scaleLabel:"";c.scaleOverride?(j={steps:c.scaleSteps,stepValue:c.scaleStepWidth,graphMin:c.scaleStartValue,labels:[]},z(l,j.labels,j.steps,c.scaleStartValue,c.scaleStepWidth)):j=C(g,f,d,e,h,l);k=Math.floor(g/j.steps);d=1;if(c.scaleShowLabels){b.font=c.scaleFontStyle+" "+c.scaleFontSize+"px "+c.scaleFontFamily;
|
30 |
+
for(e=0;e<j.labels.length;e++)h=b.measureText(j.labels[e]).width,d=h>d?h:d;d+=10}r=q-d-t;m=Math.floor(r/(a.labels.length-1));n=q-t/2-r;p=g+c.scaleFontSize/2;x(c,function(){b.lineWidth=c.scaleLineWidth;b.strokeStyle=c.scaleLineColor;b.beginPath();b.moveTo(q-t/2+5,p);b.lineTo(q-t/2-r-5,p);b.stroke();0<s?(b.save(),b.textAlign="right"):b.textAlign="center";b.fillStyle=c.scaleFontColor;for(var d=0;d<a.labels.length;d++)b.save(),0<s?(b.translate(n+d*m,p+c.scaleFontSize),b.rotate(-(s*(Math.PI/180))),b.fillText(a.labels[d],
|
31 |
+
0,0),b.restore()):b.fillText(a.labels[d],n+d*m,p+c.scaleFontSize+3),b.beginPath(),b.moveTo(n+d*m,p+3),c.scaleShowGridLines&&0<d?(b.lineWidth=c.scaleGridLineWidth,b.strokeStyle=c.scaleGridLineColor,b.lineTo(n+d*m,5)):b.lineTo(n+d*m,p+3),b.stroke();b.lineWidth=c.scaleLineWidth;b.strokeStyle=c.scaleLineColor;b.beginPath();b.moveTo(n,p+5);b.lineTo(n,5);b.stroke();b.textAlign="right";b.textBaseline="middle";for(d=0;d<j.steps;d++)b.beginPath(),b.moveTo(n-3,p-(d+1)*k),c.scaleShowGridLines?(b.lineWidth=c.scaleGridLineWidth,
|
32 |
+
b.strokeStyle=c.scaleGridLineColor,b.lineTo(n+r+5,p-(d+1)*k)):b.lineTo(n-0.5,p-(d+1)*k),b.stroke(),c.scaleShowLabels&&b.fillText(j.labels[d],n-8,p-(d+1)*k)},function(d){function e(b,c){return p-d*v(a.datasets[b].data[c],j,k)}for(var f=0;f<a.datasets.length;f++){b.strokeStyle=a.datasets[f].strokeColor;b.lineWidth=c.datasetStrokeWidth;b.beginPath();b.moveTo(n,p-d*v(a.datasets[f].data[0],j,k));for(var g=1;g<a.datasets[f].data.length;g++)c.bezierCurve?b.bezierCurveTo(n+m*(g-0.5),e(f,g-1),n+m*(g-0.5),
|
33 |
+
e(f,g),n+m*g,e(f,g)):b.lineTo(n+m*g,e(f,g));b.stroke();c.datasetFill?(b.lineTo(n+m*(a.datasets[f].data.length-1),p),b.lineTo(n,p),b.closePath(),b.fillStyle=a.datasets[f].fillColor,b.fill()):b.closePath();if(c.pointDot){b.fillStyle=a.datasets[f].pointColor;b.strokeStyle=a.datasets[f].pointStrokeColor;b.lineWidth=c.pointDotStrokeWidth;for(g=0;g<a.datasets[f].data.length;g++)b.beginPath(),b.arc(n+m*g,p-d*v(a.datasets[f].data[g],j,k),c.pointDotRadius,0,2*Math.PI,!0),b.fill(),b.stroke()}}},b)},L=function(a,
|
34 |
+
c,b){var e,h,f,d,g,k,j,l,m,t,r,n,p,s,w=0;g=u;b.font=c.scaleFontStyle+" "+c.scaleFontSize+"px "+c.scaleFontFamily;t=1;for(d=0;d<a.labels.length;d++)e=b.measureText(a.labels[d]).width,t=e>t?e:t;q/a.labels.length<t?(w=45,q/a.labels.length<Math.cos(w)*t?(w=90,g-=t):g-=Math.sin(w)*t):g-=c.scaleFontSize;d=c.scaleFontSize;g=g-5-d;e=Number.MIN_VALUE;h=Number.MAX_VALUE;for(f=0;f<a.datasets.length;f++)for(l=0;l<a.datasets[f].data.length;l++)a.datasets[f].data[l]>e&&(e=a.datasets[f].data[l]),a.datasets[f].data[l]<
|
35 |
+
h&&(h=a.datasets[f].data[l]);f=Math.floor(g/(0.66*d));d=Math.floor(0.5*(g/d));l=c.scaleShowLabels?c.scaleLabel:"";c.scaleOverride?(j={steps:c.scaleSteps,stepValue:c.scaleStepWidth,graphMin:c.scaleStartValue,labels:[]},z(l,j.labels,j.steps,c.scaleStartValue,c.scaleStepWidth)):j=C(g,f,d,e,h,l);k=Math.floor(g/j.steps);d=1;if(c.scaleShowLabels){b.font=c.scaleFontStyle+" "+c.scaleFontSize+"px "+c.scaleFontFamily;for(e=0;e<j.labels.length;e++)h=b.measureText(j.labels[e]).width,d=h>d?h:d;d+=10}r=q-d-t;m=
|
36 |
+
Math.floor(r/a.labels.length);s=(m-2*c.scaleGridLineWidth-2*c.barValueSpacing-(c.barDatasetSpacing*a.datasets.length-1)-(c.barStrokeWidth/2*a.datasets.length-1))/a.datasets.length;n=q-t/2-r;p=g+c.scaleFontSize/2;x(c,function(){b.lineWidth=c.scaleLineWidth;b.strokeStyle=c.scaleLineColor;b.beginPath();b.moveTo(q-t/2+5,p);b.lineTo(q-t/2-r-5,p);b.stroke();0<w?(b.save(),b.textAlign="right"):b.textAlign="center";b.fillStyle=c.scaleFontColor;for(var d=0;d<a.labels.length;d++)b.save(),0<w?(b.translate(n+
|
37 |
+
d*m,p+c.scaleFontSize),b.rotate(-(w*(Math.PI/180))),b.fillText(a.labels[d],0,0),b.restore()):b.fillText(a.labels[d],n+d*m+m/2,p+c.scaleFontSize+3),b.beginPath(),b.moveTo(n+(d+1)*m,p+3),b.lineWidth=c.scaleGridLineWidth,b.strokeStyle=c.scaleGridLineColor,b.lineTo(n+(d+1)*m,5),b.stroke();b.lineWidth=c.scaleLineWidth;b.strokeStyle=c.scaleLineColor;b.beginPath();b.moveTo(n,p+5);b.lineTo(n,5);b.stroke();b.textAlign="right";b.textBaseline="middle";for(d=0;d<j.steps;d++)b.beginPath(),b.moveTo(n-3,p-(d+1)*
|
38 |
+
k),c.scaleShowGridLines?(b.lineWidth=c.scaleGridLineWidth,b.strokeStyle=c.scaleGridLineColor,b.lineTo(n+r+5,p-(d+1)*k)):b.lineTo(n-0.5,p-(d+1)*k),b.stroke(),c.scaleShowLabels&&b.fillText(j.labels[d],n-8,p-(d+1)*k)},function(d){b.lineWidth=c.barStrokeWidth;for(var e=0;e<a.datasets.length;e++){b.fillStyle=a.datasets[e].fillColor;b.strokeStyle=a.datasets[e].strokeColor;for(var f=0;f<a.datasets[e].data.length;f++){var g=n+c.barValueSpacing+m*f+s*e+c.barDatasetSpacing*e+c.barStrokeWidth*e;b.beginPath();
|
39 |
+
b.moveTo(g,p);b.lineTo(g,p-d*v(a.datasets[e].data[f],j,k)+c.barStrokeWidth/2);b.lineTo(g+s,p-d*v(a.datasets[e].data[f],j,k)+c.barStrokeWidth/2);b.lineTo(g+s,p);c.barShowStroke&&b.stroke();b.closePath();b.fill()}}},b)},D=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)},F={}};
|
skin/adminhtml/default/default/lengow/js/tracker.js
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
document.observe("dom:loaded", function() {
|
2 |
+
var script_url = $('url_script').readAttribute('src');
|
3 |
+
var body = $$('body')[0];
|
4 |
+
var current_section = '';
|
5 |
+
|
6 |
+
if (typeof Checkout !== 'undefined') {
|
7 |
+
Checkout.prototype.gotoSection = function(section) {
|
8 |
+
if(section !== current_section) {
|
9 |
+
current_section = section;
|
10 |
+
|
11 |
+
var content_script = $('lengow_tracker').innerHTML;
|
12 |
+
var script = new Element('script', {type: 'text/javascript', src: script_url});
|
13 |
+
|
14 |
+
if (section === 'billing' && this.method === 'guest') {
|
15 |
+
window.page = 'lead';
|
16 |
+
body.appendChild(script);
|
17 |
+
} else if (section === 'payment') {
|
18 |
+
window.page = 'basket';
|
19 |
+
body.appendChild(script);
|
20 |
+
// Set var page to 'basket'
|
21 |
+
/*var new_content = content_script.replace(/page = \'\w+\'/, 'page = \'basket\'')
|
22 |
+
var script = new Element('script', {type: 'text/javascript', src: script_url});
|
23 |
+
alert(new_content);*/
|
24 |
+
//$('lengow_tracker').update(new_content);
|
25 |
+
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
var sectionElement = $('opc-' + section);
|
30 |
+
sectionElement.addClassName('allow');
|
31 |
+
this.accordion.openSection('opc-' + section);
|
32 |
+
this.reloadProgressBlock(section);
|
33 |
+
}
|
34 |
+
}
|
35 |
+
});
|