DHL_MeinPaket2 - Version 2.0.8

Version Notes

--

Download this release

Release Info

Developer DHL Vertriebs GmbH
Extension DHL_MeinPaket2
Version 2.0.8
Comparing to
See all releases


Version 2.0.8

Files changed (193) hide show
  1. app/code/community/Dhl/MeinPaket/Block/Adminhtml/Async.php +30 -0
  2. app/code/community/Dhl/MeinPaket/Block/Adminhtml/Async/Grid.php +65 -0
  3. app/code/community/Dhl/MeinPaket/Block/Adminhtml/Backlog/Product.php +70 -0
  4. app/code/community/Dhl/MeinPaket/Block/Adminhtml/Backlog/Product/Grid.php +75 -0
  5. app/code/community/Dhl/MeinPaket/Block/Adminhtml/BestPrice.php +22 -0
  6. app/code/community/Dhl/MeinPaket/Block/Adminhtml/BestPrice/Grid.php +88 -0
  7. app/code/community/Dhl/MeinPaket/Block/Adminhtml/Catalog/Product/Matching/Result.php +17 -0
  8. app/code/community/Dhl/MeinPaket/Block/Adminhtml/Catalog/Product/Matching/Tab.php +56 -0
  9. app/code/community/Dhl/MeinPaket/Block/Adminhtml/CategoryImport/Import.php +57 -0
  10. app/code/community/Dhl/MeinPaket/Block/Adminhtml/CategoryImport/Index.php +23 -0
  11. app/code/community/Dhl/MeinPaket/Block/Adminhtml/LeftMenu.php +63 -0
  12. app/code/community/Dhl/MeinPaket/Block/Adminhtml/Log.php +22 -0
  13. app/code/community/Dhl/MeinPaket/Block/Adminhtml/Log/Grid.php +76 -0
  14. app/code/community/Dhl/MeinPaket/Block/Adminhtml/OrderImport/Index.php +23 -0
  15. app/code/community/Dhl/MeinPaket/Block/Adminhtml/ProductExport/Export.php +72 -0
  16. app/code/community/Dhl/MeinPaket/Block/Adminhtml/ProductExport/Index.php +23 -0
  17. app/code/community/Dhl/MeinPaket/Block/Adminhtml/ProductExport/List.php +32 -0
  18. app/code/community/Dhl/MeinPaket/Block/Adminhtml/Steps.php +66 -0
  19. app/code/community/Dhl/MeinPaket/Block/Checkout/Abort.php +12 -0
  20. app/code/community/Dhl/MeinPaket/Block/Checkout/Error.php +12 -0
  21. app/code/community/Dhl/MeinPaket/Block/Checkout/Success.php +12 -0
  22. app/code/community/Dhl/MeinPaket/Helper/Attribute.php +25 -0
  23. app/code/community/Dhl/MeinPaket/Helper/Backlog.php +76 -0
  24. app/code/community/Dhl/MeinPaket/Helper/Cron.php +68 -0
  25. app/code/community/Dhl/MeinPaket/Helper/Data.php +91 -0
  26. app/code/community/Dhl/MeinPaket/Helper/Order.php +22 -0
  27. app/code/community/Dhl/MeinPaket/Helper/Product.php +353 -0
  28. app/code/community/Dhl/MeinPaket/Helper/Shipment.php +34 -0
  29. app/code/community/Dhl/MeinPaket/Model/Async.php +7 -0
  30. app/code/community/Dhl/MeinPaket/Model/Attribute/Mapping.php +6 -0
  31. app/code/community/Dhl/MeinPaket/Model/Backlog/Product.php +7 -0
  32. app/code/community/Dhl/MeinPaket/Model/BestPrice.php +7 -0
  33. app/code/community/Dhl/MeinPaket/Model/Carrier/Meinpaket.php +111 -0
  34. app/code/community/Dhl/MeinPaket/Model/Category.php +20 -0
  35. app/code/community/Dhl/MeinPaket/Model/Client/BadHttpReturnCodeException.php +39 -0
  36. app/code/community/Dhl/MeinPaket/Model/Client/HttpException.php +14 -0
  37. app/code/community/Dhl/MeinPaket/Model/Client/HttpTimeoutException.php +14 -0
  38. app/code/community/Dhl/MeinPaket/Model/Client/XmlOverHttp.php +151 -0
  39. app/code/community/Dhl/MeinPaket/Model/Cron.php +99 -0
  40. app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Frontend/LabelTranslation.php +22 -0
  41. app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Source/Carrier.php +51 -0
  42. app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Source/MeinPaketCategory.php +88 -0
  43. app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Source/ProductAttribute.php +43 -0
  44. app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Source/ProductSyncMode.php +92 -0
  45. app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Source/Taxclass.php +51 -0
  46. app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Source/Taxrate.php +49 -0
  47. app/code/community/Dhl/MeinPaket/Model/Exception/InvalidDataException.php +73 -0
  48. app/code/community/Dhl/MeinPaket/Model/Exception/MissingDataException.php +26 -0
  49. app/code/community/Dhl/MeinPaket/Model/Log.php +21 -0
  50. app/code/community/Dhl/MeinPaket/Model/Mysql4/Async.php +11 -0
  51. app/code/community/Dhl/MeinPaket/Model/Mysql4/Async/Collection.php +11 -0
  52. app/code/community/Dhl/MeinPaket/Model/Mysql4/Backlog/Product.php +11 -0
  53. app/code/community/Dhl/MeinPaket/Model/Mysql4/Backlog/Product/Collection.php +11 -0
  54. app/code/community/Dhl/MeinPaket/Model/Mysql4/BestPrice.php +11 -0
  55. app/code/community/Dhl/MeinPaket/Model/Mysql4/BestPrice/Collection.php +11 -0
  56. app/code/community/Dhl/MeinPaket/Model/Mysql4/Category.php +15 -0
  57. app/code/community/Dhl/MeinPaket/Model/Mysql4/Category/Collection.php +20 -0
  58. app/code/community/Dhl/MeinPaket/Model/Mysql4/Log.php +11 -0
  59. app/code/community/Dhl/MeinPaket/Model/Mysql4/Log/Collection.php +11 -0
  60. app/code/community/Dhl/MeinPaket/Model/Observer.php +691 -0
  61. app/code/community/Dhl/MeinPaket/Model/Payment/Method/Meinpaket.php +22 -0
  62. app/code/community/Dhl/MeinPaket/Model/Resource/Eav/Mysql4/Setup.php +127 -0
  63. app/code/community/Dhl/MeinPaket/Model/Service/Abstract.php +110 -0
  64. app/code/community/Dhl/MeinPaket/Model/Service/Async.php +52 -0
  65. app/code/community/Dhl/MeinPaket/Model/Service/MarketplaceCategoryImport/ImportService.php +149 -0
  66. app/code/community/Dhl/MeinPaket/Model/Service/MarketplaceCategoryImport/Result.php +129 -0
  67. app/code/community/Dhl/MeinPaket/Model/Service/Order/CancellationService.php +85 -0
  68. app/code/community/Dhl/MeinPaket/Model/Service/Order/CancellationService/Result.php +93 -0
  69. app/code/community/Dhl/MeinPaket/Model/Service/Order/ImportService.php +440 -0
  70. app/code/community/Dhl/MeinPaket/Model/Service/Order/RefundExportService.php +50 -0
  71. app/code/community/Dhl/MeinPaket/Model/Service/Order/RefundExportService/Result.php +58 -0
  72. app/code/community/Dhl/MeinPaket/Model/Service/Order/ShipmentExportService.php +71 -0
  73. app/code/community/Dhl/MeinPaket/Model/Service/Order/ShipmentExportService/Result.php +57 -0
  74. app/code/community/Dhl/MeinPaket/Model/Service/Product/Export.php +112 -0
  75. app/code/community/Dhl/MeinPaket/Model/Service/Product/Export/Exception/InvalidEan.php +21 -0
  76. app/code/community/Dhl/MeinPaket/Model/Service/ProductData/RequestService.php +79 -0
  77. app/code/community/Dhl/MeinPaket/Model/Service/Result/Abstract.php +63 -0
  78. app/code/community/Dhl/MeinPaket/Model/Service/Result/Upload.php +13 -0
  79. app/code/community/Dhl/MeinPaket/Model/System/Config/Source/Attributes.php +104 -0
  80. app/code/community/Dhl/MeinPaket/Model/System/MemoryLimiter.php +74 -0
  81. app/code/community/Dhl/MeinPaket/Model/Validation/ValidationInterface.php +28 -0
  82. app/code/community/Dhl/MeinPaket/Model/Validation/Validator/CDATAContent.php +22 -0
  83. app/code/community/Dhl/MeinPaket/Model/Validation/Validator/Ean.php +59 -0
  84. app/code/community/Dhl/MeinPaket/Model/Validation/Validator/IntGreaterZero.php +22 -0
  85. app/code/community/Dhl/MeinPaket/Model/Validation/Validator/NonEmptyString.php +23 -0
  86. app/code/community/Dhl/MeinPaket/Model/Validation/Validator/StringMaxLength.php +58 -0
  87. app/code/community/Dhl/MeinPaket/Model/Validation/Validator/Url.php +22 -0
  88. app/code/community/Dhl/MeinPaket/Model/Validation/ValidatorChain.php +48 -0
  89. app/code/community/Dhl/MeinPaket/Model/Validation/ValidatorFactory.php +76 -0
  90. app/code/community/Dhl/MeinPaket/Model/Validation/ValidatorInterface.php +21 -0
  91. app/code/community/Dhl/MeinPaket/Model/Xml/AbstractXmlPartial.php +186 -0
  92. app/code/community/Dhl/MeinPaket/Model/Xml/AbstractXmlRequest.php +112 -0
  93. app/code/community/Dhl/MeinPaket/Model/Xml/InvalidXmlException.php +13 -0
  94. app/code/community/Dhl/MeinPaket/Model/Xml/Request/AsynchronousStatusRequest.php +59 -0
  95. app/code/community/Dhl/MeinPaket/Model/Xml/Request/DataRequest.php +108 -0
  96. app/code/community/Dhl/MeinPaket/Model/Xml/Request/DownloadRequest.php +48 -0
  97. app/code/community/Dhl/MeinPaket/Model/Xml/Request/NotificationRequest.php +254 -0
  98. app/code/community/Dhl/MeinPaket/Model/Xml/Request/QueryRequest.php +72 -0
  99. app/code/community/Dhl/MeinPaket/Model/Xml/Request/SubmitCartRequest.php +32 -0
  100. app/code/community/Dhl/MeinPaket/Model/Xml/Request/UploadRequest.php +432 -0
  101. app/code/community/Dhl/MeinPaket/Model/Xml/Response/Abstract.php +150 -0
  102. app/code/community/Dhl/MeinPaket/Model/Xml/Response/AsynchronousStatusResponse.php +63 -0
  103. app/code/community/Dhl/MeinPaket/Model/Xml/Response/DataResponse.php +116 -0
  104. app/code/community/Dhl/MeinPaket/Model/Xml/Response/DownloadResponse.php +46 -0
  105. app/code/community/Dhl/MeinPaket/Model/Xml/Response/NotificationResponse.php +30 -0
  106. app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/Address.php +154 -0
  107. app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/Attribute.php +35 -0
  108. app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/Category.php +46 -0
  109. app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/CategoryId.php +20 -0
  110. app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/DataResponse/BestPrice.php +85 -0
  111. app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/DataResponse/Confirmation.php +34 -0
  112. app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/DataResponse/MerchantData.php +34 -0
  113. app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/DataResponse/ProductData.php +64 -0
  114. app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/DataResponse/QuotaData.php +33 -0
  115. app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/NotificationResponse/Confirmation.php +58 -0
  116. app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/NotificationResponse/Consignment.php +37 -0
  117. app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/NotificationResponse/Credit.php +36 -0
  118. app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/NotificationResponse/Return.php +36 -0
  119. app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/Order.php +119 -0
  120. app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/Order/ContactData.php +31 -0
  121. app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/Order/Entry.php +76 -0
  122. app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/ProductId.php +55 -0
  123. app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/VariantConfiguration.php +88 -0
  124. app/code/community/Dhl/MeinPaket/Model/Xml/Response/QueryResponse.php +34 -0
  125. app/code/community/Dhl/MeinPaket/Model/Xml/Response/UploadResponse.php +92 -0
  126. app/code/community/Dhl/MeinPaket/Model/Xml/XmlBuildException.php +14 -0
  127. app/code/community/Dhl/MeinPaket/Model/Xml/XmlRequestFactory.php +551 -0
  128. app/code/community/Dhl/MeinPaket/Model/Xml/XmlResponseParser.php +58 -0
  129. app/code/community/Dhl/MeinPaket/controllers/Adminhtml/AsyncController.php +89 -0
  130. app/code/community/Dhl/MeinPaket/controllers/Adminhtml/Backlog/ProductController.php +85 -0
  131. app/code/community/Dhl/MeinPaket/controllers/Adminhtml/BestPriceController.php +33 -0
  132. app/code/community/Dhl/MeinPaket/controllers/Adminhtml/CategoryImportController.php +93 -0
  133. app/code/community/Dhl/MeinPaket/controllers/Adminhtml/LogController.php +71 -0
  134. app/code/community/Dhl/MeinPaket/controllers/Adminhtml/MatchingController.php +52 -0
  135. app/code/community/Dhl/MeinPaket/controllers/Adminhtml/OrderImportController.php +125 -0
  136. app/code/community/Dhl/MeinPaket/controllers/Adminhtml/ProductExportController.php +143 -0
  137. app/code/community/Dhl/MeinPaket/etc/adminhtml.xml +66 -0
  138. app/code/community/Dhl/MeinPaket/etc/config.xml +337 -0
  139. app/code/community/Dhl/MeinPaket/etc/system.xml +385 -0
  140. app/code/community/Dhl/MeinPaket/sql/meinpaket_setup/mysql4-install-1.0.0.php +80 -0
  141. app/code/community/Dhl/MeinPaket/sql/meinpaket_setup/mysql4-upgrade-1.0.0-1.1.0.php +76 -0
  142. app/code/community/Dhl/MeinPaket/sql/meinpaket_setup/mysql4-upgrade-1.1.0-2.0.0.php +92 -0
  143. app/design/adminhtml/default/default/layout/meinpaket.xml +85 -0
  144. app/design/adminhtml/default/default/template/meinpaket/Attributemapping/edit.phtml +23 -0
  145. app/design/adminhtml/default/default/template/meinpaket/Attributemapping/edit/attributes.phtml +21 -0
  146. app/design/adminhtml/default/default/template/meinpaket/Attributemapping/edit/mapping.phtml +36 -0
  147. app/design/adminhtml/default/default/template/meinpaket/Attributemapping/edit/valuemapping.phtml +41 -0
  148. app/design/adminhtml/default/default/template/meinpaket/Attributemapping/editform.phtml +15 -0
  149. app/design/adminhtml/default/default/template/meinpaket/Attributemapping/index.phtml +19 -0
  150. app/design/adminhtml/default/default/template/meinpaket/CategoryImport/import.phtml +121 -0
  151. app/design/adminhtml/default/default/template/meinpaket/CategoryImport/index.phtml +47 -0
  152. app/design/adminhtml/default/default/template/meinpaket/OrderImport/import.phtml +38 -0
  153. app/design/adminhtml/default/default/template/meinpaket/OrderImport/index.phtml +76 -0
  154. app/design/adminhtml/default/default/template/meinpaket/ProductExport/empty.phtml +35 -0
  155. app/design/adminhtml/default/default/template/meinpaket/ProductExport/export.phtml +213 -0
  156. app/design/adminhtml/default/default/template/meinpaket/ProductExport/index.phtml +52 -0
  157. app/design/adminhtml/default/default/template/meinpaket/ProductExport/list.phtml +32 -0
  158. app/design/adminhtml/default/default/template/meinpaket/catalog/product/matching/result.phtml +58 -0
  159. app/design/adminhtml/default/default/template/meinpaket/catalog/product/matching/tab.phtml +61 -0
  160. app/design/adminhtml/default/default/template/meinpaket/category/import/import.phtml +121 -0
  161. app/design/adminhtml/default/default/template/meinpaket/category/import/index.phtml +47 -0
  162. app/design/adminhtml/default/default/template/meinpaket/category_import/import.phtml +121 -0
  163. app/design/adminhtml/default/default/template/meinpaket/category_import/index.phtml +47 -0
  164. app/design/adminhtml/default/default/template/meinpaket/leftmenu.phtml +20 -0
  165. app/design/adminhtml/default/default/template/meinpaket/productexport.phtml +29 -0
  166. app/design/adminhtml/default/default/template/meinpaket/steps.phtml +15 -0
  167. app/design/frontend/base/default/layout/meinpaket.xml +3 -0
  168. app/design/frontend/base/default/template/dhl/meinpaket/checkout/abort.phtml +6 -0
  169. app/design/frontend/base/default/template/dhl/meinpaket/checkout/cartbutton.phtml +19 -0
  170. app/design/frontend/base/default/template/dhl/meinpaket/checkout/error.phtml +2 -0
  171. app/design/frontend/base/default/template/dhl/meinpaket/checkout/sidebarbutton.phtml +21 -0
  172. app/design/frontend/base/default/template/dhl/meinpaket/checkout/success.phtml +2 -0
  173. app/etc/modules/Dhl_MeinPaket.xml +9 -0
  174. app/locale/de_DE/Dhl_MeinPaket.csv +183 -0
  175. package.xml +18 -0
  176. shell/dhlmeinpaket-category-import.php +68 -0
  177. shell/dhlmeinpaket-order-import.php +96 -0
  178. shell/dhlmeinpaket-product-export.php +89 -0
  179. shell/dhlmeinpaket-request-bestprice.php +54 -0
  180. skin/adminhtml/default/default/meinpaket/attributemapping.js +192 -0
  181. skin/adminhtml/default/default/meinpaket/common.css +1 -0
  182. skin/adminhtml/default/default/meinpaket/common.js +1 -0
  183. skin/adminhtml/default/default/meinpaket/images/1.png +0 -0
  184. skin/adminhtml/default/default/meinpaket/images/2.png +0 -0
  185. skin/adminhtml/default/default/meinpaket/images/3.png +0 -0
  186. skin/adminhtml/default/default/meinpaket/images/Thumbs.db +0 -0
  187. skin/adminhtml/default/default/meinpaket/images/dhl_logo_kl.gif +0 -0
  188. skin/adminhtml/default/default/meinpaket/images/loader.gif +0 -0
  189. skin/adminhtml/default/default/meinpaket/images/meinpaket_logo.png +0 -0
  190. skin/adminhtml/default/default/meinpaket/images/shadowtopbg.png +0 -0
  191. skin/adminhtml/default/default/meinpaket/module.css +49 -0
  192. skin/adminhtml/default/default/meinpaket/module.js +35 -0
  193. skin/frontend/default/default/meinpaket/images/dhl_checkout_button.png +0 -0
app/code/community/Dhl/MeinPaket/Block/Adminhtml/Async.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Block_Adminhtml_Async extends Mage_Adminhtml_Block_Widget_Grid_Container {
3
+ /**
4
+ * Constructor for Cron Adminhtml Block
5
+ */
6
+ public function __construct() {
7
+ $this->_blockGroup = 'meinpaket';
8
+ $this->_controller = 'adminhtml_async';
9
+ $this->_headerText = Mage::helper ( 'meinpaket' )->__ ( 'Async' );
10
+ parent::__construct ();
11
+ }
12
+ /**
13
+ * Prepare layout
14
+ *
15
+ * @return Dhl_MeinPaket_Block_Adminhtml_Backlog_Product_Grid_Container
16
+ */
17
+ protected function _prepareLayout() {
18
+ $this->removeButton ( 'add' );
19
+
20
+ $this->_addButton ( 'run_async', array (
21
+ 'label' => Mage::helper ( 'meinpaket' )->__ ( 'Synchronize Async Jobs' ),
22
+ 'onclick' => 'setLocation(\'' . $this->getUrl ( '*/*/run', array (
23
+ 'cronjob' => Dhl_MeinPaket_Model_Cron::SYNC_ASYNC
24
+ ) ) . '\')',
25
+ 'class' => 'add'
26
+ ) );
27
+
28
+ return parent::_prepareLayout ();
29
+ }
30
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/Async/Grid.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Block_Adminhtml_Async_Grid extends Mage_Adminhtml_Block_Widget_Grid {
3
+ public function __construct() {
4
+ parent::__construct ();
5
+ $this->setId ( 'meinpaket_async_grid' );
6
+ $this->setDefaultSort ( 'async_id' );
7
+ $this->setDefaultDir ( 'ASC' );
8
+ $this->setUseAjax ( true );
9
+ $this->setSaveParametersInSession ( true );
10
+ }
11
+ protected function _prepareCollection() {
12
+ $collection = Mage::getModel ( 'meinpaket/async' )->getCollection ();
13
+ $this->setCollection ( $collection );
14
+ return parent::_prepareCollection ();
15
+ }
16
+ protected function _prepareColumns() {
17
+ $this->addColumn ( 'async_id', array (
18
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'ID' ),
19
+ 'type' => 'number',
20
+ 'index' => 'async_id'
21
+ ) );
22
+
23
+ $this->addColumn ( 'request_id', array (
24
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Request ID' ),
25
+ 'index' => 'request_id'
26
+ ) );
27
+
28
+ $this->addColumn ( 'status', array (
29
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Status' ),
30
+ 'index' => 'status'
31
+ ) );
32
+
33
+ $this->addColumn ( 'created_at', array (
34
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Created At' ),
35
+ 'type' => 'datetime',
36
+ 'index' => 'created_at'
37
+ ) );
38
+
39
+ $this->addColumn ( 'updated_at', array (
40
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Updated At' ),
41
+ 'type' => 'datetime',
42
+ 'index' => 'updated_at'
43
+ ) );
44
+
45
+ $this->addExportType ( '*/*/exportExcel', Mage::helper ( 'meinpaket' )->__ ( 'Excel XML' ) );
46
+
47
+ return parent::_prepareColumns ();
48
+ }
49
+ protected function _prepareMassaction() {
50
+ $this->setMassactionIdField ( 'async_id' );
51
+ $this->getMassactionBlock ()->setFormFieldName ( 'asyncIds' );
52
+ $this->getMassactionBlock ()->addItem ( 'delete', array (
53
+ 'label' => Mage::helper ( 'meinpaket' )->__ ( 'Delete' ),
54
+ 'url' => $this->getUrl ( '*/*/massDelete', array () ),
55
+ 'confirm' => Mage::helper ( 'meinpaket' )->__ ( 'Are you sure?' )
56
+ ) );
57
+
58
+ return $this;
59
+ }
60
+ public function getGridUrl() {
61
+ return $this->getUrl ( '*/*/grid', array (
62
+ '_current' => true
63
+ ) );
64
+ }
65
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/Backlog/Product.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Block_Adminhtml_Backlog_Product extends Mage_Adminhtml_Block_Widget_Grid_Container {
3
+ /**
4
+ * Constructor for Cron Adminhtml Block
5
+ */
6
+ public function __construct() {
7
+ $this->_blockGroup = 'meinpaket';
8
+ $this->_controller = 'adminhtml_backlog_product';
9
+ $this->_headerText = Mage::helper ( 'meinpaket' )->__ ( 'Backlog' );
10
+ parent::__construct ();
11
+ }
12
+ /**
13
+ * Prepare layout
14
+ *
15
+ * @return Dhl_MeinPaket_Block_Adminhtml_Backlog_Product_Grid_Container
16
+ */
17
+ protected function _prepareLayout() {
18
+ $this->removeButton ( 'add' );
19
+
20
+ $this->_addButton ( 'run_async', array (
21
+ 'label' => Mage::helper ( 'meinpaket' )->__ ( 'Synchronize Async Jobs' ),
22
+ 'onclick' => 'setLocation(\'' . $this->getUrl ( '*/*/run', array (
23
+ 'cronjob' => Dhl_MeinPaket_Model_Cron::SYNC_ASYNC
24
+ ) ) . '\')',
25
+ 'class' => 'add'
26
+ ) );
27
+
28
+ $this->_addButton ( 'run_catalog', array (
29
+ 'label' => Mage::helper ( 'meinpaket' )->__ ( 'Synchronize Productlist' ),
30
+ 'onclick' => 'setLocation(\'' . $this->getUrl ( '*/*/run', array (
31
+ 'cronjob' => Dhl_MeinPaket_Model_Cron::SYNC_CATALOG
32
+ ) ) . '\')',
33
+ 'class' => 'add'
34
+ ) );
35
+
36
+ $this->_addButton ( 'run_orders', array (
37
+ 'label' => Mage::helper ( 'meinpaket' )->__ ( 'Import Orders' ),
38
+ 'onclick' => 'setLocation(\'' . $this->getUrl ( '*/*/run', array (
39
+ 'cronjob' => Dhl_MeinPaket_Model_Cron::SYNC_ORDERS
40
+ ) ) . '\')',
41
+ 'class' => 'add'
42
+ ) );
43
+
44
+ $this->_addButton ( 'schedule_jobs', array (
45
+ 'label' => Mage::helper ( 'meinpaket' )->__ ( 'Schedule Jobs' ),
46
+ 'onclick' => 'setLocation(\'' . $this->getUrl ( '*/*/schedule', array (
47
+ 'cronjob' => 'all'
48
+ ) ) . '\')',
49
+ 'class' => 'add'
50
+ ) );
51
+
52
+ // $this->_addButton ( 'schedule_catalog', array (
53
+ // 'label' => Mage::helper ( 'meinpaket' )->__ ( 'Schedule Catalog' ),
54
+ // 'onclick' => 'setLocation(\'' . $this->getUrl ( '*/*/schedule', array (
55
+ // 'cronjob' => Dhl_MeinPaket_Model_Cron::SYNC_CATALOG
56
+ // ) ) . '\')',
57
+ // 'class' => 'add'
58
+ // ) );
59
+
60
+ // $this->_addButton ( 'schedule_orders', array (
61
+ // 'label' => Mage::helper ( 'meinpaket' )->__ ( 'Schedule Orders' ),
62
+ // 'onclick' => 'setLocation(\'' . $this->getUrl ( '*/*/schedule', array (
63
+ // 'cronjob' => Dhl_MeinPaket_Model_Cron::SYNC_ORDERS
64
+ // ) ) . '\')',
65
+ // 'class' => 'add'
66
+ // ) );
67
+
68
+ return parent::_prepareLayout ();
69
+ }
70
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/Backlog/Product/Grid.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Block_Adminhtml_Backlog_Product_Grid extends Mage_Adminhtml_Block_Widget_Grid {
3
+ public function __construct() {
4
+ parent::__construct ();
5
+ $this->setId ( 'meinpaket_backlog_product_grid' );
6
+ $this->setDefaultSort ( 'backlog_id' );
7
+ $this->setDefaultDir ( 'ASC' );
8
+ $this->setUseAjax ( true );
9
+ $this->setSaveParametersInSession ( true );
10
+ }
11
+ protected function _prepareCollection() {
12
+ $collection = Mage::getModel ( 'meinpaket/backlog_product' )->getCollection ();
13
+ $collection->getSelect ()->joinLeft ( array (
14
+ 'product_table' => $collection->getTable ( 'catalog/product' )
15
+ ), 'main_table.product_id=product_table.entity_id', array (
16
+ 'sku' => 'sku'
17
+ ) );
18
+ $this->setCollection ( $collection );
19
+ return parent::_prepareCollection ();
20
+ }
21
+ protected function _prepareColumns() {
22
+ $this->addColumn ( 'backlog_id', array (
23
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'ID' ),
24
+ 'type' => 'number',
25
+ 'index' => 'backlog_id'
26
+ ) );
27
+
28
+ $this->addColumn ( 'product_id', array (
29
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Product ID' ),
30
+ 'type' => 'number',
31
+ 'index' => 'product_id'
32
+ ) );
33
+
34
+ $this->addColumn ( 'sku', array (
35
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'SKU' ),
36
+ 'index' => 'sku'
37
+ ) );
38
+
39
+ $this->addColumn ( 'changes', array (
40
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Changes' ),
41
+ 'index' => 'changes'
42
+ ) );
43
+
44
+ $this->addColumn ( 'created_at', array (
45
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Created At' ),
46
+ 'type' => 'datetime',
47
+ 'index' => 'created_at'
48
+ ) );
49
+
50
+ $this->addExportType ( '*/*/exportExcel', Mage::helper ( 'meinpaket' )->__ ( 'Excel XML' ) );
51
+
52
+ return parent::_prepareColumns ();
53
+ }
54
+ protected function _prepareMassaction() {
55
+ $this->setMassactionIdField ( 'backlog_id' );
56
+ $this->getMassactionBlock ()->setFormFieldName ( 'backlogIds' );
57
+ $this->getMassactionBlock ()->addItem ( 'delete', array (
58
+ 'label' => Mage::helper ( 'meinpaket' )->__ ( 'Delete' ),
59
+ 'url' => $this->getUrl ( '*/*/massDelete', array () ),
60
+ 'confirm' => Mage::helper ( 'meinpaket' )->__ ( 'Are you sure?' )
61
+ ) );
62
+
63
+ return $this;
64
+ }
65
+ public function getRowUrl($row) {
66
+ return $this->getUrl ( 'adminhtml/catalog_product/edit', array (
67
+ 'id' => $row->getProductId ()
68
+ ) );
69
+ }
70
+ public function getGridUrl() {
71
+ return $this->getUrl ( '*/*/grid', array (
72
+ '_current' => true
73
+ ) );
74
+ }
75
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/BestPrice.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Block_Adminhtml_BestPrice extends Mage_Adminhtml_Block_Widget_Grid_Container {
3
+ /**
4
+ * Constructor for Cron Adminhtml Block
5
+ */
6
+ public function __construct() {
7
+ $this->_blockGroup = 'meinpaket';
8
+ $this->_controller = 'adminhtml_bestPrice';
9
+ $this->_headerText = Mage::helper ( 'meinpaket' )->__ ( 'Best Price' );
10
+ parent::__construct ();
11
+ }
12
+ /**
13
+ * Prepare layout
14
+ *
15
+ * @return Dhl_MeinPaket_Block_Adminhtml_Backlog_Product_Grid_Container
16
+ */
17
+ protected function _prepareLayout() {
18
+ $this->removeButton ( 'add' );
19
+
20
+ return parent::_prepareLayout ();
21
+ }
22
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/BestPrice/Grid.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Block_Adminhtml_BestPrice_Grid extends Mage_Adminhtml_Block_Widget_Grid {
3
+ public function __construct() {
4
+ parent::__construct ();
5
+ $this->setId ( 'meinpaket_bestprice_grid' );
6
+ $this->setDefaultSort ( 'bestprice_id' );
7
+ $this->setDefaultDir ( 'ASC' );
8
+ $this->setUseAjax ( true );
9
+ $this->setSaveParametersInSession ( true );
10
+ }
11
+ protected function _prepareCollection() {
12
+ $collection = Mage::getModel ( 'meinpaket/bestPrice' )->getCollection ();
13
+ $this->setCollection ( $collection );
14
+ return parent::_prepareCollection ();
15
+ }
16
+ protected function _prepareColumns() {
17
+ $this->addColumn ( 'bestprice_id', array (
18
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'ID' ),
19
+ 'type' => 'number',
20
+ 'index' => 'bestprice_id'
21
+ ) );
22
+
23
+ $this->addColumn ( 'price', array (
24
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Price' ),
25
+ 'type' => 'number',
26
+ 'index' => 'price'
27
+ ) );
28
+
29
+ $this->addColumn ( 'price_currency', array (
30
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Price Currency' ),
31
+ 'index' => 'price_currency'
32
+ ) );
33
+
34
+ $this->addColumn ( 'delivery_cost', array (
35
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Delivery Cost' ),
36
+ 'type' => 'number',
37
+ 'index' => 'delivery_cost'
38
+ ) );
39
+
40
+ $this->addColumn ( 'delivery_cost_currency', array (
41
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Delivery Cost Currency' ),
42
+ 'index' => 'delivery_cost_currency'
43
+ ) );
44
+
45
+ $this->addColumn ( 'delivery_time', array (
46
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Delivery Time' ),
47
+ 'type' => 'number',
48
+ 'index' => 'delivery_time'
49
+ ) );
50
+
51
+ $this->addColumn ( 'active_offers', array (
52
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Active Offers' ),
53
+ 'type' => 'number',
54
+ 'index' => 'active_offers'
55
+ ) );
56
+
57
+ $this->addColumn ( 'ownership', array (
58
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Ownership' ),
59
+ 'index' => 'ownership'
60
+ ) );
61
+
62
+ $this->addColumn ( 'owning_dealer_code', array (
63
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Owning Dealer Code' ),
64
+ 'index' => 'owning_dealer_code'
65
+ ) );
66
+
67
+ $this->addColumn ( 'created_at', array (
68
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Created At' ),
69
+ 'type' => 'datetime',
70
+ 'index' => 'created_at'
71
+ ) );
72
+
73
+ $this->addExportType ( '*/*/exportExcel', Mage::helper ( 'meinpaket' )->__ ( 'Excel XML' ) );
74
+ $this->addExportType ( '*/*/exportCsv', Mage::helper ( 'meinpaket' )->__ ( 'CSV' ) );
75
+
76
+ return parent::_prepareColumns ();
77
+ }
78
+ public function getRowUrl($row) {
79
+ return $this->getUrl ( 'adminhtml/catalog_product/edit', array (
80
+ 'id' => $row->getProductId ()
81
+ ) );
82
+ }
83
+ public function getGridUrl() {
84
+ return $this->getUrl ( '*/*/grid', array (
85
+ '_current' => true
86
+ ) );
87
+ }
88
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/Catalog/Product/Matching/Result.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Block for the product matching.
4
+ *
5
+ * @category Dhl
6
+ * @package Dhl_MeinPaket
7
+ * @subpackage Dhl_MeinPaket_Block_Adminhtml_Catalog_Product_Matching
8
+ * @version $Id$
9
+ */
10
+ class Dhl_MeinPaket_Block_Adminhtml_Catalog_Product_Matching_Result extends Mage_Adminhtml_Block_Abstract {
11
+ public function getSuggestions() {
12
+ $product = Mage::registry ( 'current_product' );
13
+ $ean = Mage::registry ( 'sendEan' );
14
+ $name = Mage::registry ( 'sendName' );
15
+ return Mage::getModel ( 'meinpaket/service_productData_requestService' )->getProductData ( $product, $ean, $name );
16
+ }
17
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/Catalog/Product/Matching/Tab.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Block for the product matching.
4
+ *
5
+ * @category Dhl
6
+ * @package Dhl_MeinPaket
7
+ * @subpackage Dhl_MeinPaket_Block_Adminhtml_Catalog_Product_Matching
8
+ * @version $Id$
9
+ */
10
+ class Dhl_MeinPaket_Block_Adminhtml_Catalog_Product_Matching_Tab extends Mage_Adminhtml_Block_Widget implements Mage_Adminhtml_Block_Widget_Tab_Interface {
11
+
12
+ /**
13
+ * Set the template for the block
14
+ */
15
+ public function _construct() {
16
+ parent::_construct ();
17
+ $this->setTemplate ( 'meinpaket/catalog/product/matching/tab.phtml' );
18
+ }
19
+
20
+ /**
21
+ * Retrieve the label used for the tab relating to this block
22
+ *
23
+ * @return string
24
+ */
25
+ public function getTabLabel() {
26
+ return $this->__ ( 'DHL Meinpaket Matching' );
27
+ }
28
+
29
+ /**
30
+ * Retrieve the title used by this tab
31
+ *
32
+ * @return string
33
+ */
34
+ public function getTabTitle() {
35
+ return $this->__ ( 'Assign DHL Meinpaket Category' );
36
+ }
37
+
38
+ /**
39
+ * Determines whether to display the tab
40
+ * Add logic here to decide whether you want the tab to display
41
+ *
42
+ * @return bool
43
+ */
44
+ public function canShowTab() {
45
+ return true;
46
+ }
47
+
48
+ /**
49
+ * Stops the tab being hidden
50
+ *
51
+ * @return bool
52
+ */
53
+ public function isHidden() {
54
+ return false;
55
+ }
56
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/CategoryImport/Import.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Block for the import step of the category structure import.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Block_Adminhtml_CategoryImport
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Block_Adminhtml_CategoryImport_Import extends Mage_Adminhtml_Block_Template {
13
+ /**
14
+ *
15
+ * @var Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result
16
+ */
17
+ protected $result = null;
18
+
19
+ /**
20
+ * Constructor.
21
+ *
22
+ * @return void
23
+ */
24
+ public function __construct() {
25
+ parent::__construct ();
26
+ }
27
+
28
+ /**
29
+ * Sets the result object which encapsulates the information about the import process.
30
+ *
31
+ * @param Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result $result
32
+ * @return void
33
+ */
34
+ public function setResult(Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result $result) {
35
+ $this->result = $result;
36
+ }
37
+
38
+ /**
39
+ *
40
+ * @return Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result
41
+ */
42
+ public function getResult() {
43
+ return $this->result;
44
+ }
45
+
46
+ /**
47
+ * Returns an "<a>"-Tag which is a backend link to the given category.
48
+ *
49
+ * @param Mage_Catalog_Model_Category $category
50
+ * @return string
51
+ */
52
+ public function getLinkToCategory(Mage_Catalog_Model_Category $category) {
53
+ return '<a href="' . $this->getUrl ( 'adminhtml/catalog_category/edit/', array (
54
+ 'id' => $category->getId ()
55
+ ) ) . '" target="_blank">' . $this->__ ( 'edit category' ) . '</a>';
56
+ }
57
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/CategoryImport/Index.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Block for the overview step of the category structure import.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Block_Adminhtml_CategoryImport
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Block_Adminhtml_CategoryImport_Index extends Mage_Adminhtml_Block_Template
13
+ {
14
+ /**
15
+ * Constructor.
16
+ *
17
+ * @return void
18
+ */
19
+ public function __construct()
20
+ {
21
+ parent::__construct();
22
+ }
23
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/LeftMenu.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Block for the menu list of the MeinPaket menu items.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Block_Adminhtml
9
+ * @version $Id$
10
+ * @author Daniel Pötzinger <daniel.poetzinger@aoemedia.de>
11
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
12
+ */
13
+ class Dhl_MeinPaket_Block_Adminhtml_Leftmenu extends Mage_Adminhtml_Block_Template {
14
+ /**
15
+ *
16
+ * @var array
17
+ */
18
+ protected $menuItems = array ();
19
+
20
+ /**
21
+ *
22
+ * @var string
23
+ */
24
+ protected $activeItem;
25
+
26
+ /**
27
+ * Constructor.
28
+ *
29
+ * @return void
30
+ */
31
+ public function __construct() {
32
+ parent::__construct ();
33
+ }
34
+
35
+ /**
36
+ * Adds an item to the end of the menu.
37
+ *
38
+ * @param string $action
39
+ * @param string $name
40
+ * @return void
41
+ */
42
+ public function addMenuItem($action, $name) {
43
+ $this->menuItems [$action] = $name;
44
+ }
45
+
46
+ /**
47
+ *
48
+ * @return string $activeItem
49
+ */
50
+ public function getActiveItem() {
51
+ return $this->activeItem;
52
+ }
53
+
54
+ /**
55
+ *
56
+ * @param string $activeItem
57
+ * @return Dhl_MeinPaket_Block_Adminhtml_Leftmenu
58
+ */
59
+ public function setActiveItem($activeItem) {
60
+ $this->activeItem = $activeItem;
61
+ return $this;
62
+ }
63
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/Log.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Block_Adminhtml_Log extends Mage_Adminhtml_Block_Widget_Grid_Container {
3
+ /**
4
+ * Constructor for Cron Adminhtml Block
5
+ */
6
+ public function __construct() {
7
+ $this->_blockGroup = 'meinpaket';
8
+ $this->_controller = 'adminhtml_log';
9
+ $this->_headerText = Mage::helper ( 'meinpaket' )->__ ( 'Log' );
10
+ parent::__construct ();
11
+ }
12
+ /**
13
+ * Prepare layout
14
+ *
15
+ * @return Dhl_MeinPaket_Block_Adminhtml_Backlog_Product_Grid_Container
16
+ */
17
+ protected function _prepareLayout() {
18
+ $this->removeButton ( 'add' );
19
+
20
+ return parent::_prepareLayout ();
21
+ }
22
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/Log/Grid.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Block_Adminhtml_Log_Grid extends Mage_Adminhtml_Block_Widget_Grid {
3
+ public function __construct() {
4
+ parent::__construct ();
5
+ $this->setId ( 'meinpaket_log_grid' );
6
+ $this->setDefaultSort ( 'log_id' );
7
+ $this->setDefaultDir ( 'ASC' );
8
+ $this->setUseAjax ( true );
9
+ $this->setSaveParametersInSession ( true );
10
+ }
11
+ protected function _prepareCollection() {
12
+ $collection = Mage::getModel ( 'meinpaket/log' )->getCollection ();
13
+ $this->setCollection ( $collection );
14
+ return parent::_prepareCollection ();
15
+ }
16
+ protected function _prepareColumns() {
17
+ $this->addColumn ( 'log_id', array (
18
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'ID' ),
19
+ 'type' => 'number',
20
+ 'index' => 'log_id'
21
+ ) );
22
+
23
+ $this->addColumn ( 'request_id', array (
24
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Request ID' ),
25
+ 'index' => 'request_id'
26
+ ) );
27
+
28
+ $this->addColumn ( 'send', array (
29
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Send' ),
30
+ 'index' => 'send'
31
+ ) );
32
+
33
+ $this->addColumn ( 'received', array (
34
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Received' ),
35
+ 'index' => 'received'
36
+ ) );
37
+
38
+ $this->addColumn ( 'error', array (
39
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Error' ),
40
+ 'index' => 'error'
41
+ ) );
42
+
43
+ $this->addColumn ( 'created_at', array (
44
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Created At' ),
45
+ 'type' => 'datetime',
46
+ 'index' => 'created_at'
47
+ ) );
48
+
49
+ $this->addExportType ( '*/*/exportExcel', Mage::helper ( 'meinpaket' )->__ ( 'Excel XML' ) );
50
+
51
+ return parent::_prepareColumns ();
52
+ }
53
+ protected function _prepareMassaction() {
54
+ $this->setMassactionIdField ( 'log_id' );
55
+ $this->getMassactionBlock ()->setFormFieldName ( 'logIds' );
56
+ $this->getMassactionBlock ()->addItem ( 'delete', array (
57
+ 'label' => Mage::helper ( 'meinpaket' )->__ ( 'Delete' ),
58
+ 'url' => $this->getUrl ( '*/*/massDelete', array () ),
59
+ 'confirm' => Mage::helper ( 'meinpaket' )->__ ( 'Are you sure?' )
60
+ ) );
61
+
62
+ //$this->getMassactionBlock ()->addItem ( 'process', array (
63
+ // 'label' => Mage::helper ( 'meinpaket' )->__ ( 'Process' ),
64
+ // 'url' => $this->getUrl ( '*/*/massProcess', array () ),
65
+ // 'confirm' => Mage::helper ( 'meinpaket' )->__ ( 'Are you sure?' )
66
+ //) );
67
+
68
+
69
+ return $this;
70
+ }
71
+ public function getGridUrl() {
72
+ return $this->getUrl ( '*/*/grid', array (
73
+ '_current' => true
74
+ ) );
75
+ }
76
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/OrderImport/Index.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Block for the order import.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Block_Adminhtml_OrderImport
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Block_Adminhtml_OrderImport_Index extends Mage_Adminhtml_Block_Template
13
+ {
14
+ /**
15
+ * Constructor.
16
+ *
17
+ * @return void
18
+ */
19
+ public function __construct()
20
+ {
21
+ parent::__construct();
22
+ }
23
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/ProductExport/Export.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Block for the export step of the category structure import.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Block_Adminhtml_ProductExport
9
+ * @version $Id$
10
+ */
11
+ class Dhl_MeinPaket_Block_Adminhtml_ProductExport_Export extends Mage_Adminhtml_Block_Template {
12
+ /**
13
+ *
14
+ * @var Dhl_MeinPaket_Model_Service_Product_Export_Result
15
+ */
16
+ protected $results = array ();
17
+
18
+ /**
19
+ *
20
+ * @var integer
21
+ */
22
+ private $overallCount;
23
+
24
+ /**
25
+ *
26
+ * @var integer
27
+ */
28
+ private $sucessfullCount;
29
+
30
+ /**
31
+ * Constructor.
32
+ *
33
+ * @return void
34
+ */
35
+ public function __construct() {
36
+ parent::__construct ();
37
+ $this->assign ( 'startLabel', 'Start again' );
38
+ }
39
+
40
+ /**
41
+ * Sets the result object which encapsulates information about the export process.
42
+ *
43
+ * @param Dhl_MeinPaket_Model_Service_Product_Export_Result $results
44
+ * @return void
45
+ */
46
+ public function setResults($results) {
47
+ $this->results = $results;
48
+ }
49
+
50
+ /**
51
+ * Returns an <a>-Tag which links to the given product in the Magento backend.
52
+ *
53
+ * @param Mage_Catalog_Model_Product $product
54
+ * @return string
55
+ */
56
+ protected function getEditLink(Mage_Catalog_Model_Product $product) {
57
+ return '<a href="' . $this->getUrl ( 'adminhtml/catalog_product/edit/', array (
58
+ 'id' => $product->getId ()
59
+ ) ) . '" target="_blank">' . $this->__ ( 'edit product' ) . '</a>';
60
+ }
61
+
62
+ /**
63
+ * Returns an translated error description.
64
+ *
65
+ * @param string $errorType
66
+ * @param string $errorCode
67
+ * @return string
68
+ */
69
+ protected function getErrorDescription($errorType, $errorCode = '') {
70
+ return Mage::helper ( 'meinpaket/product' )->getErrorDescription ( $errorType, $errorCode );
71
+ }
72
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/ProductExport/Index.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Block for the overview step of the product export.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Block_Adminhtml_ProductExport
9
+ * @version $Id$
10
+ * @author Daniel Pötzinger <daniel.poetzinger@aoemedia.de>
11
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
12
+ */
13
+ class Dhl_MeinPaket_Block_Adminhtml_ProductExport_Index extends Mage_Adminhtml_Block_Template {
14
+ /**
15
+ * Constructor.
16
+ *
17
+ * @return void
18
+ */
19
+ public function __construct() {
20
+ parent::__construct ();
21
+ $this->assign ( 'exportLabel', 'Exportiere Produkte' );
22
+ }
23
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/ProductExport/List.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Block for the preview list of the products which will be exported with the current selection.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Block_Adminhtml_ProductExport
9
+ * @version $Id$
10
+ * @author Daniel Pötzinger <daniel.poetzinger@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Block_Adminhtml_ProductExport_List extends Mage_Adminhtml_Block_Template {
13
+ /**
14
+ * Constructor.
15
+ *
16
+ * @return void
17
+ */
18
+ public function __construct() {
19
+ parent::__construct ();
20
+ }
21
+
22
+ /**
23
+ * Assigns a product model collection to the template.
24
+ *
25
+ * @param
26
+ * $collection
27
+ * @return void
28
+ */
29
+ public function assignProductCollection($collection) {
30
+ $this->assign ( 'productCollection', $collection );
31
+ }
32
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/Steps.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Block for the steps view used in all MeinPaket modules.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Block_Adminhtml
9
+ * @version $Id$
10
+ * @author Daniel Pötzinger <daniel.poetzinger@aoemedia.de>
11
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
12
+ */
13
+ class Dhl_MeinPaket_Block_Adminhtml_Steps extends Mage_Adminhtml_Block_Template {
14
+ /**
15
+ *
16
+ * @var array
17
+ */
18
+ protected $steps;
19
+
20
+ /**
21
+ *
22
+ * @var string
23
+ */
24
+ protected $activeStep;
25
+
26
+ /**
27
+ * Constructor.
28
+ *
29
+ * @return void
30
+ */
31
+ public function __construct() {
32
+ $this->steps = array ();
33
+ parent::__construct ();
34
+ }
35
+
36
+ /**
37
+ * Adds a step.
38
+ *
39
+ * @param string $name
40
+ * @param string $text
41
+ * @return Dhl_MeinPaket_Block_Adminhtml_Steps
42
+ */
43
+ public function addStep($name, $text) {
44
+ $this->steps [$name] = $text;
45
+ return $this;
46
+ }
47
+
48
+ /**
49
+ *
50
+ * @return string
51
+ */
52
+ public function getActiveStep() {
53
+ return $this->activeStep;
54
+ }
55
+
56
+ /**
57
+ *
58
+ * @param
59
+ * string
60
+ * @return Dhl_MeinPaket_Block_Adminhtml_Steps
61
+ */
62
+ public function setActiveStep($activeStep) {
63
+ $this->activeStep = $activeStep;
64
+ return $this;
65
+ }
66
+ }
app/code/community/Dhl/MeinPaket/Block/Checkout/Abort.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Block template for aborted external checkout with MeinPaket
4
+ *
5
+ * @category Dhl
6
+ * @package Dhl_MeinPaket
7
+ * @subpackage Dhl_MeinPaket_Block_Checkout
8
+ * @version $Id$
9
+ * @author Andreas Demmer <andreas.demmer@aoemedia.de>
10
+ */
11
+ class Dhl_MeinPaket_Block_Checkout_Abort extends Mage_Core_Block_Template {
12
+ }
app/code/community/Dhl/MeinPaket/Block/Checkout/Error.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Block template for error while external checkout with MeinPaket
4
+ *
5
+ * @category Dhl
6
+ * @package Dhl_MeinPaket
7
+ * @subpackage Dhl_MeinPaket_Block_Checkout
8
+ * @version $Id$
9
+ * @author Andreas Demmer <andreas.demmer@aoemedia.de>
10
+ */
11
+ class Dhl_MeinPaket_Block_Checkout_Error extends Mage_Core_Block_Template {
12
+ }
app/code/community/Dhl/MeinPaket/Block/Checkout/Success.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Block template for successful external checkout with MeinPaket
4
+ *
5
+ * @category Dhl
6
+ * @package Dhl_MeinPaket
7
+ * @subpackage Dhl_MeinPaket_Block_Checkout
8
+ * @version $Id$
9
+ * @author Andreas Demmer <andreas.demmer@aoemedia.de>
10
+ */
11
+ class Dhl_MeinPaket_Block_Checkout_Success extends Mage_Core_Block_Template {
12
+ }
app/code/community/Dhl/MeinPaket/Helper/Attribute.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dhl_MeinPaket_Helper_Attribute extends Mage_Core_Helper_Abstract
4
+ {
5
+ protected $_ignoredAttributeCodes = array('status');
6
+
7
+ public function isExportableAttribute(Mage_Catalog_Model_Resource_Eav_Attribute $attribute)
8
+ {
9
+ $isExportable = false;
10
+ $data = $attribute->getData('');
11
+
12
+ if(
13
+ !in_array($data['attribute_code'], $this->_ignoredAttributeCodes) &&
14
+ (!array_key_exists('is_configurable', $data) || $data['is_configurable']) /* &&
15
+ $data['frontend_input'] === 'select' &&
16
+ $data['is_required'] &&
17
+ $data['is_visible'] &&
18
+ $data['is_searchable']*/
19
+ ) {
20
+ $isExportable = true;
21
+ }
22
+
23
+ return $isExportable;
24
+ }
25
+ }
app/code/community/Dhl/MeinPaket/Helper/Backlog.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Helper_Backlog extends Mage_Core_Helper_Abstract {
3
+
4
+ /**
5
+ * Create backlogs for every parent of given product
6
+ *
7
+ * @param int $productId
8
+ * to create backlog for
9
+ * @return integer count
10
+ */
11
+ public function createParentBacklog($productId, $changes = '') {
12
+ $count = 0;
13
+
14
+ if ($productId) {
15
+ foreach ( $this->getParentIds ( $productId ) as $productId ) {
16
+ $this->createBacklog ( $productId, $changes );
17
+ $count ++;
18
+ }
19
+ }
20
+
21
+ return $count;
22
+ }
23
+
24
+ /**
25
+ * Create backlogs for every children product
26
+ *
27
+ * @param int $productId
28
+ * to create backlog for
29
+ * @return integer count
30
+ */
31
+ public function createChildrenBacklog($productId, $changes = '') {
32
+ $count = 0;
33
+
34
+ if ($productId) {
35
+ $childIds = Mage::getModel ( 'catalog/product_type_configurable' )->getChildrenIds ( $productId );
36
+
37
+ foreach ( $childIds [0] as $key => $val ) {
38
+ $this->createBacklog ( $val, $changes );
39
+ $count ++;
40
+ }
41
+ }
42
+
43
+ return $count;
44
+ }
45
+
46
+ /**
47
+ * Create a backlog for given product using changes.
48
+ *
49
+ * @param int $productId
50
+ * to create backlog for.
51
+ * @param string $changes
52
+ * to set
53
+ */
54
+ public function createBacklog($productId, $changes = '') {
55
+ if ($productId) {
56
+ $backlog = Mage::getModel ( 'meinpaket/backlog_product' );
57
+ $backlog->product_id = $productId;
58
+ $backlog->created_at = time ();
59
+ $backlog->changes = $changes;
60
+ $backlog->save ();
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Get all parent ids for a single product given by $productId.
66
+ *
67
+ * @param int $productId
68
+ * to search for
69
+ * @return array
70
+ */
71
+ public function getParentIds($productId) {
72
+ $parentIdsGrouped = Mage::getModel ( 'catalog/product_type_grouped' )->getParentIdsByChild ( $productId );
73
+ $parentIdsConfigurable = Mage::getModel ( 'catalog/product_type_configurable' )->getParentIdsByChild ( $productId );
74
+ return array_unique ( array_merge ( $parentIdsGrouped, $parentIdsConfigurable ) );
75
+ }
76
+ }
app/code/community/Dhl/MeinPaket/Helper/Cron.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Helper_Cron extends Mage_Core_Helper_Abstract {
3
+ /**
4
+ * Schedule jobs for next cron run.
5
+ *
6
+ * @param array $cronjobs
7
+ * to schedule
8
+ * @param string $addMessage
9
+ * add messages to session
10
+ */
11
+ public function scheduleJobs(array $cronjobs, $addMessage = true) {
12
+ $session = Mage::getSingleton ( 'adminhtml/session' );
13
+ /* @var $session Mage_Adminhtml_Model_Session */
14
+
15
+ $time = time ();
16
+ $timeString = strftime ( '%Y-%m-%d %H:%M:%S', $time );
17
+ foreach ( $cronjobs as $code ) {
18
+ $schedule = Mage::getModel ( 'cron/schedule' );
19
+ $schedule->setJobCode ( $code );
20
+ $schedule->setStatus ( Mage_Cron_Model_Schedule::STATUS_PENDING );
21
+ $schedule->setCreatedAt ( $timeString );
22
+ $schedule->setScheduledAt ( $timeString );
23
+ $schedule->save ();
24
+ if ($addMessage) {
25
+ $session->addSuccess ( $this->__ ( 'Scheduled "%s" at %s', $code, $timeString ) );
26
+ }
27
+ }
28
+ }
29
+ /**
30
+ * Run jobs now.
31
+ *
32
+ * @param array $cronjobs
33
+ * to run
34
+ * @param string $addMessage
35
+ * add messages to session
36
+ */
37
+ public function runJobs(array $cronjobs, $addMessage = true) {
38
+ /* @var $session Mage_Adminhtml_Model_Session */
39
+ $session = Mage::getSingleton ( 'adminhtml/session' );
40
+
41
+ foreach ( $cronjobs as $code ) {
42
+ try {
43
+ switch ($code) {
44
+ case Dhl_MeinPaket_Model_Cron::SYNC_CATALOG :
45
+ $res = Mage::getSingleton ( 'meinpaket/service_product_export' )->exportProducts ();
46
+ break;
47
+ case Dhl_MeinPaket_Model_Cron::SYNC_ORDERS :
48
+ $res = Mage::getSingleton ( 'meinpaket/service_order_importService' )->importOrders ();
49
+ break;
50
+ case Dhl_MeinPaket_Model_Cron::SYNC_ASYNC :
51
+ $res = Mage::getSingleton ( 'meinpaket/service_async' )->process ();
52
+ break;
53
+ }
54
+
55
+ $message = is_string($res) ? $res : Zend_Debug::dump ( $res, null, false );
56
+
57
+ if ($addMessage && strlen ( $message ) > 0) {
58
+ $session->addSuccess ( $this->__ ( 'Ran "%s":<pre>%s</pre>', $code, $message ) );
59
+ }
60
+ } catch ( Exception $e ) {
61
+ if ($addMessage) {
62
+ $session->addError ( $this->__ ( 'Error while running "%s":<pre>%s</pre>', $code, $e->getMessage () ) );
63
+ }
64
+ Mage::logException ( $e );
65
+ }
66
+ }
67
+ }
68
+ }
app/code/community/Dhl/MeinPaket/Helper/Data.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Default helper for the Dhl_MeinPaket package.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Helper
9
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
10
+ */
11
+ class Dhl_MeinPaket_Helper_Data extends Mage_Core_Helper_Abstract {
12
+ /**
13
+ * Creates/extends JavaScript language object by the given labels.
14
+ * The given labels array must have the structure array('key1'=>'label1','key2'=>'label2',...).
15
+ * Key is the key under which the label will be accessible in frontend JavaScript.
16
+ * Label is the untranslated label.
17
+ * Example: Element is 'foo'=>'Bar'. So use MeinPaket.locale.foo .
18
+ *
19
+ * @param array $labels
20
+ * @return string
21
+ */
22
+ public function createLocaleJS(array $labels) {
23
+ $js = 'if(typeof MeinPaket === "undefined"){var MeinPaket={};}';
24
+ $js .= 'if(typeof MeinPaket.locale === "undefined"){MeinPaket.locale={};}';
25
+ $js .= 'Object.extend(MeinPaket.locale,{';
26
+
27
+ $firstItem = true;
28
+ if (sizeof ( $labels ) > 0) {
29
+ foreach ( $labels as $key => $label ) {
30
+ $js .= $this->_addJSLocaleLabel ( $key, $this->__ ( $label ), $firstItem );
31
+ if ($firstItem) {
32
+ $firstItem = false;
33
+ }
34
+ }
35
+ }
36
+
37
+ $js .= '});';
38
+
39
+ return $js;
40
+ }
41
+
42
+ /**
43
+ * Creates a json property.
44
+ *
45
+ * @param string $key
46
+ * @param string $label
47
+ * @param boolean $isFirst
48
+ * Tells if the label is the first in the list.
49
+ * @return string
50
+ */
51
+ protected function _addJSLocaleLabel($key, $label, $isFirst = false) {
52
+ $labelProperty = '';
53
+
54
+ if (! $isFirst) {
55
+ $labelProperty .= ',';
56
+ }
57
+
58
+ $labelProperty .= $key . ':"' . $label . '"';
59
+
60
+ return $labelProperty;
61
+ }
62
+ const STORE_VIEW_CONFIG = 'meinpaket/store/view';
63
+ private $_meinpaketStore = null;
64
+ private $_meinpaketRootCategory = null;
65
+ public function getExtensionVersion() {
66
+ return ( string ) Mage::getConfig ()->getModuleConfig ( 'Dhl_MeinPaket' )->version;
67
+ }
68
+ public function getMeinPaketStore() {
69
+ if ($this->_meinpaketStore == null) {
70
+ $this->_meinpaketStore = Mage::app ()->getStore ( Mage::getStoreConfig ( self::STORE_VIEW_CONFIG ) );
71
+ }
72
+ return $this->_meinpaketStore;
73
+ }
74
+ public function getMeinPaketStoreId() {
75
+ $store = $this->getMeinPaketStore ();
76
+ if ($store == null) {
77
+ return null;
78
+ } else {
79
+ return $store->getId ();
80
+ }
81
+ }
82
+ public function getMeinPaketRootCategoryId() {
83
+ return $this->getMeinPaketStore ()->getRootCategoryId ();
84
+ }
85
+ public function getMeinPaketRootCategory() {
86
+ if ($this->_meinpaketRootCategory == null) {
87
+ $this->_meinpaketRootCategory = Mage::getModel ( 'catalog/category' )->setStoreId ( $this->getMeinPaketStoreId () )->load ( $this->getMeinPaketRootCategoryId () );
88
+ }
89
+ return $this->_meinpaketRootCategory;
90
+ }
91
+ }
app/code/community/Dhl/MeinPaket/Helper/Order.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Order model related helper methods.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Util
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Helper_Order extends Mage_Core_Helper_Abstract {
13
+ /**
14
+ * Tells if the given order is an order that was imported from MeinPaket.de.
15
+ *
16
+ * @param Mage_Sales_Model_Order $order
17
+ * @return boolean
18
+ */
19
+ public function isMeinPaketOrder(Mage_Sales_Model_Order $order) {
20
+ return ($order->hasData ( 'dhl_mein_paket_order_id' ) && $order->getData ( 'dhl_mein_paket_order_id' ));
21
+ }
22
+ }
app/code/community/Dhl/MeinPaket/Helper/Product.php ADDED
@@ -0,0 +1,353 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Helper_Product extends Mage_Core_Helper_Abstract {
3
+ /**
4
+ *
5
+ * @var string
6
+ */
7
+ const TAX_CLASS_STANDARD = 'Standard';
8
+
9
+ /**
10
+ *
11
+ * @var string
12
+ */
13
+ const TAX_CLASS_REDUCED = 'Reduced';
14
+
15
+ /**
16
+ *
17
+ * @var string
18
+ */
19
+ const TAX_CLASS_FREE = 'Free';
20
+
21
+ /**
22
+ *
23
+ * @var Dhl_MeinPaket_Model_Validation_Validator_Ean
24
+ */
25
+ protected $_eanValidator = null;
26
+
27
+ /**
28
+ * Constructor.
29
+ *
30
+ * @return void
31
+ */
32
+ public function __construct() {
33
+ $this->_eanValidator = Mage::getSingleton ( 'meinpaket/Validation_ValidatorFactory' )->createEanValidator ();
34
+ }
35
+
36
+ /**
37
+ * Tells if the given product has a valid ean.
38
+ *
39
+ * @param Mage_Catalog_Model_Product $product
40
+ * @return boolean
41
+ */
42
+ public function hasValidEan(Mage_Catalog_Model_Product $product) {
43
+ return $this->_eanValidator->isValid ( $this->getEan ( $product ) );
44
+ }
45
+
46
+ /**
47
+ * Returns the EAN of the given product.
48
+ *
49
+ * @param Mage_Catalog_Model_Product $product
50
+ * @return string
51
+ */
52
+ public function getEan(Mage_Catalog_Model_Product $product) {
53
+ $eanAttributeCode = Mage::getStoreConfig ( 'meinpaket/product_attributes/ean_attribute' );
54
+
55
+ if (! empty ( $eanAttributeCode ) && $product->hasData($eanAttributeCode)) {
56
+ return $product->getData ( $eanAttributeCode );
57
+ } else {
58
+ return null;
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Returns the images for the given product.
64
+ * The items of the returned array are arrays themselves and have the
65
+ * following structure:
66
+ * array(
67
+ * 'url' => 'the url of the image',
68
+ * 'caption' => 'the images description'
69
+ * )
70
+ *
71
+ * @param Mage_Catalog_Model_Product $product
72
+ * @return array
73
+ */
74
+ public function getImages(Mage_Catalog_Model_Product $product) {
75
+ $images = array ();
76
+ $galleryImages = Mage::getModel ( 'catalog/product' )->load ( $product->getId () )->getMediaGalleryImages ();
77
+ $imageUrl = '';
78
+ $imageCaption = '';
79
+
80
+ if (is_object ( $galleryImages ) && $galleryImages->count () > 0) {
81
+ foreach ( $galleryImages as $image ) {
82
+ $images [] = array (
83
+ 'url' => Mage::getBaseUrl ( Mage_Core_Model_Store::URL_TYPE_MEDIA ) . 'catalog/product' . $image ['file'],
84
+ 'caption' => $image ['label']
85
+ );
86
+ }
87
+ }
88
+
89
+ return $images;
90
+ }
91
+
92
+ /**
93
+ * Returns the MeinPaket marketplace category code which is assigned to the
94
+ * product.
95
+ * If no marketplace category is assigned, an empty string will be
96
+ * returned.
97
+ *
98
+ * @param Mage_Catalog_Model_Product $product
99
+ * @return string
100
+ */
101
+ public function getMeinPaketMarketplaceCategoryCode(Mage_Catalog_Model_Product $product) {
102
+ $category = $this->getFirstMarketplaceCategory ( $product );
103
+
104
+ return (is_object ( $category ) && get_class ( $category ) === 'Mage_Catalog_Model_Category') ? $category->getDhlMarketplaceCategoryId () : '';
105
+ }
106
+
107
+ /**
108
+ * Returns all marketplace categories the product exists in.
109
+ *
110
+ * @param Mage_Catalog_Model_Product $product
111
+ * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection
112
+ */
113
+ public function getMarketplaceCategories(Mage_Catalog_Model_Product $product) {
114
+ return $product->getCategoryCollection ()->addAttributeToSelect ( 'dhl_marketplace_category_id' )->addAttributeToFilter ( 'dhl_marketplace_category_id', array (
115
+ 'notnull' => 1
116
+ ) )->load ();
117
+ }
118
+
119
+ /**
120
+ * Returns the first marketplace category for the given product.
121
+ *
122
+ * @param Mage_Catalog_Model_Product $product
123
+ * @return Mage_Catalog_Model_Category
124
+ */
125
+ public function getFirstMarketplaceCategory(Mage_Catalog_Model_Product $product) {
126
+ /* @var $category Mage_Catalog_Model_Category */
127
+ $category = null;
128
+
129
+ $collection = $this->getMarketplaceCategories ( $product );
130
+
131
+ if ($collection->count () > 0) {
132
+ $category = $collection->getFirstItem ();
133
+ }
134
+
135
+ return $category;
136
+ }
137
+
138
+ /**
139
+ * Returns the price of the given product depending on tax settings.
140
+ *
141
+ * @param Mage_Catalog_Model_Product $product
142
+ * @return float
143
+ */
144
+ public function getPriceConsideringTaxes(Mage_Catalog_Model_Product $product) {
145
+ /* @var $taxHelper Mage_Tax_Helper_Data */
146
+ $taxHelper = Mage::helper ( 'tax' );
147
+ $priceIncludesTax = ( bool ) Mage::getStoreConfig ( 'tax/calculation/price_includes_tax' ) ? true : null;
148
+
149
+ return $taxHelper->getPrice ( $product, $product->getPrice (), $priceIncludesTax );
150
+ }
151
+
152
+ /**
153
+ * Returns the MeinPaket tax group of the product.
154
+ *
155
+ * @param Mage_Catalog_Model_Product $product
156
+ * @return string May be "Free", "Reduced" or "Standard".
157
+ */
158
+ public function getMeinPaketTaxGroup(Mage_Catalog_Model_Product $product) {
159
+ $taxGroup = self::TAX_CLASS_STANDARD;
160
+
161
+ if ($product->hasData ( 'tax_class_id' )) {
162
+ $taxGroups = array (
163
+ '0' => self::TAX_CLASS_FREE,
164
+ Mage::getStoreConfig ( 'meinpaket/taxrates/default_tax_rate' ) => self::TAX_CLASS_STANDARD,
165
+ Mage::getStoreConfig ( 'meinpaket/taxrates/reduced_tax_rate' ) => self::TAX_CLASS_REDUCED
166
+ );
167
+ if (array_key_exists ( $product->getTaxClassId (), $taxGroups )) {
168
+ $taxGroup = $taxGroups [$product->getTaxClassId ()];
169
+ }
170
+ }
171
+
172
+ return $taxGroup;
173
+ }
174
+
175
+ /**
176
+ * Returns the stock count of the product which can be used for MeinPaket.
177
+ *
178
+ * @param Mage_Catalog_Model_Product $product
179
+ * @return integer
180
+ */
181
+ public function getMeinPaketStock(Mage_Catalog_Model_Product $product) {
182
+ $customDhlMeinPaketStock = 0;
183
+ $hasCustomMeinPaketStock = false;
184
+ $defaultStock = 0;
185
+ $stock = 0;
186
+
187
+ if ($product->hasData ( 'max_stock_for_dhl_mein_paket' )) {
188
+ $hasCustomMeinPaketStock = (strlen ( $product->getMaxStockForDhlMeinPaket () ) > 0);
189
+ $customDhlMeinPaketStock = ( integer ) $product->getMaxStockForDhlMeinPaket ();
190
+ }
191
+
192
+ /* @var $stockItem Mage_CatalogInventory_Model_Stock_Item */
193
+ $stockItem = Mage::getModel ( 'cataloginventory/stock_item' )->loadByProduct ( $product->getId () );
194
+
195
+ if (! $stockItem->getIsInStock ()) {
196
+ return 0;
197
+ }
198
+
199
+ $defaultStock = ( integer ) $stockItem->getQty ();
200
+
201
+ if ($hasCustomMeinPaketStock && is_integer ( $customDhlMeinPaketStock ) && $customDhlMeinPaketStock >= 0) {
202
+ $stock = $customDhlMeinPaketStock;
203
+ if ($stock > $defaultStock) {
204
+ $stock = $defaultStock;
205
+ }
206
+ } else {
207
+ $stock = $defaultStock;
208
+ }
209
+
210
+ return $stock;
211
+ }
212
+
213
+ /**
214
+ * Returns a date from which on the product won't be available on MeinPaket
215
+ * anymore.
216
+ *
217
+ * @param Mage_Catalog_Model_Product $product
218
+ * @return Zend_Date
219
+ */
220
+ public function getMeinPaketEndDate(Mage_Catalog_Model_Product $product) {
221
+ $endDate = new Zend_Date ();
222
+
223
+ if ($product->getStatus () == Mage_Catalog_Model_Product_Status::STATUS_DISABLED/* ||
224
+ $product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE*/
225
+ ) {
226
+ $endDate->setTimestamp ( time () - 86400 );
227
+ } else {
228
+ $endDate->setTimestamp ( time () + 31536000 );
229
+ }
230
+
231
+ return $endDate;
232
+ }
233
+
234
+ /**
235
+ * Returns the delivery time for orders from MeinPaket for the given product.
236
+ *
237
+ * @param Mage_Catalog_Model_Product $product
238
+ * @return integer The delivery time in days
239
+ */
240
+ public function getMeinPaketDeliveryTime(Mage_Catalog_Model_Product $product) {
241
+ $attributeId = Mage::getStoreConfig ( 'meinpaket/product_attributes/delivery_time' );
242
+ $deliveryTime = Mage::getStoreConfig ( 'meinpaket/product_attributes/default_delivery_time' );
243
+
244
+ if (strlen ( $attributeId ) > 0 && $product->hasData ( $attributeId ) && @preg_match ( "/^[0-9]+$/", $product->getData ( $attributeId ) )) {
245
+ $deliveryTime = $product->getData ( $attributeId );
246
+ }
247
+
248
+ return $deliveryTime;
249
+ }
250
+
251
+ /**
252
+ * Returns the parent configurable product of the given product.
253
+ * Returns null if the given product isn't a simple one or it has
254
+ * no parent configurable.
255
+ *
256
+ * @param Mage_Catalog_Model_Product $simpleProduct
257
+ * @return Mage_Catalog_Model_Product
258
+ */
259
+ public function getParentConfigurable(Mage_Catalog_Model_Product $simpleProduct) {
260
+ $parentConfigurable = null;
261
+
262
+ if ($simpleProduct->getTypeId () === Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
263
+ $parentIds = Mage::getModel ( 'catalog/product_type_configurable' )->getParentIdsByChild ( $simpleProduct->getId () );
264
+ if (isset ( $parentIds [0] )) {
265
+ $parentConfigurable = Mage::getModel ( 'catalog/product' )->load ( $parentIds [0] );
266
+ }
267
+ }
268
+
269
+ return $parentConfigurable;
270
+ }
271
+
272
+ /**
273
+ * Returns an translated error description.
274
+ *
275
+ * @param string $errorType
276
+ * @param string $errorCode
277
+ * @return string
278
+ */
279
+ public function getErrorDescription($errorType, $errorCode = '') {
280
+ $description = '';
281
+
282
+ switch ($errorType) {
283
+ case Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_FIELD_IS_INVALID :
284
+ $description = $this->__ ( 'Invalid value for field' ) . ' "<i><b>' . $this->__ ( $this->getLabelForFieldName ( $errorCode ) ) . '</b></i>".';
285
+ break;
286
+ case Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_REQUIRED_FIELD_IS_EMPTY :
287
+ $description = $this->__ ( 'Missing value for field' ) . ' "<i><b>' . $this->__ ( $this->getLabelForFieldName ( $errorCode ) ) . '</b></i>".';
288
+ break;
289
+ case Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_PRODUCT_NOT_EXISTS_IN_MEINPAKET :
290
+ $description = $this->__ ( 'Product is unknown in MeinPaket marketplace' ) . '.';
291
+ break;
292
+ case Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_PRODUCT_NEGATIVE_STOCK :
293
+ $description = $this->__ ( 'Product stock is lower than zero.' );
294
+ break;
295
+ case Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_MEINPAKET_SERVER_ERROR :
296
+ $description = $this->__ ( 'Internal error on MeinPaket server' ) . '.';
297
+ break;
298
+ case Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_NOT_AUTHORIZED :
299
+ $description = $this->__ ( 'You are not authorized to execute the requested functionality on MeinPaket' );
300
+ break;
301
+ case Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_INVALID_DATA :
302
+ $description = $this->__ ( 'The provided data was incorrect' );
303
+ break;
304
+ case Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_INVALID_MODIFICATION :
305
+ $description = $this->__ ( 'Ivalid modification of element' );
306
+ break;
307
+ case Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_NO_CATEGORIZATION :
308
+ $description = $this->__ ( 'The product is not mapped to neither a marketplace nor a shop category' );
309
+ break;
310
+ case Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_PRODUCT_NOT_SELLABLE :
311
+ $description = $this->__ ( 'The referenced product cannot be sold' );
312
+ break;
313
+ case Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_MARKETPLACE_CATEGORY_NOT_FOUND :
314
+ $description = $this->__ ( 'The referenced marketplace category could not be found at MeinPaket' );
315
+ break;
316
+ case Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_SHOP_CATEGORY_NOT_FOUND :
317
+ $description = $this->__ ( 'The referenced shop category could not be found at MeinPaket' );
318
+ break;
319
+ case Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_MISSING_VALUE_FOR_ATTRIBUTE :
320
+ $description = $this->__ ( 'Missing value mapping for attribute' ) . ' "' . $errorCode . '".';
321
+ break;
322
+ case Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_VARIANT_GROUP_NOT_EXISTS :
323
+ $description = $this->__ ( 'Variant group does not exist on MeinPaket' ) . ' "' . $errorCode . '".';
324
+ break;
325
+ case Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_UNDEFINED :
326
+ default :
327
+ $description = $this->__ ( 'Undefined Error' );
328
+ }
329
+
330
+ return $description;
331
+ }
332
+
333
+ /**
334
+ * Returns the frontend label for a given attribute.
335
+ *
336
+ * @param string $fieldName
337
+ * @return string
338
+ */
339
+ public function getLabelForFieldName($fieldName) {
340
+ $productAttributeModel = Mage::getModel ( 'eav/config' )->getAttribute ( 'catalog_product', $fieldName );
341
+ $categoryAttributeModel = Mage::getModel ( 'eav/config' )->getAttribute ( 'catalog_category', $fieldName );
342
+
343
+ $label = $productAttributeModel->getFrontendLabel ();
344
+
345
+ if (! ( bool ) $label)
346
+ $label = $categoryAttributeModel->getFrontendLabel ();
347
+
348
+ if (! ( bool ) $label)
349
+ $label = $fieldName;
350
+
351
+ return $label;
352
+ }
353
+ }
app/code/community/Dhl/MeinPaket/Helper/Shipment.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shipment model related helper methods.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Util
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Helper_Shipment extends Mage_Core_Helper_Abstract {
13
+ /**
14
+ * Tells if the given order is an order that was imported from MeinPaket.de.
15
+ *
16
+ * @param Mage_Sales_Model_Order_Shipment $shipment
17
+ * to check
18
+ * @return boolean
19
+ */
20
+ public function isMeinPaketShipment(Mage_Sales_Model_Order_Shipment $shipment) {
21
+ return Mage::helper ( 'meinpaket/order' )->isMeinPaketOrder ( $shipment->getOrder () );
22
+ }
23
+
24
+ /**
25
+ * Tells if the given $shipment is exported to MeinPaket
26
+ *
27
+ * @param Mage_Sales_Model_Order_Shipment $shipment
28
+ * to be shipped
29
+ * @return boolean
30
+ */
31
+ public function isExportedToDhlMeinPaket(Mage_Sales_Model_Order_Shipment $shipment) {
32
+ return $shipment->hasData ( 'shipment_was_exported_for_dhl_mein_paket' ) && $shipment->getData ( 'shipment_was_exported_for_dhl_mein_paket' );
33
+ }
34
+ }
app/code/community/Dhl/MeinPaket/Model/Async.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Async extends Mage_Core_Model_Abstract {
3
+ public function _construct() {
4
+ parent::_construct ();
5
+ $this->_init ( 'meinpaket/async' );
6
+ }
7
+ }
app/code/community/Dhl/MeinPaket/Model/Attribute/Mapping.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Attribute_Mapping extends Mage_Core_Model_Abstract {
3
+ protected function _construct() {
4
+ $this->_init ( 'meinpaket/attribute_mapping' );
5
+ }
6
+ }
app/code/community/Dhl/MeinPaket/Model/Backlog/Product.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Backlog_Product extends Mage_Core_Model_Abstract {
3
+ public function _construct() {
4
+ parent::_construct ();
5
+ $this->_init ( 'meinpaket/backlog_product' );
6
+ }
7
+ }
app/code/community/Dhl/MeinPaket/Model/BestPrice.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_BestPrice extends Mage_Core_Model_Abstract {
3
+ public function _construct() {
4
+ parent::_construct ();
5
+ $this->_init ( 'meinpaket/bestPrice' );
6
+ }
7
+ }
app/code/community/Dhl/MeinPaket/Model/Carrier/Meinpaket.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Shipping model which handles the import of orders from DHL MeinPaket.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model
9
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
10
+ */
11
+ class Dhl_MeinPaket_Model_Carrier_Meinpaket extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface {
12
+ /**
13
+ *
14
+ * @var string
15
+ */
16
+ protected $_code = 'meinpaket';
17
+
18
+ /**
19
+ *
20
+ * @var float
21
+ */
22
+ protected static $_deliveryCosts = 0.0;
23
+
24
+ /**
25
+ * Tells if the carrier is locked for use.
26
+ *
27
+ * @var boolean
28
+ */
29
+ protected static $_isLocked = true;
30
+
31
+ /**
32
+ * Locks the carrier for use.
33
+ *
34
+ * @return void
35
+ */
36
+ public static function lock() {
37
+ self::$_isLocked = true;
38
+ }
39
+
40
+ /**
41
+ * Unlocks the carrier for use.
42
+ *
43
+ * @return void
44
+ */
45
+ public static function unlock() {
46
+ self::$_isLocked = false;
47
+ }
48
+
49
+ /**
50
+ * Returns the allowed methods for this carrier.
51
+ *
52
+ * @see Mage_Shipping_Model_Carrier_Interface::getAllowedMethods()
53
+ * @return array
54
+ */
55
+ public function getAllowedMethods() {
56
+ return array (
57
+ 'method1' => $this->getConfigData ( 'name' )
58
+ );
59
+ }
60
+
61
+ /**
62
+ * Tells if tracking of this shipment is available.
63
+ *
64
+ * @see Mage_Shipping_Model_Carrier_Abstract::isTrackingAvailable()
65
+ * @return boolean Will always return false
66
+ */
67
+ public function isTrackingAvailable() {
68
+ return false;
69
+ }
70
+
71
+ /**
72
+ * Collect the rates.
73
+ *
74
+ * @see Mage_Shipping_Model_Carrier_Abstract::collectRates()
75
+ * @param Mage_Shipping_Model_Rate_Request $request
76
+ * @return Mage_Shipping_Model_Rate_Result
77
+ */
78
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
79
+ // avoid usage as a general carrier method
80
+ if (self::$_isLocked) {
81
+ return false;
82
+ }
83
+
84
+ /* @var $result Mage_Shipping_Model_Rate_Result */
85
+ $result = Mage::getModel ( 'shipping/rate_result' );
86
+
87
+ /* @var $method Mage_Shipping_Model_Rate_Result_Method */
88
+ $method = Mage::getModel ( 'shipping/rate_result_method' );
89
+
90
+ $method->setCarrier ( $this->_code );
91
+ $method->setCarrierTitle ( $this->getConfigData ( 'title' ) );
92
+ $method->setMethod ( 'method1' );
93
+ $method->setMethodTitle ( $this->getConfigData ( 'name1' ) );
94
+
95
+ $method->setPrice ( self::$_deliveryCosts );
96
+
97
+ $result->append ( $method );
98
+
99
+ return $result;
100
+ }
101
+
102
+ /**
103
+ * Sets the total delivery costs
104
+ *
105
+ * @param float $deliveryCosts
106
+ * @return void
107
+ */
108
+ public static function setDeliveryCosts($deliveryCosts) {
109
+ self::$_deliveryCosts = ( float ) $deliveryCosts;
110
+ }
111
+ }
app/code/community/Dhl/MeinPaket/Model/Category.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * MeinPaket Category Model.
5
+ *
6
+ * @category Mage
7
+ * @package Dhl_MeinPaket
8
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
9
+ */
10
+ class Dhl_MeinPaket_Model_Category extends Mage_Core_Model_Abstract {
11
+ /**
12
+ * Constructor.
13
+ *
14
+ * @see Varien_Object::_construct()
15
+ * @return void
16
+ */
17
+ protected function _construct() {
18
+ $this->_init ( 'meinpaket/category' );
19
+ }
20
+ }
app/code/community/Dhl/MeinPaket/Model/Client/BadHttpReturnCodeException.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Exception which is thrown when a HTTP request returned an error.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Client
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Client_BadHttpReturnCodeException extends Dhl_MeinPaket_Model_Client_HttpException {
13
+ /**
14
+ *
15
+ * @var integer
16
+ */
17
+ protected $httpReturnCode;
18
+
19
+ /**
20
+ * Constructor.
21
+ *
22
+ * @param integer $httpReturnCode
23
+ * @param string $message
24
+ * @return void
25
+ */
26
+ public function __construct($httpReturnCode, $message = '') {
27
+ parent::__construct ( $message );
28
+
29
+ $this->httpReturnCode = $httpReturnCode;
30
+ }
31
+
32
+ /**
33
+ *
34
+ * @return integer
35
+ */
36
+ public function getHttpReturnCode() {
37
+ return $this->httpReturnCode;
38
+ }
39
+ }
app/code/community/Dhl/MeinPaket/Model/Client/HttpException.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * General Exception which is thrown on HTTP errors.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Client
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Client_HttpException extends Varien_Exception {
13
+ }
14
+
app/code/community/Dhl/MeinPaket/Model/Client/HttpTimeoutException.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Exception which is thrown when a HTTP request ran into timeout.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Client
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Client_HttpTimeoutException extends Dhl_MeinPaket_Model_Client_HttpException {
13
+ }
14
+
app/code/community/Dhl/MeinPaket/Model/Client/XmlOverHttp.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * HTTP client to communicate with MeinPaket webservice.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Client
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Client_XmlOverHttp extends Varien_Object {
13
+ /**
14
+ * Endpoint for production
15
+ *
16
+ * @var string
17
+ */
18
+ const PRODUCTIVE_ENDPOINT = 'www.meinpaket.de/dealerapi/xml';
19
+ /**
20
+ * Endpoint for sandbox
21
+ *
22
+ * @var string
23
+ */
24
+ const SANDBOX_ENDPOINT = 'mp-api.mepa-home.de/dealerapi/xml';
25
+ /**
26
+ * Suffix for async requests
27
+ *
28
+ * @var string
29
+ */
30
+ const ASYNC_SUFFIX = 'Async';
31
+
32
+ /**
33
+ * Configuration
34
+ *
35
+ * @var array
36
+ */
37
+ private $config;
38
+
39
+ /**
40
+ * Endpoint
41
+ *
42
+ * @var string
43
+ */
44
+ private $endpoint;
45
+
46
+ /**
47
+ * Constructor.
48
+ *
49
+ * @return void
50
+ */
51
+ public function __construct() {
52
+ $this->config = array ('useragent' => 'Magento ' . Mage::getVersion() . ' Extension ' . Mage::helper('meinpaket/data')->getExtensionVersion());
53
+ $scheme = Mage::getStoreConfigFlag ( 'meinpaket/endpoint/https' ) ? 'https://' : 'http://';
54
+ $path = Mage::getStoreConfigFlag ( 'meinpaket/endpoint/sandbox' ) ? self::SANDBOX_ENDPOINT : self::PRODUCTIVE_ENDPOINT;
55
+ $this->endpoint = $scheme . $path;
56
+
57
+ $host = Mage::getStoreConfig ( 'meinpaket/endpoint/proxy_host' );
58
+ $port = Mage::getStoreConfig ( 'meinpaket/endpoint/proxy_port' );
59
+
60
+ if (Mage::getStoreConfigFlag ( 'meinpaket/endpoint/proxy' )) {
61
+ $this->config ['adapter'] = 'Zend_Http_Client_Adapter_Proxy';
62
+
63
+ if (strlen ( $host ) > 0) {
64
+ $this->config ['proxy_host'] = $host;
65
+ } else {
66
+ $this->config ['proxy_host'] = '127.0.0.1';
67
+ }
68
+
69
+ if (strlen ( $port ) > 0) {
70
+ $this->config ['proxy_port'] = $port;
71
+ } else {
72
+ $this->config ['proxy_port'] = 8888;
73
+ }
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Sends raw XML and returns the response body.
79
+ *
80
+ * @param Dhl_MeinPaket_Model_Xml_AbstractXmlRequest $xml
81
+ * @throws Dhl_MeinPaket_Model_Client_BadHttpReturnCodeException
82
+ * @throws Dhl_MeinPaket_Model_Client_HttpTimeoutException
83
+ * @return Dhl_MeinPaket_Model_Xml_Response_Abstract
84
+ */
85
+ public function send($xml, $async = false) {
86
+ $xmlData = $xml instanceof Dhl_MeinPaket_Model_Xml_AbstractXmlPartial ? $xml->__toString () : $xml;
87
+
88
+ $url = $this->endpoint . ($async ? self::ASYNC_SUFFIX : '');
89
+ $httpClient = new Zend_Http_Client ( $url, $this->config );
90
+ //Zend_Debug::dump($httpClient);die;
91
+ $httpClient->setMethod ( Zend_Http_Client::POST );
92
+ $httpClient->setRawData ( $xmlData );
93
+
94
+ /* @var $log Dhl_MeinPaket_Model_Log */
95
+ $log = Mage::getModel ( 'meinpaket/log' );
96
+ $log->setSend ( $xmlData );
97
+ $log->setCreatedAt ( Varien_Date::now () );
98
+ if ($xml instanceof Dhl_MeinPaket_Model_Xml_Request_AsynchronousStatusRequest) {
99
+ $log->setRequestId ( $xml->getRequestId () );
100
+ }
101
+ $log->save ();
102
+
103
+ try {
104
+ $serverResponse = $httpClient->request ();
105
+ } catch ( Zend_Http_Client_Adapter_Exception $e ) {
106
+ Mage::logException ( $e );
107
+ $log->setError ( $e->getMessage () );
108
+ $log->save ();
109
+ throw new Dhl_MeinPaket_Model_Client_HttpTimeoutException ( $e->getMessage () );
110
+ }
111
+
112
+ $body = $serverResponse->getBody ();
113
+
114
+ $body4Mysql = substr ( $body, 0, 1024 * 1024 * 4 );
115
+ $log->setReceived ( $body4Mysql );
116
+ $status = $serverResponse->getStatus ();
117
+
118
+ if ($status !== 200) {
119
+ $log->setError ( 'FAILURE: Client returned HTTP return code "' . $status . '".' );
120
+ $log->save ();
121
+ throw new Dhl_MeinPaket_Model_Client_BadHttpReturnCodeException ( $status, 'FAILURE: Client returned HTTP return code "' . $status . '".' );
122
+ }
123
+ $log->save ();
124
+
125
+ $dom = new DOMDocument ();
126
+ $response = null;
127
+
128
+ try {
129
+ $valid = $dom->loadXML ( $body );
130
+ if (! $valid) {
131
+ throw new Dhl_MeinPaket_Model_Xml_InvalidXmlException ( "Invalid XML" );
132
+ }
133
+
134
+ /* @var $parser Dhl_MeinPaket_Model_Xml_XmlResponseParser */
135
+ $parser = Mage::getModel ( 'meinpaket/xml_xmlResponseParser' );
136
+ $response = $parser->parseResponse ( $dom );
137
+
138
+ if ($response instanceof Dhl_MeinPaket_Model_Xml_Response_AsynchronousStatusResponse) {
139
+ $log->setRequestId ( $response->getRequestId () );
140
+ }
141
+
142
+ $log->setError ( $response->getErrorString () );
143
+ } catch ( Exception $e ) {
144
+ Mage::logException ( $e );
145
+ $log->setError ( $e->getMessage () );
146
+ }
147
+ $log->save ();
148
+
149
+ return $response;
150
+ }
151
+ }
app/code/community/Dhl/MeinPaket/Model/Cron.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Cron handler for Dhl MeinPaket.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model
9
+ */
10
+ class Dhl_MeinPaket_Model_Cron {
11
+ const SYNC_CATALOG = 'meinpaket_sync_catalog';
12
+ const SYNC_ORDERS = 'meinpaket_sync_orders';
13
+ const SYNC_ASYNC = 'meinpaket_sync_async';
14
+ public static $CRONJOBS = array (
15
+ self::SYNC_CATALOG,
16
+ self::SYNC_ORDERS,
17
+ self::SYNC_ASYNC
18
+ );
19
+
20
+ /**
21
+ * Called to synchronize catalog.
22
+ *
23
+ * @return NULL
24
+ */
25
+ public function exportProducts() {
26
+ try {
27
+ return Mage::getSingleton ( 'meinpaket/service_product_export' )->exportProducts ();
28
+ } catch ( Exception $e ) {
29
+ Mage::logException ( $e );
30
+ }
31
+ return null;
32
+ }
33
+
34
+ /**
35
+ * Called to download orders.
36
+ *
37
+ * @return NULL
38
+ */
39
+ public function importOrders() {
40
+ try {
41
+ return Mage::getSingleton ( 'meinpaket/service_order_importService' )->importOrders ();
42
+ } catch ( Exception $e ) {
43
+ Mage::logException ( $e );
44
+ }
45
+ return null;
46
+ }
47
+
48
+ /**
49
+ * Called to download responses for async requests.
50
+ *
51
+ * @return NULL
52
+ */
53
+ public function processAsyncTasks() {
54
+ try {
55
+ return Mage::getSingleton ( 'meinpaket/service_async' )->process ();
56
+ } catch ( Exception $e ) {
57
+ Mage::logException ( $e );
58
+ }
59
+ return null;
60
+ }
61
+
62
+ /**
63
+ * Called to request best prices.
64
+ *
65
+ * @return NULL
66
+ */
67
+ public function getBestPrice() {
68
+ try {
69
+ return Mage::getSingleton ( 'meinpaket/service_productData_requestService' )->requestBestPrices ();
70
+ } catch ( Exception $e ) {
71
+ Mage::logException ( $e );
72
+ }
73
+ return null;
74
+ }
75
+
76
+ /**
77
+ * Called to request best prices.
78
+ *
79
+ * @return NULL
80
+ */
81
+ public function cleanup() {
82
+ try {
83
+ // Delete all log entries older than 40 days
84
+ $date = Zend_Date::now ();
85
+ $date->subDay ( 40 );
86
+
87
+ $logCollection = Mage::getModel ( 'meinpaket/log' )->getCollection ();
88
+ $logCollection->addFieldToFilter ( 'createdAt', array (
89
+ 'to' => $date->toString ( 'YYYY-MM-dd' )
90
+ ) );
91
+ foreach ( $logCollection as $log ) {
92
+ $log->delete ();
93
+ }
94
+ } catch ( Exception $e ) {
95
+ Mage::logException ( $e );
96
+ }
97
+ return null;
98
+ }
99
+ }
app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Frontend/LabelTranslation.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Custom label translation for frontend.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Entity_Attribute_Frontend
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Entity_Attribute_Frontend_LabelTranslation extends Mage_Eav_Model_Entity_Attribute_Frontend_Abstract {
13
+
14
+ /**
15
+ * Returns the label of the field.
16
+ *
17
+ * @return string
18
+ */
19
+ public function getLabel() {
20
+ return Mage::helper ( 'Dhl_MeinPaket' )->__ ( parent::getLabel () );
21
+ }
22
+ }
app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Source/Carrier.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Attribute source model for shipment methods based on the available carriers.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Entity_Attribute_Source
9
+ * @version $Id$
10
+ */
11
+ class Dhl_MeinPaket_Model_Entity_Attribute_Source_Carrier extends Mage_Eav_Model_Entity_Attribute_Abstract {
12
+ /**
13
+ * Returns the available shipment methods.
14
+ *
15
+ * @return array
16
+ */
17
+ protected function getActiveShipmentCarriers() {
18
+ $carriersArray = array ();
19
+
20
+ /* @var $shippingConfig Mage_Shipping_Model_Config */
21
+ $shippingConfig = Mage::getModel ( 'shipping/config' );
22
+
23
+ $activeCarriers = $shippingConfig->getActiveCarriers ();
24
+
25
+ if (sizeof ( $activeCarriers ) > 0) {
26
+
27
+ foreach ( $activeCarriers as $carrier ) {
28
+
29
+ $code = $carrier->getCarrierCode ();
30
+ $carrierMethods = $carrier->getAllowedMethods ();
31
+ $carrierTitle = Mage::getStoreConfig ( 'carriers/' . $code . '/title' );
32
+
33
+ foreach ( $carrierMethods as $methodCode => $methodTitle ) {
34
+ $carriersArray [$code . '_' . $methodCode] = $carrierTitle . ' - ' . $methodTitle;
35
+ }
36
+ }
37
+ }
38
+
39
+ return $carriersArray;
40
+ }
41
+
42
+ /**
43
+ * Returns the available shipment methods.
44
+ *
45
+ * @return array
46
+ */
47
+ public function toOptionArray() {
48
+ return $this->getActiveShipmentCarriers ();
49
+ }
50
+ }
51
+
app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Source/MeinPaketCategory.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Attribute source model for shipment methods based on the available carriers.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Entity_Attribute_Source
9
+ * @version $Id$
10
+ */
11
+ class Dhl_MeinPaket_Model_Entity_Attribute_Source_MeinPaketCategory extends Mage_Eav_Model_Entity_Attribute_Source_Abstract {
12
+ /**
13
+ * Cache key for list
14
+ * @var unknown
15
+ */
16
+ const CACHE_KEY = 'meinpaket_categories';
17
+
18
+ /**
19
+ * Returns the MeinPaket categories.
20
+ *
21
+ * @return array
22
+ */
23
+ protected function getMeinPaketCategories() {
24
+ $cache = Mage::app ()->getCache ();
25
+
26
+ //$this->cleanCache ();
27
+
28
+ $categories = $cache->load ( self::CACHE_KEY );
29
+
30
+ if (! $categories) {
31
+ $categories = array ();
32
+ $categoryCollection = Mage::getModel ( 'meinpaket/category' )->getCollection ();
33
+ $categoryCollection->setOrder ( 'code', 'ASC' );
34
+
35
+ $currentParents = array ();
36
+
37
+ foreach ( $categoryCollection as $cat ) {
38
+ // Fill lookup table
39
+ $currentParents [$cat->getCode ()] = array (
40
+ 'label' => $cat->getName (),
41
+ 'value' => $cat->getCode (),
42
+ 'parent' => $cat->getParent ()
43
+ );
44
+ }
45
+
46
+ foreach ( $currentParents as $key => &$value ) {
47
+
48
+ if (strlen ( $value ['parent'] ) <= 0) {
49
+ // This category does not have a parent. add it as default.
50
+ $categories [] = &$value;
51
+ } else if (array_key_exists ( $value ['parent'], $currentParents )) {
52
+ // We already have a parent. add it.
53
+ if (! is_array ( $currentParents [$value ['parent']] ['value'] )) {
54
+ $currentParents [$value ['parent']] ['value'] = array ();
55
+ }
56
+ $currentParents [$value ['parent']] ['value'] [] = &$value;
57
+ } else {
58
+ $categories [] = &$value;
59
+ }
60
+ unset ( $value ['parent'] );
61
+ }
62
+
63
+ if (count ( $categories ) > 0) {
64
+ $cache->save ( serialize ( $categories ), self::CACHE_KEY );
65
+ }
66
+ } else {
67
+ $categories = unserialize ( $categories );
68
+ }
69
+
70
+ return $categories;
71
+ }
72
+
73
+ /**
74
+ * Returns the Dhl MeinPaket categories.
75
+ *
76
+ * @return array
77
+ */
78
+ public function toOptionArray() {
79
+ return $this->getMeinPaketCategories ();
80
+ }
81
+ public function getAllOptions() {
82
+ return $this->getMeinPaketCategories ();
83
+ }
84
+ public function cleanCache() {
85
+ Mage::app ()->getCache ()->remove ( self::CACHE_KEY );
86
+ }
87
+ }
88
+
app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Source/ProductAttribute.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Product attributes model.
5
+ * Reads product attributes and provides them as config array.
6
+ *
7
+ * @category Dhl
8
+ * @package Dhl_MeinPaket
9
+ * @subpackage Model_Entity_Attribute_Source
10
+ * @version $Id$
11
+ */
12
+ class Dhl_MeinPaket_Model_Entity_Attribute_Source_ProductAttribute extends Mage_Eav_Model_Entity_Attribute_Abstract {
13
+ protected $attributes;
14
+ public function __construct() {
15
+ $this->attributes = array (
16
+ array (
17
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'None' ),
18
+ 'value' => ''
19
+ )
20
+ );
21
+
22
+ foreach ( Mage::getResourceModel ( 'catalog/product_attribute_collection' ) as $attribute ) {
23
+ if (strlen ( $attribute->getFrontendLabel () ) > 0) {
24
+ $this->attributes [] = array (
25
+ 'label' => $attribute->getFrontendLabel (),
26
+ 'value' => $attribute->getAttributecode ()
27
+ );
28
+ }
29
+ }
30
+ }
31
+ public function toOptionArray($addEmpty = true) {
32
+ return $this->attributes;
33
+ }
34
+ public function toSelectArray() {
35
+ $result = array ();
36
+
37
+ foreach ( $this->attributes as $attribute ) {
38
+ $result [$attribute ['value']] = $attribute ['label'];
39
+ }
40
+
41
+ return $result;
42
+ }
43
+ }
app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Source/ProductSyncMode.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Status flags for product sync.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Entity_Attribute_Source
9
+ * @version $Id$
10
+ */
11
+ class Dhl_MeinPaket_Model_Entity_Attribute_Source_ProductSyncMode extends Mage_Eav_Model_Entity_Attribute_Abstract {
12
+ /**
13
+ * Disabled.
14
+ *
15
+ * @var unknown
16
+ */
17
+ const DISABLED = 0;
18
+ /**
19
+ * Offer.
20
+ *
21
+ * @var unknown
22
+ */
23
+ const OFFER = 1;
24
+ /**
25
+ * Complete.
26
+ *
27
+ * @var unknown
28
+ */
29
+ const COMPLETE = 2;
30
+
31
+ /**
32
+ * Options
33
+ *
34
+ * @var array
35
+ */
36
+ protected $options;
37
+
38
+ /**
39
+ * Default constructor.
40
+ */
41
+ public function __construct() {
42
+ $this->options = array (
43
+ array (
44
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Disabled' ),
45
+ 'value' => self::DISABLED
46
+ ),
47
+ array (
48
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Offer' ),
49
+ 'value' => self::OFFER
50
+ ),
51
+ array (
52
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Product Data + Offer' ),
53
+ 'value' => self::COMPLETE
54
+ )
55
+ );
56
+ }
57
+
58
+ /**
59
+ * Get array of options.
60
+ *
61
+ * @param string $addEmpty
62
+ * @return multitype:
63
+ */
64
+ public function toOptionArray($addEmpty = true) {
65
+ return $this->options;
66
+ }
67
+
68
+ /**
69
+ * Get array of options.
70
+ *
71
+ * @param string $addEmpty
72
+ * @return multitype:
73
+ */
74
+ public function getAllOptions() {
75
+ return $this->options;
76
+ }
77
+
78
+ /**
79
+ * To select array.
80
+ *
81
+ * @return multitype:unknown
82
+ */
83
+ public function toSelectArray() {
84
+ $result = array ();
85
+
86
+ foreach ( $this->options as $option ) {
87
+ $result [$option ['value']] = $option ['label'];
88
+ }
89
+
90
+ return $result;
91
+ }
92
+ }
app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Source/Taxclass.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Tax class model.
5
+ * Reads tax classes from database and provides them as config array.
6
+ *
7
+ * @category Dhl
8
+ * @package Dhl_MeinPaket
9
+ * @subpackage Model_Entity_Attribute_Source
10
+ * @version $Id$
11
+ */
12
+ class Dhl_MeinPaket_Model_entity_Attribute_Source_Taxclass extends Mage_Eav_Model_Entity_Attribute_Abstract {
13
+ /**
14
+ * returns tax classes from database
15
+ *
16
+ * @return bool
17
+ */
18
+ protected function getTaxClasses() {
19
+ $taxClasses = array ();
20
+
21
+ $db = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_write' );
22
+ $table_prefix = Mage::getConfig ()->getTablePrefix ();
23
+
24
+ $result = $db->query ( "
25
+ SELECT class_id, class_name
26
+ FROM {$table_prefix}tax_class
27
+ WHERE class_type = 'PRODUCT'
28
+ ORDER BY class_id
29
+ " );
30
+
31
+ if ($result) {
32
+ while ( $row = $result->fetch ( PDO::FETCH_ASSOC ) ) {
33
+ $taxClasses [] = array (
34
+ 'value' => $row ['class_id'],
35
+ 'label' => $row ['class_name']
36
+ );
37
+ }
38
+ }
39
+
40
+ return $taxClasses;
41
+ }
42
+
43
+ /**
44
+ *
45
+ * @return array
46
+ */
47
+ public function toOptionArray() {
48
+ return $this->getTaxClasses ();
49
+ }
50
+ }
51
+
app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Source/Taxrate.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Tax rate model.
5
+ * Reads tax rates from database and provides them as config array.
6
+ *
7
+ * @category Dhl
8
+ * @package Dhl_MeinPaket
9
+ * @subpackage Model_Entity_Attribute_Source
10
+ * @version $Id$
11
+ */
12
+ class Dhl_MeinPaket_Model_entity_Attribute_Source_Taxrate extends Mage_Eav_Model_Entity_Attribute_Abstract {
13
+ /**
14
+ * returns tax rates from database
15
+ *
16
+ * @return bool
17
+ */
18
+ protected function getTaxRates() {
19
+ $taxRates = array ();
20
+
21
+ $db = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_write' );
22
+ $table_prefix = Mage::getConfig ()->getTablePrefix ();
23
+
24
+ $result = $db->query ( "
25
+ SELECT tax_calculation_rate_id, rate
26
+ FROM {$table_prefix}tax_calculation_rate
27
+ ORDER BY tax_calculation_rate_id
28
+ " );
29
+
30
+ if ($result) {
31
+ while ( $row = $result->fetch ( PDO::FETCH_ASSOC ) ) {
32
+ $taxRates [] = array (
33
+ 'value' => $row ['tax_calculation_rate_id'],
34
+ 'label' => $row ['rate']
35
+ );
36
+ }
37
+ }
38
+
39
+ return $taxRates;
40
+ }
41
+
42
+ /**
43
+ *
44
+ * @return array
45
+ */
46
+ public function toOptionArray() {
47
+ return $this->getTaxRates ();
48
+ }
49
+ }
app/code/community/Dhl/MeinPaket/Model/Exception/InvalidDataException.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Basic exception class for invalid data.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Exception
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Exception_InvalidDataException extends Varien_Exception {
13
+ /**
14
+ *
15
+ * @var string
16
+ */
17
+ protected $errorType;
18
+
19
+ /**
20
+ *
21
+ * @var string
22
+ */
23
+ protected $fieldName;
24
+
25
+ /**
26
+ *
27
+ * @var integer
28
+ */
29
+ protected $entityId;
30
+
31
+ /**
32
+ * Constructor.
33
+ *
34
+ * @param integer $entityId
35
+ * of the model entity on which the error occured.
36
+ * @param string $fieldName
37
+ * of the attribute which is invalid.
38
+ * @param string $errorType
39
+ * type defined in Dhl_MeinPaket_Model_Validation_ValidationInterface.
40
+ * @return void
41
+ */
42
+ public function __construct($entityId, $fieldName, $errorType = Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_FIELD_IS_INVALID) {
43
+ parent::__construct ( 'Invalid data field "' . $fieldName . '" for entity (id=' . $entityId . '). Error type is "' . $errorType . '".' );
44
+
45
+ $this->entityId = $entityId;
46
+ $this->fieldName = $fieldName;
47
+ $this->errorType = $errorType;
48
+ }
49
+
50
+ /**
51
+ *
52
+ * @return string
53
+ */
54
+ public function getFieldName() {
55
+ return $this->fieldName;
56
+ }
57
+
58
+ /**
59
+ *
60
+ * @return integer
61
+ */
62
+ public function getEntityId() {
63
+ return $this->entityId;
64
+ }
65
+
66
+ /**
67
+ *
68
+ * @return string
69
+ */
70
+ public function getErrorType() {
71
+ return $this->errorType;
72
+ }
73
+ }
app/code/community/Dhl/MeinPaket/Model/Exception/MissingDataException.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Basic exception class for invalid data.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Exception
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Exception_MissingDataException extends Dhl_MeinPaket_Model_Exception_InvalidDataException {
13
+ /**
14
+ * Constructor.
15
+ *
16
+ * @param integer $entityId
17
+ * of the model entity on which the error occured.
18
+ * @param string $fieldName
19
+ * of the attribute that is missing.
20
+ * @return void
21
+ */
22
+ public function __construct($entityId, $fieldName) {
23
+ parent::__construct ( $entityId, $fieldName, Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_REQUIRED_FIELD_IS_EMPTY );
24
+ }
25
+ }
26
+
app/code/community/Dhl/MeinPaket/Model/Log.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Log extends Mage_Core_Model_Abstract {
3
+ public function _construct() {
4
+ parent::_construct ();
5
+ $this->_init ( 'meinpaket/log' );
6
+ }
7
+
8
+ /**
9
+ * Set received data.
10
+ * Filter if response is too big for mysql.
11
+ *
12
+ * @param unknown $data
13
+ */
14
+ public function setReceived($data) {
15
+ if (count ( $data ) < 1024 * 1024 * 8) {
16
+ parent::setReceived ( $data );
17
+ } else {
18
+ parent::setReceived ( 'Response too big for mysql' );
19
+ }
20
+ }
21
+ }
app/code/community/Dhl/MeinPaket/Model/Mysql4/Async.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Mysql4_Async extends Mage_Core_Model_Mysql4_Abstract {
3
+ /**
4
+ * Initialize domain model and set primary key
5
+ *
6
+ * @return void
7
+ */
8
+ protected function _construct() {
9
+ $this->_init ( 'meinpaket/async', 'async_id' );
10
+ }
11
+ }
app/code/community/Dhl/MeinPaket/Model/Mysql4/Async/Collection.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Mysql4_Async_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
3
+ /**
4
+ * Initialize domain model
5
+ *
6
+ * @return void
7
+ */
8
+ protected function _construct() {
9
+ $this->_init ( 'meinpaket/async' );
10
+ }
11
+ }
app/code/community/Dhl/MeinPaket/Model/Mysql4/Backlog/Product.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Mysql4_Backlog_Product extends Mage_Core_Model_Mysql4_Abstract {
3
+ /**
4
+ * Initialize domain model and set primary key
5
+ *
6
+ * @return void
7
+ */
8
+ protected function _construct() {
9
+ $this->_init ( 'meinpaket/backlog_product', 'backlog_id' );
10
+ }
11
+ }
app/code/community/Dhl/MeinPaket/Model/Mysql4/Backlog/Product/Collection.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Mysql4_Backlog_Product_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
3
+ /**
4
+ * Initialize domain model
5
+ *
6
+ * @return void
7
+ */
8
+ protected function _construct() {
9
+ $this->_init ( 'meinpaket/backlog_product' );
10
+ }
11
+ }
app/code/community/Dhl/MeinPaket/Model/Mysql4/BestPrice.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Mysql4_BestPrice extends Mage_Core_Model_Mysql4_Abstract {
3
+ /**
4
+ * Initialize domain model and set primary key
5
+ *
6
+ * @return void
7
+ */
8
+ protected function _construct() {
9
+ $this->_init ( 'meinpaket/bestprice', 'bestprice_id' );
10
+ }
11
+ }
app/code/community/Dhl/MeinPaket/Model/Mysql4/BestPrice/Collection.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Mysql4_BestPrice_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
3
+ /**
4
+ * Initialize domain model
5
+ *
6
+ * @return void
7
+ */
8
+ protected function _construct() {
9
+ $this->_init ( 'meinpaket/bestPrice' );
10
+ }
11
+ }
app/code/community/Dhl/MeinPaket/Model/Mysql4/Category.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * MeinPaket category resource model
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
9
+ */
10
+ class Dhl_MeinPaket_Model_Mysql4_Category extends Mage_Core_Model_Mysql4_Abstract {
11
+ protected function _construct() {
12
+ $this->_init ( 'meinpaket/category', 'category_id' );
13
+ }
14
+ }
15
+
app/code/community/Dhl/MeinPaket/Model/Mysql4/Category/Collection.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * MeinPaket category collection.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
9
+ */
10
+ class Dhl_MeinPaket_Model_Mysql4_Category_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
11
+ /**
12
+ * Constructor.
13
+ *
14
+ * @see Mage_Core_Model_Mysql4_Collection_Abstract::_construct()
15
+ * @return void
16
+ */
17
+ protected function _construct() {
18
+ $this->_init ( 'meinpaket/category' );
19
+ }
20
+ }
app/code/community/Dhl/MeinPaket/Model/Mysql4/Log.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Mysql4_Log extends Mage_Core_Model_Mysql4_Abstract {
3
+ /**
4
+ * Initialize domain model and set primary key
5
+ *
6
+ * @return void
7
+ */
8
+ protected function _construct() {
9
+ $this->_init ( 'meinpaket/log', 'log_id' );
10
+ }
11
+ }
app/code/community/Dhl/MeinPaket/Model/Mysql4/Log/Collection.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Mysql4_Log_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
3
+ /**
4
+ * Initialize domain model
5
+ *
6
+ * @return void
7
+ */
8
+ protected function _construct() {
9
+ $this->_init ( 'meinpaket/log' );
10
+ }
11
+ }
app/code/community/Dhl/MeinPaket/Model/Observer.php ADDED
@@ -0,0 +1,691 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Observer for all events the DHL MeinPaket extension has to catch.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Observer {
13
+ /**
14
+ * Stock attributes.
15
+ *
16
+ * @var array
17
+ */
18
+ private $STOCK_ATTRIBUTES = array (
19
+ 'qty',
20
+ 'manage_stock',
21
+ 'is_in_stock',
22
+ 'min_qty',
23
+ 'min_sale_qty',
24
+ 'max_sale_qty'
25
+ );
26
+
27
+ /**
28
+ * Holds the id of the order whose save_after event is actually triggered.
29
+ *
30
+ * @var integer
31
+ */
32
+ protected static $currentlySavedOrderId = - 1;
33
+
34
+ /**
35
+ * Tells if the save_after has been triggered twice or more on
36
+ * the same order during script lifetime.
37
+ *
38
+ * @var boolean
39
+ */
40
+ protected static $isSameSavedOrder = false;
41
+
42
+ /**
43
+ * Sets the id of the order whose save_after event has been triggered.
44
+ *
45
+ * @param integer $orderId
46
+ * @return void
47
+ */
48
+ protected static function setCurrentOrderId($orderId) {
49
+ if (self::$currentlySavedOrderId === $orderId) {
50
+ self::$isSameSavedOrder = true;
51
+ } else {
52
+ self::$isSameSavedOrder = false;
53
+ }
54
+ self::$currentlySavedOrderId = $orderId;
55
+ }
56
+
57
+ /**
58
+ * Tells if the save_after event of the current order has been triggered
59
+ * at least once during the lifecycle of the current script.
60
+ *
61
+ * @return boolean
62
+ */
63
+ protected static function saveEventHasBeenTriggeredOnSameOrderBefore() {
64
+ return self::$isSameSavedOrder;
65
+ }
66
+
67
+ /**
68
+ * Triggered when product is duplicated.
69
+ *
70
+ * @param Varien_Event_Observer $observer
71
+ * @return Dhl_MeinPaket_Model_Observer
72
+ */
73
+ public function productDuplicate(Varien_Event_Observer $observer) {
74
+ $newProduct = $observer->getEvent ()->getNewProduct ();
75
+ $newProduct->setData ( 'meinpaket_id', '' );
76
+ $newProduct->setData ( 'meinpaket_export', 0 );
77
+ return $this;
78
+ }
79
+
80
+ /**
81
+ * Is triggered when an order is saved.
82
+ *
83
+ * @param Varien_Event_Observer $observer
84
+ * @return Dhl_MeinPaket_Model_Observer
85
+ */
86
+ public function salesOrderSaveAfter(Varien_Event_Observer $observer) {
87
+ $order = $observer->getData ( 'order' );
88
+
89
+ self::setCurrentOrderId ( $order->getId () );
90
+
91
+ $this->_updateMeinPaketOrderId ( $order );
92
+ $this->_handleOrderItemsChange ( $order );
93
+ $this->_cancelMeinPaketOrder ( $order );
94
+
95
+ return $this;
96
+ }
97
+
98
+ /**
99
+ * Sets the dhl_mein_paket_order_id for the given order.
100
+ * This is necessary if an order is edit and so created a new one.
101
+ * The new one will not have it's dhl_mein_paket_order_id attribute
102
+ * automatically.
103
+ *
104
+ * @param Varien_Object $order
105
+ * @return Dhl_MeinPaket_Model_Observer
106
+ */
107
+ protected function _updateMeinPaketOrderId($order) {
108
+ // return if the order doesn't have a parent order
109
+ // or if it already has a MeinPaket.de order id...
110
+ if (! $order->hasData ( 'relation_parent_id' ) || $order->hasData ( 'dhl_mein_paket_order_id' )) {
111
+ return;
112
+ }
113
+
114
+ /* @var $parentOrder Mage_Sales_Model_Order */
115
+ $parentOrder = Mage::getModel ( 'sales/order' )->load ( $order->getData ( 'relation_parent_id' ) );
116
+
117
+ if (! $parentOrder->hasData ( 'relation_parent_id' ) || $parentOrder->hasData ( 'dhl_mein_paket_order_id' )) {
118
+ $order->setData ( 'dhl_mein_paket_order_id', $parentOrder->getDhlMeinPaketOrderId () );
119
+ $parentOrder->setData ( 'dhl_mein_paket_order_id', '' )->getResource ()->saveAttribute ( $parentOrder, 'dhl_mein_paket_order_id' );
120
+ }
121
+
122
+ return $this;
123
+ }
124
+
125
+ /**
126
+ * Cancels single order items.
127
+ *
128
+ * @param Mage_Sales_Model_Order $order
129
+ * @return Dhl_MeinPaket_Model_Observer
130
+ */
131
+ protected function _handleOrderItemsChange(Mage_Sales_Model_Order $order) {
132
+ if (self::saveEventHasBeenTriggeredOnSameOrderBefore ()) {
133
+ return;
134
+ }
135
+
136
+ if ($order->getData ( 'state' ) === Mage_Sales_Model_Order::STATE_CANCELED) {
137
+ return $this;
138
+ }
139
+
140
+ if (! $order->hasData ( 'relation_parent_id' )) {
141
+ return $this;
142
+ }
143
+
144
+ /* @var $orderHelper Dhl_MeinPaket_Helper_Order */
145
+ $orderHelper = Mage::helper ( 'meinpaket/order' );
146
+
147
+ /* @var $parentOrder Mage_Sales_Model_Order */
148
+ $parentOrder = Mage::getModel ( 'sales/order' )->load ( $order->getData ( 'relation_parent_id' ) );
149
+
150
+ if ($orderHelper->isMeinPaketOrder ( $order )) {
151
+
152
+ $orderItemCollection = $order->getItemsCollection ();
153
+ $parentItemCollection = $parentOrder->getItemsCollection ();
154
+ $items = array ();
155
+ $parentItems = array ();
156
+ $reduceList = array ();
157
+ $submitChanges = false;
158
+
159
+ foreach ( $orderItemCollection as $item ) {
160
+ $options = $item->getProductOptions ();
161
+ if (isset ( $options ['info_buyRequest'] ) && isset ( $options ['info_buyRequest'] ['dhl_mein_paket_item_id'] )) {
162
+ $items [$options ['info_buyRequest'] ['dhl_mein_paket_item_id']] = array (
163
+ 'qty' => ( integer ) $item->getQtyOrdered (),
164
+ 'productId' => $item->getProductId ()
165
+ );
166
+ }
167
+ }
168
+ foreach ( $parentItemCollection as $item ) {
169
+ $options = $item->getProductOptions ();
170
+ if ($item->getQtyCanceled () != $item->getQtyOrdered ()) {
171
+ $submitChanges = true;
172
+ }
173
+ if (isset ( $options ['info_buyRequest'] ) && isset ( $options ['info_buyRequest'] ['dhl_mein_paket_item_id'] )) {
174
+ $parentItems [$options ['info_buyRequest'] ['dhl_mein_paket_item_id']] = array (
175
+ 'qty' => ( integer ) $item->getQtyOrdered (),
176
+ 'productId' => $item->getProductId ()
177
+ );
178
+ }
179
+ }
180
+
181
+ if ($submitChanges === false) {
182
+ return $this;
183
+ }
184
+
185
+ // find items with lowered quantity
186
+ if (sizeof ( $items ) < sizeof ( $parentItems )) {
187
+ foreach ( $parentItems as $dhlItemId => $item ) {
188
+ if (! array_key_exists ( $dhlItemId, $items )) {
189
+ $reduceList [$dhlItemId] = array (
190
+ 'qty' => $item ['qty'],
191
+ 'productId' => $item ['productId']
192
+ );
193
+ } elseif ($items [$dhlItemId] ['qty'] < $item ['qty']) {
194
+ $reduceList [$dhlItemId] = array (
195
+ 'qty' => $item ['qty'] - $items [$dhlItemId] ['qty'],
196
+ 'productId' => $item ['productId']
197
+ );
198
+ }
199
+ }
200
+ } else {
201
+ foreach ( $items as $dhlItemId => $item ) {
202
+ if (array_key_exists ( $dhlItemId, $parentItems ) && $item ['qty'] < $parentItems [$dhlItemId] ['qty']) {
203
+ $reduceList [$dhlItemId] = array (
204
+ 'qty' => $parentItems [$dhlItemId] ['qty'] - $item ['qty'],
205
+ 'productId' => $item ['productId']
206
+ );
207
+ }
208
+ }
209
+ }
210
+
211
+ if (sizeof ( $reduceList ) > 0) {
212
+ // make request
213
+ /* @var $cancellationService Dhl_MeinPaket_Model_Service_Order_CancellationService */
214
+ $cancellationService = Mage::getModel ( 'meinpaket/service_order_cancellationService' );
215
+ $result = null;
216
+ $helper = Mage::helper ( 'meinpaket/data' );
217
+ $errMsg = '';
218
+
219
+ try {
220
+ $result = $cancellationService->cancelOrderItems ( $order, $reduceList );
221
+ } catch ( Dhl_MeinPaket_Model_Xml_XmlBuildException $e ) {
222
+ Mage::logException ( $e );
223
+ $errMsg .= $helper->__ ( 'Request could not be built.' );
224
+ } catch ( Dhl_MeinPaket_Model_Client_BadHttpReturnCodeException $e ) {
225
+ Mage::logException ( $e );
226
+ $errMsg .= sprintf ( $helper->__ ( 'MeinPaket.de server returned HTPP code %s.' ), $e->getHttpReturnCode () );
227
+ } catch ( Dhl_MeinPaket_Model_Client_HttpTimeoutException $e ) {
228
+ Mage::logException ( $e );
229
+ $errMsg .= $helper->__ ( 'Connection to MeinPaket.de server timed out.' );
230
+ } catch ( Dhl_MeinPaket_Model_Xml_InvalidXmlException $e ) {
231
+ Mage::logException ( $e );
232
+ $errMsg .= $helper->__ ( 'Invalid response from MeinPaket.de server.' );
233
+ } catch ( Exception $e ) {
234
+ Mage::logException ( $e );
235
+ $errMsg .= $helper->__ ( 'Unknown error.' );
236
+ }
237
+ if (is_object ( $result ) && $result->hasError ()) {
238
+ $errMsg .= sprintf ( $helper->__ ( 'MeinPaket.de server returned error code %s.' ), $result->getError () );
239
+ }
240
+
241
+ if (strlen ( $errMsg ) > 0) {
242
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $helper->__ ( 'Error on tranfering cancelled items to MeinPaket.de.' ) . ' (' . $errMsg . ')' );
243
+ throw new Exception ( 'Failed transfering cancelled items to MeinPaket.de server.' );
244
+ }
245
+ }
246
+ }
247
+
248
+ return $this;
249
+ }
250
+
251
+ /**
252
+ * Cancels the given order in MeinPaket.de if the given order is a MeinPaket.de order
253
+ * and its state is Mage_Sales_Model_Order::STATE_CANCELED.
254
+ *
255
+ * @param Mage_Sales_Model_Order $order
256
+ * @return Dhl_MeinPaket_Model_Observer
257
+ */
258
+ protected function _cancelMeinPaketOrder(Mage_Sales_Model_Order $order) {
259
+ $meinPaketOrderId = $order->getData ( 'dhl_mein_paket_order_id' );
260
+
261
+ if (strlen ( $meinPaketOrderId ) > 1 && $order->getData ( 'state' ) === Mage_Sales_Model_Order::STATE_CANCELED) {
262
+
263
+ $col = Mage::getModel ( 'sales/order' )->getCollection ()->addAttributeToFilter ( 'relation_parent_id', $order->getId () )->load ();
264
+
265
+ if ($col->count () > 0) {
266
+ return $this;
267
+ }
268
+
269
+ // TODO: Class missing
270
+
271
+ /* @var $orderCancellationService Dhl_MeinPaket_Model_Service_Order_CancellationService */
272
+ $orderCancellationService = Mage::getModel ( 'meinpaket/service_order_cancellationService' );
273
+
274
+ $result = null;
275
+ $helper = Mage::helper ( 'meinpaket/data' );
276
+ $errMsg = '';
277
+
278
+ try {
279
+ $result = $orderCancellationService->cancelOrder ( $order );
280
+ } catch ( Dhl_MeinPaket_Model_Xml_XmlBuildException $e ) {
281
+ Mage::logException ( $e );
282
+ $errMsg .= $helper->__ ( 'Request could not be built.' );
283
+ } catch ( Dhl_MeinPaket_Model_Client_BadHttpReturnCodeException $e ) {
284
+ Mage::logException ( $e );
285
+ $errMsg .= sprintf ( $helper->__ ( 'MeinPaket.de server returned HTPP code %s.' ), $e->getHttpReturnCode () );
286
+ } catch ( Dhl_MeinPaket_Model_Client_HttpTimeoutException $e ) {
287
+ Mage::logException ( $e );
288
+ $errMsg .= $helper->__ ( 'Connection to MeinPaket.de server timed out.' );
289
+ } catch ( Dhl_MeinPaket_Model_Xml_InvalidXmlException $e ) {
290
+ Mage::logException ( $e );
291
+ $errMsg .= $helper->__ ( 'Invalid response from MeinPaket.de server.' );
292
+ } catch ( Exception $e ) {
293
+ Mage::logException ( $e );
294
+ $errMsg .= $helper->__ ( 'Unknown error.' );
295
+ }
296
+ if (is_object ( $result ) && $result->hasError ()) {
297
+ $errMsg .= sprintf ( $helper->__ ( 'MeinPaket.de server returned error code %s.' ), $result->getError () );
298
+ }
299
+
300
+ if (strlen ( $errMsg ) > 0) {
301
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $helper->__ ( 'Error on tranfering cancelled items to MeinPaket.de.' ) . ' (' . $errMsg . ')' );
302
+ throw new Exception ( 'Failed transfering cancelled items to MeinPaket.de server.' );
303
+ }
304
+ }
305
+
306
+ return $this;
307
+ }
308
+
309
+ /**
310
+ * Is triggered when a shipment is saved.
311
+ *
312
+ * @param Varien_Event_Observer $observer
313
+ * @return Dhl_MeinPaket_Model_Observer
314
+ */
315
+ public function salesOrderShipmentSaveAfter(Varien_Event_Observer $observer) {
316
+ /* @var $order Dhl_MeinPaket_Helper_Shipment */
317
+ $shipmentHelper = Mage::helper ( 'meinpaket/shipment' );
318
+
319
+ /* @var $shipment Mage_Sales_Model_Order_Shipment */
320
+ $shipment = Mage::getModel ( 'sales/order_shipment' )->load ( $observer->getData ( 'shipment' )->getId () );
321
+
322
+ if ($shipmentHelper->isExportedToDhlMeinPaket ( $shipment )) {
323
+ return $this;
324
+ }
325
+
326
+ if (! $shipmentHelper->isMeinPaketShipment ( $shipment )) {
327
+ return $this;
328
+ }
329
+
330
+ // send shipment request to MeinPaket.
331
+ $this->_exportShipmentToMeinPaket ( $shipment );
332
+
333
+ return $this;
334
+ }
335
+
336
+ /**
337
+ * Is called after a shipment save is committed.
338
+ * Sets the shipment's "shipment_was_exported_for_dhl_mein_paket" attribute
339
+ * value to "1" if it isn't set yet.
340
+ *
341
+ * @param Varien_Event_Observer $observer
342
+ * @return Dhl_MeinPaket_Model_Observer
343
+ */
344
+ public function salesOrderShipmentSaveCommitAfter(Varien_Event_Observer $observer) {
345
+ /* @var $order Dhl_MeinPaket_Helper_Shipment */
346
+ $shipmentHelper = Mage::helper ( 'meinpaket/shipment' );
347
+
348
+ /* @var $shipment Mage_Sales_Model_Order_Shipment */
349
+ $shipment = $observer->getShipment ();
350
+
351
+ if ($shipmentHelper->isExportedToDhlMeinPaket ( $shipment )) {
352
+ return $this;
353
+ }
354
+
355
+ if (! $shipmentHelper->isMeinPaketShipment ( $shipment )) {
356
+ return $this;
357
+ }
358
+
359
+ if ($shipmentHelper->isMeinPaketShipment ( $shipment ) && ! $shipment->getData ( 'shipment_was_exported_for_dhl_mein_paket' )) {
360
+ $shipment->setData ( 'shipment_was_exported_for_dhl_mein_paket', 1 )->getResource ()->saveAttribute ( $shipment, 'shipment_was_exported_for_dhl_mein_paket' );
361
+ }
362
+ }
363
+
364
+ /**
365
+ * Exports an saved shipment to MeinPaket.de.
366
+ *
367
+ * @param Mage_Sales_Model_Order_Shipment $shipment
368
+ * @return Dhl_MeinPaket_Model_Observer
369
+ */
370
+ protected function _exportShipmentToMeinPaket(Mage_Sales_Model_Order_Shipment $shipment) {
371
+ /* @var $shipmentExportService Dhl_MeinPaket_Model_Service_Order_ShipmentExportService */
372
+ $shipmentExportService = Mage::getModel ( 'meinpaket/service_order_shipmentExportService' );
373
+
374
+ $result = null;
375
+ $errMsg = '';
376
+ $helper = Mage::helper ( 'meinpaket/data' );
377
+
378
+ try {
379
+ $result = $shipmentExportService->exportShipment ( $shipment );
380
+ } catch ( Dhl_MeinPaket_Model_Xml_XmlBuildException $e ) {
381
+ Mage::logException ( $e );
382
+ $errMsg .= $helper->__ ( 'Request could not be built.' );
383
+ } catch ( Dhl_MeinPaket_Model_Client_BadHttpReturnCodeException $e ) {
384
+ Mage::logException ( $e );
385
+ $errMsg .= sprintf ( $helper->__ ( 'MeinPaket.de server returned HTPP code %s.' ), $e->getHttpReturnCode () );
386
+ } catch ( Dhl_MeinPaket_Model_Client_HttpTimeoutException $e ) {
387
+ Mage::logException ( $e );
388
+ $errMsg .= $helper->__ ( 'Connection to MeinPaket.de server timed out.' );
389
+ } catch ( Dhl_MeinPaket_Model_Xml_InvalidXmlException $e ) {
390
+ Mage::logException ( $e );
391
+ $errMsg .= $helper->__ ( 'Invalid response from MeinPaket.de server.' );
392
+ } catch ( Exception $e ) {
393
+ Mage::logException ( $e );
394
+ $errMsg .= $helper->__ ( 'Unknown error.' );
395
+ }
396
+
397
+ if ($result == null || $result->hasErrors ()) {
398
+ $errMsg .= $helper->__ ( 'Shipment has not been accepted by MeinPaket.de.' );
399
+ }
400
+
401
+ if (strlen ( $errMsg ) > 0) {
402
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $helper->__ ( 'Error on transfering shipment to MeinPaket.de.' ) . ' (' . $errMsg . ')' );
403
+ throw new Exception ( 'Failed exporting shipment to MeinPaket.de server.' );
404
+ }
405
+
406
+ return $this;
407
+ }
408
+
409
+ /**
410
+ * Is called when a creditmemo is saved.
411
+ * If the creditmemo is refunded, a notification will be send to MeinPaket.de.
412
+ *
413
+ * @param Varien_Event_Observer $observer
414
+ * @return Dhl_MeinPaket_Model_Observer
415
+ */
416
+ public function salesOrderCreditmemoSaveAfter(Varien_Event_Observer $observer) {
417
+ /* @var $creditmemo Mage_Sales_Model_Order_Creditmemo */
418
+ $creditmemo = $observer->getData ( 'creditmemo' );
419
+
420
+ // check if creditmemo is refunded
421
+ if ($creditmemo->getState () != Mage_Sales_Model_Order_Creditmemo::STATE_REFUNDED) {
422
+ return $this;
423
+ }
424
+
425
+ // check if the order is a MeinPaket.de order
426
+ if (! Mage::helper('meinpaket/order')->isMeinPaketOrder ( $creditmemo->getOrder () )) {
427
+ return $this;
428
+ }
429
+
430
+ /* @var $result Dhl_MeinPaket_Model_Sevice_RefundExport_Result */
431
+ $result = null;
432
+
433
+ /* @var $exportService Dhl_MeinPaket_Model_Sevice_RefundExportService */
434
+ $exportService = Mage::getModel ( 'meinpaket/service_order_refundExportService' );
435
+
436
+ $helper = Mage::helper ( 'meinpaket/data' );
437
+ $errMsg = '';
438
+
439
+ try {
440
+ $result = $exportService->exportRefund ( $creditmemo );
441
+ } catch ( Dhl_MeinPaket_Model_Xml_XmlBuildException $e ) {
442
+ Mage::logException ( $e );
443
+ $errMsg .= $helper->__ ( 'Request could not be built.' );
444
+ } catch ( Dhl_MeinPaket_Model_Client_BadHttpReturnCodeException $e ) {
445
+ Mage::logException ( $e );
446
+ $errMsg .= sprintf ( $helper->__ ( 'MeinPaket.de server returned HTPP code %s.' ), $e->getHttpReturnCode () );
447
+ } catch ( Dhl_MeinPaket_Model_Client_HttpTimeoutException $e ) {
448
+ Mage::logException ( $e );
449
+ $errMsg .= $helper->__ ( 'Connection to MeinPaket.de server timed out.' );
450
+ } catch ( Dhl_MeinPaket_Model_Xml_InvalidXmlException $e ) {
451
+ Mage::logException ( $e );
452
+ $errMsg .= $helper->__ ( 'Invalid response from MeinPaket.de server.' );
453
+ } catch ( Exception $e ) {
454
+ Mage::logException ( $e );
455
+ $errMsg .= $helper->__ ( 'Unknown error.' );
456
+ }
457
+
458
+ if ($result == null) {
459
+ $errMsg .= $helper->__ ( 'Refund has not been accepted by MeinPaket.de.' );
460
+ }
461
+
462
+ if (strlen ( $errMsg ) > 0) {
463
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $helper->__ ( 'Error on transfering refund to MeinPaket.de.' ) . ' (' . $errMsg . ')' );
464
+ throw new Exception ( 'Failed exporting refund to MeinPaket.de server.' );
465
+ }
466
+
467
+ return $this;
468
+ }
469
+
470
+ /**
471
+ * Is called when a shipment track is saved.
472
+ * The tracking code will be sent to MeinPaket.de if it's the first track
473
+ * for the shipment.
474
+ *
475
+ * @param Varien_Event_Observer $observer
476
+ * @return Dhl_MeinPaket_Model_Observer
477
+ */
478
+ public function salesOrderShipmentTrackSaveAfter(Varien_Event_Observer $observer) {
479
+ /* @var $track Mage_Sales_Model_Order_Shipment_Track */
480
+ $track = $observer->getData ( 'track' );
481
+
482
+ if ($track == null) {
483
+ return this;
484
+ }
485
+
486
+ /* @var $shipment Mage_Sales_Model_Order_Shipment */
487
+ $shipment = $track->getShipment ();
488
+
489
+ /* @var $order Mage_Sales_Model_Order */
490
+ $order = $shipment->getOrder ();
491
+
492
+ // check if order is a MeinPaket.de order...
493
+ if (! Mage::helper ( 'meinpaket/order' )->isMeinPaketOrder ( $order )) {
494
+ return $this;
495
+ }
496
+
497
+ $helper = Mage::helper ( 'meinpaket' );
498
+ $result = null;
499
+ $errMsg = '';
500
+
501
+ /* @var $service Dhl_MeinPaket_Model_Service_Order_ShipmentExportService */
502
+ $service = Mage::getModel ( 'meinpaket/service_order_shipmentExportService' );
503
+
504
+ try {
505
+ $result = $service->exportTrackingNumber ( $track );
506
+ } catch ( Dhl_MeinPaket_Model_Xml_XmlBuildException $e ) {
507
+ Mage::logException ( $e );
508
+ $errMsg .= $helper->__ ( 'Request could not be built.' );
509
+ } catch ( Dhl_MeinPaket_Model_Client_BadHttpReturnCodeException $e ) {
510
+ Mage::logException ( $e );
511
+ $errMsg .= sprintf ( $helper->__ ( 'MeinPaket.de server returned HTPP code %s.' ), $e->getHttpReturnCode () );
512
+ } catch ( Dhl_MeinPaket_Model_Client_HttpTimeoutException $e ) {
513
+ Mage::logException ( $e );
514
+ $errMsg .= $helper->__ ( 'Connection to MeinPaket.de server timed out.' );
515
+ } catch ( Dhl_MeinPaket_Model_Xml_InvalidXmlException $e ) {
516
+ Mage::logException ( $e );
517
+ $errMsg .= $helper->__ ( 'Invalid response from MeinPaket.de server.' );
518
+ } catch ( Exception $e ) {
519
+ Mage::logException ( $e );
520
+ $errMsg .= $helper->__ ( 'Unknown error.' );
521
+ }
522
+
523
+ if ($result !== null && ! $result->hasBeenAccepted ()) {
524
+ $errMsg .= $helper->__ ( 'Tracking code has not been accepted by MeinPaket.de.' );
525
+ if ($result->hasError ()) {
526
+ $errMsg .= ' (' . sprintf ( $helper->__ ( 'MeinPaket.de returned error code %s.' ), $result->getError () ) . ')';
527
+ }
528
+ }
529
+
530
+ if (strlen ( $errMsg ) > 0) {
531
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $helper->__ ( 'Error on transfering tracking code to MeinPaket.de.' ) . ' (' . $errMsg . ')' );
532
+ throw new Exception ( 'Failed exporting tracking code to MeinPaket.de server.' );
533
+ }
534
+
535
+ return $this;
536
+ }
537
+
538
+ /**
539
+ * Is triggered after a product has been deleted.
540
+ * If the product has been exported to MeinPake.de once before, the
541
+ * product's status will be set to disabled, and then be saved to
542
+ * trigger the catalog_product_save_after event again.
543
+ *
544
+ * @see Dhl_MeinPaket_Model_Observer::catalogProductSaveAfter()
545
+ * @param Varien_Event_Observer $observer
546
+ * @return Dhl_MeinPaket_Model_Observer
547
+ */
548
+ public function catalogProductDeleteBefore(Varien_Event_Observer $observer) {
549
+ try {
550
+ $product = Mage::getModel ( 'catalog/product' )->load ( $observer->getData ( 'product' )->getId () );
551
+ if ($product->hasData ( 'was_exported_for_dhl_mein_paket' ) && (( boolean ) $product->getData ( 'product_was_exported_for_dhl' )) === true) {
552
+ $product->setStatus ( Mage_Catalog_Model_Product_Status::STATUS_DISABLED )->save ();
553
+ }
554
+
555
+ $catalogService = Mage::getSingleton ( 'meinpaket/service_catalog' ); // TODO:
556
+ $catalogService->deleteProduct ( $product );
557
+ $catalogService->deleteProductAsVariation ( $product );
558
+ } catch ( Exception $ex ) {
559
+ Mage::logException ( $ex );
560
+ }
561
+
562
+ return $this;
563
+ }
564
+
565
+ /**
566
+ * Triggered before product is saved.
567
+ *
568
+ * @param Varien_Event_Observer $observer
569
+ * @return Dhl_MeinPaket_Model_Observer
570
+ */
571
+ public function catalogProductSaveBefore(Varien_Event_Observer $observer) {
572
+ /**
573
+ *
574
+ * @var $product Mage_Catalog_Model_Product
575
+ */
576
+ $product = $observer->getEvent ()->getProduct ();
577
+
578
+ if (! $product->getId ()) {
579
+ /*
580
+ * Delete meinpaket data for new and as such not synchronized objects. It's assumed that meinpaket_export is either set by the user or productDuplicate in this class. This is for example needed for quick created variants.
581
+ */
582
+ $product->setData ( 'meinpaket_id', '' );
583
+ }
584
+
585
+ if ($product->hasDataChanges ()) {
586
+ try {
587
+ $changes = array ();
588
+ foreach ( $product->getData () as $attribute => $newValue ) {
589
+ // Find changed products
590
+ $oldValue = $product->getOrigData ( $attribute );
591
+
592
+ if (is_array ( $newValue ) && is_array ( $oldValue )) {
593
+ // Ignored
594
+ } else if ($newValue != $oldValue) {
595
+ $changes [] = $attribute;
596
+ }
597
+ }
598
+
599
+ if (count ( $changes )) {
600
+ // Flag schedule in backlog.
601
+ $product->setData ( 'meinpaket_backlog_changes', $changes );
602
+ }
603
+ } catch ( Exception $e ) {
604
+ Mage::logException ( $e );
605
+ }
606
+ }
607
+ return $this;
608
+ }
609
+
610
+ /**
611
+ * Triggered after product is saved.
612
+ *
613
+ * @param Varien_Event_Observer $observer
614
+ * @return Dhl_MeinPaket_Model_Observer
615
+ */
616
+ public function catalogProductSaveAfter(Varien_Event_Observer $observer) {
617
+ try {
618
+ $product = $observer->getEvent ()->getProduct ();
619
+
620
+ if (is_array ( $product->getData ( 'meinpaket_backlog_changes' ) )) {
621
+ // Schedule the product for later
622
+ $changes = $product->getData ( 'meinpaket_backlog_changes' );
623
+ if (count ( $changes ) && $product->getId ()) {
624
+ $typeInstance = $product->getTypeInstance ();
625
+ if ($typeInstance instanceof Mage_Catalog_Model_Product_Type_Configurable) {
626
+ Mage::helper ( 'meinpaket/backlog' )->createChildrenBacklog ( $product->getId () );
627
+ } else {
628
+ Mage::helper ( 'meinpaket/backlog' )->createBacklog ( $product->getId (), implode ( ',', $changes ) );
629
+ }
630
+ }
631
+ }
632
+ } catch ( Exception $ex ) {
633
+ Mage::logException ( $ex );
634
+ }
635
+
636
+ return $this;
637
+ }
638
+
639
+ /**
640
+ * Triggered before product massaction.
641
+ *
642
+ * @param Varien_Event_Observer $observer
643
+ * @return Dhl_MeinPaket_Model_Observer
644
+ */
645
+ public function catalogProductAttributeUpdateBefore(Varien_Event_Observer $observer) {
646
+ $attributesData = $observer->getEvent ()->getAttributesData ();
647
+ $productIds = $observer->getEvent ()->getProductIds ();
648
+
649
+ $changes = implode ( ',', array_keys ( $attributesData ) );
650
+
651
+ foreach ( $productIds as $id ) {
652
+ $count = Mage::helper ( 'meinpaket/backlog' )->createChildrenBacklog ( $id );
653
+ if ($count <= 0) {
654
+ Mage::helper ( 'meinpaket/backlog' )->createBacklog ( $id, $changes );
655
+ }
656
+ }
657
+ return $this;
658
+ }
659
+ public function salesOrderGridCollectionLoadBefore($observer) {
660
+ $collection = $observer->getOrderGridCollection ();
661
+ // Don't enable this if select contains *. If an attribute is added all others are removed.
662
+ // $collection->addAttributeToSelect ( 'dhl_mein_paket_order_id' );
663
+ return $this;
664
+ }
665
+ public function gridAddAttributes(Varien_Event_Observer $observer) {
666
+ $block = $observer->getBlock ();
667
+ if (! isset ( $block )) {
668
+ return $this;
669
+ }
670
+
671
+ if ($block->getType () == 'adminhtml/sales_order_grid') {
672
+ /* @var $block Mage_Adminhtml_Block_Sales_Order_Grid */
673
+
674
+ $block->addColumnAfter ( 'dhl_mein_paket_order_id', array (
675
+ 'header' => __ ( 'MeinPaket.de Order No.' ),
676
+ 'index' => 'dhl_mein_paket_order_id'
677
+ ), 'real_order_id' );
678
+ }
679
+ return $this;
680
+ }
681
+ public function addMeinPaketAttributes($observer) {
682
+ $fieldset = $observer->getForm ()->getElement ( 'base_fieldset' );
683
+ $attribute = $observer->getAttribute ();
684
+ $fieldset->addField ( 'meinpaket_attribute', 'select', array (
685
+ 'name' => 'meinpaket_attribute',
686
+ 'label' => Mage::helper ( 'meinpaket' )->__ ( 'MeinPaket Attribute' ),
687
+ 'title' => Mage::helper ( 'meinpaket' )->__ ( 'MeinPaket Attribute' ),
688
+ 'values' => Mage::getModel ( 'meinpaket/system_config_source_attributes' )->toOptionArray ()
689
+ ) );
690
+ }
691
+ }
app/code/community/Dhl/MeinPaket/Model/Payment/Method/Meinpaket.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * MeinPaket payment method for imported orders.
5
+ *
6
+ * @category Mage
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Payment_Method
9
+ */
10
+ class Dhl_MeinPaket_Model_Payment_Method_Meinpaket extends Mage_Payment_Model_Method_Abstract {
11
+ /**
12
+ *
13
+ * @var string
14
+ */
15
+ protected $_code = 'meinpaket';
16
+
17
+ /**
18
+ *
19
+ * @var boolean
20
+ */
21
+ protected $_canUseCheckout = false;
22
+ }
app/code/community/Dhl/MeinPaket/Model/Resource/Eav/Mysql4/Setup.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup {
3
+ /**
4
+ *
5
+ * @return array
6
+ */
7
+ public function getDefaultEntities() {
8
+ return array (
9
+ 'catalog_product' => array (
10
+ 'entity_model' => 'catalog/product',
11
+ 'attribute_model' => 'catalog/resource_eav_attribute',
12
+ 'table' => 'catalog/product',
13
+ 'additional_attribute_table' => 'catalog/eav_attribute',
14
+ 'entity_attribute_collection' => 'catalog/product_attribute_collection',
15
+ 'attributes' => array (
16
+ 'meinpaket_id' => array (
17
+ 'type' => 'int',
18
+ 'label' => 'Product DHL MeinPaket Id',
19
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
20
+ 'visible' => false,
21
+ 'is_visible' => false,
22
+ 'required' => false,
23
+ 'user_defined' => false,
24
+ 'searchable' => false,
25
+ 'filterable' => false,
26
+ 'comparable' => false,
27
+ 'visible_on_front' => false,
28
+ 'visible_in_advanced_search' => false,
29
+ 'unique' => false,
30
+ 'is_configurable' => false
31
+ ),
32
+ 'sync_with_dhl_mein_paket' => array (
33
+ 'type' => 'int',
34
+ 'label' => 'Sync with MeinPaket.de',
35
+ 'frontend' => 'meinpaket/entity_attribute_frontend_labelTranslation',
36
+ 'input' => 'select',
37
+ 'source' => 'meinpaket/entity_attribute_source_productSyncMode',
38
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
39
+ 'visible' => false,
40
+ 'required' => false,
41
+ 'user_defined' => false,
42
+ 'searchable' => false,
43
+ 'filterable' => false,
44
+ 'comparable' => false,
45
+ 'visible_on_front' => false,
46
+ 'visible_in_advanced_search' => false,
47
+ 'unique' => false
48
+ ),
49
+ 'max_stock_for_dhl_mein_paket' => array (
50
+ 'type' => 'int',
51
+ 'label' => 'Maximum stock qty. for MeinPaket.de',
52
+ 'frontend' => 'meinpaket/entity_attribute_frontend_labelTranslation',
53
+ 'input' => 'text',
54
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
55
+ 'visible' => false,
56
+ 'required' => false,
57
+ 'user_defined' => false,
58
+ 'searchable' => false,
59
+ 'filterable' => false,
60
+ 'comparable' => false,
61
+ 'visible_on_front' => false,
62
+ 'visible_in_advanced_search' => false,
63
+ 'unique' => false
64
+ ),
65
+ 'meinpaket_category' => array (
66
+ 'type' => 'text',
67
+ 'label' => 'DHL MeinPaket Categories',
68
+ 'input' => 'select',
69
+ 'source' => 'meinpaket/entity_attribute_source_meinPaketCategory',
70
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
71
+ 'visible' => false,
72
+ 'required' => false,
73
+ 'user_defined' => false,
74
+ 'searchable' => false,
75
+ 'filterable' => false,
76
+ 'comparable' => false,
77
+ 'visible_on_front' => false,
78
+ 'visible_in_advanced_search' => false,
79
+ 'unique' => false
80
+ )
81
+ )
82
+ ),
83
+ 'order' => array (
84
+ 'entity_model' => 'sales/order',
85
+ 'table' => 'sales/order',
86
+ 'increment_model' => 'eav/entity_increment_numeric',
87
+ 'increment_per_store' => true,
88
+ 'backend_prefix' => 'sales_entity/order_attribute_backend',
89
+ 'attributes' => array (
90
+ 'meinpaket_id' => array (
91
+ 'type' => 'int',
92
+ 'label' => 'Order MeinPaket Id',
93
+ 'required' => false,
94
+ 'is_visible' => false,
95
+ 'visible' => false
96
+ )
97
+ )
98
+ ) ,
99
+ 'customer' => array (
100
+ 'entity_model' => 'customer/customer',
101
+ 'attribute_model' => 'customer/attribute',
102
+ 'table' => 'customer/entity',
103
+ 'increment_model' => 'eav/entity_increment_numeric',
104
+ 'additional_attribute_table' => 'customer/eav_attribute',
105
+ 'entity_attribute_collection' => 'customer/attribute_collection',
106
+ 'attributes' => array (
107
+ 'meinpaket_buyer_id' => array (
108
+ 'type' => 'int',
109
+ 'label' => 'VIA eBay Buyer Id',
110
+ 'input' => 'text',
111
+ 'required' => false,
112
+ 'sort_order' => 200,
113
+ 'visible' => false
114
+ ),
115
+ 'meinpaket_buyer_name' => array (
116
+ 'type' => 'varchar',
117
+ 'label' => 'VIA eBay Buyer Name',
118
+ 'input' => 'text',
119
+ 'required' => false,
120
+ 'sort_order' => 201,
121
+ 'visible' => false
122
+ )
123
+ )
124
+ )
125
+ );
126
+ }
127
+ }
app/code/community/Dhl/MeinPaket/Model/Service/Abstract.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Service_Abstract {
3
+ /**
4
+ * Process ID.
5
+ */
6
+ const DEFAULT_PROCESS_ID = 'meinpaket';
7
+
8
+ /**
9
+ * Used process id.
10
+ *
11
+ * @var unknown
12
+ */
13
+ protected $processID;
14
+
15
+ /**
16
+ *
17
+ * @var Mage_Core_Model_App_Emulation
18
+ */
19
+ protected $appEmulation;
20
+
21
+ /**
22
+ * Initial environment when starting emulation.
23
+ * Used to unset.
24
+ *
25
+ * @var array
26
+ */
27
+ protected $initialEnvironmentInfo;
28
+
29
+ /**
30
+ * Lock API.
31
+ *
32
+ * @var Mage_Index_Model_Process $indexProcess
33
+ */
34
+ protected $process;
35
+
36
+ /**
37
+ *
38
+ * @var unknown
39
+ */
40
+ protected $storeId;
41
+
42
+ /**
43
+ *
44
+ * @var unknown
45
+ */
46
+ protected $lockFile;
47
+
48
+ /**
49
+ *
50
+ * @var boolean
51
+ */
52
+ protected $isLocked = false;
53
+ function __construct($processID = null) {
54
+ $this->processID = $processID;
55
+ $this->storeId = Mage::helper ( 'meinpaket/data' )->getMeinPaketStoreId ();
56
+ $this->appEmulation = Mage::getSingleton ( 'core/app_emulation' );
57
+ }
58
+
59
+ /**
60
+ * Lock process.
61
+ *
62
+ * @throws ErrorException
63
+ */
64
+ function lock($storeId = null) {
65
+ if (flock ( $this->getLockFile (), LOCK_EX | LOCK_NB )) {
66
+ $this->isLocked = true;
67
+ } else {
68
+ throw new ErrorException ( 'MeinPaket already running' );
69
+ }
70
+ // Start environment emulation of the specified store
71
+ $this->initialEnvironmentInfo = $this->appEmulation->startEnvironmentEmulation ( $storeId == null ? $this->storeId : $storeId );
72
+ }
73
+
74
+ /**
75
+ * Unlock process.
76
+ */
77
+ function unlock() {
78
+ if ($this->isLocked) {
79
+ // Stop environment emulation and restore original store
80
+ $this->appEmulation->stopEnvironmentEmulation ( $this->initialEnvironmentInfo );
81
+ flock ( $this->getLockFile (), LOCK_UN );
82
+ $this->isLocked = false;
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Get lock file resource
88
+ *
89
+ * @return resource
90
+ */
91
+ protected function getLockFile() {
92
+ if ($this->processID == null) {
93
+ $id = self::DEFAULT_PROCESS_ID;
94
+ } else {
95
+ $id = $this->processID;
96
+ }
97
+
98
+ if ($this->lockFile === null) {
99
+ $varDir = Mage::getConfig ()->getVarDir ( 'locks' );
100
+ $file = $varDir . DS . 'sync_process_' . $id . '.lock';
101
+ if (is_file ( $file )) {
102
+ $this->lockFile = fopen ( $file, 'w' );
103
+ } else {
104
+ $this->lockFile = fopen ( $file, 'x' );
105
+ }
106
+ fwrite ( $this->lockFile, date ( 'r' ) );
107
+ }
108
+ return $this->lockFile;
109
+ }
110
+ }
app/code/community/Dhl/MeinPaket/Model/Service/Async.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Result class which encapsulates information concerning the shipment export process.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Service_ShipmentExport
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Service_Async extends Dhl_MeinPaket_Model_Service_Abstract {
13
+ /**
14
+ * Exports products.
15
+ *
16
+ * @param integer $selectionMode
17
+ * @return Dhl_MeinPaket_Model_Service_Product_Export_Result
18
+ */
19
+ public function process() {
20
+ $seenMagentoProducts = array ();
21
+
22
+ /* @var $client Dhl_MeinPaket_Model_Client_XmlOverHttp */
23
+ $client = Mage::getModel ( 'meinpaket/client_xmlOverHttp' );
24
+
25
+ /* var $logCollection Dhl_MeinPaket_Model_Mysql4_Log_Collection */
26
+ $asyncCollection = Mage::getModel ( 'meinpaket/async' )->getCollection ();
27
+
28
+ $count = 0;
29
+
30
+ foreach ( $asyncCollection as $async ) {
31
+ /* @var $uploadRequest Dhl_MeinPaket_Model_Xml_Request_AsynchronousStatusRequest */
32
+ $statusRequest = Mage::getModel ( 'meinpaket/xml_request_asynchronousStatusRequest' );
33
+ $statusRequest->addRequestStatus ( $async->getRequestId () );
34
+ $response = $client->send ( $statusRequest );
35
+
36
+ if ($response instanceof Dhl_MeinPaket_Model_Xml_Response_AsynchronousStatusResponse) {
37
+ /* @var $response Dhl_MeinPaket_Model_Xml_Response_AsynchronousStatusResponse */
38
+ $async->setRequestId ( $response->getRequestId () );
39
+ $async->setStatus ( $response->getStatus () );
40
+ $async->setUpdatedAt ( Varien_Date::now () );
41
+ $async->save ();
42
+ } else {
43
+ $async->delete ();
44
+ }
45
+
46
+ $count ++;
47
+ }
48
+
49
+ return Mage::helper ( 'meinpaket/data' )->__ ( "Processed %d async jobs", $count );
50
+ }
51
+ }
52
+
app/code/community/Dhl/MeinPaket/Model/Service/MarketplaceCategoryImport/ImportService.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Service class which imports the whole MeinPaket marketplace structure
5
+ * as categories into Magento.
6
+ *
7
+ * @category Dhl
8
+ * @package Dhl_MeinPaket
9
+ * @subpackage Model_Service_MarketplaceCategoryImport
10
+ * @version $Id$
11
+ * @author Daniel Pötzinger <daniel.poetzinger@aoemedia.de>
12
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
13
+ */
14
+ class Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_ImportService extends Varien_Object {
15
+ /**
16
+ *
17
+ * @var Mage_Catalog_Model_Category_Api
18
+ */
19
+ protected $categoryApi = null;
20
+
21
+ /**
22
+ *
23
+ * @var array
24
+ */
25
+ private $idMapping = array ();
26
+
27
+ /**
28
+ *
29
+ * @var Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result
30
+ */
31
+ protected $result = null;
32
+
33
+ /**
34
+ * Constructor.
35
+ *
36
+ * @return void
37
+ */
38
+ public function __construct() {
39
+ $this->result = Mage::getModel ( 'meinpaket/Service_MarketplaceCategoryImport_Result' );
40
+ }
41
+
42
+ /**
43
+ * Imports the marketplace category structure into the local marketplace root category.
44
+ *
45
+ * @return void
46
+ */
47
+ public function importMarketplaceCategoryStructure() {
48
+ /* @var $structure array */
49
+ $structure = null;
50
+
51
+ /* @var $rootCategory Mage_Catalog_Model_Category */
52
+ $rootCategory = Mage::getModel ( 'catalog/category' );
53
+
54
+ /* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
55
+ $collection = $rootCategory->getCollection ();
56
+
57
+ /* @var $memoryLimiter Dhl_MeinPaket_Model_System_MemoryLimiter */
58
+ $memoryLimiter = Mage::getModel ( 'meinpaket/System_MemoryLimiter' );
59
+
60
+ /* @var $requestXml string */
61
+ $requestXml = '';
62
+
63
+ /* @var $resultXml string */
64
+ $resultXml = '';
65
+
66
+ /* @var $structure array */
67
+ $structure = null;
68
+
69
+ /* @var $client Dhl_MeinPaket_Model_Client_XmlOverHttp */
70
+ $client = Mage::getModel ( 'meinpaket/client_xmlOverHttp' );
71
+
72
+ $memoryLimiter->setMemoryLimit ( Dhl_MeinPaket_Model_System_MemoryLimiter::MEMORY_LIMIT_VERY_HIGH );
73
+
74
+ /* @var $ids array */
75
+ $ids = array ();
76
+
77
+ $transaction = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_write' );
78
+
79
+ try {
80
+ $transaction->beginTransaction ();
81
+
82
+ /* @var $request Dhl_MeinPaket_Model_Xml_Request_DownloadRequest */
83
+ $request = Mage::getModel ( 'meinpaket/xml_request_downloadRequest' );
84
+ $request->addDownloadMarketplaceCategories ();
85
+
86
+ $dom = $client->send ( $request );
87
+
88
+ $ids = Mage::getResourceModel ( 'meinpaket/category_collection' )->getAllIds ();
89
+
90
+ $categories = array ();
91
+
92
+ /* @var $category Dhl_MeinPaket_Model_Xml_Response_Partial_Category */
93
+ foreach ( $dom->getCategories () as $category ) {
94
+ /* @var $model Dhl_MeinPaket_Model_Category */
95
+ $model = Mage::getModel ( 'meinpaket/category' )->load ( $category->getCode (), 'code' );
96
+
97
+ $model->setName ( trim ( $category->getName () ) );
98
+ $model->setCode ( trim ( $category->getCode () ) );
99
+ $model->setParent ( trim ( $category->getParent () ) );
100
+ $model->setLeaf ( true );
101
+
102
+ $categories [$model->getCode ()] = $model;
103
+
104
+ if ($model->getId ()) {
105
+ $ids = array_diff ( $ids, [
106
+ $model->getId ()
107
+ ] );
108
+ }
109
+ }
110
+
111
+ foreach ( $categories as $key => $value ) {
112
+ if (array_key_exists ( $value->getParent (), $categories )) {
113
+ $categories [$value->getParent ()]->setLeaf ( false );
114
+ }
115
+ }
116
+
117
+ foreach ( $categories as $key => $value ) {
118
+ if ($value->getData () != $value->getOrigData ()) {
119
+ $oldId = $value->getId ();
120
+ $value->save ();
121
+ if ($oldId) {
122
+ $this->result->addUpdatedCategory ( $value );
123
+ } else {
124
+ $this->result->addNewCategory ( $value );
125
+ }
126
+ }
127
+ }
128
+
129
+ foreach ( $ids as $id ) {
130
+ $model = Mage::getModel ( 'meinpaket/category' )->load ( $attr ['code'], 'code' );
131
+ if ($model->getId () != null) {
132
+ $this->result->addDeletedCategory ( $model );
133
+ $model->delete ();
134
+ }
135
+ }
136
+
137
+ $transaction->commit ();
138
+
139
+ Mage::getModel ( 'meinpaket/entity_attribute_source_meinPaketCategory' )->cleanCache ();
140
+ } catch ( Exception $e ) {
141
+ $transaction->rollback ();
142
+ Mage::logException ( $e );
143
+ throw $e;
144
+ }
145
+
146
+ return $this->result;
147
+ }
148
+ }
149
+
app/code/community/Dhl/MeinPaket/Model/Service/MarketplaceCategoryImport/Result.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Result class which keeps information about a category import process..
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Service_MarketplaceCategoryImport
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result extends Dhl_MeinPaket_Model_Service_Result_Abstract {
13
+ /**
14
+ *
15
+ * @var array
16
+ */
17
+ protected $newCategories = array ();
18
+
19
+ /**
20
+ *
21
+ * @var array
22
+ */
23
+ protected $deletedCategories = array ();
24
+
25
+ /**
26
+ *
27
+ * @var array
28
+ */
29
+ protected $updatedCategories = array ();
30
+
31
+ /**
32
+ * Adds a category which was not there before.
33
+ *
34
+ * @param integer $categoryId
35
+ * @return Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_ImportService
36
+ */
37
+ public function addNewCategory(Dhl_MeinPaket_Model_Category $category) {
38
+ $this->newCategories [] = $category;
39
+ return $this;
40
+ }
41
+
42
+ /**
43
+ * Adds a category which has been deleted because it is not existent in the
44
+ * MeinPaket marketplace anymore.
45
+ *
46
+ * @param string $name
47
+ * @return Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_ImportService
48
+ */
49
+ public function addDeletedCategory(Dhl_MeinPaket_Model_Category $category) {
50
+ $this->deletedCategories [] = $category;
51
+ return $this;
52
+ }
53
+
54
+ /**
55
+ * Adds a category which has been renamed.
56
+ *
57
+ * @param Dhl_MeinPaket_Model_Category $category
58
+ * @return Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_ImportService
59
+ */
60
+ public function addUpdatedCategory(Dhl_MeinPaket_Model_Category $category) {
61
+ $this->updatedCategories[] = $category;
62
+ return $this;
63
+ }
64
+
65
+ /**
66
+ * Returns the ids of the categories which have not been existent in Magento yet.
67
+ *
68
+ * @return array
69
+ */
70
+ public function getNewCategories() {
71
+ return $this->newCategories;
72
+ }
73
+
74
+ /**
75
+ * Returns the names of the categories which have been deleted
76
+ * because they were existent in Magento but don't exist
77
+ * in MeinPaket's marketplace category structure anymore.
78
+ *
79
+ * @return array
80
+ */
81
+ public function getDeletedCategories() {
82
+ return $this->deletedCategories;
83
+ }
84
+
85
+ /**
86
+ * Returns an array of arrays which represent the categories which
87
+ * have been renamed.
88
+ *
89
+ * @return array array has the following structure:
90
+ * [
91
+ * [
92
+ * 'id', // entity id of the category
93
+ * 'oldName' // The former name of the category
94
+ * ],
95
+ * ...
96
+ * ]
97
+ */
98
+ public function getUpdatedCategories() {
99
+ return $this->updatedCategories;
100
+ }
101
+
102
+ /**
103
+ * Returns the number of categories that have been added.
104
+ *
105
+ * @return integer
106
+ */
107
+ public function getNewCategoriesCount() {
108
+ return sizeof ( $this->newCategories );
109
+ }
110
+
111
+ /**
112
+ * Returns the number of categories that have been deleted.
113
+ *
114
+ * @return integer
115
+ */
116
+ public function getDeletedCategoriesCount() {
117
+ return sizeof ( $this->deletedCategories );
118
+ }
119
+
120
+ /**
121
+ * Returns the number of categories that have been renamed.
122
+ *
123
+ * @return integer
124
+ */
125
+ public function getUpdatedCategoriesCount() {
126
+ return sizeof ( $this->updatedCategories );
127
+ }
128
+ }
129
+
app/code/community/Dhl/MeinPaket/Model/Service/Order/CancellationService.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Service class which cancels an order.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_OrderCancellation
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Service_Order_CancellationService extends Varien_Object {
13
+ /**
14
+ * Cancels the given MeinPaket order.
15
+ *
16
+ * @param Mage_Sales_Model_Order $order
17
+ * @throws Dhl_MeinPaket_Model_Xml_XmlBuildException
18
+ * @throws Dhl_MeinPaket_Model_Client_BadHttpReturnCodeException
19
+ * @throws Dhl_MeinPaket_Model_Client_HttpTimeoutException
20
+ * @throws Dhl_MeinPaket_Model_Xml_InvalidXmlException
21
+ * @return Dhl_MeinPaket_Model_OrderCancellation_Result
22
+ */
23
+ public function cancelOrder(Mage_Sales_Model_Order $order) {
24
+
25
+ /* @var $notificationRequest Dhl_MeinPaket_Model_Xml_Request_NotificationRequest */
26
+ $notificationRequest = Mage::getModel ( 'meinpaket/xml_request_notificationRequest' );
27
+
28
+ /* @var $client Dhl_MeinPaket_Model_Client_XmlOverHttp */
29
+ $httpClient = Mage::getModel ( 'meinpaket/client_xmlOverHttp' );
30
+
31
+ /* @var $result Dhl_MeinPaket_Model_Service_Order_CancellationService_Result */
32
+ $result = Mage::getModel ( 'meinpaket/service_order_cancellationService_result' );
33
+
34
+ try {
35
+ $notificationRequest->addCancellation ( $order );
36
+ $responseXml = $httpClient->send ( $notificationRequest );
37
+ } catch ( Exception $e ) {
38
+ Mage::logException ( $e );
39
+ throw $e;
40
+ }
41
+
42
+ return $result;
43
+ }
44
+
45
+ /**
46
+ * Cancels a set of items for MeinPaket order.
47
+ *
48
+ * @param Mage_Sales_Model_Order $order
49
+ * @param array $items
50
+ * of the array have to be associative arrays
51
+ * containing the keys "productId" and "qty" (Quantity to reduce).
52
+ * @throws Dhl_MeinPaket_Model_Xml_XmlBuildException
53
+ * @throws Dhl_MeinPaket_Model_Client_BadHttpReturnCodeException
54
+ * @throws Dhl_MeinPaket_Model_Client_HttpTimeoutException
55
+ * @throws Dhl_MeinPaket_Model_Xml_InvalidXmlException
56
+ * @return Dhl_MeinPaket_Model_OrderCancellation_Result
57
+ */
58
+ public function cancelOrderItems(Mage_Sales_Model_Order $order, array $items) {
59
+ /* @var $xmlRequestFactory Dhl_MeinPaket_Model_Xml_XmlRequestFactory */
60
+ $xmlRequestFactory = Mage::getModel ( 'meinpaket/Xml_XmlRequestFactory' );
61
+
62
+ /* @var $xmlResponseParser Dhl_MeinPaket_Model_Xml_XmlResponseParser */
63
+ $xmlResponseParser = Mage::getModel ( 'meinpaket/Xml_XmlResponseParser' );
64
+
65
+ /* @var $httpClient Dhl_MeinPaket_Model_Client_XmlOverHttp */
66
+ $httpClient = Mage::getModel ( 'meinpaket/Client_XmlOverHttp' );
67
+
68
+ /* @var $result Dhl_MeinPaket_Model_Service_Order_CancellationService_Result */
69
+ $result = Mage::getModel ( 'meinpaket/service_order_cancellationService_result' );
70
+
71
+ $requestXml = '';
72
+ $responseXml = '';
73
+
74
+ try {
75
+ // TODO: see Observer line 220
76
+ $response = $httpClient->send ( $xmlRequestFactory->createPartialOrderCancellationRequest ( $order, $items ) );
77
+ $xmlResponseParser->parseOrderCancellationResultFromXml ( $responseXml, $result );
78
+ } catch ( Exception $e ) {
79
+ Mage::logException ( $e );
80
+ throw $e;
81
+ }
82
+
83
+ return $result;
84
+ }
85
+ }
app/code/community/Dhl/MeinPaket/Model/Service/Order/CancellationService/Result.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Encapsulates information about the results of a order cancellation process.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_OrderCancellation
9
+ * @version $Id$
10
+ */
11
+ class Dhl_MeinPaket_Model_Service_Order_CancellationService_Result extends Dhl_MeinPaket_Model_Service_Result_Abstract {
12
+ /**
13
+ *
14
+ * @var string
15
+ */
16
+ const ERROR_XML_REQUEST_BUILDING_FAILED = 'xmlRequestBuildingFailed';
17
+
18
+ /**
19
+ *
20
+ * @var string
21
+ */
22
+ const ERROR_SENDING_REQUST_TO_MEIN_PAKET_SERVER_FAILED = 'sendingRequestFailed';
23
+
24
+ /**
25
+ *
26
+ * @var string
27
+ */
28
+ const ERROR_INVALID_XML_RESPONSE_RECEIVED = 'invalidXmlResponse';
29
+
30
+ /**
31
+ *
32
+ * @var string
33
+ */
34
+ protected $errorCode = '';
35
+
36
+ /**
37
+ *
38
+ * @var array
39
+ */
40
+ protected $consignmentIds = array ();
41
+
42
+ /**
43
+ * Sets the error that occured.
44
+ *
45
+ *
46
+ * @param string $errorCode
47
+ * has to be the errorCode
48
+ * that was returned from the MeinPaket.de
49
+ * webservice.
50
+ * @return void
51
+ */
52
+ public function setError($errorCode) {
53
+ $this->errorCode = $errorCode;
54
+ }
55
+
56
+ /**
57
+ * Tells if an error occured during the process.
58
+ *
59
+ * @return boolean
60
+ */
61
+ public function hasError() {
62
+ return (strlen ( $this->errorCode ) > 0);
63
+ }
64
+
65
+ /**
66
+ * Returns the errorCode of the error that has occured.
67
+ * If there was no error, the method will return an empty string.
68
+ *
69
+ * @return string
70
+ */
71
+ public function getError() {
72
+ return $this->errorCode;
73
+ }
74
+
75
+ /**
76
+ * Adds a consignment id for a cancelled product.
77
+ *
78
+ * @param string $consignmentId
79
+ * @return void
80
+ */
81
+ public function addConsignmentId($consignmentId) {
82
+ $this->consignmentIds [] = $consignmentId;
83
+ }
84
+
85
+ /**
86
+ * Returns all consignment ids that have been returned by MeinPaket.de.
87
+ *
88
+ * @return array
89
+ */
90
+ public function getConsignmentIds() {
91
+ return $this->consignmentIds;
92
+ }
93
+ }
app/code/community/Dhl/MeinPaket/Model/Service/Order/ImportService.php ADDED
@@ -0,0 +1,440 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Service class which imports orders from MeinPaket.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Order
9
+ * @version $Id$
10
+ * @author Andreas Demmer <andreas.demmer@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Service_Order_ImportService extends Varien_Object {
13
+ /**
14
+ * counts of imported and duplicate orders
15
+ *
16
+ * @var $_orders array
17
+ */
18
+ var $_orderCount;
19
+
20
+ /**
21
+ * DHL IDs from orders which are out of stock
22
+ *
23
+ * @var $_outOfStockOrders array
24
+ */
25
+ var $_outOfStockOrders;
26
+
27
+ /**
28
+ * Dhl order ids which include disabled products.
29
+ *
30
+ * @var array
31
+ */
32
+ protected $_disabledProductOrders;
33
+
34
+ /**
35
+ *
36
+ * @var string
37
+ */
38
+ const IMPORT_SHIPPING_METHOD = 'meinpaket_method1';
39
+
40
+ /**
41
+ *
42
+ * @var string
43
+ */
44
+ const IMPORT_PAYMENT_METHOD = 'meinpaket';
45
+
46
+ /**
47
+ *
48
+ * @var duplicate orders, returncode
49
+ */
50
+ const DUPLICATE_ORDER_STATUS = 2;
51
+
52
+ /**
53
+ *
54
+ * @var imported orders, returncode
55
+ */
56
+ const IMPORTED_ORDER_STATUS = 1;
57
+
58
+ /**
59
+ *
60
+ * @var out-of-stock orders, returncode
61
+ */
62
+ const OUT_OF_STOCK_ORDER_STATUS = 3;
63
+
64
+ /**
65
+ * Status for a disabled product.
66
+ *
67
+ * @var integer
68
+ */
69
+ const DISABLED_ORDER_STATUS = 4;
70
+ const USE_GUEST_ACCOUNT_CONFIG = 'meinpaket/order/use_guest_account';
71
+ const CUSTOMER_GROUP_CONFIG = 'meinpaket/order/customer_group';
72
+
73
+ /**
74
+ *
75
+ * @var boolean
76
+ */
77
+ protected $serviceResponseWasMalformed = false;
78
+
79
+ /**
80
+ * Constructor.
81
+ *
82
+ * @return void
83
+ */
84
+ public function __construct() {
85
+ $this->_orderCount = array (
86
+ 'imported' => 0,
87
+ 'duplicates' => 0,
88
+ 'outOfStock' => 0,
89
+ 'disabled' => 0
90
+ );
91
+
92
+ $_outOfStockOrders = array ();
93
+ $this->_disabledProductOrders = array ();
94
+
95
+ parent::__construct ();
96
+ }
97
+
98
+ /**
99
+ * Tells if the MeinPaket response for the impoer orders request was
100
+ * malformed and could not be parsed.
101
+ *
102
+ * @return boolean
103
+ */
104
+ public function wasServiceResponseMalformed() {
105
+ return $this->serviceResponseWasMalformed;
106
+ }
107
+
108
+ /**
109
+ * returns count of imported and duplicate orders
110
+ *
111
+ * @return array
112
+ */
113
+ public function getOrderCount() {
114
+ return $this->_orderCount;
115
+ }
116
+
117
+ /**
118
+ * returns DHL IDs of orders which are out of stock
119
+ *
120
+ * @return array
121
+ */
122
+ public function getOutOfStockOrders() {
123
+ return $this->_outOfStockOrders;
124
+ }
125
+
126
+ /**
127
+ * Returns the order ids which could not be imported, because they contained
128
+ * disabled products.
129
+ *
130
+ * @return array
131
+ */
132
+ public function getDisabledProductOrders() {
133
+ return $this->_disabledProductOrders;
134
+ }
135
+
136
+ /**
137
+ * Imports Order from meinPaket
138
+ * //TODO make a simple result object containing: countnew / countexisting / warnings (e.g.
139
+ * if price missmatch)
140
+ *
141
+ * @param integer $start
142
+ * @param integer $stop
143
+ * @return void
144
+ */
145
+ public function importOrders($start = null, $stop = null) {
146
+ /* @var $xmlRequestFactory Dhl_MeinPaket_Model_Xml_XmlRequestFactory */
147
+ $xmlRequestFactory = Mage::getSingleton ( 'meinpaket/xml_xmlRequestFactory' );
148
+
149
+ /* @var $client Dhl_MeinPaket_Model_Client_XmlOverHttp */
150
+ $client = Mage::getModel ( 'meinpaket/client_xmlOverHttp' );
151
+
152
+ /* @var $queryRequest Dhl_MeinPaket_Model_Xml_Request_QueryRequest */
153
+ $queryRequest = Mage::getModel ( 'meinpaket/xml_request_queryRequest' );
154
+ // $queryRequest->addOrders ( $start, $stop );
155
+ $queryRequest->addOrders ( $start, $stop, 'Open' );
156
+
157
+ /* @var $queryResult Dhl_MeinPaket_Model_Xml_Response_QueryResponse */
158
+ $queryResult = $client->send ( $queryRequest );
159
+
160
+ foreach ( $queryResult->getOrders () as $order ) {
161
+ /* @var $order Dhl_MeinPaket_Model_Xml_Response_Partial_Order */
162
+ $successCode = $this->_importOrder ( $order );
163
+ switch ($successCode) {
164
+ case self::IMPORTED_ORDER_STATUS :
165
+ $this->_orderCount ['imported'] ++;
166
+ break;
167
+ case self::DUPLICATE_ORDER_STATUS :
168
+ $this->_orderCount ['duplicates'] ++;
169
+ break;
170
+ case self::OUT_OF_STOCK_ORDER_STATUS :
171
+ $this->_orderCount ['outOfStock'] ++;
172
+ break;
173
+ case self::DISABLED_ORDER_STATUS :
174
+ $this->_orderCount ['disabled'] ++;
175
+ break;
176
+ }
177
+ }
178
+
179
+ return $this->_orderCount;
180
+ }
181
+
182
+ /**
183
+ * imports orders from XML, returns success code
184
+ *
185
+ * @param SimpleXMLElement $order
186
+ * @return int
187
+ */
188
+ protected function _importOrder(Dhl_MeinPaket_Model_Xml_Response_Partial_Order $order) {
189
+ $storeId = Mage::helper ( 'meinpaket/data' )->getMeinPaketStoreId ();
190
+ $store = Mage::helper ( 'meinpaket/data' )->getMeinPaketStore ();
191
+
192
+ /* @var $orderObj Mage_Sales_Model_Order */
193
+ $orderObj = Mage::getModel ( 'sales/order' )->load ( $order->getOrderId (), 'dhl_mein_paket_order_id' );
194
+
195
+ // do not import order already existing orders
196
+ if ($orderObj->getId ()) {
197
+ return self::DUPLICATE_ORDER_STATUS;
198
+ }
199
+
200
+ $customer = $this->getOrCreateCustomer ( $order );
201
+
202
+ if (! Mage::getStoreConfig ( self::USE_GUEST_ACCOUNT_CONFIG )) {
203
+ $customer->save ();
204
+ }
205
+
206
+ // Set email for guest order
207
+ /* @var $quoteObj Mage_Sales_Model_Quote */
208
+ $quoteObj = Mage::getModel ( 'sales/quote' );
209
+ $quoteObj->setStoreId ( $storeId );
210
+ $quoteObj->setCustomerNote ( __ ( 'Imported from DHL MeinPaket.de' ) . ' (' . __ ( 'Delivery Method' ) . ':' . (( string ) $order->getDeliveryMethod ()) . ')' );
211
+ $quoteObj->setCustomerFirstname ( $customer->getFirstname () );
212
+ $quoteObj->setCustomerLastname ( $customer->getLastname () );
213
+ $quoteObj->setCustomerIsGuest ( Mage::getStoreConfig ( self::USE_GUEST_ACCOUNT_CONFIG ) );
214
+ $quoteObj->setCustomerEmail ( $customer->getEmail () );
215
+ $quoteObj->setCustomer ( $customer );
216
+
217
+ $hasNoConfigurables = true;
218
+ $quoteItems = array ();
219
+
220
+ foreach ( $order->getEntries () as $orderEntry ) {
221
+ /* var $orderEntry Dhl_MeinPaket_Model_Xml_Response_Partial_Order_Entry */
222
+ $productId = ( string ) $orderEntry->getProductId ();
223
+
224
+ if ($hasNoConfigurables) {
225
+
226
+ try {
227
+ /* @var $productObj Mage_Catalog_Model_Product */
228
+ $productObj = Mage::getModel ( 'catalog/product' )->setStoreId ( $storeId )->load ( $productId );
229
+
230
+ if ($productObj->isConfigurable ()) {
231
+ $hasNoConfigurables = false;
232
+ break;
233
+ }
234
+
235
+ // check wether product is in stock
236
+ $stockItem = $productObj->getStockItem ();
237
+
238
+ $magentoPrice = number_format ( $productObj->getPrice (), 2 ) . " " . $store->getCurrentCurrencyCode ();
239
+ $meinPaketPrice = number_format ( ( string ) $orderEntry->getBasePrice (), 2 ) . " " . $store->getCurrentCurrencyCode ();
240
+
241
+ if ($productObj->getStatus () == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) {
242
+ $this->_disabledProductOrders [] = $order->getOrderId ();
243
+ return self::DISABLED_ORDER_STATUS;
244
+ } elseif (( bool ) $stockItem->getData ( 'is_in_stock' )) {
245
+ if ($magentoPrice != $meinPaketPrice) {
246
+ $message = sprintf ( __ ( '%s was ordered with a different price (%s instead of current price %s). Was the price changed after exporting to MeinPaket.de?' ), $productObj->getName (), $meinPaketPrice, $magentoPrice );
247
+ Mage::getSingleton ( 'adminhtml/session' )->addNotice ( $message );
248
+ }
249
+
250
+ $item = $quoteObj->addProduct ( $productObj, new Varien_Object ( $request = array (
251
+ 'qty' => ( string ) $orderEntry->getQuantity (),
252
+ 'dhl_mein_paket_item_id' => ( string ) $orderEntry->getMeinPaketId ()
253
+ ) ) );
254
+
255
+ $item->setRowTotal ( floatval ( $item->getRowTotal () ) + $orderEntry->getBasePrice () );
256
+ $item->setCustomPrice ( $orderEntry->getBasePrice () );
257
+ $item->setOriginalCustomPrice ( $orderEntry->getBasePrice () );
258
+ $item->setRowTotal ( $orderEntry->getTotalPrice () );
259
+
260
+ $item->getProduct ()->setIsSuperMode ( true );
261
+ } else {
262
+ $this->_outOfStockOrders [] = $order->getOrderId ();
263
+ return self::OUT_OF_STOCK_ORDER_STATUS;
264
+ }
265
+ } catch ( Exception $e ) {
266
+ Mage::logException ( $e );
267
+ throw new Exception ( 'Could not add product ' . $productId . ' - ' . $e->getMessage () );
268
+ }
269
+ }
270
+ }
271
+
272
+ if (! $hasNoConfigurables) {
273
+ $quoteObj->delete ();
274
+ return 0;
275
+ }
276
+
277
+ if (sizeof ( $quoteItems ) > 0) {
278
+ foreach ( $quoteItems as $quoteItem ) {
279
+ }
280
+ }
281
+
282
+ $billingAddress = $quoteObj->getBillingAddress ();
283
+ $billingAddress->addData ( $this->_getAddressData ( $order->getBillingAddress () ) );
284
+ $shippingAddress = $quoteObj->getShippingAddress ();
285
+ if ($order->getDeliveryAddress () != null) {
286
+ $shippingAddress->addData ( $this->_getAddressData ( $order->getDeliveryAddress () ) );
287
+ } else {
288
+ $shippingAddress->addData ( $this->_getAddressData ( $order->getBillingAddress () ) );
289
+ }
290
+
291
+ $paymentMethod = self::IMPORT_PAYMENT_METHOD;
292
+ $shippingAddress->setPaymentMethod ( $paymentMethod );
293
+ $quoteObj->getPayment ()->importData ( array (
294
+ 'method' => $paymentMethod
295
+ ) );
296
+
297
+ Dhl_MeinPaket_Model_Carrier_Meinpaket::unlock ();
298
+ Dhl_MeinPaket_Model_Carrier_Meinpaket::setDeliveryCosts ( $order->getTotalDeliveryCosts () );
299
+
300
+ $shippingAddress->setShippingMethod ( self::IMPORT_SHIPPING_METHOD )->unsGrandTotal ()->unsBaseGrandTotal ()->setCollectShippingRates ( true )->save ();
301
+ $shippingAddress->collectTotals ();
302
+
303
+ $quoteObj->collectTotals ();
304
+ $quoteObj->save ();
305
+
306
+ /* @var $quoteObj Mage_Sales_Model_Service_Quote */
307
+ $serviceQuote = Mage::getModel ( 'sales/service_quote', $quoteObj );
308
+ $serviceQuote->submitAll ();
309
+
310
+ /* @var $orderModel Mage_Sales_Model_Order */
311
+ $orderModel = $serviceQuote->getOrder ();
312
+ /**
313
+ * triggert aufruf von authorizes() auf dem payment model (ggf auch capture() )
314
+ */
315
+
316
+ $contactData = $order->getContactData ();
317
+
318
+ $orderModel->place ();
319
+ $orderModel->setState ( Mage_Sales_Model_Order::STATE_PROCESSING, true );
320
+ $orderModel->setData ( 'created_at', $this->_getFormattedDateString ( $order->getOrderDate () ) );
321
+ $orderModel->setData ( 'customer_email', strlen ( $contactData->getEmail () ) ? $contactData->getEmail () : Mage::getStoreConfig ( 'meinpaket/customer/default_email' ) );
322
+ $orderModel->setData ( 'ext_customer_id', $contactData->getCustomerId () );
323
+ $orderModel->setData ( 'dhl_mein_paket_order_id', $order->getOrderId () );
324
+ // Zend_Debug::dump($orderModel->getData());die;
325
+ $orderModel->save ();
326
+
327
+ Dhl_MeinPaket_Model_Carrier_Meinpaket::unlock ();
328
+
329
+ // dispatch event
330
+ Mage::dispatchEvent ( 'dhl_meinpaket_orderimport', array (
331
+ 'orderId' => $orderModel->getId ()
332
+ ) );
333
+
334
+ $this->createInvoice($orderModel);
335
+
336
+ return self::IMPORTED_ORDER_STATUS;
337
+ }
338
+
339
+ /**
340
+ * Extracts address data from the given element.
341
+ *
342
+ * @param SimpleXMLElement $addressElement
343
+ * @return array
344
+ */
345
+ protected function _getAddressData(Dhl_MeinPaket_Model_Xml_Response_Partial_Address $address) {
346
+ $addressArray = array (
347
+ 'salutation' => ( string ) $address->getSalutation (),
348
+ 'firstname' => ( string ) $address->getFirstName (),
349
+ 'lastname' => ( string ) $address->getLastName (),
350
+ // 'street' => ( string ) $address->getStreet (),
351
+ 'postcode' => ( string ) $address->getZipCode (),
352
+ 'city' => ( string ) $address->getCity (),
353
+ 'region_id' => '91', // TODO: make this optional - and add in documentation
354
+ 'country_id' => ( string ) $address->getCountry (),
355
+ 'telephone' => '0000'
356
+ );
357
+
358
+ if (strlen ( $address->getCustomerId () )) {
359
+ $addressArray ['street'] = ( string ) $address->getCustomerId () . "\n" . ( string ) $address->getStreet () . " " . ( string ) $address->getHouseNumber () . "\n" . ( string ) $address->getAddressAddition ();
360
+ } else {
361
+ $addressArray ['street'] = ( string ) $address->getStreet () . " " . ( string ) $address->getHouseNumber () . "\n" . ( string ) $address->getAddressAddition ();
362
+ }
363
+
364
+ if (strlen ( $address->getCompany () )) {
365
+ $addressArray ['company'] = ( string ) $address->getCompany ();
366
+ }
367
+
368
+ return $addressArray;
369
+ }
370
+
371
+ /**
372
+ * Converts the given ISO date string (i.e.
373
+ * "2010-10-27T15:59:59.012+02:00")
374
+ * into the mysql datetime format (i.e. "2010-10-27 15:59:59").
375
+ *
376
+ * @param string $isoDateString
377
+ * @wins Code of the year contest
378
+ * @return string
379
+ */
380
+ protected function _getFormattedDateString($isoDateString) {
381
+ $date = new Zend_Date ( $isoDateString, Zend_Date::ISO_8601 );
382
+ $mysqlDateString = $date->toString ( 'YYYY-MM-dd HH:mm:ss' );
383
+ return $mysqlDateString;
384
+ }
385
+
386
+ /**
387
+ * Get or create customer.
388
+ *
389
+ * @param array $viaOrder
390
+ * to check
391
+ * @return Mage_Customer_Model_Customer
392
+ */
393
+ protected function getOrCreateCustomer(Dhl_MeinPaket_Model_Xml_Response_Partial_Order $order) {
394
+ /* @var $customer Mage_Customer_Model_Customer */
395
+ $customer = Mage::getModel ( 'customer/customer' )->getCollection ()->addAttributeToSelect ( 'meinpaket_buyer_id' )->addAttributeToFilter ( 'meinpaket_buyer_id', $order->getContactData ()->getCustomerId () )->load ()->getFirstItem ();
396
+
397
+ if ($customer->getId () != null) {
398
+ return $customer;
399
+ }
400
+
401
+ // Set store and website for loadByEmail.
402
+ $customer->setStore ( Mage::helper ( 'meinpaket/data' )->getMeinPaketStore () );
403
+ // Could not find customer by meinpaket_buyer_id. As there can only be one customer for a given
404
+ // email try to load one.
405
+ $customer->loadByEmail ( $order->getContactData ()->getEmail () );
406
+
407
+ if ($customer->getId () != null) {
408
+ return $customer;
409
+ }
410
+
411
+ // New customer
412
+ // Set store and website again after loadByEmail reset it.
413
+ $customer->setStore ( Mage::helper ( 'meinpaket/data' )->getMeinPaketStore () );
414
+ $customer->setFirstname ( $order->getBillingAddress ()->getFirstName () );
415
+ $customer->setLastname ( $order->getBillingAddress ()->getLastName () );
416
+ $customer->setEmail ( $order->getContactData ()->getEmail () );
417
+
418
+ $groupId = Mage::getStoreConfig ( self::CUSTOMER_GROUP_CONFIG );
419
+ $customer->setData ( 'group_id', $groupId );
420
+
421
+ $customer->setData ( 'meinpaket_buyer_id', $order->getContactData ()->getCustomerId () );
422
+
423
+ if (! $customer->getId ()) {
424
+ // recurring customer
425
+ $customer->setPasswordHash ( $customer->generatePassword () );
426
+ }
427
+
428
+ return $customer;
429
+ }
430
+ protected function createInvoice(Mage_Sales_Model_Order $order) {
431
+ /* @var $invoiceModel Sales_Model_Order_Invoice */
432
+ $invoice = $order->prepareInvoice ();
433
+
434
+ $invoice->setRequestedCaptureCase ( Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE );
435
+ $invoice->register ();
436
+ $invoice->setIsInProcess ( true );
437
+
438
+ $transactionSave = Mage::getModel ( 'core/resource_transaction' )->addObject ( $invoice )->addObject ( $invoice->getOrder () )->save ();
439
+ }
440
+ }
app/code/community/Dhl/MeinPaket/Model/Service/Order/RefundExportService.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Service class which sends a refund to MeinPaket.de.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Service_RefundExport
9
+ * @version $Id$
10
+ */
11
+ class Dhl_MeinPaket_Model_Service_Order_RefundExportService {
12
+ /**
13
+ * Exports the given refunded creditmemo to MeinPaket.de.
14
+ *
15
+ * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
16
+ * @throws Dhl_MeinPaket_Model_Xml_XmlBuildException
17
+ * @throws Dhl_MeinPaket_Model_Client_BadHttpReturnCodeException
18
+ * @throws Dhl_MeinPaket_Model_Client_HttpTimeoutException
19
+ * @throws Dhl_MeinPaket_Model_Xml_InvalidXmlException
20
+ * @return Dhl_MeinPaket_Model_Sevice_RefundExport_Result
21
+ */
22
+ public function exportRefund(Mage_Sales_Model_Order_Creditmemo $creditmemo) {
23
+ /* @var $httpClient Dhl_MeinPaket_Model_Client_XmlOverHttp */
24
+ $httpClient = Mage::getModel ( 'meinpaket/client_xmlOverHttp' );
25
+
26
+ /* @var $notificationRequest Dhl_MeinPaket_Model_Xml_Request_NotificationRequest */
27
+ $notificationRequest = Mage::getModel ( 'meinpaket/xml_request_notificationRequest' );
28
+
29
+ $order = $creditmemo->getOrder ();
30
+ if ($order->hasShipments ()) {
31
+ foreach ( $order->getShipmentsCollection () as $shipment ) {
32
+ $notificationRequest->addCreditMemo ( $creditmemo, $shipment );
33
+ }
34
+ } else {
35
+ $notificationRequest->addCancellation ( $creditmemo->getOrder () );
36
+ }
37
+
38
+ try {
39
+ if ($notificationRequest->isHasData()) {
40
+ return $httpClient->send ( $notificationRequest );
41
+ }
42
+ } catch ( Exception $e ) {
43
+ Mage::logException ( $e );
44
+ throw $e;
45
+ }
46
+
47
+ return null;
48
+ }
49
+ }
50
+
app/code/community/Dhl/MeinPaket/Model/Service/Order/RefundExportService/Result.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Result class which encapsulates information concerning the refund export process.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Service_RefundExport
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Service_Order_RefundExportService_Result extends Dhl_MeinPaket_Model_Service_Result_Abstract {
13
+ /**
14
+ *
15
+ * @var string
16
+ */
17
+ protected $originalRefundId = '-1';
18
+
19
+ /**
20
+ *
21
+ * @var string
22
+ */
23
+ protected $returnedRefundId = '-2';
24
+
25
+ /**
26
+ *
27
+ * @param string $refundId
28
+ * @return void
29
+ */
30
+ public function setOriginalRefundId($refundId) {
31
+ if (! is_string ( $refundId )) {
32
+ $refundId = ( string ) $refundId;
33
+ }
34
+ $this->originalRefundId = $refundId;
35
+ }
36
+
37
+ /**
38
+ *
39
+ * @param string $refundId
40
+ * @return void
41
+ */
42
+ public function setReturnedRefundId($refundId) {
43
+ if (! is_string ( $refundId )) {
44
+ $refundId = ( string ) $refundId;
45
+ }
46
+ $this->returnedRefundId = $refundId;
47
+ }
48
+
49
+ /**
50
+ * Tells if the refund has been accepted by MeinPaket.de.
51
+ *
52
+ * @return boolean
53
+ */
54
+ public function hasBeenAccepted() {
55
+ return ($this->originalRefundId === $this->returnedRefundId);
56
+ }
57
+ }
58
+
app/code/community/Dhl/MeinPaket/Model/Service/Order/ShipmentExportService.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Service which exports an order's shipment to MeinPaket.de.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Service_ShipmentExport
9
+ * @version $Id$
10
+ */
11
+ class Dhl_MeinPaket_Model_Service_Order_ShipmentExportService {
12
+ /**
13
+ * Exports a shipment to MeinPaket.de.
14
+ *
15
+ * @param Mage_Sales_Model_Order_Shipment $shipment
16
+ * @throws Dhl_MeinPaket_Model_Xml_XmlBuildException
17
+ * @throws Dhl_MeinPaket_Model_Client_BadHttpReturnCodeException
18
+ * @throws Dhl_MeinPaket_Model_Client_HttpTimeoutException
19
+ * @throws Dhl_MeinPaket_Model_Xml_InvalidXmlException
20
+ * @return Dhl_MeinPaket_Model_Xml_Response_NotificationResponse
21
+ */
22
+ public function exportShipment(Mage_Sales_Model_Order_Shipment $shipment) {
23
+ /* @var $notificationRequest Dhl_MeinPaket_Model_Xml_Request_NotificationRequest */
24
+ $notificationRequest = Mage::getModel ( 'meinpaket/xml_request_notificationRequest' );
25
+
26
+ /* @var $client Dhl_MeinPaket_Model_Client_XmlOverHttp */
27
+ $client = Mage::getModel ( 'meinpaket/client_xmlOverHttp' );
28
+
29
+ $notificationRequest->addConsignment ( $shipment );
30
+
31
+ /* @var $responseXml Dhl_MeinPaket_Model_Xml_Response_NotificationResponse */
32
+ $responseXml = $client->send ( $notificationRequest );
33
+
34
+ return $responseXml;
35
+ }
36
+
37
+ /**
38
+ * Exports the tracking number of a shipment to MeinPaket.de.
39
+ *
40
+ * @param Mage_Sales_Model_Order_Shipment $shipment
41
+ * The shipment which tracking numbers shall be exported.
42
+ * @throws Dhl_MeinPaket_Model_Xml_XmlBuildException
43
+ * @throws Dhl_MeinPaket_Model_Client_BadHttpReturnCodeException
44
+ * @throws Dhl_MeinPaket_Model_Client_HttpTimeoutException
45
+ * @throws Dhl_MeinPaket_Model_Xml_InvalidXmlException
46
+ * @return Dhl_MeinPaket_Model_Service_TrackingNumberExport_Result
47
+ */
48
+ public function exportTrackingNumber(Mage_Sales_Model_Order_Shipment_Track $track) {
49
+
50
+ /* @var $notificationRequest Dhl_MeinPaket_Model_Xml_Request_NotificationRequest */
51
+ $notificationRequest = Mage::getModel ( 'meinpaket/xml_request_notificationRequest' );
52
+
53
+ /* @var $client Dhl_MeinPaket_Model_Client_XmlOverHttp */
54
+ $client = Mage::getModel ( 'meinpaket/client_xmlOverHttp' );
55
+
56
+ /* @var $result Dhl_MeinPaket_Model_Service_Product_Export_Result */
57
+ $result = Mage::getModel ( 'meinpaket/service_product_export_result' );
58
+
59
+ $notificationRequest->addTrackingNumber ( $track );
60
+
61
+ try {
62
+ $responseXml = $client->send ( $notificationRequest );
63
+ // TODO: parse
64
+ } catch ( Exception $e ) {
65
+ Mage::logException ( $e );
66
+ throw $e;
67
+ }
68
+
69
+ return null;
70
+ }
71
+ }
app/code/community/Dhl/MeinPaket/Model/Service/Order/ShipmentExportService/Result.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Result class which encapsulates information concerning the shipment export process.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Service_ShipmentExport
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Service_Order_ShipmentExportService_Result extends Dhl_MeinPaket_Model_Service_Result_Abstract {
13
+ /**
14
+ *
15
+ * @var string
16
+ */
17
+ protected $consignmentId = '';
18
+
19
+ /**
20
+ *
21
+ * @var string
22
+ */
23
+ protected $responseConsignmentId = '_';
24
+
25
+ /**
26
+ * Sets the consignment id of the shipment.
27
+ *
28
+ * @param string $consignmentId
29
+ * @return Dhl_MeinPaket_Model_Service_ShipmentExport_Result
30
+ */
31
+ public function setConsignmentId($consignmentId) {
32
+ $this->consignmentId = $consignmentId;
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * Sets the consignment id of the shipment which was returned from MeinPaket.de.
38
+ *
39
+ * @param string $consignmentId
40
+ * @return Dhl_MeinPaket_Model_Service_ShipmentExport_Result
41
+ */
42
+ public function setResponseConsignmentId($responseConsignmentId) {
43
+ $this->responseConsignmentId = $responseConsignmentId;
44
+ return $this;
45
+ }
46
+
47
+ /**
48
+ * Tells if the send consignment id has been returned by MeinPaket.de.
49
+ * If this is true, the consignment has been accepted.
50
+ *
51
+ * @return boolean
52
+ */
53
+ public function hasBeenAccepted() {
54
+ return ($this->consignmentId === $this->responseConsignmentId);
55
+ }
56
+ }
57
+
app/code/community/Dhl/MeinPaket/Model/Service/Product/Export.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Service class which encapsulates the product export process.
5
+ *
6
+ * @category Mage
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Service_Product
9
+ */
10
+ class Dhl_MeinPaket_Model_Service_Product_Export extends Dhl_MeinPaket_Model_Service_Abstract {
11
+
12
+ /**
13
+ *
14
+ * @var Dhl_MeinPaket_Helper_Product
15
+ */
16
+ protected $_productHelper = null;
17
+
18
+ /**
19
+ * Constructor.
20
+ *
21
+ * @return void
22
+ */
23
+ public function __construct() {
24
+ $this->_processableProducts = array ();
25
+ $this->_productHelper = Mage::helper ( 'meinpaket/product' );
26
+ }
27
+
28
+ /**
29
+ * Exports products.
30
+ *
31
+ * @param integer $selectionMode
32
+ * @return Dhl_MeinPaket_Model_Service_Product_Export_Result
33
+ */
34
+ public function exportProducts() {
35
+ $seenMagentoProducts = array ();
36
+
37
+ /* @var $productBacklogs Dhl_MeinPaket_Model_Mysql4_Backlog_Product_Collection */
38
+ $productBacklogs = Mage::getModel ( 'meinpaket/backlog_product' )->getCollection ();
39
+
40
+ /* @var $uploadRequest Dhl_MeinPaket_Model_Xml_Request_UploadRequest */
41
+ $uploadRequest = Mage::getModel ( 'meinpaket/xml_request_uploadRequest' );
42
+
43
+ /* @var $client Dhl_MeinPaket_Model_Client_XmlOverHttp */
44
+ $client = Mage::getModel ( 'meinpaket/client_xmlOverHttp' );
45
+
46
+ $count = 0;
47
+
48
+ foreach ( $productBacklogs as $productBacklog ) {
49
+ $productId = $productBacklog->getProductId ();
50
+
51
+ $changes = explode ( ',', $productBacklog->getChanges () );
52
+
53
+ try {
54
+ if (! isset ( $seenMagentoProducts [$productId] )) {
55
+ $seenMagentoProducts [$productId] = true;
56
+
57
+ $product = Mage::getModel ( 'catalog/product' )->load ( $productId );
58
+
59
+ $syncMode = $product->getData ( 'sync_with_dhl_mein_paket' );
60
+
61
+ switch ($syncMode) {
62
+ case Dhl_MeinPaket_Model_Entity_Attribute_Source_ProductSyncMode::COMPLETE :
63
+ $uploadRequest->addProductDescription ( $product );
64
+ break;
65
+ case Dhl_MeinPaket_Model_Entity_Attribute_Source_ProductSyncMode::OFFER :
66
+ $uploadRequest->addOffer ( $product );
67
+ break;
68
+ default :
69
+ $uploadRequest->removeProduct($product);
70
+ break;
71
+ }
72
+ } else {
73
+ Mage::log ( 'Product m' . $productId . ' already synced' );
74
+ }
75
+
76
+ $count ++;
77
+
78
+ $productBacklog->delete ();
79
+ } catch ( Exception $ex ) {
80
+ Mage::logException ( $ex );
81
+ // TODO: add error
82
+ // $result ['error'] ++;
83
+ Mage::log ( 'Error syncing product m' . $productId );
84
+ }
85
+ }
86
+
87
+ if ($uploadRequest->isHasData()) {
88
+ $response = $client->send ( $uploadRequest, true );
89
+ $this->_markAsExported ();
90
+ }
91
+
92
+ return Mage::helper ( 'meinpaket/data' )->__ ( "Processed %d products", $count );
93
+ }
94
+
95
+ /**
96
+ * Sets the was_exported_for_dhl_mein_paket attribute to "1" for the
97
+ * products with the given product ids.
98
+ *
99
+ * @param array $productIds
100
+ * @return void
101
+ */
102
+ protected function _markAsExported() {
103
+
104
+ // $product = Mage::getModel ( 'catalog/product' );
105
+
106
+ // foreach ( $this->_result->getOfferedProductIds () as $productId ) {
107
+ // $product->load ( $productId );
108
+ // $product->setData ( 'product_was_exported_for_dhl', 1 );
109
+ // $product->getResource ()->saveAttribute ( $product, 'product_was_exported_for_dhl' );
110
+ // }
111
+ }
112
+ }
app/code/community/Dhl/MeinPaket/Model/Service/Product/Export/Exception/InvalidEan.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Exception which is thrown when a product has an invalid EAN.
5
+ *
6
+ * @category Mage
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Service_Product_Export_Exception_InvalidEan
9
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
10
+ */
11
+ class Dhl_MeinPaket_Model_Service_Product_Export_Exception_InvalidEan extends Dhl_MeinPaket_Model_Exception_InvalidDataException {
12
+ /**
13
+ * Constructor.
14
+ *
15
+ * @param integer $entityId
16
+ * @return void
17
+ */
18
+ public function __construct($entityId) {
19
+ parent::__construct ( $entityId, 'sku' );
20
+ }
21
+ }
app/code/community/Dhl/MeinPaket/Model/Service/ProductData/RequestService.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Service which exports an order's shipment to MeinPaket.de.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Service_ShipmentExport
9
+ * @version $Id$
10
+ */
11
+ class Dhl_MeinPaket_Model_Service_ProductData_RequestService {
12
+ /**
13
+ * Exports a shipment to MeinPaket.de.
14
+ *
15
+ * @param Mage_Catalog_Model_Product $product
16
+ * @throws Dhl_MeinPaket_Model_Xml_XmlBuildException
17
+ * @throws Dhl_MeinPaket_Model_Client_BadHttpReturnCodeException
18
+ * @throws Dhl_MeinPaket_Model_Client_HttpTimeoutException
19
+ * @throws Dhl_MeinPaket_Model_Xml_InvalidXmlException
20
+ * @return Dhl_MeinPaket_Model_Service_ShipmentExport_Result
21
+ */
22
+ public function getProductData(Mage_Catalog_Model_Product $product, $sendEAN = false, $sendName = false) {
23
+ /* @var $uploadRequest Dhl_MeinPaket_Model_Xml_Request_ProductDataRequest */
24
+ $productDataRequest = Mage::getModel ( 'meinpaket/xml_request_dataRequest' );
25
+
26
+ /* @var $client Dhl_MeinPaket_Model_Client_XmlOverHttp */
27
+ $client = Mage::getModel ( 'meinpaket/client_xmlOverHttp' );
28
+
29
+ try {
30
+ $productDataRequest->addProduct ( $product, $sendEAN, $sendName );
31
+ return $response = $client->send ( $productDataRequest );
32
+ } catch ( Exception $e ) {
33
+ Mage::logException ( $e );
34
+
35
+ // return $this->_result;
36
+ }
37
+
38
+ return null;
39
+ }
40
+
41
+ /**
42
+ * Request best prices from MeinPaket.
43
+ *
44
+ * @param Mage_Catalog_Model_Product $product
45
+ * @throws Dhl_MeinPaket_Model_Xml_XmlBuildException
46
+ * @throws Dhl_MeinPaket_Model_Client_BadHttpReturnCodeException
47
+ * @throws Dhl_MeinPaket_Model_Client_HttpTimeoutException
48
+ * @throws Dhl_MeinPaket_Model_Xml_InvalidXmlException
49
+ * @return Dhl_MeinPaket_Model_Service_ShipmentExport_Result
50
+ */
51
+ public function requestBestPrices() {
52
+ /* @var $uploadRequest Dhl_MeinPaket_Model_Xml_Request_ProductDataRequest */
53
+ $productDataRequest = Mage::getModel ( 'meinpaket/xml_request_dataRequest' );
54
+
55
+ /* @var $client Dhl_MeinPaket_Model_Client_XmlOverHttp */
56
+ $client = Mage::getModel ( 'meinpaket/client_xmlOverHttp' );
57
+
58
+ try {
59
+ /* @var $collection Mage_Catalog_Model_Resource_Product_Collection */
60
+ $collection = Mage::getModel ( 'catalog/product' )->getCollection ();
61
+
62
+ $collection->addAttributeToFilter ( 'meinpaket_id', array (
63
+ 'neq' => ''
64
+ ) );
65
+ $collection->addAttributeToFilter ( 'sync_with_dhl_mein_paket', array (
66
+ 'gt' => '0'
67
+ ) );
68
+
69
+ foreach ( $collection as $productId ) {
70
+ $productDataRequest->addBestPriceProduct ( $productId );
71
+ }
72
+ return $response = $client->send ( $productDataRequest, true );
73
+ } catch ( Exception $e ) {
74
+ Mage::logException ( $e );
75
+ }
76
+
77
+ return null;
78
+ }
79
+ }
app/code/community/Dhl/MeinPaket/Model/Service/Result/Abstract.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Result class which keeps information
5
+ *
6
+ * @category Mage
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Service
9
+ * @version $Id$
10
+ */
11
+ abstract class Dhl_MeinPaket_Model_Service_Result_Abstract {
12
+
13
+ /**
14
+ *
15
+ * @var array
16
+ */
17
+ protected $commonErrors = array ();
18
+
19
+ /**
20
+ * Adds a common error which is not product related.
21
+ *
22
+ * @param string $code
23
+ * @param string $message
24
+ */
25
+ public function addCommonError($code, $message) {
26
+ // check if error already exists
27
+ if (sizeof ( $this->commonErrors ) > 0) {
28
+ foreach ( $this->commonErrors as $error ) {
29
+ if ($error ['code'] === $code && $error ['message'] === $message) {
30
+ return;
31
+ }
32
+ }
33
+ }
34
+
35
+ // add error
36
+ $this->commonErrors [] = array (
37
+ 'code' => $code,
38
+ 'message' => $message
39
+ );
40
+ }
41
+
42
+ /**
43
+ *
44
+ * @return boolean
45
+ */
46
+ public function hasErrors() {
47
+ return (sizeof ( $this->commonErrors ) > 0);
48
+ }
49
+
50
+ /**
51
+ * Returns an array of common (not product related) errors.
52
+ * The elements of result array have the following structure:
53
+ * [
54
+ * 'code' => '...',
55
+ * 'message' => '...'
56
+ * ]
57
+ *
58
+ * @return array
59
+ */
60
+ public function getCommonErrors() {
61
+ return $this->commonErrors;
62
+ }
63
+ }
app/code/community/Dhl/MeinPaket/Model/Service/Result/Upload.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Result class which encapsulates information concerning the upload process.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Service_ShipmentExport
9
+ * @version $Id$
10
+ S */
11
+ class Dhl_MeinPaket_Model_Service_Result_Upload extends Dhl_MeinPaket_Model_Service_Result_Abstract {
12
+ }
13
+
app/code/community/Dhl/MeinPaket/Model/System/Config/Source/Attributes.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_System_Config_Source_Attributes {
3
+ protected $attributes;
4
+ public function __construct() {
5
+ $this->attributes = array (
6
+ array (
7
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'None' ),
8
+ 'value' => 'None'
9
+ ),
10
+ array (
11
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Default' ),
12
+ 'value' => 'Default'
13
+ ),
14
+ array (
15
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Color' ),
16
+ 'value' => 'Farbe'
17
+ ),
18
+ array (
19
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Size' ),
20
+ 'value' => 'Größe'
21
+ ),
22
+ array (
23
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Dimension' ),
24
+ 'value' => 'Abmessung'
25
+ ),
26
+ array (
27
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Quantity' ),
28
+ 'value' => 'Anzahl'
29
+ ),
30
+ array (
31
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Width' ),
32
+ 'value' => 'Breite'
33
+ ),
34
+ array (
35
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Length' ),
36
+ 'value' => 'Länge'
37
+ ),
38
+ array (
39
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Format' ),
40
+ 'value' => 'Format'
41
+ ),
42
+ array (
43
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Material' ),
44
+ 'value' => 'Material'
45
+ ),
46
+ array (
47
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Flavor' ),
48
+ 'value' => 'Geschmacksrichtung'
49
+ ),
50
+ array (
51
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Inscription' ),
52
+ 'value' => 'Beschriftung'
53
+ ),
54
+ array (
55
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Model' ),
56
+ 'value' => 'Modell'
57
+ ),
58
+ array (
59
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Platform' ),
60
+ 'value' => 'Plattform'
61
+ ),
62
+ array (
63
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Radius' ),
64
+ 'value' => 'Radius'
65
+ ),
66
+ array (
67
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Strength' ),
68
+ 'value' => 'Stärke'
69
+ ),
70
+ array (
71
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Diameter' ),
72
+ 'value' => 'Durchmesser'
73
+ ),
74
+ array (
75
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Cylinder' ),
76
+ 'value' => 'Zylinder'
77
+ ),
78
+ array (
79
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Axis' ),
80
+ 'value' => 'Achse'
81
+ ),
82
+ array (
83
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Bust Measurement' ),
84
+ 'value' => 'Brustumfang'
85
+ ),
86
+ array (
87
+ 'label' => Mage::helper ( 'meinpaket/data' )->__ ( 'Cup' ),
88
+ 'value' => 'Cup'
89
+ )
90
+ );
91
+ }
92
+ public function toOptionArray($addEmpty = true) {
93
+ return $this->attributes;
94
+ }
95
+ public function toSelectArray() {
96
+ $result = array ();
97
+
98
+ foreach ( $this->attributes as $attribute ) {
99
+ $result [$attribute ['value']] = $attribute ['label'];
100
+ }
101
+
102
+ return $result;
103
+ }
104
+ }
app/code/community/Dhl/MeinPaket/Model/System/MemoryLimiter.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PHP memory limit control.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_System
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_System_MemoryLimiter extends Varien_Object {
13
+ /**
14
+ *
15
+ * @var integer
16
+ */
17
+ const MEMORY_LIMIT_MEDIUM = 256;
18
+
19
+ /**
20
+ *
21
+ * @var integer
22
+ */
23
+ const MEMORY_LIMIT_HIGH = 512;
24
+
25
+ /**
26
+ *
27
+ * @var integer
28
+ */
29
+ const MEMORY_LIMIT_VERY_HIGH = 1024;
30
+
31
+ /**
32
+ * Sets the memory limit for the current script.
33
+ * If the current setting from PHP ini is greater than the given value,
34
+ * the method call will have no effect.
35
+ *
36
+ * @param integer $limit
37
+ * @return void
38
+ *
39
+ */
40
+ public function setMemoryLimit($limit) {
41
+ if (! in_array ( $limit, $this->getAllowedMemoryLimitValues () )) {
42
+ return;
43
+ }
44
+
45
+ $currentLimit = $this->getLimitFromIni ();
46
+
47
+ if ($currentLimit < $limit) {
48
+ ini_set ( 'memory_limit', $limit . 'M' );
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Returns the current memory limit in megabytes.
54
+ *
55
+ * @return integer
56
+ */
57
+ protected function getLimitFromIni() {
58
+ return ( integer ) trim ( str_replace ( "M", "", ini_get ( 'memory_limit' ) ) );
59
+ }
60
+
61
+ /**
62
+ * Returns the values that are valid as a parameter for method setMemoryLimit.
63
+ *
64
+ * @return array
65
+ */
66
+ protected function getAllowedMemoryLimitValues() {
67
+ return array (
68
+ self::MEMORY_LIMIT_MEDIUM,
69
+ self::MEMORY_LIMIT_HIGH,
70
+ self::MEMORY_LIMIT_VERY_HIGH
71
+ );
72
+ }
73
+ }
74
+
app/code/community/Dhl/MeinPaket/Model/Validation/ValidationInterface.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Common validation interface.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Validation
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ interface Dhl_MeinPaket_Model_Validation_ValidationInterface {
13
+ const ERROR_UNDEFINED = 'undefinedError';
14
+ const ERROR_REQUIRED_FIELD_IS_EMPTY = 'fieldIsEmpty';
15
+ const ERROR_FIELD_IS_INVALID = 'invalidField';
16
+ const ERROR_PRODUCT_NOT_EXISTS_IN_MEINPAKET = 'PRODUCT_NOT_FOUND';
17
+ const ERROR_MEINPAKET_SERVER_ERROR = 'SERVER_ERROR';
18
+ const ERROR_PRODUCT_NEGATIVE_STOCK = 'AVAILABILITY_NEGATIVE';
19
+ const ERROR_NOT_AUTHORIZED = 'NOT_AUTHORIZED';
20
+ const ERROR_INVALID_DATA = 'INVALID_DATA';
21
+ const ERROR_INVALID_MODIFICATION = 'INVALID_MODIFICATION';
22
+ const ERROR_NO_CATEGORIZATION = 'NO_CATEGORIZATION';
23
+ const ERROR_PRODUCT_NOT_SELLABLE = 'PRODUCT_NOT_SELLABLE';
24
+ const ERROR_MARKETPLACE_CATEGORY_NOT_FOUND = 'MARKETPLACE_CATEGORY_NOT_FOUND';
25
+ const ERROR_SHOP_CATEGORY_NOT_FOUND = 'SHOP_CATEGORY_NOT_FOUND';
26
+ const ERROR_MISSING_VALUE_FOR_ATTRIBUTE = 'MISSING_VALUE_FOR_ATTRIBUTE';
27
+ const ERROR_VARIANT_GROUP_NOT_EXISTS = 'VARIANT_GROUP_NOT_FOUND';
28
+ }
app/code/community/Dhl/MeinPaket/Model/Validation/Validator/CDATAContent.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Validator for CDATA block content.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Validation_Validator
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Validation_Validator_CDATAContent implements Dhl_MeinPaket_Model_Validation_ValidatorInterface {
13
+ /**
14
+ * Validates a string to be valid content of a CDATA block.
15
+ *
16
+ * @param mixed $value
17
+ * @return boolean
18
+ */
19
+ public function isValid($value) {
20
+ return (preg_match ( '~' . preg_quote ( ']]>' ) . '~', $value ) === 0);
21
+ }
22
+ }
app/code/community/Dhl/MeinPaket/Model/Validation/Validator/Ean.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Validator for European Article Numbers.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Validation_Validator
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Validation_Validator_Ean implements Dhl_MeinPaket_Model_Validation_ValidatorInterface {
13
+ /**
14
+ * Validates an EAN.
15
+ *
16
+ * @param mixed $value
17
+ * @return boolean
18
+ */
19
+ public function isValid($value) {
20
+ $length = 0;
21
+ $checkSum = 0;
22
+ $char = '';
23
+ $validLengths = array (
24
+ 13
25
+ ); // @todo check why array(13, 8) isn't possible
26
+
27
+ if (! is_string ( $value )) {
28
+ $value = ( string ) $value;
29
+ }
30
+
31
+ $length = strlen ( $value );
32
+
33
+ // check for length
34
+ if (! in_array ( $length, $validLengths )) {
35
+ return false;
36
+ }
37
+
38
+ // perform checksum check
39
+ for($i = 0; $i < $length; $i ++) {
40
+
41
+ $char = substr ( $value, $i, 1 );
42
+
43
+ if (! preg_match ( '~\d~', $char )) {
44
+ return false;
45
+ }
46
+
47
+ if ($i % 2 == 0) {
48
+ $checkSum += (( integer ) $char) * 1;
49
+ } else {
50
+ $checkSum += (( integer ) $char) * 3;
51
+ }
52
+ }
53
+ if ($checkSum % 10 != 0) {
54
+ return false;
55
+ }
56
+
57
+ return true;
58
+ }
59
+ }
app/code/community/Dhl/MeinPaket/Model/Validation/Validator/IntGreaterZero.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Validates an interger value to be greater than 0.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Validation_Validator
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Validation_Validator_IntGreaterZero implements Dhl_MeinPaket_Model_Validation_ValidatorInterface {
13
+ /**
14
+ * Validates an integer value to be greater than zero.
15
+ *
16
+ * @param mixed $value
17
+ * @return boolean
18
+ */
19
+ public function isValid($value) {
20
+ return (( integer ) $value > 0);
21
+ }
22
+ }
app/code/community/Dhl/MeinPaket/Model/Validation/Validator/NonEmptyString.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Validator for non empty strings.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Validation_Validator
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Validation_Validator_NonEmptyString implements Dhl_MeinPaket_Model_Validation_ValidatorInterface {
13
+ /**
14
+ * Validates the given value.
15
+ * Checks if the given has at least one character.
16
+ *
17
+ * @param mixed $value
18
+ * @return boolean
19
+ */
20
+ public function isValid($value) {
21
+ return (is_string ( $value ) && strlen ( $value ) > 0);
22
+ }
23
+ }
app/code/community/Dhl/MeinPaket/Model/Validation/Validator/StringMaxLength.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Validator for maximum length of strings.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Validation_Validator
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Validation_Validator_StringMaxLength implements Dhl_MeinPaket_Model_Validation_ValidatorInterface {
13
+ /**
14
+ *
15
+ * @var integer
16
+ */
17
+ const LENGTH_INFINITE = - 1;
18
+
19
+ /**
20
+ *
21
+ * @var integer
22
+ */
23
+ protected $maxLength = self::LENGTH_INFINITE;
24
+
25
+ /**
26
+ * Validates a string not to be longer than the set length.
27
+ *
28
+ * @param mixed $value
29
+ * @return boolean
30
+ */
31
+ public function isValid($value) {
32
+ $value = @(( string ) $value);
33
+ $valid = true;
34
+
35
+ if (! is_string ( $value )) {
36
+ return false;
37
+ }
38
+
39
+ if ($this->maxLength !== self::LENGTH_INFINITE) {
40
+ $valid = (strlen ( $value ) <= $this->maxLength);
41
+ }
42
+
43
+ return $valid;
44
+ }
45
+
46
+ /**
47
+ * Sets the maximum allowed length.
48
+ *
49
+ * @param integer $length
50
+ * @return Dhl_MeinPaket_Model_Validation_Validator_StringMaxLength
51
+ */
52
+ public function setMaxLength($length) {
53
+ if (is_integer ( $length ) && $length >= 0) {
54
+ $this->maxLength = $length;
55
+ }
56
+ return $this;
57
+ }
58
+ }
app/code/community/Dhl/MeinPaket/Model/Validation/Validator/Url.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Validator for URLs.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Validation_Validator
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Validation_Validator_Url implements Dhl_MeinPaket_Model_Validation_ValidatorInterface {
13
+ /**
14
+ * Validates an URL.
15
+ *
16
+ * @param mixed $value
17
+ * @return boolean
18
+ */
19
+ public function isValid($value) {
20
+ return (substr ( $value, 0, 4 ) === 'http');
21
+ }
22
+ }
app/code/community/Dhl/MeinPaket/Model/Validation/ValidatorChain.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Validator chain class which validates a value using a set of validators.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Validation
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Validation_ValidatorChain implements Dhl_MeinPaket_Model_Validation_ValidatorInterface {
13
+ /**
14
+ *
15
+ * @var array
16
+ */
17
+ protected $validators = array ();
18
+
19
+ /**
20
+ * Returns the chained result of all validators.
21
+ *
22
+ * @param mixed $value
23
+ * @return boolean
24
+ */
25
+ public function isValid($value) {
26
+ if (sizeof ( $this->validators ) > 0) {
27
+ foreach ( $this->validators as $validator ) {
28
+ if (! $validator->isValid ( $value )) {
29
+ return false;
30
+ }
31
+ }
32
+ }
33
+
34
+ return true;
35
+ }
36
+
37
+ /**
38
+ * Adds a validator to the end of the chain.
39
+ *
40
+ * @param Dhl_MeinPaket_Model_Validation_ValidatorInterface $validator
41
+ * @return Dhl_MeinPaket_Model_Validation_ValidatorChain
42
+ */
43
+ public function addValidator(Dhl_MeinPaket_Model_Validation_ValidatorInterface $validator) {
44
+ $this->validators [] = $validator;
45
+ return $this;
46
+ }
47
+ }
48
+
app/code/community/Dhl/MeinPaket/Model/Validation/ValidatorFactory.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Factory for validators.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Validation
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Validation_ValidatorFactory extends Varien_Object {
13
+ /**
14
+ *
15
+ * @var string
16
+ */
17
+ protected $packagePrefix = 'meinpaket/Validation_Validator_';
18
+
19
+ /**
20
+ *
21
+ * @return Dhl_MeinPaket_Model_Validation_ValidatorChain
22
+ */
23
+ public function createValidatorChain() {
24
+ return Mage::getModel ( 'meinpaket/Validation_ValidatorChain' );
25
+ }
26
+
27
+ /**
28
+ *
29
+ * @return Dhl_MeinPaket_Model_Validation_Validator_NonEmptyString
30
+ */
31
+ public function createNonEmptyStringValidator() {
32
+ return Mage::getModel ( $this->packagePrefix . 'NonEmptyString' );
33
+ }
34
+
35
+ /**
36
+ *
37
+ * @return Dhl_MeinPaket_Model_Validation_Validator_Ean
38
+ */
39
+ public function createEanValidator() {
40
+ return Mage::getModel ( $this->packagePrefix . 'Ean' );
41
+ }
42
+
43
+ /**
44
+ *
45
+ * @return Dhl_MeinPaket_Model_Validation_Validator_IntGreaterZero
46
+ */
47
+ public function createIntGreaterZeroValidator() {
48
+ return Mage::getModel ( $this->packagePrefix . 'IntGreaterZero' );
49
+ }
50
+
51
+ /**
52
+ *
53
+ * @return Dhl_MeinPaket_Model_Validation_Validator_CDATAContent
54
+ */
55
+ public function createCDATAContentValidator() {
56
+ return Mage::getModel ( $this->packagePrefix . 'CDATAContent' );
57
+ }
58
+
59
+ /**
60
+ *
61
+ * @return Dhl_MeinPaket_Model_Validation_Validator_Url
62
+ */
63
+ public function createUrlValidator() {
64
+ return Mage::getModel ( $this->packagePrefix . 'Url' );
65
+ }
66
+
67
+ /**
68
+ *
69
+ * @param integer $maxLength
70
+ * @return Dhl_MeinPaket_Model_Validation_Validator_StringMaxLength
71
+ */
72
+ public function createStringMaxLengthValidator($maxLength = Dhl_MeinPaket_Model_Validation_Validator_StringMaxLength::LENGTH_INFINITE) {
73
+ return Mage::getModel ( $this->packagePrefix . 'StringMaxLength' )->setMaxLength ( $maxLength );
74
+ }
75
+ }
76
+
app/code/community/Dhl/MeinPaket/Model/Validation/ValidatorInterface.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Common interface for all validator classes.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Validation
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ interface Dhl_MeinPaket_Model_Validation_ValidatorInterface {
13
+
14
+ /**
15
+ * Validates the given value.
16
+ *
17
+ * @param mixed $value
18
+ * @return boolean
19
+ */
20
+ public function isValid($value);
21
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/AbstractXmlPartial.php ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abstract base class of all partials.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Xml
9
+ * @version $Id$
10
+ * @author Daniel Pötzinger <daniel.poetzinger@aoemedia.de>
11
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
12
+ */
13
+ abstract class Dhl_MeinPaket_Model_Xml_AbstractXmlPartial {
14
+ /**
15
+ *
16
+ * @var DOMNode
17
+ */
18
+ protected $node = null;
19
+
20
+ /**
21
+ *
22
+ * @var DOMDocument
23
+ */
24
+ protected $document = null;
25
+
26
+ /**
27
+ * Default constructor.
28
+ *
29
+ * @param DOMDocument $document
30
+ */
31
+ public function __construct(DOMDocument $document) {
32
+ $this->document = $document;
33
+
34
+ if ($this->document == null || ! ($this->document instanceof DOMDocument)) {
35
+ throw new InvalidArgumentException ( "Invalid DOMDocument given" );
36
+ }
37
+ }
38
+
39
+ /**
40
+ * Returns the DOM node of the element.
41
+ * The build() method has to be called before. Otherwise
42
+ * this method will return null.
43
+ *
44
+ * @return DOMNode
45
+ */
46
+ public function getNode() {
47
+ return $this->node;
48
+ }
49
+
50
+ /**
51
+ * Returns the associated document.
52
+ *
53
+ * @return DOMDocument
54
+ */
55
+ protected function getDocument() {
56
+ return $this->document;
57
+ }
58
+ /**
59
+ * Returns the associated root document.
60
+ *
61
+ * @return DOMNode
62
+ */
63
+ protected function getDocumentElement() {
64
+ if ($this->document != null) {
65
+ return $this->document->documentElement;
66
+ }
67
+ return null;
68
+ }
69
+
70
+ /**
71
+ * Sets the DOM document.
72
+ *
73
+ * @param DOMDocument $document
74
+ * @return Dhl_MeinPaket_Model_Xml_AbstractXmlPartial
75
+ */
76
+ public function setDocument(DOMDocument $document) {
77
+ $this->document = $document;
78
+ return $this;
79
+ }
80
+
81
+ /**
82
+ *
83
+ * @param integer $time
84
+ * @return string
85
+ */
86
+ protected function getFormatedDate($time) {
87
+ $date = date ( 'c', $time );
88
+ $dateExploded = explode ( '+', $date );
89
+ return $dateExploded [0];
90
+ }
91
+
92
+ /**
93
+ * Builds the DOM node.
94
+ *
95
+ * @return DOMNode
96
+ */
97
+ abstract public function build();
98
+
99
+ /**
100
+ * Creates a CDATA noe.
101
+ *
102
+ * @param string $nodeName
103
+ * name.
104
+ * @param string $content
105
+ * @return DOMElement
106
+ */
107
+ protected function getCDATANode($nodeName, $content) {
108
+ $node = $this->getDocument ()->createElement ( $nodeName );
109
+ $node->appendChild ( $this->getDocument ()->createCDATASection ( $content ) );
110
+ return $node;
111
+ }
112
+
113
+ /**
114
+ * Simple validation for element content.
115
+ *
116
+ * @param string $content
117
+ * @param string $validatorType
118
+ * @return boolean
119
+ */
120
+ protected function isValid($content, $validatorType) {
121
+ $valid = false;
122
+
123
+ switch ($validatorType) {
124
+ case 'nonEmptyString' :
125
+ $valid = Mage::getModel ( 'meinpaket/Validation_Validator_NonEmptyString' )->isValid ( $content );
126
+ break;
127
+ case 'ean' :
128
+ $valid = Mage::getModel ( 'meinpaket/Validation_Validator_Ean' )->isValid ( $content );
129
+ break;
130
+ }
131
+
132
+ return $valid;
133
+ }
134
+
135
+ /**
136
+ * Returns an instance of Dhl_MeinPaket_Model_Validation_ValidatorFactory.
137
+ *
138
+ * @return Dhl_MeinPaket_Model_Validation_ValidatorFactory
139
+ */
140
+ protected function getValidatorFactory() {
141
+ return Mage::getSingleton ( 'meinpaket/Validation_ValidatorFactory' );
142
+ }
143
+
144
+ /**
145
+ * Creates an ISO date string without trailing timezone offset for the
146
+ * given timestamp.
147
+ *
148
+ * @param integer $timestamp
149
+ * @return string
150
+ */
151
+ public function getIsoDateTime($timestamp = null) {
152
+ $isoString = '';
153
+ $format = 'Y-m-d\TH:i:s';
154
+
155
+ if ($timestamp === null) {
156
+ $isoString = date ( $format );
157
+ } else {
158
+ $isoString = date ( $format, $timestamp );
159
+ }
160
+
161
+ return $isoString;
162
+ }
163
+ /**
164
+ * Convert HTML entities to UTF- 8special chars while leaving the already existing special chars intact
165
+ * TODO: Move to helper?
166
+ * @param string $string
167
+ * @return string
168
+ */
169
+ protected function escapeStringForMeinPaket($string) {
170
+ $string = utf8_decode ( $string );
171
+ $string = html_entity_decode ( $string );
172
+ $string = utf8_encode ( $string );
173
+
174
+ return $string;
175
+ }
176
+
177
+ /**
178
+ * Create a string from created document.
179
+ *
180
+ * @return string
181
+ */
182
+ public function __toString() {
183
+ return $this->getDocument ()->saveXML ();
184
+ }
185
+ }
186
+
app/code/community/Dhl/MeinPaket/Model/Xml/AbstractXmlRequest.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abstract base class of all partials.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Xml
9
+ * @version $Id$
10
+ * @author Daniel Pötzinger <daniel.poetzinger@aoemedia.de>
11
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
12
+ */
13
+ abstract class Dhl_MeinPaket_Model_Xml_AbstractXmlRequest extends Dhl_MeinPaket_Model_Xml_AbstractXmlPartial {
14
+ // const XMLNS = 'http://www.meinpaket.de/xsd/dietmar/1.0/products';
15
+ const XMLNS_COMMON = 'http://www.meinpaket.de/xsd/dietmar/1.0/common';
16
+ const XMLNS_DATA = 'http://www.meinpaket.de/xsd/dietmar/1.0/data';
17
+ const XMLNS_PRODUCTS = 'http://www.meinpaket.de/xsd/dietmar/1.0/products';
18
+ const XMLNS_ORDERS = 'http://www.meinpaket.de/xsd/dietmar/1.0/orders';
19
+ const XMLNS_CHECKOUT = 'http://www.meinpaket.de/xsd/dietmar/1.0/checkout';
20
+ const XMLNS_ASYNCHRONOUS = 'http://www.meinpaket.de/xsd/dietmar/1.0/asynchronous';
21
+
22
+ /**
23
+ * The XML-version of the generated XML.
24
+ *
25
+ * @var string
26
+ */
27
+ const XML_VERSION = '1.0';
28
+
29
+ /**
30
+ * The charset which is set in the XML prologue of the generated XML.
31
+ *
32
+ * @var string
33
+ */
34
+ const XML_CHARSET = 'UTF-8';
35
+
36
+ /**
37
+ * Has data been added
38
+ *
39
+ * @var boolean
40
+ */
41
+ protected $hasData = false;
42
+
43
+ /**
44
+ * Default constructor.
45
+ *
46
+ * @param DOMDocument $document
47
+ */
48
+ public function __construct(DOMDocument $document = null) {
49
+ parent::__construct ( $document === null ? new DOMDocument ( self::XML_VERSION, self::XML_CHARSET ) : $document );
50
+ $this->createDocumentElement ();
51
+ $this->addHeader ();
52
+ }
53
+ public function addHeader() {
54
+ $username = Mage::getStoreConfig ( 'meinpaket/credentials/username' );
55
+ $password = Mage::getStoreConfig ( 'meinpaket/credentials/password' );
56
+
57
+ if (! is_string ( $username ) || ! is_string ( $password ) || strlen ( $username ) <= 0 || strlen ( $password ) <= 0) {
58
+ throw new Dhl_MeinPaket_Model_Xml_XmlBuildException ( 'No authentication parameters set.' );
59
+ }
60
+
61
+ $headerNode = $this->getDocument ()->createElement ( 'common:header' );
62
+ $usernameNode = $this->getDocument ()->createElement ( 'common:login' );
63
+ $passwordNode = $this->getDocument ()->createElement ( 'common:password' );
64
+ $languageNode = $this->getDocument ()->createElement ( 'common:language', 'de' );
65
+ $multiplierIdNode = $this->getDocument ()->createElement ( 'common:multiplierId', 'MAGENTO' );
66
+
67
+ $usernameNode->appendChild ( $this->getDocument ()->createTextNode ( $username ) );
68
+ $passwordNode->appendChild ( $this->getDocument ()->createTextNode ( $password ) );
69
+
70
+ $headerNode->appendChild ( $usernameNode );
71
+ $headerNode->appendChild ( $passwordNode );
72
+ $headerNode->appendChild ( $languageNode );
73
+ $headerNode->appendChild ( $multiplierIdNode );
74
+
75
+ $this->getDocumentElement ()->appendChild ( $headerNode );
76
+ }
77
+
78
+ /**
79
+ * Builds the DOM node.
80
+ *
81
+ * @return Dhl_MeinPaket_Model_Xml_AbstractXmlPartial
82
+ */
83
+ public function build() {
84
+ // No need to be build
85
+ return $this;
86
+ }
87
+
88
+ /**
89
+ * Is has data set?
90
+ *
91
+ * @return boolean
92
+ */
93
+ public function isHasData() {
94
+ return $this->hasData;
95
+ }
96
+
97
+ /**
98
+ * Set has data.
99
+ *
100
+ * @param boolean $value
101
+ */
102
+ public function setHasData($value = true) {
103
+ $this->hasData = $value;
104
+ }
105
+
106
+ /**
107
+ * Create the root element for the document.
108
+ *
109
+ * @return DOMNode
110
+ */
111
+ abstract public function createDocumentElement();
112
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/InvalidXmlException.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Exception class which has to be thrown for notification on invalid xml structure.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Xml
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Xml_InvalidXmlException extends Varien_Exception {
13
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Request/AsynchronousStatusRequest.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Partial which represents the 'downloadRequest' element.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Xml_Partial
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Xml_Request_AsynchronousStatusRequest extends Dhl_MeinPaket_Model_Xml_AbstractXmlRequest {
13
+ /**
14
+ * RequesdId for this request
15
+ *
16
+ * @var unknown
17
+ */
18
+ protected $requestId;
19
+
20
+ /**
21
+ * Default Constructor.
22
+ */
23
+ public function __construct() {
24
+ parent::__construct ();
25
+ }
26
+
27
+ /**
28
+ * Create the root element for the document.
29
+ *
30
+ * @return DOMNode
31
+ */
32
+ public function createDocumentElement() {
33
+ $this->node = $this->getDocument ()->createElement ( 'asynchronousStatusRequest' );
34
+ $this->node->setAttribute ( 'xmlns', self::XMLNS_ASYNCHRONOUS );
35
+ $this->node->setAttribute ( 'xmlns:common', self::XMLNS_COMMON );
36
+ $this->node->setAttribute ( 'version', '1.0' );
37
+ $this->getDocument ()->appendChild ( $this->node );
38
+ }
39
+
40
+ /**
41
+ * Creates the request XML for a category structure download request.
42
+ */
43
+ public function addRequestStatus($requestId, $onlyStatus = 'false') {
44
+ $this->requestId = $requestId;
45
+ $getRequestStatusNode = $this->getDocument ()->createElement ( 'getRequestStatus' );
46
+ $this->getDocumentElement ()->appendChild ( $getRequestStatusNode );
47
+
48
+ $requestIdNode = $this->getDocument ()->createElement ( 'requestId', $requestId );
49
+ $getRequestStatusNode->appendChild ( $requestIdNode );
50
+
51
+ $onlyStatusNode = $this->getDocument ()->createElement ( 'onlyStatus', $onlyStatus );
52
+ $getRequestStatusNode->appendChild ( $onlyStatusNode );
53
+
54
+ return $this;
55
+ }
56
+ public function getRequestId() {
57
+ return $this->requestId;
58
+ }
59
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Request/DataRequest.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Represents the XML structure of an <productDataRequest> element.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Xml_Partial
9
+ * @subpackage Dhl_MeinPaket_Model_Xml_Partial
10
+ */
11
+ class Dhl_MeinPaket_Model_Xml_Request_DataRequest extends Dhl_MeinPaket_Model_Xml_AbstractXmlRequest {
12
+ /**
13
+ *
14
+ * @var Dhl_MeinPaket_Helper_Product
15
+ */
16
+ protected $productHelper = null;
17
+ protected $productDataRequest = null;
18
+ protected $bestPriceRequest = null;
19
+
20
+ /**
21
+ * Default Constructor.
22
+ */
23
+ public function __construct() {
24
+ parent::__construct ();
25
+ $this->productHelper = Mage::helper ( 'meinpaket/product' );
26
+ }
27
+
28
+ /**
29
+ * Create the root element for the document.
30
+ *
31
+ * @return DOMNode
32
+ */
33
+ public function createDocumentElement() {
34
+ $this->node = $this->getDocument ()->createElement ( 'dataRequest' );
35
+ $this->node->setAttribute ( 'xmlns', self::XMLNS_DATA );
36
+ $this->node->setAttribute ( 'xmlns:common', self::XMLNS_COMMON );
37
+ $this->node->setAttribute ( 'version', '1.0' );
38
+ $this->getDocument ()->appendChild ( $this->node );
39
+ }
40
+
41
+ /**
42
+ *
43
+ * @param Mage_Catalog_Model_Product $product
44
+ * @param boolean $sendEAN
45
+ * send ean value
46
+ * @param boolean $sendName
47
+ * send name value
48
+ * @return DOMNode|Ambigous <boolean, DOMElement>
49
+ */
50
+ public function addProduct(Mage_Catalog_Model_Product $product, $sendEAN = false, $sendName = false) {
51
+ $productNode = $this->getDocument ()->createElement ( 'product' );
52
+ $this->getProductDataRequest ()->appendChild ( $productNode );
53
+ $productNode->setAttribute ( 'entryId', $product->getId () );
54
+
55
+ $ean = $this->productHelper->getEan ( $product );
56
+
57
+ if ($sendEAN) {
58
+ $eanNode = $this->getDocument ()->createElement ( 'ean', $ean );
59
+ $productNode->appendChild ( $eanNode );
60
+ }
61
+
62
+ if ($sendName) {
63
+ $nameNode = $this->getDocument ()->createElement ( 'productName', $product->getName () );
64
+ $productNode->appendChild ( $nameNode );
65
+ }
66
+
67
+ return $this;
68
+ }
69
+
70
+ /**
71
+ *
72
+ * @param Mage_Catalog_Model_Product $product
73
+ * @param boolean $sendEAN
74
+ * send ean value
75
+ * @param boolean $sendName
76
+ * send name value
77
+ * @return DOMNode|Ambigous <boolean, DOMElement>
78
+ */
79
+ public function addBestPriceProduct(Mage_Catalog_Model_Product $product) {
80
+ $productNode = $this->getDocument ()->createElement ( 'productId', $product->getId () );
81
+ $this->getBestPriceRequest ()->appendChild ( $productNode );
82
+ return $this;
83
+ }
84
+
85
+ /**
86
+ *
87
+ * @return DOMElement
88
+ */
89
+ protected function getProductDataRequest() {
90
+ if ($this->productDataRequest == null) {
91
+ $this->productDataRequest = $this->getDocument ()->createElement ( 'productDataRequest' );
92
+ $this->getDocumentElement ()->appendChild ( $this->productDataRequest );
93
+ }
94
+ return $this->productDataRequest;
95
+ }
96
+
97
+ /**
98
+ *
99
+ * @return DOMElement
100
+ */
101
+ protected function getBestPriceRequest() {
102
+ if ($this->bestPriceRequest == null) {
103
+ $this->bestPriceRequest = $this->getDocument ()->createElement ( 'bestPriceRequest' );
104
+ $this->getDocumentElement ()->appendChild ( $this->bestPriceRequest );
105
+ }
106
+ return $this->bestPriceRequest;
107
+ }
108
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Request/DownloadRequest.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Partial which represents the 'downloadRequest' element.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Xml_Partial
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Xml_Request_DownloadRequest extends Dhl_MeinPaket_Model_Xml_AbstractXmlRequest {
13
+ /**
14
+ * Default Constructor.
15
+ */
16
+ public function __construct() {
17
+ parent::__construct();
18
+ }
19
+
20
+ /**
21
+ * Create the root element for the document.
22
+ *
23
+ * @return DOMNode
24
+ */
25
+ public function createDocumentElement() {
26
+ $this->node = $this->getDocument ()->createElement ( 'downloadRequest' );
27
+ $this->node->setAttribute ( 'xmlns', self::XMLNS_PRODUCTS );
28
+ $this->node->setAttribute ( 'xmlns:common', self::XMLNS_COMMON );
29
+ $this->node->setAttribute ( 'version', '1.0' );
30
+ $this->getDocument ()->appendChild ( $this->node );
31
+ }
32
+
33
+ /**
34
+ * Creates the request XML for a category structure download request.
35
+ */
36
+ public function addDownloadMarketplaceCategories() {
37
+ $this->getDocumentElement ()->appendChild ( $this->getDocument ()->createElement ( 'catalogstructure', 'marketplace' ) );
38
+ }
39
+ public function addDownloadOffers() {
40
+ $this->getDocumentElement ()->appendChild ( $this->getDocument ()->createElement ( 'getProductOffers' ) );
41
+ }
42
+ public function addVariantConfigurations() {
43
+ $this->getDocumentElement ()->appendChild ( $this->getDocument ()->createElement ( 'variantConfigurations' ) );
44
+ }
45
+ public function addInternationalPrices() {
46
+ $this->getDocumentElement ()->appendChild ( $this->getDocument ()->createElement ( 'getInternationalPrices' ) );
47
+ }
48
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Request/NotificationRequest.php ADDED
@@ -0,0 +1,254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Partial which represents the 'notificationRequest' element.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Xml_Partial
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Xml_Request_NotificationRequest extends Dhl_MeinPaket_Model_Xml_AbstractXmlRequest {
13
+ /**
14
+ *
15
+ * @var DOMNode
16
+ */
17
+ protected $cancellations = null;
18
+ /**
19
+ *
20
+ * @var DOMNode
21
+ */
22
+ protected $consignments = null;
23
+ /**
24
+ *
25
+ * @var DOMNode
26
+ */
27
+ protected $trackingNumbers = null;
28
+ /**
29
+ *
30
+ * @var DOMNode
31
+ */
32
+ protected $returns = null;
33
+ /**
34
+ *
35
+ * @var DOMNode
36
+ */
37
+ protected $credits = null;
38
+
39
+ /**
40
+ * Default Constructor.
41
+ */
42
+ public function __construct() {
43
+ parent::__construct ();
44
+ }
45
+
46
+ /**
47
+ * Create the root element for the document.
48
+ *
49
+ * @return DOMNode
50
+ */
51
+ public function createDocumentElement() {
52
+ $this->node = $this->getDocument ()->createElement ( 'notificationRequest' );
53
+ $this->node->setAttribute ( 'xmlns', self::XMLNS_ORDERS );
54
+ $this->node->setAttribute ( 'xmlns:common', self::XMLNS_COMMON );
55
+ $this->node->setAttribute ( 'version', '1.0' );
56
+ $this->getDocument ()->appendChild ( $this->node );
57
+ }
58
+
59
+ /**
60
+ *
61
+ * @param Mage_Sales_Model_Order_Shipment $shipment
62
+ * @param Mage_Sales_Model_Order $order
63
+ * @param mixed $trackingNumber
64
+ * null or trackingNumber
65
+ * @return DOMNode|Ambigous <boolean, DOMElement>
66
+ */
67
+ public function addConsignment(Mage_Sales_Model_Order_Shipment $shipment, Mage_Sales_Model_Order $order = null, $trackingNumber = null) {
68
+ $consignmentNode = $this->getDocument ()->createElement ( 'consignment' );
69
+ $this->getConsignments ()->appendChild ( $consignmentNode );
70
+
71
+ if ($order == null) {
72
+ $order = $shipment->getOrder ();
73
+ }
74
+
75
+ $orderIdNode = $this->getDocument ()->createElement ( 'orderId', $order->getDhlMeinPaketOrderId () );
76
+ $consignmentNode->appendChild ( $orderIdNode );
77
+
78
+ $consignmentIdNode = $this->getDocument ()->createElement ( 'consignmentId', $shipment->getId () );
79
+ $consignmentNode->appendChild ( $consignmentIdNode );
80
+
81
+ if ($trackingNumber == null) {
82
+ foreach ( $shipment->getAllTracks () as $track ) {
83
+ // take the last one
84
+ $trackingNumber = $track->getNumber ();
85
+ }
86
+ }
87
+
88
+ if (strlen ( $trackingNumber )) {
89
+ $trackingIdNode = $this->getDocument ()->createElement ( 'trackingId', $trackingNumber );
90
+ $consignmentNode->appendChild ( $trackingIdNode );
91
+ }
92
+
93
+ foreach ( $shipment->getAllItems () as $item ) {
94
+ $consignmentEntryNode = $this->getDocument ()->createElement ( 'consignmentEntry' );
95
+ $consignmentNode->appendChild ( $consignmentEntryNode );
96
+
97
+ $consignmentEntryNode->appendChild ( $this->getDocument ()->createElement ( 'common:productId', $item->getProductId () ) );
98
+ $consignmentEntryNode->appendChild ( $this->getDocument ()->createElement ( 'quantity', ( int ) $item->getQty () ) );
99
+ }
100
+
101
+ $this->setHasData();
102
+
103
+ return $this;
104
+ }
105
+
106
+ /**
107
+ *
108
+ * @param Mage_Sales_Model_Order_Shipment_Track $trackingNumber
109
+ * @return DOMNode|Ambigous <boolean, DOMElement>
110
+ */
111
+ public function addTrackingNumber(Mage_Sales_Model_Order_Shipment_Track $trackingNumber) {
112
+ $trackingNumberNode = $this->getDocument ()->createElement ( 'trackingNumber' );
113
+ $this->getTrackingNumbers ()->appendChild ( $trackingNumberNode );
114
+
115
+ $consignmentIdNode = $this->getDocument ()->createElement ( 'consignmentId', $trackingNumber->getShipment ()->getId () );
116
+ $trackingNumberNode->appendChild ( $consignmentIdNode );
117
+
118
+ $trackingIdNode = $this->getDocument ()->createElement ( 'trackingId', $trackingNumber->getNumber () );
119
+ $trackingNumberNode->appendChild ( $trackingIdNode );
120
+
121
+ $this->setHasData();
122
+
123
+ return $this;
124
+ }
125
+
126
+ /**
127
+ *
128
+ * @param Mage_Sales_Model_Order_Shipment $shipment
129
+ * @param Mage_Sales_Model_Order $order
130
+ * @param mixed $trackingNumber
131
+ * null or trackingNumber
132
+ * @return DOMNode|Ambigous <boolean, DOMElement>
133
+ */
134
+ public function addCancellation(Mage_Sales_Model_Order $order) {
135
+ $cancellationNode = $this->getDocument ()->createElement ( 'cancellation' );
136
+ $this->getCancellations ()->appendChild ( $cancellationNode );
137
+
138
+ $orderIdNode = $this->getDocument ()->createElement ( 'orderId', $order->getData ( 'dhl_mein_paket_order_id' ) );
139
+ $cancellationNode->appendChild ( $orderIdNode );
140
+
141
+ $consignmentIdNode = $this->getDocument ()->createElement ( 'consignmentId', $order->getId () . ' ' . microtime () );
142
+ $cancellationNode->appendChild ( $consignmentIdNode );
143
+
144
+ foreach ( $order->getAllItems () as $orderItem ) {
145
+ $cancellationEntryNode = $this->getDocument ()->createElement ( 'cancellationEntry' );
146
+ $cancellationNode->appendChild ( $cancellationEntryNode );
147
+
148
+ $productIdNode = $this->getDocument ()->createElement ( 'common:productId', $orderItem->getProductId () );
149
+ $cancellationEntryNode->appendChild ( $productIdNode );
150
+
151
+ $quantityNode = $this->getDocument ()->createElement ( 'quantity', ( int ) $orderItem->getQtyOrdered () );
152
+ $cancellationEntryNode->appendChild ( $quantityNode );
153
+
154
+ $reasonNode = $this->getDocument ()->createElement ( 'reason', 'DealerRequest' );
155
+ $cancellationEntryNode->appendChild ( $reasonNode );
156
+ }
157
+
158
+ $this->setHasData();
159
+
160
+ return $this;
161
+ }
162
+
163
+ /**
164
+ *
165
+ * @param Mage_Sales_Model_Order_Shipment $shipment
166
+ * @param Mage_Sales_Model_Order $order
167
+ * @param mixed $trackingNumber
168
+ * null or trackingNumber
169
+ * @return DOMNode|Ambigous <boolean, DOMElement>
170
+ */
171
+ public function addCreditMemo(Mage_Sales_Model_Order_Creditmemo $creditMemo, Mage_Sales_Model_Order_Shipment $shipment) {
172
+ $creditMemoNode = $this->getDocument ()->createElement ( 'creditMemo' );
173
+ $this->getCredits ()->appendChild ( $creditMemoNode );
174
+
175
+ $consignmentIdNode = $this->getDocument ()->createElement ( 'consignmentId', $shipment->getId () );
176
+ $creditMemoNode->appendChild ( $consignmentIdNode );
177
+
178
+ $orderIdNode = $this->getDocument ()->createElement ( 'orderId', $creditMemo->getOrder ()->getDhlMeinPaketOrderId () );
179
+ $creditMemoNode->appendChild ( $orderIdNode );
180
+
181
+ $creditIdNode = $this->getDocument ()->createElement ( 'creditId', $creditMemo->getId () );
182
+ $creditMemoNode->appendChild ( $creditIdNode );
183
+
184
+ $creditAmountNode = $this->getDocument ()->createElement ( 'creditAmount', $creditMemo->getGrandTotal () );
185
+ $creditMemoNode->appendChild ( $creditAmountNode );
186
+
187
+ $creditMemoReasonNode = $this->getDocument ()->createElement ( 'creditMemoReason', 'DEALER_GOODWILL' );
188
+ $creditMemoNode->appendChild ( $creditMemoReasonNode );
189
+
190
+ $this->setHasData();
191
+
192
+ return $this;
193
+ }
194
+
195
+ /**
196
+ *
197
+ * @return DOMElement
198
+ */
199
+ protected function getCancellations() {
200
+ if ($this->cancellations == null) {
201
+ $this->cancellations = $this->getDocument ()->createElement ( 'cancellations' );
202
+ $this->getDocumentElement ()->appendChild ( $this->cancellations );
203
+ }
204
+ return $this->cancellations;
205
+ }
206
+
207
+ /**
208
+ *
209
+ * @return DOMElement
210
+ */
211
+ protected function getConsignments() {
212
+ if ($this->consignments == null) {
213
+ $this->consignments = $this->getDocument ()->createElement ( 'consignments' );
214
+ $this->getDocumentElement ()->appendChild ( $this->consignments );
215
+ }
216
+ return $this->consignments;
217
+ }
218
+
219
+ /**
220
+ *
221
+ * @return DOMElement
222
+ */
223
+ protected function getReturns() {
224
+ if ($this->returns == null) {
225
+ $this->returns = $this->getDocument ()->createElement ( 'returns' );
226
+ $this->getDocumentElement ()->appendChild ( $this->returns );
227
+ }
228
+ return $this->returns;
229
+ }
230
+
231
+ /**
232
+ *
233
+ * @return DOMElement
234
+ */
235
+ protected function getTrackingNumbers() {
236
+ if ($this->trackingNumbers == null) {
237
+ $this->trackingNumbers = $this->getDocument ()->createElement ( 'trackingNumbers' );
238
+ $this->getDocumentElement ()->appendChild ( $this->trackingNumbers );
239
+ }
240
+ return $this->trackingNumbers;
241
+ }
242
+
243
+ /**
244
+ *
245
+ * @return DOMElement
246
+ */
247
+ protected function getCredits() {
248
+ if ($this->credits == null) {
249
+ $this->credits = $this->getDocument ()->createElement ( 'credits' );
250
+ $this->getDocumentElement ()->appendChild ( $this->credits );
251
+ }
252
+ return $this->credits;
253
+ }
254
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Request/QueryRequest.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Partial which represents the 'queryRequest' element.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Xml_Partial
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Xml_Request_QueryRequest extends Dhl_MeinPaket_Model_Xml_AbstractXmlRequest {
13
+
14
+ /**
15
+ * Default Constructor.
16
+ */
17
+ public function __construct() {
18
+ parent::__construct ();
19
+ }
20
+
21
+ /**
22
+ * Create the root element for the document.
23
+ *
24
+ * @return DOMNode
25
+ */
26
+ public function createDocumentElement() {
27
+ $this->node = $this->getDocument ()->createElement ( 'queryRequest' );
28
+ $this->node->setAttribute ( 'xmlns', self::XMLNS_ORDERS );
29
+ $this->node->setAttribute ( 'xmlns:common', self::XMLNS_COMMON );
30
+ $this->node->setAttribute ( 'version', '1.0' );
31
+ $this->getDocument ()->appendChild ( $this->node );
32
+ }
33
+
34
+ /**
35
+ * Add order request.
36
+ *
37
+ * @param string $from
38
+ * @param string $to
39
+ * @param string $status
40
+ */
41
+ public function addOrders($from = null, $to = null, $status = null) {
42
+ $this->orders = $this->getDocument ()->createElement ( 'orders' );
43
+ $this->getDocumentElement ()->appendChild ( $this->orders );
44
+ $this->orders->setAttribute ( 'getEmail', 'true' );
45
+ $this->orders->setAttribute ( 'additionalInfos', true );
46
+
47
+ if ($from != null) {
48
+ $dateFromNode = $this->getDocument ()->createElement ( "dateFrom", $this->getFormatedDate ( $from ) );
49
+ $this->orders->appendChild ( $dateFromNode );
50
+ } else {
51
+ // One week ago
52
+ /* @var $date Zend_Date */
53
+ $date = Zend_Date::now ();
54
+ $date->subWeek ( 1 );
55
+ $date->setHour ( 0 );
56
+ $date->setMinute ( 0 );
57
+ $date->setMilliSecond ( 0 );
58
+ $dateFromNode = $this->getDocument ()->createElement ( "dateFrom", $date->toString ( Zend_Date::ISO_8601 ) );
59
+ $this->orders->appendChild ( $dateFromNode );
60
+ }
61
+
62
+ if ($to != null) {
63
+ $dateToNode = $this->getDocument ()->createElement ( "dateTo", $this->getFormatedDate ( $to ) );
64
+ $this->orders->appendChild ( $dateToNode );
65
+ }
66
+
67
+ if ($status != null) {
68
+ $statusNode = $this->getDocument ()->createElement ( "orderStatus", $status );
69
+ $this->orders->appendChild ( $statusNode );
70
+ }
71
+ }
72
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Request/SubmitCartRequest.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Partial which represents the 'submitCartRequest' element.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Xml_Partial
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Xml_Request_SubmitCartRequest extends Dhl_MeinPaket_Model_Xml_AbstractXmlRequest {
13
+ /**
14
+ * Default Constructor.
15
+ */
16
+ public function __construct() {
17
+ parent::__construct ();
18
+ }
19
+
20
+ /**
21
+ * Create the root element for the document.
22
+ *
23
+ * @return DOMNode
24
+ */
25
+ public function createDocumentElement() {
26
+ $this->node = $this->getDocument ()->createElement ( 'submitCartRequest' );
27
+ $this->node->setAttribute ( 'xmlns', self::XMLNS_CHECKOUT );
28
+ $this->node->setAttribute ( 'xmlns:common', self::XMLNS_COMMON );
29
+ $this->node->setAttribute ( 'version', '1.0' );
30
+ $this->getDocument ()->appendChild ( $this->node );
31
+ }
32
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Request/UploadRequest.php ADDED
@@ -0,0 +1,432 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Represents the XML structure of an <uploadRequest> element.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Xml_Partial
9
+ * @subpackage Dhl_MeinPaket_Model_Xml_Partial
10
+ */
11
+ class Dhl_MeinPaket_Model_Xml_Request_UploadRequest extends Dhl_MeinPaket_Model_Xml_AbstractXmlRequest {
12
+ /**
13
+ *
14
+ * @var DOMNode
15
+ */
16
+ protected $productDescriptions = null;
17
+ /**
18
+ *
19
+ * @var DOMNode
20
+ */
21
+ protected $offers = null;
22
+ /**
23
+ *
24
+ * @var DOMNode
25
+ */
26
+ protected $variantGroups = null;
27
+ /**
28
+ *
29
+ * @var DOMNode
30
+ */
31
+ protected $trackingNumbers = null;
32
+ /**
33
+ *
34
+ * @var DOMNode
35
+ */
36
+ protected $categories = null;
37
+ /**
38
+ *
39
+ * @var DOMNode
40
+ */
41
+ protected $deletions = null;
42
+
43
+ /**
44
+ *
45
+ * @var Dhl_MeinPaket_Helper_Product
46
+ */
47
+ protected $productHelper = null;
48
+
49
+ /**
50
+ * Default Constructor.
51
+ */
52
+ public function __construct() {
53
+ parent::__construct ();
54
+ $this->productHelper = Mage::helper ( 'meinpaket/product' );
55
+ }
56
+
57
+ /**
58
+ * Create the root element for the document.
59
+ *
60
+ * @return DOMNode
61
+ */
62
+ public function createDocumentElement() {
63
+ $this->node = $this->getDocument ()->createElement ( 'uploadRequest' );
64
+ $this->node->setAttribute ( 'xmlns', self::XMLNS_PRODUCTS );
65
+ $this->node->setAttribute ( 'xmlns:common', self::XMLNS_COMMON );
66
+ $this->node->setAttribute ( 'version', '1.0' );
67
+ $this->getDocument ()->appendChild ( $this->node );
68
+ }
69
+
70
+ /**
71
+ *
72
+ * @param Mage_Catalog_Model_Product $product
73
+ * @return DOMNode|Ambigous <boolean, DOMElement>
74
+ */
75
+ public function addProductDescription(Mage_Catalog_Model_Product $product) {
76
+ switch ($product->getTypeId ()) {
77
+ case Mage_Catalog_Model_Product_Type::TYPE_SIMPLE :
78
+ return $this->handleSimpleProduct ( $product );
79
+ case Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE :
80
+ return $this->handleConfigurableProduct ( $product );
81
+ default :
82
+ Mage::log ( 'Unhandled typeId ' . $product->getTypeId () );
83
+ }
84
+ }
85
+
86
+ /**
87
+ *
88
+ * @param Mage_Catalog_Model_Product $product
89
+ * @return DOMElement
90
+ */
91
+ public function addOffer(Mage_Catalog_Model_Product $product) {
92
+ $offer = $this->getDocument ()->createElement ( 'productOffer' );
93
+
94
+ // product id
95
+ $offer->appendChild ( $this->getDocument ()->createElement ( 'common:productId', $product->getId () ) );
96
+
97
+ // ean
98
+ $ean = Mage::helper ( 'meinpaket/product' )->getEan ( $product );
99
+ if (! empty ( $ean )) {
100
+ $offer->appendChild ( $this->getDocument ()->createElement ( 'common:ean', $ean ) );
101
+ }
102
+
103
+ // manufacturer
104
+ $manufacturer = $product->getAttributeText ( 'manufacturer' );
105
+ if (! empty ( $manufacturer )) {
106
+ $offer->appendChild ( $this->getCDATANode ( 'common:manufacturerName', $manufacturer ) );
107
+ }
108
+
109
+ // price
110
+ $offer->appendChild ( $this->getDocument ()->createElement ( 'price', $product->getPrice () ) );
111
+
112
+ // tax group
113
+ $taxGroup = $this->productHelper->getMeinPaketTaxGroup ( $product );
114
+ $offer->appendChild ( $this->getDocument ()->createElement ( 'taxGroup', $taxGroup ) );
115
+
116
+ // availability
117
+ $availability = $this->productHelper->getMeinPaketStock ( $product );
118
+ $offer->appendChild ( $this->getDocument ()->createElement ( 'availability', $availability ) );
119
+
120
+ // abuse enddate for activation and deactivation
121
+ // $offer->appendChild ( $this->getDocument ()->createElement ( 'endDate', $this->getIsoDateTime ( now () ) ) );
122
+
123
+ // deliverytime
124
+ $deliveryTime = $this->productHelper->getMeinPaketDeliveryTime ( $product );
125
+ if ($deliveryTime !== false) {
126
+ $offer->appendChild ( $this->getDocument ()->createElement ( 'deliverytime', $deliveryTime ) );
127
+ }
128
+
129
+ $this->getOffers ()->appendChild ( $offer );
130
+
131
+ $this->setHasData ();
132
+
133
+ return $offer;
134
+ }
135
+ public function removeProduct(Mage_Catalog_Model_Product $product) {
136
+ if ($product->getData ( 'meinpaket_id' )) {
137
+ /* @var $productDeletion DOMNode */
138
+ $productDeletionNode = $this->getDocument ()->createElement ( 'productDeletion' );
139
+ $this->getDeletions ()->appendChild ( $productDeletionNode );
140
+ $productDeletionNode->appendChild ( $this->getDocument ()->createElement ( 'common:productId', $product->getId () ) );
141
+ }
142
+ }
143
+ public function addCategory(Mage_Catalog_Model_Product $product) {
144
+ $productDescriptions = Mage::getModel ( 'meinpaket/xml_partial_productDescriptions', $this->getDocument () );
145
+
146
+ /* @var $offers Dhl_MeinPaket_Model_Xml_Partial_Offers */
147
+ $offers = Mage::getModel ( 'meinpaket/xml_partial_offers' );
148
+ }
149
+ public function removeCategory(Mage_Catalog_Model_Product $product) {
150
+ }
151
+ protected function getProductDescriptions() {
152
+ if ($this->productDescriptions == null) {
153
+ $this->productDescriptions = $this->getDocument ()->createElement ( 'descriptions' );
154
+ $this->getDocumentElement ()->appendChild ( $this->productDescriptions );
155
+ }
156
+ return $this->productDescriptions;
157
+ }
158
+
159
+ /**
160
+ *
161
+ * @return DOMElement
162
+ */
163
+ protected function getOffers() {
164
+ if ($this->offers == null) {
165
+ $this->offers = $this->getDocument ()->createElement ( 'offers' );
166
+ $this->getDocumentElement ()->appendChild ( $this->offers );
167
+ }
168
+ return $this->offers;
169
+ }
170
+
171
+ /**
172
+ *
173
+ * @return DOMElement
174
+ */
175
+ protected function getVariantGroups() {
176
+ if ($this->variantGroups == null) {
177
+ $this->variantGroups = $this->getDocument ()->createElement ( 'variantGroups' );
178
+ $this->getDocumentElement ()->appendChild ( $this->variantGroups );
179
+ }
180
+ return $this->variantGroups;
181
+ }
182
+
183
+ /**
184
+ *
185
+ * @return DOMElement
186
+ */
187
+ protected function getTrackingNumbers() {
188
+ if ($this->trackingNumbers == null) {
189
+ $this->trackingNumbers = $this->getDocument ()->createElement ( 'trackingNumbers' );
190
+ $this->getDocumentElement ()->appendChild ( $this->trackingNumbers );
191
+ }
192
+ return $this->trackingNumbers;
193
+ }
194
+
195
+ /**
196
+ *
197
+ * @return DOMElement
198
+ */
199
+ protected function getCategories() {
200
+ if ($this->categories == null) {
201
+ $this->categories = $this->getDocument ()->createElement ( 'categories' );
202
+ $this->getDocumentElement ()->appendChild ( $this->categories );
203
+ }
204
+ return $this->categories;
205
+ }
206
+
207
+ /**
208
+ *
209
+ * @return DOMElement
210
+ */
211
+ protected function getDeletions() {
212
+ if ($this->deletions == null) {
213
+ $this->deletions = $this->getDocument ()->createElement ( 'deletions' );
214
+ $this->getDocumentElement ()->appendChild ( $this->deletions );
215
+ }
216
+ return $this->deletions;
217
+ }
218
+
219
+ /**
220
+ * Export a single simple product.
221
+ *
222
+ * @param Mage_Catalog_Model_Product $product
223
+ * to be exported
224
+ * @param string $variantGroup
225
+ * the product belongs to if available
226
+ * @throws Dhl_MeinPaket_Model_Exception_InvalidDataException
227
+ * @throws Dhl_MeinPaket_Model_Exception_MissingDataException
228
+ * @return DOMNode
229
+ */
230
+ protected function handleSimpleProduct(Mage_Catalog_Model_Product $product, Mage_Catalog_Model_Product $configurableProduct = null) {
231
+ if ($configurableProduct == null) {
232
+ $type = Mage::getModel ( 'catalog/product_type_configurable' );
233
+ $parentIdArray = $type->getParentIdsByChild ( $product->getId () );
234
+ if (isset ( $parentIdArray [0] )) {
235
+ $configurableProduct = Mage::getModel ( 'catalog/product' )->load ( $parentIdArray [0] );
236
+ }
237
+ }
238
+
239
+ if (! $product->getData ( 'sync_with_dhl_mein_paket' ) && $configurableProduct == null) {
240
+ /* @var $productDeletion DOMNode */
241
+ $productDeletion = $this->getDocument ()->createElement ( 'productDeletion' );
242
+ $this->getDeletions ()->appendChild ( $productDeletion );
243
+ $pId = $this->getDocument ()->createElement ( 'common:productId', $product->getId () );
244
+ // TODO:
245
+ // $productDeletion->appendChild ( $pId );
246
+ return false;
247
+ }
248
+
249
+ /* @var $productDescription DOMNode */
250
+ $productDescription = $this->getDocument ()->createElement ( 'productDescription' );
251
+ $variantInfo = null;
252
+
253
+ // product id
254
+ $productId = $this->getDocument ()->createElement ( 'common:productId', $product->getId () );
255
+ $productDescription->appendChild ( $productId );
256
+
257
+ // ean (optional)
258
+ $ean = Mage::helper ( 'meinpaket/product' )->getEan ( $product );
259
+ if (! empty ( $ean )) {
260
+ $productDescription->appendChild ( $this->getDocument ()->createElement ( 'common:ean', $ean ) );
261
+ }
262
+
263
+ // manufacturer
264
+ $manufacturer = $product->getAttributeText ( 'manufacturer' );
265
+ if (! empty ( $manufacturer )) {
266
+ $productDescription->appendChild ( $this->getCDATANode ( 'common:manufacturerName', $manufacturer ) );
267
+ }
268
+
269
+ if ($configurableProduct != NULL) {
270
+ $variantGroupInfoNode = $this->getDocument ()->createElement ( "variantGroupInfo" );
271
+ $variantGroupInfoNode->setAttribute ( "code", $configurableProduct->getId () );
272
+ $productDescription->appendChild ( $variantGroupInfoNode );
273
+ }
274
+
275
+ // name
276
+ if (strlen ( $product->getName () ) > 0) {
277
+ $productDescription->appendChild ( $this->getCDATANode ( 'name', $product->getName () ) );
278
+ } else {
279
+ throw new Dhl_MeinPaket_Model_Exception_InvalidDataException ( $product->getId (), 'name' );
280
+ }
281
+
282
+ // shortdescription
283
+ if (strlen ( $product->getShortDescription () ) > 0) {
284
+ $shortDescription = $this->escapeStringForMeinPaket ( $product->getShortDescription () );
285
+ $productDescription->appendChild ( $this->getCDATANode ( 'shortDescription', $shortDescription ) );
286
+ } else {
287
+ throw new Dhl_MeinPaket_Model_Exception_MissingDataException ( $product->getId (), 'short_description' );
288
+ }
289
+
290
+ // long description (optional) && (strlen > 0)
291
+ if (strlen ( $product->getDescription () ) > 0) {
292
+ $description = $this->escapeStringForMeinPaket ( $product->getDescription () );
293
+ $productDescription->appendChild ( $this->getCDATANode ( 'longDescription', $description ) );
294
+ }
295
+
296
+ // Export images
297
+ $images = $product->getMediaGalleryImages ();
298
+ if ($images != null) {
299
+ foreach ( $images as $image ) {
300
+ $smallOrImage = false;
301
+
302
+ if ($image->getDisabled ()) {
303
+ continue;
304
+ }
305
+
306
+ $imageNode = $this->getDocument ()->createElement ( "image" );
307
+ $productDescription->appendChild ( $imageNode );
308
+ $imageNode->appendChild ( $this->getDocument ()->createElement ( "url", $image->getUrl () ) );
309
+
310
+ $label = $image->getLabel ();
311
+ if (! empty ( $label )) {
312
+ $imageNode->appendChild ( $this->getDocument ()->createElement ( "caption", $image->getLabel () ) );
313
+ }
314
+ }
315
+ }
316
+
317
+ // marketplace category
318
+ $meinpaketCategory = $product->getData ( 'meinpaket_category' );
319
+ if (strlen ( $meinpaketCategory ) > 0) {
320
+ $mNode = $this->getDocument ()->createElement ( 'marketplaceCategory' );
321
+ $mNode->setAttribute ( 'code', $meinpaketCategory );
322
+ $productDescription->appendChild ( $mNode );
323
+ } else {
324
+ throw new Dhl_MeinPaket_Model_Exception_MissingDataException ( $product->getId (), 'dhl_marketplace_category_id' );
325
+ }
326
+
327
+ $this->exportAttributes ( $product, $productDescription, $configurableProduct );
328
+ $this->getProductDescriptions ()->appendChild ( $productDescription );
329
+ $this->addOffer ( $product );
330
+
331
+ $this->setHasData ();
332
+
333
+ return $productDescription;
334
+ }
335
+
336
+ /**
337
+ * Export product attributes.
338
+ */
339
+ protected function exportAttributes(Mage_Catalog_Model_Product $product, DOMNode $node, Mage_Catalog_Model_Product $configurableProduct = null) {
340
+ $configurableAttributes = array ();
341
+
342
+ if ($configurableProduct != null) {
343
+ foreach ( $configurableProduct->getTypeInstance ( true )->getConfigurableAttributes ( $configurableProduct ) as $attr ) {
344
+ $configurableAttributes [] = $attr->getProductAttribute ()->getAttributeCode ();
345
+ }
346
+ }
347
+
348
+ foreach ( $product->getAttributes () as $attribute ) {
349
+ /* @var $attribute Mage_Eav_Model_Attribute */
350
+
351
+ $isConfigurable = in_array ( $attribute->getAttributeCode (), $configurableAttributes );
352
+
353
+ if (strlen ( $attribute->getMeinpaketAttribute () ) <= 0 || $attribute->getMeinpaketAttribute () == 'None') {
354
+ continue;
355
+ }
356
+
357
+ $productValue = $product->getData ( $attribute->getAttributeCode () );
358
+
359
+ if ($attribute->isValueEmpty ( $productValue ) || empty ( $productValue )) {
360
+ continue;
361
+ }
362
+
363
+ $frontendValue = $attribute->getFrontend ()->getValue ( $product );
364
+
365
+ if (empty ( $frontendValue )) {
366
+ continue;
367
+ }
368
+
369
+ $storeLabel = $attribute->getFrontendLabel ();
370
+
371
+ if (strlen ( $storeLabel ) <= 0) {
372
+ continue;
373
+ }
374
+
375
+ $attributeNode = $this->getDocument ()->createElement ( "attribute" );
376
+ if ($isConfigurable) {
377
+ $attributeNode->setAttribute ( "variant", "true" );
378
+ }
379
+ $attributeNode->setAttribute ( "code", $attribute->getMeinpaketAttribute () == 'Default' ? $attribute->getAttributeCode () : $attribute->getMeinpaketAttribute () );
380
+
381
+ $nameNode = $this->getDocument ()->createElement ( "name", $storeLabel );
382
+ $attributeNode->appendChild ( $nameNode );
383
+ $valueNode = $this->getDocument ()->createElement ( "value", $frontendValue );
384
+ $attributeNode->appendChild ( $valueNode );
385
+
386
+ $node->appendChild ( $attributeNode );
387
+ }
388
+ }
389
+
390
+ /**
391
+ * Export a configurable product.
392
+ *
393
+ * @param Mage_Catalog_Model_Product $product
394
+ */
395
+ protected function handleConfigurableProduct(Mage_Catalog_Model_Product $product) {
396
+ if (! $product->getData ( 'sync_with_dhl_mein_paket' )) {
397
+ /* @var $productDescription DOMNode */
398
+ $productDeletion = $this->getDocument ()->createElement ( 'productDeletion' );
399
+ $this->getDeletions ()->appendChild ( $productDeletion );
400
+ $pId = $this->getDocument ()->createElement ( 'common:productId', $product->getId () );
401
+ $productDeletion->appendChild ( $pId );
402
+ return false;
403
+ }
404
+
405
+ if ($product->getTypeId () != Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
406
+ return false;
407
+ }
408
+
409
+ $typeInstance = $product->getTypeInstance ( true );
410
+ $configurableType = $typeInstance->setProduct ( $product );
411
+ $variantGroupNode = null;
412
+
413
+ $variantGroupNode = $this->getDocument ()->createElement ( "variantGroup" );
414
+ $variantGroupNode->setAttribute ( "code", $product->getId () );
415
+ // $this->getVariantGroups ()->appendChild ( $variantGroupNode );
416
+
417
+ /*
418
+ * $configurationNode = $this->getDocument ()->createElement ( "configuration" ); $variantGroupNode->appendChild ( $configurationNode ); $configurationNode->setAttribute ( "code", $variantMapping->getMeinpaketVariantId () );
419
+ */
420
+
421
+ $titleNode = $this->getDocument ()->createElement ( "title" );
422
+ $variantGroupNode->appendChild ( $titleNode );
423
+ $titleNode->appendChild ( $this->getDocument ()->createTextNode ( $product->getName () ) );
424
+
425
+ $simpleCollection = $configurableType->getUsedProductCollection ()->addAttributeToSelect ( '*' )->addFilterByRequiredOptions ();
426
+ foreach ( $simpleCollection as $simpleProduct ) {
427
+ $this->handleSimpleProduct ( $simpleProduct, $product );
428
+ }
429
+
430
+ return $variantGroupNode;
431
+ }
432
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/Abstract.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Result class which keeps information
5
+ *
6
+ * @category Mage
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Service
9
+ * @version $Id$
10
+ */
11
+ abstract class Dhl_MeinPaket_Model_Xml_Response_Abstract {
12
+
13
+ /**
14
+ *
15
+ * @var array
16
+ */
17
+ protected $commonErrors = array ();
18
+
19
+ /**
20
+ * domElement this class represents.
21
+ *
22
+ * @var DOMElement
23
+ */
24
+ protected $domElement;
25
+
26
+ /**
27
+ *
28
+ * @param DOMElement $domElement
29
+ */
30
+ public function __construct(DOMElement $domElement) {
31
+ $this->domElement = $domElement;
32
+ foreach ( $domElement->childNodes as $child ) {
33
+ if ($child->localName == 'error') {
34
+ $code = null;
35
+ $message = null;
36
+ $object = null;
37
+ foreach ( $child->childNodes as $errorChild ) {
38
+ switch ($errorChild->localName) {
39
+ case 'categoryDeletion' :
40
+ case 'category' :
41
+ $object = $errorChild->getAttribute ( 'code' );
42
+ break;
43
+ case 'productDeletion' :
44
+ case 'productDescription' :
45
+ case 'productOffer' :
46
+ $object = new Dhl_MeinPaket_Model_Xml_Response_Partial_ProductId ( $errorChild );
47
+ break;
48
+ case 'internationalPrice' :
49
+ case 'internationalPriceDeletion' :
50
+ $productId = null;
51
+ $location = null;
52
+
53
+ foreach ( $errorChild->childNodes as $internationalPriceError ) {
54
+ switch ($internationalPriceError->localName) {
55
+ case 'productId' :
56
+ $productId = $internationalPriceError->nodeValue;
57
+ break;
58
+ case 'country' :
59
+ $location = $internationalPriceError->nodeValue;
60
+ break;
61
+ case 'deliveryZone' :
62
+ $location = $internationalPriceError->getAttribute ( 'name' );
63
+ break;
64
+ }
65
+ }
66
+
67
+ $object = $productId . ' ' . $location;
68
+ break;
69
+ case 'variantGroup' :
70
+ $object = $errorChild->getAttribute ( 'code' );
71
+ break;
72
+ case 'error-code' :
73
+ $code = $errorChild->nodeValue;
74
+ break;
75
+ case 'error-message' :
76
+ $message = $errorChild->nodeValue;
77
+ break;
78
+ }
79
+ }
80
+ $this->addCommonError ( $code, $message, $object );
81
+ }
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Adds a common error which is not product related.
87
+ *
88
+ * @param string $code
89
+ * @param string $message
90
+ * @param string $object
91
+ */
92
+ public function addCommonError($code, $message, $object = null) {
93
+ // check if error already exists
94
+ if (sizeof ( $this->commonErrors ) > 0) {
95
+ foreach ( $this->commonErrors as $error ) {
96
+ if ($error ['code'] === $code && $error ['message'] === $message && $error ['object'] == $object) {
97
+ return;
98
+ }
99
+ }
100
+ }
101
+
102
+ // add error
103
+ $this->commonErrors [] = array (
104
+ 'code' => $code,
105
+ 'message' => $message,
106
+ 'object' => $object
107
+ );
108
+ }
109
+
110
+ /**
111
+ *
112
+ * @return boolean
113
+ */
114
+ public function hasErrors() {
115
+ return (sizeof ( $this->commonErrors ) > 0);
116
+ }
117
+
118
+ /**
119
+ * Returns an array of common (not product related) errors.
120
+ * The elements of result array have the following structure:
121
+ * [
122
+ * 'code' => '...',
123
+ * 'message' => '...'
124
+ * ]
125
+ *
126
+ * @return array
127
+ */
128
+ public function getCommonErrors() {
129
+ return $this->commonErrors;
130
+ }
131
+
132
+ /**
133
+ * Return error messages as string.
134
+ *
135
+ * @return string
136
+ */
137
+ public function getErrorString() {
138
+ $result = "";
139
+ foreach ( $this->commonErrors as $message ) {
140
+ $result = $message ['object'] . " " . $message ['message'] . " " . $message ['code'] . "\n";
141
+ }
142
+ return $result;
143
+ }
144
+
145
+ /**
146
+ * Process response
147
+ */
148
+ public function process() {
149
+ }
150
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/AsynchronousStatusResponse.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Xml_Response_AsynchronousStatusResponse extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
3
+ private $requestId;
4
+ private $status;
5
+ public function __construct(DOMElement $domElement) {
6
+ parent::__construct ( $domElement );
7
+ assert ( $domElement->localName == 'asynchronousStatusResponse' );
8
+
9
+ foreach ( $domElement->childNodes as $asynchronousStatusResponseNodes ) {
10
+ switch ($asynchronousStatusResponseNodes->localName) {
11
+ case 'getRequestStatusResponse' :
12
+ foreach ( $asynchronousStatusResponseNodes->childNodes as $getRequestStatusResponseNode ) {
13
+ switch ($getRequestStatusResponseNode->localName) {
14
+ case 'requestId' :
15
+ $this->requestId = $getRequestStatusResponseNode->nodeValue;
16
+ break;
17
+ case 'status' :
18
+ $this->status = $getRequestStatusResponseNode->nodeValue;
19
+ break;
20
+ }
21
+ }
22
+ break;
23
+ }
24
+ }
25
+ }
26
+ public function setRequestId(string $requestId) {
27
+ $this->requestId = $requestId;
28
+ }
29
+ public function getRequestId() {
30
+ return $this->requestId;
31
+ }
32
+ public function setStatus(string $status) {
33
+ $this->status = $status;
34
+ }
35
+ public function getStatus() {
36
+ return $this->status;
37
+ }
38
+
39
+ /**
40
+ * Parses the response of a sync request
41
+ *
42
+ * @return Dhl_MeinPaket_Model_Xml_Response_AsynchronousStatusResponse
43
+ */
44
+ public function createOrUpdateAsync() {
45
+ /* @var $request Dhl_MeinPaket_Model_Async */
46
+ $request = Mage::getModel ( 'meinpaket/async' )->load ( $this->requestId, 'request_id' );
47
+ $request->setCreatedAt ( Varien_Date::now() );
48
+ $request->setUpdatedAt ( Varien_Date::now() );
49
+ $request->setRequestId ( $this->requestId );
50
+ $request->setStatus ( $this->status );
51
+ $request->save ();
52
+
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * Process response
58
+ */
59
+ public function process() {
60
+ $this->createOrUpdateAsync();
61
+ }
62
+
63
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/DataResponse.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Xml_Response_DataResponse extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
3
+ private $confirmations = array ();
4
+ private $bestPrices = array ();
5
+ private $productData = array ();
6
+ private $merchantData = array ();
7
+ private $quotaData = array ();
8
+
9
+ /**
10
+ * Default constructor.
11
+ *
12
+ * @param DOMElement $domElement
13
+ */
14
+ public function __construct(DOMElement $domElement) {
15
+ parent::__construct ( $domElement );
16
+ assert ( $domElement->localName == 'dataResponse' );
17
+
18
+ foreach ( $domElement->childNodes as $downloadResponseEntries ) {
19
+ switch ($downloadResponseEntries->localName) {
20
+ case 'confirmation' :
21
+ $this->confirmations [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_DataResponse_Confirmation ( $downloadResponseEntries );
22
+ break;
23
+ case 'bestPrice' :
24
+ $this->bestPrices [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_DataResponse_BestPrice ( $downloadResponseEntries );
25
+ break;
26
+ case 'productData' :
27
+ $this->productData [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_DataResponse_ProductData ( $downloadResponseEntries );
28
+ break;
29
+ case 'merchantData' :
30
+ $this->merchantData [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_DataResponse_MerchantData ( $downloadResponseEntries );
31
+ break;
32
+ case 'quotaData' :
33
+ $this->quotaData [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_DataResponse_QuotaData ( $downloadResponseEntries );
34
+ break;
35
+ }
36
+ }
37
+ }
38
+
39
+ /**
40
+ *
41
+ * @return array
42
+ */
43
+ public function getConfirmations() {
44
+ return $this->confirmations;
45
+ }
46
+
47
+ /**
48
+ *
49
+ * @return array
50
+ */
51
+ public function getBestPrices() {
52
+ return $this->bestPrices;
53
+ }
54
+
55
+ /**
56
+ *
57
+ * @return array
58
+ */
59
+ public function getProductData() {
60
+ return $this->productData;
61
+ }
62
+
63
+ /**
64
+ *
65
+ * @return array
66
+ */
67
+ public function getMerchantData() {
68
+ return $this->merchantData;
69
+ }
70
+
71
+ /**
72
+ *
73
+ * @return array
74
+ */
75
+ public function getQuotaData() {
76
+ return $this->quotaData;
77
+ }
78
+ public function process() {
79
+ $transaction = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_write' );
80
+
81
+ try {
82
+ $transaction->beginTransaction ();
83
+ /* @var $bestPrice Dhl_MeinPaket_Model_Xml_Response_Partial_DataResponse_BestPrice */
84
+
85
+ foreach ( $this->bestPrices as $bestPrice ) {
86
+ if (count ( $bestPrice->getCommonErrors () )) {
87
+ continue;
88
+ }
89
+
90
+ $collection = Mage::getModel ( 'meinpaket/bestPrice' )->getCollection ();
91
+ foreach ( $collection->getItems () as $price ) {
92
+ $price->delete ();
93
+ }
94
+
95
+ /* @var $bestPriceModel Dhl_MeinPaket_Model_BestPrice */
96
+ $bestPriceModel = Mage::getModel ( 'meinpaket/bestPrice' );
97
+ $bestPriceModel->setProductId ( $bestPrice->getProductId () );
98
+ $bestPriceModel->setPrice ( $bestPrice->getPrice () );
99
+ $bestPriceModel->setPriceCurrency ( $bestPrice->getPriceCurrency () );
100
+ $bestPriceModel->setDeliveryCost ( $bestPrice->getDeliveryCost () );
101
+ $bestPriceModel->setDeliveryCostCurrency ( $bestPrice->getDeliveryCostCurrency () );
102
+ $bestPriceModel->setDeliveryTime ( $bestPrice->getDeliveryTime () );
103
+ $bestPriceModel->setActiveOffers ( $bestPrice->getActiveOffers () );
104
+ $bestPriceModel->setOwnership ( $bestPrice->getOwnership () );
105
+ $bestPriceModel->setOwningDealerCode ( $bestPrice->getOwningDealerCode () );
106
+ $bestPriceModel->setCreatedAt ( Varien_Date::now () );
107
+ $bestPriceModel->save ();
108
+ }
109
+ $transaction->commit ();
110
+ } catch ( Exception $e ) {
111
+ $transaction->rollback ();
112
+ Mage::logException ( $e );
113
+ throw $e;
114
+ }
115
+ }
116
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/DownloadResponse.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Xml_Response_DownloadResponse extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
3
+ private $categories = array ();
4
+ private $productOffers = array ();
5
+ private $variantConfigurations = array ();
6
+ public function __construct(DOMElement $domElement) {
7
+ parent::__construct ( $domElement );
8
+ assert ( $domElement->localName == 'downloadResponse' );
9
+
10
+ foreach ( $domElement->childNodes as $downloadResponseEntries ) {
11
+ switch ($downloadResponseEntries->localName) {
12
+ case 'category' :
13
+ $this->categories [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_Category ( $downloadResponseEntries );
14
+ break;
15
+ case 'productOffers' :
16
+ // $this->productOfferConfirmations [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_ProductId ( $downloadResponseEntries );
17
+ break;
18
+ case 'variantConfiguration' :
19
+ $this->variantConfigurations [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_VariantConfiguration ( $downloadResponseEntries );
20
+ break;
21
+ }
22
+ }
23
+ }
24
+
25
+ /**
26
+ *
27
+ * @return array
28
+ */
29
+ public function getCategories() {
30
+ return $this->categories;
31
+ }
32
+ /**
33
+ *
34
+ * @return array
35
+ */
36
+ public function getProductOffers() {
37
+ return $this->productOffers;
38
+ }
39
+ /**
40
+ *
41
+ * @return array
42
+ */
43
+ public function getVariantConfigurations() {
44
+ return $this->variantConfigurations;
45
+ }
46
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/NotificationResponse.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Xml_Response_NotificationResponse extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
3
+ private $confirmations = array ();
4
+
5
+ /**
6
+ * Default constructor.
7
+ *
8
+ * @param DOMElement $domElement
9
+ */
10
+ public function __construct(DOMElement $domElement) {
11
+ parent::__construct ( $domElement );
12
+ assert ( $domElement->localName == 'notificationResponse' );
13
+
14
+ foreach ( $domElement->childNodes as $notificationResponseEntries ) {
15
+ switch ($notificationResponseEntries->localName) {
16
+ case 'confirmation' :
17
+ $this->confirmations [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_NotificationResponse_Confirmation ( $notificationResponseEntries );
18
+ break;
19
+ }
20
+ }
21
+ }
22
+
23
+ /**
24
+ *
25
+ * @return array
26
+ */
27
+ public function getConfirmations() {
28
+ return $this->confirmations;
29
+ }
30
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/Address.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Xml_Response_Partial_Address extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
3
+ /**
4
+ * Salutation.
5
+ *
6
+ * @var string
7
+ */
8
+ private $salutation;
9
+ /**
10
+ * Company.
11
+ *
12
+ * @var string
13
+ */
14
+ private $company;
15
+ /**
16
+ * First name.
17
+ *
18
+ * @var string
19
+ */
20
+ private $firstName;
21
+ /**
22
+ * Last name.
23
+ *
24
+ * @var string
25
+ */
26
+ private $lastName;
27
+ /**
28
+ * Street.
29
+ *
30
+ * @var string
31
+ */
32
+ private $street;
33
+ /**
34
+ * Used for house number or packstationId.
35
+ *
36
+ * @var string
37
+ */
38
+ private $houseNumber;
39
+ /**
40
+ * Used for addressAddition.
41
+ *
42
+ * @var string
43
+ */
44
+ private $addressAddition;
45
+ /**
46
+ * Used for customerId.
47
+ *
48
+ * @var string
49
+ */
50
+ private $customerId;
51
+ /**
52
+ * Zip code.
53
+ *
54
+ * @var string
55
+ */
56
+ private $zipCode;
57
+ /**
58
+ * City.
59
+ *
60
+ * @var string
61
+ */
62
+ private $city;
63
+ /**
64
+ * Country.
65
+ *
66
+ * @var string
67
+ */
68
+ private $country;
69
+
70
+ /**
71
+ * Default constructor.
72
+ *
73
+ * @param DOMElement $domElement
74
+ */
75
+ public function __construct(DOMElement $domElement) {
76
+ parent::__construct ( $domElement );
77
+ assert ( $domElement->localName == 'deliveryAddress' || $domElement->localName == 'billingAddress' );
78
+
79
+ foreach ( $domElement->childNodes as $childNode ) {
80
+ switch ($childNode->localName) {
81
+ case 'salutation' :
82
+ $this->salutation = $childNode->nodeValue;
83
+ break;
84
+ case 'company' :
85
+ $this->company = $childNode->nodeValue;
86
+ break;
87
+ case 'firstName' :
88
+ $this->firstName = $childNode->nodeValue;
89
+ break;
90
+ case 'lastName' :
91
+ $this->lastName = $childNode->nodeValue;
92
+ break;
93
+ case 'street' :
94
+ $this->street = $childNode->nodeValue;
95
+ break;
96
+ case 'houseNumber' :
97
+ $this->houseNumber = $childNode->nodeValue;
98
+ break;
99
+ case 'addressAddition' :
100
+ $this->addressAddition = $childNode->nodeValue;
101
+ break;
102
+ case 'zipCode' :
103
+ $this->zipCode = $childNode->nodeValue;
104
+ break;
105
+ case 'city' :
106
+ $this->city = $childNode->nodeValue;
107
+ break;
108
+ case 'country' :
109
+ $this->country = $childNode->nodeValue;
110
+ break;
111
+ case 'packstationId' :
112
+ $this->street = 'Packstation';
113
+ $this->houseNumber = $childNode->nodeValue;
114
+ break;
115
+ case 'customerId' :
116
+ $this->customerId = $childNode->nodeValue;
117
+ break;
118
+ }
119
+ }
120
+ }
121
+ public function getSalutation() {
122
+ return $this->salutation;
123
+ }
124
+ public function getCompany() {
125
+ return $this->company;
126
+ }
127
+ public function getFirstName() {
128
+ return $this->firstName;
129
+ }
130
+ public function getLastName() {
131
+ return $this->lastName;
132
+ }
133
+ public function getStreet() {
134
+ return $this->street;
135
+ }
136
+ public function getHouseNumber() {
137
+ return $this->houseNumber;
138
+ }
139
+ public function getAddressAddition() {
140
+ return $this->addressAddition;
141
+ }
142
+ public function getZipCode() {
143
+ return $this->zipCode;
144
+ }
145
+ public function getCity() {
146
+ return $this->city;
147
+ }
148
+ public function getCountry() {
149
+ return $this->country;
150
+ }
151
+ public function getCustomerId() {
152
+ return $this->customerId;
153
+ }
154
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/Attribute.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Xml_Response_Partial_Attribute extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
3
+ private $code;
4
+ private $name;
5
+ private $variantAtributeValues = array ();
6
+ public function __construct(DOMElement $domElement) {
7
+ parent::__construct ( $domElement );
8
+ // assert ( $domElement->localName == 'variantConfiguration' );
9
+
10
+ $this->code = $domElement->getAttribute ( "code" );
11
+
12
+ foreach ( $domElement->childNodes as $childNode ) {
13
+ switch ($childNode->localName) {
14
+ case 'name' :
15
+ $this->name = $childNode->nodeValue;
16
+ break;
17
+ case 'requiredAttribute' :
18
+ $this->variantAtributeValues [] = array (
19
+ 'value' => $childNode->getAttribute ( 'value' ),
20
+ 'unit' => $childNode->getAttribute ( 'unit' )
21
+ );
22
+ break;
23
+ }
24
+ }
25
+ }
26
+ public function getCode() {
27
+ return $this->code;
28
+ }
29
+ public function getName() {
30
+ return $this->name;
31
+ }
32
+ public function getVariantAtributeValues() {
33
+ return $this->variantAtributeValues;
34
+ }
35
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/Category.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Xml_Response_Partial_Category extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
3
+ private $code;
4
+ private $name;
5
+ private $shortDescription;
6
+ private $parent;
7
+ private $deprecated;
8
+ public function __construct(DOMElement $domElement) {
9
+ parent::__construct ( $domElement );
10
+ assert ( $domElement->localName == 'category' );
11
+
12
+ $this->code = $domElement->getAttribute ( "code" );
13
+
14
+ foreach ( $domElement->childNodes as $childNode ) {
15
+ switch ($childNode->localName) {
16
+ case 'name' :
17
+ $this->name = $childNode->nodeValue;
18
+ break;
19
+ case 'shortDescription' :
20
+ $this->shortDescription = $childNode->nodeValue;
21
+ break;
22
+ case 'parent' :
23
+ $this->parent = $childNode->getAttribute ( "code" );
24
+ break;
25
+ case 'deprecated' :
26
+ $this->deprecated = $childNode->nodeValue == "true";
27
+ break;
28
+ }
29
+ }
30
+ }
31
+ public function getCode() {
32
+ return $this->code;
33
+ }
34
+ public function getName() {
35
+ return $this->name;
36
+ }
37
+ public function getShortDescription() {
38
+ return $this->shortDescription;
39
+ }
40
+ public function getParent() {
41
+ return $this->parent;
42
+ }
43
+ public function getDeprecated() {
44
+ return $this->deprecated;
45
+ }
46
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/CategoryId.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Xml_Response_Partial_CategoryId extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
3
+ private $categoryCode;
4
+ public function __construct(DOMElement $domElement) {
5
+ parent::__construct ( $domElement );
6
+ $this->categoryCode = $domElement->getAttribute ( 'code' );
7
+ }
8
+ public function getCategoryCode() {
9
+ return $this->productCode;
10
+ }
11
+
12
+ /**
13
+ * Return string for this object.
14
+ *
15
+ * @return string
16
+ */
17
+ public function __toString() {
18
+ return $this->categoryCode;
19
+ }
20
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/DataResponse/BestPrice.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @author stephan
6
+ *
7
+ */
8
+ class Dhl_MeinPaket_Model_Xml_Response_Partial_DataResponse_BestPrice extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
9
+ const OwNERSHIP_OWN = "OWN";
10
+ const OwNERSHIP_FOREIGN = "FOREIGN";
11
+ private $productId;
12
+ private $price;
13
+ private $priceCurrency;
14
+ private $deliveryCost;
15
+ private $deliveryCostCurrency;
16
+ private $deliveryTime;
17
+ private $ownership;
18
+ private $owningDealerCode;
19
+ public function __construct(DOMElement $domElement) {
20
+ parent::__construct ( $domElement );
21
+ assert ( $domElement->localName == 'bestPrice' );
22
+
23
+ foreach ( $domElement->childNodes as $childNode ) {
24
+ switch ($childNode->localName) {
25
+ case 'productId' :
26
+ $this->productId = $childNode->nodeValue;
27
+ break;
28
+ case 'price' :
29
+ $this->price = $childNode->nodeValue;
30
+ $this->priceCurrency = $childNode->getAttribute ( 'currency' );
31
+ break;
32
+ case 'deliveryCost' :
33
+ $this->deliveryCost = $childNode->nodeValue;
34
+ $this->deliveryCostCurrency = $childNode->getAttribute ( 'currency' );
35
+ break;
36
+ case 'deliveryTime' :
37
+ $this->deliveryTime = $childNode->nodeValue;
38
+ break;
39
+ case 'activeOffers' :
40
+ $this->activeOffers = $childNode->nodeValue;
41
+ break;
42
+ case 'ownership' :
43
+ switch ($childNode->nodeValue) {
44
+ case self::OwNERSHIP_OWN :
45
+ $this->ownership = self::OwNERSHIP_OWN;
46
+ break;
47
+ case self::OwNERSHIP_FOREIGN :
48
+ $this->ownership = self::OwNERSHIP_FOREIGN;
49
+ break;
50
+ }
51
+ break;
52
+ case 'owningDealerCode' :
53
+ $this->owningDealerCode = $childNode->nodeValue;
54
+ break;
55
+ }
56
+ }
57
+ }
58
+ public function getActiveOffers() {
59
+ return $this->activeOffers;
60
+ }
61
+ public function getProductId() {
62
+ return $this->productId;
63
+ }
64
+ public function getPrice() {
65
+ return $this->price;
66
+ }
67
+ public function getPriceCurrency() {
68
+ return $this->priceCurrency;
69
+ }
70
+ public function getDeliveryCost() {
71
+ return $this->deliveryCost;
72
+ }
73
+ public function getDeliveryCostCurrency() {
74
+ return $this->deliveryCostCurrency;
75
+ }
76
+ public function getDeliveryTime() {
77
+ return $this->deliveryTime;
78
+ }
79
+ public function getOwnership() {
80
+ return $this->ownership;
81
+ }
82
+ public function getOwningDealerCode() {
83
+ return $this->owningDealerCode;
84
+ }
85
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/DataResponse/Confirmation.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @author stephan
6
+ *
7
+ */
8
+ class Dhl_MeinPaket_Model_Xml_Response_Partial_DataResponse_Confirmation extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
9
+ private $customerId;
10
+ private $email;
11
+ public function __construct(DOMElement $domElement) {
12
+ parent::__construct ( $domElement );
13
+ assert ( $domElement->localName == 'confirmation' );
14
+
15
+ //TODO: Not implemented
16
+
17
+ foreach ( $domElement->childNodes as $childNode ) {
18
+ switch ($childNode->localName) {
19
+ case 'customerId' :
20
+ $this->customerId = $childNode->nodeValue;
21
+ break;
22
+ case 'email' :
23
+ $this->email = $childNode->nodeValue;
24
+ break;
25
+ }
26
+ }
27
+ }
28
+ public function getCustomerId() {
29
+ return $this->customerId;
30
+ }
31
+ public function getEmail() {
32
+ return $this->email;
33
+ }
34
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/DataResponse/MerchantData.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @author stephan
6
+ *
7
+ */
8
+ class Dhl_MeinPaket_Model_Xml_Response_Partial_DataResponse_MerchantData extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
9
+ private $customerId;
10
+ private $email;
11
+ public function __construct(DOMElement $domElement) {
12
+ parent::__construct ( $domElement );
13
+ assert ( $domElement->localName == 'merchantData' );
14
+
15
+ //TODO: Not implemented
16
+
17
+ foreach ( $domElement->childNodes as $childNode ) {
18
+ switch ($childNode->localName) {
19
+ case 'customerId' :
20
+ $this->customerId = $childNode->nodeValue;
21
+ break;
22
+ case 'email' :
23
+ $this->email = $childNode->nodeValue;
24
+ break;
25
+ }
26
+ }
27
+ }
28
+ public function getCustomerId() {
29
+ return $this->customerId;
30
+ }
31
+ public function getEmail() {
32
+ return $this->email;
33
+ }
34
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/DataResponse/ProductData.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @author stephan
6
+ *
7
+ */
8
+ class Dhl_MeinPaket_Model_Xml_Response_Partial_DataResponse_ProductData extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
9
+ private $entryId;
10
+ private $type;
11
+ private $marketplaceCategory;
12
+ private $name;
13
+ private $shortDescription;
14
+ private $longDescription;
15
+ private $manufacturerName;
16
+ public function __construct(DOMElement $domElement) {
17
+ parent::__construct ( $domElement );
18
+ assert ( $domElement->localName == 'productData' );
19
+
20
+ $this->entryId = $domElement->getAttribute ( 'entryId' );
21
+ $this->type = $domElement->getAttribute ( 'type' );
22
+
23
+ foreach ( $domElement->childNodes as $childNode ) {
24
+ switch ($childNode->localName) {
25
+ case 'marketplaceCategory' :
26
+ $this->marketplaceCategory = $childNode->getAttribute ( 'code' );
27
+ break;
28
+ case 'name' :
29
+ $this->name = $childNode->nodeValue;
30
+ break;
31
+ case 'shortDescription' :
32
+ $this->shortDescription = $childNode->nodeValue;
33
+ break;
34
+ case 'longDescription' :
35
+ $this->longDescription = $childNode->nodeValue;
36
+ break;
37
+ case 'manufacturerName' :
38
+ $this->manufacturerName = $childNode->nodeValue;
39
+ break;
40
+ }
41
+ }
42
+ }
43
+ public function getEntityId() {
44
+ return $this->entryId;
45
+ }
46
+ public function getMarketplaceCategory() {
47
+ return $this->marketplaceCategory;
48
+ }
49
+ public function getName() {
50
+ return $this->name;
51
+ }
52
+ public function getShortDescription() {
53
+ return $this->shortDescription;
54
+ }
55
+ public function getLongDescription() {
56
+ return $this->longDescription;
57
+ }
58
+ public function getManufacturerName() {
59
+ return $this->manufacturerName;
60
+ }
61
+ public function getType() {
62
+ return $this->type;
63
+ }
64
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/DataResponse/QuotaData.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @author stephan
6
+ *
7
+ */
8
+ class Dhl_MeinPaket_Model_Xml_Response_Partial_DataResponse_QuotaData extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
9
+ private $customerId;
10
+ private $email;
11
+ public function __construct(DOMElement $domElement) {
12
+ parent::__construct ( $domElement );
13
+ assert ( $domElement->localName == 'quotaData' );
14
+
15
+ //TODO: Not implemented
16
+ foreach ( $domElement->childNodes as $childNode ) {
17
+ switch ($childNode->localName) {
18
+ case 'customerId' :
19
+ $this->customerId = $childNode->nodeValue;
20
+ break;
21
+ case 'email' :
22
+ $this->email = $childNode->nodeValue;
23
+ break;
24
+ }
25
+ }
26
+ }
27
+ public function getCustomerId() {
28
+ return $this->customerId;
29
+ }
30
+ public function getEmail() {
31
+ return $this->email;
32
+ }
33
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/NotificationResponse/Confirmation.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @author stephan
6
+ *
7
+ */
8
+ class Dhl_MeinPaket_Model_Xml_Response_Partial_NotificationResponse_Confirmation extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
9
+ private $cancellationConfirmation = array ();
10
+ private $consignmentConfirmation = array ();
11
+ private $trackingNumberConfirmation = array ();
12
+ private $returnConfirmation = array ();
13
+ private $creditMemoConfirmation = array ();
14
+
15
+ /**
16
+ *
17
+ * @param DOMElement $domElement
18
+ */
19
+ public function __construct(DOMElement $domElement) {
20
+ parent::__construct ( $domElement );
21
+ assert ( $domElement->localName == 'confirmation' );
22
+
23
+ foreach ( $domElement->childNodes as $childNode ) {
24
+ switch ($childNode->localName) {
25
+ case 'cancellation' :
26
+ $this->cancellationConfirmation [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_NotificationResponse_Consignment ( $childNode );
27
+ break;
28
+ case 'consignment' :
29
+ $this->consignmentConfirmation [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_NotificationResponse_Consignment ( $childNode );
30
+ break;
31
+ case 'trackingNumber' :
32
+ $this->trackingNumberConfirmation [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_NotificationResponse_Consignment ( $childNode );
33
+ break;
34
+ case 'return' :
35
+ $this->returnConfirmation [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_NotificationResponse_Return ( $childNode );
36
+ break;
37
+ case 'creditMemo' :
38
+ $this->creditMemoConfirmation [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_NotificationResponse_Credit ( $childNode );
39
+ break;
40
+ }
41
+ }
42
+ }
43
+ public function getCancellationConfirmations() {
44
+ return $this->cancellationConfirmation;
45
+ }
46
+ public function getConsignmentConfirmations() {
47
+ return $this->consignmentConfirmation;
48
+ }
49
+ public function getTrackingNumberConfirmations() {
50
+ return $this->trackingNumberConfirmation;
51
+ }
52
+ public function getReturnConfirmations() {
53
+ return $this->returnConfirmation;
54
+ }
55
+ public function getCreditMemoConfirmations() {
56
+ return $this->creditMemoConfirmation;
57
+ }
58
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/NotificationResponse/Consignment.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Xml_Response_Partial_NotificationResponse_Consignment extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
3
+ /**
4
+ *
5
+ * @var string
6
+ */
7
+ private $consignmentId;
8
+
9
+ /**
10
+ *
11
+ * @param DOMElement $domElement
12
+ */
13
+ public function __construct(DOMElement $domElement) {
14
+ parent::__construct ( $domElement );
15
+ $this->consignmentId = $domElement->nodeValue;
16
+
17
+ foreach ( $domElement->childNodes as $childNode ) {
18
+ switch ($childNode->localName) {
19
+ case 'consignmentId' :
20
+ $this->consignmentId = $childNode->nodeValue;
21
+ break;
22
+ }
23
+ }
24
+ }
25
+ public function getConsignmentId() {
26
+ return $this->consignmentId;
27
+ }
28
+
29
+ /**
30
+ * Return string for this object.
31
+ *
32
+ * @return string
33
+ */
34
+ public function __toString() {
35
+ return $this->consignmentId;
36
+ }
37
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/NotificationResponse/Credit.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Xml_Response_Partial_NotificationResponse_Credit extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
3
+ /**
4
+ *
5
+ * @var string
6
+ */
7
+ private $creditId;
8
+
9
+ /**
10
+ *
11
+ * @param DOMElement $domElement
12
+ */
13
+ public function __construct(DOMElement $domElement) {
14
+ parent::__construct ( $domElement );
15
+
16
+ foreach ( $domElement->childNodes as $childNode ) {
17
+ switch ($childNode->localName) {
18
+ case 'creditId' :
19
+ $this->creditId = $childNode->nodeValue;
20
+ break;
21
+ }
22
+ }
23
+ }
24
+ public function getCreditId() {
25
+ return $this->creditId;
26
+ }
27
+
28
+ /**
29
+ * Return string for this object.
30
+ *
31
+ * @return string
32
+ */
33
+ public function __toString() {
34
+ return $this->returnId;
35
+ }
36
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/NotificationResponse/Return.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Xml_Response_Partial_NotificationResponse_Return extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
3
+ /**
4
+ *
5
+ * @var string
6
+ */
7
+ private $returnId;
8
+
9
+ /**
10
+ *
11
+ * @param DOMElement $domElement
12
+ */
13
+ public function __construct(DOMElement $domElement) {
14
+ parent::__construct ( $domElement );
15
+
16
+ foreach ( $domElement->childNodes as $childNode ) {
17
+ switch ($childNode->localName) {
18
+ case 'returnId' :
19
+ $this->returnId = $childNode->nodeValue;
20
+ break;
21
+ }
22
+ }
23
+ }
24
+ public function getReturnId() {
25
+ return $this->returnId;
26
+ }
27
+
28
+ /**
29
+ * Return string for this object.
30
+ *
31
+ * @return string
32
+ */
33
+ public function __toString() {
34
+ return $this->returnId;
35
+ }
36
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/Order.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @author stephan
6
+ *
7
+ */
8
+ class Dhl_MeinPaket_Model_Xml_Response_Partial_Order extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
9
+ private $orderId;
10
+ private $orderDate;
11
+ private $lastModificationDate;
12
+ private $totalPrice;
13
+ private $totalPriceCurrency;
14
+ private $totalDeliveryCosts;
15
+ private $totalDeliveryCostsCurrency;
16
+ private $deliveryMethod;
17
+ /**
18
+ *
19
+ * @var Dhl_MeinPaket_Model_Xml_Response_Partial_Order_ContactData
20
+ */
21
+ private $contactData; // ?
22
+ /**
23
+ *
24
+ * @var Dhl_MeinPaket_Model_Xml_Response_Partial_Address
25
+ */
26
+ private $deliveryAddress;
27
+ /**
28
+ *
29
+ * @var Dhl_MeinPaket_Model_Xml_Response_Partial_Address
30
+ */
31
+ private $billingAddress;
32
+ /**
33
+ *
34
+ * @var array
35
+ */
36
+ private $entries = array ();
37
+
38
+ /**
39
+ * Default constructor.
40
+ *
41
+ * @param DOMElement $domElement
42
+ */
43
+ public function __construct(DOMElement $domElement) {
44
+ parent::__construct ( $domElement );
45
+ assert ( $domElement->localName == 'order' );
46
+
47
+ foreach ( $domElement->childNodes as $childNode ) {
48
+ switch ($childNode->localName) {
49
+ case 'orderId' :
50
+ $this->orderId = $childNode->nodeValue;
51
+ break;
52
+ case 'orderDate' :
53
+ $this->orderDate = $childNode->nodeValue;
54
+ break;
55
+ case 'lastModificationDate' :
56
+ $this->lastModificationDate = $childNode->nodeValue;
57
+ break;
58
+ case 'totalPrice' :
59
+ $this->totalPrice = $childNode->nodeValue;
60
+ $this->totalPriceCurrency = $childNode->getAttribute ( 'currency' );
61
+ break;
62
+ case 'totalDeliveryCosts' :
63
+ $this->totalDeliveryCosts = $childNode->nodeValue;
64
+ $this->totalDeliveryCostsCurrency = $childNode->getAttribute ( 'currency' );
65
+ break;
66
+ case 'deliveryMethod' :
67
+ $this->deliveryMethod = $childNode->nodeValue;
68
+ break;
69
+ case 'contactData' :
70
+ $this->contactData = new Dhl_MeinPaket_Model_Xml_Response_Partial_Order_ContactData ( $childNode );
71
+ break;
72
+ case 'deliveryAddress' :
73
+ $this->deliveryAddress = new Dhl_MeinPaket_Model_Xml_Response_Partial_Address ( $childNode );
74
+ break;
75
+ case 'billingAddress' :
76
+ $this->billingAddress = new Dhl_MeinPaket_Model_Xml_Response_Partial_Address ( $childNode );
77
+ break;
78
+ case 'orderEntry' :
79
+ $this->entries [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_Order_Entry ( $childNode );
80
+ }
81
+ }
82
+ }
83
+ public function getOrderId() {
84
+ return $this->orderId;
85
+ }
86
+ public function getOrderDate() {
87
+ return $this->orderDate;
88
+ }
89
+ public function getLastModificationDate() {
90
+ return $this->lastModificationDate;
91
+ }
92
+ public function getTotalPrice() {
93
+ return $this->totalPrice;
94
+ }
95
+ public function getTotalPriceCurrency() {
96
+ return $this->totalPriceCurrency;
97
+ }
98
+ public function getTotalDeliveryCosts() {
99
+ return $this->totalDeliveryCosts;
100
+ }
101
+ public function getTotalDeliveryCostsCurrency() {
102
+ return $this->totalDeliveryCostsCurrency;
103
+ }
104
+ public function getDeliveryMethod() {
105
+ return $this->deliveryMethod;
106
+ }
107
+ public function getContactData() {
108
+ return $this->contactData;
109
+ }
110
+ public function getDeliveryAddress() {
111
+ return $this->deliveryAddress;
112
+ }
113
+ public function getBillingAddress() {
114
+ return $this->billingAddress;
115
+ }
116
+ public function getEntries() {
117
+ return $this->entries;
118
+ }
119
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/Order/ContactData.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @author stephan
6
+ *
7
+ */
8
+ class Dhl_MeinPaket_Model_Xml_Response_Partial_Order_ContactData extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
9
+ private $customerId;
10
+ private $email;
11
+ public function __construct(DOMElement $domElement) {
12
+ parent::__construct ( $domElement );
13
+ assert ( $domElement->localName == 'contactData' );
14
+ foreach ( $domElement->childNodes as $childNode ) {
15
+ switch ($childNode->localName) {
16
+ case 'customerId' :
17
+ $this->customerId = $childNode->nodeValue;
18
+ break;
19
+ case 'email' :
20
+ $this->email = $childNode->nodeValue;
21
+ break;
22
+ }
23
+ }
24
+ }
25
+ public function getCustomerId() {
26
+ return $this->customerId;
27
+ }
28
+ public function getEmail() {
29
+ return $this->email;
30
+ }
31
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/Order/Entry.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @author stephan
6
+ *
7
+ */
8
+ class Dhl_MeinPaket_Model_Xml_Response_Partial_Order_Entry extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
9
+ private $productId;
10
+ private $meinPaketId;
11
+ private $ean;
12
+ private $name;
13
+ private $quantity;
14
+ private $basePrice;
15
+ private $basePriceCurrency;
16
+ private $totalPrice;
17
+ private $totalPriceCurrency;
18
+ public function __construct(DOMElement $domElement) {
19
+ parent::__construct ( $domElement );
20
+ assert ( $domElement->localName == 'orderEntry' );
21
+ foreach ( $domElement->childNodes as $childNode ) {
22
+ switch ($childNode->localName) {
23
+ case 'productId' :
24
+ $this->productId = $childNode->nodeValue;
25
+ break;
26
+ case 'meinPaketId' :
27
+ $this->meinPaketId = $childNode->nodeValue;
28
+ break;
29
+ case 'ean' :
30
+ $this->ean = strtotime ( $childNode->nodeValue );
31
+ break;
32
+ case 'name' :
33
+ $this->name = $childNode->nodeValue;
34
+ break;
35
+ case 'quantity' :
36
+ $this->quantity = $childNode->nodeValue;
37
+ break;
38
+ case 'basePrice' :
39
+ $this->basePrice = $childNode->nodeValue;
40
+ $this->basePriceCurrency = $childNode->getAttribute ( 'currency' );
41
+ break;
42
+ case 'totalPrice' :
43
+ $this->totalPrice = $childNode->nodeValue;
44
+ $this->totalPriceCurrency = $childNode->getAttribute ( 'currency' );
45
+ break;
46
+ }
47
+ }
48
+ }
49
+ public function getProductId() {
50
+ return $this->productId;
51
+ }
52
+ public function getMeinPaketId() {
53
+ return $this->meinPaketId;
54
+ }
55
+ public function getEan() {
56
+ return $this->ean;
57
+ }
58
+ public function getName() {
59
+ return $this->name;
60
+ }
61
+ public function getQuantity() {
62
+ return $this->quantity;
63
+ }
64
+ public function getBasePrice() {
65
+ return $this->basePrice;
66
+ }
67
+ public function getBaseCurrency() {
68
+ return $this->basePriceCurrency;
69
+ }
70
+ public function getTotalPrice() {
71
+ return $this->totalPrice;
72
+ }
73
+ public function getTotalPriceCurrency() {
74
+ return $this->totalPriceCurrency;
75
+ }
76
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/ProductId.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Xml_Response_Partial_ProductId extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
3
+ private $productId;
4
+ private $meinPaketId;
5
+ private $ean;
6
+ private $manufacturerName;
7
+ private $manufacturerPN;
8
+ public function __construct(DOMElement $domElement) {
9
+ parent::__construct ( $domElement );
10
+
11
+ foreach ( $domElement->childNodes as $childNode ) {
12
+ switch ($childNode->localName) {
13
+ case 'productId' :
14
+ $this->productId = $childNode->nodeValue;
15
+ break;
16
+ case 'meinPaketId' :
17
+ $this->meinPaketId = $childNode->nodeValue;
18
+ break;
19
+ case 'ean' :
20
+ $this->ean = $childNode->nodeValue;
21
+ break;
22
+ case 'manufacturerName' :
23
+ $this->manufacturerName = $childNode->nodeValue;
24
+ break;
25
+ case 'manufacturerPN' :
26
+ $this->manufacturerPN = $childNode->nodeValue;
27
+ break;
28
+ }
29
+ }
30
+ }
31
+ public function getProductId() {
32
+ return $this->productId;
33
+ }
34
+ public function getMeinPaketId() {
35
+ return $this->meinPaketId;
36
+ }
37
+ public function getEan() {
38
+ return $this->ean;
39
+ }
40
+ public function getManufacturerName() {
41
+ return $this->manufacturerName;
42
+ }
43
+ public function getManufacturerPN() {
44
+ return $this->manufacturerPN;
45
+ }
46
+
47
+ /**
48
+ * Return string for this object.
49
+ *
50
+ * @return string
51
+ */
52
+ public function __toString() {
53
+ return $this->productId . ' ' . $this->meinPaketId . ' ' . $this->ean . ' ' . $this->manufacturerName . ' ' . $this->manufacturerPN;
54
+ }
55
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/Partial/VariantConfiguration.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Xml_Response_Partial_VariantConfiguration extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
3
+ private $code;
4
+ private $indexAsGroup;
5
+ private $variantSelectionRule;
6
+ private $description;
7
+ private $requiredAttributes = array ();
8
+ public function __construct(DOMElement $domElement) {
9
+ parent::__construct ( $domElement );
10
+ assert ( $domElement->localName == 'variantConfiguration' );
11
+
12
+ $this->code = $domElement->getAttribute ( "code" );
13
+ $this->indexAsGroup = $domElement->getAttribute ( "indexAsGroup" ) == 'true';
14
+ $this->variantSelectionRule = $domElement->getAttribute ( "variantSelectionRule" );
15
+
16
+ $attributes = array ();
17
+
18
+ foreach ( $domElement->childNodes as $childNode ) {
19
+ switch ($childNode->localName) {
20
+ case 'description' :
21
+ $this->description = $childNode->nodeValue;
22
+ break;
23
+ case 'requiredAttribute' :
24
+ $this->requiredAttributes [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_Attribute ( $childNode );
25
+ break;
26
+ }
27
+ }
28
+ }
29
+ public function getCode() {
30
+ return $this->code;
31
+ }
32
+ public function getIndexAsGroup() {
33
+ return $this->indexAsGroup;
34
+ }
35
+ public function getVariantSelectionRule() {
36
+ return $this->variantSelectionRule;
37
+ }
38
+ public function getDescription() {
39
+ return $this->description;
40
+ }
41
+ public function getRequiredAttributes() {
42
+ return $this->requiredAttributes;
43
+ }
44
+
45
+ /**
46
+ * Parses the result from the given XML.
47
+ *
48
+ * @param SimpleXMLElement $dom
49
+ * The raw XML result returned by the webservice.
50
+ */
51
+ public function parseVariantConfigurationsDownloadResponse(SimpleXMLElement $dom) {
52
+ $variantConfigurations = array ();
53
+
54
+ if (isset ( $dom->variantConfiguration )) {
55
+ /* @var $variantConfiguration SimpleXMLElement */
56
+ foreach ( $dom->variantConfiguration as $variantConfiguration ) {
57
+ $variantAttributes = ( array ) ($variantConfiguration->attributes ());
58
+ $variantAttributes = array_pop ( $variantAttributes );
59
+ $variantCode = ( string ) $variantAttributes ['code'];
60
+ $variantConfigurations [$variantCode] = array (
61
+ 'indexAsGroup' => ( boolean ) $variantAttributes ['indexAsGroup'],
62
+ 'variantSelectionRule' => ( string ) $variantAttributes ['variantSelectionRule'],
63
+ 'description' => ( string ) $variantConfiguration->description
64
+ );
65
+ if (isset ( $variantConfiguration->requiredAttribute )) {
66
+ foreach ( $variantConfiguration->requiredAttribute as $requiredAttribute ) {
67
+ $requiredAttributeAttributes = ( array ) ($requiredAttribute->attributes ());
68
+ $requiredAttributeAttributes = array_pop ( $requiredAttributeAttributes );
69
+ $attributeCode = ( string ) $requiredAttributeAttributes ['code'];
70
+ $variantConfigurations [$variantCode] ['requiredAttributes'] [$attributeCode] = array (
71
+ 'name' => ( string ) $requiredAttribute->name,
72
+ 'values' => array ()
73
+ );
74
+ if (isset ( $requiredAttribute->variantAtributeValue )) {
75
+ foreach ( $requiredAttribute->variantAtributeValue as $variantAttributeValue ) {
76
+ $variantAttributeValueAttributes = ( array ) ($variantAttributeValue->attributes ());
77
+ $variantAttributeValueAttributes = array_pop ( $variantAttributeValueAttributes );
78
+ $variantConfigurations [$variantCode] ['requiredAttributes'] [$attributeCode] ['values'] [] = ( string ) $variantAttributeValueAttributes ['value'];
79
+ }
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }
85
+
86
+ return $variantConfigurations;
87
+ }
88
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/QueryResponse.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Xml_Response_QueryResponse extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
3
+ /**
4
+ *
5
+ * @var $orders array
6
+ */
7
+ private $orders = array ();
8
+
9
+ /**
10
+ * Constructor
11
+ *
12
+ * @param unknown $domElement
13
+ */
14
+ public function __construct(DOMElement $domElement) {
15
+ parent::__construct ( $domElement );
16
+ assert ( $domElement->localName == 'queryResponse' );
17
+
18
+ foreach ( $domElement->childNodes as $queryResponseEntries ) {
19
+ switch ($queryResponseEntries->localName) {
20
+ case 'order' :
21
+ $this->orders [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_Order ( $queryResponseEntries );
22
+ break;
23
+ }
24
+ }
25
+ }
26
+
27
+ /**
28
+ *
29
+ * @return $orders
30
+ */
31
+ public function getOrders() {
32
+ return $this->orders;
33
+ }
34
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/Response/UploadResponse.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Xml_Response_UploadResponse extends Dhl_MeinPaket_Model_Xml_Response_Abstract {
3
+ private $warnings = array ();
4
+ private $categoryDeletionConfirmations = array ();
5
+ private $categoryConfirmations = array ();
6
+ private $productDeletionConfirmations = array ();
7
+ private $productDescriptionConfirmations = array ();
8
+ private $productOfferConfirmations = array ();
9
+ private $variantGroupConfirmations = array ();
10
+
11
+ /**
12
+ *
13
+ * @param DOMElement $domElement
14
+ */
15
+ public function __construct(DOMElement $domElement) {
16
+ parent::__construct ( $domElement );
17
+ assert ( $domElement->localName == 'uploadResponse' );
18
+
19
+ foreach ( $domElement->childNodes as $uploadResponseEntries ) {
20
+ switch ($uploadResponseEntries->localName) {
21
+ case 'confirmation' :
22
+ foreach ( $uploadResponseEntries->childNodes as $confirmationEntries ) {
23
+ switch ($confirmationEntries->localName) {
24
+ case 'categoryDeletion' :
25
+ $this->categoryDeletionConfirmations [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_CategoryId ( $confirmationEntries );
26
+ break;
27
+ case 'category' :
28
+ $this->categoryConfirmations [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_CategoryId ( $confirmationEntries );
29
+ break;
30
+ case 'productDeletion' :
31
+ $this->productDeletionConfirmations [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_ProductId ( $confirmationEntries );
32
+ break;
33
+ case 'productDescription' :
34
+ $this->productDescriptionConfirmations [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_ProductId ( $confirmationEntries );
35
+ break;
36
+ case 'productOffer' :
37
+ $this->productOfferConfirmations [] = new Dhl_MeinPaket_Model_Xml_Response_Partial_ProductId ( $confirmationEntries );
38
+ break;
39
+ case 'variantGroup' :
40
+ break;
41
+ }
42
+ }
43
+ break;
44
+ case 'warning' :
45
+ $warnings [] = $uploadResponseEntries->nodeValue;
46
+ break;
47
+ }
48
+ }
49
+ }
50
+
51
+ /**
52
+ */
53
+ public function storeMeinPaketIds() {
54
+ foreach ( $this->productDescriptionConfirmations as $conf ) {
55
+ /* @var $product Mage_Catalog_Model_Product */
56
+ $product = Mage::getModel ( 'catalog/product' )->load ( $conf->getProductId () );
57
+ if ($product->getData ( 'meinpaket_id' ) != $conf->getMeinPaketId ()) {
58
+ $product->setData ( 'meinpaket_id', $conf->getMeinPaketId () );
59
+ $product->getResource ()->saveAttribute ( $product, 'meinpaket_id' );
60
+ }
61
+ }
62
+
63
+ foreach ( $this->productDeletionConfirmations as $conf ) {
64
+ /* @var $product Mage_Catalog_Model_Product */
65
+ $product = Mage::getModel ( 'catalog/product' )->load ( $conf->getProductId () );
66
+ if ($product->getData ( 'meinpaket_id' ) != $conf->getMeinPaketId ()) {
67
+ $product->setData ( 'meinpaket_id', $conf->getMeinPaketId () );
68
+ $product->getResource ()->saveAttribute ( $product, 'meinpaket_id' );
69
+ }
70
+ }
71
+ }
72
+
73
+ /**
74
+ */
75
+ public function deleteMeinPaketIds() {
76
+ /* @var $conf Dhl_MeinPaket_Model_Xml_Response_Partial_ProductId */
77
+ foreach ( $this->productDeletionConfirmations as $conf ) {
78
+ /* @var $product Mage_Catalog_Model_Product */
79
+ $product = Mage::getModel ( 'catalog/product' )->load ( $conf->getProductId () );
80
+ $product->setData ( 'meinpaket_id', null );
81
+ $product->getResource ()->saveAttribute ( $product, 'meinpaket_id' );
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Process response
87
+ */
88
+ public function process() {
89
+ $this->deleteMeinPaketIds ();
90
+ $this->storeMeinPaketIds ();
91
+ }
92
+ }
app/code/community/Dhl/MeinPaket/Model/Xml/XmlBuildException.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Basic exception which occurs when building of XML request failed for any reason.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Xml
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Xml_XmlBuildException extends Varien_Exception {
13
+ }
14
+
app/code/community/Dhl/MeinPaket/Model/Xml/XmlRequestFactory.php ADDED
@@ -0,0 +1,551 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * XML Request builder class which generates the requests to communicate with
5
+ * the MeinPaket.de webservice.
6
+ *
7
+ * @category Dhl
8
+ * @package Dhl_MeinPaket
9
+ * @subpackage Model_Xml
10
+ * @version $Id$
11
+ * @author Daniel Pötzinger <daniel.poetzinger@aoemedia.de>
12
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
13
+ */
14
+ class Dhl_MeinPaket_Model_Xml_XmlRequestFactory extends Varien_Object {
15
+
16
+ /**
17
+ * The XML-version of the generated XML.
18
+ *
19
+ * @var string
20
+ */
21
+ const XML_VERSION = '1.0';
22
+
23
+ /**
24
+ * The charset which is set in the XML prologue of the generated XML.
25
+ *
26
+ * @var string
27
+ */
28
+ const XML_CHARSET = 'UTF-8';
29
+
30
+ /**
31
+ * Constructor.
32
+ *
33
+ * @return void
34
+ */
35
+ public function __construct() {
36
+ }
37
+
38
+ /**
39
+ * NEW
40
+ * Creates the XML for upload request.
41
+ *
42
+ * @param Dhl_MeinPaket_Model_Service_Product_Export_Result $result
43
+ * @throws Dhl_MeinPaket_Model_Xml_XmlBuildException
44
+ * @return Dhl_MeinPaket_Model_Xml_Partial_UploadRequest
45
+ */
46
+ public function createUploadRequest() {
47
+ return Mage::getModel ( 'meinpaket/xml_requets_uploadRequest' );
48
+ }
49
+
50
+
51
+ /**
52
+ * Crates XML for a variant group upload.
53
+ *
54
+ * @param Dhl_MeinPaket_Model_Service_Product_Export_Variant_Group_Collection $variantGroups
55
+ * @throws Dhl_MeinPaket_Model_Xml_XmlBuildException
56
+ * @return string
57
+ */
58
+ public function createVariantGroupUploadRequest(Dhl_MeinPaket_Model_Service_Product_Export_Variant_Group_Collection $variantGroups) {
59
+ if (! $this->areAuthenticationParamtersSet ()) {
60
+ throw new Dhl_MeinPaket_Model_Xml_XmlBuildException ( 'No authentication parameters set.' );
61
+ }
62
+
63
+ if ($variantGroups->count () < 1) {
64
+ throw new Dhl_MeinPaket_Model_Xml_XmlBuildException ( 'No variant groups.' );
65
+ }
66
+
67
+ $xml = '';
68
+ $document = $this->createDocument ();
69
+
70
+ /* @var $uploadRequest Dhl_MeinPaket_Model_Xml_Partial_UploadRequest */
71
+ $uploadRequest = Mage::getModel ( 'meinpaket/xml_partial_uploadRequest' );
72
+
73
+ /* @var $variantGroupsPartial Dhl_MeinPaket_Model_Xml_Partial_VariantGroups */
74
+ $variantGroupsPartial = Mage::getModel ( 'meinpaket/xml_partial_variantGroups' );
75
+
76
+ $uploadRequest->setDocument ( $document )->build ();
77
+ $variantGroupsPartial->setDocument ( $document )->build ();
78
+
79
+ foreach ( $variantGroups as $variantGroup ) {
80
+ /* @var $variantGroupPartial Dhl_MeinPaket_Model_Xml_Partial_VariantGroup */
81
+ $variantGroupPartial = Mage::getModel ( 'meinpaket/xml_partial_variantGroup' );
82
+
83
+ $variantGroupPartial->setDocument ( $document )->setVariantGroup ( $variantGroup )->build ();
84
+
85
+ $variantGroupsPartial->getNode ()->appendChild ( $variantGroupPartial->getNode () );
86
+ }
87
+
88
+ $uploadRequest->getNode ()->appendChild ( $this->createHeaderNode ( $document ) );
89
+ $uploadRequest->getNode ()->appendChild ( $variantGroupsPartial->getNode () );
90
+
91
+ $document->appendChild ( $uploadRequest->getNode () );
92
+
93
+ $xml = $document->saveXML ();
94
+
95
+ return $xml;
96
+ }
97
+
98
+
99
+ /**
100
+ * Creates the XML for a product upload request.
101
+ *
102
+ * @param Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $productCollection
103
+ * @param Dhl_MeinPaket_Model_Service_Product_Export_Result $result
104
+ * @throws Dhl_MeinPaket_Model_Xml_XmlBuildException
105
+ * @return string
106
+ */
107
+ public function createProductsUploadRequestXml(Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $productCollection, Dhl_MeinPaket_Model_Service_Product_Export_Result $result) {
108
+ if (! $this->areAuthenticationParamtersSet ()) {
109
+ throw new Dhl_MeinPaket_Model_Xml_XmlBuildException ( 'No authentication parameters set.' );
110
+ }
111
+
112
+ $document = $this->createDocument ();
113
+ $uploadRequest = Mage::getModel ( 'meinpaket/xml_partial_uploadRequest' );
114
+ $descriptions = Mage::getModel ( 'meinpaket/xml_partial_descriptions' );
115
+ $offers = Mage::getModel ( 'meinpaket/xml_partial_offers' );
116
+ $description = null;
117
+ $offer = null;
118
+ $xml = '';
119
+
120
+ $uploadRequest->setDocument ( $document )->build ();
121
+ $descriptions->setDocument ( $document )->build ();
122
+ $offers->setDocument ( $document )->build ();
123
+
124
+ if ($productCollection->count () > 0) {
125
+
126
+ /* @var $attributeHelper Dhl_MeinPaket_Helper_Attribute */
127
+ $attributeHelper = Mage::helper ( 'meinpaket/attribute' );
128
+
129
+ foreach ( $productCollection as $product ) {
130
+ // $product->load($product->getId());
131
+ // $setAttributes = $product->getTypeInstance(true)->getSetAttributes($product);
132
+ // foreach($setAttributes as $attributeIndex => $setAttribute) {
133
+ // if($attributeHelper->isExportableAttribute($setAttribute)) {
134
+ // Mage::log("Attribute is exportable: ".$attributeIndex);
135
+ // }
136
+ // }
137
+ // Mage::log('Export: '.$product->getId().' , '.$product->getTypeId());
138
+ // Mage::log("Custom Options: ".print_r($attrs,true));
139
+ // Mage::log("Default Attr Set Id: ".$product->getDefaultAttributeSetId());
140
+ // Mage::log("Ver3: ".print_r(Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId()),true));
141
+ // Mage::log("ks: ".print_r(get_class($x),true));
142
+ // Mage::log("Full: ".print_r(gettype($x[0]),true));
143
+ // Mage::log(print_r($product->loadParentProductIds()->getData('parent_product_ids'),true));
144
+ // $configurable_product = Mage::getModel('catalog/product_type_configurable');
145
+ // $parentIdArray = $configurable_product->getParentIdsByChild($product->getId());
146
+ // Mage::log("solution B: ".print_r($parentIdArray,true));
147
+
148
+ try {
149
+ $description = Mage::getModel ( 'meinpaket/xml_partial_productDescription' );
150
+ $description->setDocument ( $document )->setProduct ( $product )->build ();
151
+ $descriptions->getNode ()->appendChild ( $description->getNode () );
152
+ } catch ( Dhl_MeinPaket_Model_Exception_InvalidDataException $e ) {
153
+ Mage::logException ( $e );
154
+
155
+ $result->addErrorForProductDescription ( $e->getEntityId (), $e->getFieldName (), $e->getErrorType () );
156
+
157
+ // not all required data set for a description - we skip the description therefore
158
+ // but we need at least a valid ean (sku) to still send an offer
159
+ if (! $this->hasValidSku ( $product )) {
160
+ $result->addErrorForProductDescription ( $e->getEntityId (), 'sku', Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_FIELD_IS_INVALID );
161
+ continue; // skip current
162
+ }
163
+ }
164
+ // if description is not set - we need at least an sku - otherwise skip this item!
165
+ $offer = Mage::getModel ( 'meinpaket/xml_partial_productOffer' );
166
+ $offer->setDocument ( $document )->setProduct ( $product )->build ();
167
+ $offers->getNode ()->appendChild ( $offer->getNode () );
168
+ $result->incrementTotalRequestCount ();
169
+ }
170
+ }
171
+
172
+ $uploadRequest->getNode ()->appendChild ( $this->createHeaderNode ( $document ) );
173
+ $uploadRequest->getNode ()->appendChild ( $descriptions->getNode () );
174
+ $uploadRequest->getNode ()->appendChild ( $offers->getNode () );
175
+
176
+ $document->appendChild ( $uploadRequest->getNode () );
177
+
178
+ $xml = $document->saveXML ();
179
+
180
+ $result->setRequestXml ( $xml );
181
+
182
+ return $xml;
183
+ }
184
+
185
+ /**
186
+ * Creates the XML for an order cancellation request.
187
+ *
188
+ * @param Mage_Sales_Model_Order $order
189
+ * @param Mage_Sales_Model_Quote $quote
190
+ * @param Dhl_MeinPaket_Model_OrderCancellation_Result $result
191
+ * @throws Dhl_MeinPaket_Model_Xml_XmlBuildException
192
+ * @return string
193
+ */
194
+ public function createOrderCancellationRequest(Mage_Sales_Model_Order $order, Mage_Sales_Model_Quote $quote, Dhl_MeinPaket_Model_OrderCancellation_Result $result) {
195
+ if (! $this->areAuthenticationParamtersSet ()) {
196
+ throw new Dhl_MeinPaket_Model_Xml_XmlBuildException ( 'No authentication parameters set.' );
197
+ }
198
+
199
+ $document = $this->createDocument ();
200
+
201
+ /* @var $notificationRequest Dhl_MeinPaket_Model_Xml_Partial_NotificationRequest */
202
+ $notificationRequest = Mage::getModel ( 'meinpaket/Xml_Partial_NotificationRequest' );
203
+
204
+ /* @var $cancellations Dhl_MeinPaket_Model_Xml_Partial_Cancellations */
205
+ $cancellations = Mage::getModel ( 'meinpaket/Xml_Partial_Cancellations' );
206
+
207
+ /* @var $cancellation Dhl_MeinPaket_Model_Xml_Partial_Cancellation */
208
+ $cancellation = Mage::getModel ( 'meinpaket/Xml_Partial_Cancellation' );
209
+
210
+ /* @var $cancellationEntry Dhl_MeinPaket_Model_Xml_Partial_CancellationEntry */
211
+ $cancellationEntry = null;
212
+
213
+ $notificationRequest->setDocument ( $document )->build ();
214
+
215
+ $cancellations->setDocument ( $document )->build ();
216
+
217
+ $cancellation->setDocument ( $document )->setOrderId ( $order->getDhlMeinPaketOrderId () )->setConsignmentId ( $order->getId () )->build ();
218
+
219
+ foreach ( $quote->getItemsCollection () as $item ) {
220
+ $cancellationEntry = Mage::getModel ( 'meinpaket/Xml_Partial_CancellationEntry' );
221
+ $cancellationEntry->setDocument ( $document )->setProductId ( $item->getProductId () )->setQuantity ( $item->getQty () )->setReason ( 'OutOfStock' )->build ();
222
+ $cancellation->getNode ()->appendChild ( $cancellationEntry->getNode () );
223
+ }
224
+
225
+ $cancellations->getNode ()->appendChild ( $cancellation->getNode () );
226
+ $notificationRequest->getNode ()->appendChild ( $this->createHeaderNode ( $document ) );
227
+ $notificationRequest->getNode ()->appendChild ( $cancellations->getNode () );
228
+ $document->appendChild ( $notificationRequest->getNode () );
229
+
230
+ return $document->saveXML ();
231
+ }
232
+
233
+ /**
234
+ * Creates the XML for a request that cancels single items of an order.
235
+ *
236
+ * @param Mage_Sales_Model_Order $order
237
+ * @param array $items
238
+ * @throws Dhl_MeinPaket_Model_Xml_XmlBuildException
239
+ * @return string
240
+ */
241
+ public function createPartialOrderCancellationRequest(Mage_Sales_Model_Order $order, array $items) {
242
+ if (! $this->areAuthenticationParamtersSet ()) {
243
+ throw new Dhl_MeinPaket_Model_Xml_XmlBuildException ( 'No authentication parameters set.' );
244
+ }
245
+
246
+ $document = $this->createDocument ();
247
+
248
+ /* @var $notificationRequest Dhl_MeinPaket_Model_Xml_Partial_NotificationRequest */
249
+ $notificationRequest = Mage::getModel ( 'meinpaket/Xml_Partial_NotificationRequest' );
250
+
251
+ /* @var $cancellations Dhl_MeinPaket_Model_Xml_Partial_Cancellations */
252
+ $cancellations = Mage::getModel ( 'meinpaket/Xml_Partial_Cancellations' );
253
+
254
+ /* @var $cancellation Dhl_MeinPaket_Model_Xml_Partial_Cancellation */
255
+ $cancellation = Mage::getModel ( 'meinpaket/Xml_Partial_Cancellation' );
256
+
257
+ /* @var $cancellationEntry Dhl_MeinPaket_Model_Xml_Partial_CancellationEntry */
258
+ $cancellationEntry = null;
259
+
260
+ $notificationRequest->setDocument ( $document )->build ();
261
+
262
+ $cancellations->setDocument ( $document )->build ();
263
+
264
+ $cancellation->setDocument ( $document )->setOrderId ( $order->getDhlMeinPaketOrderId () )->setConsignmentId ( ( string ) $order->getId () )->build ();
265
+
266
+ foreach ( $items as $item ) {
267
+ $cancellationEntry = Mage::getModel ( 'meinpaket/Xml_Partial_CancellationEntry' );
268
+ $cancellationEntry->setDocument ( $document )->setProductId ( $item ['productId'] )->setQuantity ( $item ['qty'] )->setReason ( 'CustomerRequest' )->build ();
269
+ $cancellation->getNode ()->appendChild ( $cancellationEntry->getNode () );
270
+ }
271
+
272
+ $cancellations->getNode ()->appendChild ( $cancellation->getNode () );
273
+ $notificationRequest->getNode ()->appendChild ( $this->createHeaderNode ( $document ) );
274
+ $notificationRequest->getNode ()->appendChild ( $cancellations->getNode () );
275
+ $document->appendChild ( $notificationRequest->getNode () );
276
+
277
+ return $document->saveXML ();
278
+ }
279
+
280
+ /**
281
+ * Creates XML for an order download request.
282
+ *
283
+ * @param integer $dateFrom
284
+ * @param integer $dateTo
285
+ * @throws Dhl_MeinPaket_Model_Xml_XmlBuildException
286
+ * @return string
287
+ */
288
+ public function createOrderRequestXml($dateFrom, $dateTo) {
289
+ if (! $this->areAuthenticationParamtersSet ()) {
290
+ throw new Dhl_MeinPaket_Model_Xml_XmlBuildException ( 'No authentication parameters set.' );
291
+ }
292
+
293
+ $document = $this->createDocument ();
294
+ $orderRequest = Mage::getModel ( 'meinpaket/xml_partial_orderRequest' );
295
+ $orders = Mage::getModel ( 'meinpaket/xml_partial_orders' );
296
+
297
+ $orderRequest->setDocument ( $document )->build ();
298
+ $orders->setDateFrom ( $dateFrom )->setDateTo ( $dateTo )->setDocument ( $document )->build ();
299
+
300
+ $orderRequest->getNode ()->appendChild ( $this->createHeaderNode ( $document ) );
301
+ $orderRequest->getNode ()->appendChild ( $orders->getNode () );
302
+
303
+ $document->appendChild ( $orderRequest->getNode () );
304
+
305
+ return $document->saveXML ();
306
+ }
307
+
308
+ /**
309
+ * Creates XML for a shipment export request.
310
+ *
311
+ * @param Mage_Sales_Model_Order_Shipment $shipment
312
+ * @throws Dhl_MeinPaket_Model_Xml_XmlBuildException
313
+ * @return string
314
+ */
315
+ public function createShipmentRequest(Mage_Sales_Model_Order_Shipment $shipment) {
316
+ if (! $this->areAuthenticationParamtersSet ()) {
317
+ throw new Dhl_MeinPaket_Model_Xml_XmlBuildException ( 'No authentication parameters set.' );
318
+ }
319
+
320
+ $document = $this->createDocument ();
321
+
322
+ /* @var $notificationRequest Dhl_MeinPaket_Model_Xml_Partial_NotificationRequest */
323
+ $notificationRequest = Mage::getModel ( 'meinpaket/Xml_Partial_NotificationRequest' );
324
+
325
+ /* @var $consignments Dhl_MeinPaket_Model_Xml_Partial_Consignments */
326
+ $consignments = Mage::getModel ( 'meinpaket/Xml_Partial_Consignments' );
327
+
328
+ /* @var $consignment Dhl_MeinPaket_Model_Xml_Partial_Consignment */
329
+ $consignment = null;
330
+
331
+ /* @var $consignmentEntry Dhl_MeinPaket_Model_Xml_Partial_ConsignmentEntry */
332
+ $consignmentEntry = null;
333
+
334
+ /* @var $shipmentUtil Dhl_MeinPaket_Model_Util_Shipment */
335
+ $shipmentUtil = Mage::getSingleton ( 'meinpaket/Util_Shipment' );
336
+
337
+ $consignmentId = $shipmentUtil->getConsignmentIdForShipment ( $shipment );
338
+
339
+ $notificationRequest->setDocument ( $document )->build ();
340
+
341
+ $consignments->setDocument ( $document )->build ();
342
+
343
+ $itemsCollection = Mage::getModel ( 'sales/order_shipment_item' )->getCollection ();
344
+ $itemsCollection->addAttributeToSelect ( 'qty' )->addAttributeToSelect ( 'product_id' )->addAttributeToFilter ( 'parent_id', $shipment->getId () )->load ();
345
+
346
+ foreach ( $itemsCollection as $item ) {
347
+
348
+ $consignment = Mage::getModel ( 'meinpaket/Xml_Partial_Consignment' );
349
+ $consignment->setDocument ( $document )->setOrderId ( $shipment->getOrder ()->getDhlMeinPaketOrderId () )->setConsignmentId ( $consignmentId )->build ();
350
+
351
+ $consignmentEntry = Mage::getModel ( 'meinpaket/Xml_Partial_ConsignmentEntry' );
352
+ $consignmentEntry->setDocument ( $document )->setProductId ( $item->getProductId () )->setQuantity ( $item->getQty () )->build ();
353
+
354
+ $consignment->getNode ()->appendChild ( $consignmentEntry->getNode () );
355
+ $consignments->getNode ()->appendChild ( $consignment->getNode () );
356
+ }
357
+
358
+ $notificationRequest->getNode ()->appendChild ( $this->createHeaderNode ( $document ) );
359
+ $notificationRequest->getNode ()->appendChild ( $consignments->getNode () );
360
+ $document->appendChild ( $notificationRequest->getNode () );
361
+
362
+ return $document->saveXML ();
363
+ }
364
+
365
+ /**
366
+ * Creates XML for a request which notifies MeinPaket.de about returned shipments.
367
+ *
368
+ * @param Mage_Sales_Model_Order_Creditmemo $creditMemo
369
+ * @throws Dhl_MeinPaket_Model_Xml_XmlBuildException
370
+ * @return string
371
+ */
372
+ public function createReturnRequest(Mage_Sales_Model_Order_Creditmemo $creditMemo) {
373
+ if (! $this->areAuthenticationParamtersSet ()) {
374
+ throw new Dhl_MeinPaket_Model_Xml_XmlBuildException ( 'No authentication parameters set.' );
375
+ }
376
+
377
+ $document = $this->createDocument ();
378
+
379
+ /* @var $notificationRequest Dhl_MeinPaket_Model_Xml_Partial_NotificationRequest */
380
+ $notificationRequest = Mage::getModel ( 'meinpaket/Xml_Partial_NotificationRequest' );
381
+
382
+ /* @var $returns Dhl_MeinPaket_Model_Xml_Partial_Returns */
383
+ $returns = Mage::getModel ( 'meinpaket/Xml_Partial_Returns' );
384
+
385
+ /* @var $return Dhl_MeinPaket_Model_Xml_Partial_Return */
386
+ $return = Mage::getModel ( 'meinpaket/Xml_Partial_Return' );
387
+
388
+ /* @var $returnEntry Dhl_MeinPaket_Model_Xml_Partial_ReturnEntry */
389
+ $returnEntry = null;
390
+
391
+ $comment = '';
392
+
393
+ $notificationRequest->setDocument ( $document )->build ();
394
+
395
+ $returns->setDocument ( $document )->build ();
396
+
397
+ if ($creditMemo->getCommentsCollection ()->count () > 0) {
398
+ $comment = $creditMemo->getCommentsCollection ()->getFirstItem ()->getComment ();
399
+ }
400
+
401
+ $return->setDocument ( $document )->setOrderId ( $creditMemo->getOrder ()->getDhlMeinPaketOrderId () )->setReturnId ( $creditMemo->getId () )->setComment ( $comment )->setReimbursedDeliveryCosts ( $creditMemo->getShippingAmount () )->setReduction ( $creditMemo->getAdjustment () * (- 1) )-> // @todo check if this is correct
402
+ build ();
403
+
404
+ foreach ( $creditMemo->getItemsCollection () as $item ) {
405
+ $returnEntry = Mage::getModel ( 'meinpaket/Xml_Partial_ReturnEntry' );
406
+ $returnEntry->setDocument ( $document )->setProductId ( $item->getProductId () )->setQuantity ( $item->getQty () )->build ();
407
+ $return->getNode ()->appendChild ( $returnEntry->getNode () );
408
+ }
409
+
410
+ $returns->getNode ()->appendChild ( $return->getNode () );
411
+ $notificationRequest->getNode ()->appendChild ( $this->createHeaderNode ( $document ) );
412
+ $notificationRequest->getNode ()->appendChild ( $returns->getNode () );
413
+
414
+ $document->appendChild ( $notificationRequest->getNode () );
415
+
416
+ return $document->saveXML ();
417
+ }
418
+
419
+ /**
420
+ * Creates the XML request which contains the tracking code for particular shipment.
421
+ *
422
+ * @param Mage_Sales_Model_Order_Shipment_Track $track
423
+ * @throws Dhl_MeinPaket_Model_Xml_XmlBuildException
424
+ * @return string
425
+ */
426
+ public function createShipmentTrackRequestXml(Mage_Sales_Model_Order_Shipment_Track $track) {
427
+ if (! $this->areAuthenticationParamtersSet ()) {
428
+ throw new Dhl_MeinPaket_Model_Xml_XmlBuildException ( 'No authentication parameters set.' );
429
+ }
430
+
431
+ $document = $this->createDocument ();
432
+
433
+ /* @var $notificationRequest Dhl_MeinPaket_Model_Xml_Partial_NotificationRequest */
434
+ $notificationRequest = Mage::getModel ( 'meinpaket/Xml_Partial_NotificationRequest' );
435
+
436
+ /* @var $trackingNumbers Dhl_MeinPaket_Model_Xml_Partial_TrackingNumbers */
437
+ $trackingNumbers = Mage::getModel ( 'meinpaket/Xml_Partial_TrackingNumbers' );
438
+
439
+ /* @var $trackingNumber Dhl_MeinPaket_Model_Xml_Partial_TrackingNumber */
440
+ $trackingNumber = Mage::getModel ( 'meinpaket/Xml_Partial_TrackingNumber' );
441
+
442
+ /* @var $shipmentUtil Dhl_MeinPaket_Model_Util_Shipment */
443
+ $shipmentUtil = Mage::getSingleton ( 'meinpaket/Util_Shipment' );
444
+
445
+ $consignmentId = $shipmentUtil->getConsignmentIdForShipment ( $track->getShipment () );
446
+
447
+ $notificationRequest->setDocument ( $document )->build ();
448
+
449
+ $trackingNumbers->setDocument ( $document )->build ();
450
+
451
+ $trackingNumber->setConsignmentId ( $consignmentId )->setTrackingId ( $track->getNumber () )->setDocument ( $document )->build ();
452
+
453
+ $trackingNumbers->getNode ()->appendChild ( $trackingNumber->getNode () );
454
+ $notificationRequest->getNode ()->appendChild ( $this->createHeaderNode ( $document ) );
455
+ $notificationRequest->getNode ()->appendChild ( $trackingNumbers->getNode () );
456
+
457
+ $document->appendChild ( $notificationRequest->getNode () );
458
+
459
+ return $document->saveXML ();
460
+ }
461
+ public function createProductDeleteRequest($product) {
462
+ }
463
+
464
+ /**
465
+ * Creates the XML for an external checkout.
466
+ *
467
+ * @param Dhl_MeinPaket_Model_Service_Cart_Export_Checkout $checkout
468
+ * @return string
469
+ */
470
+ public function createSubmitCartRequest(Dhl_MeinPaket_Model_Service_Cart_Export_Checkout $checkout) {
471
+ if (! $this->areAuthenticationParamtersSet ()) {
472
+ throw new Dhl_MeinPaket_Model_Xml_XmlBuildException ( 'No authentication parameters set.' );
473
+ }
474
+
475
+ $document = $this->createDocument ();
476
+
477
+ /* @var $submitCartRequest Dhl_MeinPaket_Model_Xml_Partial_SubmitCartRequest */
478
+ $submitCartRequest = Mage::getModel ( 'meinpaket/Xml_Partial_SubmitCartRequest' );
479
+
480
+ /* @var $shoppingCart Dhl_MeinPaket_Model_Xml_Partial_ShoppingCart */
481
+ $shoppingCart = Mage::getModel ( 'meinpaket/Xml_Partial_ShoppingCart' );
482
+
483
+ /* @var $shoppingCartItem Dhl_MeinPaket_Model_Xml_Partial_ShoppingCartItem */
484
+ $shoppingCartItem = null;
485
+
486
+ $submitCartRequest->setDocument ( $document )->build ();
487
+
488
+ foreach ( $checkout->getCart ()->getItems () as $item ) {
489
+ $shoppingCartItem = Mage::getModel ( 'meinpaket/xml_partial_shoppingCartItem' );
490
+ $shoppingCartItem->setDocument ( $document )->setItem ( $item )->build ();
491
+ $shoppingCart->addItem ( $shoppingCartItem );
492
+ }
493
+
494
+ $shoppingCart->setDocument ( $document )->setCheckout ( $checkout );
495
+
496
+ $shoppingCart->build ();
497
+
498
+ $submitCartRequest->getNode ()->appendChild ( $this->createHeaderNode ( $document ) );
499
+ $submitCartRequest->getNode ()->appendChild ( $shoppingCart->getNode () );
500
+
501
+ $document->appendChild ( $submitCartRequest->getNode () );
502
+
503
+ return $document->saveXML ();
504
+ }
505
+
506
+ /**
507
+ * Creates the XML request for a variant configurations download.
508
+ *
509
+ * @throws Dhl_MeinPaket_Model_Xml_XmlBuildException
510
+ * @return string
511
+ */
512
+ public function createVariantConfigurationDownloadRequest() {
513
+ if (! $this->areAuthenticationParamtersSet ()) {
514
+ throw new Dhl_MeinPaket_Model_Xml_XmlBuildException ( 'No authentication parameters set.' );
515
+ }
516
+
517
+ $document = $this->createDocument ();
518
+ $downloadRequest = Mage::getModel ( 'meinpaket/xml_partial_downloadRequest' );
519
+ $variantConfigurations = Mage::getModel ( 'meinpaket/xml_partial_variantConfigurations' );
520
+
521
+ $downloadRequest->setDocument ( $document )->build ();
522
+ $variantConfigurations->setDocument ( $document )->build ();
523
+
524
+ $downloadRequest->getNode ()->appendChild ( $this->createHeaderNode ( $document ) );
525
+ $downloadRequest->getNode ()->appendChild ( $variantConfigurations->getNode () );
526
+
527
+ $document->appendChild ( $downloadRequest->getNode () );
528
+
529
+ return $document->saveXML ();
530
+ }
531
+
532
+ /**
533
+ * Checks if the necessary authentication have been set.
534
+ *
535
+ * @return boolean
536
+ */
537
+ public function areAuthenticationParamtersSet() {
538
+ return (is_string ( $this->username ) && is_string ( $this->password ) && (strlen ( $this->username ) > 0) && (strlen ( $this->password ) > 0));
539
+ }
540
+
541
+ /**
542
+ * Creates XML for the header element which encapsulates the user credentials.
543
+ *
544
+ * @param DOMDocument $document
545
+ * @return DOMNode
546
+ */
547
+ public function createHeaderNode(DOMDocument $document) {
548
+ return Mage::getModel ( 'meinpaket/xml_partial_header' )->setDocument ( $document )->setUsername ( $this->username )->setPassword ( $this->password )->build ()->getNode ();
549
+ }
550
+ }
551
+
app/code/community/Dhl/MeinPaket/Model/Xml/XmlResponseParser.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Parses raw XML responses returned by the MeinPaket webservice.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Xml
9
+ * @version $Id$
10
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
11
+ */
12
+ class Dhl_MeinPaket_Model_Xml_XmlResponseParser extends Varien_Object {
13
+ /**
14
+ *
15
+ * @param DOMDocument $dom
16
+ * @return Dhl_MeinPaket_Model_Xml_Response_Abstract
17
+ */
18
+ public function parseResponse(DOMDocument $dom) {
19
+ if (!isset($dom->documentElement)) {
20
+ return null;
21
+ }
22
+
23
+ $documentElement = $dom->documentElement;
24
+
25
+ /* @var $result Dhl_MeinPaket_Model_Xml_Response_Abstract */
26
+ $result = null;
27
+
28
+ switch ($documentElement->localName) {
29
+ case 'asynchronousStatusResponse' :
30
+ $result = new Dhl_MeinPaket_Model_Xml_Response_AsynchronousStatusResponse ( $documentElement );
31
+ break;
32
+ case 'downloadResponse' :
33
+ $result = new Dhl_MeinPaket_Model_Xml_Response_DownloadResponse ( $documentElement );
34
+ break;
35
+ case 'uploadResponse' :
36
+ $result = new Dhl_MeinPaket_Model_Xml_Response_UploadResponse ( $documentElement );
37
+ break;
38
+ case 'dataResponse' :
39
+ $result = new Dhl_MeinPaket_Model_Xml_Response_DataResponse ( $documentElement );
40
+ break;
41
+ case 'notificationResponse' :
42
+ $result = new Dhl_MeinPaket_Model_Xml_Response_NotificationResponse ( $documentElement );
43
+ break;
44
+ case 'queryResponse' :
45
+ $result = new Dhl_MeinPaket_Model_Xml_Response_QueryResponse ( $documentElement );
46
+ break;
47
+ case 'shoppingCartStatusResponse' :
48
+ break;
49
+ }
50
+
51
+ if ($result != null) {
52
+ $result->process ();
53
+ }
54
+
55
+ return $result;
56
+ }
57
+ }
58
+
app/code/community/Dhl/MeinPaket/controllers/Adminhtml/AsyncController.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ */
6
+ class Dhl_MeinPaket_Adminhtml_AsyncController extends Mage_Adminhtml_Controller_Action {
7
+ protected function _initAction() {
8
+ $this->loadLayout ()->_setActiveMenu ( 'meinpaket/async' )->_addBreadcrumb ( Mage::helper ( 'meinpaket' )->__ ( 'Async' ), Mage::helper ( 'meinpaket' )->__ ( 'Async' ) );
9
+ return $this;
10
+ }
11
+ public function indexAction() {
12
+ $this->_initAction ()->renderLayout ();
13
+ }
14
+ public function exportCsvAction() {
15
+ $fileName = 'async.csv';
16
+ $grid = $this->getLayout ()->createBlock ( 'meinpaket/adminhtml_async_grid' );
17
+ $this->_prepareDownloadResponse ( $fileName, $grid->getCsvFile () );
18
+ }
19
+ public function exportExcelAction() {
20
+ $fileName = 'async.xml';
21
+ $grid = $this->getLayout ()->createBlock ( 'meinpaket/adminhtml_async_grid' );
22
+ $this->_prepareDownloadResponse ( $fileName, $grid->getExcelFile ( $fileName ) );
23
+ }
24
+ public function massDeleteAction() {
25
+ $asyncIds = $this->getRequest ()->getParam ( 'asyncIds' );
26
+ if (! is_array ( $asyncIds )) {
27
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( Mage::helper ( 'meinpaket' )->__ ( 'Please select async entries.' ) );
28
+ } else {
29
+ try {
30
+ $asyncModel = Mage::getModel ( 'meinpaket/async' );
31
+ foreach ( $asyncIds as $asyncId ) {
32
+ $asyncModel->load ( $asyncId )->delete ();
33
+ }
34
+ Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( Mage::helper ( 'meinpaket' )->__ ( 'Total of %d record(s) were deleted.', count ( $asyncIds ) ) );
35
+ } catch ( Exception $e ) {
36
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $e->getMessage () );
37
+ }
38
+ }
39
+ $this->_redirect ( '*/*/index' );
40
+ }
41
+
42
+ /**
43
+ * Mass action: schedule
44
+ *
45
+ * @return void
46
+ */
47
+ public function scheduleAction() {
48
+ $cronjobs = $this->getCronjobs ();
49
+ Mage::helper ( 'meinpaket/cron' )->scheduleJobs ( $cronjobs, true );
50
+ $this->_redirect ( '*/*/index' );
51
+ }
52
+
53
+ /**
54
+ * Mass action: run
55
+ *
56
+ * @return void
57
+ */
58
+ public function runAction() {
59
+ $cronjobs = $this->getCronjobs ();
60
+ Mage::helper ( 'meinpaket/cron' )->runJobs ( $cronjobs, true );
61
+ $this->_redirect ( '*/*/index' );
62
+ }
63
+
64
+ /**
65
+ * Get cronjobs from request.
66
+ *
67
+ * @return array of cronjobs
68
+ */
69
+ private function getCronjobs() {
70
+ $cronjob = $this->getRequest ()->getParam ( 'cronjob', 'all' );
71
+ if ($cronjob == 'all') {
72
+ return Dhl_MeinPaket_Model_Cron::$CRONJOBS;
73
+ } else if (in_array ( $cronjob, Dhl_MeinPaket_Model_Cron::$CRONJOBS )) {
74
+ return array (
75
+ $cronjob
76
+ );
77
+ }
78
+ return null;
79
+ }
80
+
81
+ /**
82
+ * Product grid for AJAX request.
83
+ * Sort and filter result for example.
84
+ */
85
+ public function gridAction() {
86
+ $this->loadLayout ();
87
+ $this->getResponse ()->setBody ( $this->getLayout ()->createBlock ( 'meinpaket/adminhtml_async_grid' )->toHtml () );
88
+ }
89
+ }
app/code/community/Dhl/MeinPaket/controllers/Adminhtml/Backlog/ProductController.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Adminhtml_Backlog_ProductController extends Mage_Adminhtml_Controller_Action {
3
+ protected function _initAction() {
4
+ $this->loadLayout ()->_setActiveMenu ( 'meinpaket/backlog' )->_addBreadcrumb ( Mage::helper ( 'meinpaket' )->__ ( 'Backlog' ), Mage::helper ( 'meinpaket' )->__ ( 'Backlog' ) );
5
+ return $this;
6
+ }
7
+ public function indexAction() {
8
+ $this->_initAction ()->renderLayout ();
9
+ }
10
+ public function exportCsvAction() {
11
+ $fileName = 'backlog.csv';
12
+ $grid = $this->getLayout ()->createBlock ( 'meinpaket/adminhtml_backlog_product_grid' );
13
+ $this->_prepareDownloadResponse ( $fileName, $grid->getCsvFile () );
14
+ }
15
+ public function exportExcelAction() {
16
+ $fileName = 'backlog.xml';
17
+ $grid = $this->getLayout ()->createBlock ( 'meinpaket/adminhtml_backlog_product_grid' );
18
+ $this->_prepareDownloadResponse ( $fileName, $grid->getExcelFile ( $fileName ) );
19
+ }
20
+ public function massDeleteAction() {
21
+ $backlogIds = $this->getRequest ()->getParam ( 'backlogIds' );
22
+ if (! is_array ( $backlogIds )) {
23
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( Mage::helper ( 'meinpaket' )->__ ( 'Please select backlog entries.' ) );
24
+ } else {
25
+ try {
26
+ $backlogModel = Mage::getModel ( 'meinpaket/backlog_product' );
27
+ foreach ( $backlogIds as $backlogId ) {
28
+ $backlogModel->load ( $backlogId )->delete ();
29
+ }
30
+ Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( Mage::helper ( 'meinpaket' )->__ ( 'Total of %d record(s) were deleted.', count ( $backlogIds ) ) );
31
+ } catch ( Exception $e ) {
32
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $e->getMessage () );
33
+ }
34
+ }
35
+ $this->_redirect ( '*/*/index' );
36
+ }
37
+
38
+ /**
39
+ * Product grid for AJAX request.
40
+ * Sort and filter result for example.
41
+ */
42
+ public function gridAction() {
43
+ $this->loadLayout ();
44
+ $this->getResponse ()->setBody ( $this->getLayout ()->createBlock ( 'meinpaket/adminhtml_backlog_product_grid' )->toHtml () );
45
+ }
46
+
47
+ /**
48
+ * Mass action: schedule
49
+ *
50
+ * @return void
51
+ */
52
+ public function scheduleAction() {
53
+ $cronjobs = $this->getCronjobs ();
54
+ Mage::helper ( 'meinpaket/cron' )->scheduleJobs ( $cronjobs, true );
55
+ $this->_redirect ( '*/*/index' );
56
+ }
57
+
58
+ /**
59
+ * Mass action: run
60
+ *
61
+ * @return void
62
+ */
63
+ public function runAction() {
64
+ $cronjobs = $this->getCronjobs ();
65
+ Mage::helper ( 'meinpaket/cron' )->runJobs ( $cronjobs, true );
66
+ $this->_redirect ( '*/*/index' );
67
+ }
68
+
69
+ /**
70
+ * Get cronjobs from request.
71
+ *
72
+ * @return array of cronjobs
73
+ */
74
+ private function getCronjobs() {
75
+ $cronjob = $this->getRequest ()->getParam ( 'cronjob', 'all' );
76
+ if ($cronjob == 'all') {
77
+ return Dhl_MeinPaket_Model_Cron::$CRONJOBS;
78
+ } else if (in_array ( $cronjob, Dhl_MeinPaket_Model_Cron::$CRONJOBS )) {
79
+ return array (
80
+ $cronjob
81
+ );
82
+ }
83
+ return null;
84
+ }
85
+ }
app/code/community/Dhl/MeinPaket/controllers/Adminhtml/BestPriceController.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ */
6
+ class Dhl_MeinPaket_Adminhtml_BestPriceController extends Mage_Adminhtml_Controller_Action {
7
+ protected function _initAction() {
8
+ $this->loadLayout ()->_setActiveMenu ( 'meinpaket/bestprice' )->_addBreadcrumb ( Mage::helper ( 'meinpaket' )->__ ( 'Best Price' ), Mage::helper ( 'meinpaket' )->__ ( 'Best Price' ) );
9
+ return $this;
10
+ }
11
+ public function indexAction() {
12
+ $this->_initAction ()->renderLayout ();
13
+ }
14
+ public function exportCsvAction() {
15
+ $fileName = 'bestprice.csv';
16
+ $grid = $this->getLayout ()->createBlock ( 'meinpaket/adminhtml_bestPrice_grid' );
17
+ $this->_prepareDownloadResponse ( $fileName, $grid->getCsvFile () );
18
+ }
19
+ public function exportExcelAction() {
20
+ $fileName = 'bestprice.xml';
21
+ $grid = $this->getLayout ()->createBlock ( 'meinpaket/adminhtml_bestPrice_grid' );
22
+ $this->_prepareDownloadResponse ( $fileName, $grid->getExcelFile ( $fileName ) );
23
+ }
24
+
25
+ /**
26
+ * Product grid for AJAX request.
27
+ * Sort and filter result for example.
28
+ */
29
+ public function gridAction() {
30
+ $this->loadLayout ();
31
+ $this->getResponse ()->setBody ( $this->getLayout ()->createBlock ( 'meinpaket/adminhtml_bestPrice_grid' )->toHtml () );
32
+ }
33
+ }
app/code/community/Dhl/MeinPaket/controllers/Adminhtml/CategoryImportController.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Controller for MeinPaket marketplace category structure import.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Adminhtml
9
+ * @version $Id$
10
+ * @author Daniel Pötzinger <daniel.poetzinger@aoemedia.de>
11
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
12
+ */
13
+ class Dhl_MeinPaket_Adminhtml_CategoryImportController extends Mage_Adminhtml_Controller_Action {
14
+ /**
15
+ * Initializes the controller.
16
+ *
17
+ * @return Dhl_MeinPaket_Adminhtml_CategoryImportController
18
+ */
19
+ protected function _initAction() {
20
+ $this->loadLayout ()->_setActiveMenu ( 'meinpaket' ); // TODO how to make this via configuration?
21
+ $this->_title ( $this->__ ( 'MeinPaket.de' ) )->_title ( $this->__ ( 'Category Import' ) );
22
+ return $this;
23
+ }
24
+
25
+ /**
26
+ * Default action.
27
+ *
28
+ * @return void
29
+ */
30
+ public function indexAction() {
31
+ $this->_initAction ();
32
+ $this->renderLayout ();
33
+ }
34
+
35
+ /**
36
+ * Processes the category import and displays the results.
37
+ *
38
+ * @return void
39
+ */
40
+ public function importAction() {
41
+ /* @var $service Dhl_MeinPaket_Model_MarketplaceCategoryStructureImportService */
42
+ $service = Mage::getModel ( 'meinpaket/Service_MarketplaceCategoryImport_ImportService' );
43
+
44
+ /* @var $result Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result */
45
+ $result = null;
46
+
47
+ $errorMsg = '';
48
+
49
+ try {
50
+ $result = $service->importMarketplaceCategoryStructure ();
51
+ } catch ( Dhl_MeinPaket_Model_Client_BadHttpReturnCodeException $e ) {
52
+ Mage::logException ( $e );
53
+ $errorMsg = $this->__ ( 'Connecting to MeinPaket.de server failed.' );
54
+ } catch ( Dhl_MeinPaket_Model_Client_HttpTimeoutException $e ) {
55
+ Mage::logException ( $e );
56
+ $errorMsg = $this->__ ( 'Connection to MeinPaket.de server timed out.' );
57
+ } catch ( Exception $e ) {
58
+ Mage::logException ( $e );
59
+ $errorMsg = $this->__ ( 'Unknown error' ) . '. (' . $e->getMessage () . ')';
60
+ }
61
+
62
+ if (strlen ( $errorMsg ) > 0) {
63
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $this->__ ( 'Error' ) . ': ' . $errorMsg );
64
+ } else {
65
+ Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( $this->__ ( 'Successfully imported marketplace categories.' ) );
66
+ }
67
+
68
+ if ($result !== null) {
69
+
70
+ $countNew = $result->getNewCategoriesCount ();
71
+ $countRenamed = $result->getUpdatedCategoriesCount ();
72
+ $countDeleted = $result->getDeletedCategoriesCount ();
73
+
74
+ if ($countNew > 0) {
75
+ Mage::getSingleton ( 'adminhtml/session' )->addNotice ( sprintf ( $this->__ ( 'Added %s new categories.' ), $countNew ) );
76
+ }
77
+ if ($countRenamed > 0) {
78
+ Mage::getSingleton ( 'adminhtml/session' )->addNotice ( sprintf ( $this->__ ( 'Renamed %s categories.' ), $countRenamed ) );
79
+ }
80
+ if ($countDeleted > 0) {
81
+ Mage::getSingleton ( 'adminhtml/session' )->addNotice ( sprintf ( $this->__ ( 'Deleted %s categories.' ), $countDeleted ) );
82
+ }
83
+ }
84
+
85
+ $this->_initAction ();
86
+
87
+ if ($result !== null) {
88
+ $this->getLayout ()->getBlock ( 'meinpaket.adminhtml_categoryImport_import' )->setResult ( $result );
89
+ }
90
+
91
+ $this->renderLayout ();
92
+ }
93
+ }
app/code/community/Dhl/MeinPaket/controllers/Adminhtml/LogController.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ */
6
+ class Dhl_MeinPaket_Adminhtml_LogController extends Mage_Adminhtml_Controller_Action {
7
+ protected function _initAction() {
8
+ $this->loadLayout ()->_setActiveMenu ( 'meinpaket/log' )->_addBreadcrumb ( Mage::helper ( 'meinpaket' )->__ ( 'Log' ), Mage::helper ( 'meinpaket' )->__ ( 'Log' ) );
9
+ return $this;
10
+ }
11
+ public function indexAction() {
12
+ $this->_initAction ()->renderLayout ();
13
+ }
14
+ public function exportCsvAction() {
15
+ $fileName = 'log.csv';
16
+ $grid = $this->getLayout ()->createBlock ( 'meinpaket/adminhtml_log_grid' );
17
+ $this->_prepareDownloadResponse ( $fileName, $grid->getCsvFile () );
18
+ }
19
+ public function exportExcelAction() {
20
+ $fileName = 'log.xml';
21
+ $grid = $this->getLayout ()->createBlock ( 'meinpaket/adminhtml_log_grid' );
22
+ $this->_prepareDownloadResponse ( $fileName, $grid->getExcelFile ( $fileName ) );
23
+ }
24
+ public function massDeleteAction() {
25
+ $logIds = $this->getRequest ()->getParam ( 'logIds' );
26
+ if (! is_array ( $logIds )) {
27
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( Mage::helper ( 'meinpaket' )->__ ( 'Please select log entries.' ) );
28
+ } else {
29
+ try {
30
+ $logModel = Mage::getModel ( 'meinpaket/log' );
31
+ foreach ( $logIds as $logId ) {
32
+ $logModel->load ( $logId )->delete ();
33
+ }
34
+ Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( Mage::helper ( 'meinpaket' )->__ ( 'Total of %d record(s) were deleted.', count ( $logIds ) ) );
35
+ } catch ( Exception $e ) {
36
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $e->getMessage () );
37
+ }
38
+ }
39
+ $this->_redirect ( '*/*/index' );
40
+ }
41
+ public function massProcessAction() {
42
+ $logIds = $this->getRequest ()->getParam ( 'logIds' );
43
+ if (! is_array ( $logIds )) {
44
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( Mage::helper ( 'meinpaket' )->__ ( 'Please select log entries.' ) );
45
+ } else {
46
+ try {
47
+ $logModel = Mage::getModel ( 'meinpaket/log' );
48
+ foreach ( $logIds as $logId ) {
49
+ $logModel->load ( $logId );
50
+ $xmlDocument = new DOMDocument();
51
+ $xmlDocument->loadXML($logModel->getReceived());
52
+ Mage::getModel('meinpaket/xml_xmlResponseParser')->parseResponse($xmlDocument);
53
+ }
54
+ Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( Mage::helper ( 'meinpaket' )->__ ( 'Total of %d record(s) were deleted.', count ( $logIds ) ) );
55
+ } catch ( Exception $e ) {
56
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $e->getMessage () );
57
+ }
58
+ }
59
+ $this->_redirect ( '*/*/index' );
60
+ }
61
+
62
+
63
+ /**
64
+ * Product grid for AJAX request.
65
+ * Sort and filter result for example.
66
+ */
67
+ public function gridAction() {
68
+ $this->loadLayout ();
69
+ $this->getResponse ()->setBody ( $this->getLayout ()->createBlock ( 'meinpaket/adminhtml_log_grid' )->toHtml () );
70
+ }
71
+ }
app/code/community/Dhl/MeinPaket/controllers/Adminhtml/MatchingController.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ */
6
+ class Dhl_MeinPaket_Adminhtml_MatchingController extends Mage_Adminhtml_Controller_Action {
7
+ /**
8
+ * Get custom products grid and serializer block
9
+ */
10
+ public function indexAction() {
11
+ Mage::register ( 'sendName', $this->getRequest ()->getParam ( 'name', false ) );
12
+ Mage::register ( 'sendEan', $this->getRequest ()->getParam ( 'ean', false ) );
13
+
14
+ $this->_initProduct ();
15
+ $this->loadLayout ();
16
+ $this->renderLayout ();
17
+ }
18
+ public function applyAction() {
19
+ $product = $this->_initProduct ();
20
+ $categoryString = $this->getRequest ()->getParam ( 'category' );
21
+
22
+ if (strlen ( $categoryString )) {
23
+ $product->setMeinpaketCategory ( $categoryString );
24
+ $product->save ();
25
+ Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( 'Category assigned ' );
26
+ } else {
27
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( 'No category given' );
28
+ }
29
+
30
+ $this->_redirect ( 'adminhtml/catalog_product/edit', array (
31
+ 'id' => $product->getId ()
32
+ ) );
33
+ }
34
+
35
+ /**
36
+ * Try to load product from request.
37
+ *
38
+ * @return Mage_Catalog_Model_Product
39
+ */
40
+ protected function _initProduct() {
41
+ $productId = ( int ) $this->getRequest ()->getParam ( 'id' );
42
+ $product = Mage::getModel ( 'catalog/product' )->setStoreId ( $this->getRequest ()->getParam ( 'store', 0 ) );
43
+
44
+ if ($productId) {
45
+ $product->load ( $productId );
46
+ }
47
+
48
+ Mage::register ( 'product', $product );
49
+ Mage::register ( 'current_product', $product );
50
+ return $product;
51
+ }
52
+ }
app/code/community/Dhl/MeinPaket/controllers/Adminhtml/OrderImportController.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Controller for MeinPaket order import.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Adminhtml
9
+ * @version $Id$
10
+ * @author Daniel Pötzinger <daniel.poetzinger@aoemedia.de>
11
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
12
+ */
13
+ class Dhl_MeinPaket_Adminhtml_OrderImportController extends Mage_Adminhtml_Controller_Action {
14
+ /**
15
+ * Initialized the controller.
16
+ *
17
+ * @return Dhl_MeinPaket_Adminhtml_OrderImportController
18
+ */
19
+ protected function _initAction() {
20
+ $this->loadLayout ()->_setActiveMenu ( 'meinpaket' );
21
+ $this->_title ( $this->__ ( 'MeinPaket.de' ) )->_title ( $this->__ ( 'Order Import' ) );
22
+ return $this;
23
+ }
24
+
25
+ /**
26
+ * Default controller action.
27
+ *
28
+ * @return void
29
+ */
30
+ public function indexAction() {
31
+ $this->_initAction ();
32
+ $this->renderLayout ();
33
+ }
34
+
35
+ /**
36
+ * Triggers the import process.
37
+ *
38
+ * @return void
39
+ */
40
+ public function importAction() {
41
+ /* @var $OrderImportService Dhl_MeinPaket_Model_Order_ImportService */
42
+ $OrderImportService = Mage::getModel ( 'meinpaket/Order_ImportService' );
43
+ $startdate = $this->getRequest ()->getParam ( 'startdate', 0 );
44
+ $enddate = $this->getRequest ()->getParam ( 'enddate', 0 );
45
+
46
+ if ($startdate == 0) {
47
+ $startdate = time () - 3600;
48
+ } else {
49
+ $startdate = $this->parseTime ( $startdate );
50
+ }
51
+ if ($enddate == 0) {
52
+ $enddate = $this->parseTime ( date ( 'm' ) . '/' . date ( 'd' ) . '/' . date ( 'y' ), true );
53
+ } else {
54
+ $enddate = $this->parseTime ( $enddate, true );
55
+ }
56
+
57
+ try {
58
+ $status = $OrderImportService->importOrders ( $startdate, $enddate );
59
+ } catch ( Exception $e ) {
60
+ Mage::logException ( $e );
61
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( 'An error occured: ' . $e->getMessage () );
62
+ }
63
+
64
+ if ($OrderImportService->wasServiceResponseMalformed ()) {
65
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( __ ( 'The MeinPaket server did not deliver a valid response. Have a look at the system log for more information.' ) );
66
+ } else {
67
+ $orderCount = $OrderImportService->getOrderCount ();
68
+
69
+ if ($orderCount ['imported'] > 0) {
70
+ $message = sprintf ( __ ( '%s order(s) sucessfully imported.' ), $orderCount ['imported'] );
71
+ Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( $message );
72
+ } elseif ($orderCount ['outOfStock'] === 0) {
73
+ Mage::getSingleton ( 'adminhtml/session' )->addNotice ( __ ( 'No new orders found.' ) );
74
+ }
75
+
76
+ if ($orderCount ['duplicates'] > 0) {
77
+ if ($orderCount ['duplicates'] > 1)
78
+ $message = sprintf ( __ ( 'Skipped %s duplicate orders that were already imported previously.' ), $orderCount ['duplicates'] );
79
+ else
80
+ $message = sprintf ( __ ( 'Skipped %s duplicate order that was already imported previously.' ), $orderCount ['duplicates'] );
81
+
82
+ Mage::getSingleton ( 'adminhtml/session' )->addNotice ( $message );
83
+ }
84
+
85
+ if ($orderCount ['outOfStock'] > 0) {
86
+ $message = sprintf ( __ ( 'Skipped %s order(s) because: out of stock. Please process the following order(s) at your MeinPaket.de dealer area:' ), $orderCount ['outOfStock'] );
87
+ $dhlOrderIds = implode ( ', ', $OrderImportService->getOutOfStockOrders () );
88
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $message . " " . $dhlOrderIds );
89
+ }
90
+
91
+ if ($orderCount ['disabled'] > 0) {
92
+ $message = sprintf ( __ ( 'Skipped %s order(s) because: some or all of the included products were disabled in Magento after the export to MeinPaket.de . Please process the following order(s) at your MeinPaket.de dealer area:' ), $orderCount ['disabled'] );
93
+ $disabledDhlOrderIds = implode ( ', ', $OrderImportService->getDisabledProductOrders () );
94
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $message . " " . $disabledDhlOrderIds );
95
+ }
96
+ }
97
+
98
+ $this->_initAction ();
99
+ $this->renderLayout ();
100
+ }
101
+
102
+ /**
103
+ * Converts a date string in the format "MM/DD/YY" into a timestamp.
104
+ *
105
+ * @param string $data
106
+ * Must be formatted as "MM/DD/YY"
107
+ * @param boolean $toEndOfDay
108
+ * If set to true the time of the day will be set to "23:59:59", otherwise "00:00:00".
109
+ * @return integer timestamp
110
+ */
111
+ private function parseTime($data, $toEndOfDay = false) {
112
+ $seconds = 0;
113
+ $minutes = 0;
114
+ $hours = 0;
115
+ $timeData = strptime ( $data, '%m/%e/%y' );
116
+
117
+ if ($toEndOfDay === true) {
118
+ $seconds = 59;
119
+ $minutes = 59;
120
+ $hours = 23;
121
+ }
122
+
123
+ return mktime ( $hours, $minutes, $seconds, $timeData ['tm_mon'] + 1, $timeData ['tm_mday'], 1900 + $timeData ['tm_year'] );
124
+ }
125
+ }
app/code/community/Dhl/MeinPaket/controllers/Adminhtml/ProductExportController.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Controls the export of local products to MeinPaket.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Adminhtml
9
+ * @version $Id$
10
+ * @author Daniel Pötzinger <daniel.poetzinger@aoemedia.de>
11
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
12
+ */
13
+ class Dhl_MeinPaket_Adminhtml_ProductExportController extends Mage_Adminhtml_Controller_Action {
14
+ /**
15
+ *
16
+ * @var integer
17
+ */
18
+ const PRODUCT_SELECTION_MODE_SYNCED_ONLY = 1;
19
+
20
+ /**
21
+ *
22
+ * @var integer
23
+ */
24
+ const PRODUCT_SELECTION_MODE_ALL = 2;
25
+
26
+ /**
27
+ *
28
+ * @var integer
29
+ */
30
+ protected $_defaultSelectionMode = self::PRODUCT_SELECTION_MODE_SYNCED_ONLY;
31
+
32
+ /**
33
+ * Initialization.
34
+ *
35
+ * @return Dhl_MeinPaket_Adminhtml_ProductExportController
36
+ */
37
+ protected function _initAction() {
38
+ $this->loadLayout ()->_setActiveMenu ( 'meinpaket' );
39
+
40
+ $this->_title ( $this->__ ( 'MeinPaket.de' ) )->_title ( $this->__ ( 'Product Export' ) );
41
+
42
+ return $this;
43
+ }
44
+
45
+ /**
46
+ * Default action.
47
+ *
48
+ * @return void
49
+ */
50
+ public function indexAction() {
51
+ $this->_initAction ();
52
+ $this->renderLayout ();
53
+ }
54
+
55
+ /**
56
+ * Shows a list of the selected products.
57
+ *
58
+ * @return void
59
+ */
60
+ public function listAction() {
61
+ $this->_initAction ();
62
+ $this->getLayout ()->getBlock ( 'meinpaket.adminhtml_productExport_list' )->assignProductCollection ( $this->getProductCollection () );
63
+
64
+ $this->renderLayout ();
65
+ }
66
+
67
+ /**
68
+ * Transfers descriptions and offers of the selected products to MeinPaket.
69
+ *
70
+ * @return void
71
+ */
72
+ public function exportAction() {
73
+ /* @var $exportService Dhl_MeinPaket_Model_Service_Product_Export */
74
+ $exportService = Mage::getModel ( 'meinpaket/service_product_export' );
75
+
76
+ /* @var $results Dhl_MeinPaket_Model_Service_Product_Export_Result */
77
+ $results = null;
78
+
79
+ try {
80
+ $results = $exportService->exportProducts ( );
81
+
82
+ if ($debugMode) {
83
+ Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( 'DEBUG:' . $results->debugOutput () );
84
+ }
85
+ if (count ( $results->getFullyConfirmedProductIds () ) > 0) {
86
+ Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( sprintf ( $this->__ ( '%s of %s products were successfully exported' ), count ( $results->getFullyConfirmedProductIds () ), $collection->count () ) );
87
+ } else {
88
+ Mage::getSingleton ( 'adminhtml/session' )->addNotice ( $this->__ ( 'There were no products that could be exported.' ) );
89
+ }
90
+ } catch ( Dhl_MeinPaket_Model_Xml_XmlBuildException $xmlBuildException ) {
91
+ Mage::logException ( $xmlBuildException );
92
+ $exceptionMsg = $this->__ ( 'Product export failed. Request could not be built.' );
93
+ Mage::logException ( $xmlBuildException );
94
+ } catch ( Dhl_MeinPaket_Model_Client_HttpException $httpException ) {
95
+ Mage::logException ( $httpException );
96
+ $exceptionMsg = $this->__ ( 'Product export failed. Failed connecting to MeinPaket server.' );
97
+ Mage::logException ( $httpException );
98
+ } catch ( Exception $e ) {
99
+ Mage::logException ( $e );
100
+ $exceptionMsg = $this->__ ( 'Product export failed for unknown reason.' );
101
+ }
102
+
103
+ if (strlen ( $exceptionMsg ) > 0) {
104
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $exceptionMsg );
105
+ }
106
+
107
+ $this->_initAction ();
108
+ $block = $this->getLayout ()->getBlock ( 'meinpaket.adminhtml_productExport_export' );
109
+ /*
110
+ if ($results !== null) {
111
+ $block->setResults ( $results );
112
+ }
113
+ */
114
+ $this->renderLayout ();
115
+ }
116
+
117
+ /**
118
+ * Do nothin.
119
+ *
120
+ * @return void
121
+ */
122
+ public function emptyAction() {
123
+ $this->_initAction ();
124
+ $this->renderLayout ();
125
+ }
126
+
127
+ /**
128
+ * Returns a collection of the products which have to be exported.
129
+ *
130
+ * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
131
+ */
132
+ private function getProductCollection() {
133
+ /* @var $selectService Dhl_MeinPaket_Model_Service_Product_Export_Select */
134
+ $selectService = Mage::getModel ( 'meinpaket/service_product_export_select' );
135
+ $productselection = $this->getRequest ()->getParam ( 'productselection' );
136
+
137
+ if ($productselection == 2) {
138
+ return $selectService->getProductsForExport ( FALSE );
139
+ } else {
140
+ return $selectService->getProductsForExport ( TRUE );
141
+ }
142
+ }
143
+ }
app/code/community/Dhl/MeinPaket/etc/adminhtml.xml ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <translate>
4
+ <modules>
5
+ <Dhl_adminhtml>
6
+ <files>
7
+ <meinpaket>Dhl_Meinpaket.csv</meinpaket>
8
+ </files>
9
+ </Dhl_adminhtml>
10
+ </modules>
11
+ </translate>
12
+ <menu>
13
+ <meinpaket>
14
+ <title>MeinPaket.de</title>
15
+ <children>
16
+ <meinpaket_backlog translate="title" module="meinpaket">
17
+ <title>Synchronisation</title>
18
+ <action>meinpaket/adminhtml_backlog_product</action>
19
+ </meinpaket_backlog>
20
+ <!-- <meinpaket_productexport translate="title"> <title>export products</title> <action>meinpaket/adminhtml_productExport</action>
21
+ </meinpaket_productexport> <meinpaket_orderimport translate="title"> <title>import orders</title> <action>meinpaket/adminhtml_orderImport</action>
22
+ </meinpaket_orderimport> -->
23
+ <meinpaket_categoryimport translate="title">
24
+ <title>import categories</title>
25
+ <action>meinpaket/adminhtml_categoryImport</action>
26
+ </meinpaket_categoryimport>
27
+ <!-- <meinpaket_attributemapping translate="title"> <title>attribute mapping</title> <action>meinpaket/adminhtml_attributeMapping</action>
28
+ </meinpaket_attributemapping> -->
29
+ <meinpaket_log translate="title" module="meinpaket">
30
+ <title>Log</title>
31
+ <action>meinpaket/adminhtml_log</action>
32
+ </meinpaket_log>
33
+ <meinpaket_async translate="title" module="meinpaket">
34
+ <title>Async</title>
35
+ <action>meinpaket/adminhtml_async</action>
36
+ </meinpaket_async>
37
+ <meinpaket_bestprice translate="title">
38
+ <title>best prices</title>
39
+ <action>meinpaket/adminhtml_bestPrice</action>
40
+ </meinpaket_bestprice>
41
+ </children>
42
+ <sort_order>90</sort_order>
43
+ <class>meinpaket</class>
44
+ </meinpaket>
45
+ </menu>
46
+ <acl>
47
+ <resources>
48
+ <admin>
49
+ <children>
50
+ <system>
51
+ <children>
52
+ <config>
53
+ <children>
54
+ <meinpaket translate="title" module="Dhl_MeinPaket">
55
+ <title>MeinPaket.de.de</title>
56
+ <sort_order>100</sort_order>
57
+ </meinpaket>
58
+ </children>
59
+ </config>
60
+ </children>
61
+ </system>
62
+ </children>
63
+ </admin>
64
+ </resources>
65
+ </acl>
66
+ </config>
app/code/community/Dhl/MeinPaket/etc/config.xml ADDED
@@ -0,0 +1,337 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dhl_MeinPaket>
5
+ <version>2.0.8</version>
6
+ </Dhl_MeinPaket>
7
+ </modules>
8
+ <admin>
9
+ <routers>
10
+ <meinpaket>
11
+ <use>admin</use>
12
+ <args>
13
+ <module>Dhl_MeinPaket</module>
14
+ <frontName>meinpaket</frontName>
15
+ </args>
16
+ </meinpaket>
17
+ </routers>
18
+ </admin>
19
+ <adminhtml>
20
+ <translate>
21
+ <modules>
22
+ <meinpaket>
23
+ <files>
24
+ <default>Dhl_MeinPaket.csv</default>
25
+ </files>
26
+ </meinpaket>
27
+ </modules>
28
+ </translate>
29
+ <layout>
30
+ <updates>
31
+ <meinpaket>
32
+ <file>meinpaket.xml</file>
33
+ </meinpaket>
34
+ </updates>
35
+ </layout>
36
+ </adminhtml>
37
+ <crontab>
38
+ <jobs>
39
+ <meinpaket_processAsyncTasks>
40
+ <schedule>
41
+ <config_path>meinpaket/cron/async</config_path>
42
+ </schedule>
43
+ <run>
44
+ <model>meinpaket/cron::processAsyncTasks</model>
45
+ </run>
46
+ </meinpaket_processAsyncTasks>
47
+ <meinpaket_importOrders>
48
+ <schedule>
49
+ <config_path>meinpaket/cron/order</config_path>
50
+ </schedule>
51
+ <run>
52
+ <model>meinpaket/cron::importOrders</model>
53
+ </run>
54
+ </meinpaket_importOrders>
55
+ <meinpaket_exportProducts>
56
+ <schedule>
57
+ <config_path>meinpaket/cron/product</config_path>
58
+ </schedule>
59
+ <run>
60
+ <model>meinpaket/cron::exportProducts</model>
61
+ </run>
62
+ </meinpaket_exportProducts>
63
+ <meinpaket_getBestPrice>
64
+ <schedule>
65
+ <config_path>meinpaket/cron/bestprice</config_path>
66
+ </schedule>
67
+ <run>
68
+ <model>meinpaket/cron::getBestPrice</model>
69
+ </run>
70
+ </meinpaket_getBestPrice>
71
+ <meinpaket_cleanup>
72
+ <schedule>
73
+ <config_path>meinpaket/cron/cleanup</config_path>
74
+ </schedule>
75
+ <run>
76
+ <model>meinpaket/cron::cleanup</model>
77
+ </run>
78
+ </meinpaket_cleanup>
79
+ </jobs>
80
+ </crontab>
81
+ <default>
82
+ <payment>
83
+ <meinpaket>
84
+ <active>1</active>
85
+ <model>meinpaket/payment_method_meinpaket</model>
86
+ <order_status>pending</order_status>
87
+ <title>MeinPaket</title>
88
+ <allowspecific>0</allowspecific>
89
+ <group>offline</group>
90
+ </meinpaket>
91
+ </payment>
92
+ <carriers>
93
+ <meinpaket>
94
+ <active>1</active>
95
+ <sallowspecific>0</sallowspecific>
96
+ <allowed_methods>method1</allowed_methods>
97
+ <title>MeinPaket.de</title>
98
+ <name>MeinPaket</name>
99
+ <handling_fee>1.00</handling_fee>
100
+ <handling_type>F</handling_type>
101
+ <handling_action>P</handling_action>
102
+ <model>meinpaket/carrier_meinpaket</model>
103
+ </meinpaket>
104
+ </carriers>
105
+ <meinpaket>
106
+ <endpoint>
107
+ <sandbox>0</sandbox>
108
+ <https>1</https>
109
+ <proxy></proxy>
110
+ <proxy_host></proxy_host>
111
+ <proxy_port></proxy_port>
112
+ </endpoint>
113
+ <shipment>
114
+ <default_shipment_method>flatrate_flatrate</default_shipment_method>
115
+ </shipment>
116
+ <checkout>
117
+ <available>0</available>
118
+ <submit_shipping_costs>0</submit_shipping_costs>
119
+ </checkout>
120
+ <product_attributes>
121
+ <default_delivery_time>5</default_delivery_time>
122
+ </product_attributes>
123
+ <cron>
124
+ <async>*/10 * * * *</async>
125
+ <product>0 * * * *</product>
126
+ <order>*/15 * * * *</order>
127
+ <bestprice>15 3 * * *</bestprice>
128
+ <cleanup>0 6 * * *</cleanup>
129
+ </cron>
130
+ </meinpaket>
131
+ </default>
132
+ <frontend>
133
+ <translate>
134
+ <modules>
135
+ <meinpaket>
136
+ <files>
137
+ <default>Dhl_MeinPaket.csv</default>
138
+ </files>
139
+ </meinpaket>
140
+ </modules>
141
+ </translate>
142
+ <routers>
143
+ <meinpaket>
144
+ <use>standard</use>
145
+ <args>
146
+ <module>Dhl_MeinPaket</module>
147
+ <frontName>meinpaket</frontName>
148
+ </args>
149
+ </meinpaket>
150
+ </routers>
151
+ <layout>
152
+ <updates>
153
+ <meinpaket>
154
+ <file>meinpaket.xml</file>
155
+ </meinpaket>
156
+ </updates>
157
+ </layout>
158
+ </frontend>
159
+ <global>
160
+ <resources>
161
+ <meinpaket_setup>
162
+ <setup>
163
+ <module>Dhl_MeinPaket</module>
164
+ <class>Dhl_MeinPaket_Model_Resource_Eav_Mysql4_Setup</class>
165
+ </setup>
166
+ </meinpaket_setup>
167
+ </resources>
168
+ <models>
169
+ <meinpaket>
170
+ <class>Dhl_MeinPaket_Model</class>
171
+ <resourceModel>meinpaket_mysql4</resourceModel>
172
+ </meinpaket>
173
+ <meinpaket_mysql4>
174
+ <class>Dhl_MeinPaket_Model_Mysql4</class>
175
+ <entities>
176
+ <category>
177
+ <table>meinpaket_category</table>
178
+ </category>
179
+ <backlog_product>
180
+ <table>meinpaket_backlog_product</table>
181
+ </backlog_product>
182
+ <bestprice>
183
+ <table>meinpaket_bestprice</table>
184
+ </bestprice>
185
+ <log>
186
+ <table>meinpaket_log</table>
187
+ </log>
188
+ <async>
189
+ <table>meinpaket_async</table>
190
+ </async>
191
+ </entities>
192
+ </meinpaket_mysql4>
193
+ </models>
194
+ <blocks>
195
+ <meinpaket>
196
+ <class>Dhl_MeinPaket_Block</class>
197
+ </meinpaket>
198
+ </blocks>
199
+ <helpers>
200
+ <!-- WTF? -->
201
+ <Dhl_MeinPaket>
202
+ <class>Dhl_MeinPaket_Helper</class>
203
+ </Dhl_MeinPaket>
204
+ <meinpaket>
205
+ <class>Dhl_MeinPaket_Helper</class>
206
+ </meinpaket>
207
+ </helpers>
208
+ <events>
209
+ <catalog_product_save_before>
210
+ <observers>
211
+ <meinpaket_product_save_before>
212
+ <type>singleton</type>
213
+ <class>meinpaket/observer</class>
214
+ <method>catalogProductSaveBefore</method>
215
+ </meinpaket_product_save_before>
216
+ </observers>
217
+ </catalog_product_save_before>
218
+ <catalog_product_save_after>
219
+ <observers>
220
+ <meinpaket_product_save_after>
221
+ <type>singleton</type>
222
+ <class>meinpaket/observer</class>
223
+ <method>catalogProductSaveAfter</method>
224
+ </meinpaket_product_save_after>
225
+ </observers>
226
+ </catalog_product_save_after>
227
+ <catalog_product_attribute_update_before>
228
+ <observers>
229
+ <meinpaket_product_attribute_update_before>
230
+ <type>singleton</type>
231
+ <class>meinpaket/observer</class>
232
+ <method>catalogProductAttributeUpdateBefore</method>
233
+ </meinpaket_product_attribute_update_before>
234
+ </observers>
235
+ </catalog_product_attribute_update_before>
236
+ <catalog_product_delete_before>
237
+ <observers>
238
+ <meinpaket_delete_product>
239
+ <type>singleton</type>
240
+ <class>meinpaket/observer</class>
241
+ <method>catalogProductDeleteBefore</method>
242
+ </meinpaket_delete_product>
243
+ </observers>
244
+ </catalog_product_delete_before>
245
+ <cataloginventory_stock_item_save_after>
246
+ <observers>
247
+ <meinpaket_stock_item_save_after>
248
+ <type>singleton</type>
249
+ <class>meinpaket/observer</class>
250
+ <method>catalogInventoryStockItemSaveAfter</method>
251
+ </meinpaket_stock_item_save_after>
252
+ </observers>
253
+ </cataloginventory_stock_item_save_after>
254
+ <sales_order_save_after>
255
+ <observers>
256
+ <meinpaket_cancel_order>
257
+ <type>singleton</type>
258
+ <class>meinpaket/observer</class>
259
+ <method>salesOrderSaveAfter</method>
260
+ </meinpaket_cancel_order>
261
+ </observers>
262
+ </sales_order_save_after>
263
+ <sales_order_shipment_save_after>
264
+ <observers>
265
+ <meinpaket_save_sales_order_shipment>
266
+ <type>singleton</type>
267
+ <class>meinpaket/observer</class>
268
+ <method>salesOrderShipmentSaveAfter</method>
269
+ </meinpaket_save_sales_order_shipment>
270
+ </observers>
271
+ </sales_order_shipment_save_after>
272
+ <sales_order_shipment_save_commit_after>
273
+ <observers>
274
+ <meinpaket_commit_sales_order_shipment>
275
+ <type>singleton</type>
276
+ <class>meinpaket/observer</class>
277
+ <method>salesOrderShipmentSaveCommitAfter</method>
278
+ </meinpaket_commit_sales_order_shipment>
279
+ </observers>
280
+ </sales_order_shipment_save_commit_after>
281
+ <sales_order_shipment_track_save_after>
282
+ <observers>
283
+ <meinpaket_save_sales_order_shipment_track>
284
+ <type>singleton</type>
285
+ <class>meinpaket/observer</class>
286
+ <method>salesOrderShipmentTrackSaveAfter</method>
287
+ </meinpaket_save_sales_order_shipment_track>
288
+ </observers>
289
+ </sales_order_shipment_track_save_after>
290
+ <sales_order_creditmemo_save_after>
291
+ <observers>
292
+ <meinpaket_save_creditmemo>
293
+ <type>singleton</type>
294
+ <class>meinpaket/observer</class>
295
+ <method>salesOrderCreditmemoSaveAfter</method>
296
+ </meinpaket_save_creditmemo>
297
+ </observers>
298
+ </sales_order_creditmemo_save_after>
299
+ <adminhtml_catalog_product_attribute_edit_prepare_form>
300
+ <observers>
301
+ <add_meinpaket_to_attribute_editor>
302
+ <type>singleton</type>
303
+ <class>meinpaket/observer</class>
304
+ <method>addMeinPaketAttributes</method>
305
+ </add_meinpaket_to_attribute_editor>
306
+ </observers>
307
+ </adminhtml_catalog_product_attribute_edit_prepare_form>
308
+ <catalog_model_product_duplicate>
309
+ <observers>
310
+ <meinpaket_product_duplicate>
311
+ <type>singleton</type>
312
+ <class>meinpaket/observer</class>
313
+ <method>productDuplicate</method>
314
+ </meinpaket_product_duplicate>
315
+ </observers>
316
+ </catalog_model_product_duplicate>
317
+ <sales_order_grid_collection_load_before>
318
+ <observers>
319
+ <meinpaket_sales_order_grid_collection_add_attribute>
320
+ <type>singleton</type>
321
+ <model>meinpaket/observer</model>
322
+ <method>salesOrderGridCollectionLoadBefore</method>
323
+ </meinpaket_sales_order_grid_collection_add_attribute>
324
+ </observers>
325
+ </sales_order_grid_collection_load_before>
326
+ <core_block_abstract_prepare_layout_before>
327
+ <observers>
328
+ <meinpaket_grid_column_append>
329
+ <type>singleton</type>
330
+ <class>meinpaket/observer</class>
331
+ <method>gridAddAttributes</method>
332
+ </meinpaket_grid_column_append>
333
+ </observers>
334
+ </core_block_abstract_prepare_layout_before>
335
+ </events>
336
+ </global>
337
+ </config>
app/code/community/Dhl/MeinPaket/etc/system.xml ADDED
@@ -0,0 +1,385 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <meinpaket module="core" translate="label">
5
+ <comment>Test</comment>
6
+ <label>DHL MeinPaket.de</label>
7
+ <tab>general</tab>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>1000</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</show_in_store>
13
+ <class>meinpaket</class>
14
+ <groups>
15
+ <store>
16
+ <label>Store</label>
17
+ <frontend_type>text</frontend_type>
18
+ <sort_order>1</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>1</show_in_store>
22
+ <frontend_class>meinpaket</frontend_class>
23
+ <fields translate="label">
24
+ <view translate="label">
25
+ <label>Store View</label>
26
+ <frontend_type>select</frontend_type>
27
+ <source_model>adminhtml/system_config_source_store</source_model>
28
+ <sort_order>1</sort_order>
29
+ <show_in_default>1</show_in_default>
30
+ <show_in_website>0</show_in_website>
31
+ <show_in_store>0</show_in_store>
32
+ </view>
33
+ </fields>
34
+ </store>
35
+ <credentials translate="label">
36
+ <label>Credentials</label>
37
+ <frontend_type>text</frontend_type>
38
+ <sort_order>3</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>0</show_in_store>
42
+ <frontend_class>meinpaket</frontend_class>
43
+ <fields>
44
+ <username translate="label comment">
45
+ <label>DHL Username</label>
46
+ <comment><![CDATA[This is the username that was given to you by DHL, mostly your email address.]]></comment>
47
+ <frontend_type>text</frontend_type>
48
+ <sort_order>10</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>0</show_in_store>
52
+ </username>
53
+ <password translate="label comment">
54
+ <label>DHL Password</label>
55
+ <comment><![CDATA[This is the password that was given to you by DHL.]]></comment>
56
+ <frontend_type>password</frontend_type>
57
+ <sort_order>20</sort_order>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>0</show_in_store>
61
+ </password>
62
+ </fields>
63
+ </credentials>
64
+ <endpoint translate="label">
65
+ <label>Remote system</label>
66
+ <frontend_type>text</frontend_type>
67
+ <sort_order>2</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ <frontend_class>meinpaket</frontend_class>
72
+ <fields>
73
+ <https translate="label comment">
74
+ <label>Use HTTPs</label>
75
+ <comment><![CDATA[Use https:// to connect to DHL MeinPaket]]></comment>
76
+ <frontend_type>select</frontend_type>
77
+ <source_model>adminhtml/system_config_source_yesno</source_model>
78
+ <sort_order>10</sort_order>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>0</show_in_website>
81
+ <show_in_store>0</show_in_store>
82
+ </https>
83
+ <sandbox translate="label comment">
84
+ <label>Use Sandbox</label>
85
+ <comment><![CDATA[Use DHL MeinPaket sandbox]]></comment>
86
+ <frontend_type>select</frontend_type>
87
+ <source_model>adminhtml/system_config_source_yesno</source_model>
88
+ <sort_order>11</sort_order>
89
+ <show_in_default>1</show_in_default>
90
+ <show_in_website>0</show_in_website>
91
+ <show_in_store>0</show_in_store>
92
+ </sandbox>
93
+ <proxy translate="label comment">
94
+ <label>Use Proxy</label>
95
+ <comment><![CDATA[Use proxy to connect to DHL MeinPaket]]></comment>
96
+ <frontend_type>select</frontend_type>
97
+ <source_model>adminhtml/system_config_source_yesno</source_model>
98
+ <sort_order>20</sort_order>
99
+ <show_in_default>1</show_in_default>
100
+ <show_in_website>0</show_in_website>
101
+ <show_in_store>0</show_in_store>
102
+ </proxy>
103
+ <proxy_host translate="label comment">
104
+ <label>Proxy Host</label>
105
+ <comment><![CDATA[Used proxy host to connect to DHL MeinPaket. Disabled when empty]]></comment>
106
+ <frontend_type>text</frontend_type>
107
+ <sort_order>21</sort_order>
108
+ <show_in_default>1</show_in_default>
109
+ <show_in_website>0</show_in_website>
110
+ <show_in_store>0</show_in_store>
111
+ <depends>
112
+ <proxy>1</proxy>
113
+ </depends>
114
+ </proxy_host>
115
+ <proxy_port translate="label comment">
116
+ <label>Proxy Port</label>
117
+ <comment><![CDATA[Use proxy port to connect to DHL MeinPaket. Disabled when empty]]></comment>
118
+ <frontend_type>text</frontend_type>
119
+ <sort_order>22</sort_order>
120
+ <show_in_default>1</show_in_default>
121
+ <show_in_website>0</show_in_website>
122
+ <show_in_store>0</show_in_store>
123
+ <depends>
124
+ <proxy>1</proxy>
125
+ </depends>
126
+ </proxy_port>
127
+ </fields>
128
+ </endpoint>
129
+ <shipment translate="label">
130
+ <label>Shipment</label>
131
+ <frontend_type>text</frontend_type>
132
+ <sort_order>15</sort_order>
133
+ <show_in_default>1</show_in_default>
134
+ <show_in_website>1</show_in_website>
135
+ <show_in_store>1</show_in_store>
136
+ <frontend_class>meinpaket</frontend_class>
137
+ <fields>
138
+ <default_shipment_method translate="label comment">
139
+ <label>Default Shipment Method</label>
140
+ <comment><![CDATA[Shipment method which is used for order import and POSTPAY.]]></comment>
141
+ <frontend_type>select</frontend_type>
142
+ <type>text</type>
143
+ <source_model>meinpaket/entity_attribute_source_carrier
144
+ </source_model>
145
+ <sort_order>20</sort_order>
146
+ <show_in_default>1</show_in_default>
147
+ <show_in_website>1</show_in_website>
148
+ <show_in_store>0</show_in_store>
149
+ </default_shipment_method>
150
+ </fields>
151
+ </shipment>
152
+ <checkout translate="label">
153
+ <label>POSTPAY</label>
154
+ <frontend_type>text</frontend_type>
155
+ <sort_order>20</sort_order>
156
+ <show_in_default>1</show_in_default>
157
+ <show_in_website>1</show_in_website>
158
+ <show_in_store>1</show_in_store>
159
+ <frontend_class>meinpaket</frontend_class>
160
+ <fields>
161
+ <available translate="label comment">
162
+ <label>POSTPAY available</label>
163
+ <comment><![CDATA[This defines wether the external Checkout with DHL is available for customers.]]></comment>
164
+ <frontend_type>select</frontend_type>
165
+ <source_model>adminhtml/system_config_source_yesno</source_model>
166
+ <sort_order>10</sort_order>
167
+ <show_in_default>1</show_in_default>
168
+ <show_in_website>0</show_in_website>
169
+ <show_in_store>0</show_in_store>
170
+ </available>
171
+ <submit_shipping_costs translate="label comment">
172
+ <label>Submit shipping costs for POSTPAY</label>
173
+ <comment><![CDATA[If set to yes, the shippingscosts for the POSTPAY will be calculated based on the default shipment method.]]></comment>
174
+ <frontend_type>select</frontend_type>
175
+ <source_model>adminhtml/system_config_source_yesno</source_model>
176
+ <sort_order>20</sort_order>
177
+ <show_in_default>1</show_in_default>
178
+ <show_in_website>0</show_in_website>
179
+ <show_in_store>0</show_in_store>
180
+ </submit_shipping_costs>
181
+ </fields>
182
+ </checkout>
183
+ <taxrates translate="label">
184
+ <label>Tax rates</label>
185
+ <frontend_type>text</frontend_type>
186
+ <sort_order>30</sort_order>
187
+ <show_in_default>1</show_in_default>
188
+ <show_in_website>1</show_in_website>
189
+ <show_in_store>0</show_in_store>
190
+ <frontend_class>meinpaket</frontend_class>
191
+ <fields>
192
+ <default_tax_rate translate="label comment">
193
+ <label>Default tax rate</label>
194
+ <comment><![CDATA[The default tax rate applies to most products]]></comment>
195
+ <frontend_type>select</frontend_type>
196
+ <type>text</type>
197
+ <source_model>meinpaket/entity_attribute_source_taxclass</source_model>
198
+ <sort_order>10</sort_order>
199
+ <show_in_default>1</show_in_default>
200
+ <show_in_website>1</show_in_website>
201
+ <show_in_store>0</show_in_store>
202
+ </default_tax_rate>
203
+ <reduced_tax_rate translate="label comment">
204
+ <label>Reduced tax rate</label>
205
+ <comment><![CDATA[The reduced tax rate applies to special products, such as aliments]]></comment>
206
+ <frontend_type>select</frontend_type>
207
+ <source_model>meinpaket/entity_attribute_source_taxclass</source_model>
208
+ <sort_order>20</sort_order>
209
+ <show_in_default>1</show_in_default>
210
+ <show_in_website>1</show_in_website>
211
+ <show_in_store>0</show_in_store>
212
+ </reduced_tax_rate>
213
+ </fields>
214
+ </taxrates>
215
+ <product_attributes translate="label">
216
+ <label>Product attributes</label>
217
+ <frontend_type>text</frontend_type>
218
+ <sort_order>40</sort_order>
219
+ <show_in_default>1</show_in_default>
220
+ <show_in_website>1</show_in_website>
221
+ <show_in_store>0</show_in_store>
222
+ <frontend_class>meinpaket</frontend_class>
223
+ <fields>
224
+ <ean_attribute translate="label comment">
225
+ <label>EAN</label>
226
+ <comment><![CDATA[Attribute containing EAN]]></comment>
227
+ <frontend_type>select</frontend_type>
228
+ <source_model>meinpaket/entity_attribute_source_productAttribute
229
+ </source_model>
230
+ <sort_order>1</sort_order>
231
+ <show_in_default>1</show_in_default>
232
+ <show_in_website>1</show_in_website>
233
+ <show_in_store>0</show_in_store>
234
+ </ean_attribute>
235
+ <delivery_time translate="label comment">
236
+ <label>Delivery time</label>
237
+ <comment><![CDATA[Please select the product attribute which represents the approx. delivery time]]></comment>
238
+ <frontend_type>select</frontend_type>
239
+ <source_model>meinpaket/entity_attribute_source_productAttribute
240
+ </source_model>
241
+ <sort_order>10</sort_order>
242
+ <show_in_default>1</show_in_default>
243
+ <show_in_website>1</show_in_website>
244
+ <show_in_store>0</show_in_store>
245
+ </delivery_time>
246
+ <default_delivery_time translate="label comment">
247
+ <label>Default delivery time</label>
248
+ <comment><![CDATA[Delivery time in days if no other delivery time applies]]></comment>
249
+ <frontend_type>text</frontend_type>
250
+ <validate>validate-digits</validate>
251
+ <sort_order>20</sort_order>
252
+ <show_in_default>1</show_in_default>
253
+ <show_in_website>1</show_in_website>
254
+ <show_in_store>0</show_in_store>
255
+ </default_delivery_time>
256
+ </fields>
257
+ </product_attributes>
258
+ <customer translate="label">
259
+ <label>Customer</label>
260
+ <frontend_type>text</frontend_type>
261
+ <sort_order>50</sort_order>
262
+ <show_in_default>1</show_in_default>
263
+ <show_in_website>1</show_in_website>
264
+ <show_in_store>0</show_in_store>
265
+ <frontend_class>meinpaket</frontend_class>
266
+ <fields>
267
+ <default_email translate="label comment">
268
+ <label>Default customer email</label>
269
+ <comment><![CDATA[This eMail address is used as the default one for orders that do not include one.]]></comment>
270
+ <frontend_type>text</frontend_type>
271
+ <validate>validate-email</validate>
272
+ <sort_order>10</sort_order>
273
+ <show_in_default>1</show_in_default>
274
+ <show_in_website>1</show_in_website>
275
+ <show_in_store>0</show_in_store>
276
+ </default_email>
277
+ </fields>
278
+ </customer>
279
+ <cron translate="label">
280
+ <label>Cron</label>
281
+ <frontend_type>text</frontend_type>
282
+ <sort_order>100</sort_order>
283
+ <show_in_default>1</show_in_default>
284
+ <show_in_website>1</show_in_website>
285
+ <show_in_store>0</show_in_store>
286
+ <frontend_class>meinpaket</frontend_class>
287
+ <fields>
288
+ <async translate="label comment">
289
+ <label>Async Request</label>
290
+ <comment><![CDATA[Async request check interval]]></comment>
291
+ <frontend_type>text</frontend_type>
292
+ <sort_order>10</sort_order>
293
+ <show_in_default>1</show_in_default>
294
+ <show_in_website>1</show_in_website>
295
+ <show_in_store>0</show_in_store>
296
+ </async>
297
+ <product translate="label comment">
298
+ <label>Product Export</label>
299
+ <comment><![CDATA[Product export interval]]></comment>
300
+ <frontend_type>text</frontend_type>
301
+ <sort_order>20</sort_order>
302
+ <show_in_default>1</show_in_default>
303
+ <show_in_website>1</show_in_website>
304
+ <show_in_store>0</show_in_store>
305
+ </product>
306
+ <order translate="label comment">
307
+ <label>Order Import</label>
308
+ <comment><![CDATA[Order import interval.]]></comment>
309
+ <frontend_type>text</frontend_type>
310
+ <sort_order>30</sort_order>
311
+ <show_in_default>1</show_in_default>
312
+ <show_in_website>1</show_in_website>
313
+ <show_in_store>0</show_in_store>
314
+ </order>
315
+ <bestprice translate="label comment">
316
+ <label>BestPrice Interval</label>
317
+ <comment><![CDATA[BestPrice refresh interval.]]></comment>
318
+ <frontend_type>text</frontend_type>
319
+ <sort_order>40</sort_order>
320
+ <show_in_default>1</show_in_default>
321
+ <show_in_website>1</show_in_website>
322
+ <show_in_store>0</show_in_store>
323
+ </bestprice>
324
+ <cleanup translate="label comment">
325
+ <label>Cleanup Interval</label>
326
+ <comment><![CDATA[Interval to run cleanups.]]></comment>
327
+ <frontend_type>text</frontend_type>
328
+ <sort_order>50</sort_order>
329
+ <show_in_default>1</show_in_default>
330
+ <show_in_website>1</show_in_website>
331
+ <show_in_store>0</show_in_store>
332
+ </cleanup>
333
+ </fields>
334
+ </cron>
335
+ </groups>
336
+ </meinpaket>
337
+ <carriers>
338
+ <groups>
339
+ <meinpaket translate="label" module="meinpaket">
340
+ <label>MeinPaket Versand Modul</label>
341
+ <frontend_type>text</frontend_type>
342
+ <sort_order>20</sort_order>
343
+ <show_in_default>1</show_in_default>
344
+ <show_in_website>1</show_in_website>
345
+ <show_in_store>1</show_in_store>
346
+ <fields>
347
+ <active translate="label">
348
+ <label>Enabled</label>
349
+ <frontend_type>select</frontend_type>
350
+ <source_model>adminhtml/system_config_source_yesno</source_model>
351
+ <sort_order>10</sort_order>
352
+ <show_in_default>1</show_in_default>
353
+ <show_in_website>1</show_in_website>
354
+ <show_in_store>1</show_in_store>
355
+ </active>
356
+ </fields>
357
+ </meinpaket>
358
+ </groups>
359
+ </carriers>
360
+ <payment>
361
+ <groups>
362
+ <meinpaket translate="label comment" module="meinpaket">
363
+ <label>MeinPaket</label>
364
+ <frontend_type>text</frontend_type>
365
+ <sort_order>0</sort_order>
366
+ <show_in_default>1</show_in_default>
367
+ <show_in_website>1</show_in_website>
368
+ <show_in_store>1</show_in_store>
369
+ <fields>
370
+ <active translate="label">
371
+ <label>Enabled</label>
372
+ <frontend_type>select</frontend_type>
373
+ <source_model>adminhtml/system_config_source_yesno</source_model>
374
+ <sort_order>10</sort_order>
375
+ <show_in_default>1</show_in_default>
376
+ <show_in_website>1</show_in_website>
377
+ <show_in_store>1</show_in_store>
378
+ </active>
379
+ </fields>
380
+ </meinpaket>
381
+ </groups>
382
+ </payment>
383
+ </sections>
384
+ </config>
385
+
app/code/community/Dhl/MeinPaket/sql/meinpaket_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Setup-Script fuer Dhl_MeinPaket
4
+ *
5
+ * Uninstall MeinPaket:
6
+ * delete from core_resource where code = 'meinpaket_setup';
7
+ * delete from eav_attribute where attribute_code = "is_dhl_mein_paket_root";
8
+ * delete from eav_attribute where attribute_code = "is_dhl_marketplace_root";
9
+ * delete from eav_attribute where attribute_code = "dhl_marketplace_category_id";
10
+ * delete from eav_attribute where attribute_code = "sync_with_dhl_mein_paket";
11
+ * delete from eav_attribute where attribute_code = "max_stock_for_dhl_mein_paket";
12
+ * delete from eav_attribute where attribute_code = "shipment_was_exported_for_dhl_mein_paket";
13
+ * delete from eav_attribute where attribute_code = "dhl_mein_paket_order_id";
14
+ * delete from eav_attribute_group where attribute_group_name = "MeinPaket.de";
15
+ * alter table sales_flat_order drop column dhl_mein_paket_order_id;
16
+ * alter table sales_flat_order_grid drop column dhl_mein_paket_order_id;
17
+ *
18
+ * @author Andreas Demmer <andreas.demmer@aoemedia.de>
19
+ */
20
+
21
+ /* @var $installer Dhl_MeinPaket_Model_Resource_Eav_Mysql4_Setup */
22
+ $installer = $this;
23
+ $installer->startSetup ();
24
+
25
+ // get DB connectiondelete from core_resource where code = 'meinpaket_setup';
26
+ $db = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_write' );
27
+ $table_prefix = Mage::getConfig ()->getTablePrefix ();
28
+
29
+
30
+ // ############### create dhl_mein_paket_order_id attribute #################
31
+
32
+ // check wether dhl_mein_paket_order_id column exists for orders
33
+ $orderIdFieldExists = false;
34
+ $result = $db->query ( "EXPLAIN {$table_prefix}sales_flat_order" );
35
+
36
+ while ( $resultset = $result->fetch ( PDO::FETCH_ASSOC ) ) {
37
+ if ($resultset ['Field'] == 'dhl_mein_paket_order_id')
38
+ $orderIdFieldExists = true;
39
+ }
40
+
41
+ if (! $orderIdFieldExists) {
42
+ $installer->getConnection ()->addColumn ( $installer->getTable ( 'sales_flat_order' ), 'dhl_mein_paket_order_id', 'varchar(255) NULL DEFAULT NULL AFTER `entity_id`' );
43
+
44
+ $installer->addAttribute ( 'order', 'dhl_mein_paket_order_id', array (
45
+ 'type' => 'static'
46
+ // 'visible' => false
47
+ ) );
48
+ }
49
+
50
+ // check wether dhl_mein_paket_order_id column exists for orders grid
51
+ $orderIdFieldExists = false;
52
+ $result = $db->query ( "EXPLAIN {$table_prefix}sales_flat_order_grid" );
53
+
54
+ while ( $resultset = $result->fetch ( PDO::FETCH_ASSOC ) ) {
55
+ if ($resultset ['Field'] == 'dhl_mein_paket_order_id')
56
+ $orderIdFieldExists = true;
57
+ }
58
+
59
+ if (! $orderIdFieldExists) {
60
+ $installer->getConnection ()->addColumn ( $installer->getTable ( 'sales_flat_order_grid' ), 'dhl_mein_paket_order_id', 'varchar(255) NULL DEFAULT NULL AFTER `entity_id`' );
61
+ }
62
+
63
+ // ############### create shipment_was_exported_for_dhl_mein_paket attribute #################
64
+
65
+ $orderIdFieldExists = false;
66
+ $result = $db->query ( "EXPLAIN {$table_prefix}sales_flat_shipment" );
67
+
68
+ while ( $resultset = $result->fetch ( PDO::FETCH_ASSOC ) ) {
69
+ if ($resultset ['Field'] == 'shipment_was_exported_for_dhl_mein_paket')
70
+ $orderIdFieldExists = true;
71
+ }
72
+
73
+ if (! $orderIdFieldExists) {
74
+ $installer->getConnection ()->addColumn ( $installer->getTable ( 'sales_flat_shipment' ), 'shipment_was_exported_for_dhl_mein_paket', 'int(1) NULL DEFAULT NULL AFTER `entity_id`' );
75
+ }
76
+
77
+ Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( 'DHL MeinPaket.de extension was successfully installed!' );
78
+
79
+ $installer->installEntities();
80
+ $installer->endSetup ();
app/code/community/Dhl/MeinPaket/sql/meinpaket_setup/mysql4-upgrade-1.0.0-1.1.0.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* @var $installer Dhl_MeinPaket_Model_Resource_Eav_Mysql4_Setup */
4
+ $installer = $this;
5
+ $installer->startSetup ();
6
+
7
+ $installer->installEntities();
8
+
9
+ /*
10
+ $installer->run ( "
11
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/variants')};
12
+ CREATE TABLE {$this->getTable('meinpaket/variants')} (
13
+ `variant_id` int(10) unsigned not null auto_increment ,
14
+ `meinpaket_code` varchar(255) not null ,
15
+ `meinpaket_name` varchar(255) not null ,
16
+ `meinpaket_selection_rule` varchar(255) not null ,
17
+ `meinpaket_index_as_group` tinyint(1) unsigned not null ,
18
+ PRIMARY KEY (`variant_id`)
19
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='MeinPaket Variants';
20
+ " );
21
+
22
+ $installer->run ( "
23
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/attributes')};
24
+ CREATE TABLE {$this->getTable('meinpaket/attributes')} (
25
+ `attribute_id` int(10) unsigned not null auto_increment ,
26
+ `variant_id` int(10) unsigned not null ,
27
+ `meinpaket_code` varchar(255) not null ,
28
+ `meinpaket_name` varchar(255) not null ,
29
+ PRIMARY KEY (`attribute_id`)
30
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='MeinPaket Attributes';
31
+ " );
32
+
33
+ $installer->run ( "
34
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/values')};
35
+ CREATE TABLE {$this->getTable('meinpaket/values')} (
36
+ `value_id` int(10) unsigned not null auto_increment ,
37
+ `attribute_id` int(10) unsigned not null ,
38
+ `value` varchar(255) not null ,
39
+ PRIMARY KEY (`value_id`)
40
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='MeinPaket Attribute Values';
41
+ " );
42
+
43
+ $installer->run ( "
44
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/variant_mappings')};
45
+ CREATE TABLE {$this->getTable('meinpaket/variant_mappings')} (
46
+ `variant_mapping_id` int(10) unsigned not null auto_increment ,
47
+ `meinpaket_variant_id` int(10) unsigned not null ,
48
+ `attribute_set_id` int(10) unsigned not null ,
49
+ PRIMARY KEY (`variant_mapping_id`)
50
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='MeinPaket Variant to Magento Attribute Set Mapping';
51
+ " );
52
+
53
+ $installer->run ( "
54
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/attribute_mappings')};
55
+ CREATE TABLE {$this->getTable('meinpaket/attribute_mappings')} (
56
+ `attribute_mapping_id` int(10) unsigned not null auto_increment ,
57
+ `variant_mapping_id` int(10) unsigned not null ,
58
+ `meinpaket_attribute_id` int(10) unsigned not null ,
59
+ `attribute_id` int(10) unsigned not null ,
60
+ PRIMARY KEY (`attribute_mapping_id`)
61
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='MeinPaket Attribute to Magento Attribute Mapping';
62
+ " );
63
+
64
+ $installer->run ( "
65
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/value_mappings')};
66
+ CREATE TABLE {$this->getTable('meinpaket/value_mappings')} (
67
+ `value_mapping_id` int(10) unsigned not null auto_increment ,
68
+ `attribute_mapping_id` int(10) unsigned not null ,
69
+ `meinpaket_value_id` int(10) unsigned not null ,
70
+ `option_id` int(10) unsigned not null ,
71
+ PRIMARY KEY (`value_mapping_id`)
72
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='MeinPaket Value to Magento Option Mapping';
73
+ " );
74
+
75
+ $installer->endSetup ();
76
+ */
app/code/community/Dhl/MeinPaket/sql/meinpaket_setup/mysql4-upgrade-1.1.0-2.0.0.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* @var $installer Dhl_MeinPaket_Model_Resource_Eav_Mysql4_Setup */
4
+ $installer = $this;
5
+ $installer->startSetup ();
6
+
7
+ $installer->installEntities ();
8
+
9
+ /*
10
+ $installer->run ( "
11
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/variants')};
12
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/attributes')};
13
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/values')};
14
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/variant_mappings')};
15
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/attribute_mappings')};
16
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/value_mappings')};
17
+ " );
18
+ */
19
+
20
+ $installer->run ( "
21
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/category')};
22
+ CREATE TABLE {$this->getTable('meinpaket/category')} (
23
+ `category_id` int(10) unsigned not null auto_increment,
24
+ `name` varchar(255) not null,
25
+ `code` varchar(255) not null,
26
+ `parent` varchar(255) not null,
27
+ `leaf` tinyint(1) unsigned not null ,
28
+ PRIMARY KEY (`category_id`)
29
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='MeinPaket Categories';
30
+ " );
31
+
32
+ $installer->run ( "
33
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/backlog_product')};
34
+ CREATE TABLE {$this->getTable('meinpaket/backlog_product')} (
35
+ `backlog_id` int(11) unsigned NOT NULL auto_increment,
36
+ `product_id` int(10) unsigned NOT NULL,
37
+ `changes` text default '',
38
+ `created_at` datetime default '0000-00-00 00:00:00',
39
+ PRIMARY KEY(`backlog_id`),
40
+ CONSTRAINT `FK_MEINPAKET_PRODUCT_BACKLOG_PRODUCT_ID` FOREIGN KEY (`product_id`) REFERENCES {$installer->getTable('catalog_product_entity')} (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE
41
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='MeinPaket Backlog';
42
+ " );
43
+
44
+ $installer->run ( "
45
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/log')};
46
+ CREATE TABLE {$this->getTable('meinpaket/log')} (
47
+ `log_id` int(11) unsigned NOT NULL auto_increment,
48
+ `request_id` varchar(255),
49
+ `status` varchar(255),
50
+ `send` text default '',
51
+ `received` text default '',
52
+ `error` text default '',
53
+ `created_at` datetime default '0000-00-00 00:00:00',
54
+ PRIMARY KEY(`log_id`)
55
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='MeinPaket Sync';
56
+ " );
57
+
58
+ $installer->run ( "
59
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/async')};
60
+ CREATE TABLE {$this->getTable('meinpaket/async')} (
61
+ `async_id` int(11) unsigned NOT NULL auto_increment,
62
+ `request_id` varchar(255),
63
+ `status` varchar(255),
64
+ `created_at` datetime default '0000-00-00 00:00:00',
65
+ `updated_at` datetime default '0000-00-00 00:00:00',
66
+ PRIMARY KEY(`async_id`)
67
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='MeinPaket Async Requests';
68
+ " );
69
+
70
+ $installer->run ( "
71
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/bestprice')};
72
+ CREATE TABLE {$this->getTable('meinpaket/bestprice')} (
73
+ `bestprice_id` int(11) unsigned NOT NULL auto_increment,
74
+ `product_id` int(10) unsigned NOT NULL,
75
+ `price` decimal(12,4),
76
+ `price_currency` varchar(255),
77
+ `delivery_cost` decimal(12,4),
78
+ `delivery_cost_currency` varchar(255),
79
+ `delivery_time` int(10),
80
+ `active_offers` int(10),
81
+ `ownership` varchar(255),
82
+ `owning_dealer_code` varchar(255),
83
+ `created_at` datetime default '0000-00-00 00:00:00',
84
+ PRIMARY KEY(`bestprice_id`),
85
+ CONSTRAINT `FK_MEINPAKET_BESTPRICE_PRODUCT_ID` FOREIGN KEY (`product_id`) REFERENCES {$installer->getTable('catalog_product_entity')} (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE
86
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='MeinPaket BestPrices';
87
+ " );
88
+
89
+
90
+ $installer->getConnection ()->addColumn ( $installer->getTable ( 'catalog/eav_attribute' ), 'meinpaket_attribute', "VARCHAR( 255 ) DEFAULT 'None' COMMENT 'MeinPaket Attribute'" );
91
+
92
+ $installer->endSetup ();
app/design/adminhtml/default/default/layout/meinpaket.xml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout version="0.1.0">
3
+ <meinpaket_head_imports>
4
+ <reference name="head">
5
+ <action method="addItem">
6
+ <type>skin_js</type>
7
+ <name>meinpaket/module.js</name>
8
+ <params />
9
+ </action>
10
+ <action method="addItem">
11
+ <type>skin_css</type>
12
+ <name>meinpaket/module.css</name>
13
+ <params />
14
+ </action>
15
+ </reference>
16
+ </meinpaket_head_imports>
17
+
18
+ <meinpaket_adminhtml_categoryimport_index>
19
+ <update handle="meinpaket_head_imports" />
20
+ <reference name="content">
21
+ <block type="meinpaket/adminhtml_categoryImport_index" name="meinpaket.adminhtml_categoryImport_index"
22
+ template="meinpaket/category/import/index.phtml" />
23
+ </reference>
24
+ </meinpaket_adminhtml_categoryimport_index>
25
+
26
+ <meinpaket_adminhtml_categoryimport_import>
27
+ <update handle="meinpaket_head_imports" />
28
+ <reference name="content">
29
+ <block type="meinpaket/adminhtml_categoryImport_index" name="meinpaket.adminhtml_categoryImport_import"
30
+ template="meinpaket/category/import/import.phtml" />
31
+ </reference>
32
+ </meinpaket_adminhtml_categoryimport_import>
33
+
34
+ <meinpaket_adminhtml_backlog_product_index>
35
+ <update handle="meinpaket_head_imports" />
36
+ <reference name="content">
37
+ <block type="meinpaket/adminhtml_backlog_product" name="meinpaket_admin_backlog_grid" />
38
+ </reference>
39
+ </meinpaket_adminhtml_backlog_product_index>
40
+
41
+ <meinpaket_adminhtml_log_index translate="label" module="meinpaket">
42
+ <update handle="meinpaket_head_imports" />
43
+ <reference name="content">
44
+ <block type="meinpaket/adminhtml_log" name="meinpaket_admin_log_grid" />
45
+ </reference>
46
+ </meinpaket_adminhtml_log_index>
47
+
48
+ <meinpaket_adminhtml_async_index translate="label" module="meinpaket">
49
+ <update handle="meinpaket_head_imports" />
50
+ <reference name="content">
51
+ <block type="meinpaket/adminhtml_async" name="meinpaket_admin_async_grid" />
52
+ </reference>
53
+ </meinpaket_adminhtml_async_index>
54
+
55
+ <meinpaket_adminhtml_matching_index>
56
+ <update handle="meinpaket_head_imports" />
57
+ <block type="core/text_list" name="root" output="toHtml">
58
+ <block type="meinpaket/adminhtml_catalog_product_matching_result" name="catalog.product.matching.result"
59
+ template="meinpaket/catalog/product/matching/result.phtml" />
60
+ </block>
61
+ </meinpaket_adminhtml_matching_index>
62
+
63
+ <meinpaket_adminhtml_bestprice_index translate="label" module="meinpaket">
64
+ <update handle="meinpaket_head_imports" />
65
+ <reference name="content">
66
+ <block type="meinpaket/adminhtml_bestPrice" name="meinpaket_admin_bestPrice_grid" />
67
+ </reference>
68
+ </meinpaket_adminhtml_bestprice_index>
69
+
70
+ <adminhtml_catalog_product_edit>
71
+ <update handle="meinpaket_head_imports" />
72
+ <reference name="product_tabs">
73
+ <action method="addTab">
74
+ <name>meinpaket_matching</name>
75
+ <block>meinpaket/adminhtml_catalog_product_matching_tab</block>
76
+ </action>
77
+ </reference>
78
+ </adminhtml_catalog_product_edit>
79
+
80
+ <adminhtml_system_config_edit>
81
+ <update handle="meinpaket_head_imports" />
82
+ <reference name="head">
83
+ </reference>
84
+ </adminhtml_system_config_edit>
85
+ </layout>
app/design/adminhtml/default/default/template/meinpaket/Attributemapping/edit.phtml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $block Dhl_MeinPaket_Block_Adminhtml_Attributemapping_Edit */
3
+ $block = $this;
4
+ ?>
5
+ <div class="content-header">
6
+ <table cellspacing="0" class="grid-header">
7
+ <tr>
8
+ <td><h3 class="icon-head meinpaket"><?php echo __('Attribute Mappings'); ?></h3></td>
9
+ <td class="a-right">
10
+ <button onclick="addAttributeMapping()" class="scalable add"
11
+ type="button" id="startButton">
12
+ <span><?php echo $this->__('Add Attribute Mapping'); ?></span>
13
+ </button> <input type="hidden" name="mapping_id" id="mapping_id"
14
+ value="<?php echo $block->getMappingId(); ?>" /> <input
15
+ type="hidden" name="variant_id" id="variant_id"
16
+ value="<?php echo $block->getVariantId(); ?>" /> <input
17
+ type="hidden" name="attribute_set_id" id="attribute_set_id"
18
+ value="<?php echo $block->getAttributeSetId(); ?>" />
19
+ </td>
20
+ </tr>
21
+ </table>
22
+ </div>
23
+ todo
app/design/adminhtml/default/default/template/meinpaket/Attributemapping/edit/attributes.phtml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if(!$this->getMappingExists()) : ?>
2
+ <script type="text/javascript">
3
+ MeinPaket.magentoAttributes = <?php echo $this->getAvailableMagentoAttributes(); ?>;
4
+ MeinPaket.meinpaketAttributes = <?php echo $this->getAvailableMeinPaketAttributes(); ?>;
5
+ MeinPaket.url = {};
6
+ MeinPaket.url.editAttributeValues = "<?php echo $this->getUrl('*/*/loadAttributeValues'); ?>";
7
+ </script>
8
+ <div class="entry-edit custom-options bundle"
9
+ id="meinpaket_attributes_container">
10
+ <div class="entry-edit-head">
11
+ <h4><?php echo $this->__('Attributes') ?></h4>
12
+ <div class="right"><?php echo $this->getAddButtonHtml() ?></div>
13
+ </div>
14
+
15
+ <div id="meinpaket_attribute" class="box">
16
+ <div id="meinpaket_attribute_top"></div>
17
+ </div>
18
+ </div>
19
+ <?php else : ?>
20
+ <div><?php echo $this->__('A mapping for the Magento attribute set already exists.'); ?></div>
21
+ <?php endif; ?>
app/design/adminhtml/default/default/template/meinpaket/Attributemapping/edit/mapping.phtml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div
2
+ id="attribute_mapping_container_<?php echo $this->getCurrentIndex(); ?>"
3
+ class="option-box attribute-mapping-container">
4
+ <table class="option-header" cellpadding="0" cellspacing="0">
5
+ <thead>
6
+ <tr>
7
+ <th class="opt-type"><?php echo $this->__('Magento Attribute'); ?></th>
8
+ <th class="opt-req"><?php echo $this->__('MeinPaket Attribute'); ?></th>
9
+ <th>&nbsp;</th>
10
+ <th>&nbsp;</th>
11
+ </tr>
12
+ </thead>
13
+ <tbody id="attribute_table_<?php echo $this->getCurrentIndex(); ?>">
14
+ <tr>
15
+ <td><?php echo $this->getAttributeSetAttributesSelectElement()->toHtml(); ?></td>
16
+ <td><?php echo $this->getVariantAttributesSelectElement()->toHtml(); ?></td>
17
+ <td>
18
+ <button type="button" value="" class="scalable add"
19
+ onclick="MeinPaket.loadValueMapping(<?php echo $this->getCurrentIndex(); ?>);">
20
+ <span><?php echo $this->__('Edit Value Mapping'); ?></span>
21
+ </button>
22
+ </td>
23
+ <td>
24
+ <button type="button" value="" class="scalable delete"
25
+ onclick="MeinPaket.deleteAttributeMapping(<?php echo $this->getCurrentIndex(); ?>);">
26
+ <span><?php echo $this->__('Delete Mapping'); ?></span>
27
+ </button>
28
+ </td>
29
+ </tr>
30
+ <tr id="values_row_<?php echo $this->getCurrentIndex(); ?>">
31
+ <td colspan="4"></td>
32
+ </tr>
33
+ </tbody>
34
+ </table>
35
+ <div id="values_container_<?php echo $this->getCurrentIndex(); ?>"></div>
36
+ </div>
app/design/adminhtml/default/default/template/meinpaket/Attributemapping/edit/valuemapping.phtml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $block Dhl_MeinPaket_Block_Adminhtml_Attributemapping_Edit_Valuemapping */
3
+ $block = $this;
4
+ $mpValues = $block->getMeinpaketOptions ();
5
+ $mageValues = $block->getMagentoOptions ();
6
+ $mappingId = $block->getMappingIndex ();
7
+ ?>
8
+ <?php if(sizeof($mpValues) > 0) : ?>
9
+ <tr>
10
+ <th><?php echo Mage::helper('meinpaket')->__('Magento Value'); ?></th>
11
+ <th><?php echo Mage::helper('meinpaket')->__('MeinPaket Value'); ?></th>
12
+ <th>&nbsp;</th>
13
+ <th>&nbsp;</th>
14
+ </tr>
15
+ <?php foreach($mageValues as $mageValue): ?>
16
+ <?php
17
+ $mpSelect = '<select id="attribute_value_id_' . $mageValue ['id'] . '" name="attribute_value_mapping[' . $mappingId . '][' . $mageValue ['id'] . ']">';
18
+ $mpSelect .= '<option value="">' . Mage::helper ( 'meinpaket' )->__ ( 'not assigned' ) . '</option>';
19
+ foreach ( $mpValues as $mpValue ) {
20
+ $mpSelect .= '<option value="' . $mpValue ['id'] . '" ';
21
+ if ($mpValue ['assigned'] !== null && $mpValue ['assigned'] == $mageValue ['id']) {
22
+ // if($mageValue['name'] == $mpValue['name']) {
23
+ $mpSelect .= 'selected="selected"';
24
+ }
25
+ $mpSelect .= '>' . $mpValue ['name'] . '</option>';
26
+ }
27
+ ?>
28
+ <tr>
29
+ <td><?php echo $mageValue['name']; ?></td>
30
+ <td><?php echo $mpSelect; ?></td>
31
+ <td>&nbsp;</td>
32
+ <td>&nbsp;</td>
33
+ </tr>
34
+ <?php endforeach; ?>
35
+ <?php else : ?>
36
+ <tr>
37
+ <td colspan="4">
38
+ <?php echo $this->__('No mapable attribute values available for the selected MeinPaket attribute.'); ?><br /><?php echo $this->__('Magento attribute values will be used instead.'); ?>
39
+ </td>
40
+ </tr>
41
+ <?php endif; ?>
app/design/adminhtml/default/default/template/meinpaket/Attributemapping/editform.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <div class="content-header">
3
+ <table cellspacing="0" class="grid-header">
4
+ <tr>
5
+ <td><h3 class="icon-head meinpaket"><?php echo __('Attribute Mappings'); ?></h3></td>
6
+ <td class="a-right">
7
+ <button onclick="addAttributeMapping()" class="scalable add"
8
+ type="button" id="startButton">
9
+ <span><?php echo $this->__('Add Attribute Mapping'); ?></span>
10
+ </button>
11
+ </td>
12
+ </tr>
13
+ </table>
14
+ </div>
15
+ todo
app/design/adminhtml/default/default/template/meinpaket/Attributemapping/index.phtml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="content-header">
2
+ <table cellspacing="0" class="grid-header">
3
+ <tr>
4
+ <td><h3 class="icon-head meinpaket"><?php echo __('Attribute Mappings'); ?></h3></td>
5
+ <td class="a-right">
6
+ <button
7
+ onclick="variantconfigurationsImport('<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) ?>')"
8
+ class="scalable add" type="button">
9
+ <span><?php echo $this->__('import Variantconfigurations'); ?></span>
10
+ </button>
11
+ <button
12
+ onclick="setLocation('<?php echo $this->getUrl('meinpaket/adminhtml_attributeMapping/edit') ?>')"
13
+ class="scalable add" type="button" id="startButton">
14
+ <span><?php echo $this->__('Add Attribute Mapping'); ?></span>
15
+ </button>
16
+ </td>
17
+ </tr>
18
+ </table>
19
+ </div>
app/design/adminhtml/default/default/template/meinpaket/CategoryImport/import.phtml ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $this Dhl_MeinPaket_Block_Adminhtml_CategoryImport_Import */
3
+ /* @var $result Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result */
4
+ $result = $this->getResult ();
5
+ ?>
6
+ <div class="content-header">
7
+ <table class="grid-header">
8
+ <tr>
9
+ <td><h3 class="icon-head meinpaket"><?php echo __('Import Categories'); ?></h3></td>
10
+ <td class="a-right">
11
+ <button
12
+ onclick="setLocation('<?php echo $this->getUrl('meinpaket/adminhtml_categoryImport/index/') ?>')"
13
+ class="scalable back" type="button">
14
+ <span><?php echo $this->__('start again'); ?></span>
15
+ </button>
16
+ </td>
17
+ </tr>
18
+ </table>
19
+ </div>
20
+ <div class="dashboard-container meinpaket-content">
21
+ <ul class="meinpaket-steps">
22
+ <li class="nr1"><p><?php echo __('Overview'); ?></p></li>
23
+ <li class="nr2"><p><?php echo __('Import'); ?></p></li>
24
+ <li class="nr3 active"><p><?php echo __('Result'); ?></p></li>
25
+ </ul>
26
+ <div class="cc">
27
+ <!-- -->
28
+ </div>
29
+
30
+ <div id="meinpaket-results" class="scrollablebox grid entry-edit">
31
+ <?php if($result !== null && $result->getNewCategoriesCount() + $result->getDeletedCategoriesCount() + $result->getUpdatedCategoriesCount() > 0) : ?>
32
+ <table id="meinpaket-results">
33
+ <tbody>
34
+
35
+ <?php /*** NEW CATEGORIES **********************************************/ ?>
36
+ <?php if($result->getNewCategoriesCount() > 0) : ?>
37
+ <tr>
38
+ <td colspan="4" class="row-subheader"><?php echo __('New categories'); ?> | <span
39
+ class="resultCount"><?php echo $result->getNewCategoriesCount().' '.__('total'); ?></span></td>
40
+ </tr>
41
+ <tr class="headings">
42
+ <th class="header-center">#</th>
43
+ <th class="col-product" colspan="2"><?php echo __('Category'); ?></th>
44
+ <th><?php echo __('Category Code'); ?></th>
45
+ </tr>
46
+ <?php
47
+ $newCategories = $result->getNewCategories ();
48
+ $currentIndex = 0;
49
+ $stripeClass = 'odd';
50
+ ?>
51
+ <?php foreach($newCategories as $category) : ?>
52
+ <?php $stripeClass = ($stripeClass === 'even') ? 'odd' : 'even'; ?>
53
+ <tr class="<?php echo $stripeClass; ?>">
54
+ <td class="row-num"><?php echo ++$currentIndex; ?></td>
55
+ <td colspan="2"><?php echo $category->getName(); ?> </td>
56
+ <td><?php echo $category->getCode(); ?></td>
57
+ </tr>
58
+ <?php endforeach; ?>
59
+ <?php endif; ?>
60
+
61
+ <?php /*** UPDATED CATEGORIES ******************************************/ ?>
62
+ <?php if($result->getUpdatedCategoriesCount() > 0) : ?>
63
+ <tr>
64
+ <td colspan="4" class="row-subheader"><?php echo __('Updated categories'); ?> | <span
65
+ class="resultCount"><?php echo $result->getUpdatedCategoriesCount().' '.__('total'); ?></span></td>
66
+ </tr>
67
+ <tr class="headings">
68
+ <th class="header-center">#</th>
69
+ <th class="col-product"><?php echo __('Category'); ?></th>
70
+ <th><?php echo __('Category Code'); ?></th>
71
+ </tr>
72
+ <?php
73
+ $updatedCategories = $result->getUpdatedCategories ();
74
+ $currentIndex = 0;
75
+ $stripeClass = 'odd';
76
+ ?>
77
+ <?php foreach($updatedCategories as $category) : ?>
78
+ <?php $stripeClass = ($stripeClass === 'even') ? 'odd' : 'even'; ?>
79
+ <tr class="<?php echo $stripeClass; ?>">
80
+ <td class="row-num"><?php echo ++$currentIndex; ?></td>
81
+ <td><?php echo $category->getName(); ?> </td>
82
+ <td><?php echo $category->getCode(); ?></td>
83
+ </tr>
84
+ <?php endforeach; ?>
85
+ <?php endif; ?>
86
+
87
+ <?php /*** DELETED CATEGORIES ******************************************/ ?>
88
+ <?php if($result->getDeletedCategoriesCount() > 0) : ?>
89
+ <tr>
90
+ <td colspan="4" class="row-subheader"><?php echo __('Deleted categories'); ?> | <span
91
+ class="resultCount"><?php echo $result->getDeletedCategoriesCount().' '.__('total'); ?></span></td>
92
+ </tr>
93
+ <tr class="headings">
94
+ <th class="header-center">#</th>
95
+ <th class="col-product"><?php echo __('Category'); ?></th>
96
+ <th><?php echo __('Category Code'); ?></th>
97
+ </tr>
98
+ <?php
99
+ $deletedCategories = $result->getDeletedCategories ();
100
+ $currentIndex = 0;
101
+ $stripeClass = 'odd';
102
+ ?>
103
+ <?php foreach($deletedCategories as $category) : ?>
104
+ <?php $stripeClass = ($stripeClass === 'even') ? 'odd' : 'even'; ?>
105
+ <tr class="<?php echo $stripeClass; ?>">
106
+ <td class="row-num"><?php echo ++$currentIndex; ?></td>
107
+ <td><?php echo $category->getName(); ?> </td>
108
+ <td><?php echo $category->getCode(); ?></td>
109
+ </tr>
110
+ <?php endforeach; ?>
111
+ <?php endif; ?>
112
+ </tbody>
113
+ </table>
114
+ <?php else : ?>
115
+ <div class="meinpaket-description">
116
+ <p><?php echo __('Marketplace category structure was up to date. There have been no changes.'); ?></p>
117
+ </div>
118
+ <?php endif; ?>
119
+ </div>
120
+ </div>
121
+
app/design/adminhtml/default/default/template/meinpaket/CategoryImport/index.phtml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <div class="content-header">
3
+ <table cellspacing="0" class="grid-header">
4
+ <tr>
5
+ <td><h3 class="icon-head meinpaket"><?php echo __('Import Categories'); ?></h3></td>
6
+ <td class="a-right">
7
+ <!-- <button onclick="setLocationWithWait('<?php echo $this->getUrl('meinpaket/adminhtml_categoryImport/import/') ?>')" class="scalable" type="button"><span><?php echo $this->__('import categories'); ?></span></button> -->
8
+ <button onclick="startProcessing()" class="scalable" type="button"
9
+ id="startButton">
10
+ <span><?php echo $this->__('import categories'); ?></span>
11
+ </button>
12
+ </td>
13
+ </tr>
14
+ </table>
15
+ </div>
16
+ <div class="dashboard-container meinpaket-content">
17
+
18
+ <ul class="meinpaket-steps">
19
+ <li class="active nr1"><p><?php echo __('Overview'); ?></p></li>
20
+ <li class="nr2"><p><?php echo __('Import'); ?></p></li>
21
+ <li class="nr3"><p><?php echo __('Result'); ?></p></li>
22
+ </ul>
23
+ <div class="cc">
24
+ <!-- -->
25
+ </div>
26
+
27
+ <div id="meinpaket-description">
28
+ <p><?php echo __('Textual introduction into category import goes here...'); ?></p>
29
+ </div>
30
+
31
+ <div id="disabled-till-export" class="meinpaket-waitbox"
32
+ style="display: none">
33
+ <img src="/skin/adminhtml/default/default/meinpaket/images/loader.gif" /><br />
34
+ <small><?php echo $this->__('please wait'); ?></small>
35
+ </div>
36
+
37
+ <form id="meinpaket_form" name="meinpaket_form" method="get"
38
+ action="<?php echo $this->getUrl('meinpaket/adminhtml_categoryImport/import/') ?>">
39
+ <fieldset>
40
+ <button onclick="startProcessing()" class="scalable" type="button"
41
+ id="startButton">
42
+ <span><?php echo $this->__('import categories'); ?></span>
43
+ </button>
44
+ </fieldset>
45
+ </form>
46
+ </div>
47
+
app/design/adminhtml/default/default/template/meinpaket/OrderImport/import.phtml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="content-header">
2
+ <table cellspacing="0" class="grid-header">
3
+ <tr>
4
+ <td><h3 class="icon-head meinpaket">Importiere Bestellungen</h3></td>
5
+ <td class="a-right">
6
+ <button
7
+ onclick="setLocation('<?php echo $this->getUrl('meinpaket/adminhtml_orderImport/index/') ?>')"
8
+ class="scalable back" type="button">
9
+ <span><?php echo $this->__('start again'); ?></span>
10
+ </button>
11
+ <button
12
+ onclick="setLocation('<?php echo $this->getUrl('adminhtml/sales_order/index/') ?>')"
13
+ class="scalable" type="button">
14
+ <span><?php echo $this->__('view orders'); ?></span>
15
+ </button>
16
+ </td>
17
+ </tr>
18
+ </table>
19
+ </div>
20
+ <div class="dashboard-container meinpaket-content">
21
+ <?php echo $this->getChildHtml('steps'); ?>
22
+ <div class="cc">
23
+ <!-- -->
24
+ </div>
25
+ <div class="meinpaket-description">
26
+ <p>Bestellungen importiert</p>
27
+ <button
28
+ onclick="setLocation('<?php echo $this->getUrl('adminhtml/sales_order/index/') ?>')"
29
+ class="scalable" type="button">
30
+ <span><?php echo $this->__('view orders'); ?></span>
31
+ </button>
32
+
33
+ </div>
34
+
35
+ <br />
36
+
37
+ </div>
38
+
app/design/adminhtml/default/default/template/meinpaket/OrderImport/index.phtml ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="content-header">
2
+ <table cellspacing="0" class="grid-header">
3
+ <tr>
4
+ <td><h3 class="icon-head meinpaket"><?php echo __('Import Products'); ?></h3></td>
5
+ <td class="a-right">
6
+ <button onclick="startProcessing()" class="scalable" type="button"
7
+ id="startButton">
8
+ <span><?php echo $this->__('import orders'); ?></span>
9
+ </button>
10
+
11
+ </td>
12
+ </tr>
13
+ </table>
14
+ </div>
15
+ <div class="dashboard-container meinpaket-content">
16
+ <?php echo $this->getChildHtml('steps'); ?>
17
+ <div class="cc">
18
+ <!-- -->
19
+ </div>
20
+ <div id="meinpaket-description">
21
+ <p><?php echo __('Textual guide for importing orders follows here'); ?></p>
22
+ </div>
23
+ <div id="disabled-till-export" class="meinpaket-waitbox"
24
+ style="display: none">
25
+ <img src="/skin/adminhtml/default/default/meinpaket/images/loader.gif" /><br />
26
+ <small><?php echo $this->__('please wait'); ?></small>
27
+ </div>
28
+ <form id="meinpaket_form" name="meinpaket_form" method="get"
29
+ action="<?php echo $this->getUrl('meinpaket/adminhtml_orderImport/import/') ?>">
30
+ <fieldset>
31
+ <label><?php echo $this->__('start date'); ?></label><input
32
+ name="startdate" id="startdate"
33
+ value="<?php echo strftime('%m/%e/%y',strtotime('-1 week')); ?>"
34
+ class=" input-text" style="width: 110px ! important;" type="text"> <img
35
+ src="<?php echo $this->getSkinUrl('images/grid-cal.gif') ?>" alt=""
36
+ class="v-middle" id="startdate_trig" title="Select Date" style="">
37
+ <script type="text/javascript">
38
+ //<![CDATA[
39
+ Calendar.setup({
40
+ inputField: "startdate",
41
+ ifFormat: "%m/%e/%y",
42
+ showsTime: false,
43
+ button: "startdate_trig",
44
+ align: "Bl",
45
+ singleClick : true
46
+ });
47
+ //]]>
48
+ </script>
49
+ <br /> <label><?php echo $this->__('end date'); ?></label> <input
50
+ name="enddate" id="enddate" value="" class=" input-text"
51
+ style="width: 110px ! important;" type="text"> <img
52
+ src="<?php echo $this->getSkinUrl('images/grid-cal.gif') ?>" alt=""
53
+ class="v-middle" id="enddate_trig" title="Select Date" style="">
54
+ <!-- <small><?php echo $this->__('leave empty to load all till now'); ?></small> -->
55
+ <script type="text/javascript">
56
+ //<![CDATA[
57
+ Calendar.setup({
58
+ inputField: "enddate",
59
+ ifFormat: "%m/%e/%y",
60
+ showsTime: false,
61
+ button: "enddate_trig",
62
+ align: "Bl",
63
+ singleClick : true
64
+ });
65
+ //]]>
66
+ </script>
67
+ </fieldset>
68
+ <br />
69
+ <button onclick="startProcessing()" class="scalable" type="button"
70
+ id="startButton">
71
+ <span><?php echo $this->__('import orders'); ?></span>
72
+ </button>
73
+ </form>
74
+ <br />
75
+ </div>
76
+
app/design/adminhtml/default/default/template/meinpaket/ProductExport/empty.phtml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <div class="content-header">
3
+ <table cellspacing="0" class="grid-header">
4
+ <tr>
5
+ <td><h3 class="icon-head meinpaket">Export Products</h3></td>
6
+ <td class="a-right">
7
+ <button
8
+ onclick="setLocation('<?php echo $this->getUrl('meinpaket/adminhtml_productExport/index/') ?>')"
9
+ class="scalable back" type="button">
10
+ <span><?php echo $this->__('start again'); ?></span>
11
+ </button>
12
+ </td>
13
+ </tr>
14
+ </table>
15
+ </div>
16
+ <div class="dashboard-container meinpaket-content">
17
+
18
+ <div class="cc">
19
+ <!-- -->
20
+ </div>
21
+
22
+ <p>Es gibt keine Produkte zum exportieren. Lernen Sie hier wie Sie neue
23
+ Produkte zum exportieren auswählen:</p>
24
+ <ul>
25
+ <li>Ist Ihr Shop-Root korrekt gestetzt (Anchor und Shop-Root
26
+ Eigenschaft)</li>
27
+ <li>Wollen Sie alle Produkte unterhalb einer Kategorie exportieren?
28
+ Wählöen Sie einfach "alle" aus</li>
29
+ <li>Wollen Sie nur einzelne Produkte exportieren, so müssen Sie die
30
+ Produkte als "zu meinPaket exportieren" markieren.</li>
31
+ </ul>
32
+ <br />
33
+
34
+ </div>
35
+
app/design/adminhtml/default/default/template/meinpaket/ProductExport/export.phtml ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <style type="text/css">
2
+ .hidden-mouseover {
3
+ display: block;
4
+ font-size: 0.9em;
5
+ color: #a1a1a1;
6
+ }
7
+ </style>
8
+ <div class="content-header">
9
+ <table cellspacing="0" class="grid-header">
10
+ <tr>
11
+ <td><h3 class="icon-head meinpaket"><?php echo __('export products'); ?> &gt; <?php echo __('Result'); ?></h3></td>
12
+ <td class="a-right">
13
+ <button
14
+ onclick="setLocation('<?php echo $this->getUrl('meinpaket/adminhtml_productExport/index/') ?>')"
15
+ class="scalable back" type="button">
16
+ <span><?php echo $this->__('start again'); ?></span>
17
+ </button>
18
+ </td>
19
+ </tr>
20
+ </table>
21
+ </div>
22
+ <div class="dashboard-container meinpaket-content">
23
+
24
+ <ul class="meinpaket-steps">
25
+ <li class="nr1"><p><?php echo __('Selection'); ?></p></li>
26
+ <li class="nr2"><p><?php echo __('Upload'); ?></p></li>
27
+ <li class="nr3 active"><p><?php echo __('Result'); ?></p></li>
28
+ </ul>
29
+ <div class="cc">
30
+ <!-- -->
31
+ </div>
32
+
33
+ <?php
34
+ if (is_object ( $this->results ) && get_class ( $this->results ) === 'Dhl_MeinPaket_Model_Service_Product_Export_Result') :
35
+ ?>
36
+ <div id="meinpaket-results" class="scrollablebox grid entry-edit">
37
+ <table id="meinpaket-results">
38
+ <tbody>
39
+ <?php
40
+ /* @var $results Dhl_MeinPaket_Model_Service_Product_Export_Result */
41
+ $results = $this->results;
42
+ // if ($results->hasErrors()) :
43
+ $confirmedProducts = $results->getFullyConfirmedProductIds ();
44
+ $offeredOnlyProducts = $results->getProductsWhichCouldOnlyBeOffered ();
45
+ $notExportedProducts = $results->getProductsWhichCouldNotBeOfferedOrDescribed ();
46
+ $commonErrors = $results->getCommonErrors ();
47
+ $stripeClass = 'odd';
48
+ $currentIndex = 0;
49
+ ?>
50
+
51
+ <?php if(sizeof($confirmedProducts) > 0) : ?>
52
+ <tr>
53
+ <td colspan="4" class="row-subheader"><?php echo __('Successfully Exported Products'); ?> | <span
54
+ class="resultCount"><?php echo sizeof($confirmedProducts).' '.__('total'); ?></span></td>
55
+ </tr>
56
+ <tr class="headings">
57
+ <th class="header-center">#</th>
58
+ <th class="col-product"><?php echo __('Product'); ?></th>
59
+ <th colspan="2"><?php echo __('Edit Product'); ?></th>
60
+ </tr>
61
+ <?php $stripeClass = 'odd'; ?>
62
+ <?php $currentIndex = 0; ?>
63
+ <?php foreach($confirmedProducts as $confirmedProductId) : ?>
64
+ <?php $stripeClass = ($stripeClass === 'even') ? 'odd' : 'even'; ?>
65
+ <?php $product = Mage::getModel('catalog/product')->load($confirmedProductId); ?>
66
+ <tr class="<?php echo $stripeClass; ?>">
67
+ <td class="row-num"><?php echo ++$currentIndex; ?></td>
68
+ <td><?php echo $product->getName(); ?> </td>
69
+ <td colspan="2"><?php echo $this->getEditLink($product); ?></td>
70
+ </tr>
71
+ <?php endforeach; ?>
72
+ <?php endif; ?>
73
+
74
+ <?php if(sizeof($commonErrors) > 0) : ?>
75
+ <tr>
76
+ <td colspan="4" class="row-subheader"><?php echo __('Common Errors'); ?> | <span
77
+ class="resultCount"><?php echo sizeof($commonErrors).' '.__('total'); ?></span></td>
78
+ </tr>
79
+ <?php foreach ($commonErrors as $error) : ?>
80
+ <?php $stripeClass = ($stripeClass === 'even') ? 'odd' : 'even'; ?>
81
+ <tr class="<?php echo $stripeClass; ?>">
82
+ <td class="row-num"><?php echo ++$currentIndex; ?></td>
83
+ <td colspan="3"><?php echo $error['code']; ?>&nbsp; &nbsp;<?php echo $error['message']; ?>+</td>
84
+ </tr>
85
+ <?php endforeach; ?>
86
+ <?php endif; ?>
87
+
88
+ <?php if(sizeof($notExportedProducts) > 0) : ?>
89
+ <?php $stripeClass = 'odd'; ?>
90
+ <?php $currentIndex = 0; ?>
91
+ <tr>
92
+ <td colspan="4" class="row-subheader"><?php echo __('These products could not be exported'); ?> | <span
93
+ class="resultCount"><?php echo sizeof($notExportedProducts).' '.__('total'); ?></span></td>
94
+ </tr>
95
+ <tr class="headings">
96
+ <th class="header-center" style="width: 1px">#</th>
97
+ <th class="col-product"><?php echo __('Product'); ?></th>
98
+ <th><?php echo __('Edit Product'); ?></th>
99
+ <th class="col-result"><?php echo __('Error Description'); ?></th>
100
+ </tr>
101
+ <?php foreach ($notExportedProducts as $notExportedProduct) : ?>
102
+ <?php $stripeClass = ($stripeClass === 'even') ? 'odd' : 'even'; ?>
103
+ <?php $product = Mage::getModel('catalog/product')->load($notExportedProduct['id']); ?>
104
+ <tr class="<?php echo $stripeClass; ?>">
105
+ <td class="row-num"><?php echo ++$currentIndex; ?></td>
106
+ <td><?php echo $product->getName(); ?> </td>
107
+ <td><?php echo $this->getEditLink($product); ?></td>
108
+ <td>
109
+ <?php
110
+ $errorMsg = '';
111
+ $offerErrorMsg = '';
112
+ if (! $notExportedProduct ['description'] ['confirmed']) {
113
+ foreach ( $notExportedProduct ['description'] ['errors'] as $error ) {
114
+ $tmpErrorMsg = $this->getErrorDescription ( $error ['code'], $error ['type'] ) . '<span class="hidden-mouseover">' . $error ['type'] . '</span>';
115
+ if (strlen ( $errorMsg ) > 0) {
116
+ $errorMsg .= '<br/>';
117
+ }
118
+ $errorMsg .= $tmpErrorMsg;
119
+ }
120
+ echo $errorMsg;
121
+ }
122
+ if (! $notExportedProduct ['offer'] ['confirmed']) {
123
+ foreach ( $notExportedProduct ['offer'] ['errors'] as $error ) {
124
+ $tmpOfferErrorMsg = $this->getErrorDescription ( $error ['code'], $error ['type'] ) . '<span class="hidden-mouseover">' . $error ['type'] . '</span>';
125
+ if (strlen ( $offerErrorMsg ) > 0) {
126
+ $offerErrorMsg .= '<br/>';
127
+ }
128
+ $offerErrorMsg .= $tmpOfferErrorMsg;
129
+ }
130
+ echo $offerErrorMsg;
131
+ }
132
+ ?>
133
+ </td>
134
+ </tr>
135
+ <?php endforeach; ?>
136
+ <?php endif; ?>
137
+
138
+ <?php if(sizeof($offeredOnlyProducts) > 0) : ?>
139
+ <tr>
140
+ <td colspan="4" class="row-subheader"><?php echo __('The following products could only be exported as description'); ?> | <span
141
+ class="resultCount"><?php echo sizeof($offeredOnlyProducts).' '.__('total'); ?></span></td>
142
+ </tr>
143
+ <tr class="headings">
144
+ <th class="header-center">#</th>
145
+ <th class="col-product"><?php echo __('Product'); ?></th>
146
+ <th><?php echo __('Edit Product'); ?></th>
147
+ <th class="col-result"><?php echo __('Error Description'); ?></th>
148
+ </tr>
149
+ <?php $stripeClass = 'odd'; ?>
150
+ <?php $currentIndex = 0; ?>
151
+ <?php foreach($offeredOnlyProducts as $onlyOfferedProduct) : ?>
152
+ <?php $stripeClass = ($stripeClass === 'even') ? 'odd' : 'even'; ?>
153
+ <?php $product = Mage::getModel('catalog/product')->load($onlyOfferedProduct['id']); ?>
154
+ <tr class="<?php echo $stripeClass; ?>">
155
+ <td class="row-num"><?php echo ++$currentIndex; ?></td>
156
+ <td><?php echo $product->getName(); ?> </td>
157
+ <td><?php echo $this->getEditLink($product); ?></td>
158
+ <td>
159
+ <?php $errorMsg = ''; ?>
160
+ <?php foreach($onlyOfferedProduct['description']['errors'] as $error) : ?>
161
+ <?php
162
+ $tmpErrorMsg = $this->getErrorDescription ( $error ['code'], $error ['type'] ) . '<span class="hidden-mouseover">' . $error ['type'] . '</span>';
163
+ if (strlen ( $errorMsg ) > 0) {
164
+ $errorMsg .= '<br/>';
165
+ }
166
+ $errorMsg .= $tmpErrorMsg;
167
+ ?>
168
+ <?php endforeach; ?>
169
+ <?php
170
+ if (strlen ( $errorMsg ) < 1) {
171
+ $errorMsg = $this->__ ( 'Not available.' );
172
+ }
173
+ ?>
174
+ <?php echo $errorMsg; ?>
175
+ </td>
176
+ </tr>
177
+ <?php endforeach; ?>
178
+ <?php endif; ?>
179
+
180
+ <?php if($results->hasFailedVariantGroups()) : ?>
181
+ <tr>
182
+ <td colspan="4" class="row-subheader"><?php echo __('The following configurable products could not be exported'); ?> | <span
183
+ class="resultCount"><?php echo sizeof($results->getFailedVariantGroupIds()).' '.__('total'); ?></span></td>
184
+ </tr>
185
+ <tr class="headings">
186
+ <th class="header-center">#</th>
187
+ <th class="col-product"><?php echo __('Product'); ?></th>
188
+ <th><?php echo __('Edit Product'); ?></th>
189
+ <th class="col-result"><?php echo __('Error Description'); ?></th>
190
+ </tr>
191
+ <?php $stripeClass = 'odd'; ?>
192
+ <?php $currentIndex = 0; ?>
193
+ <?php foreach($results->getFailedVariantGroups() as $variantId => $variant) : ?>
194
+ <?php $stripeClass = ($stripeClass === 'even') ? 'odd' : 'even'; ?>
195
+ <?php $product = Mage::getModel('catalog/product')->load($variantId); ?>
196
+ <tr class="<?php echo $stripeClass; ?>">
197
+ <td class="row-num"><?php echo ++$currentIndex; ?></td>
198
+ <td><?php echo $product->getName(); ?> </td>
199
+ <td><?php echo $this->getEditLink($product); ?></td>
200
+ <td>
201
+ <?php echo $this->getErrorDescription($variant['code'], ''); ?>
202
+ <span class="hidden-mouseover"><?php echo $variant['message']; ?></span>
203
+ </td>
204
+ </tr>
205
+ <?php endforeach; ?>
206
+ <?php endif; ?>
207
+
208
+ </tbody>
209
+ </table>
210
+ </div>
211
+ <?php endif; ?>
212
+ </div>
213
+
app/design/adminhtml/default/default/template/meinpaket/ProductExport/index.phtml ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <div class="content-header">
3
+ <table cellspacing="0" class="grid-header">
4
+ <tr>
5
+ <td><h3 class="icon-head meinpaket"><?php echo __('export products'); ?></h3></td>
6
+ <td class="a-right">
7
+ <button onclick="startProcessing()" class="scalable" type="button"
8
+ id="startButton">
9
+ <span><?php echo $this->__('export products'); ?></span>
10
+ </button>
11
+ </td>
12
+ </tr>
13
+ </table>
14
+ </div>
15
+ <div class="dashboard-container meinpaket-content">
16
+ <ul class="meinpaket-steps">
17
+ <li class="active nr1"><p><?php echo __('Selection'); ?></p></li>
18
+ <li class="nr2"><p><?php echo __('Upload'); ?></p></li>
19
+ <li class="nr3"><p><?php echo __('Result'); ?></p></li>
20
+ </ul>
21
+ <div class="cc">
22
+ <!-- -->
23
+ </div>
24
+
25
+ <div id="meinpaket-description">
26
+ <p><?php echo __('At this place you can choose which products you want to export and start the process.'); ?></p>
27
+ </div>
28
+
29
+ <div id="disabled-till-export" class="meinpaket-waitbox"
30
+ style="display: none">
31
+ <img src="/skin/adminhtml/default/default/meinpaket/images/loader.gif" /><br />
32
+ <small><?php echo $this->__('please wait'); ?></small>
33
+ </div>
34
+
35
+ <form id="meinpaket_form" name="meinpaket_form" method="get"
36
+ action="<?php echo $this->getUrl('meinpaket/adminhtml_productExport/export/') ?>">
37
+
38
+ <fieldset>
39
+ <label><?php echo $this->__('select products'); ?></label><select
40
+ name="productselection"><option value="1"><?php echo $this->__('only marked products'); ?></option>
41
+ <option value="2"><?php echo $this->__('all'); ?></option></select>
42
+ <button onclick="startProcessing()" class="scalable" type="button"
43
+ id="startButton">
44
+ <span><?php echo $this->__('export products'); ?></span>
45
+ </button>
46
+ <!-- <button onclick="submitForm('<?php echo $this->getUrl('meinpaket/adminhtml_productExport/list/') ?>')" class="scalable" type="button"><span><?php echo $this->__('list products'); ?></span></button> -->
47
+ </fieldset>
48
+ </form>
49
+ <br />
50
+
51
+ </div>
52
+
app/design/adminhtml/default/default/template/meinpaket/ProductExport/list.phtml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <div class="content-header">
3
+ <table cellspacing="0" class="grid-header">
4
+ <tr>
5
+ <td><h3 class="icon-head meinpaket">Export Products</h3></td>
6
+ <td class="a-right">
7
+ <button
8
+ onclick="setLocation('<?php echo $this->getUrl('meinpaket/adminhtml_productExport/index/') ?>')"
9
+ class="scalable" type="button">
10
+ <span><?php echo $this->__('start'); ?></span>
11
+ </button>
12
+ </td>
13
+ </tr>
14
+ </table>
15
+ </div>
16
+ <div class="dashboard-container meinpaket-content">
17
+
18
+ <div class="cc">
19
+ <!-- -->
20
+ </div>
21
+ <div id="meinpaket-results" class="scrollablebox">
22
+ <?php
23
+
24
+ foreach ( $productCollection as $product ) {
25
+ print_r ( $product->debug () );
26
+ echo '<hr />';
27
+ }
28
+
29
+ ?>
30
+ </div>
31
+ </div>
32
+
app/design/adminhtml/default/default/template/meinpaket/catalog/product/matching/result.phtml ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Suggestion response tab.
4
+ */
5
+ ?>
6
+
7
+ <div class="entry-edit">
8
+ <div class="entry-edit-head">
9
+ <h4 class="icon-head head-edit-form fieldset-legend">Results</h4>
10
+ <div class="form-buttons"></div>
11
+ </div>
12
+ <div class="fieldset fieldset-wide" id="group_fields78">
13
+ <?php if ($this->getSuggestions() != null && count($this->getSuggestions()->getProductData())): ?>
14
+ <div class="hor-scroll">
15
+ <div class="grid">
16
+ <table cellspacing="0" class="data border" width="100%">
17
+ <colgroup>
18
+ <col>
19
+ <col>
20
+ <col>
21
+ <col>
22
+ <col width="70">
23
+ </colgroup>
24
+ <thead>
25
+ <tr class="headings">
26
+ <th><?php echo $this->__('Name');?></th>
27
+ <th><?php echo $this->__('Manufacturer');?></th>
28
+ <th><?php echo $this->__('Short Description');?></th>
29
+ <th><?php echo $this->__('Marketplace Category');?></th>
30
+ <th class="last"><?php echo $this->__('Apply');?></th>
31
+ </tr>
32
+ </thead>
33
+ <tbody>
34
+ <?php foreach ($this->getSuggestions()->getProductData() as $suggestion):?>
35
+ <tr class="preview">
36
+ <td class="cell-name"><?php echo $suggestion->getName(); ?></td>
37
+ <td class="cell-manufacturer-name"><?php echo $suggestion->getManufacturerName(); ?></td>
38
+ <td class="cell-short-description"><?php echo $suggestion->getShortDescription(); ?></td>
39
+ <td class="cell-category"><?php echo Mage::getModel('meinpaket/category')->load($suggestion->getMarketplaceCategory(), 'code')->getName(); ?> (<?php echo $suggestion->getMarketplaceCategory(); ?>)</td>
40
+ <td class="cell-assign a-center last">
41
+ <?php if (true || strlen($suggestion->getMarketplaceCategory())):?>
42
+ <a
43
+ href="<?php echo $this->getUrl('meinpaket/adminhtml_matching/apply', array('id' => Mage::registry('current_product')->getId(), 'category' => $suggestion->getMarketplaceCategory())); ?>">
44
+ <?php echo $this->__('Apply'); ?>
45
+ </a>
46
+ <?php endif;?>
47
+ </td>
48
+ </tr>
49
+ <?php endforeach;?>
50
+ </tbody>
51
+ </table>
52
+ </div>
53
+ </div>
54
+ <?php else: ?>
55
+ <?php echo $this->__('No results');?>
56
+ <?php endif; ?>
57
+ </div>
58
+ </div>
app/design/adminhtml/default/default/template/meinpaket/catalog/product/matching/tab.phtml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Custom tab template
4
+ */
5
+ ?>
6
+
7
+ <?php $product = Mage::registry("current_product"); ?>
8
+
9
+ <div class="entry-edit">
10
+ <div class="entry-edit-head">
11
+ <h4 class="icon-head head-edit-form fieldset-legend">Suggestions</h4>
12
+ </div>
13
+ <div class="fieldset fieldset-wide" id="group_fields49">
14
+ <div class="hor-scroll">
15
+ <table cellspacing="0" class="form-list">
16
+ <tbody>
17
+ <tr>
18
+ <td class="label"><label for="mp_name">Name</label></td>
19
+ <td class="value"><?php echo $product->getName(); ?></td>
20
+ <td class="value"><input id="mp_name" name="mp_name"
21
+ type="checkbox" value="1" class="input-checkbox"></td>
22
+ </tr>
23
+ <tr>
24
+ <td class="label"><label for="mp_ean">EAN</label></td>
25
+ <td class="value"><?php echo Mage::helper('meinpaket/product')->getEAN($product); ?></td>
26
+ <td class="value"><input id="mp_ean" name="mp_ean" type="checkbox"
27
+ value="1" class="input-checkbox" checked="checked"></td>
28
+ </tr>
29
+ <tr>
30
+ <td colspan="3"><button onclick="loadSuggestions(); return false;"
31
+ class="scalable btn-wysiwyg">Load suggestions</button></td>
32
+ </tr>
33
+ </tbody>
34
+ </table>
35
+ </div>
36
+ </div>
37
+ </div>
38
+
39
+ <script type="text/javascript">
40
+ var mp_url = '<?php echo $this->getUrl('meinpaket/adminhtml_matching/index') ?>';
41
+ var mp_productId = <?php echo Mage::registry("current_product")->getId();?>;
42
+
43
+ function loadSuggestions() {
44
+ var name = document.getElementById('mp_name');
45
+ var ean = document.getElementById('mp_ean');
46
+
47
+ if (name.checked || ean.checked) {
48
+ new Ajax.Updater({
49
+ success : 'mp_suggest_target'
50
+ }, mp_url, {
51
+ parameters : {
52
+ id : mp_productId,
53
+ name : name.checked ? 1 : 0,
54
+ ean : ean.checked ? 1 : 0
55
+ }
56
+ });
57
+ }
58
+ }
59
+ </script>
60
+
61
+ <div id="mp_suggest_target"></div>
app/design/adminhtml/default/default/template/meinpaket/category/import/import.phtml ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $this Dhl_MeinPaket_Block_Adminhtml_CategoryImport_Import */
3
+ /* @var $result Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result */
4
+ $result = $this->getResult ();
5
+ ?>
6
+ <div class="content-header">
7
+ <table class="grid-header">
8
+ <tr>
9
+ <td><h3 class="icon-head meinpaket"><?php echo __('Import Categories'); ?></h3></td>
10
+ <td class="a-right">
11
+ <button
12
+ onclick="setLocation('<?php echo $this->getUrl('meinpaket/adminhtml_categoryImport/index/') ?>')"
13
+ class="scalable back" type="button">
14
+ <span><?php echo $this->__('start again'); ?></span>
15
+ </button>
16
+ </td>
17
+ </tr>
18
+ </table>
19
+ </div>
20
+ <div class="dashboard-container meinpaket-content">
21
+ <ul class="meinpaket-steps">
22
+ <li class="nr1"><p><?php echo __('Overview'); ?></p></li>
23
+ <li class="nr2"><p><?php echo __('Import'); ?></p></li>
24
+ <li class="nr3 active"><p><?php echo __('Result'); ?></p></li>
25
+ </ul>
26
+ <div class="cc">
27
+ <!-- -->
28
+ </div>
29
+
30
+ <div id="meinpaket-results" class="scrollablebox grid entry-edit">
31
+ <?php if($result !== null && $result->getNewCategoriesCount() + $result->getDeletedCategoriesCount() + $result->getUpdatedCategoriesCount() > 0) : ?>
32
+ <table id="meinpaket-results">
33
+ <tbody>
34
+
35
+ <?php /*** NEW CATEGORIES **********************************************/ ?>
36
+ <?php if($result->getNewCategoriesCount() > 0) : ?>
37
+ <tr>
38
+ <td colspan="4" class="row-subheader"><?php echo __('New categories'); ?> | <span
39
+ class="resultCount"><?php echo $result->getNewCategoriesCount().' '.__('total'); ?></span></td>
40
+ </tr>
41
+ <tr class="headings">
42
+ <th class="header-center">#</th>
43
+ <th class="col-product" colspan="2"><?php echo __('Category'); ?></th>
44
+ <th><?php echo __('Category Code'); ?></th>
45
+ </tr>
46
+ <?php
47
+ $newCategories = $result->getNewCategories ();
48
+ $currentIndex = 0;
49
+ $stripeClass = 'odd';
50
+ ?>
51
+ <?php foreach($newCategories as $category) : ?>
52
+ <?php $stripeClass = ($stripeClass === 'even') ? 'odd' : 'even'; ?>
53
+ <tr class="<?php echo $stripeClass; ?>">
54
+ <td class="row-num"><?php echo ++$currentIndex; ?></td>
55
+ <td colspan="2"><?php echo $category->getName(); ?> </td>
56
+ <td><?php echo $category->getCode(); ?></td>
57
+ </tr>
58
+ <?php endforeach; ?>
59
+ <?php endif; ?>
60
+
61
+ <?php /*** UPDATED CATEGORIES ******************************************/ ?>
62
+ <?php if($result->getUpdatedCategoriesCount() > 0) : ?>
63
+ <tr>
64
+ <td colspan="4" class="row-subheader"><?php echo __('Updated categories'); ?> | <span
65
+ class="resultCount"><?php echo $result->getUpdatedCategoriesCount().' '.__('total'); ?></span></td>
66
+ </tr>
67
+ <tr class="headings">
68
+ <th class="header-center">#</th>
69
+ <th class="col-product"><?php echo __('Category'); ?></th>
70
+ <th><?php echo __('Category Code'); ?></th>
71
+ </tr>
72
+ <?php
73
+ $updatedCategories = $result->getUpdatedCategories ();
74
+ $currentIndex = 0;
75
+ $stripeClass = 'odd';
76
+ ?>
77
+ <?php foreach($updatedCategories as $category) : ?>
78
+ <?php $stripeClass = ($stripeClass === 'even') ? 'odd' : 'even'; ?>
79
+ <tr class="<?php echo $stripeClass; ?>">
80
+ <td class="row-num"><?php echo ++$currentIndex; ?></td>
81
+ <td><?php echo $category->getName(); ?> </td>
82
+ <td><?php echo $category->getCode(); ?></td>
83
+ </tr>
84
+ <?php endforeach; ?>
85
+ <?php endif; ?>
86
+
87
+ <?php /*** DELETED CATEGORIES ******************************************/ ?>
88
+ <?php if($result->getDeletedCategoriesCount() > 0) : ?>
89
+ <tr>
90
+ <td colspan="4" class="row-subheader"><?php echo __('Deleted categories'); ?> | <span
91
+ class="resultCount"><?php echo $result->getDeletedCategoriesCount().' '.__('total'); ?></span></td>
92
+ </tr>
93
+ <tr class="headings">
94
+ <th class="header-center">#</th>
95
+ <th class="col-product"><?php echo __('Category'); ?></th>
96
+ <th><?php echo __('Category Code'); ?></th>
97
+ </tr>
98
+ <?php
99
+ $deletedCategories = $result->getDeletedCategories ();
100
+ $currentIndex = 0;
101
+ $stripeClass = 'odd';
102
+ ?>
103
+ <?php foreach($deletedCategories as $category) : ?>
104
+ <?php $stripeClass = ($stripeClass === 'even') ? 'odd' : 'even'; ?>
105
+ <tr class="<?php echo $stripeClass; ?>">
106
+ <td class="row-num"><?php echo ++$currentIndex; ?></td>
107
+ <td><?php echo $category->getName(); ?> </td>
108
+ <td><?php echo $category->getCode(); ?></td>
109
+ </tr>
110
+ <?php endforeach; ?>
111
+ <?php endif; ?>
112
+ </tbody>
113
+ </table>
114
+ <?php else : ?>
115
+ <div class="meinpaket-description">
116
+ <p><?php echo __('Marketplace category structure was up to date. There have been no changes.'); ?></p>
117
+ </div>
118
+ <?php endif; ?>
119
+ </div>
120
+ </div>
121
+
app/design/adminhtml/default/default/template/meinpaket/category/import/index.phtml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <div class="content-header">
3
+ <table cellspacing="0" class="grid-header">
4
+ <tr>
5
+ <td><h3 class="icon-head meinpaket"><?php echo __('Import Categories'); ?></h3></td>
6
+ <td class="a-right">
7
+ <!-- <button onclick="setLocationWithWait('<?php echo $this->getUrl('meinpaket/adminhtml_categoryImport/import/') ?>')" class="scalable" type="button"><span><?php echo $this->__('import categories'); ?></span></button> -->
8
+ <button onclick="startProcessing()" class="scalable" type="button"
9
+ id="startButton">
10
+ <span><?php echo $this->__('import categories'); ?></span>
11
+ </button>
12
+ </td>
13
+ </tr>
14
+ </table>
15
+ </div>
16
+ <div class="dashboard-container meinpaket-content">
17
+
18
+ <ul class="meinpaket-steps">
19
+ <li class="active nr1"><p><?php echo __('Overview'); ?></p></li>
20
+ <li class="nr2"><p><?php echo __('Import'); ?></p></li>
21
+ <li class="nr3"><p><?php echo __('Result'); ?></p></li>
22
+ </ul>
23
+ <div class="cc">
24
+ <!-- -->
25
+ </div>
26
+
27
+ <div id="meinpaket-description">
28
+ <p><?php echo __('Textual introduction into category import goes here...'); ?></p>
29
+ </div>
30
+
31
+ <div id="disabled-till-export" class="meinpaket-waitbox"
32
+ style="display: none">
33
+ <img src="/skin/adminhtml/default/default/meinpaket/images/loader.gif" /><br />
34
+ <small><?php echo $this->__('please wait'); ?></small>
35
+ </div>
36
+
37
+ <form id="meinpaket_form" name="meinpaket_form" method="get"
38
+ action="<?php echo $this->getUrl('meinpaket/adminhtml_categoryImport/import/') ?>">
39
+ <fieldset>
40
+ <button onclick="startProcessing()" class="scalable" type="button"
41
+ id="startButton">
42
+ <span><?php echo $this->__('import categories'); ?></span>
43
+ </button>
44
+ </fieldset>
45
+ </form>
46
+ </div>
47
+
app/design/adminhtml/default/default/template/meinpaket/category_import/import.phtml ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $this Dhl_MeinPaket_Block_Adminhtml_CategoryImport_Import */
3
+ /* @var $result Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result */
4
+ $result = $this->getResult ();
5
+ ?>
6
+ <div class="content-header">
7
+ <table class="grid-header">
8
+ <tr>
9
+ <td><h3 class="icon-head meinpaket"><?php echo __('Import Categories'); ?></h3></td>
10
+ <td class="a-right">
11
+ <button
12
+ onclick="setLocation('<?php echo $this->getUrl('meinpaket/adminhtml_categoryImport/index/') ?>')"
13
+ class="scalable back" type="button">
14
+ <span><?php echo $this->__('start again'); ?></span>
15
+ </button>
16
+ </td>
17
+ </tr>
18
+ </table>
19
+ </div>
20
+ <div class="dashboard-container meinpaket-content">
21
+ <ul class="meinpaket-steps">
22
+ <li class="nr1"><p><?php echo __('Overview'); ?></p></li>
23
+ <li class="nr2"><p><?php echo __('Import'); ?></p></li>
24
+ <li class="nr3 active"><p><?php echo __('Result'); ?></p></li>
25
+ </ul>
26
+ <div class="cc">
27
+ <!-- -->
28
+ </div>
29
+
30
+ <div id="meinpaket-results" class="scrollablebox grid entry-edit">
31
+ <?php if($result !== null && $result->getNewCategoriesCount() + $result->getDeletedCategoriesCount() + $result->getUpdatedCategoriesCount() > 0) : ?>
32
+ <table id="meinpaket-results">
33
+ <tbody>
34
+
35
+ <?php /*** NEW CATEGORIES **********************************************/ ?>
36
+ <?php if($result->getNewCategoriesCount() > 0) : ?>
37
+ <tr>
38
+ <td colspan="4" class="row-subheader"><?php echo __('New categories'); ?> | <span
39
+ class="resultCount"><?php echo $result->getNewCategoriesCount().' '.__('total'); ?></span></td>
40
+ </tr>
41
+ <tr class="headings">
42
+ <th class="header-center">#</th>
43
+ <th class="col-product" colspan="2"><?php echo __('Category'); ?></th>
44
+ <th><?php echo __('Category Code'); ?></th>
45
+ </tr>
46
+ <?php
47
+ $newCategories = $result->getNewCategories ();
48
+ $currentIndex = 0;
49
+ $stripeClass = 'odd';
50
+ ?>
51
+ <?php foreach($newCategories as $category) : ?>
52
+ <?php $stripeClass = ($stripeClass === 'even') ? 'odd' : 'even'; ?>
53
+ <tr class="<?php echo $stripeClass; ?>">
54
+ <td class="row-num"><?php echo ++$currentIndex; ?></td>
55
+ <td colspan="2"><?php echo $category->getName(); ?> </td>
56
+ <td><?php echo $category->getCode(); ?></td>
57
+ </tr>
58
+ <?php endforeach; ?>
59
+ <?php endif; ?>
60
+
61
+ <?php /*** UPDATED CATEGORIES ******************************************/ ?>
62
+ <?php if($result->getUpdatedCategoriesCount() > 0) : ?>
63
+ <tr>
64
+ <td colspan="4" class="row-subheader"><?php echo __('Updated categories'); ?> | <span
65
+ class="resultCount"><?php echo $result->getUpdatedCategoriesCount().' '.__('total'); ?></span></td>
66
+ </tr>
67
+ <tr class="headings">
68
+ <th class="header-center">#</th>
69
+ <th class="col-product"><?php echo __('Category'); ?></th>
70
+ <th><?php echo __('Category Code'); ?></th>
71
+ </tr>
72
+ <?php
73
+ $updatedCategories = $result->getUpdatedCategories ();
74
+ $currentIndex = 0;
75
+ $stripeClass = 'odd';
76
+ ?>
77
+ <?php foreach($updatedCategories as $category) : ?>
78
+ <?php $stripeClass = ($stripeClass === 'even') ? 'odd' : 'even'; ?>
79
+ <tr class="<?php echo $stripeClass; ?>">
80
+ <td class="row-num"><?php echo ++$currentIndex; ?></td>
81
+ <td><?php echo $category->getName(); ?> </td>
82
+ <td><?php echo $category->getCode(); ?></td>
83
+ </tr>
84
+ <?php endforeach; ?>
85
+ <?php endif; ?>
86
+
87
+ <?php /*** DELETED CATEGORIES ******************************************/ ?>
88
+ <?php if($result->getDeletedCategoriesCount() > 0) : ?>
89
+ <tr>
90
+ <td colspan="4" class="row-subheader"><?php echo __('Deleted categories'); ?> | <span
91
+ class="resultCount"><?php echo $result->getDeletedCategoriesCount().' '.__('total'); ?></span></td>
92
+ </tr>
93
+ <tr class="headings">
94
+ <th class="header-center">#</th>
95
+ <th class="col-product"><?php echo __('Category'); ?></th>
96
+ <th><?php echo __('Category Code'); ?></th>
97
+ </tr>
98
+ <?php
99
+ $deletedCategories = $result->getDeletedCategories ();
100
+ $currentIndex = 0;
101
+ $stripeClass = 'odd';
102
+ ?>
103
+ <?php foreach($deletedCategories as $category) : ?>
104
+ <?php $stripeClass = ($stripeClass === 'even') ? 'odd' : 'even'; ?>
105
+ <tr class="<?php echo $stripeClass; ?>">
106
+ <td class="row-num"><?php echo ++$currentIndex; ?></td>
107
+ <td><?php echo $category->getName(); ?> </td>
108
+ <td><?php echo $category->getCode(); ?></td>
109
+ </tr>
110
+ <?php endforeach; ?>
111
+ <?php endif; ?>
112
+ </tbody>
113
+ </table>
114
+ <?php else : ?>
115
+ <div class="meinpaket-description">
116
+ <p><?php echo __('Marketplace category structure was up to date. There have been no changes.'); ?></p>
117
+ </div>
118
+ <?php endif; ?>
119
+ </div>
120
+ </div>
121
+
app/design/adminhtml/default/default/template/meinpaket/category_import/index.phtml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <div class="content-header">
3
+ <table cellspacing="0" class="grid-header">
4
+ <tr>
5
+ <td><h3 class="icon-head meinpaket"><?php echo __('Import Categories'); ?></h3></td>
6
+ <td class="a-right">
7
+ <!-- <button onclick="setLocationWithWait('<?php echo $this->getUrl('meinpaket/adminhtml_categoryImport/import/') ?>')" class="scalable" type="button"><span><?php echo $this->__('import categories'); ?></span></button> -->
8
+ <button onclick="startProcessing()" class="scalable" type="button"
9
+ id="startButton">
10
+ <span><?php echo $this->__('import categories'); ?></span>
11
+ </button>
12
+ </td>
13
+ </tr>
14
+ </table>
15
+ </div>
16
+ <div class="dashboard-container meinpaket-content">
17
+
18
+ <ul class="meinpaket-steps">
19
+ <li class="active nr1"><p><?php echo __('Overview'); ?></p></li>
20
+ <li class="nr2"><p><?php echo __('Import'); ?></p></li>
21
+ <li class="nr3"><p><?php echo __('Result'); ?></p></li>
22
+ </ul>
23
+ <div class="cc">
24
+ <!-- -->
25
+ </div>
26
+
27
+ <div id="meinpaket-description">
28
+ <p><?php echo __('Textual introduction into category import goes here...'); ?></p>
29
+ </div>
30
+
31
+ <div id="disabled-till-export" class="meinpaket-waitbox"
32
+ style="display: none">
33
+ <img src="/skin/adminhtml/default/default/meinpaket/images/loader.gif" /><br />
34
+ <small><?php echo $this->__('please wait'); ?></small>
35
+ </div>
36
+
37
+ <form id="meinpaket_form" name="meinpaket_form" method="get"
38
+ action="<?php echo $this->getUrl('meinpaket/adminhtml_categoryImport/import/') ?>">
39
+ <fieldset>
40
+ <button onclick="startProcessing()" class="scalable" type="button"
41
+ id="startButton">
42
+ <span><?php echo $this->__('import categories'); ?></span>
43
+ </button>
44
+ </fieldset>
45
+ </form>
46
+ </div>
47
+
app/design/adminhtml/default/default/template/meinpaket/leftmenu.phtml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <ul class="tabs">
2
+ <li>
3
+ <dl>
4
+ <?php
5
+ // Mage::helper/'core/string')
6
+ foreach ( $this->menuItems as $action => $item ) :
7
+ $class = "";
8
+ if ($action == $this->activeItem) {
9
+ $class = "active";
10
+ }
11
+ ?>
12
+ <dd>
13
+ <a class="<?php echo $class ?>"
14
+ href="<?php echo $this->getUrl($action) ?>"> <span class="active"><?php echo $item ?></span>
15
+ </a>
16
+ </dd>
17
+ <?php endforeach ?>
18
+ </dl>
19
+ </li>
20
+ </ul>
app/design/adminhtml/default/default/template/meinpaket/productexport.phtml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <link rel="stylesheet" type="text/css"
2
+ href="/skin/adminhtml/default/dhl_meinpaket/module.css" />
3
+ <div class="content-header">
4
+ <table cellspacing="0" class="grid-header">
5
+ <tr>
6
+ <td><h3 class="icon-head meinpaket">Export Products</h3></td>
7
+ <td class="a-right">
8
+ <button
9
+ onclick="setLocation('<?php echo $this->getUrl('meinpaket/adminhtml_productExport/export/') ?>')"
10
+ class="scalable save" type="button">
11
+ <span><?php echo $exportLabel; ?></span>
12
+ </button>
13
+ </td>
14
+ </tr>
15
+ </table>
16
+ </div>
17
+ <div class="dashboard-container">
18
+ <form id="myform" name="myform" method="post"
19
+ action="<?php echo $this->getUrl('web/adminhtml_myform/post/') ?>">
20
+
21
+ <ul class="meinpaket-steps">
22
+ <li class="active nr1"><p>Wählen Sie aus welche Produkte hochgeladen
23
+ werden sollen</p></li>
24
+ <li class="nr2"><p>Upload</p></li>
25
+ <li class="nr3"><p>Results</p></li>
26
+ </ul>
27
+
28
+ </div>
29
+
app/design/adminhtml/default/default/template/meinpaket/steps.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <ul class="meinpaket-steps">
3
+ <?php
4
+ $i = 0;
5
+ foreach ( $this->steps as $k => $v ) :
6
+ $i ++;
7
+ $class = "nr" . $i;
8
+ if ($k == $this->activeStep) {
9
+ $class .= " active";
10
+ }
11
+ ?>
12
+ <li class="<?php echo $class ?>"><p><?php echo $v ?></p></li>
13
+
14
+ <?php endforeach ?>
15
+ </ul>
app/design/frontend/base/default/layout/meinpaket.xml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout version="0.1.0">
3
+ </layout>
app/design/frontend/base/default/template/dhl/meinpaket/checkout/abort.phtml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <h2><?php echo $title ?></h2>
2
+ <?php echo $content?>
3
+ <p>&nbsp;</p>
4
+ <p>
5
+ <a href="<?php echo Mage::app()->getStore()->getUrl() ?>"><?php echo __('Continue shopping') ?></a>
6
+ </p>
app/design/frontend/base/default/template/dhl/meinpaket/checkout/cartbutton.phtml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->isPossibleOnepageCheckout()):?>
2
+ <button type="button"
3
+ title="<?php echo $this->__('Proceed to Checkout') ?>"
4
+ class="button btn-checkout<?php if ($this->isDisabled()):?> no-checkout<?php endif; ?>"
5
+ <?php if ($this->isDisabled()):?> disabled="disabled" <?php endif; ?>
6
+ onclick="window.location='<?php echo $this->getCheckoutUrl() ?>';">
7
+ <span><span><?php echo $this->__('Proceed to Checkout') ?></span></span>
8
+ </button>
9
+ <?php if ( (bool)Mage::getStoreConfig('meinpaket/checkout/available') ) { ?>
10
+ <p style="margin-top: 10px;">
11
+ <a
12
+ href="<?php echo Mage::app()->getStore()->getUrl() ?>meinpaket/checkout/redirect">
13
+ <img
14
+ src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) ?>skin/frontend/default/default/meinpaket/images/dhl_checkout_button.png"
15
+ alt="POSTPAY" title="POSTPAY" />
16
+ </a>
17
+ </p>
18
+ <?php } ?>
19
+ <?php endif?>
app/design/frontend/base/default/template/dhl/meinpaket/checkout/error.phtml ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <h2><?php echo $title ?></h2>
2
+ <?php echo $content ?>
app/design/frontend/base/default/template/dhl/meinpaket/checkout/sidebarbutton.phtml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $checkoutIsPossible = false;
3
+
4
+ foreach ( Mage::getSingleton ( 'checkout/session' )->getQuote ()->getItemsCollection () as $item ) {
5
+ $checkoutIsPossible = true;
6
+ }
7
+ ?>
8
+ <?php if ($checkoutIsPossible) { ?>
9
+ <?php if ( (bool)Mage::getStoreConfig('meinpaket/checkout/available') ) { ?>
10
+ <div class="block">
11
+ <div class="block-content">
12
+ <a
13
+ href="<?php echo Mage::app()->getStore()->getUrl() ?>meinpaket/checkout/redirect"
14
+ style="display: block; text-align: center; margin-bottom: 5px;"> <img
15
+ src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) ?>skin/frontend/default/default/meinpaket/images/dhl_checkout_button.png"
16
+ alt="POSTPAY" title="POSTPAY" />
17
+ </a>
18
+ </div>
19
+ </div>
20
+ <?php } ?>
21
+ <?php } ?>
app/design/frontend/base/default/template/dhl/meinpaket/checkout/success.phtml ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <h2><?php echo $title ?></h2>
2
+ <?php echo $content ?>
app/etc/modules/Dhl_MeinPaket.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dhl_MeinPaket>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Dhl_MeinPaket>
8
+ </modules>
9
+ </config>
app/locale/de_DE/Dhl_MeinPaket.csv ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "import Variantconfigurations","Variantenkonfigurationen importieren"
2
+ "Credentials","Zugangsdaten"
3
+ "export products","Produkte exportieren"
4
+ "import orders","Bestellungen importieren"
5
+ "import categories","Kategorien importieren"
6
+ "list products","Produkte anzeigen"
7
+ "select products","Produktauswahl angeben"
8
+ "edit product","Produkt bearbeiten"
9
+ "only marked products", "Nur ausgewählte Produkte"
10
+ "all","Alle"
11
+ "start again","nochmal starten"
12
+ "best prices","Beste Preise"
13
+ "DHL Username","Benutzername"
14
+ "This is the username that was given to you by DHL, mostly your email address.","Dies ist der Benutzername, der Ihnen von DHL mitgeteilt wurde. Meisst ist dies Ihre E-Mail Adresse."
15
+ "DHL Password","Passwort"
16
+ "This is the password that was given to you by DHL.","Dies ist das Passwort, das Ihnen von DHL mitgeteilt wurde."
17
+ "Remote system","Entferntes System"
18
+ "This is the address of the remote API.","Dies ist die Adresse der entfernten API."
19
+ "Tax rates","Steuersätze"
20
+ "Default tax rate","Standard-Steuersatz"
21
+ "The default tax rate applies to most products","Dieser Steuersatz gilt für die meissten Produkte."
22
+ "Reduced tax rate","reduzierter Steuersatz"
23
+ "The reduced tax rate applies to special products, such as aliments","Der reduzierte Steuersatz, der für spezielle Produkte - etwa Nahrungsmittel - gilt."
24
+ "Shop tree root","Shop Hauptkategorie"
25
+ "Marketplace tree root","Marktplatz Hauptkategorie"
26
+ "Sync with MeinPaket.de","mit MeinPaket.de abgleichen"
27
+ "Maximum stock qty. for MeinPaket.de","maximale Stückzahl für MeinPaket.de"
28
+ "Product attributes","Produkteigenschaften"
29
+ "Delivery time","Lieferzeit (in Tagen)"
30
+ "Please select the product attribute which represents the approx. delivery time","Bitte wählen Sie die Produkteigenschaft, welche die Lieferzeit angibt."
31
+ "Default delivery time","Standard-Lieferzeit"
32
+ "Delivery time in days if no other delivery time applies","Lieferzeit in Tagen, wenn keine andere Lieferzeit angegeben."
33
+ "Marketplace category ID","Marktplatz-Kategorie"
34
+ "These products could not be exported","Die folgenden Produkte konnten aufgrund von Fehlern nicht exportiert werden"
35
+ "Result","Ergebnis"
36
+ "Selection","Auswahl"
37
+ "Upload","Upload"
38
+ "Common Errors","Allgemeine Fehler"
39
+ "Product","Produkt"
40
+ "Edit Product","Produkt bearbeiten"
41
+ "Error Description","Fehlerbeschreibung"
42
+ "Invalid value for field","Ungültiger Wert für Feld"
43
+ "Missing value for field","Fehlender Wert für Feld"
44
+ "The following products could only be exported as description","Für die folgenden Produkte konnten nur Angebote eingestellt werden"
45
+ "Unknown Error","Unbekannter Fehler"
46
+ "Product is unknown in MeinPaket marketplace","Produkt ist im MeinPaket Marktplatz nicht bekannt"
47
+ "Successfully Exported Products","Erfolgreich exportierte Produkte"
48
+ "total","gesamt"
49
+ "of","von"
50
+ "%s of %s products were successfully exported","%s von %s Produkten wurden erfolgreich exportiert"
51
+ "At this place you can choose which products you want to export and start the process.","<b>Hier können Sie Produkte Ihres Magento-Shops nach MeinPaket.de exportieren.</b><p>Wählen Sie in der Auswahlliste unten den Punkt &bdquo;<i>Nur ausgewählte Produkte</i>&rdquo;, um nur die Produkte zu exportieren, deren &bdquo;<i>mit MeinPaket.de abgleichen</i>&rdquo;-Attribut explizit auf &bdquo;<i>Ja</i>&rdquo; gesetzt wurde. Dieses Attribut können Sie in den Produktinformationen im Reiter &bdquo;<i>Allgemein</i>&rdquo; bearbeiten.</p><p>Um alle Produkte Ihres Magento-Shops nach MeinPaket.de zu exportieren, wählen Sie &bdquo;<i>Alle</i>&rdquo; in der unten stehenden Auswahlliste. Berücksichtigt werden hierbei nur Produkte, die einer MeinPaket.de-Marktplatzkategorie zugeordnet sind.</p><p>Sie starten den Vorgang durch Betätigen des &bdquo;<i>Produkte exportieren</i>&rdquo;-Buttons. Dadurch springt der Export in den Upload-Modus. Unterbrechen Sie den Prozess während dessen nicht.</p><p>Wenn alle ausgewählten Produkte an MeinPaket übermittelt wurden, sehen Sie eine Übersicht aller exportierter Produkte sowie eine detaillierte Auflistung aller während des Vorgangs aufgetretenen Fehler.</p>"
52
+ "Skipped %s duplicate orders that were already imported previously.","%s Bestellungen übersprungen, die bereits zu einem früheren Zeitpunkt importiert wurden."
53
+ "Skipped %s duplicate order that was already imported previously.","%s Bestellung übersprungen, die bereits zu einem früheren Zeitpunkt importiert wurde."
54
+ "%s order(s) sucessfully imported.","%s Bestellung(en) erfolgreich importiert."
55
+ "start date","Startdatum"
56
+ "end date","Enddatum"
57
+ "Textual guide for importing orders follows here","<b>Hier können Sie Bestellungen importieren, die Käufer auf MeinPaket.de getätigt haben.</b><p>Legen Sie mit Hilfe der Felder &bdquo;<i>Startdatum</i>&rdquo; und &bdquo;<i>Enddatum</i>&rdquo; einen Zeitraum fest, für den Sie Bestellungen von MeinPaket.de importieren möchten. Sie können das Feld &bdquo;<i>Enddatum</i>&rdquo; leer lassen, um alle Bestellungen vom &bdquo;<i>Startdatum</i>&rdquo; bis zum jetzigen Zeitpunkt zu importieren.</p><p>Starten Sie den Vorgang durch Betätigen des &bdquo;<i>Bestellungen importieren</i>&rdquo;-Buttons. Warten Sie, bis der Vorgang abgeschlossen ist. Sie sehen im Anschluss einen Statusbericht über die importierten Bestellungen.</p>"
58
+ "leave empty to load all till now","leer lassen, um alles bis jetzt zu laden"
59
+ "please wait","Bitte warten...",
60
+ "view orders","Bestellungen ansehen"
61
+ "Finished","Abgeschlossen"
62
+ "Import Products","Bestellungen importieren"
63
+ "Import Categories","MeinPaket.de Kategorien importieren"
64
+ "Category import completed.","Der Import der MeinPaket.de Marktplatz-Kategorien wurde abgeschlossen."
65
+ "Textual introduction into category import goes here...","<b>Hier können Sie die Marktplatzkategorien von MeinPaket.de importieren. Die Kategorien finden Sie im Anschluss unter der Kategorie &bdquo;<i>MeinPaket.de marketplace</i>&rdquo; auf der obersten Ebene Ihres Magento-Kategoriebaumes.</b><p>Wenn Sie die MeinPaket.de-Marktplatzkategorien schon einmal importiert haben, werden diese nicht überschrieben, sondern nur mögliche Änderungen und Ergänzungen vorgenommen. Produkte, die Sie bereits MeinPaket.de-Marktplatzkategorien zugeordnet haben, bleiben weiterhin diesen Kategorien zugeordnet.</p><p>Starten Sie den Importvorgang durch Betätigen des &bdquo;<i>Kategorien importieren</i>&rdquo;-Buttons. Der Vorgang kann einige Minuten dauern. Brechen Sie den Vorgang nicht ab.</p>"
66
+ "Product export failed. Failed connecting to MeinPaket server.","Produktexport fehlgeschlagen: Konnte keine Verbindung zu MeinPaket.de aufgebaut werden."
67
+ "No new orders found.","Es wurden keine neuen Bestellungen gefunden."
68
+ "Skipped %s order(s) because: out of stock. Please process the following order(s) at your MeinPaket.de dealer area:","%s Bestellung(en) übersprungen, da nicht auf Lager. Bitte bearbeiten Sie die folgende(n) Bestellung(en) in Ihrem MeinPaket Händlerbereich:"
69
+ "Skipped %s order(s) because: some or all of the included products were disabled in Magento after the export to MeinPaket.de . Please process the following order(s) at your MeinPaket.de dealer area:","%s Bestellung(en) übersprungen, da sie Produkte enthielten, die nachträglich zum Export nach MeinPaket.de in Magento deaktiviert wurden. Bitte bearbeiten Sie die folgende(n) Bestellung(en) in Ihrem MeinPaket Händlerbereich:"
70
+ "%s was ordered with a different price (%s instead of current price %s). Was the price changed after exporting to MeinPaket.de?","%s wurde zu einem anderen Preis bestellt (%s statt aktuellem Preis %s). Wurde der Preis nachträglich nach dem Export zu MeinPaket.de geändert?"
71
+ "Internal error on MeinPaket server","Interner Fehler auf MeinPaket-Server",
72
+ "Product stock is lower than zero.","Der Lagerbestand für dieses Produkt ist im negativen Bereich."
73
+ "Overview","Übersicht"
74
+ "Category","Kategorie"
75
+ "Old name","Alter Name"
76
+ "Edit Category","Kategorie bearbeiten"
77
+ "New categories","Neue Kategorien"
78
+ "Renamed categories","Umbenannte Kategorien"
79
+ "Deleted categories","Gelöschte Kategorien"
80
+ "Successfully imported marketplace categories.","Die Marktplatz-Kategorien wurden erfolgreich mit MeinPaket.de abgeglichen."
81
+ "Connecting to MeinPaket.de server failed.","Die Verbindung zum MeinPaket.de-Server konnte nicht aufgebaut werden."
82
+ "Connection to MeinPaket.de server timed out.","Der MeinPaket.de-Server antwortet nicht."
83
+ "Unknown error","Es ist ein unbekannter Fehler aufgetreten"
84
+ "Error","Fehler"
85
+ "Added %s new categories.","Es wurden %s neue Kategorien angelegt."
86
+ "Renamed %s categories.","Es wurden %s Kategorien umbenannt."
87
+ "Deleted %s categories.","Es wurden %s Kategorien gelöscht, die im MeinPaket.de-Marktplatz nicht mehr verfügbar sind."
88
+ "Marketplace category structure was up to date. There have been no changes.","Markplatz-Kategoriestruktur ist auf dem neuesten Stand."
89
+ "Imported from DHL MeinPaket.de","Importiert von MeinPaket.de"
90
+ "MeinPaket.de Order No.","MeinPaket.de Best.Nr."
91
+ "Request could not be built.","Die Anfrage konnte nicht generiert werden."
92
+ "MeinPaket.de server returned HTPP code %s.","Der MeinPaket.de-Server hat den HTTP-Fehlercode %s zurückgeliefert."
93
+ "Connection to MeinPaket.de server timed out.","Zeitüberschreitung beim Verbindungsaufbau zu MeinPaket.de-Server."
94
+ "Invalid response from MeinPaket.de server.","Ungültige Antwort von MeinPaket.de-Server erhalten."
95
+ "Error on tranfering cancelled items to MeinPaket.de.","Bei der Stornierung der Bestellpositionen bei MeinPaket.de ist ein Fehler aufgetreten."
96
+ "MeinPaket.de server returned error code %s.","Der MeinPaket.de-Server hat den Fehlercode %s zurückgegeben."
97
+ "Shipment has not been accepted by MeinPaket.de.","Die Lieferung wurde von MeinPaket.de nicht akzeptiert."
98
+ "Error on transfering shipment to MeinPaket.de.","Fehler beim Senden der Lieferinformationen zu MeinPaket.de."
99
+ "Refund has not been accepted by MeinPaket.de.","Die Gutschrift wurde nicht von MeinPaket.de akzeptiert."
100
+ "Error on transfering refund to MeinPaket.de.","Fehler beim Senden der Gutschrift an MeinPaket.de."
101
+ "Tracking code has not been accepted by MeinPaket.de.","Der gesendete Tracking-Code für diese Lieferung wurde von MeinPaket.de nicht akzeptiert."
102
+ "MeinPaket.de returned error code %s.","MeinPaket.de lieferte den Fehler-Code %s zurück."
103
+ "Error on transfering tracking code to MeinPaket.de.","Fehler beim Senden des Tracking-Codes am MeinPaket.de."
104
+ "There were no products that could be exported.","Es konnten keine Produkte exportiert werden."
105
+ "Product information has not been accepted by MeinPaket.de.","Die Produktinformationen wurden von MeinPaket.de nicht akzeptiert."
106
+ "Error on transfering product information to MeinPaket.de.","Fehler beim Exportieren des Produktes nach MeinPaket.de."
107
+ "Thank you for your order!","Vielen Dank für Ihre Bestellung!"
108
+ "Your order was successfully processed at MeinPaket.de. We will recieve your order shortly.","Ihre Bestellung wurde bei MeinPaket.de erfogreich bearbeitet. Wir werden Ihre Bestellung in Kürze erhalten."
109
+ "Ooops!","Uuups!"
110
+ "Something has gone terribly wrong while processing your order at MeinPaket.de! Please contact our customer service.","Etwas ist schiefgelaufen, während Ihre Bestellung bei MeinPaket.de bearbeitet wurde. Bitte kontaktieren Sie unseren Kundenservice!"
111
+ "Checkout aborted!","Bestellvorgang abgebrochen!"
112
+ "You decided to abort the external checkout at DHL MeinPaket. Your order has NOT been processed yet. Feel free to continue shopping and use our own checkout.","Sie haben den POSTPAY abgebrochen. Ihre Bestellung wurde noch NICHT verabeitet. Gerne können Sie Ihren Einkauf fortsetzen und unseren Checkout nutzen."
113
+ "Continue shopping","Einkauf fortsetzen"
114
+ "Checkout","Checkout"
115
+ "POSTPAY available","POSTPAY anbieten"
116
+ "This defines wether the external Checkout with DHL is available for customers.","Dies legt fest, ob der POSTPAY für Ihre Kunden verfügbar ist."
117
+ "The MeinPaket server did not deliver a valid response. Have a look at the system log for more information.","Der MeinPaket-Server hat keine gültige Antwort für die Bestellungsabfrage geliefert. Für mehr Informationen zu diesem Problem, schauen Sie bitte im System-Log nach."
118
+ "You are not authorized to execute the requested functionality on MeinPaket","Sie sind nicht berechtigt diese Funktionalität der MeinPaket-Plattform zu nutzen"
119
+ "The provided data was incorrect","MeinPaket konnte die gegebenen Daten nicht akzeptieren"
120
+ "The requested modification is not allowed. Please contact the MeinPaket support team","Diese Modifikation ist nicht erlaubt. Bitte kontaktieren Sie das MeinPaket Support Team"
121
+ "The product is not mapped to neither a marketplace nor a shop category","Dieses Produkt ist weder einer Markplatzkategorie noch einer Shopkategorie zugewiesen"
122
+ "The referenced product cannot be sold","Das Produkt kann nicht auf MeinPaket verkauft werden"
123
+ "The referenced marketplace category could not be found at MeinPaket","Die angegebene Marktplatzkategorie kann auf MeinPaket nicht gefunden werden. Bitte importieren Sie die Marktplatzkategorien erneut, um auf dem aktuellen Stand zu arbeiten"
124
+ "The referenced shop category could not be found at MeinPaket","Die angegebene Shop-Kategorie konnte bei MeinPaket nicht gefunden werden"
125
+ "Default Shipment Method","Standard Versandmethode"
126
+ "Shipment method which is used for order import and POSTPAY.","Versandmethode, die beim Import von MeinPaket-Bestellungen und für POSTPAY verwendet wird."
127
+ "Submit shipping costs for POSTPAY","Versandkosten übertragen"
128
+ "If set to yes, the shippingscosts for the POSTPAY will be calculated based on the default shipment method.","Legt fest, ob die Versandkosten basierend auf der eingestellten Standard Liefermethode mit übertragen werden."
129
+ "Error on POSTPAY","Fehler bei POSTPAY"
130
+ "The current version of POSTPAY does not support configurable products.","POSTPAY unterstützt in der aktuellen Version keine konfigurierbaren Produkte."
131
+ "attribute mapping","Attribut-Mapping"
132
+ "Attribute Mapping","Attribut-Mapping"
133
+ "Attribute mappings","Attribut-Mappings"
134
+ "Attribute Mappings","Attribut-Mappings"
135
+ "Add Attribute Mapping","Neues Attribut-Mapping"
136
+ "Save Mapping","Mapping speichern"
137
+ "Create Attribute Mapping","Neues Attribut-Mapping anlegen"
138
+ "Edit Attribute Mapping","Attribut-Mapping bearbeiten"
139
+ "Magento Attribute Set","Magento Attribut-Set"
140
+ "Please select attribute set and variant.","Bitte wählen Sie ein Attribut-Set und eine Varianten-Konfiguration aus."
141
+ "MeinPaket Variant Configuration","MeinPaket Varianten-Konfiguration"
142
+ "_Custom_","_Benutzerdefiniert_"
143
+ "not assigned","nicht zugewiesen"
144
+ "Magento Attribute","Magento-Attribut"
145
+ "MeinPaket Attribute","MeinPaket-Attribut"
146
+ "Magento Value","Magento-Wert"
147
+ "MeinPaket Value","MeinPaket-Wert"
148
+ "Edit Value Mapping","bearbeiten"
149
+ "Delete Mapping","löschen"
150
+ "No mapable attribute values available for the selected MeinPaket attribute.","Für das ausgewählte MeinPaket-Attribut existieren keine zuweisbaren Attribut-Werte."
151
+ "Magento attribute values will be used instead.","Es werden direkt die Werte des Magento-Attributes verwendet."
152
+ "_Auto_","_Automatisch_"
153
+ "Apply a mapping for the following MeinPaket attributes","Bitte legen Sie für folgenden MeinPaket-Attribute ein Attribut-Mapping fest"
154
+ "A mapping for the Magento attribute set already exists.","Ein Mapping für das ausgewählte Attribut-Set existiert bereits."
155
+ "Your shopping cart contains product types that can not be handled by POSTPAY.","Ihr Einkaufswagen enthält Produkttypen, die von POSTPAY nich verarbeitet werden können."
156
+ "Not available.","Nicht verfügbar."
157
+ "Product export failed for unknown reason.","Der Produktexport ist aus einem unbekannten Grund fehlgeschlagen."
158
+ "Missing value mapping for attribute","Fehlende Wertezuweisung für Attribut"
159
+ "Default customer email","Standard Kunden-E-Mail-Adresse"
160
+ "Customer","Kunde"
161
+ "This eMail address is used as the default one for orders that do not include one.","Diese E-Mail-Adresse wird als Standard-Adresse für Bestellungen verwendet, für die keine Kunden-E-Mail-Adresse geliefert wird."
162
+ "The following configurable products could not be exported","Die folgenden konfigurierbaren Produkte konnten nicht exportiert werden"
163
+ "Ivalid modification of element","Unerlaubte Modifikation des Elementes"
164
+ "Variant group does not exist on MeinPaket","Die verwendeten Produktattribute sind als MeinPaket-Variantenkonfiguration nicht bekannt."
165
+ "Color","Farbe"
166
+ "Size","Größe"
167
+ "Dimension","Abmessung"
168
+ "Quantity","Anzahl"
169
+ "Width","Breite"
170
+ "Format","Format"
171
+ "Material","Material"
172
+ "Length","Länge"
173
+ "Flavor","Geschmacksrichtung"
174
+ "Inscription","Beschriftung"
175
+ "Model","Modell"
176
+ "Platform","Plattform"
177
+ "Radius","Radius"
178
+ "Strength","Stärke"
179
+ "Diameter","Durchmesser"
180
+ "Cylinder","Zylinder"
181
+ "Axis","Achse"
182
+ "Bust Measurement",Brustumfang
183
+ "Cup","Cup"
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>DHL_MeinPaket2</name>
4
+ <version>2.0.8</version>
5
+ <stability>stable</stability>
6
+ <license>--</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>MeinPaket connector</summary>
10
+ <description>The Extension connects your magento shop with DHL MeinPaket.</description>
11
+ <notes>--</notes>
12
+ <authors><author><name>DHL Vertriebs GmbH</name><user>--</user><email>support@meinpaket.de</email></author></authors>
13
+ <date>2014-11-03</date>
14
+ <time>14:32:00</time>
15
+ <contents><target name="magecommunity"><dir><dir name="Dhl"><dir name="MeinPaket"><dir><dir name="Block"><dir name="Adminhtml"><dir name="Async"><file name="Grid.php" hash="4b82203f22583909829d6e8ac0db3b48"/></dir><file name="Async.php" hash="ef4f9e97c51e89e0500c1716f78f137d"/><dir name="Backlog"><dir name="Product"><file name="Grid.php" hash="1e174969ba66fee012f821537c3ebcfe"/></dir><file name="Product.php" hash="d0fa6e92c7a2349cb2ef578eb1dad702"/></dir><dir name="BestPrice"><file name="Grid.php" hash="adb8a1085e086f3d1dc57a489619ff5d"/></dir><file name="BestPrice.php" hash="b4f9912d464830a48fd5154c45b0c040"/><dir name="Catalog"><dir name="Product"><dir name="Matching"><file name="Result.php" hash="135446bcf25b60bb017e29b15881daa8"/><file name="Tab.php" hash="6f27e6fb28ee96e9202361e7d6c43768"/></dir></dir></dir><dir name="CategoryImport"><file name="Import.php" hash="ff3d5bd990c083a3b301176c24362913"/><file name="Index.php" hash="4c5a08ddbb0690b1cfa0761d946d0438"/></dir><file name="LeftMenu.php" hash="841b0491f1c19c07448e112badba8931"/><dir name="Log"><file name="Grid.php" hash="bf9c49ad316749ef39f580a24dae0de0"/></dir><file name="Log.php" hash="8b8483b85d3fde61e1311735e259ff83"/><dir name="OrderImport"><file name="Index.php" hash="93fdf0e300f87fdf85dc41e6b881bb10"/></dir><dir name="ProductExport"><file name="Export.php" hash="e12ef6d9b52a9607820fbcd5e58e76ca"/><file name="Index.php" hash="7495cd0332c5ca82060ceba2e6113c87"/><file name="List.php" hash="4a32ced740d35ebb7a10d0fffa782223"/></dir><file name="Steps.php" hash="93a8cac6f58eba2d32b116b725099f1f"/></dir><dir name="Checkout"><file name="Abort.php" hash="0d26a20ad1bc999d4b77ac8a7fbb9d2e"/><file name="Error.php" hash="43852fdbf5efc3764258fb1984a15d2b"/><file name="Success.php" hash="0a5519df124dd0894634b59e41d6a4ef"/></dir></dir><dir name="Helper"><file name="Attribute.php" hash="36cf44cf54204426e3f50864381a6443"/><file name="Backlog.php" hash="51c08b4ef137799d0e7dbf900543ab3e"/><file name="Cron.php" hash="f9fadece6ceb35c90568bd68b5ee0ccd"/><file name="Data.php" hash="17b2ff0eaf887b371ab40b0bbb2ca439"/><file name="Order.php" hash="4d14caabf6a94f15a94ce570dfba82da"/><file name="Product.php" hash="42495296ac652656def68db51a966813"/><file name="Shipment.php" hash="9301fede718b839f2c0c2677e2fb3bf9"/></dir><dir name="Model"><file name="Async.php" hash="0a28e792075d101a619e49265f843fe1"/><dir name="Attribute"><file name="Mapping.php" hash="7d8a8d9e18f7c6019ae71a7032061ab7"/></dir><dir name="Backlog"><file name="Product.php" hash="a2d547dcfba28c80819155a73ff5cff4"/></dir><file name="BestPrice.php" hash="b75de965445df6125e115d0d89add52c"/><dir name="Carrier"><file name="Meinpaket.php" hash="ef4c1115bf11a3584896743e7dd8a8bf"/></dir><file name="Category.php" hash="6c809b62cf4688ac62b39c0aae224422"/><dir name="Client"><file name="BadHttpReturnCodeException.php" hash="9377dbcc046ab1465c70caa4ef3a5706"/><file name="HttpException.php" hash="e525b48fb4f7be4dac59058e64947319"/><file name="HttpTimeoutException.php" hash="4835db459423c36607cabfc0b63245ad"/><file name="XmlOverHttp.php" hash="8f1f26f8a39a2a87fc00f1e1b4e23413"/></dir><file name="Cron.php" hash="ccf8a1dd23a035caaf40bc4e98f059ac"/><dir name="Entity"><dir name="Attribute"><dir name="Frontend"><file name="LabelTranslation.php" hash="e46ff6aca592cbb643a64ecfe1042422"/></dir><dir name="Source"><file name="Carrier.php" hash="65770c58617deb2dce75d8e83e055d79"/><file name="MeinPaketCategory.php" hash="17f784c2d79bfd847dd6472dca661334"/><file name="ProductAttribute.php" hash="aba17fe2a9acb85d0483926c3d5ba9a8"/><file name="ProductSyncMode.php" hash="39db6c156e9100ab59384756ec9ac2c5"/><file name="Taxclass.php" hash="e54c0dcb118a1308d572a8c0e53b5853"/><file name="Taxrate.php" hash="a45e4f6a4bf33eb5b39a0cdc4d847868"/></dir></dir></dir><dir name="Exception"><file name="InvalidDataException.php" hash="e1b7bf3f0a4d3743ee42cbf4ce379ddb"/><file name="MissingDataException.php" hash="351f85425c276f434551caf3eafdc7db"/></dir><file name="Log.php" hash="5b2bb2ee0b779db8ddf8c90855012d13"/><dir name="Mysql4"><dir name="Async"><file name="Collection.php" hash="a6583bdf6b8276a95af5b81f5ff2dd8e"/></dir><file name="Async.php" hash="7182fca1fbb6bcf9ada0f9c53c2fc45c"/><dir name="Backlog"><dir name="Product"><file name="Collection.php" hash="2711f602d90e22ea72b773003cf38ef4"/></dir><file name="Product.php" hash="d46057bf2e8b93b32b23653222599316"/></dir><dir name="BestPrice"><file name="Collection.php" hash="fedcad4595269a646ff1c452bed87b00"/></dir><file name="BestPrice.php" hash="79399000e407b6a22489d0dbfedd6f34"/><dir name="Category"><file name="Collection.php" hash="d68d50e74632b2c664d3013dc936470a"/></dir><file name="Category.php" hash="e240b146ddfafa4aed1922f5f51dc877"/><dir name="Log"><file name="Collection.php" hash="7d42d5b7a3075b823a88b6e74c473e35"/></dir><file name="Log.php" hash="7d153ffb060adf03d92c178c40cf269f"/></dir><file name="Observer.php" hash="da29297864f61edc4a354e1f92b703b5"/><dir name="Payment"><dir name="Method"><file name="Meinpaket.php" hash="4d20cbcb9a017abcd068fc9099827525"/></dir></dir><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="b56c5cdf5ff7b19d7454c1c91d8eacdb"/></dir></dir></dir><dir name="Service"><file name="Abstract.php" hash="4776e034ff665b32dee0d74e3f0a25f5"/><file name="Async.php" hash="875339ec7c1161981dc880ae7b4fe79c"/><dir name="MarketplaceCategoryImport"><file name="ImportService.php" hash="db3f8cd8257b0376caa58bfdc34d35c6"/><file name="Result.php" hash="b2124bf2744a2c899cf4dd57b135937f"/></dir><dir name="Order"><dir name="CancellationService"><file name="Result.php" hash="13336bcccbd384487a7b36fb731825b2"/></dir><file name="CancellationService.php" hash="083d6cef1b1ba32f714ca1603575cba8"/><file name="ImportService.php" hash="b05477219c7ef58b133aeab1e706c74f"/><dir name="RefundExportService"><file name="Result.php" hash="799ca2f107c97fad3c9b1ff9e3c89c30"/></dir><file name="RefundExportService.php" hash="6d9039f6bac8c8b6237118082e0b88c5"/><dir name="ShipmentExportService"><file name="Result.php" hash="c11445ba185f598c338a55515c67b07b"/></dir><file name="ShipmentExportService.php" hash="017ec3ccd4776d7a09005f4ead97bb6c"/></dir><dir name="Product"><dir name="Export"><dir name="Exception"><file name="InvalidEan.php" hash="1a2a297dff79e2b563c135b5b5999ca9"/></dir></dir><file name="Export.php" hash="18dd5ba4201e28365171bd079e4728b9"/></dir><dir name="ProductData"><file name="RequestService.php" hash="c126a7ec932871340cf93b25bfab2912"/></dir><dir name="Result"><file name="Abstract.php" hash="5f828d781f44b20ff5db9abef0a2c9f8"/><file name="Upload.php" hash="aab1a35b3bdb3d1a02ae9f92250f8c90"/></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Attributes.php" hash="e6cd11540ebf6bc87f4d949d81285703"/></dir></dir><file name="MemoryLimiter.php" hash="522bdd80d5e76e7c6fe7ae21a1c36436"/></dir><dir name="Validation"><file name="ValidationInterface.php" hash="ad30a76f3bf48ea8024ed0aa4d914608"/><dir name="Validator"><file name="CDATAContent.php" hash="5b87759291e6212352789cab04683c97"/><file name="Ean.php" hash="1bf0b2816803b34967064996b8cabd5c"/><file name="IntGreaterZero.php" hash="cba7eb6b0e55fbb95adb0adb170314f1"/><file name="NonEmptyString.php" hash="84d6f55c1cb4a7204ca0f9554dcb9444"/><file name="StringMaxLength.php" hash="f385739383b78a635d7aea934a56efe6"/><file name="Url.php" hash="77e55a2b1a49c16fb66a74e47314afad"/></dir><file name="ValidatorChain.php" hash="9abf53fa93ceb7580eee33dc0390048f"/><file name="ValidatorFactory.php" hash="efd64d609fbad93b33649973902c0a03"/><file name="ValidatorInterface.php" hash="952fd149292edfca02202dc05a5b9eca"/></dir><dir name="Xml"><file name="AbstractXmlPartial.php" hash="e1e70183337419918108ce0ce271da0e"/><file name="AbstractXmlRequest.php" hash="bcd0e4b3c1f0c5b772c3e9a30bc83191"/><file name="InvalidXmlException.php" hash="0ef6e07ea095b14f48f41cd2398e011c"/><dir name="Request"><file name="AsynchronousStatusRequest.php" hash="fd2a31247b41e490293c1cf23fdd0d55"/><file name="DataRequest.php" hash="2e4060aff376b619f6a1adce526dcf19"/><file name="DownloadRequest.php" hash="00c6d26edbe92e16b1a16f958a6ae45d"/><file name="NotificationRequest.php" hash="fa9d0839e6bd608bcc0b0fe957517e91"/><file name="QueryRequest.php" hash="a67a0d8ba1aafa76e14b1218f38066b2"/><file name="SubmitCartRequest.php" hash="0ec103744d136310e4ab8ec2ba7c65ee"/><file name="UploadRequest.php" hash="6430f4a3c3980826e8b8a0496a19c2b6"/></dir><dir name="Response"><file name="Abstract.php" hash="1645ed875ccd91dc6c7dc72aa0dbc7ef"/><file name="AsynchronousStatusResponse.php" hash="db49a17b1e9553626394a9d45841e3a0"/><file name="DataResponse.php" hash="2b7a4fb49939925e55c2f5d6a1a2bc09"/><file name="DownloadResponse.php" hash="48f724a3ccb54be8e360c49286d9c60f"/><file name="NotificationResponse.php" hash="b36f19e5eb85bcb182ca4ee1b3d2688d"/><dir name="Partial"><file name="Address.php" hash="acf4e17a370cdea81258b738d325988b"/><file name="Attribute.php" hash="6ea2780f911a9693044d24712fe75087"/><file name="Category.php" hash="02d29f2659be87cda96e10e1a125f4c6"/><file name="CategoryId.php" hash="d5218f01be4974e21782b3866a1dcdfb"/><dir name="DataResponse"><file name="BestPrice.php" hash="22d91bab5e172b2a388560af7bd24799"/><file name="Confirmation.php" hash="f984cf7c306f645f9a5900fb09be7fa4"/><file name="MerchantData.php" hash="104595efc0d99aaa78f13700526d8ef6"/><file name="ProductData.php" hash="ecd56a23225216a26688e37df13844e1"/><file name="QuotaData.php" hash="b902885c85421d5295c8c85da73958bb"/></dir><dir name="NotificationResponse"><file name="Confirmation.php" hash="288f9fa00b63d24934d473a9fddf0441"/><file name="Consignment.php" hash="2beda1a5785fc957edd3bdbf76181e8a"/><file name="Credit.php" hash="3d9541e0ce1a3afd5c8409b092929a8b"/><file name="Return.php" hash="6e3e83db65ac3d79d36996418e8eebb6"/></dir><dir name="Order"><file name="ContactData.php" hash="4669122c22318099d01c90423a48115b"/><file name="Entry.php" hash="e4a1ccc9b49a6312668bf05d450e2723"/></dir><file name="Order.php" hash="53c032abb427608fc729a2e9796df94c"/><file name="ProductId.php" hash="014f284435b3ea6469f2b0f445ee5495"/><file name="VariantConfiguration.php" hash="5686dac51ea5553336d6bfd983c05265"/></dir><file name="QueryResponse.php" hash="33b4e739ee7992602c345e8a0eb12255"/><file name="UploadResponse.php" hash="cb3c1aa7d8e1ef39596c2c0b99d716cb"/></dir><file name="XmlBuildException.php" hash="ece8e4ad0e6f139768cd2b42bfd81c88"/><file name="XmlRequestFactory.php" hash="a76bf5473ab681166bf3933d7780b83b"/><file name="XmlResponseParser.php" hash="1835f430af6dddd176f7ab429195e70c"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="AsyncController.php" hash="01c2d45ca561e8c73e0589da11bb1104"/><dir name="Backlog"><file name="ProductController.php" hash="bb1f8850442ff1950549b21a2dcf74c5"/></dir><file name="BestPriceController.php" hash="a0eafd1b7ec08351bf3c02bbf66509c6"/><file name="CategoryImportController.php" hash="979b3ec551dd2f337f5d0ee5ec4db86b"/><file name="LogController.php" hash="05bfc6f1d349f4545309040d5a0f34d6"/><file name="MatchingController.php" hash="f568a8a7d331264944d1586aa567e6ee"/><file name="OrderImportController.php" hash="5ccdb9bd5a81fda7bba4d9652d76e8ed"/><file name="ProductExportController.php" hash="43f09694db508d52a3065eb305fd23e0"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="cf0fe5f6628cd3e19f5202fbda61138e"/><file name="config.xml" hash="20255883385916a1609e0c617cba5f61"/><file name="system.xml" hash="2d3d0f7bf87975c7090c6bd018b862c6"/></dir><dir name="sql"><dir name="meinpaket_setup"><file name="mysql4-install-1.0.0.php" hash="cf38e941731f2ccff85616aad45da252"/><file name="mysql4-upgrade-1.0.0-1.1.0.php" hash="98bf889d49c11c90ab53242be6fadc0d"/><file name="mysql4-upgrade-1.1.0-2.0.0.php" hash="ff60a264f8dc415dba8cee70832df69b"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Dhl_MeinPaket.xml" hash="cc761a0416eaf0808b4ed169e48da755"/></dir></dir></target><target name="mage"><dir><dir name="shell"><file name="dhlmeinpaket-category-import.php" hash="e1f1154494d78b9abba765e6fbea32a4"/><file name="dhlmeinpaket-order-import.php" hash="bc77461787366c328308cb2bf54778a1"/><file name="dhlmeinpaket-product-export.php" hash="c2d93a0d578d9f09deb0d44f7f3cd535"/><file name="dhlmeinpaket-request-bestprice.php" hash="5b7ff1e8762d1cf6146f1487ea8fe6f4"/></dir></dir></target><target name="magedesign"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="meinpaket.xml" hash="3854556688b7e27a8e7eda0cdf2b6610"/></dir><dir name="template"><dir name="dhl"><dir name="meinpaket"><dir name="checkout"><file name="abort.phtml" hash="b5c16625c1e2dcadf215ebe151dc81a2"/><file name="cartbutton.phtml" hash="a010510f79971d3317cd85e97ce8cc50"/><file name="error.phtml" hash="c831e14959f51118bd71fc25ca88ac53"/><file name="sidebarbutton.phtml" hash="a34f589280b8811163e5b1d1a96c03a4"/><file name="success.phtml" hash="c831e14959f51118bd71fc25ca88ac53"/></dir></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="meinpaket.xml" hash="5b2c84737d953d5456efbd58b6f618fc"/></dir><dir name="template"><dir name="meinpaket"><dir><dir name="Attributemapping"><dir name="edit"><file name="attributes.phtml" hash="ba984f55c900ff0134236b8b89b9a2d1"/><file name="mapping.phtml" hash="7fd78e80c370cc8452b3e056949a4346"/><file name="valuemapping.phtml" hash="2f46ca0709dd318e1363b24689d4e9c4"/></dir><file name="edit.phtml" hash="d35789adf1fd828ac04cf26258d06fb0"/><file name="editform.phtml" hash="e689674c059bef3d5011e8b63b5d51f2"/><file name="index.phtml" hash="ac7f238e2ab37816647f11808c8a2fa4"/></dir><dir name="CategoryImport"><file name="import.phtml" hash="b5c85d896808a7595b530661c19a38fd"/><file name="index.phtml" hash="d315bbae053b89300c8b04a1adb661cb"/></dir><dir name="OrderImport"><file name="import.phtml" hash="edc25fa4eb5fdcc2b3e49cfee18590c1"/><file name="index.phtml" hash="f6bc797fc058db8199f03f7c2733cb57"/></dir><dir name="ProductExport"><file name="empty.phtml" hash="2b62d4c5dcd9d6784a7ba55aa99cfa0e"/><file name="export.phtml" hash="698442f3c05acaab870331b0177c3e16"/><file name="index.phtml" hash="0cb13ff868cba8f23aeb7bf51b7f8733"/><file name="list.phtml" hash="df123aeda1752fd313b6c4024f5ec0b2"/></dir><dir name="catalog"><dir name="product"><dir name="matching"><file name="result.phtml" hash="fcc1b10a90944f5657e7c39bda175d44"/><file name="tab.phtml" hash="bfa9945e79b7ebbf841b95ef99c1fc5d"/></dir></dir></dir><dir name="category"><dir name="import"><file name="import.phtml" hash="b5c85d896808a7595b530661c19a38fd"/><file name="index.phtml" hash="d315bbae053b89300c8b04a1adb661cb"/></dir></dir><dir name="category_import"><file name="import.phtml" hash="b5c85d896808a7595b530661c19a38fd"/><file name="index.phtml" hash="d315bbae053b89300c8b04a1adb661cb"/></dir></dir><file name="leftmenu.phtml" hash="4afb8d200ed8ceddf2f682c5911c565c"/><file name="productexport.phtml" hash="1c7ec782dcd405fd6a5a360f23bf0913"/><file name="steps.phtml" hash="8fcd5c06f70a00c18e325cf9b94693e6"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir><dir><dir name="de_DE"><file name="Dhl_MeinPaket.csv" hash="9d562e495b66d92a1a6f3600a72b23e5"/></dir></dir></dir></target><target name="mageskin"><dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="meinpaket"><dir name="images"><file name="dhl_checkout_button.png" hash="cd33e91292c35a7056736813c43afe90"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="meinpaket"><file name="attributemapping.js" hash="1a4bde24fd6e7347372a3cd77de4389c"/><file name="common.css" hash="90ee229c9b60ea9450b05cec7769bd8b"/><file name="common.js" hash="68b329da9893e34099c7d8ad5cb9c940"/><dir name="images"><file name="1.png" hash="42488db618cc9b25226dc43fe8f24eec"/><file name="2.png" hash="0ca63d439b4a0e6f1578c155ed893fe7"/><file name="3.png" hash="813d4d0fd2051695785ac976b751143c"/><file name="Thumbs.db" hash="a40a4912cd54321346eb8113cd658277"/><file name="dhl_logo_kl.gif" hash="a8ca13c020d033cc487e7c5e7b30807d"/><file name="loader.gif" hash="466e0414bdf21d89645d169669b827ce"/><file name="meinpaket_logo.png" hash="0f7c7ac45b8606ea076dc1d06ea5e057"/><file name="shadowtopbg.png" hash="d8b88f456ebc93a6d11658f5ab14d590"/></dir><file name="module.css" hash="c0ad44ad9719ae396f9becbd183f5033"/><file name="module.js" hash="0ace146549dd0befdd83d23a3149f140"/></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
shell/dhlmeinpaket-category-import.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'abstract.php';
3
+
4
+ /**
5
+ * Imports the category structure from MeinPaket.
6
+ *
7
+ * @category Dhl
8
+ * @package Dhl_MeinPaket
9
+ * @subpackage Dhl_MeinPaket_Shell
10
+ * @version $Id$
11
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
12
+ */
13
+ class Dhl_MeinPaket_Shell_CategoryImport extends Mage_Shell_Abstract {
14
+ /**
15
+ * Imports the marketplace category structure from DHL MeinPaket.
16
+ *
17
+ * @return Dhl_MeinPaket_Shell_CategoryImport
18
+ */
19
+ public function run() {
20
+ /* @var $result Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result */
21
+ $result = null;
22
+
23
+ echo "Starting Category Import (" . $this->getFormattedDate () . ")\n";
24
+
25
+ try {
26
+ /* @var $service Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_ImportService */
27
+ $service = Mage::getModel ( 'meinpaket/Service_MarketplaceCategoryImport_ImportService' );
28
+
29
+ $result = $service->importMarketplaceCategoryStructure ();
30
+ } catch ( Exception $e ) {
31
+ echo 'Category Import failed. Exception occured: ' . $e->getMessage ();
32
+ Mage::logException ( $e );
33
+ return $this;
34
+ }
35
+
36
+ echo "Finished Category Import (" . $this->getFormattedDate () . ")\n";
37
+
38
+ echo "Number of new categories: " . $result->getNewCategoriesCount() . "\n";
39
+ echo "Number of updated categories: " . $result->getUpdatedCategoriesCount() . "\n";
40
+ echo "Number of deleted categories: " . $result->getDeletedCategoriesCount() . "\n";
41
+
42
+ return $this;
43
+ }
44
+
45
+ /**
46
+ * Retrieve Usage Help Message
47
+ */
48
+ public function usageHelp() {
49
+ return <<<USAGE
50
+ Usage: php -f dhlmeinpaket-order-import.php -- [options]
51
+
52
+ help This help
53
+ \n
54
+ USAGE;
55
+ }
56
+
57
+ /**
58
+ * Returns the current timestamp as a formatted string.
59
+ *
60
+ * @return string
61
+ */
62
+ protected function getFormattedDate() {
63
+ return strftime ( "%Y-%m-%d %H:%M:%S" );
64
+ }
65
+ }
66
+
67
+ $categoryImporter = new Dhl_MeinPaket_Shell_CategoryImport ();
68
+ $categoryImporter->run ();
shell/dhlmeinpaket-order-import.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'abstract.php';
3
+
4
+ /**
5
+ * Imports the category structure from MeinPaket.
6
+ *
7
+ * @category Dhl
8
+ * @package Dhl_MeinPaket
9
+ * @subpackage Dhl_MeinPaket_Shell
10
+ * @version $Id$
11
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
12
+ */
13
+ class Dhl_MeinPaket_Shell_OrderImport extends Mage_Shell_Abstract {
14
+ /**
15
+ *
16
+ * @var integer
17
+ */
18
+ const DEFAULT_HOURS = 24;
19
+
20
+ /**
21
+ * Imports orders from DHL MeinPaket.
22
+ *
23
+ * @return Dhl_MeinPaket_Shell_OrderImport
24
+ */
25
+ public function run() {
26
+ echo "Starting order import (" . $this->getFormattedDate () . ")\n";
27
+
28
+ /* @var $service Dhl_MeinPaket_Model_Service_Order_ImportService */
29
+ $service = Mage::getModel ( "meinpaket/service_order_importService" );
30
+ $hours = self::DEFAULT_HOURS;
31
+ $startTime = 0;
32
+ $endTime = 0;
33
+
34
+ if ($this->getArg ( 'hours' )) {
35
+ $passedHours = ( integer ) $this->getArg ( 'hours' );
36
+ if ($passedHours < 1) {
37
+ echo 'Number of given hours (' . $passedHours . ') is to small. Process cancelled.';
38
+ return $this;
39
+ }
40
+ $hours = $passedHours;
41
+ }
42
+
43
+ $endTime = mktime ();
44
+ $startTime = $endTime - ($hours * 3600);
45
+
46
+ echo "Time range: " . $this->getFormattedDate ( $startTime ) . " GMT - " . $this->getFormattedDate ( $endTime ) . " GMT\n";
47
+
48
+ try {
49
+ $service->importOrders ( $startTime, $endTime );
50
+ } catch ( Exception $e ) {
51
+ Mage::logException ( $e );
52
+ echo 'Order import failed. Exception occured: ' . $e->getMessage ();
53
+ }
54
+
55
+ echo "Import finished (" . $this->getFormattedDate () . ")\n";
56
+ echo "Imported " . sizeof ( $service->getOrderCount () ) . " orders.\n";
57
+
58
+ return $this;
59
+ }
60
+
61
+ /**
62
+ * Retrieve Usage Help Message
63
+ */
64
+ public function usageHelp() {
65
+ return <<<USAGE
66
+ Usage: php -f dhlmeinpaket-order-import.php -- [options]
67
+
68
+ --hours The time in hours for which to import orders.
69
+ The default setting is 24, which means that the orders of the
70
+ last 24 hours will be imported.
71
+ help This help
72
+ \n
73
+ USAGE;
74
+ }
75
+
76
+ /**
77
+ * Returns the current timestamp as a formatted string.
78
+ *
79
+ * @return string
80
+ */
81
+ protected function getFormattedDate($timestamp = null) {
82
+ $format = "%Y-%m-%d %H:%M:%S";
83
+ $date = '';
84
+
85
+ if ($timestamp !== null) {
86
+ $date = strftime ( $format, $timestamp );
87
+ } else {
88
+ $date = strftime ( $format );
89
+ }
90
+
91
+ return $date;
92
+ }
93
+ }
94
+
95
+ $orderImporter = new Dhl_MeinPaket_Shell_OrderImport ();
96
+ $orderImporter->run ();
shell/dhlmeinpaket-product-export.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'abstract.php';
3
+
4
+ /**
5
+ * Exports products to MeinPaket.
6
+ *
7
+ * @category Dhl
8
+ * @package Dhl_MeinPaket
9
+ * @subpackage Dhl_MeinPaket_Shell
10
+ * @version $Id$
11
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
12
+ */
13
+ class Dhl_MeinPaket_Shell_ProductExport extends Mage_Shell_Abstract {
14
+ /**
15
+ * Exports products DHL MeinPaket.
16
+ *
17
+ * @return Dhl_MeinPaket_Shell_ProductExport
18
+ */
19
+ public function run() {
20
+ echo " > Starting Export (" . $this->getFormattedDate () . ")\n";
21
+
22
+ /* @var $exportService Dhl_MeinPaket_Model_Service_Product_Export */
23
+ $exportService = Mage::getModel ( 'meinpaket/service_product_export' );
24
+
25
+ $result = null;
26
+
27
+ $commonErrors = null;
28
+
29
+ // export products
30
+ try {
31
+ $result = $exportService->exportProducts ();
32
+ } catch ( Exception $e ) {
33
+ Mage::logException ( $e );
34
+ echo 'Products could not be exported: ' . $e->getMessage ();
35
+ return $this;
36
+ }
37
+
38
+ //$this->showResults ( $result );
39
+
40
+ return $this;
41
+ }
42
+
43
+ /**
44
+ * Retrieve Usage Help Message
45
+ */
46
+ public function usageHelp() {
47
+ return <<<USAGE
48
+ Usage: php -f dhlmeinpaket-product-export.php -- [options]
49
+
50
+ all Exports all products. No matter if they have their synchronize with DHL MeinPaket flag enabled.
51
+ help This help
52
+ \n
53
+ USAGE;
54
+ }
55
+
56
+ /**
57
+ * Echoes information about the result of the product export process.
58
+ *
59
+ * @param Dhl_MeinPaket_Model_Service_Product_Export_Result $result
60
+ * @return void
61
+ */
62
+ protected function showResults(Dhl_MeinPaket_Model_Service_Product_Export_Result $result) {
63
+ $commonErrors = $result->getCommonErrors ();
64
+ $fullyConfirmedIds = $result->getFullyConfirmedProductIds ();
65
+ $offeredOnly = $result->getProductsWhichCouldOnlyBeOffered ();
66
+ $totallyFailed = $result->getProductsWhichCouldNotBeOfferedOrDescribed ();
67
+
68
+ echo " > Finished Export (" . $this->getFormattedDate () . ")\n";
69
+ echo "----------------------------------------------------------\n";
70
+ echo "| RESULT OVERVIEW: |\n";
71
+ echo "----------------------------------------------------------\n";
72
+ echo " > Successfully exported: " . sizeof ( $fullyConfirmedIds ) . "\n";
73
+ echo " > Offered only: " . sizeof ( $offeredOnly ) . "\n";
74
+ echo " > Not exportable: " . sizeof ( $totallyFailed ) . "\n";
75
+ }
76
+
77
+ /**
78
+ * Returns the current timestamp as a formatted string.
79
+ *
80
+ * @return string
81
+ */
82
+ protected function getFormattedDate() {
83
+ return strftime ( "%Y-%m-%d %H:%M:%S" );
84
+ }
85
+ }
86
+
87
+ $productExporter = new Dhl_MeinPaket_Shell_ProductExport ();
88
+ $productExporter->run ();
89
+
shell/dhlmeinpaket-request-bestprice.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'abstract.php';
3
+
4
+ /**
5
+ * Imports the variant configurations from MeinPaket.
6
+ *
7
+ * @category Dhl
8
+ * @package Dhl_MeinPaket
9
+ * @subpackage Dhl_MeinPaket_Shell
10
+ * @version $Id$
11
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
12
+ */
13
+ class Dhl_MeinPaket_Shell_RequestBestPrice extends Mage_Shell_Abstract {
14
+ /**
15
+ * Imports the variant configurations from DHL MeinPaket.
16
+ *
17
+ * @return Dhl_MeinPaket_Shell_VariantConfigurationsDownload
18
+ */
19
+ public function run() {
20
+ /* @var $service Dhl_MeinPaket_Model_Service_ProductData_RequestService */
21
+ $service = Mage::getModel ( 'meinpaket/service_productData_requestService' );
22
+
23
+ /* @var $result Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result */
24
+ $result = null;
25
+
26
+ echo "Requesting \n";
27
+
28
+ try {
29
+ $result = $service->requestBestPrices ();
30
+ } catch ( Exception $e ) {
31
+ echo 'Request failed. Exception occured: "' . $e->getMessage () . '"' . "\n";
32
+ Mage::logException ( $e );
33
+ return $this;
34
+ }
35
+
36
+ return $this;
37
+ }
38
+
39
+ /**
40
+ * Retrieve Usage Help Message
41
+ */
42
+ public function usageHelp() {
43
+ return <<<USAGE
44
+ Usage: php -f dhlmeinpaket-request-bestprice.php -- [options]
45
+
46
+ help This help
47
+ \n
48
+ USAGE;
49
+ }
50
+ }
51
+
52
+ $shll = new Dhl_MeinPaket_Shell_RequestBestPrice ();
53
+ $shll->run ();
54
+
skin/adminhtml/default/default/meinpaket/attributemapping.js ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * JavaScript attribute mapping helpers.
3
+ *
4
+ * @category skin
5
+ * @package Dhl_MeinPaket
6
+ * @author Timo Fuchs <timo.fuchs@aoemedia.de>
7
+ */
8
+
9
+ // setup namespace object
10
+ if (typeof MeinPaket === 'undefined') {
11
+ var MeinPaket = {};
12
+ }
13
+
14
+ /**
15
+ * Attribute helper class.
16
+ */
17
+ MeinPaket.Attribute = Class.create();
18
+ MeinPaket.Attribute.prototype = {
19
+
20
+ /**
21
+ * Number of attribute mappings.
22
+ *
23
+ * @var integer
24
+ */
25
+ numItems : 0,
26
+
27
+ /**
28
+ * Prefix.
29
+ *
30
+ * @var string
31
+ */
32
+ attributeMappingIndexPrefix : 'meinpaket_attribute_mapping_',
33
+
34
+ /**
35
+ * Constructor.
36
+ *
37
+ * @return void
38
+ */
39
+ initialize : function() {
40
+ },
41
+
42
+ /**
43
+ * Adds a attribute mapping interface.
44
+ *
45
+ * @return void
46
+ */
47
+ add : function() {
48
+ var index = this.numItems;
49
+ var tpl = new Template(this.template);
50
+ var data = {
51
+ index : index,
52
+ prefix : this.attributeMappingIndexPrefix,
53
+ magentoAttributesSelect : this.renderMagentoAttributeSelect(
54
+ MeinPaket.magentoAttributes, index),
55
+ meinpaketAttributesSelect : this.renderMeinpaketAttributeSelect(
56
+ MeinPaket.meinpaketAttributes, index),
57
+ labelMagentoAttribute : MeinPaket.locale.magentoAttribute,
58
+ labelMeinPaketAttribute : MeinPaket.locale.meinpaketAttribute,
59
+ labelMagentoValue : MeinPaket.locale.magentoValue,
60
+ labelMeinPaketValue : MeinPaket.locale.meinpaketValue,
61
+ labelEditValueMapping : MeinPaket.locale.editValueMapping,
62
+ labelDeleteValueMapping : MeinPaket.locale.deleteValueMapping
63
+ };
64
+
65
+ this.top = $('meinpaket_attribute_top');
66
+
67
+ Element.insert(this.top, {
68
+ 'after' : tpl.evaluate(data)
69
+ });
70
+ // this.top = $(this.idLabel + '_' + index);
71
+ this.numItems++;
72
+ },
73
+
74
+ deleteAttributeMapping : function(index) {
75
+ $(this.attributeMappingIndexPrefix + index).remove();
76
+ },
77
+
78
+ /**
79
+ * Template html for attribute mappings.
80
+ *
81
+ * @var string
82
+ */
83
+ template : '<div id="#{prefix}#{index}" class="option-box"> '
84
+ + '<table class="option-header" cellpadding="0" cellspacing="0">'
85
+ + '<thead>'
86
+ + '<tr>'
87
+ + '<th class="opt-type">#{labelMagentoAttribute}</th>'
88
+ + '<th class="opt-req">#{labelMeinPaketAttribute}</th>'
89
+ + '<th>&nbsp;</th>'
90
+ + '<th>&nbsp;</th>'
91
+ + '</tr>'
92
+ + '</thead>'
93
+ + '<tbody id="attribute_table_#{index}">'
94
+ + '<tr>'
95
+ +
96
+
97
+ '<td>#{magentoAttributesSelect}</td>'
98
+ + '<td>#{meinpaketAttributesSelect}</td>'
99
+ + '<td>'
100
+ + '<button type="button" value="" class="scalable add" onclick="meinPaketAttribute.editValueMapping(#{index});"><span>#{labelEditValueMapping}</span></button>'
101
+ + '</td>'
102
+ + '<td>'
103
+ + '<button type="button" value="" class="scalable delete" onclick="meinPaketAttribute.deleteAttributeMapping(#{index});"><span>#{labelDeleteValueMapping}</span></button>'
104
+ + '</td>' + '</tr>'
105
+ + '<tr id="values_row_#{index}"><td colspan="4"></td></tr>'
106
+ + '</tbody>' + '</table>'
107
+ + '<div id="values_container_#{index}"></div>' + '</div>',
108
+
109
+ /**
110
+ * Renders an attribute select box.
111
+ *
112
+ * @param Array
113
+ * attributes An Array of objects which have "id" and "name"
114
+ * properties.
115
+ * @param string
116
+ * type Must be "magento" or "meinpaket".
117
+ * @param integer
118
+ * id Index of the current mapping.
119
+ * @return String
120
+ */
121
+ renderAttributeSelect : function(attributes, type, id) {
122
+ var html = '<select id="select_' + type + '_attribute_' + id
123
+ + '" name="' + type + '_attribute_id[' + id + ']">';
124
+ for (var i = 0; i < attributes.length; i++) {
125
+ html += '<option value="' + attributes[i].id + '">'
126
+ + attributes[i].name + '</option>';
127
+ }
128
+ html += '</select>';
129
+ return html;
130
+ },
131
+
132
+ /**
133
+ * Renders a Magento attribute select box.
134
+ *
135
+ * @see MeinPaket.Attribute.renderAttributeSelect()
136
+ * @param Array
137
+ * attributes
138
+ * @param integer
139
+ * id
140
+ * @return String
141
+ */
142
+ renderMagentoAttributeSelect : function(attributes, id) {
143
+ return this.renderAttributeSelect(attributes, 'magento', id);
144
+ },
145
+
146
+ /**
147
+ * Renders a MeinPaket attribute select box.
148
+ *
149
+ * @see MeinPaket.Attribute.renderAttributeSelect()
150
+ * @param Array
151
+ * attributes
152
+ * @param integer
153
+ * id
154
+ * @return String
155
+ */
156
+ renderMeinpaketAttributeSelect : function(attributes, id) {
157
+ return this.renderAttributeSelect(attributes, 'meinpaket', id);
158
+ },
159
+
160
+ /**
161
+ * Creates a mapping table for the attribute mapping with the given id.
162
+ *
163
+ * @param integer
164
+ * index
165
+ * @return void
166
+ */
167
+ editValueMapping : function(index) {
168
+ var container = $(this.attributeMappingIndexPrefix + index);
169
+ var elements = [ $("select_attribute_set"), $("select_variant"),
170
+ $("select_magento_attribute_" + index),
171
+ $("select_meinpaket_attribute_" + index) ].flatten();
172
+ var serializedElements = Form.serializeElements(elements)
173
+ + '&attribute_mapping_id=' + index;
174
+ new Ajax.Updater("attribute_table_" + index,
175
+ MeinPaket.url.editAttributeValues, {
176
+ parameters : serializedElements,
177
+ evalScripts : true,
178
+ insertion : 'bottom',
179
+ onComplete : function() {
180
+ // $("select_magento_attribute_"+index).disabled = true;
181
+ // $("select_meinpaket_attribute_"+index).disabled =
182
+ // true;
183
+ // $(\'save_button\').disabled = false;
184
+ // Event.observe($("select_itemtype"), \'change\',
185
+ // itemType.updateAttributes);
186
+ }
187
+ });
188
+ }
189
+ };
190
+
191
+ // create attribute instance
192
+ var meinPaketAttribute = new MeinPaket.Attribute();
skin/adminhtml/default/default/meinpaket/common.css ADDED
@@ -0,0 +1 @@
 
1
+ @CHARSET "UTF-8";
skin/adminhtml/default/default/meinpaket/common.js ADDED
@@ -0,0 +1 @@
 
1
+
skin/adminhtml/default/default/meinpaket/images/1.png ADDED
Binary file
skin/adminhtml/default/default/meinpaket/images/2.png ADDED
Binary file
skin/adminhtml/default/default/meinpaket/images/3.png ADDED
Binary file
skin/adminhtml/default/default/meinpaket/images/Thumbs.db ADDED
Binary file
skin/adminhtml/default/default/meinpaket/images/dhl_logo_kl.gif ADDED
Binary file
skin/adminhtml/default/default/meinpaket/images/loader.gif ADDED
Binary file
skin/adminhtml/default/default/meinpaket/images/meinpaket_logo.png ADDED
Binary file
skin/adminhtml/default/default/meinpaket/images/shadowtopbg.png ADDED
Binary file
skin/adminhtml/default/default/meinpaket/module.css ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @CHARSET "UTF-8";
2
+
3
+ h3.meinpaket {}
4
+ div#meinpaket-description {background: url('images/meinpaket_logo.png') no-repeat 0px 5px; padding: 5px 150px 20px 240px; min-height: 100px; }
5
+ div#meinpaket-description p {text-align: justify;}
6
+ div#meinpaket-description b {color: #515151;}
7
+ div#meinpaket-description i {color: #646B70;}
8
+ div.meinpaket-content {padding: 10px; background: url('images/shadowtopbg.png') repeat-x #E5E5E5; border: 1px solid #FFCC00}
9
+
10
+ div.meinpaket-content form label {margin-right: 10px; }
11
+
12
+ #disabled-till-export {}
13
+
14
+ ul.meinpaket-steps {margin: 10px 0 0 0; clear: both}
15
+ li.nr1 {background: url('images/1.png') no-repeat 0px 0px }
16
+ li.nr2 {background: url('images/2.png') no-repeat 0px 0px }
17
+ li.nr3 {background: url('images/3.png') no-repeat 0px 0px }
18
+ ul.meinpaket-steps li { background-color: #6A6B6B; width: 32%; display: block; border: 1px solid #595959; float: left; padding: 8px 0px 8px 0px; margin: 5px 1% 15px 0;}
19
+ ul.meinpaket-steps li p {margin: 4px 0 4px 80px; font-weight: bold}
20
+ ul.meinpaket-steps li.active { background-color: #FFCC00; border-style: solid; border-color: #ddbb00;}
21
+
22
+ div.scrollablebox {height: 300px; overflow: auto; /*border: 1px solid #eee; padding: 5px;*/}
23
+
24
+ table#meinpaket-results {}
25
+ th.col-product {min-width: 200px}
26
+ table#meinpaket-results td.row-subheader { background-color: #FFCC00; color: #2F2F2F; font-weight: bold; }
27
+ table#meinpaket-results td.row-subheader span.resultCount { color: #646B70; font-size: 80%; }
28
+ table#meinpaket-results td.row-num { width: 1px; text-align: right !important; }
29
+ table#meinpaket-results th.header-center { text-align: center !important; }
30
+ .cc {clear: both}
31
+
32
+ .meinpaket-waitbox { float: none; display: block; clear: both; padding: 10px; text-align: center; }
33
+ .meinpaket-waitbox small { position: relative; top: -8px; }
34
+
35
+ .columns #edit_form .form-list td.value { width: auto; }
36
+ #edit_form .form-list td.value select { width: 280px; }
37
+
38
+ .section-config.meinpaket > :first-child {
39
+ background-color: #fc0 !important;
40
+ }
41
+
42
+ .section-config.meinpaket > :first-child > a {
43
+ color: #ff0000 !important;
44
+ }
45
+
46
+ .section-config.meinpaket:first-child {
47
+ padding-top: 170px;
48
+ background:url('http://portal.meinpaket.de/fileadmin/media/magento_admin.jpg') no-repeat;
49
+ }
skin/adminhtml/default/default/meinpaket/module.js ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function startProcessing() {
2
+ var form = $('meinpaket_form');
3
+ $('startButton').hide();
4
+ $('disabled-till-export').show();
5
+
6
+ $$('li.nr1').each(function(aElement) {
7
+ aElement.removeClassName('active');
8
+ });
9
+
10
+ $$('li.nr2').each(function(aElement) {
11
+ aElement.addClassName('active');
12
+ });
13
+
14
+ $('meinpaket-description').hide();
15
+ form.submit();
16
+ form.disable();
17
+ form.hide();
18
+
19
+ }
20
+
21
+ function setLocationWithWait(gotourl) {
22
+ setLocation(gotourl);
23
+ $('disabled-till-export').show();
24
+ }
25
+
26
+ function submitForm(actionUrl) {
27
+ var form = $('meinpaket_form');
28
+ form.writeAttribute('action', actionUrl);
29
+ form.submit();
30
+
31
+ }
32
+
33
+ function showResponse(req) {
34
+ alert(req.responseText);
35
+ }
skin/frontend/default/default/meinpaket/images/dhl_checkout_button.png ADDED
Binary file