DHL_Allyouneed - Version 2.2.0

Version Notes

--

Download this release

Release Info

Developer DHL Vertriebs GmbH
Extension DHL_Allyouneed
Version 2.2.0
Comparing to
See all releases


Version 2.2.0

Files changed (221) hide show
  1. app/code/community/Dhl/MeinPaket/Block/Adminhtml/Backlog/Product.php +70 -0
  2. app/code/community/Dhl/MeinPaket/Block/Adminhtml/Backlog/Product/Grid.php +78 -0
  3. app/code/community/Dhl/MeinPaket/Block/Adminhtml/BestPrice.php +22 -0
  4. app/code/community/Dhl/MeinPaket/Block/Adminhtml/BestPrice/Grid.php +88 -0
  5. app/code/community/Dhl/MeinPaket/Block/Adminhtml/Catalog/Product/Matching/Result.php +17 -0
  6. app/code/community/Dhl/MeinPaket/Block/Adminhtml/Catalog/Product/Matching/Tab.php +56 -0
  7. app/code/community/Dhl/MeinPaket/Block/Adminhtml/CategoryImport/Import.php +56 -0
  8. app/code/community/Dhl/MeinPaket/Block/Adminhtml/CategoryImport/Index.php +20 -0
  9. app/code/community/Dhl/MeinPaket/Block/Adminhtml/LeftMenu.php +61 -0
  10. app/code/community/Dhl/MeinPaket/Block/Adminhtml/OrderImport/Index.php +20 -0
  11. app/code/community/Dhl/MeinPaket/Block/Adminhtml/ProductExport/Export.php +72 -0
  12. app/code/community/Dhl/MeinPaket/Block/Adminhtml/ProductExport/Index.php +21 -0
  13. app/code/community/Dhl/MeinPaket/Block/Adminhtml/ProductExport/List.php +32 -0
  14. app/code/community/Dhl/MeinPaket/Block/Adminhtml/Steps.php +64 -0
  15. app/code/community/Dhl/MeinPaket/Block/Adminhtml/Version.php +6 -0
  16. app/code/community/Dhl/MeinPaket/Helper/Attribute.php +25 -0
  17. app/code/community/Dhl/MeinPaket/Helper/Backlog.php +76 -0
  18. app/code/community/Dhl/MeinPaket/Helper/Cron.php +68 -0
  19. app/code/community/Dhl/MeinPaket/Helper/Data.php +90 -0
  20. app/code/community/Dhl/MeinPaket/Helper/Order.php +21 -0
  21. app/code/community/Dhl/MeinPaket/Helper/Product.php +353 -0
  22. app/code/community/Dhl/MeinPaket/Helper/Shipment.php +33 -0
  23. app/code/community/Dhl/MeinPaket/Model/Attribute/Mapping.php +6 -0
  24. app/code/community/Dhl/MeinPaket/Model/Backlog/Product.php +7 -0
  25. app/code/community/Dhl/MeinPaket/Model/BestPrice.php +7 -0
  26. app/code/community/Dhl/MeinPaket/Model/Category.php +19 -0
  27. app/code/community/Dhl/MeinPaket/Model/Cron.php +47 -0
  28. app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Frontend/LabelTranslation.php +21 -0
  29. app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Source/Carrier.php +51 -0
  30. app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Source/MeinPaketCategory.php +88 -0
  31. app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Source/ProductAttribute.php +43 -0
  32. app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Source/ProductSyncMode.php +92 -0
  33. app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Source/Taxclass.php +51 -0
  34. app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Source/Taxrate.php +49 -0
  35. app/code/community/Dhl/MeinPaket/Model/Exception/InvalidDataException.php +72 -0
  36. app/code/community/Dhl/MeinPaket/Model/Exception/MissingDataException.php +25 -0
  37. app/code/community/Dhl/MeinPaket/Model/Mysql4/Backlog/Product.php +11 -0
  38. app/code/community/Dhl/MeinPaket/Model/Mysql4/Backlog/Product/Collection.php +11 -0
  39. app/code/community/Dhl/MeinPaket/Model/Mysql4/BestPrice.php +11 -0
  40. app/code/community/Dhl/MeinPaket/Model/Mysql4/BestPrice/Collection.php +11 -0
  41. app/code/community/Dhl/MeinPaket/Model/Mysql4/Category.php +14 -0
  42. app/code/community/Dhl/MeinPaket/Model/Mysql4/Category/Collection.php +19 -0
  43. app/code/community/Dhl/MeinPaket/Model/Observer.php +164 -0
  44. app/code/community/Dhl/MeinPaket/Model/Payment/Method/Meinpaket.php +29 -0
  45. app/code/community/Dhl/MeinPaket/Model/Resource/Eav/Mysql4/Setup.php +59 -0
  46. app/code/community/Dhl/MeinPaket/Model/Service/MarketplaceCategoryImport/ImportService.php +145 -0
  47. app/code/community/Dhl/MeinPaket/Model/Service/MarketplaceCategoryImport/Result.php +128 -0
  48. app/code/community/Dhl/MeinPaket/Model/Service/Product/Export.php +140 -0
  49. app/code/community/Dhl/MeinPaket/Model/Service/Product/Export/Exception/InvalidEan.php +20 -0
  50. app/code/community/Dhl/MeinPaket/Model/Service/ProductData/RequestService.php +79 -0
  51. app/code/community/Dhl/MeinPaket/Model/Service/Result/Abstract.php +63 -0
  52. app/code/community/Dhl/MeinPaket/Model/Service/Result/Upload.php +13 -0
  53. app/code/community/Dhl/MeinPaket/Model/System/Config/Source/Attributes.php +104 -0
  54. app/code/community/Dhl/MeinPaket/controllers/Adminhtml/Backlog/ProductController.php +85 -0
  55. app/code/community/Dhl/MeinPaket/controllers/Adminhtml/BestPriceController.php +33 -0
  56. app/code/community/Dhl/MeinPaket/controllers/Adminhtml/CategoryImportController.php +91 -0
  57. app/code/community/Dhl/MeinPaket/controllers/Adminhtml/MatchingController.php +52 -0
  58. app/code/community/Dhl/MeinPaket/controllers/Adminhtml/ProductExportController.php +141 -0
  59. app/code/community/Dhl/MeinPaket/etc/adminhtml.xml +53 -0
  60. app/code/community/Dhl/MeinPaket/etc/config.xml +217 -0
  61. app/code/community/Dhl/MeinPaket/etc/system.xml +185 -0
  62. app/code/community/Dhl/MeinPaket/sql/meinpaket_setup/mysql4-install-1.0.0.php +28 -0
  63. app/code/community/Dhl/MeinPaket/sql/meinpaket_setup/mysql4-upgrade-1.0.0-1.1.0.php +9 -0
  64. app/code/community/Dhl/MeinPaket/sql/meinpaket_setup/mysql4-upgrade-1.1.0-2.0.0.php +54 -0
  65. app/code/community/Dhl/MeinPaket/sql/meinpaket_setup/mysql4-upgrade-2.1.0-2.2.0.php +9 -0
  66. app/code/community/Dhl/MeinPaketCommon/Block/Adminhtml/Async.php +30 -0
  67. app/code/community/Dhl/MeinPaketCommon/Block/Adminhtml/Async/Grid.php +65 -0
  68. app/code/community/Dhl/MeinPaketCommon/Block/Adminhtml/Log.php +22 -0
  69. app/code/community/Dhl/MeinPaketCommon/Block/Adminhtml/Log/Grid.php +69 -0
  70. app/code/community/Dhl/MeinPaketCommon/Block/Adminhtml/Version.php +6 -0
  71. app/code/community/Dhl/MeinPaketCommon/Helper/Address.php +51 -0
  72. app/code/community/Dhl/MeinPaketCommon/Helper/Attribute.php +16 -0
  73. app/code/community/Dhl/MeinPaketCommon/Helper/Cron.php +68 -0
  74. app/code/community/Dhl/MeinPaketCommon/Helper/Data.php +128 -0
  75. app/code/community/Dhl/MeinPaketCommon/Helper/Order.php +21 -0
  76. app/code/community/Dhl/MeinPaketCommon/Helper/Product.php +330 -0
  77. app/code/community/Dhl/MeinPaketCommon/Helper/Shipment.php +39 -0
  78. app/code/community/Dhl/MeinPaketCommon/Model/Async.php +7 -0
  79. app/code/community/Dhl/MeinPaketCommon/Model/Carrier/Allyouneed.php +111 -0
  80. app/code/community/Dhl/MeinPaketCommon/Model/Carrier/Meinpaket.php +123 -0
  81. app/code/community/Dhl/MeinPaketCommon/Model/Client/BadHttpReturnCodeException.php +38 -0
  82. app/code/community/Dhl/MeinPaketCommon/Model/Client/HttpException.php +13 -0
  83. app/code/community/Dhl/MeinPaketCommon/Model/Client/HttpTimeoutException.php +13 -0
  84. app/code/community/Dhl/MeinPaketCommon/Model/Client/XmlOverHttp.php +158 -0
  85. app/code/community/Dhl/MeinPaketCommon/Model/Cron.php +71 -0
  86. app/code/community/Dhl/MeinPaketCommon/Model/Entity/Attribute/Source/Carrier.php +51 -0
  87. app/code/community/Dhl/MeinPaketCommon/Model/Exception/InvalidDataException.php +72 -0
  88. app/code/community/Dhl/MeinPaketCommon/Model/Exception/MissingDataException.php +25 -0
  89. app/code/community/Dhl/MeinPaketCommon/Model/Log.php +21 -0
  90. app/code/community/Dhl/MeinPaketCommon/Model/Mysql4/Async.php +11 -0
  91. app/code/community/Dhl/MeinPaketCommon/Model/Mysql4/Async/Collection.php +11 -0
  92. app/code/community/Dhl/MeinPaketCommon/Model/Mysql4/Log.php +11 -0
  93. app/code/community/Dhl/MeinPaketCommon/Model/Mysql4/Log/Collection.php +11 -0
  94. app/code/community/Dhl/MeinPaketCommon/Model/Observer.php +536 -0
  95. app/code/community/Dhl/MeinPaketCommon/Model/Payment/Method/Allyouneed.php +29 -0
  96. app/code/community/Dhl/MeinPaketCommon/Model/Payment/Method/Meinpaket.php +29 -0
  97. app/code/community/Dhl/MeinPaketCommon/Model/Resource/Eav/Mysql4/Setup.php +53 -0
  98. app/code/community/Dhl/MeinPaketCommon/Model/Service/Abstract.php +110 -0
  99. app/code/community/Dhl/MeinPaketCommon/Model/Service/Async.php +55 -0
  100. app/code/community/Dhl/MeinPaketCommon/Model/Service/Order/CancellationService.php +85 -0
  101. app/code/community/Dhl/MeinPaketCommon/Model/Service/Order/CancellationService/Result.php +93 -0
  102. app/code/community/Dhl/MeinPaketCommon/Model/Service/Order/ImportService.php +494 -0
  103. app/code/community/Dhl/MeinPaketCommon/Model/Service/Order/RefundExportService.php +50 -0
  104. app/code/community/Dhl/MeinPaketCommon/Model/Service/Order/RefundExportService/Result.php +57 -0
  105. app/code/community/Dhl/MeinPaketCommon/Model/Service/Order/ShipmentExportService.php +65 -0
  106. app/code/community/Dhl/MeinPaketCommon/Model/Service/Order/ShipmentExportService/Result.php +56 -0
  107. app/code/community/Dhl/MeinPaketCommon/Model/Service/Result/Abstract.php +63 -0
  108. app/code/community/Dhl/MeinPaketCommon/Model/Service/Result/Upload.php +13 -0
  109. app/code/community/Dhl/MeinPaketCommon/Model/System/MemoryLimiter.php +73 -0
  110. app/code/community/Dhl/MeinPaketCommon/Model/Validation/ValidationInterface.php +27 -0
  111. app/code/community/Dhl/MeinPaketCommon/Model/Validation/Validator/CDATAContent.php +21 -0
  112. app/code/community/Dhl/MeinPaketCommon/Model/Validation/Validator/Ean.php +58 -0
  113. app/code/community/Dhl/MeinPaketCommon/Model/Validation/Validator/IntGreaterZero.php +21 -0
  114. app/code/community/Dhl/MeinPaketCommon/Model/Validation/Validator/NonEmptyString.php +22 -0
  115. app/code/community/Dhl/MeinPaketCommon/Model/Validation/Validator/StringMaxLength.php +57 -0
  116. app/code/community/Dhl/MeinPaketCommon/Model/Validation/Validator/Url.php +21 -0
  117. app/code/community/Dhl/MeinPaketCommon/Model/Validation/ValidatorChain.php +47 -0
  118. app/code/community/Dhl/MeinPaketCommon/Model/Validation/ValidatorInterface.php +20 -0
  119. app/code/community/Dhl/MeinPaketCommon/Model/Xml/AbstractXmlPartial.php +184 -0
  120. app/code/community/Dhl/MeinPaketCommon/Model/Xml/AbstractXmlRequest.php +111 -0
  121. app/code/community/Dhl/MeinPaketCommon/Model/Xml/InvalidXmlException.php +12 -0
  122. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Request/AsynchronousStatusRequest.php +61 -0
  123. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Request/DataRequest.php +108 -0
  124. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Request/DownloadRequest.php +47 -0
  125. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Request/NotificationRequest.php +253 -0
  126. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Request/QueryRequest.php +142 -0
  127. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Request/SubmitCartRequest.php +173 -0
  128. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Request/UploadRequest.php +443 -0
  129. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Abstract.php +150 -0
  130. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/AsynchronousStatusResponse.php +64 -0
  131. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/DataResponse.php +116 -0
  132. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/DownloadResponse.php +46 -0
  133. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/NotificationResponse.php +30 -0
  134. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/Address.php +154 -0
  135. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/Attribute.php +35 -0
  136. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/Category.php +46 -0
  137. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/CategoryId.php +20 -0
  138. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/DataResponse/BestPrice.php +83 -0
  139. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/DataResponse/Confirmation.php +32 -0
  140. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/DataResponse/MerchantData.php +32 -0
  141. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/DataResponse/ProductData.php +62 -0
  142. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/DataResponse/QuotaData.php +30 -0
  143. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/NotificationResponse/Confirmation.php +55 -0
  144. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/NotificationResponse/Consignment.php +37 -0
  145. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/NotificationResponse/Credit.php +36 -0
  146. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/NotificationResponse/Return.php +36 -0
  147. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/Order.php +116 -0
  148. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/Order/ContactData.php +28 -0
  149. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/Order/Entry.php +73 -0
  150. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/ProductId.php +55 -0
  151. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/VariantConfiguration.php +88 -0
  152. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/QueryResponse.php +98 -0
  153. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/SubmitCartResponse.php +26 -0
  154. app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/UploadResponse.php +92 -0
  155. app/code/community/Dhl/MeinPaketCommon/Model/Xml/XmlBuildException.php +13 -0
  156. app/code/community/Dhl/MeinPaketCommon/Model/Xml/XmlResponseParser.php +58 -0
  157. app/code/community/Dhl/MeinPaketCommon/controllers/Adminhtml/AsyncController.php +89 -0
  158. app/code/community/Dhl/MeinPaketCommon/controllers/Adminhtml/LogController.php +70 -0
  159. app/code/community/Dhl/MeinPaketCommon/controllers/Adminhtml/OrderImportController.php +128 -0
  160. app/code/community/Dhl/MeinPaketCommon/etc/adminhtml.xml +40 -0
  161. app/code/community/Dhl/MeinPaketCommon/etc/config.xml +240 -0
  162. app/code/community/Dhl/MeinPaketCommon/etc/system.xml +258 -0
  163. app/code/community/Dhl/MeinPaketCommon/sql/meinpaketcommon_setup/mysql4-install-1.0.0.php +108 -0
  164. app/code/community/Dhl/MeinPaketCommon/sql/meinpaketcommon_setup/mysql4-upgrade-1.0.0-1.1.0.php +9 -0
  165. app/code/community/Dhl/Postpay/Block/Adminhtml/Version.php +6 -0
  166. app/code/community/Dhl/Postpay/Block/Checkout.php +76 -0
  167. app/code/community/Dhl/Postpay/Block/Payment/Form/Standard.php +15 -0
  168. app/code/community/Dhl/Postpay/Block/Payment/Info/Standard.php +6 -0
  169. app/code/community/Dhl/Postpay/Helper/Cron.php +68 -0
  170. app/code/community/Dhl/Postpay/Helper/Data.php +27 -0
  171. app/code/community/Dhl/Postpay/Model/Cart.php +50 -0
  172. app/code/community/Dhl/Postpay/Model/Cron.php +29 -0
  173. app/code/community/Dhl/Postpay/Model/Mysql4/Cart.php +11 -0
  174. app/code/community/Dhl/Postpay/Model/Mysql4/Cart/Collection.php +11 -0
  175. app/code/community/Dhl/Postpay/Model/Observer.php +12 -0
  176. app/code/community/Dhl/Postpay/Model/Payment/Method/Express.php +73 -0
  177. app/code/community/Dhl/Postpay/Model/Payment/Method/Standard.php +165 -0
  178. app/code/community/Dhl/Postpay/Model/Resource/Eav/Mysql4/Setup.php +11 -0
  179. app/code/community/Dhl/Postpay/Model/Service/Order/ImportService.php +154 -0
  180. app/code/community/Dhl/Postpay/controllers/CheckoutController.php +46 -0
  181. app/code/community/Dhl/Postpay/controllers/NotificationController.php +40 -0
  182. app/code/community/Dhl/Postpay/controllers/ResponseController.php +51 -0
  183. app/code/community/Dhl/Postpay/etc/config.xml +128 -0
  184. app/code/community/Dhl/Postpay/etc/system.xml +100 -0
  185. app/code/community/Dhl/Postpay/sql/postpay_setup/mysql4-install-1.0.0.php +24 -0
  186. app/design/adminhtml/default/default/layout/meinpaket.xml +50 -0
  187. app/design/adminhtml/default/default/layout/meinpaketcommon.xml +38 -0
  188. app/design/adminhtml/default/default/layout/postpay.xml +3 -0
  189. app/design/adminhtml/default/default/template/meinpaket/catalog/product/matching/result.phtml +58 -0
  190. app/design/adminhtml/default/default/template/meinpaket/catalog/product/matching/tab.phtml +61 -0
  191. app/design/adminhtml/default/default/template/meinpaket/category/import/import.phtml +121 -0
  192. app/design/adminhtml/default/default/template/meinpaket/category/import/index.phtml +49 -0
  193. app/design/adminhtml/default/default/template/meinpaket/leftmenu.phtml +20 -0
  194. app/design/adminhtml/default/default/template/meinpaket/steps.phtml +15 -0
  195. app/design/frontend/base/default/layout/meinpaket.xml +3 -0
  196. app/design/frontend/base/default/layout/meinpaketcommon.xml +3 -0
  197. app/design/frontend/base/default/layout/postpay.xml +21 -0
  198. app/design/frontend/base/default/template/postpay/checkout.phtml +20 -0
  199. app/design/frontend/base/default/template/postpay/checkout/image.phtml +3 -0
  200. app/design/frontend/base/default/template/postpay/payment/redirect.phtml +8 -0
  201. app/etc/modules/Dhl_MeinPaket.xml +12 -0
  202. app/etc/modules/Dhl_MeinPaketCommon.xml +14 -0
  203. app/etc/modules/Dhl_Postpay.xml +13 -0
  204. app/locale/de_DE/Dhl_MeinPaket.csv +90 -0
  205. app/locale/de_DE/Dhl_MeinPaketCommon.csv +65 -0
  206. app/locale/de_DE/Dhl_Postpay.csv +3 -0
  207. package.xml +18 -0
  208. shell/dhlmeinpaket-category-import.php +67 -0
  209. shell/dhlmeinpaket-order-import.php +95 -0
  210. shell/dhlmeinpaket-product-export.php +88 -0
  211. shell/dhlmeinpaket-request-bestprice.php +53 -0
  212. skin/adminhtml/default/default/meinpaketcommon/images/1.png +0 -0
  213. skin/adminhtml/default/default/meinpaketcommon/images/2.png +0 -0
  214. skin/adminhtml/default/default/meinpaketcommon/images/3.png +0 -0
  215. skin/adminhtml/default/default/meinpaketcommon/images/ayn_ger_tuete_produkte_aussen.jpg +0 -0
  216. skin/adminhtml/default/default/meinpaketcommon/images/dhl_logo_kl.gif +0 -0
  217. skin/adminhtml/default/default/meinpaketcommon/images/loader.gif +0 -0
  218. skin/adminhtml/default/default/meinpaketcommon/images/shadowtopbg.png +0 -0
  219. skin/adminhtml/default/default/meinpaketcommon/module.css +55 -0
  220. skin/adminhtml/default/default/meinpaketcommon/module.js +34 -0
  221. skin/frontend/default/default/meinpaket/images/dhl_checkout_button.png +0 -0
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,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /* @var $model Dhl_MeinPaket_Model_Backlog_Product */
13
+ $model = Mage::getModel ( 'meinpaket/backlog_product' );
14
+ /* @var $collection Dhl_MeinPaket_Model_Mysql4_Backlog_Product_Collection */
15
+ $collection = $model->getCollection ();
16
+ $collection->getSelect ()->joinLeft ( array (
17
+ 'product_table' => $collection->getTable ( 'catalog/product' )
18
+ ), 'main_table.product_id=product_table.entity_id', array (
19
+ 'sku' => 'sku'
20
+ ) );
21
+ $this->setCollection ( $collection );
22
+ return parent::_prepareCollection ();
23
+ }
24
+ protected function _prepareColumns() {
25
+ $this->addColumn ( 'backlog_id', array (
26
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'ID' ),
27
+ 'type' => 'number',
28
+ 'index' => 'backlog_id'
29
+ ) );
30
+
31
+ $this->addColumn ( 'product_id', array (
32
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Product ID' ),
33
+ 'type' => 'number',
34
+ 'index' => 'product_id'
35
+ ) );
36
+
37
+ $this->addColumn ( 'sku', array (
38
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'SKU' ),
39
+ 'index' => 'sku'
40
+ ) );
41
+
42
+ $this->addColumn ( 'changes', array (
43
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Changes' ),
44
+ 'index' => 'changes'
45
+ ) );
46
+
47
+ $this->addColumn ( 'created_at', array (
48
+ 'header' => Mage::helper ( 'meinpaket' )->__ ( 'Created At' ),
49
+ 'type' => 'datetime',
50
+ 'index' => 'created_at'
51
+ ) );
52
+
53
+ $this->addExportType ( '*/*/exportExcel', Mage::helper ( 'meinpaket' )->__ ( 'Excel XML' ) );
54
+
55
+ return parent::_prepareColumns ();
56
+ }
57
+ protected function _prepareMassaction() {
58
+ $this->setMassactionIdField ( 'backlog_id' );
59
+ $this->getMassactionBlock ()->setFormFieldName ( 'backlogIds' );
60
+ $this->getMassactionBlock ()->addItem ( 'delete', array (
61
+ 'label' => Mage::helper ( 'meinpaket' )->__ ( 'Delete' ),
62
+ 'url' => $this->getUrl ( '*/*/massDelete', array () ),
63
+ 'confirm' => Mage::helper ( 'meinpaket' )->__ ( 'Are you sure?' )
64
+ ) );
65
+
66
+ return $this;
67
+ }
68
+ public function getRowUrl($row) {
69
+ return $this->getUrl ( 'adminhtml/catalog_product/edit', array (
70
+ 'id' => $row->getProductId ()
71
+ ) );
72
+ }
73
+ public function getGridUrl() {
74
+ return $this->getUrl ( '*/*/grid', array (
75
+ '_current' => true
76
+ ) );
77
+ }
78
+ }
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->__ ( 'Allyouneed 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 Allyouneed 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,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaket_Block_Adminhtml_CategoryImport_Import extends Mage_Adminhtml_Block_Template {
12
+ /**
13
+ *
14
+ * @var Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result
15
+ */
16
+ protected $result = null;
17
+
18
+ /**
19
+ * Constructor.
20
+ *
21
+ * @return void
22
+ */
23
+ public function __construct() {
24
+ parent::__construct ();
25
+ }
26
+
27
+ /**
28
+ * Sets the result object which encapsulates the information about the import process.
29
+ *
30
+ * @param Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result $result
31
+ * @return void
32
+ */
33
+ public function setResult(Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result $result) {
34
+ $this->result = $result;
35
+ }
36
+
37
+ /**
38
+ *
39
+ * @return Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result
40
+ */
41
+ public function getResult() {
42
+ return $this->result;
43
+ }
44
+
45
+ /**
46
+ * Returns an "<a>"-Tag which is a backend link to the given category.
47
+ *
48
+ * @param Mage_Catalog_Model_Category $category
49
+ * @return string
50
+ */
51
+ public function getLinkToCategory(Mage_Catalog_Model_Category $category) {
52
+ return '<a href="' . $this->getUrl ( 'adminhtml/catalog_category/edit/', array (
53
+ 'id' => $category->getId ()
54
+ ) ) . '" target="_blank">' . $this->__ ( 'edit category' ) . '</a>';
55
+ }
56
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/CategoryImport/Index.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaket_Block_Adminhtml_CategoryImport_Index extends Mage_Adminhtml_Block_Template {
12
+ /**
13
+ * Constructor.
14
+ *
15
+ * @return void
16
+ */
17
+ public function __construct() {
18
+ parent::__construct ();
19
+ }
20
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/LeftMenu.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaket_Block_Adminhtml_Leftmenu extends Mage_Adminhtml_Block_Template {
12
+ /**
13
+ *
14
+ * @var array
15
+ */
16
+ protected $menuItems = array ();
17
+
18
+ /**
19
+ *
20
+ * @var string
21
+ */
22
+ protected $activeItem;
23
+
24
+ /**
25
+ * Constructor.
26
+ *
27
+ * @return void
28
+ */
29
+ public function __construct() {
30
+ parent::__construct ();
31
+ }
32
+
33
+ /**
34
+ * Adds an item to the end of the menu.
35
+ *
36
+ * @param string $action
37
+ * @param string $name
38
+ * @return void
39
+ */
40
+ public function addMenuItem($action, $name) {
41
+ $this->menuItems [$action] = $name;
42
+ }
43
+
44
+ /**
45
+ *
46
+ * @return string $activeItem
47
+ */
48
+ public function getActiveItem() {
49
+ return $this->activeItem;
50
+ }
51
+
52
+ /**
53
+ *
54
+ * @param string $activeItem
55
+ * @return Dhl_MeinPaket_Block_Adminhtml_Leftmenu
56
+ */
57
+ public function setActiveItem($activeItem) {
58
+ $this->activeItem = $activeItem;
59
+ return $this;
60
+ }
61
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/OrderImport/Index.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaket_Block_Adminhtml_OrderImport_Index extends Mage_Adminhtml_Block_Template {
12
+ /**
13
+ * Constructor.
14
+ *
15
+ * @return void
16
+ */
17
+ public function __construct() {
18
+ parent::__construct ();
19
+ }
20
+ }
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,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaket_Block_Adminhtml_ProductExport_Index extends Mage_Adminhtml_Block_Template {
12
+ /**
13
+ * Constructor.
14
+ *
15
+ * @return void
16
+ */
17
+ public function __construct() {
18
+ parent::__construct ();
19
+ $this->assign ( 'exportLabel', 'Exportiere Produkte' );
20
+ }
21
+ }
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,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaket_Block_Adminhtml_Steps extends Mage_Adminhtml_Block_Template {
12
+ /**
13
+ *
14
+ * @var array
15
+ */
16
+ protected $steps;
17
+
18
+ /**
19
+ *
20
+ * @var string
21
+ */
22
+ protected $activeStep;
23
+
24
+ /**
25
+ * Constructor.
26
+ *
27
+ * @return void
28
+ */
29
+ public function __construct() {
30
+ $this->steps = array ();
31
+ parent::__construct ();
32
+ }
33
+
34
+ /**
35
+ * Adds a step.
36
+ *
37
+ * @param string $name
38
+ * @param string $text
39
+ * @return Dhl_MeinPaket_Block_Adminhtml_Steps
40
+ */
41
+ public function addStep($name, $text) {
42
+ $this->steps [$name] = $text;
43
+ return $this;
44
+ }
45
+
46
+ /**
47
+ *
48
+ * @return string
49
+ */
50
+ public function getActiveStep() {
51
+ return $this->activeStep;
52
+ }
53
+
54
+ /**
55
+ *
56
+ * @param
57
+ * string
58
+ * @return Dhl_MeinPaket_Block_Adminhtml_Steps
59
+ */
60
+ public function setActiveStep($activeStep) {
61
+ $this->activeStep = $activeStep;
62
+ return $this;
63
+ }
64
+ }
app/code/community/Dhl/MeinPaket/Block/Adminhtml/Version.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Block_Adminhtml_Version extends Mage_Adminhtml_Block_System_Config_Form_Field {
3
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
4
+ return ( string ) Mage::helper ( 'meinpaket/data' )->getExtensionVersion ();
5
+ }
6
+ }
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 ( 'meinpaketcommon/service_order_importService' )->importOrders ();
49
+ break;
50
+ case Dhl_MeinPaket_Model_Cron::SYNC_ASYNC :
51
+ $res = Mage::getSingleton ( 'meinpaketcommon/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,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Default helper for the Dhl_MeinPaket package.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Helper
9
+ */
10
+ class Dhl_MeinPaket_Helper_Data extends Mage_Core_Helper_Abstract {
11
+ /**
12
+ * Creates/extends JavaScript language object by the given labels.
13
+ * The given labels array must have the structure array('key1'=>'label1','key2'=>'label2',...).
14
+ * Key is the key under which the label will be accessible in frontend JavaScript.
15
+ * Label is the untranslated label.
16
+ * Example: Element is 'foo'=>'Bar'. So use MeinPaket.locale.foo .
17
+ *
18
+ * @param array $labels
19
+ * @return string
20
+ */
21
+ public function createLocaleJS(array $labels) {
22
+ $js = 'if(typeof MeinPaket === "undefined"){var MeinPaket={};}';
23
+ $js .= 'if(typeof MeinPaket.locale === "undefined"){MeinPaket.locale={};}';
24
+ $js .= 'Object.extend(MeinPaket.locale,{';
25
+
26
+ $firstItem = true;
27
+ if (sizeof ( $labels ) > 0) {
28
+ foreach ( $labels as $key => $label ) {
29
+ $js .= $this->_addJSLocaleLabel ( $key, $this->__ ( $label ), $firstItem );
30
+ if ($firstItem) {
31
+ $firstItem = false;
32
+ }
33
+ }
34
+ }
35
+
36
+ $js .= '});';
37
+
38
+ return $js;
39
+ }
40
+
41
+ /**
42
+ * Creates a json property.
43
+ *
44
+ * @param string $key
45
+ * @param string $label
46
+ * @param boolean $isFirst
47
+ * Tells if the label is the first in the list.
48
+ * @return string
49
+ */
50
+ protected function _addJSLocaleLabel($key, $label, $isFirst = false) {
51
+ $labelProperty = '';
52
+
53
+ if (! $isFirst) {
54
+ $labelProperty .= ',';
55
+ }
56
+
57
+ $labelProperty .= $key . ':"' . $label . '"';
58
+
59
+ return $labelProperty;
60
+ }
61
+ public function getExtensionVersion() {
62
+ return ( string ) Mage::getConfig ()->getModuleConfig ( 'Dhl_MeinPaket' )->version;
63
+ }
64
+ const STORE_VIEW_CONFIG = 'meinpaket/store/view';
65
+ private $_meinpaketStore = null;
66
+ private $_meinpaketRootCategory = null;
67
+ public function getMeinPaketStore() {
68
+ if ($this->_meinpaketStore == null) {
69
+ $this->_meinpaketStore = Mage::app ()->getStore ( Mage::getStoreConfig ( self::STORE_VIEW_CONFIG ) );
70
+ }
71
+ return $this->_meinpaketStore;
72
+ }
73
+ public function getMeinPaketStoreId() {
74
+ $store = $this->getMeinPaketStore ();
75
+ if ($store == null) {
76
+ return null;
77
+ } else {
78
+ return $store->getId ();
79
+ }
80
+ }
81
+ public function getMeinPaketRootCategoryId() {
82
+ return $this->getMeinPaketStore ()->getRootCategoryId ();
83
+ }
84
+ public function getMeinPaketRootCategory() {
85
+ if ($this->_meinpaketRootCategory == null) {
86
+ $this->_meinpaketRootCategory = Mage::getModel ( 'catalog/category' )->setStoreId ( $this->getMeinPaketStoreId () )->load ( $this->getMeinPaketRootCategoryId () );
87
+ }
88
+ return $this->_meinpaketRootCategory;
89
+ }
90
+ }
app/code/community/Dhl/MeinPaket/Helper/Order.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaket_Helper_Order extends Mage_Core_Helper_Abstract {
12
+ /**
13
+ * Tells if the given order is an order that was imported from Allyouneed.
14
+ *
15
+ * @param Mage_Sales_Model_Order $order
16
+ * @return boolean
17
+ */
18
+ public function isMeinPaketOrder(Mage_Sales_Model_Order $order) {
19
+ return ($order->hasData ( 'dhl_mein_paket_order_id' ) && $order->getData ( 'dhl_mein_paket_order_id' ));
20
+ }
21
+ }
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 ( 'meinpaketcommon/validation_validator_ean' );
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 ) && $this->_eanValidator->isValid ( $product->getData ( $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 Allyouneed 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 Allyouneed 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 Allyouneed' );
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->__ ( 'Invalid 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 Allyouneed' );
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 Allyouneed' );
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 Allyouneed' ) . ' "' . $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,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaket_Helper_Shipment extends Mage_Core_Helper_Abstract {
12
+ /**
13
+ * Tells if the given order is an order that was imported from Allyouneed.
14
+ *
15
+ * @param Mage_Sales_Model_Order_Shipment $shipment
16
+ * to check
17
+ * @return boolean
18
+ */
19
+ public function isMeinPaketShipment(Mage_Sales_Model_Order_Shipment $shipment) {
20
+ return Mage::helper ( 'meinpaket/order' )->isMeinPaketOrder ( $shipment->getOrder () );
21
+ }
22
+
23
+ /**
24
+ * Tells if the given $shipment is exported to MeinPaket
25
+ *
26
+ * @param Mage_Sales_Model_Order_Shipment $shipment
27
+ * to be shipped
28
+ * @return boolean
29
+ */
30
+ public function isExportedToDhlMeinPaket(Mage_Sales_Model_Order_Shipment $shipment) {
31
+ return $shipment->hasData ( 'shipment_was_exported_for_dhl_mein_paket' ) && $shipment->getData ( 'shipment_was_exported_for_dhl_mein_paket' );
32
+ }
33
+ }
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/Category.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * MeinPaket Category Model.
5
+ *
6
+ * @category Mage
7
+ * @package Dhl_MeinPaket
8
+ */
9
+ class Dhl_MeinPaket_Model_Category extends Mage_Core_Model_Abstract {
10
+ /**
11
+ * Constructor.
12
+ *
13
+ * @see Varien_Object::_construct()
14
+ * @return void
15
+ */
16
+ protected function _construct() {
17
+ $this->_init ( 'meinpaket/category' );
18
+ }
19
+ }
app/code/community/Dhl/MeinPaket/Model/Cron.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Cron handler for Dhl Allyouneed.
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 request best prices.
36
+ *
37
+ * @return NULL
38
+ */
39
+ public function getBestPrice() {
40
+ try {
41
+ return Mage::getSingleton ( 'meinpaket/service_productData_requestService' )->requestBestPrices ();
42
+ } catch ( Exception $e ) {
43
+ Mage::logException ( $e );
44
+ }
45
+ return null;
46
+ }
47
+ }
app/code/community/Dhl/MeinPaket/Model/Entity/Attribute/Frontend/LabelTranslation.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaket_Model_Entity_Attribute_Frontend_LabelTranslation extends Mage_Eav_Model_Entity_Attribute_Frontend_Abstract {
12
+
13
+ /**
14
+ * Returns the label of the field.
15
+ *
16
+ * @return string
17
+ */
18
+ public function getLabel() {
19
+ return Mage::helper ( 'Dhl_MeinPaket' )->__ ( parent::getLabel () );
20
+ }
21
+ }
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,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaket_Model_Exception_InvalidDataException extends Varien_Exception {
12
+ /**
13
+ *
14
+ * @var string
15
+ */
16
+ protected $errorType;
17
+
18
+ /**
19
+ *
20
+ * @var string
21
+ */
22
+ protected $fieldName;
23
+
24
+ /**
25
+ *
26
+ * @var integer
27
+ */
28
+ protected $entityId;
29
+
30
+ /**
31
+ * Constructor.
32
+ *
33
+ * @param integer $entityId
34
+ * of the model entity on which the error occured.
35
+ * @param string $fieldName
36
+ * of the attribute which is invalid.
37
+ * @param string $errorType
38
+ * type defined in Dhl_MeinPaket_Model_Validation_ValidationInterface.
39
+ * @return void
40
+ */
41
+ public function __construct($entityId, $fieldName, $errorType = Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_FIELD_IS_INVALID) {
42
+ parent::__construct ( 'Invalid data field "' . $fieldName . '" for entity (id=' . $entityId . '). Error type is "' . $errorType . '".' );
43
+
44
+ $this->entityId = $entityId;
45
+ $this->fieldName = $fieldName;
46
+ $this->errorType = $errorType;
47
+ }
48
+
49
+ /**
50
+ *
51
+ * @return string
52
+ */
53
+ public function getFieldName() {
54
+ return $this->fieldName;
55
+ }
56
+
57
+ /**
58
+ *
59
+ * @return integer
60
+ */
61
+ public function getEntityId() {
62
+ return $this->entityId;
63
+ }
64
+
65
+ /**
66
+ *
67
+ * @return string
68
+ */
69
+ public function getErrorType() {
70
+ return $this->errorType;
71
+ }
72
+ }
app/code/community/Dhl/MeinPaket/Model/Exception/MissingDataException.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaket_Model_Exception_MissingDataException extends Dhl_MeinPaket_Model_Exception_InvalidDataException {
12
+ /**
13
+ * Constructor.
14
+ *
15
+ * @param integer $entityId
16
+ * of the model entity on which the error occured.
17
+ * @param string $fieldName
18
+ * of the attribute that is missing.
19
+ * @return void
20
+ */
21
+ public function __construct($entityId, $fieldName) {
22
+ parent::__construct ( $entityId, $fieldName, Dhl_MeinPaket_Model_Validation_ValidationInterface::ERROR_REQUIRED_FIELD_IS_EMPTY );
23
+ }
24
+ }
25
+
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,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Allyouneed category resource model
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ */
9
+ class Dhl_MeinPaket_Model_Mysql4_Category extends Mage_Core_Model_Mysql4_Abstract {
10
+ protected function _construct() {
11
+ $this->_init ( 'meinpaket/category', 'category_id' );
12
+ }
13
+ }
14
+
app/code/community/Dhl/MeinPaket/Model/Mysql4/Category/Collection.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Allyouneed category collection.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ */
9
+ class Dhl_MeinPaket_Model_Mysql4_Category_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
10
+ /**
11
+ * Constructor.
12
+ *
13
+ * @see Mage_Core_Model_Mysql4_Collection_Abstract::_construct()
14
+ * @return void
15
+ */
16
+ protected function _construct() {
17
+ $this->_init ( 'meinpaket/category' );
18
+ }
19
+ }
app/code/community/Dhl/MeinPaket/Model/Observer.php ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaket_Model_Observer {
12
+ /**
13
+ * Triggered when product is duplicated.
14
+ *
15
+ * @param Varien_Event_Observer $observer
16
+ * @return Dhl_MeinPaket_Model_Observer
17
+ */
18
+ public function productDuplicate(Varien_Event_Observer $observer) {
19
+ $newProduct = $observer->getEvent ()->getNewProduct ();
20
+ $newProduct->setData ( 'meinpaket_id', '' );
21
+ $newProduct->setData ( 'meinpaket_export', 0 );
22
+ return $this;
23
+ }
24
+
25
+ /**
26
+ * Is triggered after a product has been deleted.
27
+ * If the product has been exported to MeinPake.de once before, the
28
+ * product's status will be set to disabled, and then be saved to
29
+ * trigger the catalog_product_save_after event again.
30
+ *
31
+ * @see Dhl_MeinPaket_Model_Observer::catalogProductSaveAfter()
32
+ * @param Varien_Event_Observer $observer
33
+ * @return Dhl_MeinPaket_Model_Observer
34
+ */
35
+ public function catalogProductDeleteBefore(Varien_Event_Observer $observer) {
36
+ try {
37
+ $product = Mage::getModel ( 'catalog/product' )->load ( $observer->getData ( 'product' )->getId () );
38
+ if ($product->hasData ( 'was_exported_for_dhl_mein_paket' ) && (( boolean ) $product->getData ( 'product_was_exported_for_dhl' )) === true) {
39
+ $product->setStatus ( Mage_Catalog_Model_Product_Status::STATUS_DISABLED )->save ();
40
+ }
41
+
42
+ $catalogService = Mage::getSingleton ( 'meinpaket/service_product_export' );
43
+ $catalogService->deleteProduct ( $product );
44
+ } catch ( Exception $ex ) {
45
+ Mage::logException ( $ex );
46
+ }
47
+
48
+ return $this;
49
+ }
50
+
51
+ /**
52
+ * Triggered before product is saved.
53
+ *
54
+ * @param Varien_Event_Observer $observer
55
+ * @return Dhl_MeinPaket_Model_Observer
56
+ */
57
+ public function catalogProductSaveBefore(Varien_Event_Observer $observer) {
58
+ /**
59
+ *
60
+ * @var $product Mage_Catalog_Model_Product
61
+ */
62
+ $product = $observer->getEvent ()->getProduct ();
63
+
64
+ if (! $product->getId ()) {
65
+ /*
66
+ * 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.
67
+ */
68
+ $product->setData ( 'meinpaket_id', '' );
69
+ }
70
+
71
+ if ($product->hasDataChanges ()) {
72
+ try {
73
+ $changes = array ();
74
+ foreach ( $product->getData () as $attribute => $newValue ) {
75
+ // Find changed products
76
+ $oldValue = $product->getOrigData ( $attribute );
77
+
78
+ if (is_array ( $newValue ) && is_array ( $oldValue )) {
79
+ // Ignored
80
+ } else if ($newValue != $oldValue) {
81
+ $changes [] = $attribute;
82
+ }
83
+ }
84
+
85
+ if (count ( $changes )) {
86
+ // Flag schedule in backlog.
87
+ $product->setData ( 'meinpaket_backlog_changes', $changes );
88
+ }
89
+ } catch ( Exception $e ) {
90
+ Mage::logException ( $e );
91
+ }
92
+ }
93
+ return $this;
94
+ }
95
+
96
+ /**
97
+ * Triggered after product is saved.
98
+ *
99
+ * @param Varien_Event_Observer $observer
100
+ * @return Dhl_MeinPaket_Model_Observer
101
+ */
102
+ public function catalogProductSaveAfter(Varien_Event_Observer $observer) {
103
+ try {
104
+ $product = $observer->getEvent ()->getProduct ();
105
+
106
+ if (is_array ( $product->getData ( 'meinpaket_backlog_changes' ) )) {
107
+ // Schedule the product for later
108
+ $changes = $product->getData ( 'meinpaket_backlog_changes' );
109
+ if (count ( $changes ) && $product->getId ()) {
110
+ $typeInstance = $product->getTypeInstance ();
111
+ if ($typeInstance instanceof Mage_Catalog_Model_Product_Type_Configurable) {
112
+ Mage::helper ( 'meinpaket/backlog' )->createChildrenBacklog ( $product->getId () );
113
+ } else {
114
+ Mage::helper ( 'meinpaket/backlog' )->createBacklog ( $product->getId (), implode ( ',', $changes ) );
115
+ }
116
+ }
117
+ }
118
+ } catch ( Exception $ex ) {
119
+ Mage::logException ( $ex );
120
+ }
121
+
122
+ return $this;
123
+ }
124
+
125
+ /**
126
+ * Triggered before product massaction.
127
+ *
128
+ * @param Varien_Event_Observer $observer
129
+ * @return Dhl_MeinPaket_Model_Observer
130
+ */
131
+ public function catalogProductAttributeUpdateBefore(Varien_Event_Observer $observer) {
132
+ $attributesData = $observer->getEvent ()->getAttributesData ();
133
+ $productIds = $observer->getEvent ()->getProductIds ();
134
+
135
+ $changes = implode ( ',', array_keys ( $attributesData ) );
136
+
137
+ foreach ( $productIds as $id ) {
138
+ $count = Mage::helper ( 'meinpaket/backlog' )->createChildrenBacklog ( $id );
139
+ if ($count <= 0) {
140
+ Mage::helper ( 'meinpaket/backlog' )->createBacklog ( $id, $changes );
141
+ }
142
+ }
143
+ return $this;
144
+ }
145
+
146
+ public function catalogInventoryStockItemSaveAfter() {
147
+ //TODO:
148
+ }
149
+
150
+ /**
151
+ *
152
+ * @param unknown $observer
153
+ */
154
+ public function addMeinPaketAttributes($observer) {
155
+ $fieldset = $observer->getForm ()->getElement ( 'base_fieldset' );
156
+ $attribute = $observer->getAttribute ();
157
+ $fieldset->addField ( 'meinpaket_attribute', 'select', array (
158
+ 'name' => 'meinpaket_attribute',
159
+ 'label' => Mage::helper ( 'meinpaket' )->__ ( 'Allyouneed Attribute' ),
160
+ 'title' => Mage::helper ( 'meinpaket' )->__ ( 'Allyouneed Attribute' ),
161
+ 'values' => Mage::getModel ( 'meinpaket/system_config_source_attributes' )->toOptionArray ()
162
+ ) );
163
+ }
164
+ }
app/code/community/Dhl/MeinPaket/Model/Payment/Method/Meinpaket.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Allyouneed 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
+ * Can use this payment method in administration panel?
19
+ * @var boolean
20
+ */
21
+ protected $_canUseInternal = false;
22
+
23
+ /**
24
+ * Can show this payment method as an option on checkout payment page?
25
+ * @var boolean
26
+ */
27
+ protected $_canUseCheckout = false;
28
+
29
+ }
app/code/community/Dhl/MeinPaket/Model/Resource/Eav/Mysql4/Setup.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaket_Model_Resource_Eav_Mysql4_Setup extends Mage_Catalog_Model_Resource_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 Allyouneed Id',
19
+ 'required' => false,
20
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
21
+ 'visible' => false,
22
+ 'group' => 'Allyouneed'
23
+ ),
24
+ 'sync_with_dhl_mein_paket' => array (
25
+ 'type' => 'int',
26
+ 'label' => 'Sync with Allyouneed',
27
+ 'frontend' => 'meinpaket/entity_attribute_frontend_labelTranslation',
28
+ 'input' => 'select',
29
+ 'source' => 'meinpaket/entity_attribute_source_productSyncMode',
30
+ 'required' => false,
31
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
32
+ 'visible' => true,
33
+ 'group' => 'Allyouneed'
34
+ ),
35
+ 'max_stock_for_dhl_mein_paket' => array (
36
+ 'type' => 'int',
37
+ 'label' => 'Maximum stock qty. for Allyouneed',
38
+ 'frontend' => 'meinpaket/entity_attribute_frontend_labelTranslation',
39
+ 'input' => 'text',
40
+ 'required' => false,
41
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
42
+ 'visible' => true,
43
+ 'group' => 'Allyouneed'
44
+ ),
45
+ 'meinpaket_category' => array (
46
+ 'type' => 'text',
47
+ 'label' => 'Allyouneed Category',
48
+ 'input' => 'select',
49
+ 'source' => 'meinpaket/entity_attribute_source_meinPaketCategory',
50
+ 'required' => false,
51
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
52
+ 'visible' => true,
53
+ 'group' => 'Allyouneed'
54
+ )
55
+ )
56
+ )
57
+ );
58
+ }
59
+ }
app/code/community/Dhl/MeinPaket/Model/Service/MarketplaceCategoryImport/ImportService.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
12
+ class Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_ImportService extends Varien_Object {
13
+ /**
14
+ *
15
+ * @var Mage_Catalog_Model_Category_Api
16
+ */
17
+ protected $categoryApi = null;
18
+
19
+ /**
20
+ *
21
+ * @var array
22
+ */
23
+ private $idMapping = array ();
24
+
25
+ /**
26
+ *
27
+ * @var Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result
28
+ */
29
+ protected $result = null;
30
+
31
+ /**
32
+ * Constructor.
33
+ *
34
+ * @return void
35
+ */
36
+ public function __construct() {
37
+ $this->result = Mage::getModel ( 'meinpaket/Service_MarketplaceCategoryImport_Result' );
38
+ }
39
+
40
+ /**
41
+ * Imports the marketplace category structure into the local marketplace root category.
42
+ *
43
+ * @return void
44
+ */
45
+ public function importMarketplaceCategoryStructure() {
46
+ /* @var $structure array */
47
+ $structure = null;
48
+
49
+ /* @var $rootCategory Mage_Catalog_Model_Category */
50
+ $rootCategory = Mage::getModel ( 'catalog/category' );
51
+
52
+ /* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
53
+ $collection = $rootCategory->getCollection ();
54
+
55
+ /* @var $memoryLimiter Dhl_MeinPaket_Model_System_MemoryLimiter */
56
+ $memoryLimiter = Mage::getModel ( 'meinpaketcommon/system_memoryLimiter' );
57
+
58
+ /* @var $requestXml string */
59
+ $requestXml = '';
60
+
61
+ /* @var $resultXml string */
62
+ $resultXml = '';
63
+
64
+ /* @var $structure array */
65
+ $structure = null;
66
+
67
+ /* @var $client Dhl_MeinPaket_Model_Client_XmlOverHttp */
68
+ $client = Mage::getModel ( 'meinpaketcommon/client_xmlOverHttp' );
69
+
70
+ $memoryLimiter->setMemoryLimit ( Dhl_MeinPaketCommon_Model_System_MemoryLimiter::MEMORY_LIMIT_VERY_HIGH );
71
+
72
+ /* @var $ids array */
73
+ $ids = array ();
74
+
75
+ $transaction = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_write' );
76
+
77
+ try {
78
+ $transaction->beginTransaction ();
79
+
80
+ /* @var $request Dhl_MeinPaket_Model_Xml_Request_DownloadRequest */
81
+ $request = Mage::getModel ( 'meinpaketcommon/xml_request_downloadRequest' );
82
+ $request->addDownloadMarketplaceCategories ();
83
+
84
+ $dom = $client->send ( $request );
85
+
86
+ $ids = Mage::getResourceModel ( 'meinpaket/category_collection' )->getAllIds ();
87
+
88
+ $categories = array ();
89
+
90
+ /* @var $category Dhl_MeinPaket_Model_Xml_Response_Partial_Category */
91
+ foreach ( $dom->getCategories () as $category ) {
92
+ /* @var $model Dhl_MeinPaket_Model_Category */
93
+ $model = Mage::getModel ( 'meinpaket/category' )->load ( $category->getCode (), 'code' );
94
+
95
+ $model->setName ( trim ( $category->getName () ) );
96
+ $model->setCode ( trim ( $category->getCode () ) );
97
+ $model->setParent ( trim ( $category->getParent () ) );
98
+ $model->setLeaf ( true );
99
+
100
+ $categories [$model->getCode ()] = $model;
101
+
102
+ if ($model->getId ()) {
103
+ $ids = array_diff ( $ids, array($model->getId ()) );
104
+ }
105
+ }
106
+
107
+ foreach ( $categories as $key => $value ) {
108
+ if (array_key_exists ( $value->getParent (), $categories )) {
109
+ $categories [$value->getParent ()]->setLeaf ( false );
110
+ }
111
+ }
112
+
113
+ foreach ( $categories as $key => $value ) {
114
+ if ($value->getData () != $value->getOrigData ()) {
115
+ $oldId = $value->getId ();
116
+ $value->save ();
117
+ if ($oldId) {
118
+ $this->result->addUpdatedCategory ( $value );
119
+ } else {
120
+ $this->result->addNewCategory ( $value );
121
+ }
122
+ }
123
+ }
124
+
125
+ foreach ( $ids as $id ) {
126
+ $model = Mage::getModel ( 'meinpaket/category' )->load ( $id );
127
+ if ($model->getId () != null) {
128
+ $this->result->addDeletedCategory ( $model );
129
+ $model->delete ();
130
+ }
131
+ }
132
+
133
+ $transaction->commit ();
134
+
135
+ Mage::getModel ( 'meinpaket/entity_attribute_source_meinPaketCategory' )->cleanCache ();
136
+ } catch ( Exception $e ) {
137
+ $transaction->rollback ();
138
+ Mage::logException ( $e );
139
+ throw $e;
140
+ }
141
+
142
+ return $this->result;
143
+ }
144
+ }
145
+
app/code/community/Dhl/MeinPaket/Model/Service/MarketplaceCategoryImport/Result.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result extends Dhl_MeinPaketCommon_Model_Service_Result_Abstract {
12
+ /**
13
+ *
14
+ * @var array
15
+ */
16
+ protected $newCategories = array ();
17
+
18
+ /**
19
+ *
20
+ * @var array
21
+ */
22
+ protected $deletedCategories = array ();
23
+
24
+ /**
25
+ *
26
+ * @var array
27
+ */
28
+ protected $updatedCategories = array ();
29
+
30
+ /**
31
+ * Adds a category which was not there before.
32
+ *
33
+ * @param integer $categoryId
34
+ * @return Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_ImportService
35
+ */
36
+ public function addNewCategory(Dhl_MeinPaket_Model_Category $category) {
37
+ $this->newCategories [] = $category;
38
+ return $this;
39
+ }
40
+
41
+ /**
42
+ * Adds a category which has been deleted because it is not existent in the
43
+ * MeinPaket marketplace anymore.
44
+ *
45
+ * @param string $name
46
+ * @return Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_ImportService
47
+ */
48
+ public function addDeletedCategory(Dhl_MeinPaket_Model_Category $category) {
49
+ $this->deletedCategories [] = $category;
50
+ return $this;
51
+ }
52
+
53
+ /**
54
+ * Adds a category which has been renamed.
55
+ *
56
+ * @param Dhl_MeinPaket_Model_Category $category
57
+ * @return Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_ImportService
58
+ */
59
+ public function addUpdatedCategory(Dhl_MeinPaket_Model_Category $category) {
60
+ $this->updatedCategories[] = $category;
61
+ return $this;
62
+ }
63
+
64
+ /**
65
+ * Returns the ids of the categories which have not been existent in Magento yet.
66
+ *
67
+ * @return array
68
+ */
69
+ public function getNewCategories() {
70
+ return $this->newCategories;
71
+ }
72
+
73
+ /**
74
+ * Returns the names of the categories which have been deleted
75
+ * because they were existent in Magento but don't exist
76
+ * in Allyouneed marketplace category structure anymore.
77
+ *
78
+ * @return array
79
+ */
80
+ public function getDeletedCategories() {
81
+ return $this->deletedCategories;
82
+ }
83
+
84
+ /**
85
+ * Returns an array of arrays which represent the categories which
86
+ * have been renamed.
87
+ *
88
+ * @return array array has the following structure:
89
+ * [
90
+ * [
91
+ * 'id', // entity id of the category
92
+ * 'oldName' // The former name of the category
93
+ * ],
94
+ * ...
95
+ * ]
96
+ */
97
+ public function getUpdatedCategories() {
98
+ return $this->updatedCategories;
99
+ }
100
+
101
+ /**
102
+ * Returns the number of categories that have been added.
103
+ *
104
+ * @return integer
105
+ */
106
+ public function getNewCategoriesCount() {
107
+ return sizeof ( $this->newCategories );
108
+ }
109
+
110
+ /**
111
+ * Returns the number of categories that have been deleted.
112
+ *
113
+ * @return integer
114
+ */
115
+ public function getDeletedCategoriesCount() {
116
+ return sizeof ( $this->deletedCategories );
117
+ }
118
+
119
+ /**
120
+ * Returns the number of categories that have been renamed.
121
+ *
122
+ * @return integer
123
+ */
124
+ public function getUpdatedCategoriesCount() {
125
+ return sizeof ( $this->updatedCategories );
126
+ }
127
+ }
128
+
app/code/community/Dhl/MeinPaket/Model/Service/Product/Export.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_MeinPaketCommon_Model_Service_Abstract {
11
+ /**
12
+ *
13
+ * @var Dhl_MeinPaket_Helper_Product
14
+ */
15
+ protected $_productHelper = null;
16
+
17
+ /**
18
+ * Constructor.
19
+ *
20
+ * @return void
21
+ */
22
+ public function __construct() {
23
+ $this->_processableProducts = array ();
24
+ $this->_productHelper = Mage::helper ( 'meinpaket/product' );
25
+ }
26
+
27
+ /**
28
+ * Exports products.
29
+ *
30
+ * @param integer $selectionMode
31
+ * @return Dhl_MeinPaket_Model_Service_Product_Export_Result
32
+ */
33
+ public function exportProducts() {
34
+ $cycleCount = Mage::getStoreConfig ( 'meinpaket/advanced/cycle_product_count' );
35
+ if (! is_numeric ( $cycleCount )) {
36
+ $cycleCount = 100;
37
+ }
38
+
39
+ $seenMagentoProducts = array ();
40
+
41
+ $uploadRequest = new Dhl_MeinPaketCommon_Model_Xml_Request_UploadRequest ();
42
+
43
+ /* @var $client Dhl_MeinPaket_Model_Client_XmlOverHttp */
44
+ $client = Mage::getModel ( 'meinpaketcommon/client_xmlOverHttp' );
45
+
46
+ $count = 0;
47
+ $currentPage = 1;
48
+
49
+ /* @var $productBacklogs Dhl_MeinPaket_Model_Mysql4_Backlog_Product_Collection */
50
+ $productBacklogs = Mage::getModel ( 'meinpaket/backlog_product' )->getCollection ();
51
+ $productBacklogs->setPageSize ( $cycleCount );
52
+ $productBacklogs->addOrder ( 'product_id', Varien_Data_Collection::SORT_ORDER_ASC );
53
+
54
+ $pages = $productBacklogs->getLastPageNumber ();
55
+
56
+ do {
57
+ $productBacklogs->setCurPage ( $currentPage );
58
+ $productBacklogs->load ();
59
+ if ($productBacklogs->count () <= 0) {
60
+ break;
61
+ }
62
+
63
+ foreach ( $productBacklogs as $productBacklog ) {
64
+ $productId = $productBacklog->getProductId ();
65
+ $changes = explode ( ',', $productBacklog->getChanges () );
66
+
67
+ try {
68
+ if (! isset ( $seenMagentoProducts [$productId] )) {
69
+ $seenMagentoProducts [$productId] = true;
70
+
71
+ /* @var $product Mage_Catalog_Model_Product */
72
+ $product = Mage::getModel ( 'catalog/product' )->load ( $productId );
73
+
74
+ $syncMode = $product->getData ( 'sync_with_dhl_mein_paket' );
75
+
76
+ switch ($syncMode) {
77
+ case Dhl_MeinPaket_Model_Entity_Attribute_Source_ProductSyncMode::COMPLETE :
78
+ $uploadRequest->addProductDescription ( $product );
79
+ break;
80
+ case Dhl_MeinPaket_Model_Entity_Attribute_Source_ProductSyncMode::OFFER :
81
+ $uploadRequest->addOffer ( $product );
82
+ break;
83
+ default :
84
+ $uploadRequest->removeProduct ( $product );
85
+ break;
86
+ }
87
+ } else {
88
+ Mage::log ( 'Product m' . $productId . ' already synced' );
89
+ }
90
+
91
+ $productBacklog->delete ();
92
+ $count ++;
93
+ } catch ( Exception $ex ) {
94
+ Mage::logException ( $ex );
95
+ Mage::log ( 'Error syncing product m' . $productId );
96
+ }
97
+ }
98
+
99
+ /**
100
+ * We deleted all products on the first page.
101
+ * If we load this page again, there will be new products.
102
+ */
103
+ // $currentPage ++;
104
+ $productBacklogs->clear ();
105
+ } while ( $count < $cycleCount );
106
+
107
+ if ($uploadRequest->isHasData ()) {
108
+ $response = $client->send ( $uploadRequest, true );
109
+ }
110
+
111
+ if ($currentPage < $pages) {
112
+ Mage::helper ( 'meinpaket/cron' )->scheduleJobs ( array (
113
+ Dhl_MeinPaket_Model_Cron::SYNC_ASYNC
114
+ ), false );
115
+ }
116
+
117
+ return Mage::helper ( 'meinpaket/data' )->__ ( "Processed %d products", $count );
118
+ }
119
+
120
+ /**
121
+ * Exports products.
122
+ *
123
+ * @param Mage_Catalog_Model_Product $product
124
+ * @return Dhl_MeinPaket_Model_Service_Product_Export_Result
125
+ */
126
+ public function deleteProduct(Mage_Catalog_Model_Product $product) {
127
+ $uploadRequest = new Dhl_MeinPaketCommon_Model_Xml_Request_UploadRequest ();
128
+
129
+ /* @var $client Dhl_MeinPaket_Model_Client_XmlOverHttp */
130
+ $client = Mage::getModel ( 'meinpaketcommon/client_xmlOverHttp' );
131
+
132
+ $uploadRequest->removeProduct ( $product );
133
+
134
+ if ($uploadRequest->isHasData ()) {
135
+ $response = $client->send ( $uploadRequest, true );
136
+ }
137
+
138
+ return Mage::helper ( 'meinpaket/data' )->__ ( "Processed %d products", $count );
139
+ }
140
+ }
app/code/community/Dhl/MeinPaket/Model/Service/Product/Export/Exception/InvalidEan.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
10
+ class Dhl_MeinPaket_Model_Service_Product_Export_Exception_InvalidEan extends Dhl_MeinPaket_Model_Exception_InvalidDataException {
11
+ /**
12
+ * Constructor.
13
+ *
14
+ * @param integer $entityId
15
+ * @return void
16
+ */
17
+ public function __construct($entityId) {
18
+ parent::__construct ( $entityId, 'sku' );
19
+ }
20
+ }
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 Allyouneed.
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 Allyouneed.
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 ( 'meinpaketcommon/xml_request_dataRequest' );
25
+
26
+ /* @var $client Dhl_MeinPaket_Model_Client_XmlOverHttp */
27
+ $client = Mage::getModel ( 'meinpaketcommon/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 ( 'meinpaketcommon/xml_request_dataRequest' );
54
+
55
+ /* @var $client Dhl_MeinPaket_Model_Client_XmlOverHttp */
56
+ $client = Mage::getModel ( 'meinpaketcommon/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_MeinPaketCommon_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_MeinPaketCommon_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/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,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Controller for Allyouneed marketplace category structure import.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Adminhtml
9
+ * @version $Id$
10
+ */
11
+ class Dhl_MeinPaket_Adminhtml_CategoryImportController extends Mage_Adminhtml_Controller_Action {
12
+ /**
13
+ * Initializes the controller.
14
+ *
15
+ * @return Dhl_MeinPaket_Adminhtml_CategoryImportController
16
+ */
17
+ protected function _initAction() {
18
+ $this->loadLayout ()->_setActiveMenu ( 'meinpaket' );
19
+ $this->_title ( $this->__ ( 'Allyouneed' ) )->_title ( $this->__ ( 'Category Import' ) );
20
+ return $this;
21
+ }
22
+
23
+ /**
24
+ * Default action.
25
+ *
26
+ * @return void
27
+ */
28
+ public function indexAction() {
29
+ $this->_initAction ();
30
+ $this->renderLayout ();
31
+ }
32
+
33
+ /**
34
+ * Processes the category import and displays the results.
35
+ *
36
+ * @return void
37
+ */
38
+ public function importAction() {
39
+ /* @var $service Dhl_MeinPaket_Model_MarketplaceCategoryStructureImportService */
40
+ $service = Mage::getModel ( 'meinpaket/Service_MarketplaceCategoryImport_ImportService' );
41
+
42
+ /* @var $result Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result */
43
+ $result = null;
44
+
45
+ $errorMsg = '';
46
+
47
+ try {
48
+ $result = $service->importMarketplaceCategoryStructure ();
49
+ } catch ( Dhl_MeinPaket_Model_Client_BadHttpReturnCodeException $e ) {
50
+ Mage::logException ( $e );
51
+ $errorMsg = $this->__ ( 'Connecting to Allyouneed server failed.' );
52
+ } catch ( Dhl_MeinPaket_Model_Client_HttpTimeoutException $e ) {
53
+ Mage::logException ( $e );
54
+ $errorMsg = $this->__ ( 'Connection to Allyouneed server timed out.' );
55
+ } catch ( Exception $e ) {
56
+ Mage::logException ( $e );
57
+ $errorMsg = $this->__ ( 'Unknown error' ) . '. (' . $e->getMessage () . ')';
58
+ }
59
+
60
+ if (strlen ( $errorMsg ) > 0) {
61
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $this->__ ( 'Error' ) . ': ' . $errorMsg );
62
+ } else {
63
+ Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( $this->__ ( 'Successfully imported marketplace categories.' ) );
64
+ }
65
+
66
+ if ($result !== null) {
67
+
68
+ $countNew = $result->getNewCategoriesCount ();
69
+ $countRenamed = $result->getUpdatedCategoriesCount ();
70
+ $countDeleted = $result->getDeletedCategoriesCount ();
71
+
72
+ if ($countNew > 0) {
73
+ Mage::getSingleton ( 'adminhtml/session' )->addNotice ( sprintf ( $this->__ ( 'Added %s new categories.' ), $countNew ) );
74
+ }
75
+ if ($countRenamed > 0) {
76
+ Mage::getSingleton ( 'adminhtml/session' )->addNotice ( sprintf ( $this->__ ( 'Renamed %s categories.' ), $countRenamed ) );
77
+ }
78
+ if ($countDeleted > 0) {
79
+ Mage::getSingleton ( 'adminhtml/session' )->addNotice ( sprintf ( $this->__ ( 'Deleted %s categories.' ), $countDeleted ) );
80
+ }
81
+ }
82
+
83
+ $this->_initAction ();
84
+
85
+ if ($result !== null) {
86
+ $this->getLayout ()->getBlock ( 'meinpaket.adminhtml_categoryImport_import' )->setResult ( $result );
87
+ }
88
+
89
+ $this->renderLayout ();
90
+ }
91
+ }
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/ProductExportController.php ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Controls the export of local products to Allyouneed.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Adminhtml
9
+ * @version $Id$
10
+ */
11
+ class Dhl_MeinPaket_Adminhtml_ProductExportController extends Mage_Adminhtml_Controller_Action {
12
+ /**
13
+ *
14
+ * @var integer
15
+ */
16
+ const PRODUCT_SELECTION_MODE_SYNCED_ONLY = 1;
17
+
18
+ /**
19
+ *
20
+ * @var integer
21
+ */
22
+ const PRODUCT_SELECTION_MODE_ALL = 2;
23
+
24
+ /**
25
+ *
26
+ * @var integer
27
+ */
28
+ protected $_defaultSelectionMode = self::PRODUCT_SELECTION_MODE_SYNCED_ONLY;
29
+
30
+ /**
31
+ * Initialization.
32
+ *
33
+ * @return Dhl_MeinPaket_Adminhtml_ProductExportController
34
+ */
35
+ protected function _initAction() {
36
+ $this->loadLayout ()->_setActiveMenu ( 'meinpaket' );
37
+
38
+ $this->_title ( $this->__ ( 'Allyouneed' ) )->_title ( $this->__ ( 'Product Export' ) );
39
+
40
+ return $this;
41
+ }
42
+
43
+ /**
44
+ * Default action.
45
+ *
46
+ * @return void
47
+ */
48
+ public function indexAction() {
49
+ $this->_initAction ();
50
+ $this->renderLayout ();
51
+ }
52
+
53
+ /**
54
+ * Shows a list of the selected products.
55
+ *
56
+ * @return void
57
+ */
58
+ public function listAction() {
59
+ $this->_initAction ();
60
+ $this->getLayout ()->getBlock ( 'meinpaket.adminhtml_productExport_list' )->assignProductCollection ( $this->getProductCollection () );
61
+
62
+ $this->renderLayout ();
63
+ }
64
+
65
+ /**
66
+ * Transfers descriptions and offers of the selected products to Allyouneed.
67
+ *
68
+ * @return void
69
+ */
70
+ public function exportAction() {
71
+ /* @var $exportService Dhl_MeinPaket_Model_Service_Product_Export */
72
+ $exportService = Mage::getModel ( 'meinpaket/service_product_export' );
73
+
74
+ /* @var $results Dhl_MeinPaket_Model_Service_Product_Export_Result */
75
+ $results = null;
76
+
77
+ try {
78
+ $results = $exportService->exportProducts ( );
79
+
80
+ if ($debugMode) {
81
+ Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( 'DEBUG:' . $results->debugOutput () );
82
+ }
83
+ if (count ( $results->getFullyConfirmedProductIds () ) > 0) {
84
+ Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( sprintf ( $this->__ ( '%s of %s products were successfully exported' ), count ( $results->getFullyConfirmedProductIds () ), $collection->count () ) );
85
+ } else {
86
+ Mage::getSingleton ( 'adminhtml/session' )->addNotice ( $this->__ ( 'There were no products that could be exported.' ) );
87
+ }
88
+ } catch ( Dhl_MeinPaket_Model_Xml_XmlBuildException $xmlBuildException ) {
89
+ Mage::logException ( $xmlBuildException );
90
+ $exceptionMsg = $this->__ ( 'Product export failed. Request could not be built.' );
91
+ Mage::logException ( $xmlBuildException );
92
+ } catch ( Dhl_MeinPaket_Model_Client_HttpException $httpException ) {
93
+ Mage::logException ( $httpException );
94
+ $exceptionMsg = $this->__ ( 'Product export failed. Failed connecting to MeinPaket server.' );
95
+ Mage::logException ( $httpException );
96
+ } catch ( Exception $e ) {
97
+ Mage::logException ( $e );
98
+ $exceptionMsg = $this->__ ( 'Product export failed for unknown reason.' );
99
+ }
100
+
101
+ if (strlen ( $exceptionMsg ) > 0) {
102
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $exceptionMsg );
103
+ }
104
+
105
+ $this->_initAction ();
106
+ $block = $this->getLayout ()->getBlock ( 'meinpaket.adminhtml_productExport_export' );
107
+ /*
108
+ if ($results !== null) {
109
+ $block->setResults ( $results );
110
+ }
111
+ */
112
+ $this->renderLayout ();
113
+ }
114
+
115
+ /**
116
+ * Do nothin.
117
+ *
118
+ * @return void
119
+ */
120
+ public function emptyAction() {
121
+ $this->_initAction ();
122
+ $this->renderLayout ();
123
+ }
124
+
125
+ /**
126
+ * Returns a collection of the products which have to be exported.
127
+ *
128
+ * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
129
+ */
130
+ private function getProductCollection() {
131
+ /* @var $selectService Dhl_MeinPaket_Model_Service_Product_Export_Select */
132
+ $selectService = Mage::getModel ( 'meinpaket/service_product_export_select' );
133
+ $productselection = $this->getRequest ()->getParam ( 'productselection' );
134
+
135
+ if ($productselection == 2) {
136
+ return $selectService->getProductsForExport ( FALSE );
137
+ } else {
138
+ return $selectService->getProductsForExport ( TRUE );
139
+ }
140
+ }
141
+ }
app/code/community/Dhl/MeinPaket/etc/adminhtml.xml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <meinpaket>
5
+ <title>Allyouneed / Postpay</title>
6
+ <children>
7
+ <meinpaket_backlog translate="title" module="meinpaket">
8
+ <title>Synchronisation</title>
9
+ <action>meinpaket/adminhtml_backlog_product</action>
10
+ <depends>
11
+ <config>meinpaket/credentials/active</config>
12
+ </depends>
13
+ </meinpaket_backlog>
14
+ <meinpaket_categoryimport translate="title" module="meinpaket">
15
+ <title>import categories</title>
16
+ <action>meinpaket/adminhtml_categoryImport</action>
17
+ <depends>
18
+ <config>meinpaket/credentials/active</config>
19
+ </depends>
20
+ </meinpaket_categoryimport>
21
+ <meinpaket_bestprice translate="title" module="meinpaket">
22
+ <title>best prices</title>
23
+ <action>meinpaket/adminhtml_bestPrice</action>
24
+ <depends>
25
+ <config>meinpaket/credentials/active</config>
26
+ </depends>
27
+ </meinpaket_bestprice>
28
+ </children>
29
+ <sort_order>90</sort_order>
30
+ <class>meinpaket</class>
31
+ </meinpaket>
32
+ </menu>
33
+ <acl>
34
+ <resources>
35
+ <admin>
36
+ <children>
37
+ <system>
38
+ <children>
39
+ <config>
40
+ <children>
41
+ <meinpaket translate="title" module="meinpaket">
42
+ <title>Allyouneed / Postpay</title>
43
+ <sort_order>100</sort_order>
44
+ </meinpaket>
45
+ </children>
46
+ </config>
47
+ </children>
48
+ </system>
49
+ </children>
50
+ </admin>
51
+ </resources>
52
+ </acl>
53
+ </config>
app/code/community/Dhl/MeinPaket/etc/config.xml ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dhl_MeinPaket>
5
+ <version>2.2.0</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_exportProducts>
40
+ <schedule>
41
+ <config_path>meinpaket/cron/product</config_path>
42
+ </schedule>
43
+ <run>
44
+ <model>meinpaket/cron::exportProducts</model>
45
+ </run>
46
+ </meinpaket_exportProducts>
47
+ <meinpaket_getBestPrice>
48
+ <schedule>
49
+ <config_path>meinpaket/cron/bestprice</config_path>
50
+ </schedule>
51
+ <run>
52
+ <model>meinpaket/cron::getBestPrice</model>
53
+ </run>
54
+ </meinpaket_getBestPrice>
55
+ </jobs>
56
+ </crontab>
57
+ <default>
58
+ <meinpaket>
59
+ <checkout>
60
+ <available>0</available>
61
+ </checkout>
62
+ <product_attributes>
63
+ <default_delivery_time>5</default_delivery_time>
64
+ </product_attributes>
65
+ <cron>
66
+ <product>0 * * * *</product>
67
+ <order>*/15 * * * *</order>
68
+ <bestprice>15 3 * * *</bestprice>
69
+ </cron>
70
+ <advanced>
71
+ <cycle_product_count>100</cycle_product_count>
72
+ </advanced>
73
+ </meinpaket>
74
+ </default>
75
+ <frontend>
76
+ <translate>
77
+ <modules>
78
+ <meinpaket>
79
+ <files>
80
+ <default>Dhl_MeinPaket.csv</default>
81
+ </files>
82
+ </meinpaket>
83
+ </modules>
84
+ </translate>
85
+ <routers>
86
+ <meinpaket>
87
+ <use>standard</use>
88
+ <args>
89
+ <module>Dhl_MeinPaket</module>
90
+ <frontName>meinpaket</frontName>
91
+ </args>
92
+ </meinpaket>
93
+ </routers>
94
+ <layout>
95
+ <updates>
96
+ <meinpaket>
97
+ <file>meinpaket.xml</file>
98
+ </meinpaket>
99
+ </updates>
100
+ </layout>
101
+ </frontend>
102
+ <global>
103
+ <resources>
104
+ <meinpaket_setup>
105
+ <setup>
106
+ <module>Dhl_MeinPaket</module>
107
+ <class>Dhl_MeinPaket_Model_Resource_Eav_Mysql4_Setup</class>
108
+ </setup>
109
+ <connection>
110
+ <use>core_setup</use>
111
+ </connection>
112
+ </meinpaket_setup>
113
+ </resources>
114
+ <models>
115
+ <meinpaket>
116
+ <class>Dhl_MeinPaket_Model</class>
117
+ <resourceModel>meinpaket_mysql4</resourceModel>
118
+ </meinpaket>
119
+ <meinpaket_mysql4>
120
+ <class>Dhl_MeinPaket_Model_Mysql4</class>
121
+ <entities>
122
+ <category>
123
+ <table>meinpaket_category</table>
124
+ </category>
125
+ <backlog_product>
126
+ <table>meinpaket_backlog_product</table>
127
+ </backlog_product>
128
+ <bestprice>
129
+ <table>meinpaket_bestprice</table>
130
+ </bestprice>
131
+ <async>
132
+ <table>meinpaket_async</table>
133
+ </async>
134
+ </entities>
135
+ </meinpaket_mysql4>
136
+ </models>
137
+ <blocks>
138
+ <meinpaket>
139
+ <class>Dhl_MeinPaket_Block</class>
140
+ </meinpaket>
141
+ </blocks>
142
+ <helpers>
143
+ <!-- WTF? -->
144
+ <Dhl_MeinPaket>
145
+ <class>Dhl_MeinPaket_Helper</class>
146
+ </Dhl_MeinPaket>
147
+ <meinpaket>
148
+ <class>Dhl_MeinPaket_Helper</class>
149
+ </meinpaket>
150
+ </helpers>
151
+ <events>
152
+ <catalog_model_product_duplicate>
153
+ <observers>
154
+ <meinpaket_product_duplicate>
155
+ <type>singleton</type>
156
+ <class>meinpaket/observer</class>
157
+ <method>productDuplicate</method>
158
+ </meinpaket_product_duplicate>
159
+ </observers>
160
+ </catalog_model_product_duplicate>
161
+ <catalog_product_delete_before>
162
+ <observers>
163
+ <meinpaket_delete_product>
164
+ <type>singleton</type>
165
+ <class>meinpaket/observer</class>
166
+ <method>catalogProductDeleteBefore</method>
167
+ </meinpaket_delete_product>
168
+ </observers>
169
+ </catalog_product_delete_before>
170
+ <catalog_product_save_before>
171
+ <observers>
172
+ <meinpaket_product_save_before>
173
+ <type>singleton</type>
174
+ <class>meinpaket/observer</class>
175
+ <method>catalogProductSaveBefore</method>
176
+ </meinpaket_product_save_before>
177
+ </observers>
178
+ </catalog_product_save_before>
179
+ <catalog_product_save_after>
180
+ <observers>
181
+ <meinpaket_product_save_after>
182
+ <type>singleton</type>
183
+ <class>meinpaket/observer</class>
184
+ <method>catalogProductSaveAfter</method>
185
+ </meinpaket_product_save_after>
186
+ </observers>
187
+ </catalog_product_save_after>
188
+ <catalog_product_attribute_update_before>
189
+ <observers>
190
+ <meinpaket_product_attribute_update_before>
191
+ <type>singleton</type>
192
+ <class>meinpaket/observer</class>
193
+ <method>catalogProductAttributeUpdateBefore</method>
194
+ </meinpaket_product_attribute_update_before>
195
+ </observers>
196
+ </catalog_product_attribute_update_before>
197
+ <cataloginventory_stock_item_save_after>
198
+ <observers>
199
+ <meinpaket_stock_item_save_after>
200
+ <type>singleton</type>
201
+ <class>meinpaket/observer</class>
202
+ <method>catalogInventoryStockItemSaveAfter</method>
203
+ </meinpaket_stock_item_save_after>
204
+ </observers>
205
+ </cataloginventory_stock_item_save_after>
206
+ <adminhtml_catalog_product_attribute_edit_prepare_form>
207
+ <observers>
208
+ <add_meinpaket_to_attribute_editor>
209
+ <type>singleton</type>
210
+ <class>meinpaket/observer</class>
211
+ <method>addMeinPaketAttributes</method>
212
+ </add_meinpaket_to_attribute_editor>
213
+ </observers>
214
+ </adminhtml_catalog_product_attribute_edit_prepare_form>
215
+ </events>
216
+ </global>
217
+ </config>
app/code/community/Dhl/MeinPaket/etc/system.xml ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <meinpaket module="core" translate="label">
5
+ <groups>
6
+ <credentials translate="label">
7
+ <label>Credentials</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>1</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>0</show_in_store>
13
+ <frontend_class>allyouneed</frontend_class>
14
+ <fields>
15
+ <active translate="label comment">
16
+ <label>Allyouneed Active</label>
17
+ <comment><![CDATA[Disable Postpay using Configuration / Payment Methods / Postpay Standard and Postpay Express.]]></comment>
18
+ <frontend_type>select</frontend_type>
19
+ <source_model>adminhtml/system_config_source_yesno</source_model>
20
+ <sort_order>1</sort_order>
21
+ <show_in_default>1</show_in_default>
22
+ <show_in_website>1</show_in_website>
23
+ <show_in_store>0</show_in_store>
24
+ </active>
25
+ </fields>
26
+ </credentials>
27
+ <taxrates translate="label">
28
+ <label>Tax rates (nur Allyouneed)</label>
29
+ <frontend_type>text</frontend_type>
30
+ <sort_order>30</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>0</show_in_store>
34
+ <frontend_class>allyouneed</frontend_class>
35
+ <fields>
36
+ <default_tax_rate translate="label comment">
37
+ <label>Default tax rate</label>
38
+ <comment><![CDATA[The default tax rate applies to most products]]></comment>
39
+ <frontend_type>select</frontend_type>
40
+ <type>text</type>
41
+ <source_model>meinpaket/entity_attribute_source_taxclass</source_model>
42
+ <sort_order>10</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>0</show_in_store>
46
+ </default_tax_rate>
47
+ <reduced_tax_rate translate="label comment">
48
+ <label>Reduced tax rate</label>
49
+ <comment><![CDATA[The reduced tax rate applies to special products, such as aliments]]></comment>
50
+ <frontend_type>select</frontend_type>
51
+ <source_model>meinpaket/entity_attribute_source_taxclass</source_model>
52
+ <sort_order>20</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>0</show_in_store>
56
+ </reduced_tax_rate>
57
+ </fields>
58
+ </taxrates>
59
+ <product_attributes translate="label">
60
+ <label>Product attributes (only Allyouneed)</label>
61
+ <frontend_type>text</frontend_type>
62
+ <sort_order>40</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>0</show_in_store>
66
+ <frontend_class>allyouneed</frontend_class>
67
+ <fields>
68
+ <ean_attribute translate="label comment">
69
+ <label>EAN</label>
70
+ <comment><![CDATA[Product attribute containing EAN]]></comment>
71
+ <frontend_type>select</frontend_type>
72
+ <source_model>meinpaket/entity_attribute_source_productAttribute</source_model>
73
+ <sort_order>1</sort_order>
74
+ <show_in_default>1</show_in_default>
75
+ <show_in_website>1</show_in_website>
76
+ <show_in_store>0</show_in_store>
77
+ </ean_attribute>
78
+ <delivery_time translate="label comment">
79
+ <label>Delivery time attribute</label>
80
+ <comment><![CDATA[Please select the product attribute which represents the approx. delivery time]]></comment>
81
+ <frontend_type>select</frontend_type>
82
+ <source_model>meinpaket/entity_attribute_source_productAttribute</source_model>
83
+ <sort_order>10</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>1</show_in_website>
86
+ <show_in_store>0</show_in_store>
87
+ </delivery_time>
88
+ <default_delivery_time translate="label comment">
89
+ <label>Default delivery time</label>
90
+ <comment><![CDATA[Delivery time in days if no other delivery time applies]]></comment>
91
+ <frontend_type>text</frontend_type>
92
+ <validate>validate-digits</validate>
93
+ <sort_order>20</sort_order>
94
+ <show_in_default>1</show_in_default>
95
+ <show_in_website>1</show_in_website>
96
+ <show_in_store>0</show_in_store>
97
+ </default_delivery_time>
98
+ <use_available_special_price translate="label comment">
99
+ <label>Use special price if available</label>
100
+ <comment><![CDATA[Use product special price if available]]></comment>
101
+ <frontend_type>select</frontend_type>
102
+ <source_model>adminhtml/system_config_source_yesno</source_model>
103
+ <sort_order>30</sort_order>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_website>1</show_in_website>
106
+ <show_in_store>0</show_in_store>
107
+ </use_available_special_price>
108
+ </fields>
109
+ </product_attributes>
110
+ <customer translate="label">
111
+ <label>Customer (nur Allyouneed)</label>
112
+ <frontend_type>text</frontend_type>
113
+ <sort_order>50</sort_order>
114
+ <show_in_default>1</show_in_default>
115
+ <show_in_website>1</show_in_website>
116
+ <show_in_store>0</show_in_store>
117
+ <frontend_class>allyouneed</frontend_class>
118
+ <fields>
119
+ <default_email translate="label comment">
120
+ <label>Default customer email</label>
121
+ <comment><![CDATA[This eMail address is used as the default one for orders that do not include one.]]></comment>
122
+ <frontend_type>text</frontend_type>
123
+ <validate>validate-email</validate>
124
+ <sort_order>10</sort_order>
125
+ <show_in_default>1</show_in_default>
126
+ <show_in_website>1</show_in_website>
127
+ <show_in_store>0</show_in_store>
128
+ </default_email>
129
+ </fields>
130
+ </customer>
131
+ <cron translate="label">
132
+ <label>Cron</label>
133
+ <frontend_type>text</frontend_type>
134
+ <sort_order>100</sort_order>
135
+ <show_in_default>1</show_in_default>
136
+ <show_in_website>1</show_in_website>
137
+ <show_in_store>0</show_in_store>
138
+ <frontend_class>allyouneed</frontend_class>
139
+ <fields>
140
+ <product translate="label comment">
141
+ <label>Product Export (only Allyouneed)</label>
142
+ <comment><![CDATA[Product export interval]]></comment>
143
+ <frontend_type>text</frontend_type>
144
+ <sort_order>100</sort_order>
145
+ <show_in_default>1</show_in_default>
146
+ <show_in_website>1</show_in_website>
147
+ <show_in_store>0</show_in_store>
148
+ </product>
149
+ <bestprice translate="label comment">
150
+ <label>BestPrice Interval (only Allyouneed)</label>
151
+ <comment><![CDATA[BestPrice refresh interval.]]></comment>
152
+ <frontend_type>text</frontend_type>
153
+ <sort_order>110</sort_order>
154
+ <show_in_default>1</show_in_default>
155
+ <show_in_website>1</show_in_website>
156
+ <show_in_store>0</show_in_store>
157
+ </bestprice>
158
+ </fields>
159
+ </cron>
160
+ <advanced translate="label">
161
+ <label>Advanced (only Allyouneed)</label>
162
+ <frontend_type>text</frontend_type>
163
+ <sort_order>150</sort_order>
164
+ <show_in_default>1</show_in_default>
165
+ <show_in_website>1</show_in_website>
166
+ <show_in_store>0</show_in_store>
167
+ <frontend_class>allyouneed</frontend_class>
168
+ <fields>
169
+ <cycle_product_count translate="label comment">
170
+ <label>Cycle product count</label>
171
+ <comment><![CDATA[Count of products transfered during a single cycle]]></comment>
172
+ <frontend_type>text</frontend_type>
173
+ <validate>validate-digits</validate>
174
+ <sort_order>15</sort_order>
175
+ <show_in_default>1</show_in_default>
176
+ <show_in_website>1</show_in_website>
177
+ <show_in_store>0</show_in_store>
178
+ </cycle_product_count>
179
+ </fields>
180
+ </advanced>
181
+ </groups>
182
+ </meinpaket>
183
+ </sections>
184
+ </config>
185
+
app/code/community/Dhl/MeinPaket/sql/meinpaket_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 = "Allyouneed";
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
+ // Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( 'DHL Allyouneed extension was successfully installed!' );
26
+
27
+ $installer->installEntities ();
28
+ $installer->endSetup ();
app/code/community/Dhl/MeinPaket/sql/meinpaket_setup/mysql4-upgrade-1.0.0-1.1.0.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
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
+ $installer->endSetup ();
app/code/community/Dhl/MeinPaket/sql/meinpaket_setup/mysql4-upgrade-1.1.0-2.0.0.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $installer->run ( "
10
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/category')};
11
+ CREATE TABLE {$this->getTable('meinpaket/category')} (
12
+ `category_id` int(10) unsigned not null auto_increment,
13
+ `name` varchar(255) not null,
14
+ `code` varchar(255) not null,
15
+ `parent` varchar(255) not null,
16
+ `leaf` tinyint(1) unsigned not null ,
17
+ PRIMARY KEY (`category_id`)
18
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Allyouneed Categories';
19
+ " );
20
+
21
+ $installer->run ( "
22
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/backlog_product')};
23
+ CREATE TABLE {$this->getTable('meinpaket/backlog_product')} (
24
+ `backlog_id` int(11) unsigned NOT NULL auto_increment,
25
+ `product_id` int(10) unsigned NOT NULL,
26
+ `changes` text default '',
27
+ `created_at` datetime default '0000-00-00 00:00:00',
28
+ PRIMARY KEY(`backlog_id`),
29
+ 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
30
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Allyouneed Backlog';
31
+ " );
32
+
33
+ $installer->run ( "
34
+ DROP TABLE IF EXISTS {$this->getTable('meinpaket/bestprice')};
35
+ CREATE TABLE {$this->getTable('meinpaket/bestprice')} (
36
+ `bestprice_id` int(11) unsigned NOT NULL auto_increment,
37
+ `product_id` int(10) unsigned NOT NULL,
38
+ `price` decimal(12,4),
39
+ `price_currency` varchar(255),
40
+ `delivery_cost` decimal(12,4),
41
+ `delivery_cost_currency` varchar(255),
42
+ `delivery_time` int(10),
43
+ `active_offers` int(10),
44
+ `ownership` varchar(255),
45
+ `owning_dealer_code` varchar(255),
46
+ `created_at` datetime default '0000-00-00 00:00:00',
47
+ PRIMARY KEY(`bestprice_id`),
48
+ CONSTRAINT `FK_MEINPAKET_BESTPRICE_PRODUCT_ID` FOREIGN KEY (`product_id`) REFERENCES {$installer->getTable('catalog_product_entity')} (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE
49
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Allyouneed BestPrices';
50
+ " );
51
+
52
+ $installer->getConnection ()->addColumn ( $installer->getTable ( 'catalog/eav_attribute' ), 'meinpaket_attribute', "VARCHAR( 255 ) DEFAULT 'None' COMMENT 'Allyouneed Attribute'" );
53
+
54
+ $installer->endSetup ();
app/code/community/Dhl/MeinPaket/sql/meinpaket_setup/mysql4-upgrade-2.1.0-2.2.0.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
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
+ $installer->endSetup ();
app/code/community/Dhl/MeinPaketCommon/Block/Adminhtml/Async.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_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 = 'meinpaketcommon';
8
+ $this->_controller = 'adminhtml_async';
9
+ $this->_headerText = Mage::helper ( 'meinpaketcommon' )->__ ( '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 ( 'meinpaketcommon' )->__ ( '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/MeinPaketCommon/Block/Adminhtml/Async/Grid.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Block_Adminhtml_Async_Grid extends Mage_Adminhtml_Block_Widget_Grid {
3
+ public function __construct() {
4
+ parent::__construct ();
5
+ $this->setId ( 'meinpaketcommon_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 ( 'meinpaketcommon/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 ( 'meinpaketcommon' )->__ ( 'ID' ),
19
+ 'type' => 'number',
20
+ 'index' => 'async_id'
21
+ ) );
22
+
23
+ $this->addColumn ( 'request_id', array (
24
+ 'header' => Mage::helper ( 'meinpaketcommon' )->__ ( 'Request ID' ),
25
+ 'index' => 'request_id'
26
+ ) );
27
+
28
+ $this->addColumn ( 'status', array (
29
+ 'header' => Mage::helper ( 'meinpaketcommon' )->__ ( 'Status' ),
30
+ 'index' => 'status'
31
+ ) );
32
+
33
+ $this->addColumn ( 'created_at', array (
34
+ 'header' => Mage::helper ( 'meinpaketcommon' )->__ ( 'Created At' ),
35
+ 'type' => 'datetime',
36
+ 'index' => 'created_at'
37
+ ) );
38
+
39
+ $this->addColumn ( 'updated_at', array (
40
+ 'header' => Mage::helper ( 'meinpaketcommon' )->__ ( 'Updated At' ),
41
+ 'type' => 'datetime',
42
+ 'index' => 'updated_at'
43
+ ) );
44
+
45
+ $this->addExportType ( '*/*/exportExcel', Mage::helper ( 'meinpaketcommon' )->__ ( '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 ( 'meinpaketcommon' )->__ ( 'Delete' ),
54
+ 'url' => $this->getUrl ( '*/*/massDelete', array () ),
55
+ 'confirm' => Mage::helper ( 'meinpaketcommon' )->__ ( '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/MeinPaketCommon/Block/Adminhtml/Log.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_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 = 'meinpaketcommon';
8
+ $this->_controller = 'adminhtml_log';
9
+ $this->_headerText = Mage::helper ( 'meinpaketcommon' )->__ ( 'Log' );
10
+ parent::__construct ();
11
+ }
12
+ /**
13
+ * Prepare layout
14
+ *
15
+ * @return Dhl_MeinPaketCommon_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/MeinPaketCommon/Block/Adminhtml/Log/Grid.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Block_Adminhtml_Log_Grid extends Mage_Adminhtml_Block_Widget_Grid {
3
+ public function __construct() {
4
+ parent::__construct ();
5
+ $this->setId ( 'meinpaketcommon_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 ( 'meinpaketcommon/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 ( 'meinpaketcommon' )->__ ( 'ID' ),
19
+ 'type' => 'number',
20
+ 'index' => 'log_id'
21
+ ) );
22
+
23
+ $this->addColumn ( 'request_id', array (
24
+ 'header' => Mage::helper ( 'meinpaketcommon' )->__ ( 'Request ID' ),
25
+ 'index' => 'request_id'
26
+ ) );
27
+
28
+ $this->addColumn ( 'send', array (
29
+ 'header' => Mage::helper ( 'meinpaketcommon' )->__ ( 'Send' ),
30
+ 'index' => 'send'
31
+ ) );
32
+
33
+ $this->addColumn ( 'received', array (
34
+ 'header' => Mage::helper ( 'meinpaketcommon' )->__ ( 'Received' ),
35
+ 'index' => 'received'
36
+ ) );
37
+
38
+ $this->addColumn ( 'error', array (
39
+ 'header' => Mage::helper ( 'meinpaketcommon' )->__ ( 'Error' ),
40
+ 'index' => 'error'
41
+ ) );
42
+
43
+ $this->addColumn ( 'created_at', array (
44
+ 'header' => Mage::helper ( 'meinpaketcommon' )->__ ( 'Created At' ),
45
+ 'type' => 'datetime',
46
+ 'index' => 'created_at'
47
+ ) );
48
+
49
+ $this->addExportType ( '*/*/exportExcel', Mage::helper ( 'meinpaketcommon' )->__ ( '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 ( 'meinpaketcommon' )->__ ( 'Delete' ),
58
+ 'url' => $this->getUrl ( '*/*/massDelete', array () ),
59
+ 'confirm' => Mage::helper ( 'meinpaketcommon' )->__ ( 'Are you sure?' )
60
+ ) );
61
+
62
+ return $this;
63
+ }
64
+ public function getGridUrl() {
65
+ return $this->getUrl ( '*/*/grid', array (
66
+ '_current' => true
67
+ ) );
68
+ }
69
+ }
app/code/community/Dhl/MeinPaketCommon/Block/Adminhtml/Version.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Block_Adminhtml_Version extends Mage_Adminhtml_Block_System_Config_Form_Field {
3
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
4
+ return ( string ) Mage::helper ( 'meinpaketcommon/data' )->getExtensionVersion ();
5
+ }
6
+ }
app/code/community/Dhl/MeinPaketCommon/Helper/Address.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Default helper for the Dhl_MeinPaket package.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Helper
9
+ */
10
+ class Dhl_MeinPaketCommon_Helper_Address extends Mage_Core_Helper_Abstract {
11
+ const STREET_HOUSENUMBER = '/^(?P<street>\D+)\s*(?P<houseNumber>\d.*)$/';
12
+ const HOUSENUMBER_STREET = '/^(?P<houseNumber>\d\S*)\s*(?P<street>\D.*)$/';
13
+
14
+ /**
15
+ * Parse address and return array with keys "street" and "houseNumber".
16
+ *
17
+ * @return array
18
+ */
19
+ public function parseAddress(Mage_Sales_Model_Order_Address $address) {
20
+ return $this->parseStreetHouseNumber ( $address->getStreet1 () );
21
+ }
22
+
23
+ /**
24
+ * Parse address and return array with keys "street" and "houseNumber".
25
+ *
26
+ * @return array
27
+ */
28
+ public function parseStreetHouseNumber($address) {
29
+ if ($address == null) {
30
+ return null;
31
+ }
32
+
33
+ $matches = null;
34
+
35
+ if (preg_match ( self::STREET_HOUSENUMBER, $address, $matches )) {
36
+ return $matches;
37
+ }
38
+
39
+ if (preg_match ( self::HOUSENUMBER_STREET, $address, $matches )) {
40
+ return $matches;
41
+ }
42
+
43
+ return array (
44
+ 0 => $address,
45
+ 1 => $address,
46
+ 2 => "",
47
+ "street" => $address,
48
+ "houseNumber" => ""
49
+ );
50
+ }
51
+ }
app/code/community/Dhl/MeinPaketCommon/Helper/Attribute.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Helper_Attribute extends Mage_Core_Helper_Abstract {
3
+ protected $_ignoredAttributeCodes = array (
4
+ 'status'
5
+ );
6
+ public function isExportableAttribute(Mage_Catalog_Model_Resource_Eav_Attribute $attribute) {
7
+ $isExportable = false;
8
+ $data = $attribute->getData ( '' );
9
+
10
+ if (! in_array ( $data ['attribute_code'], $this->_ignoredAttributeCodes ) && (! array_key_exists ( 'is_configurable', $data ) || $data ['is_configurable'])) {
11
+ $isExportable = true;
12
+ }
13
+
14
+ return $isExportable;
15
+ }
16
+ }
app/code/community/Dhl/MeinPaketCommon/Helper/Cron.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_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_MeinPaketCommon_Model_Cron::SYNC_CATALOG :
45
+ $res = Mage::getSingleton ( 'meinpaket/service_product_export' )->exportProducts ();
46
+ break;
47
+ case Dhl_MeinPaketCommon_Model_Cron::SYNC_ORDERS :
48
+ $res = Mage::getSingleton ( 'meinpaketcommon/service_order_importService' )->importOrders ();
49
+ break;
50
+ case Dhl_MeinPaketCommon_Model_Cron::SYNC_ASYNC :
51
+ $res = Mage::getSingleton ( 'meinpaketcommon/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/MeinPaketCommon/Helper/Data.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Default helper for the Dhl_MeinPaket package.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Helper
9
+ */
10
+ class Dhl_MeinPaketCommon_Helper_Data extends Mage_Core_Helper_Abstract {
11
+ /**
12
+ * Creates/extends JavaScript language object by the given labels.
13
+ * The given labels array must have the structure array('key1'=>'label1','key2'=>'label2',...).
14
+ * Key is the key under which the label will be accessible in frontend JavaScript.
15
+ * Label is the untranslated label.
16
+ * Example: Element is 'foo'=>'Bar'. So use MeinPaket.locale.foo .
17
+ *
18
+ * @param array $labels
19
+ * @return string
20
+ */
21
+ public function createLocaleJS(array $labels) {
22
+ $js = 'if(typeof MeinPaket === "undefined"){var MeinPaket={};}';
23
+ $js .= 'if(typeof MeinPaket.locale === "undefined"){MeinPaket.locale={};}';
24
+ $js .= 'Object.extend(MeinPaket.locale,{';
25
+
26
+ $firstItem = true;
27
+ if (sizeof ( $labels ) > 0) {
28
+ foreach ( $labels as $key => $label ) {
29
+ $js .= $this->_addJSLocaleLabel ( $key, $this->__ ( $label ), $firstItem );
30
+ if ($firstItem) {
31
+ $firstItem = false;
32
+ }
33
+ }
34
+ }
35
+
36
+ $js .= '});';
37
+
38
+ return $js;
39
+ }
40
+
41
+ /**
42
+ * Creates a json property.
43
+ *
44
+ * @param string $key
45
+ * @param string $label
46
+ * @param boolean $isFirst
47
+ * Tells if the label is the first in the list.
48
+ * @return string
49
+ */
50
+ protected function _addJSLocaleLabel($key, $label, $isFirst = false) {
51
+ $labelProperty = '';
52
+
53
+ if (! $isFirst) {
54
+ $labelProperty .= ',';
55
+ }
56
+
57
+ $labelProperty .= $key . ':"' . $label . '"';
58
+
59
+ return $labelProperty;
60
+ }
61
+ public function getExtensionVersion() {
62
+ return ( string ) Mage::getConfig ()->getModuleConfig ( 'Dhl_MeinPaketCommon' )->version;
63
+ }
64
+ const STORE_VIEW_CONFIG = 'meinpaket/store/view';
65
+ private $_meinpaketStore = null;
66
+ private $_meinpaketRootCategory = null;
67
+ public function getMeinPaketStore() {
68
+ if ($this->_meinpaketStore == null) {
69
+ $this->_meinpaketStore = Mage::app ()->getStore ( Mage::getStoreConfig ( self::STORE_VIEW_CONFIG ) );
70
+ }
71
+ return $this->_meinpaketStore;
72
+ }
73
+ public function getMeinPaketStoreId() {
74
+ $store = $this->getMeinPaketStore ();
75
+ if ($store == null) {
76
+ return null;
77
+ } else {
78
+ return $store->getId ();
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Get filtered quote from session.
84
+ *
85
+ * @return NULL|Mage_Sales_Model_Quote
86
+ */
87
+ public function getQuoteFiltered() {
88
+ $quote = Mage::getSingleton ( 'checkout/session' )->getQuote ();
89
+ /* @var $quote Mage_Sales_Model_Quote */
90
+
91
+ if ($quote === null) {
92
+ return null;
93
+ }
94
+
95
+ foreach ( $quote->getAllVisibleItems () as $item ) {
96
+ if (! $this->checkItem ( $item )) {
97
+ return null;
98
+ }
99
+ }
100
+
101
+ return $quote;
102
+ }
103
+
104
+ /**
105
+ * Get filtered quote from session.
106
+ *
107
+ * @return boolean
108
+ */
109
+ public function checkItem(Mage_Sales_Model_Order_Item $item) {
110
+ $options = Mage::helper ( 'catalog/product_configuration' )->getCustomOptions ( $item );
111
+ // $options = $item->getProduct ()->getTypeInstance ( true )->getOrderOptions ( $item->getProduct () );
112
+
113
+ if (count ( $options ) || $item->getIsNominal () || $item->getIsVirtual () || $item->getIsRecurring ()) {
114
+ return false;
115
+ }
116
+ // Mage::log ( Zend_Debug::dump ( $options ) );
117
+
118
+ if ($item->getParentItemId ()) {
119
+ true;
120
+ }
121
+
122
+ if ($item->getProduct ()->isVirtual () || $item->getProduct ()->isRecurring ()) {
123
+ return false;
124
+ }
125
+
126
+ return true;
127
+ }
128
+ }
app/code/community/Dhl/MeinPaketCommon/Helper/Order.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Helper_Order extends Mage_Core_Helper_Abstract {
12
+ /**
13
+ * Tells if the given order is an order that was imported from Allyouneed.
14
+ *
15
+ * @param Mage_Sales_Model_Order $order
16
+ * @return boolean
17
+ */
18
+ public function isMeinPaketOrder(Mage_Sales_Model_Order $order) {
19
+ return ($order->hasData ( 'dhl_mein_paket_order_id' ) && $order->getData ( 'dhl_mein_paket_order_id' ));
20
+ }
21
+ }
app/code/community/Dhl/MeinPaketCommon/Helper/Product.php ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_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_MeinPaketCommon_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 ) && $this->_eanValidator->isValid ( $product->getData ( $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 stock count of the product which can be used for MeinPaket.
154
+ *
155
+ * @param Mage_Catalog_Model_Product $product
156
+ * @return integer
157
+ */
158
+ public function getMeinPaketStock(Mage_Catalog_Model_Product $product) {
159
+ $customDhlMeinPaketStock = 0;
160
+ $hasCustomMeinPaketStock = false;
161
+ $defaultStock = 0;
162
+ $stock = 0;
163
+
164
+ if ($product->hasData ( 'max_stock_for_dhl_mein_paket' )) {
165
+ $hasCustomMeinPaketStock = (strlen ( $product->getMaxStockForDhlMeinPaket () ) > 0);
166
+ $customDhlMeinPaketStock = ( integer ) $product->getMaxStockForDhlMeinPaket ();
167
+ }
168
+
169
+ /* @var $stockItem Mage_CatalogInventory_Model_Stock_Item */
170
+ $stockItem = Mage::getModel ( 'cataloginventory/stock_item' )->loadByProduct ( $product->getId () );
171
+
172
+ if (! $stockItem->getIsInStock ()) {
173
+ return 0;
174
+ }
175
+
176
+ $defaultStock = ( integer ) $stockItem->getQty ();
177
+
178
+ if ($hasCustomMeinPaketStock && is_integer ( $customDhlMeinPaketStock ) && $customDhlMeinPaketStock >= 0) {
179
+ $stock = $customDhlMeinPaketStock;
180
+ if ($stock > $defaultStock) {
181
+ $stock = $defaultStock;
182
+ }
183
+ } else {
184
+ $stock = $defaultStock;
185
+ }
186
+
187
+ return $stock;
188
+ }
189
+
190
+ /**
191
+ * Returns a date from which on the product won't be available on MeinPaket
192
+ * anymore.
193
+ *
194
+ * @param Mage_Catalog_Model_Product $product
195
+ * @return Zend_Date
196
+ */
197
+ public function getMeinPaketEndDate(Mage_Catalog_Model_Product $product) {
198
+ $endDate = new Zend_Date ();
199
+
200
+ if ($product->getStatus () == Mage_Catalog_Model_Product_Status::STATUS_DISABLED/* ||
201
+ $product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE*/
202
+ ) {
203
+ $endDate->setTimestamp ( time () - 86400 );
204
+ } else {
205
+ $endDate->setTimestamp ( time () + 31536000 );
206
+ }
207
+
208
+ return $endDate;
209
+ }
210
+
211
+ /**
212
+ * Returns the delivery time for orders from MeinPaket for the given product.
213
+ *
214
+ * @param Mage_Catalog_Model_Product $product
215
+ * @return integer The delivery time in days
216
+ */
217
+ public function getMeinPaketDeliveryTime(Mage_Catalog_Model_Product $product) {
218
+ $attributeId = Mage::getStoreConfig ( 'meinpaket/product_attributes/delivery_time' );
219
+ $deliveryTime = Mage::getStoreConfig ( 'meinpaket/product_attributes/default_delivery_time' );
220
+
221
+ if (strlen ( $attributeId ) > 0 && $product->hasData ( $attributeId ) && @preg_match ( "/^[0-9]+$/", $product->getData ( $attributeId ) )) {
222
+ $deliveryTime = $product->getData ( $attributeId );
223
+ }
224
+
225
+ return $deliveryTime;
226
+ }
227
+
228
+ /**
229
+ * Returns the parent configurable product of the given product.
230
+ * Returns null if the given product isn't a simple one or it has
231
+ * no parent configurable.
232
+ *
233
+ * @param Mage_Catalog_Model_Product $simpleProduct
234
+ * @return Mage_Catalog_Model_Product
235
+ */
236
+ public function getParentConfigurable(Mage_Catalog_Model_Product $simpleProduct) {
237
+ $parentConfigurable = null;
238
+
239
+ if ($simpleProduct->getTypeId () === Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
240
+ $parentIds = Mage::getModel ( 'catalog/product_type_configurable' )->getParentIdsByChild ( $simpleProduct->getId () );
241
+ if (isset ( $parentIds [0] )) {
242
+ $parentConfigurable = Mage::getModel ( 'catalog/product' )->load ( $parentIds [0] );
243
+ }
244
+ }
245
+
246
+ return $parentConfigurable;
247
+ }
248
+
249
+ /**
250
+ * Returns an translated error description.
251
+ *
252
+ * @param string $errorType
253
+ * @param string $errorCode
254
+ * @return string
255
+ */
256
+ public function getErrorDescription($errorType, $errorCode = '') {
257
+ $description = '';
258
+
259
+ switch ($errorType) {
260
+ case Dhl_MeinPaketCommon_Model_Validation_ValidationInterface::ERROR_FIELD_IS_INVALID :
261
+ $description = $this->__ ( 'Invalid value for field' ) . ' "<i><b>' . $this->__ ( $this->getLabelForFieldName ( $errorCode ) ) . '</b></i>".';
262
+ break;
263
+ case Dhl_MeinPaketCommon_Model_Validation_ValidationInterface::ERROR_REQUIRED_FIELD_IS_EMPTY :
264
+ $description = $this->__ ( 'Missing value for field' ) . ' "<i><b>' . $this->__ ( $this->getLabelForFieldName ( $errorCode ) ) . '</b></i>".';
265
+ break;
266
+ case Dhl_MeinPaketCommon_Model_Validation_ValidationInterface::ERROR_PRODUCT_NOT_EXISTS_IN_MEINPAKET :
267
+ $description = $this->__ ( 'Product is unknown in MeinPaket marketplace' ) . '.';
268
+ break;
269
+ case Dhl_MeinPaketCommon_Model_Validation_ValidationInterface::ERROR_PRODUCT_NEGATIVE_STOCK :
270
+ $description = $this->__ ( 'Product stock is lower than zero.' );
271
+ break;
272
+ case Dhl_MeinPaketCommon_Model_Validation_ValidationInterface::ERROR_MEINPAKET_SERVER_ERROR :
273
+ $description = $this->__ ( 'Internal error on MeinPaket server' ) . '.';
274
+ break;
275
+ case Dhl_MeinPaketCommon_Model_Validation_ValidationInterface::ERROR_NOT_AUTHORIZED :
276
+ $description = $this->__ ( 'You are not authorized to execute the requested functionality on MeinPaket' );
277
+ break;
278
+ case Dhl_MeinPaketCommon_Model_Validation_ValidationInterface::ERROR_INVALID_DATA :
279
+ $description = $this->__ ( 'The provided data was incorrect' );
280
+ break;
281
+ case Dhl_MeinPaketCommon_Model_Validation_ValidationInterface::ERROR_INVALID_MODIFICATION :
282
+ $description = $this->__ ( 'Invalid modification of element' );
283
+ break;
284
+ case Dhl_MeinPaketCommon_Model_Validation_ValidationInterface::ERROR_NO_CATEGORIZATION :
285
+ $description = $this->__ ( 'The product is not mapped to neither a marketplace nor a shop category' );
286
+ break;
287
+ case Dhl_MeinPaketCommon_Model_Validation_ValidationInterface::ERROR_PRODUCT_NOT_SELLABLE :
288
+ $description = $this->__ ( 'The referenced product cannot be sold' );
289
+ break;
290
+ case Dhl_MeinPaketCommon_Model_Validation_ValidationInterface::ERROR_MARKETPLACE_CATEGORY_NOT_FOUND :
291
+ $description = $this->__ ( 'The referenced marketplace category could not be found at MeinPaket' );
292
+ break;
293
+ case Dhl_MeinPaketCommon_Model_Validation_ValidationInterface::ERROR_SHOP_CATEGORY_NOT_FOUND :
294
+ $description = $this->__ ( 'The referenced shop category could not be found at MeinPaket' );
295
+ break;
296
+ case Dhl_MeinPaketCommon_Model_Validation_ValidationInterface::ERROR_MISSING_VALUE_FOR_ATTRIBUTE :
297
+ $description = $this->__ ( 'Missing value mapping for attribute' ) . ' "' . $errorCode . '".';
298
+ break;
299
+ case Dhl_MeinPaketCommon_Model_Validation_ValidationInterface::ERROR_VARIANT_GROUP_NOT_EXISTS :
300
+ $description = $this->__ ( 'Variant group does not exist on MeinPaket' ) . ' "' . $errorCode . '".';
301
+ break;
302
+ case Dhl_MeinPaketCommon_Model_Validation_ValidationInterface::ERROR_UNDEFINED :
303
+ default :
304
+ $description = $this->__ ( 'Undefined Error' );
305
+ }
306
+
307
+ return $description;
308
+ }
309
+
310
+ /**
311
+ * Returns the frontend label for a given attribute.
312
+ *
313
+ * @param string $fieldName
314
+ * @return string
315
+ */
316
+ public function getLabelForFieldName($fieldName) {
317
+ $productAttributeModel = Mage::getModel ( 'eav/config' )->getAttribute ( 'catalog_product', $fieldName );
318
+ $categoryAttributeModel = Mage::getModel ( 'eav/config' )->getAttribute ( 'catalog_category', $fieldName );
319
+
320
+ $label = $productAttributeModel->getFrontendLabel ();
321
+
322
+ if (! ( bool ) $label)
323
+ $label = $categoryAttributeModel->getFrontendLabel ();
324
+
325
+ if (! ( bool ) $label)
326
+ $label = $fieldName;
327
+
328
+ return $label;
329
+ }
330
+ }
app/code/community/Dhl/MeinPaketCommon/Helper/Shipment.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Helper_Shipment extends Mage_Core_Helper_Abstract {
12
+ /**
13
+ * Tells if the given order is an order that was imported from Allyouneed.
14
+ *
15
+ * @param Mage_Sales_Model_Order_Shipment $shipment
16
+ * to check
17
+ * @return boolean
18
+ */
19
+ public function isMeinPaketShipment(Mage_Sales_Model_Order_Shipment $shipment) {
20
+ $paymentMethodCode = $shipment->getOrder ()->getPayment ()->getMethodInstance ()->getCode ();
21
+
22
+ if ($paymentMethodCode == 'postpay') {
23
+ return false;
24
+ }
25
+
26
+ return Mage::helper ( 'meinpaket/order' )->isMeinPaketOrder ( $shipment->getOrder () );
27
+ }
28
+
29
+ /**
30
+ * Tells if the given $shipment is exported to MeinPaket
31
+ *
32
+ * @param Mage_Sales_Model_Order_Shipment $shipment
33
+ * to be shipped
34
+ * @return boolean
35
+ */
36
+ public function isExportedToDhlMeinPaket(Mage_Sales_Model_Order_Shipment $shipment) {
37
+ return $shipment->hasData ( 'shipment_was_exported_for_dhl_mein_paket' ) && $shipment->getData ( 'shipment_was_exported_for_dhl_mein_paket' );
38
+ }
39
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Async.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Model_Async extends Mage_Core_Model_Abstract {
3
+ public function _construct() {
4
+ parent::_construct ();
5
+ $this->_init ( 'meinpaketcommon/async' );
6
+ }
7
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Carrier/Allyouneed.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
+ */
10
+ class Dhl_MeinPaketCommon_Model_Carrier_Allyouneed extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface {
11
+ /**
12
+ *
13
+ * @var string
14
+ */
15
+ protected $_code = 'allyouneed';
16
+
17
+ /**
18
+ *
19
+ * @var float
20
+ */
21
+ protected static $_deliveryCosts = 0.0;
22
+
23
+ /**
24
+ * Tells if the carrier is locked for use.
25
+ *
26
+ * @var boolean
27
+ */
28
+ protected static $_isLocked = true;
29
+
30
+ /**
31
+ * Locks the carrier for use.
32
+ *
33
+ * @return void
34
+ */
35
+ public static function lock() {
36
+ self::$_isLocked = true;
37
+ }
38
+
39
+ /**
40
+ * Unlocks the carrier for use.
41
+ *
42
+ * @return void
43
+ */
44
+ public static function unlock() {
45
+ self::$_isLocked = false;
46
+ }
47
+
48
+ /**
49
+ * Returns the allowed methods for this carrier.
50
+ *
51
+ * @see Mage_Shipping_Model_Carrier_Interface::getAllowedMethods()
52
+ * @return array
53
+ */
54
+ public function getAllowedMethods() {
55
+ return array (
56
+ 'standard' => 'Allyouneed',
57
+ 'method1' => 'Allyouneed'
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 ( 'method' );
93
+ $method->setMethodTitle ( 'Allyouneed' );
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/MeinPaketCommon/Model/Carrier/Meinpaket.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
10
+ class Dhl_MeinPaketCommon_Model_Carrier_Meinpaket extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface {
11
+ /**
12
+ *
13
+ * @var string
14
+ */
15
+ protected $_code = 'meinpaket';
16
+
17
+ /**
18
+ *
19
+ * @var float
20
+ */
21
+ protected static $_deliveryCosts = 0.0;
22
+
23
+ /**
24
+ * Tells if the carrier is locked for use.
25
+ *
26
+ * @var boolean
27
+ */
28
+ protected static $_isLocked = true;
29
+
30
+ /**
31
+ * Locks the carrier for use.
32
+ *
33
+ * @return void
34
+ */
35
+ public static function lock() {
36
+ self::$_isLocked = true;
37
+ }
38
+
39
+ /**
40
+ * Unlocks the carrier for use.
41
+ *
42
+ * @return void
43
+ */
44
+ public static function unlock() {
45
+ self::$_isLocked = false;
46
+ }
47
+
48
+ /**
49
+ * Returns the allowed methods for this carrier.
50
+ *
51
+ * @see Mage_Shipping_Model_Carrier_Interface::getAllowedMethods()
52
+ * @return array
53
+ */
54
+ public function getAllowedMethods() {
55
+ return array (
56
+ 'standard' => 'MeinPaket',
57
+ 'method1' => 'MeinPaket'
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
+ /**
73
+ * Determine whether current carrier enabled for activity
74
+ *
75
+ * @return bool
76
+ */
77
+ public function isActive()
78
+ {
79
+ return false;
80
+ }
81
+
82
+
83
+ /**
84
+ * Collect the rates.
85
+ *
86
+ * @see Mage_Shipping_Model_Carrier_Abstract::collectRates()
87
+ * @param Mage_Shipping_Model_Rate_Request $request
88
+ * @return Mage_Shipping_Model_Rate_Result
89
+ */
90
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
91
+ // avoid usage as a general carrier method
92
+ if (self::$_isLocked) {
93
+ return false;
94
+ }
95
+
96
+ /* @var $result Mage_Shipping_Model_Rate_Result */
97
+ $result = Mage::getModel ( 'shipping/rate_result' );
98
+
99
+ /* @var $method Mage_Shipping_Model_Rate_Result_Method */
100
+ $method = Mage::getModel ( 'shipping/rate_result_method' );
101
+
102
+ $method->setCarrier ( $this->_code );
103
+ $method->setCarrierTitle ( $this->getConfigData ( 'title' ) );
104
+ $method->setMethod ( 'method' );
105
+ $method->setMethodTitle ( 'MeinPaket' );
106
+
107
+ $method->setPrice ( self::$_deliveryCosts );
108
+
109
+ $result->append ( $method );
110
+
111
+ return $result;
112
+ }
113
+
114
+ /**
115
+ * Sets the total delivery costs
116
+ *
117
+ * @param float $deliveryCosts
118
+ * @return void
119
+ */
120
+ public static function setDeliveryCosts($deliveryCosts) {
121
+ self::$_deliveryCosts = ( float ) $deliveryCosts;
122
+ }
123
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Client/BadHttpReturnCodeException.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Client_BadHttpReturnCodeException extends Dhl_MeinPaketCommon_Model_Client_HttpException {
12
+ /**
13
+ *
14
+ * @var integer
15
+ */
16
+ protected $httpReturnCode;
17
+
18
+ /**
19
+ * Constructor.
20
+ *
21
+ * @param integer $httpReturnCode
22
+ * @param string $message
23
+ * @return void
24
+ */
25
+ public function __construct($httpReturnCode, $message = '') {
26
+ parent::__construct ( $message );
27
+
28
+ $this->httpReturnCode = $httpReturnCode;
29
+ }
30
+
31
+ /**
32
+ *
33
+ * @return integer
34
+ */
35
+ public function getHttpReturnCode() {
36
+ return $this->httpReturnCode;
37
+ }
38
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Client/HttpException.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Client_HttpException extends Varien_Exception {
12
+ }
13
+
app/code/community/Dhl/MeinPaketCommon/Model/Client/HttpTimeoutException.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Client_HttpTimeoutException extends Dhl_MeinPaketCommon_Model_Client_HttpException {
12
+ }
13
+
app/code/community/Dhl/MeinPaketCommon/Model/Client/XmlOverHttp.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Client_XmlOverHttp extends Varien_Object {
12
+ /**
13
+ * Endpoint for production
14
+ *
15
+ * @var string
16
+ */
17
+ const PRODUCTIVE_ENDPOINT = 'de.allyouneed.com/dealerapi/';
18
+ /**
19
+ * Endpoint for sandbox
20
+ *
21
+ * @var string
22
+ */
23
+ const SANDBOX_ENDPOINT = 'ayn-api.mepa-home.de/dealerapi/xml';
24
+ /**
25
+ * Suffix for async requests
26
+ *
27
+ * @var string
28
+ */
29
+ const ASYNC_SUFFIX = 'Async';
30
+
31
+ /**
32
+ * Configuration
33
+ *
34
+ * @var array
35
+ */
36
+ private $config;
37
+
38
+ /**
39
+ * Endpoint
40
+ *
41
+ * @var string
42
+ */
43
+ private $endpoint;
44
+
45
+ /**
46
+ * Constructor.
47
+ *
48
+ * @return void
49
+ */
50
+ public function __construct() {
51
+ $this->config = array (
52
+ 'useragent' => 'Magento ' . Mage::getVersion () . ' Extension ' . Mage::helper ( 'meinpaket/data' )->getExtensionVersion ()
53
+ );
54
+ $scheme = Mage::getStoreConfigFlag ( 'meinpaket/endpoint/https' ) ? 'https://' : 'http://';
55
+ $path = Mage::getStoreConfigFlag ( 'meinpaket/endpoint/sandbox' ) ? self::SANDBOX_ENDPOINT : self::PRODUCTIVE_ENDPOINT;
56
+ $this->endpoint = $scheme . $path;
57
+
58
+ if (Mage::getStoreConfigFlag ( 'meinpaket/endpoint/proxy' )) {
59
+ $this->config ['adapter'] = 'Zend_Http_Client_Adapter_Proxy';
60
+ $host = Mage::getStoreConfig ( 'meinpaket/endpoint/proxy_host' );
61
+ $port = Mage::getStoreConfig ( 'meinpaket/endpoint/proxy_port' );
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_MeinPaketCommon_Model_Xml_AbstractXmlRequest $xml
81
+ * @throws Dhl_MeinPaketCommon_Model_Client_BadHttpReturnCodeException
82
+ * @throws Dhl_MeinPaketCommon_Model_Client_HttpTimeoutException
83
+ * @return Dhl_MeinPaketCommon_Model_Xml_Response_Abstract
84
+ */
85
+ public function send($xml, $async = false) {
86
+ $xmlData = $xml instanceof Dhl_MeinPaketCommon_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($this->config);
91
+ // Zend_Debug::dump($httpClient);die;
92
+ $httpClient->setMethod ( Zend_Http_Client::POST );
93
+ $httpClient->setRawData ( $xmlData );
94
+
95
+ /* @var $log Dhl_MeinPaketCommon_Model_Log */
96
+ $log = Mage::getModel ( 'meinpaketcommon/log' );
97
+ $log->setSend ( $xmlData );
98
+ $log->setCreatedAt ( Varien_Date::now () );
99
+ if ($xml instanceof Dhl_MeinPaketCommon_Model_Xml_Request_AsynchronousStatusRequest) {
100
+ $log->setRequestId ( $xml->getRequestId () );
101
+ }
102
+ $log->save ();
103
+
104
+ Mage::log ( $xmlData, 'meinpaket.log' );
105
+
106
+ try {
107
+ // echo $xmlData . "\n";
108
+ $serverResponse = $httpClient->request ();
109
+ // echo $serverResponse . "\n";
110
+ } catch ( Zend_Http_Client_Adapter_Exception $e ) {
111
+ Mage::logException ( $e );
112
+ $log->setError ( $e->getMessage () );
113
+ $log->save ();
114
+ throw new Dhl_MeinPaketCommon_Model_Client_HttpTimeoutException ( $e->getMessage () );
115
+ }
116
+
117
+ $body = $serverResponse->getBody ();
118
+
119
+ $body4Mysql = substr ( $body, 0, 1024 * 1024 * 4 );
120
+ $log->setReceived ( $body4Mysql );
121
+ $status = $serverResponse->getStatus ();
122
+
123
+ Mage::log ( $status . "\n" . $body, 'meinpaket.log' );
124
+
125
+ if ($status !== 200) {
126
+ $log->setError ( 'FAILURE: Client returned HTTP return code "' . $status . '".' );
127
+ $log->save ();
128
+ throw new Dhl_MeinPaketCommon_Model_Client_BadHttpReturnCodeException ( $status, 'FAILURE: Client returned HTTP return code "' . $status . '".' );
129
+ }
130
+ $log->save ();
131
+
132
+ $dom = new DOMDocument ();
133
+ $response = null;
134
+
135
+ try {
136
+ $valid = $dom->loadXML ( $body );
137
+ if (! $valid) {
138
+ throw new Dhl_MeinPaketCommon_Model_Xml_InvalidXmlException ( "Invalid XML" );
139
+ }
140
+
141
+ /* @var $parser Dhl_MeinPaketCommon_Model_Xml_XmlResponseParser */
142
+ $parser = Mage::getModel ( 'meinpaketcommon/xml_xmlResponseParser' );
143
+ $response = $parser->parseResponse ( $dom );
144
+
145
+ if ($response instanceof Dhl_MeinPaketCommon_Model_Xml_Response_AsynchronousStatusResponse) {
146
+ $log->setRequestId ( $response->getRequestId () );
147
+ }
148
+
149
+ $log->setError ( $response->getErrorString () );
150
+ } catch ( Exception $e ) {
151
+ Mage::logException ( $e );
152
+ $log->setError ( $e->getMessage () );
153
+ }
154
+ $log->save ();
155
+
156
+ return $response;
157
+ }
158
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Cron.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_MeinPaketCommon_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 download orders.
22
+ *
23
+ * @return NULL
24
+ */
25
+ public function importOrders() {
26
+ try {
27
+ return Mage::getSingleton ( 'meinpaketcommon/service_order_importService' )->importOrders ();
28
+ } catch ( Exception $e ) {
29
+ Mage::logException ( $e );
30
+ }
31
+ return null;
32
+ }
33
+
34
+ /**
35
+ * Called to download responses for async requests.
36
+ *
37
+ * @return NULL
38
+ */
39
+ public function processAsyncTasks() {
40
+ try {
41
+ return Mage::getSingleton ( 'meinpaketcommon/service_async' )->process ();
42
+ } catch ( Exception $e ) {
43
+ Mage::logException ( $e );
44
+ }
45
+ return null;
46
+ }
47
+
48
+ /**
49
+ * Called to request best prices.
50
+ *
51
+ * @return NULL
52
+ */
53
+ public function cleanup() {
54
+ try {
55
+ // Delete all log entries older than 40 days
56
+ $date = Zend_Date::now ();
57
+ $date->subDay ( 40 );
58
+
59
+ $logCollection = Mage::getModel ( 'meinpaketcommon/log' )->getCollection ();
60
+ $logCollection->addFieldToFilter ( 'createdAt', array (
61
+ 'to' => $date->toString ( 'YYYY-MM-dd' )
62
+ ) );
63
+ foreach ( $logCollection as $log ) {
64
+ $log->delete ();
65
+ }
66
+ } catch ( Exception $e ) {
67
+ Mage::logException ( $e );
68
+ }
69
+ return null;
70
+ }
71
+ }
app/code/community/Dhl/MeinPaketCommon/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_MeinPaketCommon_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/MeinPaketCommon/Model/Exception/InvalidDataException.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Exception_InvalidDataException extends Varien_Exception {
12
+ /**
13
+ *
14
+ * @var string
15
+ */
16
+ protected $errorType;
17
+
18
+ /**
19
+ *
20
+ * @var string
21
+ */
22
+ protected $fieldName;
23
+
24
+ /**
25
+ *
26
+ * @var integer
27
+ */
28
+ protected $entityId;
29
+
30
+ /**
31
+ * Constructor.
32
+ *
33
+ * @param integer $entityId
34
+ * of the model entity on which the error occured.
35
+ * @param string $fieldName
36
+ * of the attribute which is invalid.
37
+ * @param string $errorType
38
+ * type defined in Dhl_MeinPaketCommon_Model_Validation_ValidationInterface.
39
+ * @return void
40
+ */
41
+ public function __construct($entityId, $fieldName, $errorType = Dhl_MeinPaketCommon_Model_Validation_ValidationInterface::ERROR_FIELD_IS_INVALID) {
42
+ parent::__construct ( 'Invalid data field "' . $fieldName . '" for entity (id=' . $entityId . '). Error type is "' . $errorType . '".' );
43
+
44
+ $this->entityId = $entityId;
45
+ $this->fieldName = $fieldName;
46
+ $this->errorType = $errorType;
47
+ }
48
+
49
+ /**
50
+ *
51
+ * @return string
52
+ */
53
+ public function getFieldName() {
54
+ return $this->fieldName;
55
+ }
56
+
57
+ /**
58
+ *
59
+ * @return integer
60
+ */
61
+ public function getEntityId() {
62
+ return $this->entityId;
63
+ }
64
+
65
+ /**
66
+ *
67
+ * @return string
68
+ */
69
+ public function getErrorType() {
70
+ return $this->errorType;
71
+ }
72
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Exception/MissingDataException.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Exception_MissingDataException extends Dhl_MeinPaketCommon_Model_Exception_InvalidDataException {
12
+ /**
13
+ * Constructor.
14
+ *
15
+ * @param integer $entityId
16
+ * of the model entity on which the error occured.
17
+ * @param string $fieldName
18
+ * of the attribute that is missing.
19
+ * @return void
20
+ */
21
+ public function __construct($entityId, $fieldName) {
22
+ parent::__construct ( $entityId, $fieldName, Dhl_MeinPaketCommon_Model_Validation_ValidationInterface::ERROR_REQUIRED_FIELD_IS_EMPTY );
23
+ }
24
+ }
25
+
app/code/community/Dhl/MeinPaketCommon/Model/Log.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Model_Log extends Mage_Core_Model_Abstract {
3
+ public function _construct() {
4
+ parent::_construct ();
5
+ $this->_init ( 'meinpaketcommon/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/MeinPaketCommon/Model/Mysql4/Async.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_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 ( 'meinpaketcommon/async', 'async_id' );
10
+ }
11
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Mysql4/Async/Collection.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_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 ( 'meinpaketcommon/async' );
10
+ }
11
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Mysql4/Log.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_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 ( 'meinpaketcommon/log', 'log_id' );
10
+ }
11
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Mysql4/Log/Collection.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_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 ( 'meinpaketcommon/log' );
10
+ }
11
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Observer.php ADDED
@@ -0,0 +1,536 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Observer {
12
+ /**
13
+ * Holds the id of the order whose save_after event is actually triggered.
14
+ *
15
+ * @var integer
16
+ */
17
+ protected static $currentlySavedOrderId = - 1;
18
+
19
+ /**
20
+ * Tells if the save_after has been triggered twice or more on
21
+ * the same order during script lifetime.
22
+ *
23
+ * @var boolean
24
+ */
25
+ protected static $isSameSavedOrder = false;
26
+
27
+ /**
28
+ * Sets the id of the order whose save_after event has been triggered.
29
+ *
30
+ * @param integer $orderId
31
+ * @return void
32
+ */
33
+ protected static function setCurrentOrderId($orderId) {
34
+ if (self::$currentlySavedOrderId === $orderId) {
35
+ self::$isSameSavedOrder = true;
36
+ } else {
37
+ self::$isSameSavedOrder = false;
38
+ }
39
+ self::$currentlySavedOrderId = $orderId;
40
+ }
41
+
42
+ /**
43
+ *
44
+ * @param unknown $observer
45
+ */
46
+ public function gridAddAttributes(Varien_Event_Observer $observer) {
47
+ $block = $observer->getBlock ();
48
+ if (! isset ( $block )) {
49
+ return $this;
50
+ }
51
+
52
+ if ($block->getType () == 'adminhtml/sales_order_grid') {
53
+ /* @var $block Mage_Adminhtml_Block_Sales_Order_Grid */
54
+
55
+ $block->addColumnAfter ( 'dhl_mein_paket_order_id', array (
56
+ 'header' => __ ( 'Allyouneed Order No.' ),
57
+ 'index' => 'dhl_mein_paket_order_id'
58
+ ), 'real_order_id' );
59
+ }
60
+ return $this;
61
+ }
62
+
63
+ /**
64
+ * Tells if the save_after event of the current order has been triggered
65
+ * at least once during the lifecycle of the current script.
66
+ *
67
+ * @return boolean
68
+ */
69
+ protected static function saveEventHasBeenTriggeredOnSameOrderBefore() {
70
+ return self::$isSameSavedOrder;
71
+ }
72
+
73
+ /**
74
+ * Is triggered when an order is saved.
75
+ *
76
+ * @param Varien_Event_Observer $observer
77
+ * @return Dhl_MeinPaketCommon_Model_Observer
78
+ */
79
+ public function salesOrderSaveAfter(Varien_Event_Observer $observer) {
80
+ $order = $observer->getData ( 'order' );
81
+
82
+ self::setCurrentOrderId ( $order->getId () );
83
+
84
+ $this->_updateMeinPaketOrderId ( $order );
85
+ $this->_handleOrderItemsChange ( $order );
86
+ $this->_cancelMeinPaketOrder ( $order );
87
+
88
+ return $this;
89
+ }
90
+
91
+ /**
92
+ * Sets the dhl_mein_paket_order_id for the given order.
93
+ * This is necessary if an order is edit and so created a new one.
94
+ * The new one will not have it's dhl_mein_paket_order_id attribute
95
+ * automatically.
96
+ *
97
+ * @param Varien_Object $order
98
+ * @return Dhl_MeinPaketCommon_Model_Observer
99
+ */
100
+ protected function _updateMeinPaketOrderId($order) {
101
+ // return if the order doesn't have a parent order
102
+ // or if it already has a Allyouneed order id...
103
+ if (! $order->hasData ( 'relation_parent_id' ) || $order->hasData ( 'dhl_mein_paket_order_id' )) {
104
+ return;
105
+ }
106
+
107
+ /* @var $parentOrder Mage_Sales_Model_Order */
108
+ $parentOrder = Mage::getModel ( 'sales/order' )->load ( $order->getData ( 'relation_parent_id' ) );
109
+
110
+ if (! $parentOrder->hasData ( 'relation_parent_id' ) || $parentOrder->hasData ( 'dhl_mein_paket_order_id' )) {
111
+ $order->setData ( 'dhl_mein_paket_order_id', $parentOrder->getDhlMeinPaketOrderId () );
112
+ $parentOrder->setData ( 'dhl_mein_paket_order_id', '' )->getResource ()->saveAttribute ( $parentOrder, 'dhl_mein_paket_order_id' );
113
+ }
114
+
115
+ return $this;
116
+ }
117
+
118
+ /**
119
+ * Cancels single order items.
120
+ *
121
+ * @param Mage_Sales_Model_Order $order
122
+ * @return Dhl_MeinPaketCommon_Model_Observer
123
+ */
124
+ protected function _handleOrderItemsChange(Mage_Sales_Model_Order $order) {
125
+ if (self::saveEventHasBeenTriggeredOnSameOrderBefore ()) {
126
+ return;
127
+ }
128
+
129
+ if ($order->getData ( 'state' ) === Mage_Sales_Model_Order::STATE_CANCELED) {
130
+ return $this;
131
+ }
132
+
133
+ if (! $order->hasData ( 'relation_parent_id' )) {
134
+ return $this;
135
+ }
136
+
137
+ /* @var $orderHelper Dhl_MeinPaketCommon_Helper_Order */
138
+ $orderHelper = Mage::helper ( 'meinpaketcommon/order' );
139
+
140
+ /* @var $parentOrder Mage_Sales_Model_Order */
141
+ $parentOrder = Mage::getModel ( 'sales/order' )->load ( $order->getData ( 'relation_parent_id' ) );
142
+
143
+ if ($orderHelper->isMeinPaketOrder ( $order )) {
144
+
145
+ $orderItemCollection = $order->getItemsCollection ();
146
+ $parentItemCollection = $parentOrder->getItemsCollection ();
147
+ $items = array ();
148
+ $parentItems = array ();
149
+ $reduceList = array ();
150
+ $submitChanges = false;
151
+
152
+ foreach ( $orderItemCollection as $item ) {
153
+ $options = $item->getProductOptions ();
154
+ if (isset ( $options ['info_buyRequest'] ) && isset ( $options ['info_buyRequest'] ['dhl_mein_paket_item_id'] )) {
155
+ $items [$options ['info_buyRequest'] ['dhl_mein_paket_item_id']] = array (
156
+ 'qty' => ( integer ) $item->getQtyOrdered (),
157
+ 'productId' => $item->getProductId ()
158
+ );
159
+ }
160
+ }
161
+ foreach ( $parentItemCollection as $item ) {
162
+ $options = $item->getProductOptions ();
163
+ if ($item->getQtyCanceled () != $item->getQtyOrdered ()) {
164
+ $submitChanges = true;
165
+ }
166
+ if (isset ( $options ['info_buyRequest'] ) && isset ( $options ['info_buyRequest'] ['dhl_mein_paket_item_id'] )) {
167
+ $parentItems [$options ['info_buyRequest'] ['dhl_mein_paket_item_id']] = array (
168
+ 'qty' => ( integer ) $item->getQtyOrdered (),
169
+ 'productId' => $item->getProductId ()
170
+ );
171
+ }
172
+ }
173
+
174
+ if ($submitChanges === false) {
175
+ return $this;
176
+ }
177
+
178
+ // find items with lowered quantity
179
+ if (sizeof ( $items ) < sizeof ( $parentItems )) {
180
+ foreach ( $parentItems as $dhlItemId => $item ) {
181
+ if (! array_key_exists ( $dhlItemId, $items )) {
182
+ $reduceList [$dhlItemId] = array (
183
+ 'qty' => $item ['qty'],
184
+ 'productId' => $item ['productId']
185
+ );
186
+ } elseif ($items [$dhlItemId] ['qty'] < $item ['qty']) {
187
+ $reduceList [$dhlItemId] = array (
188
+ 'qty' => $item ['qty'] - $items [$dhlItemId] ['qty'],
189
+ 'productId' => $item ['productId']
190
+ );
191
+ }
192
+ }
193
+ } else {
194
+ foreach ( $items as $dhlItemId => $item ) {
195
+ if (array_key_exists ( $dhlItemId, $parentItems ) && $item ['qty'] < $parentItems [$dhlItemId] ['qty']) {
196
+ $reduceList [$dhlItemId] = array (
197
+ 'qty' => $parentItems [$dhlItemId] ['qty'] - $item ['qty'],
198
+ 'productId' => $item ['productId']
199
+ );
200
+ }
201
+ }
202
+ }
203
+
204
+ if (sizeof ( $reduceList ) > 0) {
205
+ // make request
206
+ $cancellationService = new Dhl_MeinPaketCommon_Model_Service_Order_CancellationService ();
207
+ $result = null;
208
+ $helper = Mage::helper ( 'meinpaketcommon/data' );
209
+ $errMsg = '';
210
+
211
+ try {
212
+ $result = $cancellationService->cancelOrderItems ( $order, $reduceList );
213
+ } catch ( Dhl_MeinPaketCommon_Model_Xml_XmlBuildException $e ) {
214
+ Mage::logException ( $e );
215
+ $errMsg .= $helper->__ ( 'Request could not be built.' );
216
+ } catch ( Dhl_MeinPaketCommon_Model_Client_BadHttpReturnCodeException $e ) {
217
+ Mage::logException ( $e );
218
+ $errMsg .= sprintf ( $helper->__ ( 'Allyouneed server returned HTPP code %s.' ), $e->getHttpReturnCode () );
219
+ } catch ( Dhl_MeinPaketCommon_Model_Client_HttpTimeoutException $e ) {
220
+ Mage::logException ( $e );
221
+ $errMsg .= $helper->__ ( 'Connection to Allyouneed server timed out.' );
222
+ } catch ( Dhl_MeinPaketCommon_Model_Xml_InvalidXmlException $e ) {
223
+ Mage::logException ( $e );
224
+ $errMsg .= $helper->__ ( 'Invalid response from Allyouneed server.' );
225
+ } catch ( Exception $e ) {
226
+ Mage::logException ( $e );
227
+ $errMsg .= $helper->__ ( 'Unknown error.' );
228
+ }
229
+ if (is_object ( $result ) && $result->hasError ()) {
230
+ $errMsg .= sprintf ( $helper->__ ( 'Allyouneed server returned error code %s.' ), $result->getError () );
231
+ }
232
+
233
+ if (strlen ( $errMsg ) > 0) {
234
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $helper->__ ( 'Error on tranfering cancelled items to Allyouneed.' ) . ' (' . $errMsg . ')' );
235
+ throw new Exception ( 'Failed transfering cancelled items to Allyouneed server.' );
236
+ }
237
+ }
238
+ }
239
+
240
+ return $this;
241
+ }
242
+
243
+ /**
244
+ * Cancels the given order in Allyouneed if the given order is a Allyouneed order
245
+ * and its state is Mage_Sales_Model_Order::STATE_CANCELED.
246
+ *
247
+ * @param Mage_Sales_Model_Order $order
248
+ * @return Dhl_MeinPaketCommon_Model_Observer
249
+ */
250
+ protected function _cancelMeinPaketOrder(Mage_Sales_Model_Order $order) {
251
+ $meinPaketOrderId = $order->getData ( 'dhl_mein_paket_order_id' );
252
+
253
+ if (strlen ( $meinPaketOrderId ) > 1 && $order->getData ( 'state' ) === Mage_Sales_Model_Order::STATE_CANCELED) {
254
+
255
+ $col = Mage::getModel ( 'sales/order' )->getCollection ()->addAttributeToFilter ( 'relation_parent_id', $order->getId () )->load ();
256
+
257
+ if ($col->count () > 0) {
258
+ return $this;
259
+ }
260
+
261
+ // TODO: Class missing
262
+
263
+ /* @var $orderCancellationService Dhl_MeinPaketCommon_Model_Service_Order_CancellationService */
264
+ $orderCancellationService = new Dhl_MeinPaketCommon_Model_Service_Order_CancellationService ();
265
+
266
+ $result = null;
267
+ $helper = Mage::helper ( 'meinpaketcommon/data' );
268
+ $errMsg = '';
269
+
270
+ try {
271
+ $result = $orderCancellationService->cancelOrder ( $order );
272
+ } catch ( Dhl_MeinPaketCommon_Model_Xml_XmlBuildException $e ) {
273
+ Mage::logException ( $e );
274
+ $errMsg .= $helper->__ ( 'Request could not be built.' );
275
+ } catch ( Dhl_MeinPaketCommon_Model_Client_BadHttpReturnCodeException $e ) {
276
+ Mage::logException ( $e );
277
+ $errMsg .= sprintf ( $helper->__ ( 'Allyouneed server returned HTPP code %s.' ), $e->getHttpReturnCode () );
278
+ } catch ( Dhl_MeinPaketCommon_Model_Client_HttpTimeoutException $e ) {
279
+ Mage::logException ( $e );
280
+ $errMsg .= $helper->__ ( 'Connection to Allyouneed server timed out.' );
281
+ } catch ( Dhl_MeinPaketCommon_Model_Xml_InvalidXmlException $e ) {
282
+ Mage::logException ( $e );
283
+ $errMsg .= $helper->__ ( 'Invalid response from Allyouneed server.' );
284
+ } catch ( Exception $e ) {
285
+ Mage::logException ( $e );
286
+ $errMsg .= $helper->__ ( 'Unknown error.' );
287
+ }
288
+ if (is_object ( $result ) && $result->hasError ()) {
289
+ $errMsg .= sprintf ( $helper->__ ( 'Allyouneed server returned error code %s.' ), $result->getError () );
290
+ }
291
+
292
+ if (strlen ( $errMsg ) > 0) {
293
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $helper->__ ( 'Error on tranfering cancelled items to Allyouneed.' ) . ' (' . $errMsg . ')' );
294
+ throw new Exception ( 'Failed transfering cancelled items to Allyouneed server.' );
295
+ }
296
+ }
297
+
298
+ return $this;
299
+ }
300
+
301
+ /**
302
+ * Is triggered when a shipment is saved.
303
+ *
304
+ * @param Varien_Event_Observer $observer
305
+ * @return Dhl_MeinPaketCommon_Model_Observer
306
+ */
307
+ public function salesOrderShipmentSaveAfter(Varien_Event_Observer $observer) {
308
+ /* @var $order Dhl_MeinPaketCommon_Helper_Shipment */
309
+ $shipmentHelper = Mage::helper ( 'meinpaketcommon/shipment' );
310
+
311
+ /* @var $shipment Mage_Sales_Model_Order_Shipment */
312
+ $shipment = $observer->getData ( 'shipment' );
313
+
314
+ self::setCurrentOrderId ( $shipment->getOrder ()->getId () );
315
+
316
+ if ($shipmentHelper->isExportedToDhlMeinPaket ( $shipment )) {
317
+ return $this;
318
+ }
319
+
320
+ if (! $shipmentHelper->isMeinPaketShipment ( $shipment )) {
321
+ return $this;
322
+ }
323
+
324
+ // send shipment request to MeinPaket.
325
+ $this->_exportShipmentToMeinPaket ( $shipment );
326
+
327
+ return $this;
328
+ }
329
+
330
+ /**
331
+ * Is called after a shipment save is committed.
332
+ * Sets the shipment's "shipment_was_exported_for_dhl_mein_paket" attribute
333
+ * value to "1" if it isn't set yet.
334
+ *
335
+ * @param Varien_Event_Observer $observer
336
+ * @return Dhl_MeinPaketCommon_Model_Observer
337
+ */
338
+ public function salesOrderShipmentSaveCommitAfter(Varien_Event_Observer $observer) {
339
+ /* @var $order Dhl_MeinPaketCommon_Helper_Shipment */
340
+ $shipmentHelper = Mage::helper ( 'meinpaketcommon/shipment' );
341
+
342
+ /* @var $shipment Mage_Sales_Model_Order_Shipment */
343
+ $shipment = $observer->getShipment ();
344
+
345
+ self::setCurrentOrderId ( $shipment->getOrder ()->getId () );
346
+
347
+ if ($shipmentHelper->isExportedToDhlMeinPaket ( $shipment )) {
348
+ return $this;
349
+ }
350
+
351
+ if (! $shipmentHelper->isMeinPaketShipment ( $shipment )) {
352
+ return $this;
353
+ }
354
+
355
+ if ($shipmentHelper->isMeinPaketShipment ( $shipment ) && ! $shipment->getData ( 'shipment_was_exported_for_dhl_mein_paket' )) {
356
+ $shipment->setData ( 'shipment_was_exported_for_dhl_mein_paket', 1 )->getResource ()->saveAttribute ( $shipment, 'shipment_was_exported_for_dhl_mein_paket' );
357
+ }
358
+ }
359
+
360
+ /**
361
+ * Exports an saved shipment to Allyouneed.
362
+ *
363
+ * @param Mage_Sales_Model_Order_Shipment $shipment
364
+ * @return Dhl_MeinPaketCommon_Model_Observer
365
+ */
366
+ protected function _exportShipmentToMeinPaket(Mage_Sales_Model_Order_Shipment $shipment) {
367
+ $shipmentExportService = new Dhl_MeinPaketCommon_Model_Service_Order_ShipmentExportService ();
368
+
369
+ $result = null;
370
+ $errMsg = '';
371
+ $helper = Mage::helper ( 'meinpaketcommon/data' );
372
+
373
+ try {
374
+ $result = $shipmentExportService->exportShipment ( $shipment );
375
+ } catch ( Dhl_MeinPaketCommon_Model_Xml_XmlBuildException $e ) {
376
+ Mage::logException ( $e );
377
+ $errMsg .= $helper->__ ( 'Request could not be built.' );
378
+ } catch ( Dhl_MeinPaketCommon_Model_Client_BadHttpReturnCodeException $e ) {
379
+ Mage::logException ( $e );
380
+ $errMsg .= sprintf ( $helper->__ ( 'Allyouneed server returned HTPP code %s.' ), $e->getHttpReturnCode () );
381
+ } catch ( Dhl_MeinPaketCommon_Model_Client_HttpTimeoutException $e ) {
382
+ Mage::logException ( $e );
383
+ $errMsg .= $helper->__ ( 'Connection to Allyouneed server timed out.' );
384
+ } catch ( Dhl_MeinPaketCommon_Model_Xml_InvalidXmlException $e ) {
385
+ Mage::logException ( $e );
386
+ $errMsg .= $helper->__ ( 'Invalid response from Allyouneed server.' );
387
+ } catch ( Exception $e ) {
388
+ Mage::logException ( $e );
389
+ $errMsg .= $helper->__ ( 'Unknown error.' );
390
+ }
391
+
392
+ if ($result == null || $result->hasErrors ()) {
393
+ $errMsg .= $helper->__ ( 'Shipment has not been accepted by Allyouneed.' );
394
+ }
395
+
396
+ if (strlen ( $errMsg ) > 0) {
397
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $helper->__ ( 'Error on transfering shipment to Allyouneed.' ) . ' (' . $errMsg . ')' );
398
+ throw new Exception ( 'Failed exporting shipment to Allyouneed server.' );
399
+ }
400
+
401
+ return $this;
402
+ }
403
+
404
+ /**
405
+ * Is called when a creditmemo is saved.
406
+ * If the creditmemo is refunded, a notification will be send to Allyouneed.
407
+ *
408
+ * @param Varien_Event_Observer $observer
409
+ * @return Dhl_MeinPaketCommon_Model_Observer
410
+ */
411
+ public function salesOrderCreditmemoSaveAfter(Varien_Event_Observer $observer) {
412
+ /* @var $creditmemo Mage_Sales_Model_Order_Creditmemo */
413
+ $creditmemo = $observer->getData ( 'creditmemo' );
414
+
415
+ self::setCurrentOrderId ( $creditmemo->getOrder ()->getId () );
416
+
417
+ // check if creditmemo is refunded
418
+ if ($creditmemo->getState () != Mage_Sales_Model_Order_Creditmemo::STATE_REFUNDED) {
419
+ return $this;
420
+ }
421
+
422
+ // check if the order is a Allyouneed order
423
+ if (! Mage::helper ( 'meinpaketcommon/order' )->isMeinPaketOrder ( $creditmemo->getOrder () )) {
424
+ return $this;
425
+ }
426
+
427
+ /* @var $result Dhl_MeinPaketCommon_Model_Sevice_RefundExport_Result */
428
+ $result = null;
429
+
430
+ /* @var $exportService Dhl_MeinPaketCommon_Model_Service_Order_RefundExportService */
431
+ $exportService = new Dhl_MeinPaketCommon_Model_Service_Order_RefundExportService ();
432
+
433
+ $helper = Mage::helper ( 'meinpaketcommon/data' );
434
+ $errMsg = '';
435
+
436
+ try {
437
+ $result = $exportService->exportRefund ( $creditmemo );
438
+ } catch ( Dhl_MeinPaketCommon_Model_Xml_XmlBuildException $e ) {
439
+ Mage::logException ( $e );
440
+ $errMsg .= $helper->__ ( 'Request could not be built.' );
441
+ } catch ( Dhl_MeinPaketCommon_Model_Client_BadHttpReturnCodeException $e ) {
442
+ Mage::logException ( $e );
443
+ $errMsg .= sprintf ( $helper->__ ( 'Allyouneed server returned HTPP code %s.' ), $e->getHttpReturnCode () );
444
+ } catch ( Dhl_MeinPaketCommon_Model_Client_HttpTimeoutException $e ) {
445
+ Mage::logException ( $e );
446
+ $errMsg .= $helper->__ ( 'Connection to Allyouneed server timed out.' );
447
+ } catch ( Dhl_MeinPaketCommon_Model_Xml_InvalidXmlException $e ) {
448
+ Mage::logException ( $e );
449
+ $errMsg .= $helper->__ ( 'Invalid response from Allyouneed server.' );
450
+ } catch ( Exception $e ) {
451
+ Mage::logException ( $e );
452
+ $errMsg .= $helper->__ ( 'Unknown error.' );
453
+ }
454
+
455
+ if ($result == null) {
456
+ $errMsg .= $helper->__ ( 'Refund has not been accepted by Allyouneed.' );
457
+ }
458
+
459
+ if (strlen ( $errMsg ) > 0) {
460
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $helper->__ ( 'Error on transfering refund to Allyouneed.' ) . ' (' . $errMsg . ')' );
461
+ throw new Exception ( 'Failed exporting refund to Allyouneed server.' );
462
+ }
463
+
464
+ return $this;
465
+ }
466
+
467
+ /**
468
+ * Is called when a shipment track is saved.
469
+ * The tracking code will be sent to Allyouneed if it's the first track
470
+ * for the shipment.
471
+ *
472
+ * @param Varien_Event_Observer $observer
473
+ * @return Dhl_MeinPaketCommon_Model_Observer
474
+ */
475
+ public function salesOrderShipmentTrackSaveAfter(Varien_Event_Observer $observer) {
476
+ /* @var $track Mage_Sales_Model_Order_Shipment_Track */
477
+ $track = $observer->getData ( 'track' );
478
+
479
+ if ($track == null) {
480
+ return this;
481
+ }
482
+
483
+ self::setCurrentOrderId ( $track->getOrderId () );
484
+
485
+ if (self::$isSameSavedOrder) {
486
+ return $this;
487
+ }
488
+
489
+ /* @var $shipment Mage_Sales_Model_Order_Shipment */
490
+ $shipment = $track->getShipment ();
491
+
492
+ // check if order is a Allyouneed order...
493
+ if (! Mage::helper ( 'meinpaketcommon/shipment' )->isMeinPaketShipment ( $shipment )) {
494
+ return $this;
495
+ }
496
+
497
+ $helper = Mage::helper ( 'meinpaketcommon/data' );
498
+ $result = null;
499
+ $errMsg = '';
500
+
501
+ $service = new Dhl_MeinPaketCommon_Model_Service_Order_ShipmentExportService ();
502
+
503
+ try {
504
+ $result = $service->exportTrackingNumber ( $track );
505
+ } catch ( Dhl_MeinPaketCommon_Model_Xml_XmlBuildException $e ) {
506
+ Mage::logException ( $e );
507
+ $errMsg .= $helper->__ ( 'Request could not be built.' );
508
+ } catch ( Dhl_MeinPaketCommon_Model_Client_BadHttpReturnCodeException $e ) {
509
+ Mage::logException ( $e );
510
+ $errMsg .= sprintf ( $helper->__ ( 'Allyouneed server returned HTPP code %s.' ), $e->getHttpReturnCode () );
511
+ } catch ( Dhl_MeinPaketCommon_Model_Client_HttpTimeoutException $e ) {
512
+ Mage::logException ( $e );
513
+ $errMsg .= $helper->__ ( 'Connection to Allyouneed server timed out.' );
514
+ } catch ( Dhl_MeinPaketCommon_Model_Xml_InvalidXmlException $e ) {
515
+ Mage::logException ( $e );
516
+ $errMsg .= $helper->__ ( 'Invalid response from Allyouneed server.' );
517
+ } catch ( Exception $e ) {
518
+ Mage::logException ( $e );
519
+ $errMsg .= $helper->__ ( 'Unknown error.' );
520
+ }
521
+
522
+ if ($result !== null && ! $result->hasBeenAccepted ()) {
523
+ $errMsg .= $helper->__ ( 'Tracking code has not been accepted by Allyouneed.' );
524
+ if ($result->hasError ()) {
525
+ $errMsg .= ' (' . sprintf ( $helper->__ ( 'Allyouneed returned error code %s.' ), $result->getError () ) . ')';
526
+ }
527
+ }
528
+
529
+ if (strlen ( $errMsg ) > 0) {
530
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $helper->__ ( 'Error on transfering tracking code to Allyouneed.' ) . ' (' . $errMsg . ')' );
531
+ throw new Exception ( 'Failed exporting tracking code to Allyouneed server.' );
532
+ }
533
+
534
+ return $this;
535
+ }
536
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Payment/Method/Allyouneed.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_MeinPaketCommon_Model_Payment_Method_Allyouneed extends Mage_Payment_Model_Method_Abstract {
11
+ /**
12
+ *
13
+ * @var string
14
+ */
15
+ protected $_code = 'allyouneed';
16
+
17
+ /**
18
+ * Can use this payment method in administration panel?
19
+ * @var boolean
20
+ */
21
+ protected $_canUseInternal = false;
22
+
23
+ /**
24
+ * Can show this payment method as an option on checkout payment page?
25
+ * @var boolean
26
+ */
27
+ protected $_canUseCheckout = false;
28
+
29
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Payment/Method/Meinpaket.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_MeinPaketCommon_Model_Payment_Method_Meinpaket extends Mage_Payment_Model_Method_Abstract {
11
+ /**
12
+ *
13
+ * @var string
14
+ */
15
+ protected $_code = 'meinpaket';
16
+
17
+ /**
18
+ * Can use this payment method in administration panel?
19
+ * @var boolean
20
+ */
21
+ protected $_canUseInternal = false;
22
+
23
+ /**
24
+ * Can show this payment method as an option on checkout payment page?
25
+ * @var boolean
26
+ */
27
+ protected $_canUseCheckout = false;
28
+
29
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Resource/Eav/Mysql4/Setup.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Model_Resource_Eav_Mysql4_Setup extends Mage_Catalog_Model_Resource_Setup {
3
+ /**
4
+ *
5
+ * @return array
6
+ */
7
+ public function getDefaultEntities() {
8
+ return array (
9
+ 'order' => array (
10
+ 'entity_model' => 'sales/order',
11
+ 'table' => 'sales/order',
12
+ 'increment_model' => 'eav/entity_increment_numeric',
13
+ 'increment_per_store' => true,
14
+ 'backend_prefix' => 'sales_entity/order_attribute_backend',
15
+ 'attributes' => array (
16
+ 'meinpaket_id' => array (
17
+ 'type' => 'int',
18
+ 'label' => 'Order Allyouneed Id',
19
+ 'required' => false,
20
+ 'is_visible' => false,
21
+ 'visible' => false
22
+ )
23
+ )
24
+ ),
25
+ 'customer' => array (
26
+ 'entity_model' => 'customer/customer',
27
+ 'attribute_model' => 'customer/attribute',
28
+ 'table' => 'customer/entity',
29
+ 'increment_model' => 'eav/entity_increment_numeric',
30
+ 'additional_attribute_table' => 'customer/eav_attribute',
31
+ 'entity_attribute_collection' => 'customer/attribute_collection',
32
+ 'attributes' => array (
33
+ 'meinpaket_buyer_id' => array (
34
+ 'type' => 'int',
35
+ 'label' => 'MeinPaket Buyer Id',
36
+ 'input' => 'text',
37
+ 'required' => false,
38
+ 'sort_order' => 200,
39
+ 'visible' => false
40
+ ),
41
+ 'meinpaket_buyer_name' => array (
42
+ 'type' => 'varchar',
43
+ 'label' => 'Allyouneed Buyer Name',
44
+ 'input' => 'text',
45
+ 'required' => false,
46
+ 'sort_order' => 201,
47
+ 'visible' => false
48
+ )
49
+ )
50
+ )
51
+ );
52
+ }
53
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Service/Abstract.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_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/MeinPaketCommon/Model/Service/Async.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Service_Async extends Dhl_MeinPaketCommon_Model_Service_Abstract {
12
+ /**
13
+ * Exports products.
14
+ *
15
+ * @param integer $selectionMode
16
+ * @return Dhl_MeinPaketCommon_Model_Service_Product_Export_Result
17
+ */
18
+ public function process() {
19
+ $seenMagentoProducts = array ();
20
+
21
+ /* @var $client Dhl_MeinPaketCommon_Model_Client_XmlOverHttp */
22
+ $client = Mage::getModel ( 'meinpaketcommon/client_xmlOverHttp' );
23
+
24
+ /* var $logCollection Dhl_MeinPaketCommon_Model_Mysql4_Log_Collection */
25
+ $asyncCollection = Mage::getModel ( 'meinpaketcommon/async' )->getCollection ();
26
+
27
+ $count = 0;
28
+
29
+ foreach ( $asyncCollection as $async ) {
30
+ /* @var $statusRequest Dhl_MeinPaketCommon_Model_Xml_Request_AsynchronousStatusRequest */
31
+ $statusRequest = Mage::getModel ( 'meinpaketcommon/xml_request_asynchronousStatusRequest' );
32
+ $statusRequest->addRequestStatus ( $async->getRequestId () );
33
+
34
+ $response = null;
35
+ if ($statusRequest->isHasData ()) {
36
+ $response = $client->send ( $statusRequest );
37
+ }
38
+
39
+ if ($response != null && $response instanceof Dhl_MeinPaketCommon_Model_Xml_Response_AsynchronousStatusResponse) {
40
+ /* @var $response Dhl_MeinPaketCommon_Model_Xml_Response_AsynchronousStatusResponse */
41
+ $async->setRequestId ( $response->getRequestId () );
42
+ $async->setStatus ( $response->getStatus () );
43
+ $async->setUpdatedAt ( Varien_Date::now () );
44
+ $async->save ();
45
+ } else {
46
+ $async->delete ();
47
+ }
48
+
49
+ $count ++;
50
+ }
51
+
52
+ return Mage::helper ( 'meinpaket/data' )->__ ( "Processed %d async jobs", $count );
53
+ }
54
+ }
55
+
app/code/community/Dhl/MeinPaketCommon/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_MeinPaketCommon
8
+ * @subpackage Model_OrderCancellation
9
+ * @version $Id$
10
+ */
11
+ class Dhl_MeinPaketCommonModel_Service_Order_CancellationService extends Varien_Object {
12
+ /**
13
+ * Cancels the given MeinPaket order.
14
+ *
15
+ * @param Mage_Sales_Model_Order $order
16
+ * @throws Dhl_MeinPaketCommon_Model_Xml_XmlBuildException
17
+ * @throws Dhl_MeinPaketCommon_Model_Client_BadHttpReturnCodeException
18
+ * @throws Dhl_MeinPaketCommon_Model_Client_HttpTimeoutException
19
+ * @throws Dhl_MeinPaketCommon_Model_Xml_InvalidXmlException
20
+ * @return Dhl_MeinPaketCommon_Model_OrderCancellation_Result
21
+ */
22
+ public function cancelOrder(Mage_Sales_Model_Order $order) {
23
+
24
+ /* @var $notificationRequest Dhl_MeinPaketCommon_Model_Xml_Request_NotificationRequest */
25
+ $notificationRequest = new Dhl_MeinPaketCommon_Model_Xml_Request_NotificationRequest ();
26
+
27
+ /* @var $client Dhl_MeinPaketCommon_Model_Client_XmlOverHttp */
28
+ $httpClient = Mage::getModel ( 'meinpaketcommon/client_xmlOverHttp' );
29
+
30
+ /* @var $result Dhl_MeinPaketCommon_Model_Service_Order_CancellationService_Result */
31
+ $result = new Dhl_MeinPaketCommon_Model_Service_Order_CancellationService_Result ();
32
+
33
+ try {
34
+ $notificationRequest->addCancellation ( $order );
35
+ $responseXml = $httpClient->send ( $notificationRequest );
36
+ } catch ( Exception $e ) {
37
+ Mage::logException ( $e );
38
+ throw $e;
39
+ }
40
+
41
+ return $result;
42
+ }
43
+
44
+ /**
45
+ * TODO: broken
46
+ *
47
+ * Cancels a set of items for MeinPaket order.
48
+ *
49
+ * @param Mage_Sales_Model_Order $order
50
+ * @param array $items
51
+ * of the array have to be associative arrays
52
+ * containing the keys "productId" and "qty" (Quantity to reduce).
53
+ * @throws Dhl_MeinPaketCommon_Model_Xml_XmlBuildException
54
+ * @throws Dhl_MeinPaketCommonModel_Client_BadHttpReturnCodeException
55
+ * @throws Dhl_MeinPaketCommonModel_Client_HttpTimeoutException
56
+ * @throws Dhl_MeinPaketCommonModel_Xml_InvalidXmlException
57
+ * @return Dhl_MeinPaketCommonModel_OrderCancellation_Result
58
+ */
59
+ public function cancelOrderItems(Mage_Sales_Model_Order $order, array $items) {
60
+ $notificationRequest = new Dhl_MeinPaketCommon_Model_Xml_Request_NotificationRequest();
61
+
62
+ /* @var $xmlResponseParser Dhl_MeinPaketCommonModel_Xml_XmlResponseParser */
63
+ $xmlResponseParser = Mage::getModel ( 'meinpaketcommon/Xml_XmlResponseParser' );
64
+
65
+ /* @var $httpClient Dhl_MeinPaketCommonModel_Client_XmlOverHttp */
66
+ $httpClient = Mage::getModel ( 'meinpaketcommon/Client_XmlOverHttp' );
67
+
68
+ /* @var $result Dhl_MeinPaketCommonModel_Service_Order_CancellationService_Result */
69
+ $result = Mage::getModel ( 'meinpaketcommon/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/MeinPaketCommon/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_MeinPaketCommon_Model_Service_Order_CancellationService_Result extends Dhl_MeinPaketCommon_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 Allyouneed
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 Allyouneed.
87
+ *
88
+ * @return array
89
+ */
90
+ public function getConsignmentIds() {
91
+ return $this->consignmentIds;
92
+ }
93
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Service/Order/ImportService.php ADDED
@@ -0,0 +1,494 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Service_Order_ImportService extends Varien_Object {
12
+ /**
13
+ * counts of imported and duplicate orders
14
+ *
15
+ * @var $_orders array
16
+ */
17
+ var $_orderCount;
18
+
19
+ /**
20
+ * DHL IDs from orders which are out of stock
21
+ *
22
+ * @var $_outOfStockOrders array
23
+ */
24
+ var $_outOfStockOrders;
25
+
26
+ /**
27
+ * Dhl order ids which include disabled products.
28
+ *
29
+ * @var array
30
+ */
31
+ protected $_disabledProductOrders;
32
+
33
+ /**
34
+ *
35
+ * @var string
36
+ */
37
+ const IMPORT_SHIPPING_METHOD = 'meinpaket_standard';
38
+
39
+ /**
40
+ *
41
+ * @var string
42
+ */
43
+ const IMPORT_SHIPPING_METHOD = 'allyouneed_standard';
44
+
45
+
46
+ /**
47
+ *
48
+ * @var string
49
+ */
50
+ const IMPORT_PAYMENT_METHOD = 'allyouneed';
51
+
52
+ /**
53
+ *
54
+ * @var duplicate orders, returncode
55
+ */
56
+ const DUPLICATE_ORDER_STATUS = 2;
57
+
58
+ /**
59
+ *
60
+ * @var imported orders, returncode
61
+ */
62
+ const IMPORTED_ORDER_STATUS = 1;
63
+
64
+ /**
65
+ *
66
+ * @var out-of-stock orders, returncode
67
+ */
68
+ const OUT_OF_STOCK_ORDER_STATUS = 3;
69
+
70
+ /**
71
+ *
72
+ * @var invalid products in orders, returncode
73
+ */
74
+ const INVALID_PRODUCT_STATUS = 4;
75
+
76
+ /**
77
+ * Status for a disabled product.
78
+ *
79
+ * @var integer
80
+ */
81
+ const DISABLED_ORDER_STATUS = 4;
82
+ const USE_GUEST_ACCOUNT_CONFIG = 'meinpaket/order/use_guest_account';
83
+ const CUSTOMER_GROUP_CONFIG = 'meinpaket/order/customer_group';
84
+
85
+ /**
86
+ *
87
+ * @var boolean
88
+ */
89
+ protected $serviceResponseWasMalformed = false;
90
+
91
+ /**
92
+ * Event prefix for this class
93
+ *
94
+ * @var string
95
+ */
96
+ protected $_eventPrefix = 'meinpaketcommon_service_order_importService';
97
+
98
+ /**
99
+ * Constructor.
100
+ *
101
+ * @return void
102
+ */
103
+ public function __construct() {
104
+ $this->_orderCount = array (
105
+ 'imported' => 0,
106
+ 'duplicates' => 0,
107
+ 'outOfStock' => 0,
108
+ 'disabled' => 0,
109
+ 'invalid' => 0
110
+ );
111
+
112
+ $_outOfStockOrders = array ();
113
+ $this->_disabledProductOrders = array ();
114
+
115
+ parent::__construct ();
116
+ }
117
+
118
+ /**
119
+ * Tells if the MeinPaket response for the impoer orders request was
120
+ * malformed and could not be parsed.
121
+ *
122
+ * @return boolean
123
+ */
124
+ public function wasServiceResponseMalformed() {
125
+ return $this->serviceResponseWasMalformed;
126
+ }
127
+
128
+ /**
129
+ * returns count of imported and duplicate orders
130
+ *
131
+ * @return array
132
+ */
133
+ public function getOrderCount() {
134
+ return $this->_orderCount;
135
+ }
136
+
137
+ /**
138
+ * returns DHL IDs of orders which are out of stock
139
+ *
140
+ * @return array
141
+ */
142
+ public function getOutOfStockOrders() {
143
+ return $this->_outOfStockOrders;
144
+ }
145
+
146
+ /**
147
+ * Returns the order ids which could not be imported, because they contained
148
+ * disabled products.
149
+ *
150
+ * @return array
151
+ */
152
+ public function getDisabledProductOrders() {
153
+ return $this->_disabledProductOrders;
154
+ }
155
+
156
+ /**
157
+ * Imports Order from meinPaket
158
+ * //TODO make a simple result object containing: countnew / countexisting / warnings (e.g.
159
+ * if price missmatch)
160
+ *
161
+ * @param integer $start
162
+ * @param integer $stop
163
+ * @return void
164
+ */
165
+ public function importOrders($start = null, $stop = null) {
166
+ /* @var $client Dhl_MeinPaketCommon_Model_Client_XmlOverHttp */
167
+ $client = Mage::getModel ( 'meinpaketcommon/client_xmlOverHttp' );
168
+
169
+ $queryRequest = new Dhl_MeinPaketCommon_Model_Xml_Request_QueryRequest ();
170
+ // $queryRequest->addOrders ( $start, $stop );
171
+ $queryRequest->addOrders ( $start, $stop, 'Open' );
172
+
173
+ /* @var $queryResult Dhl_MeinPaketCommon_Model_Xml_Response_QueryResponse */
174
+ $queryResult = $client->send ( $queryRequest );
175
+
176
+ if ($queryResult == null) {
177
+ return;
178
+ }
179
+
180
+ foreach ( $queryResult->getOrders () as $order ) {
181
+ /* @var $order Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Order */
182
+ $successCode = $this->_importOrder ( $order );
183
+ switch ($successCode) {
184
+ case self::IMPORTED_ORDER_STATUS :
185
+ $this->_orderCount ['imported'] ++;
186
+ break;
187
+ case self::DUPLICATE_ORDER_STATUS :
188
+ $this->_orderCount ['duplicates'] ++;
189
+ break;
190
+ case self::OUT_OF_STOCK_ORDER_STATUS :
191
+ $this->_orderCount ['outOfStock'] ++;
192
+ break;
193
+ case self::INVALID_PRODUCT_STATUS :
194
+ $this->_orderCount ['invalid'] ++;
195
+ break;
196
+ case self::DISABLED_ORDER_STATUS :
197
+ $this->_orderCount ['disabled'] ++;
198
+ break;
199
+ }
200
+ }
201
+
202
+ return $this->_orderCount;
203
+ }
204
+
205
+ /**
206
+ * imports orders from XML, returns success code
207
+ *
208
+ * @param SimpleXMLElement $order
209
+ * @return int
210
+ */
211
+ protected function _importOrder(Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Order $order, $paymentMethod = self::IMPORT_PAYMENT_METHOD) {
212
+ $storeId = Mage::helper ( 'meinpaketcommon/data' )->getMeinPaketStoreId ();
213
+ $store = Mage::helper ( 'meinpaketcommon/data' )->getMeinPaketStore ();
214
+
215
+ /* @var $orderObj Mage_Sales_Model_Order */
216
+ $orderObj = Mage::getModel ( 'sales/order' )->load ( $order->getOrderId (), 'dhl_mein_paket_order_id' );
217
+
218
+ // do not import order already existing orders
219
+ if ($orderObj->getId ()) {
220
+ return self::DUPLICATE_ORDER_STATUS;
221
+ }
222
+
223
+ $customer = $this->getOrCreateCustomer ( $order );
224
+
225
+ if (! Mage::getStoreConfig ( self::USE_GUEST_ACCOUNT_CONFIG )) {
226
+ $customer->save ();
227
+ }
228
+
229
+ // Set email for guest order
230
+ /* @var $quoteObj Mage_Sales_Model_Quote */
231
+ $quoteObj = Mage::getModel ( 'sales/quote' );
232
+ $quoteObj->setStoreId ( $storeId );
233
+ $quoteObj->setCustomerNote ( __ ( 'Imported from DHL Allyouneed' ) . ' (' . __ ( 'Delivery Method' ) . ':' . (( string ) $order->getDeliveryMethod ()) . ')' );
234
+ $quoteObj->setCustomerFirstname ( $customer->getFirstname () );
235
+ $quoteObj->setCustomerLastname ( $customer->getLastname () );
236
+ $quoteObj->setCustomerIsGuest ( Mage::getStoreConfig ( self::USE_GUEST_ACCOUNT_CONFIG ) );
237
+ $quoteObj->setCustomerEmail ( $customer->getEmail () );
238
+ $quoteObj->setCustomer ( $customer );
239
+
240
+ $hasNoConfigurables = true;
241
+ $quoteItems = array ();
242
+
243
+ foreach ( $order->getEntries () as $orderEntry ) {
244
+ /* var $orderEntry Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Order_Entry */
245
+ $productId = ( string ) $orderEntry->getProductId ();
246
+
247
+ if ($hasNoConfigurables) {
248
+
249
+ try {
250
+ /* @var $productObj Mage_Catalog_Model_Product */
251
+ $productObj = Mage::getModel ( 'catalog/product' )->setStoreId ( $storeId )->load ( $productId );
252
+
253
+ if ($productObj->isConfigurable ()) {
254
+ $hasNoConfigurables = false;
255
+ break;
256
+ }
257
+
258
+ // check wether product is in stock
259
+ $stockItem = $productObj->getStockItem ();
260
+
261
+ if ($productObj->getStatus () == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) {
262
+ $this->_disabledProductOrders [] = $order->getOrderId ();
263
+ return self::DISABLED_ORDER_STATUS;
264
+ } elseif (( bool ) $stockItem->getData ( 'is_in_stock' )) {
265
+
266
+ if (floatval ( $productObj->getPrice () ) != floatval ( $orderEntry->getBasePrice () )) {
267
+ $message = sprintf ( __ ( '%s was ordered with a different price (%s instead of current price %s). Was the price changed after exporting to Allyouneed?' ), $productObj->getName (), $orderEntry->getBasePrice (), $productObj->getPrice () );
268
+ Mage::getSingleton ( 'adminhtml/session' )->addNotice ( $message );
269
+ }
270
+
271
+ $item = $quoteObj->addProduct ( $productObj, new Varien_Object ( $request = array (
272
+ 'qty' => ( string ) $orderEntry->getQuantity (),
273
+ 'dhl_mein_paket_item_id' => ( string ) $orderEntry->getMeinPaketId ()
274
+ ) ) );
275
+ /* @var $item Mage_Sales_Model_Quote_Item|string */
276
+
277
+ if (is_object ( $item )) {
278
+ $item->setStoreId ( $storeId );
279
+ $item->setCustomPrice ( $orderEntry->getBasePrice () );
280
+ $item->setOriginalCustomPrice ( $orderEntry->getBasePrice () );
281
+ $item->setOriginalPrice ( $productObj->getPrice () );
282
+ $item->setBaseOriginalPrice ( $productObj->getPrice () );
283
+ $item->getProduct ()->setIsSuperMode ( true );
284
+ } else {
285
+ Mage::log ( $item );
286
+ Mage::getSingleton ( 'adminhtml/session' )->addWarning ( $item );
287
+ return self::INVALID_PRODUCT_STATUS;
288
+ }
289
+ } else {
290
+ $this->_outOfStockOrders [] = $order->getOrderId ();
291
+ return self::OUT_OF_STOCK_ORDER_STATUS;
292
+ }
293
+ } catch ( Exception $e ) {
294
+ Mage::logException ( $e );
295
+ throw new Exception ( 'Could not add product ' . $productId . ' - ' . $e->getMessage () );
296
+ }
297
+ }
298
+ }
299
+
300
+ if (! $hasNoConfigurables) {
301
+ $quoteObj->delete ();
302
+ return 0;
303
+ }
304
+
305
+ if (sizeof ( $quoteItems ) > 0) {
306
+ foreach ( $quoteItems as $quoteItem ) {
307
+ }
308
+ }
309
+
310
+ $rate = $this->calculateRate ( $order );
311
+
312
+ $billingAddress = $quoteObj->getBillingAddress ();
313
+ $billingAddress->addData ( $this->_getAddressData ( $order->getBillingAddress () ) );
314
+ $shippingAddress = $quoteObj->getShippingAddress ();
315
+ if ($order->getDeliveryAddress () != null) {
316
+ $shippingAddress->addData ( $this->_getAddressData ( $order->getDeliveryAddress () ) );
317
+ } else {
318
+ $shippingAddress->addData ( $this->_getAddressData ( $order->getBillingAddress () ) );
319
+ }
320
+
321
+ $shippingAddress->setCollectShippingRates ( false );
322
+ $shippingAddress->addShippingRate ( $rate );
323
+ $shippingAddress->setShippingMethod ( $rate->getCode () );
324
+
325
+ $shippingAddress->setBaseShippingAmount ( $order->getTotalDeliveryCosts () );
326
+ $shippingAddress->setShippingAmount ( $order->getTotalDeliveryCosts () );
327
+ $shippingAddress->setPaymentMethod ( $paymentMethod );
328
+
329
+ $quoteObj->getPayment ()->importData ( array (
330
+ 'method' => $paymentMethod
331
+ ) );
332
+
333
+ // Dhl_MeinPaketCommon_Model_Carrier_Meinpaket::unlock ();
334
+ // Dhl_MeinPaketCommon_Model_Carrier_Meinpaket::setDeliveryCosts ( $order->getTotalDeliveryCosts () );
335
+
336
+ $quoteObj->collectTotals ();
337
+ $quoteObj->save ();
338
+
339
+ /* @var $quoteObj Mage_Sales_Model_Service_Quote */
340
+ $serviceQuote = Mage::getModel ( 'sales/service_quote', $quoteObj );
341
+ $serviceQuote->submitAll ();
342
+
343
+ /* @var $orderModel Mage_Sales_Model_Order */
344
+ $orderModel = $serviceQuote->getOrder ();
345
+ /**
346
+ * triggert aufruf von authorizes() auf dem payment model (ggf auch capture() )
347
+ */
348
+
349
+ $contactData = $order->getContactData ();
350
+
351
+ $orderModel->place ();
352
+ $orderModel->setState ( Mage_Sales_Model_Order::STATE_PROCESSING, true );
353
+ $orderModel->setData ( 'created_at', $this->_getFormattedDateString ( $order->getOrderDate () ) );
354
+ $orderModel->setData ( 'customer_email', strlen ( $contactData->getEmail () ) ? $contactData->getEmail () : Mage::getStoreConfig ( 'meinpaket/customer/default_email' ) );
355
+ $orderModel->setData ( 'ext_customer_id', $contactData->getCustomerId () );
356
+ $orderModel->setData ( 'dhl_mein_paket_order_id', $order->getOrderId () );
357
+ // Zend_Debug::dump($orderModel->debug());die;
358
+ $orderModel->save ();
359
+
360
+ // Dhl_MeinPaketCommon_Model_Carrier_Meinpaket::unlock ();
361
+
362
+ // dispatch event
363
+ Mage::dispatchEvent ( 'dhl_meinpaket_orderimport', array (
364
+ 'orderId' => $orderModel->getId ()
365
+ ) );
366
+
367
+ $this->createInvoice ( $orderModel );
368
+
369
+ return self::IMPORTED_ORDER_STATUS;
370
+ }
371
+
372
+ /**
373
+ * Extracts address data from the given element.
374
+ *
375
+ * @param SimpleXMLElement $addressElement
376
+ * @return array
377
+ */
378
+ protected function _getAddressData(Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Address $address) {
379
+ $addressArray = array (
380
+ 'salutation' => ( string ) $address->getSalutation (),
381
+ 'firstname' => ( string ) $address->getFirstName (),
382
+ 'lastname' => ( string ) $address->getLastName (),
383
+
384
+ // 'street' => ( string ) $address->getStreet (),
385
+ 'postcode' => ( string ) $address->getZipCode (),
386
+ 'city' => ( string ) $address->getCity (),
387
+ 'region_id' => '0', // TODO: make this optional - and add in documentation
388
+ 'country_id' => strtoupper ( $address->getCountry () ),
389
+ 'telephone' => '0000'
390
+ );
391
+
392
+ if (strlen ( $address->getCustomerId () )) {
393
+ $addressArray ['street'] = ( string ) $address->getCustomerId () . "\n" . ( string ) $address->getStreet () . " " . ( string ) $address->getHouseNumber () . "\n" . ( string ) $address->getAddressAddition ();
394
+ } else {
395
+ $addressArray ['street'] = ( string ) $address->getStreet () . " " . ( string ) $address->getHouseNumber () . "\n" . ( string ) $address->getAddressAddition ();
396
+ }
397
+
398
+ if (strlen ( $address->getCompany () )) {
399
+ $addressArray ['company'] = ( string ) $address->getCompany ();
400
+ }
401
+
402
+ return $addressArray;
403
+ }
404
+
405
+ /**
406
+ * Converts the given ISO date string (i.e.
407
+ * "2010-10-27T15:59:59.012+02:00")
408
+ * into the mysql datetime format (i.e. "2010-10-27 15:59:59").
409
+ *
410
+ * @param string $isoDateString
411
+ * @wins Code of the year contest
412
+ * @return string
413
+ */
414
+ protected function _getFormattedDateString($isoDateString) {
415
+ $date = new Zend_Date ( $isoDateString, Zend_Date::ISO_8601 );
416
+ $mysqlDateString = $date->toString ( 'YYYY-MM-dd HH:mm:ss' );
417
+ return $mysqlDateString;
418
+ }
419
+
420
+ /**
421
+ * Get or create customer.
422
+ *
423
+ * @param array $order
424
+ * to check
425
+ * @return Mage_Customer_Model_Customer
426
+ */
427
+ protected function getOrCreateCustomer(Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Order $order) {
428
+ /* @var $customer Mage_Customer_Model_Customer */
429
+ $customer = Mage::getModel ( 'customer/customer' )->getCollection ()->addAttributeToSelect ( 'meinpaket_buyer_id' )->addAttributeToFilter ( 'meinpaket_buyer_id', $order->getContactData ()->getCustomerId () )->load ()->getFirstItem ();
430
+
431
+ if ($customer->getId () != null) {
432
+ return $customer;
433
+ }
434
+
435
+ // Set store and website for loadByEmail.
436
+ $customer->setStore ( Mage::helper ( 'meinpaketcommon/data' )->getMeinPaketStore () );
437
+ // Could not find customer by meinpaket_buyer_id. As there can only be one customer for a given
438
+ // email try to load one.
439
+ $customer->loadByEmail ( $order->getContactData ()->getEmail () );
440
+
441
+ if ($customer->getId () != null) {
442
+ return $customer;
443
+ }
444
+
445
+ // New customer
446
+ // Set store and website again after loadByEmail reset it.
447
+ $customer->setStore ( Mage::helper ( 'meinpaketcommon/data' )->getMeinPaketStore () );
448
+ $customer->setFirstname ( $order->getBillingAddress ()->getFirstName () );
449
+ $customer->setLastname ( $order->getBillingAddress ()->getLastName () );
450
+ $customer->setEmail ( $order->getContactData ()->getEmail () );
451
+
452
+ $groupId = Mage::getStoreConfig ( self::CUSTOMER_GROUP_CONFIG );
453
+ $customer->setData ( 'group_id', $groupId );
454
+
455
+ $customer->setData ( 'meinpaket_buyer_id', $order->getContactData ()->getCustomerId () );
456
+
457
+ if (! $customer->getId ()) {
458
+ // recurring customer
459
+ $customer->setPasswordHash ( $customer->generatePassword () );
460
+ }
461
+
462
+ return $customer;
463
+ }
464
+ public function createInvoice(Mage_Sales_Model_Order $order) {
465
+ /* @var $invoiceModel Sales_Model_Order_Invoice */
466
+ $invoice = $order->prepareInvoice ();
467
+
468
+ $invoice->setRequestedCaptureCase ( Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE );
469
+ $invoice->register ();
470
+ $invoice->setIsInProcess ( true );
471
+
472
+ $transactionSave = Mage::getModel ( 'core/resource_transaction' )->addObject ( $invoice )->addObject ( $invoice->getOrder () )->save ();
473
+ }
474
+
475
+ /**
476
+ * Calculate carrier rate.
477
+ *
478
+ * @param Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Order $order
479
+ * @return Mage_Sales_Model_Quote_Address_Rate
480
+ */
481
+ protected function calculateRate(Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Order $order) {
482
+ $carrier = Mage::getModel ( 'meinpaketcommon/carrier_meinpaket' );
483
+ /* @var $carrier Dhl_MeinPaketCommon_Model_Carrier_Meinpaket */
484
+ $methods = $carrier->getAllowedMethods ();
485
+ $result = Mage::getModel ( 'sales/quote_address_rate' );
486
+ /* @var $result Mage_Sales_Model_Quote_Address_Rate */
487
+
488
+ $parts = explode ( "_", self::IMPORT_SHIPPING_METHOD );
489
+
490
+ $result->setCarrierTitle ( 'Allyouneed' )->setCode ( self::IMPORT_SHIPPING_METHOD )->setCarrier ( $parts [0] )->setMethod ( 'standard' )->setMethodTitle ( 'Allyouneed' )->setMethodDescription ( 'Allyouneed' )->setCost ( $order->getTotalDeliveryCosts () )->setPrice ( $order->getTotalDeliveryCosts () );
491
+
492
+ return $result;
493
+ }
494
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Service/Order/RefundExportService.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Service class which sends a refund to Allyouneed.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Service_RefundExport
9
+ * @version $Id$
10
+ */
11
+ class Dhl_MeinPaketCommon_Model_Service_Order_RefundExportService {
12
+ /**
13
+ * Exports the given refunded creditmemo to Allyouneed.
14
+ *
15
+ * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
16
+ * @throws Dhl_MeinPaketCommon_Model_Xml_XmlBuildException
17
+ * @throws Dhl_MeinPaketCommon_Model_Client_BadHttpReturnCodeException
18
+ * @throws Dhl_MeinPaketCommon_Model_Client_HttpTimeoutException
19
+ * @throws Dhl_MeinPaketCommon_Model_Xml_InvalidXmlException
20
+ * @return Dhl_MeinPaketCommon_Model_Sevice_RefundExport_Result
21
+ */
22
+ public function exportRefund(Mage_Sales_Model_Order_Creditmemo $creditmemo) {
23
+ /* @var $httpClient Dhl_MeinPaketCommon_Model_Client_XmlOverHttp */
24
+ $httpClient = Mage::getModel ( 'meinpaketcommon/client_xmlOverHttp' );
25
+
26
+ /* @var $notificationRequest Dhl_MeinPaketCommon_Model_Xml_Request_NotificationRequest */
27
+ $notificationRequest = Mage::getModel ( 'meinpaketcommon/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/MeinPaketCommon/Model/Service/Order/RefundExportService/Result.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Service_Order_RefundExportService_Result extends Dhl_MeinPaketCommon_Model_Service_Result_Abstract {
12
+ /**
13
+ *
14
+ * @var string
15
+ */
16
+ protected $originalRefundId = '-1';
17
+
18
+ /**
19
+ *
20
+ * @var string
21
+ */
22
+ protected $returnedRefundId = '-2';
23
+
24
+ /**
25
+ *
26
+ * @param string $refundId
27
+ * @return void
28
+ */
29
+ public function setOriginalRefundId($refundId) {
30
+ if (! is_string ( $refundId )) {
31
+ $refundId = ( string ) $refundId;
32
+ }
33
+ $this->originalRefundId = $refundId;
34
+ }
35
+
36
+ /**
37
+ *
38
+ * @param string $refundId
39
+ * @return void
40
+ */
41
+ public function setReturnedRefundId($refundId) {
42
+ if (! is_string ( $refundId )) {
43
+ $refundId = ( string ) $refundId;
44
+ }
45
+ $this->returnedRefundId = $refundId;
46
+ }
47
+
48
+ /**
49
+ * Tells if the refund has been accepted by Allyouneed.
50
+ *
51
+ * @return boolean
52
+ */
53
+ public function hasBeenAccepted() {
54
+ return ($this->originalRefundId === $this->returnedRefundId);
55
+ }
56
+ }
57
+
app/code/community/Dhl/MeinPaketCommon/Model/Service/Order/ShipmentExportService.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Service which exports an order's shipment to Allyouneed.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Service_ShipmentExport
9
+ * @version $Id$
10
+ */
11
+ class Dhl_MeinPaketCommon_Model_Service_Order_ShipmentExportService {
12
+ /**
13
+ * Exports a shipment to Allyouneed.
14
+ *
15
+ * @param Mage_Sales_Model_Order_Shipment $shipment
16
+ * @throws Dhl_MeinPaketCommon_Model_Xml_XmlBuildException
17
+ * @throws Dhl_MeinPaketCommon_Model_Client_BadHttpReturnCodeException
18
+ * @throws Dhl_MeinPaketCommon_Model_Client_HttpTimeoutException
19
+ * @throws Dhl_MeinPaketCommon_Model_Xml_InvalidXmlException
20
+ * @return Dhl_MeinPaketCommon_Model_Xml_Response_NotificationResponse
21
+ */
22
+ public function exportShipment(Mage_Sales_Model_Order_Shipment $shipment) {
23
+ $notificationRequest = new Dhl_MeinPaketCommon_Model_Xml_Request_NotificationRequest ();
24
+
25
+ /* @var $client Dhl_MeinPaketCommon_Model_Client_XmlOverHttp */
26
+ $client = Mage::getModel ( 'meinpaketcommon/client_xmlOverHttp' );
27
+
28
+ $notificationRequest->addConsignment ( $shipment );
29
+
30
+ /* @var $responseXml Dhl_MeinPaketCommon_Model_Xml_Response_NotificationResponse */
31
+ $responseXml = $client->send ( $notificationRequest );
32
+
33
+ return $responseXml;
34
+ }
35
+
36
+ /**
37
+ * Exports the tracking number of a shipment to Allyouneed.
38
+ *
39
+ * @param Mage_Sales_Model_Order_Shipment $shipment
40
+ * The shipment which tracking numbers shall be exported.
41
+ * @throws Dhl_MeinPaketCommon_Model_Xml_XmlBuildException
42
+ * @throws Dhl_MeinPaketCommon_Model_Client_BadHttpReturnCodeException
43
+ * @throws Dhl_MeinPaketCommon_Model_Client_HttpTimeoutException
44
+ * @throws Dhl_MeinPaketCommon_Model_Xml_InvalidXmlException
45
+ * @return Dhl_MeinPaketCommon_Model_Service_TrackingNumberExport_Result
46
+ */
47
+ public function exportTrackingNumber(Mage_Sales_Model_Order_Shipment_Track $track) {
48
+ $notificationRequest = new Dhl_MeinPaketCommon_Model_Xml_Request_NotificationRequest ();
49
+
50
+ /* @var $client Dhl_MeinPaketCommon_Model_Client_XmlOverHttp */
51
+ $client = Mage::getModel ( 'meinpaketcommon/client_xmlOverHttp' );
52
+
53
+ $notificationRequest->addTrackingNumber ( $track );
54
+
55
+ try {
56
+ $responseXml = $client->send ( $notificationRequest );
57
+ // TODO: parse
58
+ } catch ( Exception $e ) {
59
+ Mage::logException ( $e );
60
+ throw $e;
61
+ }
62
+
63
+ return null;
64
+ }
65
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Service/Order/ShipmentExportService/Result.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Service_Order_ShipmentExportService_Result extends Dhl_MeinPaketCommon_Model_Service_Result_Abstract {
12
+ /**
13
+ *
14
+ * @var string
15
+ */
16
+ protected $consignmentId = '';
17
+
18
+ /**
19
+ *
20
+ * @var string
21
+ */
22
+ protected $responseConsignmentId = '_';
23
+
24
+ /**
25
+ * Sets the consignment id of the shipment.
26
+ *
27
+ * @param string $consignmentId
28
+ * @return Dhl_MeinPaketCommon_Model_Service_ShipmentExport_Result
29
+ */
30
+ public function setConsignmentId($consignmentId) {
31
+ $this->consignmentId = $consignmentId;
32
+ return $this;
33
+ }
34
+
35
+ /**
36
+ * Sets the consignment id of the shipment which was returned from Allyouneed.
37
+ *
38
+ * @param string $consignmentId
39
+ * @return Dhl_MeinPaketCommon_Model_Service_ShipmentExport_Result
40
+ */
41
+ public function setResponseConsignmentId($responseConsignmentId) {
42
+ $this->responseConsignmentId = $responseConsignmentId;
43
+ return $this;
44
+ }
45
+
46
+ /**
47
+ * Tells if the send consignment id has been returned by Allyouneed.
48
+ * If this is true, the consignment has been accepted.
49
+ *
50
+ * @return boolean
51
+ */
52
+ public function hasBeenAccepted() {
53
+ return ($this->consignmentId === $this->responseConsignmentId);
54
+ }
55
+ }
56
+
app/code/community/Dhl/MeinPaketCommon/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_MeinPaketCommon_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/MeinPaketCommon/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_MeinPaketCommon_Model_Service_Result_Upload extends Dhl_MeinPaketCommon_Model_Service_Result_Abstract {
12
+ }
13
+
app/code/community/Dhl/MeinPaketCommon/Model/System/MemoryLimiter.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_System_MemoryLimiter extends Varien_Object {
12
+ /**
13
+ *
14
+ * @var integer
15
+ */
16
+ const MEMORY_LIMIT_MEDIUM = 256;
17
+
18
+ /**
19
+ *
20
+ * @var integer
21
+ */
22
+ const MEMORY_LIMIT_HIGH = 512;
23
+
24
+ /**
25
+ *
26
+ * @var integer
27
+ */
28
+ const MEMORY_LIMIT_VERY_HIGH = 1024;
29
+
30
+ /**
31
+ * Sets the memory limit for the current script.
32
+ * If the current setting from PHP ini is greater than the given value,
33
+ * the method call will have no effect.
34
+ *
35
+ * @param integer $limit
36
+ * @return void
37
+ *
38
+ */
39
+ public function setMemoryLimit($limit) {
40
+ if (! in_array ( $limit, $this->getAllowedMemoryLimitValues () )) {
41
+ return;
42
+ }
43
+
44
+ $currentLimit = $this->getLimitFromIni ();
45
+
46
+ if ($currentLimit < $limit) {
47
+ ini_set ( 'memory_limit', $limit . 'M' );
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Returns the current memory limit in megabytes.
53
+ *
54
+ * @return integer
55
+ */
56
+ protected function getLimitFromIni() {
57
+ return ( integer ) trim ( str_replace ( "M", "", ini_get ( 'memory_limit' ) ) );
58
+ }
59
+
60
+ /**
61
+ * Returns the values that are valid as a parameter for method setMemoryLimit.
62
+ *
63
+ * @return array
64
+ */
65
+ protected function getAllowedMemoryLimitValues() {
66
+ return array (
67
+ self::MEMORY_LIMIT_MEDIUM,
68
+ self::MEMORY_LIMIT_HIGH,
69
+ self::MEMORY_LIMIT_VERY_HIGH
70
+ );
71
+ }
72
+ }
73
+
app/code/community/Dhl/MeinPaketCommon/Model/Validation/ValidationInterface.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Common validation interface.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Validation
9
+ * @version $Id$
10
+ */
11
+ interface Dhl_MeinPaketCommon_Model_Validation_ValidationInterface {
12
+ const ERROR_UNDEFINED = 'undefinedError';
13
+ const ERROR_REQUIRED_FIELD_IS_EMPTY = 'fieldIsEmpty';
14
+ const ERROR_FIELD_IS_INVALID = 'invalidField';
15
+ const ERROR_PRODUCT_NOT_EXISTS_IN_MEINPAKET = 'PRODUCT_NOT_FOUND';
16
+ const ERROR_MEINPAKET_SERVER_ERROR = 'SERVER_ERROR';
17
+ const ERROR_PRODUCT_NEGATIVE_STOCK = 'AVAILABILITY_NEGATIVE';
18
+ const ERROR_NOT_AUTHORIZED = 'NOT_AUTHORIZED';
19
+ const ERROR_INVALID_DATA = 'INVALID_DATA';
20
+ const ERROR_INVALID_MODIFICATION = 'INVALID_MODIFICATION';
21
+ const ERROR_NO_CATEGORIZATION = 'NO_CATEGORIZATION';
22
+ const ERROR_PRODUCT_NOT_SELLABLE = 'PRODUCT_NOT_SELLABLE';
23
+ const ERROR_MARKETPLACE_CATEGORY_NOT_FOUND = 'MARKETPLACE_CATEGORY_NOT_FOUND';
24
+ const ERROR_SHOP_CATEGORY_NOT_FOUND = 'SHOP_CATEGORY_NOT_FOUND';
25
+ const ERROR_MISSING_VALUE_FOR_ATTRIBUTE = 'MISSING_VALUE_FOR_ATTRIBUTE';
26
+ const ERROR_VARIANT_GROUP_NOT_EXISTS = 'VARIANT_GROUP_NOT_FOUND';
27
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Validation/Validator/CDATAContent.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Validation_Validator_CDATAContent implements Dhl_MeinPaketCommon_Model_Validation_ValidatorInterface {
12
+ /**
13
+ * Validates a string to be valid content of a CDATA block.
14
+ *
15
+ * @param mixed $value
16
+ * @return boolean
17
+ */
18
+ public function isValid($value) {
19
+ return (preg_match ( '~' . preg_quote ( ']]>' ) . '~', $value ) === 0);
20
+ }
21
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Validation/Validator/Ean.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Validation_Validator_Ean implements Dhl_MeinPaketCommon_Model_Validation_ValidatorInterface {
12
+ /**
13
+ * Validates an EAN.
14
+ *
15
+ * @param mixed $value
16
+ * @return boolean
17
+ */
18
+ public function isValid($value) {
19
+ $length = 0;
20
+ $checkSum = 0;
21
+ $char = '';
22
+ $validLengths = array (
23
+ 13
24
+ ); // @todo check why array(13, 8) isn't possible
25
+
26
+ if (! is_string ( $value )) {
27
+ $value = ( string ) $value;
28
+ }
29
+
30
+ $length = strlen ( $value );
31
+
32
+ // check for length
33
+ if (! in_array ( $length, $validLengths )) {
34
+ return false;
35
+ }
36
+
37
+ // perform checksum check
38
+ for($i = 0; $i < $length; $i ++) {
39
+
40
+ $char = substr ( $value, $i, 1 );
41
+
42
+ if (! preg_match ( '~\d~', $char )) {
43
+ return false;
44
+ }
45
+
46
+ if ($i % 2 == 0) {
47
+ $checkSum += (( integer ) $char) * 1;
48
+ } else {
49
+ $checkSum += (( integer ) $char) * 3;
50
+ }
51
+ }
52
+ if ($checkSum % 10 != 0) {
53
+ return false;
54
+ }
55
+
56
+ return true;
57
+ }
58
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Validation/Validator/IntGreaterZero.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Validation_Validator_IntGreaterZero implements Dhl_MeinPaketCommon_Model_Validation_ValidatorInterface {
12
+ /**
13
+ * Validates an integer value to be greater than zero.
14
+ *
15
+ * @param mixed $value
16
+ * @return boolean
17
+ */
18
+ public function isValid($value) {
19
+ return (( integer ) $value > 0);
20
+ }
21
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Validation/Validator/NonEmptyString.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Validation_Validator_NonEmptyString implements Dhl_MeinPaketCommon_Model_Validation_ValidatorInterface {
12
+ /**
13
+ * Validates the given value.
14
+ * Checks if the given has at least one character.
15
+ *
16
+ * @param mixed $value
17
+ * @return boolean
18
+ */
19
+ public function isValid($value) {
20
+ return (is_string ( $value ) && strlen ( $value ) > 0);
21
+ }
22
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Validation/Validator/StringMaxLength.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Validation_Validator_StringMaxLength implements Dhl_MeinPaketCommon_Model_Validation_ValidatorInterface {
12
+ /**
13
+ *
14
+ * @var integer
15
+ */
16
+ const LENGTH_INFINITE = - 1;
17
+
18
+ /**
19
+ *
20
+ * @var integer
21
+ */
22
+ protected $maxLength = self::LENGTH_INFINITE;
23
+
24
+ /**
25
+ * Validates a string not to be longer than the set length.
26
+ *
27
+ * @param mixed $value
28
+ * @return boolean
29
+ */
30
+ public function isValid($value) {
31
+ $value = @(( string ) $value);
32
+ $valid = true;
33
+
34
+ if (! is_string ( $value )) {
35
+ return false;
36
+ }
37
+
38
+ if ($this->maxLength !== self::LENGTH_INFINITE) {
39
+ $valid = (strlen ( $value ) <= $this->maxLength);
40
+ }
41
+
42
+ return $valid;
43
+ }
44
+
45
+ /**
46
+ * Sets the maximum allowed length.
47
+ *
48
+ * @param integer $length
49
+ * @return Dhl_MeinPaketCommon_Model_Validation_Validator_StringMaxLength
50
+ */
51
+ public function setMaxLength($length) {
52
+ if (is_integer ( $length ) && $length >= 0) {
53
+ $this->maxLength = $length;
54
+ }
55
+ return $this;
56
+ }
57
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Validation/Validator/Url.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Validation_Validator_Url implements Dhl_MeinPaketCommon_Model_Validation_ValidatorInterface {
12
+ /**
13
+ * Validates an URL.
14
+ *
15
+ * @param mixed $value
16
+ * @return boolean
17
+ */
18
+ public function isValid($value) {
19
+ return (substr ( $value, 0, 4 ) === 'http');
20
+ }
21
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Validation/ValidatorChain.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Validation_ValidatorChain implements Dhl_MeinPaketCommon_Model_Validation_ValidatorInterface {
12
+ /**
13
+ *
14
+ * @var array
15
+ */
16
+ protected $validators = array ();
17
+
18
+ /**
19
+ * Returns the chained result of all validators.
20
+ *
21
+ * @param mixed $value
22
+ * @return boolean
23
+ */
24
+ public function isValid($value) {
25
+ if (sizeof ( $this->validators ) > 0) {
26
+ foreach ( $this->validators as $validator ) {
27
+ if (! $validator->isValid ( $value )) {
28
+ return false;
29
+ }
30
+ }
31
+ }
32
+
33
+ return true;
34
+ }
35
+
36
+ /**
37
+ * Adds a validator to the end of the chain.
38
+ *
39
+ * @param Dhl_MeinPaketCommon_Model_Validation_ValidatorInterface $validator
40
+ * @return Dhl_MeinPaketCommon_Model_Validation_ValidatorChain
41
+ */
42
+ public function addValidator(Dhl_MeinPaketCommon_Model_Validation_ValidatorInterface $validator) {
43
+ $this->validators [] = $validator;
44
+ return $this;
45
+ }
46
+ }
47
+
app/code/community/Dhl/MeinPaketCommon/Model/Validation/ValidatorInterface.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ interface Dhl_MeinPaketCommon_Model_Validation_ValidatorInterface {
12
+
13
+ /**
14
+ * Validates the given value.
15
+ *
16
+ * @param mixed $value
17
+ * @return boolean
18
+ */
19
+ public function isValid($value);
20
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Xml/AbstractXmlPartial.php ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ abstract class Dhl_MeinPaketCommon_Model_Xml_AbstractXmlPartial {
12
+ /**
13
+ *
14
+ * @var DOMNode
15
+ */
16
+ protected $node = null;
17
+
18
+ /**
19
+ *
20
+ * @var DOMDocument
21
+ */
22
+ protected $document = null;
23
+
24
+ /**
25
+ * Default constructor.
26
+ *
27
+ * @param DOMDocument $document
28
+ */
29
+ public function __construct(DOMDocument $document) {
30
+ $this->setDocument ( $document );
31
+ }
32
+
33
+ /**
34
+ * Returns the DOM node of the element.
35
+ * The build() method has to be called before. Otherwise
36
+ * this method will return null.
37
+ *
38
+ * @return DOMNode
39
+ */
40
+ public function getNode() {
41
+ return $this->node;
42
+ }
43
+
44
+ /**
45
+ * Returns the associated document.
46
+ *
47
+ * @return DOMDocument
48
+ */
49
+ protected function getDocument() {
50
+ return $this->document;
51
+ }
52
+ /**
53
+ * Returns the associated root document.
54
+ *
55
+ * @return DOMNode
56
+ */
57
+ protected function getDocumentElement() {
58
+ if ($this->document != null) {
59
+ return $this->document->documentElement;
60
+ }
61
+ return null;
62
+ }
63
+
64
+ /**
65
+ * Sets the DOM document.
66
+ *
67
+ * @param DOMDocument $document
68
+ * @return Dhl_MeinPaketCommon_Model_Xml_AbstractXmlPartial
69
+ */
70
+ public function setDocument(DOMDocument $document) {
71
+ if ($document == null) {
72
+ throw new InvalidArgumentException ( "Invalid DOMDocument given" );
73
+ }
74
+
75
+ $this->document = $document;
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ *
81
+ * @param integer $time
82
+ * @return string
83
+ */
84
+ protected function getFormatedDate($time) {
85
+ $date = date ( 'c', $time );
86
+ $dateExploded = explode ( '+', $date );
87
+ return $dateExploded [0];
88
+ }
89
+
90
+ /**
91
+ * Builds the DOM node.
92
+ *
93
+ * @return DOMNode
94
+ */
95
+ abstract public function build();
96
+
97
+ /**
98
+ * Creates a CDATA noe.
99
+ *
100
+ * @param string $nodeName
101
+ * name.
102
+ * @param string $content
103
+ * @return DOMElement
104
+ */
105
+ protected function getCDATANode($nodeName, $content) {
106
+ $node = $this->getDocument ()->createElement ( $nodeName );
107
+ $node->appendChild ( $this->getDocument ()->createCDATASection ( $content ) );
108
+ return $node;
109
+ }
110
+
111
+ /**
112
+ * Simple validation for element content.
113
+ *
114
+ * @param string $content
115
+ * @param string $validatorType
116
+ * @return boolean
117
+ */
118
+ protected function isValid($content, $validatorType) {
119
+ $valid = false;
120
+
121
+ switch ($validatorType) {
122
+ case 'nonEmptyString' :
123
+ $valid = Mage::getModel ( 'meinpaket/Validation_Validator_NonEmptyString' )->isValid ( $content );
124
+ break;
125
+ case 'ean' :
126
+ $valid = Mage::getModel ( 'meinpaket/Validation_Validator_Ean' )->isValid ( $content );
127
+ break;
128
+ }
129
+
130
+ return $valid;
131
+ }
132
+
133
+ /**
134
+ * Returns an instance of Dhl_MeinPaketCommon_Model_Validation_ValidatorFactory.
135
+ *
136
+ * @return Dhl_MeinPaketCommon_Model_Validation_ValidatorFactory
137
+ */
138
+ protected function getValidatorFactory() {
139
+ return Mage::getSingleton ( 'meinpaket/Validation_ValidatorFactory' );
140
+ }
141
+
142
+ /**
143
+ * Creates an ISO date string without trailing timezone offset for the
144
+ * given timestamp.
145
+ *
146
+ * @param integer $timestamp
147
+ * @return string
148
+ */
149
+ public function getIsoDateTime($timestamp = null) {
150
+ $isoString = '';
151
+ $format = 'Y-m-d\TH:i:s';
152
+
153
+ if ($timestamp === null) {
154
+ $isoString = date ( $format );
155
+ } else {
156
+ $isoString = date ( $format, $timestamp );
157
+ }
158
+
159
+ return $isoString;
160
+ }
161
+ /**
162
+ * Convert HTML entities to UTF- 8special chars while leaving the already existing special chars intact
163
+ *
164
+ * @param string $string
165
+ * @return string
166
+ */
167
+ protected function escapeStringForMeinPaket($string) {
168
+ $string = utf8_decode ( $string );
169
+ $string = html_entity_decode ( $string );
170
+ $string = utf8_encode ( $string );
171
+
172
+ return $string;
173
+ }
174
+
175
+ /**
176
+ * Create a string from created document.
177
+ *
178
+ * @return string
179
+ */
180
+ public function __toString() {
181
+ return $this->getDocument ()->saveXML ();
182
+ }
183
+ }
184
+
app/code/community/Dhl/MeinPaketCommon/Model/Xml/AbstractXmlRequest.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ abstract class Dhl_MeinPaketCommon_Model_Xml_AbstractXmlRequest extends Dhl_MeinPaketCommon_Model_Xml_AbstractXmlPartial {
12
+ // const XMLNS = 'http://www.meinpaket.de/xsd/dietmar/1.0/products';
13
+ const XMLNS_COMMON = 'http://www.meinpaket.de/xsd/dietmar/1.0/common';
14
+ const XMLNS_DATA = 'http://www.meinpaket.de/xsd/dietmar/1.0/data';
15
+ const XMLNS_PRODUCTS = 'http://www.meinpaket.de/xsd/dietmar/1.0/products';
16
+ const XMLNS_ORDERS = 'http://www.meinpaket.de/xsd/dietmar/1.0/orders';
17
+ const XMLNS_CHECKOUT = 'http://www.meinpaket.de/xsd/dietmar/1.0/checkout';
18
+ const XMLNS_ASYNCHRONOUS = 'http://www.meinpaket.de/xsd/dietmar/1.0/asynchronous';
19
+
20
+ /**
21
+ * The XML-version of the generated XML.
22
+ *
23
+ * @var string
24
+ */
25
+ const XML_VERSION = '1.0';
26
+
27
+ /**
28
+ * The charset which is set in the XML prologue of the generated XML.
29
+ *
30
+ * @var string
31
+ */
32
+ const XML_CHARSET = 'UTF-8';
33
+
34
+ /**
35
+ * Has data been added
36
+ *
37
+ * @var boolean
38
+ */
39
+ protected $hasData = false;
40
+
41
+ /**
42
+ * Default constructor.
43
+ *
44
+ * @param DOMDocument $document
45
+ */
46
+ public function __construct(DOMDocument $document = null) {
47
+ parent::__construct ( $document === null ? new DOMDocument ( self::XML_VERSION, self::XML_CHARSET ) : $document );
48
+ $this->createDocumentElement ();
49
+ $this->addHeader ();
50
+ }
51
+ public function addHeader() {
52
+ $username = Mage::getStoreConfig ( 'meinpaket/credentials/username' );
53
+ $passwordCrypted = Mage::getStoreConfig ( 'meinpaket/credentials/password' );
54
+ $password = Mage::helper ( 'core' )->decrypt ( $passwordCrypted );
55
+
56
+ if (! is_string ( $username ) || ! is_string ( $password ) || strlen ( $username ) <= 0 || strlen ( $password ) <= 0) {
57
+ throw new Dhl_MeinPaketCommon_Model_Xml_XmlBuildException ( 'No authentication parameters set.' );
58
+ }
59
+
60
+ $headerNode = $this->getDocument ()->createElement ( 'common:header' );
61
+ $usernameNode = $this->getDocument ()->createElement ( 'common:login' );
62
+ $passwordNode = $this->getDocument ()->createElement ( 'common:password' );
63
+ $languageNode = $this->getDocument ()->createElement ( 'common:language', 'de' );
64
+ $multiplierIdNode = $this->getDocument ()->createElement ( 'common:multiplierId', 'MAGENTO' );
65
+
66
+ $usernameNode->appendChild ( $this->getDocument ()->createTextNode ( $username ) );
67
+ $passwordNode->appendChild ( $this->getDocument ()->createTextNode ( $password ) );
68
+
69
+ $headerNode->appendChild ( $usernameNode );
70
+ $headerNode->appendChild ( $passwordNode );
71
+ $headerNode->appendChild ( $languageNode );
72
+ $headerNode->appendChild ( $multiplierIdNode );
73
+
74
+ $this->getDocumentElement ()->appendChild ( $headerNode );
75
+ }
76
+
77
+ /**
78
+ * Builds the DOM node.
79
+ *
80
+ * @return Dhl_MeinPaketCommon_Model_Xml_AbstractXmlPartial
81
+ */
82
+ public function build() {
83
+ // No need to be build
84
+ return $this;
85
+ }
86
+
87
+ /**
88
+ * Is has data set?
89
+ *
90
+ * @return boolean
91
+ */
92
+ public function isHasData() {
93
+ return $this->hasData;
94
+ }
95
+
96
+ /**
97
+ * Set has data.
98
+ *
99
+ * @param boolean $value
100
+ */
101
+ public function setHasData($value = true) {
102
+ $this->hasData = $value;
103
+ }
104
+
105
+ /**
106
+ * Create the root element for the document.
107
+ *
108
+ * @return DOMNode
109
+ */
110
+ abstract public function createDocumentElement();
111
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Xml/InvalidXmlException.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Xml_InvalidXmlException extends Varien_Exception {
12
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Xml/Request/AsynchronousStatusRequest.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Xml_Request_AsynchronousStatusRequest extends Dhl_MeinPaketCommon_Model_Xml_AbstractXmlRequest {
12
+ /**
13
+ * RequesdId for this request
14
+ *
15
+ * @var unknown
16
+ */
17
+ protected $requestId;
18
+
19
+ /**
20
+ * Default Constructor.
21
+ */
22
+ public function __construct() {
23
+ parent::__construct ();
24
+ }
25
+
26
+ /**
27
+ * Create the root element for the document.
28
+ *
29
+ * @return DOMNode
30
+ */
31
+ public function createDocumentElement() {
32
+ $this->node = $this->getDocument ()->createElement ( 'asynchronousStatusRequest' );
33
+ $this->node->setAttribute ( 'xmlns', self::XMLNS_ASYNCHRONOUS );
34
+ $this->node->setAttribute ( 'xmlns:common', self::XMLNS_COMMON );
35
+ $this->node->setAttribute ( 'version', '1.0' );
36
+ $this->getDocument ()->appendChild ( $this->node );
37
+ }
38
+
39
+ /**
40
+ * Creates the request XML for a category structure download request.
41
+ */
42
+ public function addRequestStatus($requestId, $onlyStatus = 'false') {
43
+ if (strlen ( $requestId ) > 0) {
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
+ $this->setHasData ( true );
55
+ }
56
+ return $this;
57
+ }
58
+ public function getRequestId() {
59
+ return $this->requestId;
60
+ }
61
+ }
app/code/community/Dhl/MeinPaketCommon/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_MeinPaketCommon_Model_Xml_Partial
10
+ */
11
+ class Dhl_MeinPaketCommon_Model_Xml_Request_DataRequest extends Dhl_MeinPaketCommon_Model_Xml_AbstractXmlRequest {
12
+ /**
13
+ *
14
+ * @var Dhl_MeinPaketCommon_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/MeinPaketCommon/Model/Xml/Request/DownloadRequest.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Xml_Request_DownloadRequest extends Dhl_MeinPaketCommon_Model_Xml_AbstractXmlRequest {
12
+ /**
13
+ * Default Constructor.
14
+ */
15
+ public function __construct() {
16
+ parent::__construct();
17
+ }
18
+
19
+ /**
20
+ * Create the root element for the document.
21
+ *
22
+ * @return DOMNode
23
+ */
24
+ public function createDocumentElement() {
25
+ $this->node = $this->getDocument ()->createElement ( 'downloadRequest' );
26
+ $this->node->setAttribute ( 'xmlns', self::XMLNS_PRODUCTS );
27
+ $this->node->setAttribute ( 'xmlns:common', self::XMLNS_COMMON );
28
+ $this->node->setAttribute ( 'version', '1.0' );
29
+ $this->getDocument ()->appendChild ( $this->node );
30
+ }
31
+
32
+ /**
33
+ * Creates the request XML for a category structure download request.
34
+ */
35
+ public function addDownloadMarketplaceCategories() {
36
+ $this->getDocumentElement ()->appendChild ( $this->getDocument ()->createElement ( 'catalogstructure', 'marketplace' ) );
37
+ }
38
+ public function addDownloadOffers() {
39
+ $this->getDocumentElement ()->appendChild ( $this->getDocument ()->createElement ( 'getProductOffers' ) );
40
+ }
41
+ public function addVariantConfigurations() {
42
+ $this->getDocumentElement ()->appendChild ( $this->getDocument ()->createElement ( 'variantConfigurations' ) );
43
+ }
44
+ public function addInternationalPrices() {
45
+ $this->getDocumentElement ()->appendChild ( $this->getDocument ()->createElement ( 'getInternationalPrices' ) );
46
+ }
47
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Xml/Request/NotificationRequest.php ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Xml_Request_NotificationRequest extends Dhl_MeinPaketCommon_Model_Xml_AbstractXmlRequest {
12
+ /**
13
+ *
14
+ * @var DOMNode
15
+ */
16
+ protected $cancellations = null;
17
+ /**
18
+ *
19
+ * @var DOMNode
20
+ */
21
+ protected $consignments = null;
22
+ /**
23
+ *
24
+ * @var DOMNode
25
+ */
26
+ protected $trackingNumbers = null;
27
+ /**
28
+ *
29
+ * @var DOMNode
30
+ */
31
+ protected $returns = null;
32
+ /**
33
+ *
34
+ * @var DOMNode
35
+ */
36
+ protected $credits = null;
37
+
38
+ /**
39
+ * Default Constructor.
40
+ */
41
+ public function __construct() {
42
+ parent::__construct ();
43
+ }
44
+
45
+ /**
46
+ * Create the root element for the document.
47
+ *
48
+ * @return DOMNode
49
+ */
50
+ public function createDocumentElement() {
51
+ $this->node = $this->getDocument ()->createElement ( 'notificationRequest' );
52
+ $this->node->setAttribute ( 'xmlns', self::XMLNS_ORDERS );
53
+ $this->node->setAttribute ( 'xmlns:common', self::XMLNS_COMMON );
54
+ $this->node->setAttribute ( 'version', '1.0' );
55
+ $this->getDocument ()->appendChild ( $this->node );
56
+ }
57
+
58
+ /**
59
+ *
60
+ * @param Mage_Sales_Model_Order_Shipment $shipment
61
+ * @param Mage_Sales_Model_Order $order
62
+ * @param mixed $trackingNumber
63
+ * null or trackingNumber
64
+ * @return DOMNode|Ambigous <boolean, DOMElement>
65
+ */
66
+ public function addConsignment(Mage_Sales_Model_Order_Shipment $shipment, Mage_Sales_Model_Order $order = null, $trackingNumber = null) {
67
+ $consignmentNode = $this->getDocument ()->createElement ( 'consignment' );
68
+ $this->getConsignments ()->appendChild ( $consignmentNode );
69
+
70
+ if ($order == null) {
71
+ $order = $shipment->getOrder ();
72
+ }
73
+
74
+ $orderIdNode = $this->getDocument ()->createElement ( 'orderId', $order->getDhlMeinPaketOrderId () );
75
+ $consignmentNode->appendChild ( $orderIdNode );
76
+
77
+ $consignmentIdNode = $this->getDocument ()->createElement ( 'consignmentId', $shipment->getId () );
78
+ $consignmentNode->appendChild ( $consignmentIdNode );
79
+
80
+ if ($trackingNumber == null) {
81
+ foreach ( $shipment->getAllTracks () as $track ) {
82
+ // take the last one
83
+ $trackingNumber = $track->getNumber ();
84
+ }
85
+ }
86
+
87
+ if (strlen ( $trackingNumber )) {
88
+ $trackingIdNode = $this->getDocument ()->createElement ( 'trackingId', $trackingNumber );
89
+ $consignmentNode->appendChild ( $trackingIdNode );
90
+ }
91
+
92
+ foreach ( $shipment->getAllItems () as $item ) {
93
+ $consignmentEntryNode = $this->getDocument ()->createElement ( 'consignmentEntry' );
94
+ $consignmentNode->appendChild ( $consignmentEntryNode );
95
+
96
+ $consignmentEntryNode->appendChild ( $this->getDocument ()->createElement ( 'common:productId', $item->getProductId () ) );
97
+ $consignmentEntryNode->appendChild ( $this->getDocument ()->createElement ( 'quantity', ( int ) $item->getQty () ) );
98
+ }
99
+
100
+ $this->setHasData();
101
+
102
+ return $this;
103
+ }
104
+
105
+ /**
106
+ *
107
+ * @param Mage_Sales_Model_Order_Shipment_Track $trackingNumber
108
+ * @return DOMNode|Ambigous <boolean, DOMElement>
109
+ */
110
+ public function addTrackingNumber(Mage_Sales_Model_Order_Shipment_Track $trackingNumber) {
111
+ $trackingNumberNode = $this->getDocument ()->createElement ( 'trackingNumber' );
112
+ $this->getTrackingNumbers ()->appendChild ( $trackingNumberNode );
113
+
114
+ $consignmentIdNode = $this->getDocument ()->createElement ( 'consignmentId', $trackingNumber->getShipment ()->getId () );
115
+ $trackingNumberNode->appendChild ( $consignmentIdNode );
116
+
117
+ $trackingIdNode = $this->getDocument ()->createElement ( 'trackingId', $trackingNumber->getNumber () );
118
+ $trackingNumberNode->appendChild ( $trackingIdNode );
119
+
120
+ $this->setHasData();
121
+
122
+ return $this;
123
+ }
124
+
125
+ /**
126
+ *
127
+ * @param Mage_Sales_Model_Order_Shipment $shipment
128
+ * @param Mage_Sales_Model_Order $order
129
+ * @param mixed $trackingNumber
130
+ * null or trackingNumber
131
+ * @return DOMNode|Ambigous <boolean, DOMElement>
132
+ */
133
+ public function addCancellation(Mage_Sales_Model_Order $order) {
134
+ $cancellationNode = $this->getDocument ()->createElement ( 'cancellation' );
135
+ $this->getCancellations ()->appendChild ( $cancellationNode );
136
+
137
+ $orderIdNode = $this->getDocument ()->createElement ( 'orderId', $order->getData ( 'dhl_mein_paket_order_id' ) );
138
+ $cancellationNode->appendChild ( $orderIdNode );
139
+
140
+ $consignmentIdNode = $this->getDocument ()->createElement ( 'consignmentId', $order->getId () . ' ' . microtime () );
141
+ $cancellationNode->appendChild ( $consignmentIdNode );
142
+
143
+ foreach ( $order->getAllItems () as $orderItem ) {
144
+ $cancellationEntryNode = $this->getDocument ()->createElement ( 'cancellationEntry' );
145
+ $cancellationNode->appendChild ( $cancellationEntryNode );
146
+
147
+ $productIdNode = $this->getDocument ()->createElement ( 'common:productId', $orderItem->getProductId () );
148
+ $cancellationEntryNode->appendChild ( $productIdNode );
149
+
150
+ $quantityNode = $this->getDocument ()->createElement ( 'quantity', ( int ) $orderItem->getQtyOrdered () );
151
+ $cancellationEntryNode->appendChild ( $quantityNode );
152
+
153
+ $reasonNode = $this->getDocument ()->createElement ( 'reason', 'DealerRequest' );
154
+ $cancellationEntryNode->appendChild ( $reasonNode );
155
+ }
156
+
157
+ $this->setHasData();
158
+
159
+ return $this;
160
+ }
161
+
162
+ /**
163
+ *
164
+ * @param Mage_Sales_Model_Order_Shipment $shipment
165
+ * @param Mage_Sales_Model_Order $order
166
+ * @param mixed $trackingNumber
167
+ * null or trackingNumber
168
+ * @return DOMNode|Ambigous <boolean, DOMElement>
169
+ */
170
+ public function addCreditMemo(Mage_Sales_Model_Order_Creditmemo $creditMemo, Mage_Sales_Model_Order_Shipment $shipment) {
171
+ $creditMemoNode = $this->getDocument ()->createElement ( 'creditMemo' );
172
+ $this->getCredits ()->appendChild ( $creditMemoNode );
173
+
174
+ $consignmentIdNode = $this->getDocument ()->createElement ( 'consignmentId', $shipment->getId () );
175
+ $creditMemoNode->appendChild ( $consignmentIdNode );
176
+
177
+ $orderIdNode = $this->getDocument ()->createElement ( 'orderId', $creditMemo->getOrder ()->getDhlMeinPaketOrderId () );
178
+ $creditMemoNode->appendChild ( $orderIdNode );
179
+
180
+ $creditIdNode = $this->getDocument ()->createElement ( 'creditId', $creditMemo->getId () );
181
+ $creditMemoNode->appendChild ( $creditIdNode );
182
+
183
+ $creditAmountNode = $this->getDocument ()->createElement ( 'creditAmount', $creditMemo->getGrandTotal () );
184
+ $creditMemoNode->appendChild ( $creditAmountNode );
185
+
186
+ $creditMemoReasonNode = $this->getDocument ()->createElement ( 'creditMemoReason', 'DEALER_GOODWILL' );
187
+ $creditMemoNode->appendChild ( $creditMemoReasonNode );
188
+
189
+ $this->setHasData();
190
+
191
+ return $this;
192
+ }
193
+
194
+ /**
195
+ *
196
+ * @return DOMElement
197
+ */
198
+ protected function getCancellations() {
199
+ if ($this->cancellations == null) {
200
+ $this->cancellations = $this->getDocument ()->createElement ( 'cancellations' );
201
+ $this->getDocumentElement ()->appendChild ( $this->cancellations );
202
+ }
203
+ return $this->cancellations;
204
+ }
205
+
206
+ /**
207
+ *
208
+ * @return DOMElement
209
+ */
210
+ protected function getConsignments() {
211
+ if ($this->consignments == null) {
212
+ $this->consignments = $this->getDocument ()->createElement ( 'consignments' );
213
+ $this->getDocumentElement ()->appendChild ( $this->consignments );
214
+ }
215
+ return $this->consignments;
216
+ }
217
+
218
+ /**
219
+ *
220
+ * @return DOMElement
221
+ */
222
+ protected function getReturns() {
223
+ if ($this->returns == null) {
224
+ $this->returns = $this->getDocument ()->createElement ( 'returns' );
225
+ $this->getDocumentElement ()->appendChild ( $this->returns );
226
+ }
227
+ return $this->returns;
228
+ }
229
+
230
+ /**
231
+ *
232
+ * @return DOMElement
233
+ */
234
+ protected function getTrackingNumbers() {
235
+ if ($this->trackingNumbers == null) {
236
+ $this->trackingNumbers = $this->getDocument ()->createElement ( 'trackingNumbers' );
237
+ $this->getDocumentElement ()->appendChild ( $this->trackingNumbers );
238
+ }
239
+ return $this->trackingNumbers;
240
+ }
241
+
242
+ /**
243
+ *
244
+ * @return DOMElement
245
+ */
246
+ protected function getCredits() {
247
+ if ($this->credits == null) {
248
+ $this->credits = $this->getDocument ()->createElement ( 'credits' );
249
+ $this->getDocumentElement ()->appendChild ( $this->credits );
250
+ }
251
+ return $this->credits;
252
+ }
253
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Xml/Request/QueryRequest.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Xml_Request_QueryRequest extends Dhl_MeinPaketCommon_Model_Xml_AbstractXmlRequest {
12
+
13
+ /**
14
+ *
15
+ * @var DOMElement
16
+ */
17
+ protected $orders;
18
+
19
+ /**
20
+ *
21
+ * @var DOMElement
22
+ */
23
+ protected $order_externalIds;
24
+
25
+ /**
26
+ *
27
+ * @var DOMElement
28
+ */
29
+ protected $shoppingCartStatus;
30
+
31
+ /**
32
+ *
33
+ * @var DOMElement
34
+ */
35
+ protected $shoppingCartStatus_externalIds;
36
+
37
+ /**
38
+ * Default Constructor.
39
+ */
40
+ public function __construct() {
41
+ parent::__construct ();
42
+ }
43
+
44
+ /**
45
+ * Create the root element for the document.
46
+ *
47
+ * @return DOMNode
48
+ */
49
+ public function createDocumentElement() {
50
+ $this->node = $this->getDocument ()->createElement ( 'queryRequest' );
51
+ $this->node->setAttribute ( 'xmlns', self::XMLNS_ORDERS );
52
+ $this->node->setAttribute ( 'xmlns:common', self::XMLNS_COMMON );
53
+ $this->node->setAttribute ( 'version', '1.0' );
54
+ $this->getDocument ()->appendChild ( $this->node );
55
+ }
56
+
57
+ /**
58
+ * Add order request.
59
+ *
60
+ * @param string $from
61
+ * @param string $to
62
+ * @param string $status
63
+ */
64
+ public function addOrders($from = null, $to = null, $status = null) {
65
+ $this->_initializeOrder ();
66
+ $this->setHasData ( true );
67
+
68
+ if ($from != null) {
69
+ $dateFromNode = $this->getDocument ()->createElement ( "dateFrom", $this->getFormatedDate ( $from ) );
70
+ $this->orders->appendChild ( $dateFromNode );
71
+ } else {
72
+ // One week ago
73
+ /* @var $date Zend_Date */
74
+ $date = Zend_Date::now ();
75
+ $date->subWeek ( 1 );
76
+ $date->setHour ( 0 );
77
+ $date->setMinute ( 0 );
78
+ $date->setMilliSecond ( 0 );
79
+ $dateFromNode = $this->getDocument ()->createElement ( "dateFrom", $date->toString ( Zend_Date::ISO_8601 ) );
80
+ $this->orders->appendChild ( $dateFromNode );
81
+ }
82
+
83
+ if ($to != null) {
84
+ $dateToNode = $this->getDocument ()->createElement ( "dateTo", $this->getFormatedDate ( $to ) );
85
+ $this->orders->appendChild ( $dateToNode );
86
+ }
87
+
88
+ if ($status != null) {
89
+ $statusNode = $this->getDocument ()->createElement ( "orderStatus", $status );
90
+ $this->orders->appendChild ( $statusNode );
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Shopping Cart Status.
96
+ *
97
+ * @param
98
+ * string cartId
99
+ */
100
+ public function addShoppingCartStatus($cartId) {
101
+ $this->setHasData ( true );
102
+ if ($this->shoppingCartStatus == null) {
103
+ $this->shoppingCartStatus = $this->getDocument ()->createElement ( 'shoppingCartStatus' );
104
+ $this->getDocumentElement ()->appendChild ( $this->shoppingCartStatus );
105
+ }
106
+
107
+ if ($this->shoppingCartStatus_externalIds == null) {
108
+ $this->shoppingCartStatus_externalIds = $this->getDocument ()->createElement ( 'externalIds' );
109
+ $this->shoppingCartStatus->appendChild ( $this->shoppingCartStatus_externalIds );
110
+ }
111
+
112
+ $externalId = $this->getDocument ()->createElement ( "externalId", $cartId );
113
+ $this->shoppingCartStatus_externalIds->appendChild ( $externalId );
114
+ }
115
+
116
+ /**
117
+ * Shopping Cart Status.
118
+ *
119
+ * @param
120
+ * string cartId
121
+ */
122
+ public function addOrderExternalId($cartId) {
123
+ $this->setHasData ( true );
124
+ $this->_initializeOrder ();
125
+
126
+ if ($this->order_externalIds == null) {
127
+ $this->order_externalIds = $this->getDocument ()->createElement ( 'externalIds' );
128
+ $this->orders->appendChild ( $this->order_externalIds );
129
+ }
130
+
131
+ $externalId = $this->getDocument ()->createElement ( "externalId", $cartId );
132
+ $this->order_externalIds->appendChild ( $externalId );
133
+ }
134
+ protected function _initializeOrder() {
135
+ if ($this->orders == null) {
136
+ $this->orders = $this->getDocument ()->createElement ( 'orders' );
137
+ $this->getDocumentElement ()->appendChild ( $this->orders );
138
+ $this->orders->setAttribute ( 'getEmail', 'true' );
139
+ $this->orders->setAttribute ( 'additionalInfos', true );
140
+ }
141
+ }
142
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Xml/Request/SubmitCartRequest.php ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Xml_Request_SubmitCartRequest extends Dhl_MeinPaketCommon_Model_Xml_AbstractXmlRequest {
12
+ const EU_MIN_STANDARD_TAX = 15;
13
+ const POSTPAY_TAX_FREE = 'Free';
14
+ const POSTPAY_TAX_REDUCED = 'Reduced';
15
+ const POSTPAY_TAX_STANDARD = 'Standard';
16
+
17
+ /**
18
+ * Default Constructor.
19
+ */
20
+ public function __construct() {
21
+ parent::__construct ();
22
+ }
23
+
24
+ /**
25
+ * Create the root element for the document.
26
+ *
27
+ * @return DOMNode
28
+ */
29
+ public function createDocumentElement() {
30
+ $this->node = $this->getDocument ()->createElement ( 'submitCartRequest' );
31
+ $this->node->setAttribute ( 'xmlns', self::XMLNS_CHECKOUT );
32
+ $this->node->setAttribute ( 'xmlns:common', self::XMLNS_COMMON );
33
+ $this->node->setAttribute ( 'version', '1.0' );
34
+ $this->getDocument ()->appendChild ( $this->node );
35
+ }
36
+
37
+ /**
38
+ *
39
+ * @param Mage_Sales_Model_Order|Mage_Sales_Model_Quote $order
40
+ * @param Dhl_Paypal_Model_Cart $cart
41
+ * @return string
42
+ */
43
+ public function addCart($order, $cart) {
44
+ if ($order == null) {
45
+ return;
46
+ }
47
+
48
+ $shoppingCartNode = $this->getDocument ()->createElement ( 'shoppingCart' );
49
+ $cartIdnode = $this->getDocument ()->createElement ( 'cartId', ( string ) $cart->getId () );
50
+ $shoppingCartNode->appendChild ( $cartIdnode );
51
+
52
+ foreach ( $order->getAllVisibleItems () as $item ) {
53
+ /* @var $item Mage_Sales_Model_Order_Item */
54
+ $this->addCartItem ( $shoppingCartNode, $item );
55
+ }
56
+
57
+ if ($order instanceof Mage_Sales_Model_Order) {
58
+ $this->addCustomerData ( $shoppingCartNode, $order );
59
+ }
60
+
61
+ if ($order->hasShippingInclTax ()) {
62
+ // If shipping availabe -> no quote
63
+ $shippingCostNode = $this->getDocument ()->createElement ( "shippingCost", $order->getShippingInclTax () );
64
+ $shoppingCartNode->appendChild ( $shippingCostNode );
65
+ }
66
+
67
+ $params = array (
68
+ '_forced_secure' => true
69
+ );
70
+
71
+ if ($order instanceof Mage_Sales_Model_Order) {
72
+ $params ['order'] = $order->getIncrementId ();
73
+ }
74
+
75
+ $redirectURLSuccessNode = $this->getDocument ()->createElement ( "redirectURLSuccess", Mage::getUrl ( 'postpay/response/success', $params ) );
76
+ $shoppingCartNode->appendChild ( $redirectURLSuccessNode );
77
+
78
+ $redirectURLErrorNode = $this->getDocument ()->createElement ( "redirectURLError", Mage::getUrl ( 'postpay/response/error', $params ) );
79
+ $shoppingCartNode->appendChild ( $redirectURLErrorNode );
80
+
81
+ $redirectURLBackNode = $this->getDocument ()->createElement ( "redirectURLBack", Mage::getUrl ( 'postpay/response/back', $params ) );
82
+ $shoppingCartNode->appendChild ( $redirectURLBackNode );
83
+
84
+ $notificationIdNode = $this->getDocument ()->createElement ( "notificationId", $cart->getNotificationId () );
85
+ $shoppingCartNode->appendChild ( $notificationIdNode );
86
+
87
+ $this->getDocumentElement ()->appendChild ( $shoppingCartNode );
88
+
89
+ return $cart->getNotificationId ();
90
+ }
91
+ protected function addCartItem(DOMElement $shoppingCartNode, Mage_Sales_Model_Order_Item $item) {
92
+ if (! Mage::helper ( 'meinpaketcommon/data' )->checkItem ( $item )) {
93
+ return;
94
+ }
95
+
96
+ $shoppingCartItemNode = $this->getDocument ()->createElement ( 'shoppingCartItem' );
97
+ $productIdNode = $this->getDocument ()->createElement ( 'productId', $item->getProductId () );
98
+ $shoppingCartItemNode->appendChild ( $productIdNode );
99
+
100
+ $shoppingCartItemNode->appendChild ( $this->getCDATANode ( 'name', $item->getName () ) );
101
+ $basePriceNode = $this->getDocument ()->createElement ( 'basePrice', $item->getBasePriceInclTax () );
102
+ $shoppingCartItemNode->appendChild ( $basePriceNode );
103
+ $taxNode = $this->getDocument ()->createElement ( 'tax' );
104
+ if ($item->getTaxPercent () <= 0) {
105
+ $taxNode->nodeValue = self::POSTPAY_TAX_FREE;
106
+ } else if ($item->getTaxPercent () >= self::EU_MIN_STANDARD_TAX) {
107
+ $taxNode->nodeValue = self::POSTPAY_TAX_STANDARD;
108
+ } else {
109
+ $taxNode->nodeValue = self::POSTPAY_TAX_REDUCED;
110
+ }
111
+ $shoppingCartItemNode->appendChild ( $taxNode );
112
+ $quantityNode = $this->getDocument ()->createElement ( 'quantity', $item->getQty () ? $item->getQty () : $item->getQtyOrdered () );
113
+ $shoppingCartItemNode->appendChild ( $quantityNode );
114
+
115
+ $shoppingCartNode->appendChild ( $shoppingCartItemNode );
116
+ $this->setHasData ( true );
117
+ }
118
+ protected function addCustomerData(DOMElement $shoppingCartNode, Mage_Sales_Model_Order $order) {
119
+ $customerDataNode = $this->getDocument ()->createElement ( 'customerData' );
120
+
121
+ $emailNode = $this->getDocument ()->createElement ( 'email', $this->getCDATANode ( 'email', $order->getCustomerEmail () ) );
122
+
123
+ if ($order->getShippingAddressId () != $order->getBillingAddressId ()) {
124
+ $deliveryAddressNode = $this->getDocument ()->createElement ( 'deliveryAddress' );
125
+ $this->addCustomerAddressFields ( $deliveryAddressNode, $order->getShippingAddress () );
126
+ $customerDataNode->appendChild ( $deliveryAddressNode );
127
+ }
128
+
129
+ $billingAddressNode = $this->getDocument ()->createElement ( 'billingAddress' );
130
+ $this->addCustomerAddressFields ( $billingAddressNode, $order->getBillingAddress () );
131
+ $customerDataNode->appendChild ( $billingAddressNode );
132
+
133
+ $shoppingCartNode->appendChild ( $customerDataNode );
134
+ }
135
+ protected function addCustomerAddressFields(DOMElement $addressNode, Mage_Sales_Model_Order_Address $address) {
136
+ $streetHouseNumber = Mage::helper ( 'meinpaketcommon/address' )->parseStreetHouseNumber ( $address->getStreet1 () );
137
+
138
+ // The salutation if provided, i.e .Herr/Frau or Mr./Mrs
139
+ switch ($address->getPrefix ()) {
140
+ case 'Frau' :
141
+ $salutation = 'Frau';
142
+ break;
143
+ case 'Mrs' :
144
+ $salutation = 'Mrs';
145
+ break;
146
+ case 'Mr' :
147
+ case 'Mr.' :
148
+ $salutation = 'Mr.';
149
+ break;
150
+ default :
151
+ $salutation = 'Herr';
152
+ break;
153
+ }
154
+
155
+ $addressNode->appendChild ( $this->getCDATANode ( 'salutation', $salutation ) );
156
+ $addressNode->appendChild ( $this->getCDATANode ( 'firstName', $address->getFirstname () ) );
157
+ $addressNode->appendChild ( $this->getCDATANode ( 'lastName', $address->getLastname () ) );
158
+ $addressNode->appendChild ( $this->getCDATANode ( 'street', $streetHouseNumber ["street"] ) );
159
+ $addressNode->appendChild ( $this->getCDATANode ( 'houseNumber', $streetHouseNumber ["houseNumber"] ) );
160
+ if (strlen ( $address->getStreet2 () )) {
161
+ $addressNode->appendChild ( $this->getCDATANode ( 'addressAddition', $address->getStreet2 () ) );
162
+ if (strlen ( $address->getStreet3 () )) {
163
+ $addressNode->appendChild ( $this->getCDATANode ( 'addressAddition', $address->getStreet3 () ) );
164
+ if (strlen ( $address->getStreet4 () )) {
165
+ $addressNode->appendChild ( $this->getCDATANode ( 'addressAddition', $address->getStreet4 () ) );
166
+ }
167
+ }
168
+ }
169
+ $addressNode->appendChild ( $this->getCDATANode ( 'zipCode', $address->getPostcode () ) );
170
+ $addressNode->appendChild ( $this->getCDATANode ( 'city', $address->getCity () ) );
171
+ $addressNode->appendChild ( $this->getCDATANode ( 'country', $address->getCountry () ) );
172
+ }
173
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Xml/Request/UploadRequest.php ADDED
@@ -0,0 +1,443 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_MeinPaketCommon_Model_Xml_Partial
10
+ */
11
+ class Dhl_MeinPaketCommon_Model_Xml_Request_UploadRequest extends Dhl_MeinPaketCommon_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_MeinPaketCommon_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
+ if (! $product->getData ( 'sync_with_dhl_mein_paket' )) {
95
+ $this->removeProduct ( $product );
96
+ return false;
97
+ }
98
+
99
+ // product id
100
+ $offer->appendChild ( $this->getDocument ()->createElement ( 'common:productId', $product->getId () ) );
101
+
102
+ // ean
103
+ $ean = Mage::helper ( 'meinpaket/product' )->getEan ( $product );
104
+ if (! empty ( $ean )) {
105
+ $offer->appendChild ( $this->getDocument ()->createElement ( 'common:ean', $ean ) );
106
+ }
107
+
108
+ // manufacturer
109
+ $manufacturer = $product->getAttributeText ( 'manufacturer' );
110
+ if (! empty ( $manufacturer )) {
111
+ $offer->appendChild ( $this->getCDATANode ( 'common:manufacturerName', $manufacturer ) );
112
+ }
113
+
114
+ // price
115
+ // Use final price to use timing
116
+ $price = Mage::getStoreConfigFlag ( 'meinpaket/product_attributes/use_available_special_price' ) && $product->getFinalPrice () > 0 ? $product->getFinalPrice () : $product->getPrice ();
117
+ $priceWithTax = Mage::helper ( 'tax' )->getPrice ( $product, $price );
118
+ $offer->appendChild ( $this->getDocument ()->createElement ( 'price', $priceWithTax ) );
119
+
120
+ // tax group
121
+ $taxGroup = $this->productHelper->getMeinPaketTaxGroup ( $product );
122
+ $offer->appendChild ( $this->getDocument ()->createElement ( 'taxGroup', $taxGroup ) );
123
+
124
+ // availability
125
+ $availability = $this->productHelper->getMeinPaketStock ( $product );
126
+ $offer->appendChild ( $this->getDocument ()->createElement ( 'availability', $availability ) );
127
+
128
+ // abuse enddate for activation and deactivation
129
+ // $offer->appendChild ( $this->getDocument ()->createElement ( 'endDate', $this->getIsoDateTime ( now () ) ) );
130
+
131
+ // deliverytime
132
+ $deliveryTime = $this->productHelper->getMeinPaketDeliveryTime ( $product );
133
+ if ($deliveryTime !== false) {
134
+ $offer->appendChild ( $this->getDocument ()->createElement ( 'deliverytime', $deliveryTime ) );
135
+ }
136
+
137
+ $this->getOffers ()->appendChild ( $offer );
138
+
139
+ $this->setHasData ();
140
+
141
+ return $offer;
142
+ }
143
+ public function removeProduct(Mage_Catalog_Model_Product $product) {
144
+ if ($product->getData ( 'meinpaket_id' )) {
145
+ /* @var $productDeletion DOMNode */
146
+ $productDeletionNode = $this->getDocument ()->createElement ( 'productDeletion' );
147
+ $this->getDeletions ()->appendChild ( $productDeletionNode );
148
+ $productIdNode = $this->getDocument ()->createElement ( 'common:productId', $product->getId () );
149
+ $productDeletionNode->appendChild ( $productIdNode );
150
+
151
+ $this->setHasData ();
152
+ }
153
+ }
154
+ public function addCategory(Mage_Catalog_Model_Product $product) {
155
+ // TODO:
156
+ }
157
+ public function removeCategory(Mage_Catalog_Model_Product $product) {
158
+ // TODO:
159
+ }
160
+ protected function getProductDescriptions() {
161
+ if ($this->productDescriptions == null) {
162
+ $this->productDescriptions = $this->getDocument ()->createElement ( 'descriptions' );
163
+ $this->getDocumentElement ()->appendChild ( $this->productDescriptions );
164
+ }
165
+ return $this->productDescriptions;
166
+ }
167
+
168
+ /**
169
+ *
170
+ * @return DOMElement
171
+ */
172
+ protected function getOffers() {
173
+ if ($this->offers == null) {
174
+ $this->offers = $this->getDocument ()->createElement ( 'offers' );
175
+ $this->getDocumentElement ()->appendChild ( $this->offers );
176
+ }
177
+ return $this->offers;
178
+ }
179
+
180
+ /**
181
+ *
182
+ * @return DOMElement
183
+ */
184
+ protected function getVariantGroups() {
185
+ if ($this->variantGroups == null) {
186
+ $this->variantGroups = $this->getDocument ()->createElement ( 'variantGroups' );
187
+ $this->getDocumentElement ()->appendChild ( $this->variantGroups );
188
+ }
189
+ return $this->variantGroups;
190
+ }
191
+
192
+ /**
193
+ *
194
+ * @return DOMElement
195
+ */
196
+ protected function getTrackingNumbers() {
197
+ if ($this->trackingNumbers == null) {
198
+ $this->trackingNumbers = $this->getDocument ()->createElement ( 'trackingNumbers' );
199
+ $this->getDocumentElement ()->appendChild ( $this->trackingNumbers );
200
+ }
201
+ return $this->trackingNumbers;
202
+ }
203
+
204
+ /**
205
+ *
206
+ * @return DOMElement
207
+ */
208
+ protected function getCategories() {
209
+ if ($this->categories == null) {
210
+ $this->categories = $this->getDocument ()->createElement ( 'categories' );
211
+ $this->getDocumentElement ()->appendChild ( $this->categories );
212
+ }
213
+ return $this->categories;
214
+ }
215
+
216
+ /**
217
+ *
218
+ * @return DOMElement
219
+ */
220
+ protected function getDeletions() {
221
+ if ($this->deletions == null) {
222
+ $this->deletions = $this->getDocument ()->createElement ( 'deletions' );
223
+ $this->getDocumentElement ()->appendChild ( $this->deletions );
224
+ }
225
+ return $this->deletions;
226
+ }
227
+
228
+ /**
229
+ * Export a single simple product.
230
+ *
231
+ * @param Mage_Catalog_Model_Product $product
232
+ * to be exported
233
+ * @param string $variantGroup
234
+ * the product belongs to if available
235
+ * @throws Dhl_MeinPaketCommon_Model_Exception_InvalidDataException
236
+ * @throws Dhl_MeinPaketCommon_Model_Exception_MissingDataException
237
+ * @return DOMNode
238
+ */
239
+ protected function handleSimpleProduct(Mage_Catalog_Model_Product $product, Mage_Catalog_Model_Product $configurableProduct = null) {
240
+ if ($configurableProduct == null) {
241
+ $type = Mage::getModel ( 'catalog/product_type_configurable' );
242
+ $parentIdArray = $type->getParentIdsByChild ( $product->getId () );
243
+ if (isset ( $parentIdArray [0] )) {
244
+ $configurableProduct = Mage::getModel ( 'catalog/product' )->load ( $parentIdArray [0] );
245
+ }
246
+ }
247
+
248
+ if (! $product->getData ( 'sync_with_dhl_mein_paket' ) && $configurableProduct == null) {
249
+ $this->removeProduct ( $product );
250
+ return false;
251
+ }
252
+
253
+ /* @var $productDescription DOMNode */
254
+ $productDescription = $this->getDocument ()->createElement ( 'productDescription' );
255
+ $variantInfo = null;
256
+
257
+ // product id
258
+ $productId = $this->getDocument ()->createElement ( 'common:productId', $product->getId () );
259
+ $productDescription->appendChild ( $productId );
260
+
261
+ // ean (optional)
262
+ $ean = Mage::helper ( 'meinpaket/product' )->getEan ( $product );
263
+ if (! empty ( $ean )) {
264
+ $productDescription->appendChild ( $this->getDocument ()->createElement ( 'common:ean', $ean ) );
265
+ }
266
+
267
+ // manufacturer
268
+ $manufacturer = $product->getAttributeText ( 'manufacturer' );
269
+ if (! empty ( $manufacturer )) {
270
+ $productDescription->appendChild ( $this->getCDATANode ( 'common:manufacturerName', $manufacturer ) );
271
+ }
272
+
273
+ if ($configurableProduct != NULL) {
274
+ $variantGroupInfoNode = $this->getDocument ()->createElement ( "variantGroupInfo" );
275
+ $variantGroupInfoNode->setAttribute ( "code", $configurableProduct->getId () );
276
+ $productDescription->appendChild ( $variantGroupInfoNode );
277
+ }
278
+
279
+ // name
280
+ if (strlen ( $product->getName () ) > 0) {
281
+ $productDescription->appendChild ( $this->getCDATANode ( 'name', $product->getName () ) );
282
+ } else {
283
+ throw new Dhl_MeinPaketCommon_Model_Exception_InvalidDataException ( $product->getId (), 'name' );
284
+ }
285
+
286
+ // shortdescription
287
+ if (strlen ( $product->getShortDescription () ) > 0) {
288
+ $shortDescription = $this->escapeStringForMeinPaket ( $product->getShortDescription () );
289
+ $productDescription->appendChild ( $this->getCDATANode ( 'shortDescription', $shortDescription ) );
290
+ } else {
291
+ throw new Dhl_MeinPaketCommon_Model_Exception_MissingDataException ( $product->getId (), 'shortDescription' );
292
+ }
293
+
294
+ // long description (optional) && (strlen > 0)
295
+ if (strlen ( $product->getDescription () ) > 0) {
296
+ $description = $this->escapeStringForMeinPaket ( $product->getDescription () );
297
+ $productDescription->appendChild ( $this->getCDATANode ( 'longDescription', $description ) );
298
+ }
299
+
300
+ // Export images
301
+ $images = $product->getMediaGalleryImages ();
302
+ if ($images != null) {
303
+ foreach ( $images as $image ) {
304
+ $smallOrImage = false;
305
+
306
+ if ($image->getDisabled ()) {
307
+ continue;
308
+ }
309
+
310
+ $imageNode = $this->getDocument ()->createElement ( "image" );
311
+ $productDescription->appendChild ( $imageNode );
312
+ $imageNode->appendChild ( $this->getDocument ()->createElement ( "url", $image->getUrl () ) );
313
+
314
+ $label = $image->getLabel ();
315
+ if (! empty ( $label )) {
316
+ $imageNode->appendChild ( $this->getDocument ()->createElement ( "caption", $image->getLabel () ) );
317
+ }
318
+ }
319
+ }
320
+
321
+ // marketplace category
322
+ $meinpaketCategory = $product->getData ( 'meinpaket_category' );
323
+ if (strlen ( $meinpaketCategory ) > 0) {
324
+ $mNode = $this->getDocument ()->createElement ( 'marketplaceCategory' );
325
+ $mNode->setAttribute ( 'code', $meinpaketCategory );
326
+ $productDescription->appendChild ( $mNode );
327
+ } else {
328
+ throw new Dhl_MeinPaketCommon_Model_Exception_MissingDataException ( $product->getId (), 'dhl_marketplace_category_id' );
329
+ }
330
+
331
+ $this->exportAttributes ( $product, $productDescription, $configurableProduct );
332
+ $this->getProductDescriptions ()->appendChild ( $productDescription );
333
+ $this->addOffer ( $product );
334
+
335
+ $this->setHasData ();
336
+
337
+ return $productDescription;
338
+ }
339
+
340
+ /**
341
+ * Export product attributes.
342
+ */
343
+ protected function exportAttributes(Mage_Catalog_Model_Product $product, DOMNode $node, Mage_Catalog_Model_Product $configurableProduct = null) {
344
+ $configurableAttributes = array ();
345
+
346
+ if ($configurableProduct != null && $configurableProduct->getTypeId () == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
347
+ foreach ( $configurableProduct->getTypeInstance ( true )->getConfigurableAttributes ( $configurableProduct ) as $attr ) {
348
+ $configurableAttributes [] = $attr->getProductAttribute ()->getAttributeCode ();
349
+ }
350
+ }
351
+
352
+ foreach ( $product->getAttributes () as $attribute ) {
353
+ /* @var $attribute Mage_Eav_Model_Attribute */
354
+
355
+ $isConfigurable = in_array ( $attribute->getAttributeCode (), $configurableAttributes );
356
+
357
+ if (strlen ( $attribute->getMeinpaketAttribute () ) <= 0 || $attribute->getMeinpaketAttribute () == 'None') {
358
+ continue;
359
+ }
360
+
361
+ $productValue = $product->getData ( $attribute->getAttributeCode () );
362
+
363
+ if ($attribute->isValueEmpty ( $productValue ) || empty ( $productValue )) {
364
+ continue;
365
+ }
366
+
367
+ $frontendValue = $attribute->getFrontend ()->getValue ( $product );
368
+
369
+ if (empty ( $frontendValue )) {
370
+ continue;
371
+ }
372
+
373
+ $storeLabel = $attribute->getFrontendLabel ();
374
+
375
+ if (strlen ( $storeLabel ) <= 0) {
376
+ continue;
377
+ }
378
+
379
+ $attributeNode = $this->getDocument ()->createElement ( "attribute" );
380
+ if ($isConfigurable) {
381
+ $attributeNode->setAttribute ( "variant", "true" );
382
+ }
383
+ $attributeNode->setAttribute ( "code", $attribute->getMeinpaketAttribute () == 'Default' ? $attribute->getAttributeCode () : $attribute->getMeinpaketAttribute () );
384
+
385
+ $nameNode = $this->getDocument ()->createElement ( "name", $storeLabel );
386
+ $attributeNode->appendChild ( $nameNode );
387
+ $valueNode = $this->getDocument ()->createElement ( "value", $frontendValue );
388
+ $attributeNode->appendChild ( $valueNode );
389
+
390
+ $node->appendChild ( $attributeNode );
391
+ }
392
+ }
393
+
394
+ /**
395
+ * Export a configurable product.
396
+ *
397
+ * @param Mage_Catalog_Model_Product $product
398
+ */
399
+ protected function handleConfigurableProduct(Mage_Catalog_Model_Product $product) {
400
+ if (! $product->getData ( 'sync_with_dhl_mein_paket' )) {
401
+ /* @var $productDescription DOMNode */
402
+ $productDeletion = $this->getDocument ()->createElement ( 'productDeletion' );
403
+ $this->getDeletions ()->appendChild ( $productDeletion );
404
+ $pId = $this->getDocument ()->createElement ( 'common:productId', $product->getId () );
405
+ $productDeletion->appendChild ( $pId );
406
+ return false;
407
+ }
408
+
409
+ if (! $product->getData ( 'sync_with_dhl_mein_paket' )) {
410
+ $this->removeProduct ( $product );
411
+ return false;
412
+ }
413
+
414
+ if ($product->getTypeId () != Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
415
+ return false;
416
+ }
417
+
418
+ $typeInstance = $product->getTypeInstance ( true );
419
+ $configurableType = $typeInstance->setProduct ( $product );
420
+ $variantGroupNode = null;
421
+
422
+ $variantGroupNode = $this->getDocument ()->createElement ( "variantGroup" );
423
+ $variantGroupNode->setAttribute ( "code", $product->getId () );
424
+ // $this->getVariantGroups ()->appendChild ( $variantGroupNode );
425
+
426
+ /*
427
+ * $configurationNode = $this->getDocument ()->createElement ( "configuration" ); $variantGroupNode->appendChild ( $configurationNode ); $configurationNode->setAttribute ( "code", $variantMapping->getMeinpaketVariantId () );
428
+ */
429
+
430
+ $titleNode = $this->getDocument ()->createElement ( "title" );
431
+ $variantGroupNode->appendChild ( $titleNode );
432
+ $titleNode->appendChild ( $this->getDocument ()->createTextNode ( $product->getName () ) );
433
+
434
+ $this->setHasData ();
435
+
436
+ $simpleCollection = $configurableType->getUsedProductCollection ()->addAttributeToSelect ( '*' )->addFilterByRequiredOptions ();
437
+ foreach ( $simpleCollection as $simpleProduct ) {
438
+ $this->handleSimpleProduct ( $simpleProduct, $product );
439
+ }
440
+
441
+ return $variantGroupNode;
442
+ }
443
+ }
app/code/community/Dhl/MeinPaketCommon/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_MeinPaketCommon_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_MeinPaketCommon_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/MeinPaketCommon/Model/Xml/Response/AsynchronousStatusResponse.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Model_Xml_Response_AsynchronousStatusResponse extends Dhl_MeinPaketCommon_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_MeinPaketCommon_Model_Xml_Response_AsynchronousStatusResponse
43
+ */
44
+ public function createOrUpdateAsync() {
45
+ if (strlen ( $this->requestId ) > 0) {
46
+ /* @var $request Dhl_MeinPaketCommon_Model_Async */
47
+ $request = Mage::getModel ( 'meinpaketcommon/async' )->load ( $this->requestId, 'request_id' );
48
+ $request->setCreatedAt ( Varien_Date::now () );
49
+ $request->setUpdatedAt ( Varien_Date::now () );
50
+ $request->setRequestId ( $this->requestId );
51
+ $request->setStatus ( $this->status );
52
+ $request->save ();
53
+ }
54
+
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * Process response
60
+ */
61
+ public function process() {
62
+ $this->createOrUpdateAsync ();
63
+ }
64
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/DataResponse.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Model_Xml_Response_DataResponse extends Dhl_MeinPaketCommon_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_MeinPaketCommon_Model_Xml_Response_Partial_DataResponse_Confirmation ( $downloadResponseEntries );
22
+ break;
23
+ case 'bestPrice' :
24
+ $this->bestPrices [] = new Dhl_MeinPaketCommon_Model_Xml_Response_Partial_DataResponse_BestPrice ( $downloadResponseEntries );
25
+ break;
26
+ case 'productData' :
27
+ $this->productData [] = new Dhl_MeinPaketCommon_Model_Xml_Response_Partial_DataResponse_ProductData ( $downloadResponseEntries );
28
+ break;
29
+ case 'merchantData' :
30
+ $this->merchantData [] = new Dhl_MeinPaketCommon_Model_Xml_Response_Partial_DataResponse_MerchantData ( $downloadResponseEntries );
31
+ break;
32
+ case 'quotaData' :
33
+ $this->quotaData [] = new Dhl_MeinPaketCommon_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_MeinPaketCommon_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_MeinPaketCommon_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/MeinPaketCommon/Model/Xml/Response/DownloadResponse.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Model_Xml_Response_DownloadResponse extends Dhl_MeinPaketCommon_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_MeinPaketCommon_Model_Xml_Response_Partial_Category ( $downloadResponseEntries );
14
+ break;
15
+ case 'productOffers' :
16
+ // $this->productOfferConfirmations [] = new Dhl_MeinPaketCommon_Model_Xml_Response_Partial_ProductId ( $downloadResponseEntries );
17
+ break;
18
+ case 'variantConfiguration' :
19
+ $this->variantConfigurations [] = new Dhl_MeinPaketCommon_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/MeinPaketCommon/Model/Xml/Response/NotificationResponse.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Model_Xml_Response_NotificationResponse extends Dhl_MeinPaketCommon_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_MeinPaketCommon_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/MeinPaketCommon/Model/Xml/Response/Partial/Address.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Address extends Dhl_MeinPaketCommon_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/MeinPaketCommon/Model/Xml/Response/Partial/Attribute.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Attribute extends Dhl_MeinPaketCommon_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/MeinPaketCommon/Model/Xml/Response/Partial/Category.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Category extends Dhl_MeinPaketCommon_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/MeinPaketCommon/Model/Xml/Response/Partial/CategoryId.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Model_Xml_Response_Partial_CategoryId extends Dhl_MeinPaketCommon_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/MeinPaketCommon/Model/Xml/Response/Partial/DataResponse/BestPrice.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ */
6
+ class Dhl_MeinPaketCommon_Model_Xml_Response_Partial_DataResponse_BestPrice extends Dhl_MeinPaketCommon_Model_Xml_Response_Abstract {
7
+ const OwNERSHIP_OWN = "OWN";
8
+ const OwNERSHIP_FOREIGN = "FOREIGN";
9
+ private $productId;
10
+ private $price;
11
+ private $priceCurrency;
12
+ private $deliveryCost;
13
+ private $deliveryCostCurrency;
14
+ private $deliveryTime;
15
+ private $ownership;
16
+ private $owningDealerCode;
17
+ public function __construct(DOMElement $domElement) {
18
+ parent::__construct ( $domElement );
19
+ assert ( $domElement->localName == 'bestPrice' );
20
+
21
+ foreach ( $domElement->childNodes as $childNode ) {
22
+ switch ($childNode->localName) {
23
+ case 'productId' :
24
+ $this->productId = $childNode->nodeValue;
25
+ break;
26
+ case 'price' :
27
+ $this->price = $childNode->nodeValue;
28
+ $this->priceCurrency = $childNode->getAttribute ( 'currency' );
29
+ break;
30
+ case 'deliveryCost' :
31
+ $this->deliveryCost = $childNode->nodeValue;
32
+ $this->deliveryCostCurrency = $childNode->getAttribute ( 'currency' );
33
+ break;
34
+ case 'deliveryTime' :
35
+ $this->deliveryTime = $childNode->nodeValue;
36
+ break;
37
+ case 'activeOffers' :
38
+ $this->activeOffers = $childNode->nodeValue;
39
+ break;
40
+ case 'ownership' :
41
+ switch ($childNode->nodeValue) {
42
+ case self::OwNERSHIP_OWN :
43
+ $this->ownership = self::OwNERSHIP_OWN;
44
+ break;
45
+ case self::OwNERSHIP_FOREIGN :
46
+ $this->ownership = self::OwNERSHIP_FOREIGN;
47
+ break;
48
+ }
49
+ break;
50
+ case 'owningDealerCode' :
51
+ $this->owningDealerCode = $childNode->nodeValue;
52
+ break;
53
+ }
54
+ }
55
+ }
56
+ public function getActiveOffers() {
57
+ return $this->activeOffers;
58
+ }
59
+ public function getProductId() {
60
+ return $this->productId;
61
+ }
62
+ public function getPrice() {
63
+ return $this->price;
64
+ }
65
+ public function getPriceCurrency() {
66
+ return $this->priceCurrency;
67
+ }
68
+ public function getDeliveryCost() {
69
+ return $this->deliveryCost;
70
+ }
71
+ public function getDeliveryCostCurrency() {
72
+ return $this->deliveryCostCurrency;
73
+ }
74
+ public function getDeliveryTime() {
75
+ return $this->deliveryTime;
76
+ }
77
+ public function getOwnership() {
78
+ return $this->ownership;
79
+ }
80
+ public function getOwningDealerCode() {
81
+ return $this->owningDealerCode;
82
+ }
83
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/DataResponse/Confirmation.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @author stephan
6
+ *
7
+ */
8
+ class Dhl_MeinPaketCommon_Model_Xml_Response_Partial_DataResponse_Confirmation extends Dhl_MeinPaketCommon_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
+ foreach ( $domElement->childNodes as $childNode ) {
16
+ switch ($childNode->localName) {
17
+ case 'customerId' :
18
+ $this->customerId = $childNode->nodeValue;
19
+ break;
20
+ case 'email' :
21
+ $this->email = $childNode->nodeValue;
22
+ break;
23
+ }
24
+ }
25
+ }
26
+ public function getCustomerId() {
27
+ return $this->customerId;
28
+ }
29
+ public function getEmail() {
30
+ return $this->email;
31
+ }
32
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/DataResponse/MerchantData.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @author stephan
6
+ *
7
+ */
8
+ class Dhl_MeinPaketCommon_Model_Xml_Response_Partial_DataResponse_MerchantData extends Dhl_MeinPaketCommon_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
+ foreach ( $domElement->childNodes as $childNode ) {
16
+ switch ($childNode->localName) {
17
+ case 'customerId' :
18
+ $this->customerId = $childNode->nodeValue;
19
+ break;
20
+ case 'email' :
21
+ $this->email = $childNode->nodeValue;
22
+ break;
23
+ }
24
+ }
25
+ }
26
+ public function getCustomerId() {
27
+ return $this->customerId;
28
+ }
29
+ public function getEmail() {
30
+ return $this->email;
31
+ }
32
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/DataResponse/ProductData.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ */
6
+ class Dhl_MeinPaketCommon_Model_Xml_Response_Partial_DataResponse_ProductData extends Dhl_MeinPaketCommon_Model_Xml_Response_Abstract {
7
+ private $entryId;
8
+ private $type;
9
+ private $marketplaceCategory;
10
+ private $name;
11
+ private $shortDescription;
12
+ private $longDescription;
13
+ private $manufacturerName;
14
+ public function __construct(DOMElement $domElement) {
15
+ parent::__construct ( $domElement );
16
+ assert ( $domElement->localName == 'productData' );
17
+
18
+ $this->entryId = $domElement->getAttribute ( 'entryId' );
19
+ $this->type = $domElement->getAttribute ( 'type' );
20
+
21
+ foreach ( $domElement->childNodes as $childNode ) {
22
+ switch ($childNode->localName) {
23
+ case 'marketplaceCategory' :
24
+ $this->marketplaceCategory = $childNode->getAttribute ( 'code' );
25
+ break;
26
+ case 'name' :
27
+ $this->name = $childNode->nodeValue;
28
+ break;
29
+ case 'shortDescription' :
30
+ $this->shortDescription = $childNode->nodeValue;
31
+ break;
32
+ case 'longDescription' :
33
+ $this->longDescription = $childNode->nodeValue;
34
+ break;
35
+ case 'manufacturerName' :
36
+ $this->manufacturerName = $childNode->nodeValue;
37
+ break;
38
+ }
39
+ }
40
+ }
41
+ public function getEntityId() {
42
+ return $this->entryId;
43
+ }
44
+ public function getMarketplaceCategory() {
45
+ return $this->marketplaceCategory;
46
+ }
47
+ public function getName() {
48
+ return $this->name;
49
+ }
50
+ public function getShortDescription() {
51
+ return $this->shortDescription;
52
+ }
53
+ public function getLongDescription() {
54
+ return $this->longDescription;
55
+ }
56
+ public function getManufacturerName() {
57
+ return $this->manufacturerName;
58
+ }
59
+ public function getType() {
60
+ return $this->type;
61
+ }
62
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/DataResponse/QuotaData.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ */
6
+ class Dhl_MeinPaketCommon_Model_Xml_Response_Partial_DataResponse_QuotaData extends Dhl_MeinPaketCommon_Model_Xml_Response_Abstract {
7
+ private $customerId;
8
+ private $email;
9
+ public function __construct(DOMElement $domElement) {
10
+ parent::__construct ( $domElement );
11
+ assert ( $domElement->localName == 'quotaData' );
12
+
13
+ foreach ( $domElement->childNodes as $childNode ) {
14
+ switch ($childNode->localName) {
15
+ case 'customerId' :
16
+ $this->customerId = $childNode->nodeValue;
17
+ break;
18
+ case 'email' :
19
+ $this->email = $childNode->nodeValue;
20
+ break;
21
+ }
22
+ }
23
+ }
24
+ public function getCustomerId() {
25
+ return $this->customerId;
26
+ }
27
+ public function getEmail() {
28
+ return $this->email;
29
+ }
30
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/NotificationResponse/Confirmation.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ */
5
+ class Dhl_MeinPaketCommon_Model_Xml_Response_Partial_NotificationResponse_Confirmation extends Dhl_MeinPaketCommon_Model_Xml_Response_Abstract {
6
+ private $cancellationConfirmation = array ();
7
+ private $consignmentConfirmation = array ();
8
+ private $trackingNumberConfirmation = array ();
9
+ private $returnConfirmation = array ();
10
+ private $creditMemoConfirmation = array ();
11
+
12
+ /**
13
+ *
14
+ * @param DOMElement $domElement
15
+ */
16
+ public function __construct(DOMElement $domElement) {
17
+ parent::__construct ( $domElement );
18
+ assert ( $domElement->localName == 'confirmation' );
19
+
20
+ foreach ( $domElement->childNodes as $childNode ) {
21
+ switch ($childNode->localName) {
22
+ case 'cancellation' :
23
+ $this->cancellationConfirmation [] = new Dhl_MeinPaketCommon_Model_Xml_Response_Partial_NotificationResponse_Consignment ( $childNode );
24
+ break;
25
+ case 'consignment' :
26
+ $this->consignmentConfirmation [] = new Dhl_MeinPaketCommon_Model_Xml_Response_Partial_NotificationResponse_Consignment ( $childNode );
27
+ break;
28
+ case 'trackingNumber' :
29
+ $this->trackingNumberConfirmation [] = new Dhl_MeinPaketCommon_Model_Xml_Response_Partial_NotificationResponse_Consignment ( $childNode );
30
+ break;
31
+ case 'return' :
32
+ $this->returnConfirmation [] = new Dhl_MeinPaketCommon_Model_Xml_Response_Partial_NotificationResponse_Return ( $childNode );
33
+ break;
34
+ case 'creditMemo' :
35
+ $this->creditMemoConfirmation [] = new Dhl_MeinPaketCommon_Model_Xml_Response_Partial_NotificationResponse_Credit ( $childNode );
36
+ break;
37
+ }
38
+ }
39
+ }
40
+ public function getCancellationConfirmations() {
41
+ return $this->cancellationConfirmation;
42
+ }
43
+ public function getConsignmentConfirmations() {
44
+ return $this->consignmentConfirmation;
45
+ }
46
+ public function getTrackingNumberConfirmations() {
47
+ return $this->trackingNumberConfirmation;
48
+ }
49
+ public function getReturnConfirmations() {
50
+ return $this->returnConfirmation;
51
+ }
52
+ public function getCreditMemoConfirmations() {
53
+ return $this->creditMemoConfirmation;
54
+ }
55
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/NotificationResponse/Consignment.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Model_Xml_Response_Partial_NotificationResponse_Consignment extends Dhl_MeinPaketCommon_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/MeinPaketCommon/Model/Xml/Response/Partial/NotificationResponse/Credit.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Model_Xml_Response_Partial_NotificationResponse_Credit extends Dhl_MeinPaketCommon_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/MeinPaketCommon/Model/Xml/Response/Partial/NotificationResponse/Return.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Model_Xml_Response_Partial_NotificationResponse_Return extends Dhl_MeinPaketCommon_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/MeinPaketCommon/Model/Xml/Response/Partial/Order.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ */
5
+ class Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Order extends Dhl_MeinPaketCommon_Model_Xml_Response_Abstract {
6
+ private $orderId;
7
+ private $orderDate;
8
+ private $lastModificationDate;
9
+ private $totalPrice;
10
+ private $totalPriceCurrency;
11
+ private $totalDeliveryCosts;
12
+ private $totalDeliveryCostsCurrency;
13
+ private $deliveryMethod;
14
+ /**
15
+ *
16
+ * @var Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Order_ContactData
17
+ */
18
+ private $contactData; // ?
19
+ /**
20
+ *
21
+ * @var Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Address
22
+ */
23
+ private $deliveryAddress;
24
+ /**
25
+ *
26
+ * @var Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Address
27
+ */
28
+ private $billingAddress;
29
+ /**
30
+ *
31
+ * @var array
32
+ */
33
+ private $entries = array ();
34
+
35
+ /**
36
+ * Default constructor.
37
+ *
38
+ * @param DOMElement $domElement
39
+ */
40
+ public function __construct(DOMElement $domElement) {
41
+ parent::__construct ( $domElement );
42
+ assert ( $domElement->localName == 'order' );
43
+
44
+ foreach ( $domElement->childNodes as $childNode ) {
45
+ switch ($childNode->localName) {
46
+ case 'orderId' :
47
+ $this->orderId = $childNode->nodeValue;
48
+ break;
49
+ case 'orderDate' :
50
+ $this->orderDate = $childNode->nodeValue;
51
+ break;
52
+ case 'lastModificationDate' :
53
+ $this->lastModificationDate = $childNode->nodeValue;
54
+ break;
55
+ case 'totalPrice' :
56
+ $this->totalPrice = $childNode->nodeValue;
57
+ $this->totalPriceCurrency = $childNode->getAttribute ( 'currency' );
58
+ break;
59
+ case 'totalDeliveryCosts' :
60
+ $this->totalDeliveryCosts = $childNode->nodeValue;
61
+ $this->totalDeliveryCostsCurrency = $childNode->getAttribute ( 'currency' );
62
+ break;
63
+ case 'deliveryMethod' :
64
+ $this->deliveryMethod = $childNode->nodeValue;
65
+ break;
66
+ case 'contactData' :
67
+ $this->contactData = new Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Order_ContactData ( $childNode );
68
+ break;
69
+ case 'deliveryAddress' :
70
+ $this->deliveryAddress = new Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Address ( $childNode );
71
+ break;
72
+ case 'billingAddress' :
73
+ $this->billingAddress = new Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Address ( $childNode );
74
+ break;
75
+ case 'orderEntry' :
76
+ $this->entries [] = new Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Order_Entry ( $childNode );
77
+ }
78
+ }
79
+ }
80
+ public function getOrderId() {
81
+ return $this->orderId;
82
+ }
83
+ public function getOrderDate() {
84
+ return $this->orderDate;
85
+ }
86
+ public function getLastModificationDate() {
87
+ return $this->lastModificationDate;
88
+ }
89
+ public function getTotalPrice() {
90
+ return $this->totalPrice;
91
+ }
92
+ public function getTotalPriceCurrency() {
93
+ return $this->totalPriceCurrency;
94
+ }
95
+ public function getTotalDeliveryCosts() {
96
+ return $this->totalDeliveryCosts;
97
+ }
98
+ public function getTotalDeliveryCostsCurrency() {
99
+ return $this->totalDeliveryCostsCurrency;
100
+ }
101
+ public function getDeliveryMethod() {
102
+ return $this->deliveryMethod;
103
+ }
104
+ public function getContactData() {
105
+ return $this->contactData;
106
+ }
107
+ public function getDeliveryAddress() {
108
+ return $this->deliveryAddress;
109
+ }
110
+ public function getBillingAddress() {
111
+ return $this->billingAddress;
112
+ }
113
+ public function getEntries() {
114
+ return $this->entries;
115
+ }
116
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/Order/ContactData.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ */
5
+ class Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Order_ContactData extends Dhl_MeinPaketCommon_Model_Xml_Response_Abstract {
6
+ private $customerId;
7
+ private $email;
8
+ public function __construct(DOMElement $domElement) {
9
+ parent::__construct ( $domElement );
10
+ assert ( $domElement->localName == 'contactData' );
11
+ foreach ( $domElement->childNodes as $childNode ) {
12
+ switch ($childNode->localName) {
13
+ case 'customerId' :
14
+ $this->customerId = $childNode->nodeValue;
15
+ break;
16
+ case 'email' :
17
+ $this->email = $childNode->nodeValue;
18
+ break;
19
+ }
20
+ }
21
+ }
22
+ public function getCustomerId() {
23
+ return $this->customerId;
24
+ }
25
+ public function getEmail() {
26
+ return $this->email;
27
+ }
28
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/Order/Entry.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ */
5
+ class Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Order_Entry extends Dhl_MeinPaketCommon_Model_Xml_Response_Abstract {
6
+ private $productId;
7
+ private $meinPaketId;
8
+ private $ean;
9
+ private $name;
10
+ private $quantity;
11
+ private $basePrice;
12
+ private $basePriceCurrency;
13
+ private $totalPrice;
14
+ private $totalPriceCurrency;
15
+ public function __construct(DOMElement $domElement) {
16
+ parent::__construct ( $domElement );
17
+ assert ( $domElement->localName == 'orderEntry' );
18
+ foreach ( $domElement->childNodes as $childNode ) {
19
+ switch ($childNode->localName) {
20
+ case 'productId' :
21
+ $this->productId = $childNode->nodeValue;
22
+ break;
23
+ case 'meinPaketId' :
24
+ $this->meinPaketId = $childNode->nodeValue;
25
+ break;
26
+ case 'ean' :
27
+ $this->ean = strtotime ( $childNode->nodeValue );
28
+ break;
29
+ case 'name' :
30
+ $this->name = $childNode->nodeValue;
31
+ break;
32
+ case 'quantity' :
33
+ $this->quantity = $childNode->nodeValue;
34
+ break;
35
+ case 'basePrice' :
36
+ $this->basePrice = $childNode->nodeValue;
37
+ $this->basePriceCurrency = $childNode->getAttribute ( 'currency' );
38
+ break;
39
+ case 'totalPrice' :
40
+ $this->totalPrice = $childNode->nodeValue;
41
+ $this->totalPriceCurrency = $childNode->getAttribute ( 'currency' );
42
+ break;
43
+ }
44
+ }
45
+ }
46
+ public function getProductId() {
47
+ return $this->productId;
48
+ }
49
+ public function getMeinPaketId() {
50
+ return $this->meinPaketId;
51
+ }
52
+ public function getEan() {
53
+ return $this->ean;
54
+ }
55
+ public function getName() {
56
+ return $this->name;
57
+ }
58
+ public function getQuantity() {
59
+ return $this->quantity;
60
+ }
61
+ public function getBasePrice() {
62
+ return $this->basePrice;
63
+ }
64
+ public function getBaseCurrency() {
65
+ return $this->basePriceCurrency;
66
+ }
67
+ public function getTotalPrice() {
68
+ return $this->totalPrice;
69
+ }
70
+ public function getTotalPriceCurrency() {
71
+ return $this->totalPriceCurrency;
72
+ }
73
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/Partial/ProductId.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Model_Xml_Response_Partial_ProductId extends Dhl_MeinPaketCommon_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/MeinPaketCommon/Model/Xml/Response/Partial/VariantConfiguration.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Model_Xml_Response_Partial_VariantConfiguration extends Dhl_MeinPaketCommon_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_MeinPaketCommon_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/MeinPaketCommon/Model/Xml/Response/QueryResponse.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Model_Xml_Response_QueryResponse extends Dhl_MeinPaketCommon_Model_Xml_Response_Abstract {
3
+ /**
4
+ *
5
+ * @var $orders array
6
+ */
7
+ private $orders = array ();
8
+
9
+ /**
10
+ *
11
+ * @var $shoppingCartStatusResponses array
12
+ */
13
+ private $shoppingCartStatusResponses = array ();
14
+
15
+ /**
16
+ * Constructor
17
+ *
18
+ * @param unknown $domElement
19
+ */
20
+ public function __construct(DOMElement $domElement) {
21
+ parent::__construct ( $domElement );
22
+ assert ( $domElement->localName == 'queryResponse' );
23
+
24
+ foreach ( $domElement->childNodes as $queryResponseEntries ) {
25
+ switch ($queryResponseEntries->localName) {
26
+ case 'order' :
27
+ $this->orders [] = new Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Order ( $queryResponseEntries );
28
+ break;
29
+ case 'shoppingCartStatusResponse' :
30
+ $this->parseShoppingCartStatusResponse ( $queryResponseEntries );
31
+ break;
32
+ }
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Parse cart status.
38
+ *
39
+ * <cartStatus>
40
+ *
41
+ * @param DOMElement $domElement
42
+ */
43
+ protected function parseShoppingCartStatusResponse(DOMElement $domElement) {
44
+ assert ( $domElement->localName == 'shoppingCartStatusResponse' );
45
+
46
+ foreach ( $domElement->childNodes as $childNode ) {
47
+ switch ($childNode->localName) {
48
+ case 'cartStatus' :
49
+ $this->parseShoppingCartStatusResponseCartStatus ( $childNode );
50
+ break;
51
+ }
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Parse cart status elements.
57
+ *
58
+ * <externalId>0001</externalId>
59
+ * <shoppingCartStatusValue>Pending</shoppingCartStatusValue>
60
+ *
61
+ * @param DOMElement $domElement
62
+ */
63
+ protected function parseShoppingCartStatusResponseCartStatus(DOMElement $domElement) {
64
+ assert ( $domElement->localName == 'cartStatus' );
65
+
66
+ $cartId = null;
67
+
68
+ foreach ( $domElement->childNodes as $childNode ) {
69
+ switch ($childNode->localName) {
70
+ case 'externalId' :
71
+ $cartId = $childNode->nodeValue;
72
+ break;
73
+ case 'shoppingCartStatusValue' :
74
+ if ($cartId != null) {
75
+ $this->shoppingCartStatusResponses [$cartId] = $childNode->nodeValue;
76
+ $cartId = null;
77
+ }
78
+ break;
79
+ }
80
+ }
81
+ }
82
+
83
+ /**
84
+ *
85
+ * @return $orders
86
+ */
87
+ public function getOrders() {
88
+ return $this->orders;
89
+ }
90
+
91
+ /**
92
+ *
93
+ * @return $shoppingCartStatusResponses
94
+ */
95
+ public function getShoppingCartStatusResponses() {
96
+ return $this->shoppingCartStatusResponses;
97
+ }
98
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/SubmitCartResponse.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Model_Xml_Response_SubmitCartResponse extends Dhl_MeinPaketCommon_Model_Xml_Response_Abstract {
3
+ private $cartId;
4
+ private $redirectURL;
5
+ public function __construct(DOMElement $domElement) {
6
+ parent::__construct ( $domElement );
7
+ assert ( $domElement->localName == 'submitCartResponse' );
8
+
9
+ foreach ( $domElement->childNodes as $submitCartResponseChildNode ) {
10
+ switch ($submitCartResponseChildNode->localName) {
11
+ case 'cartId' :
12
+ $this->cartId = $submitCartResponseChildNode->nodeValue;
13
+ break;
14
+ case 'redirectURL' :
15
+ $this->redirectURL = $submitCartResponseChildNode->nodeValue;
16
+ break;
17
+ }
18
+ }
19
+ }
20
+ public function getCartId() {
21
+ return $this->cartId;
22
+ }
23
+ public function getRedirectURL() {
24
+ return $this->redirectURL;
25
+ }
26
+ }
app/code/community/Dhl/MeinPaketCommon/Model/Xml/Response/UploadResponse.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_MeinPaketCommon_Model_Xml_Response_UploadResponse extends Dhl_MeinPaketCommon_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_MeinPaketCommon_Model_Xml_Response_Partial_CategoryId ( $confirmationEntries );
26
+ break;
27
+ case 'category' :
28
+ $this->categoryConfirmations [] = new Dhl_MeinPaketCommon_Model_Xml_Response_Partial_CategoryId ( $confirmationEntries );
29
+ break;
30
+ case 'productDeletion' :
31
+ $this->productDeletionConfirmations [] = new Dhl_MeinPaketCommon_Model_Xml_Response_Partial_ProductId ( $confirmationEntries );
32
+ break;
33
+ case 'productDescription' :
34
+ $this->productDescriptionConfirmations [] = new Dhl_MeinPaketCommon_Model_Xml_Response_Partial_ProductId ( $confirmationEntries );
35
+ break;
36
+ case 'productOffer' :
37
+ $this->productOfferConfirmations [] = new Dhl_MeinPaketCommon_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_MeinPaketCommon_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/MeinPaketCommon/Model/Xml/XmlBuildException.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Xml_XmlBuildException extends Varien_Exception {
12
+ }
13
+
app/code/community/Dhl/MeinPaketCommon/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
+ */
11
+ class Dhl_MeinPaketCommon_Model_Xml_XmlResponseParser extends Varien_Object {
12
+ /**
13
+ *
14
+ * @param DOMDocument $dom
15
+ * @return Dhl_MeinPaketCommon_Model_Xml_Response_Abstract
16
+ */
17
+ public function parseResponse(DOMDocument $dom) {
18
+ if (! isset ( $dom->documentElement )) {
19
+ return null;
20
+ }
21
+
22
+ $documentElement = $dom->documentElement;
23
+
24
+ /* @var $result Dhl_MeinPaketCommon_Model_Xml_Response_Abstract */
25
+ $result = null;
26
+
27
+ switch ($documentElement->localName) {
28
+ case 'asynchronousStatusResponse' :
29
+ $result = new Dhl_MeinPaketCommon_Model_Xml_Response_AsynchronousStatusResponse ( $documentElement );
30
+ break;
31
+ case 'downloadResponse' :
32
+ $result = new Dhl_MeinPaketCommon_Model_Xml_Response_DownloadResponse ( $documentElement );
33
+ break;
34
+ case 'uploadResponse' :
35
+ $result = new Dhl_MeinPaketCommon_Model_Xml_Response_UploadResponse ( $documentElement );
36
+ break;
37
+ case 'dataResponse' :
38
+ $result = new Dhl_MeinPaketCommon_Model_Xml_Response_DataResponse ( $documentElement );
39
+ break;
40
+ case 'notificationResponse' :
41
+ $result = new Dhl_MeinPaketCommon_Model_Xml_Response_NotificationResponse ( $documentElement );
42
+ break;
43
+ case 'queryResponse' :
44
+ $result = new Dhl_MeinPaketCommon_Model_Xml_Response_QueryResponse ( $documentElement );
45
+ break;
46
+ case 'submitCartResponse' :
47
+ $result = new Dhl_MeinPaketCommon_Model_Xml_Response_SubmitCartResponse ( $documentElement );
48
+ break;
49
+ }
50
+
51
+ if ($result != null) {
52
+ $result->process ();
53
+ }
54
+
55
+ return $result;
56
+ }
57
+ }
58
+
app/code/community/Dhl/MeinPaketCommon/controllers/Adminhtml/AsyncController.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ */
6
+ class Dhl_MeinPaketCommon_Adminhtml_AsyncController extends Mage_Adminhtml_Controller_Action {
7
+ protected function _initAction() {
8
+ $this->loadLayout ()->_setActiveMenu ( 'meinpaketcommon/async' )->_addBreadcrumb ( Mage::helper ( 'meinpaketcommon' )->__ ( 'Async' ), Mage::helper ( 'meinpaketcommon' )->__ ( '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 ( 'meinpaketcommon/adminhtml_async_grid' );
17
+ $this->_prepareDownloadResponse ( $fileName, $grid->getCsvFile () );
18
+ }
19
+ public function exportExcelAction() {
20
+ $fileName = 'async.xml';
21
+ $grid = $this->getLayout ()->createBlock ( 'meinpaketcommon/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 ( 'meinpaketcommon/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 ( 'meinpaketcommon/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 ( 'meinpaketcommon/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 ( 'meinpaketcommon/adminhtml_async_grid' )->toHtml () );
88
+ }
89
+ }
app/code/community/Dhl/MeinPaketCommon/controllers/Adminhtml/LogController.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ */
6
+ class Dhl_MeinPaketCommon_Adminhtml_LogController extends Mage_Adminhtml_Controller_Action {
7
+ protected function _initAction() {
8
+ $this->loadLayout ()->_setActiveMenu ( 'meinpaketcommon/log' )->_addBreadcrumb ( Mage::helper ( 'meinpaketcommon' )->__ ( 'Log' ), Mage::helper ( 'meinpaketcommon' )->__ ( '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 ( 'meinpaketcommon/adminhtml_log_grid' );
17
+ $this->_prepareDownloadResponse ( $fileName, $grid->getCsvFile () );
18
+ }
19
+ public function exportExcelAction() {
20
+ $fileName = 'log.xml';
21
+ $grid = $this->getLayout ()->createBlock ( 'meinpaketcommon/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 ( 'meinpaketcommon' )->__ ( 'Please select log entries.' ) );
28
+ } else {
29
+ try {
30
+ $logModel = Mage::getModel ( 'meinpaketcommon/log' );
31
+ foreach ( $logIds as $logId ) {
32
+ $logModel->load ( $logId )->delete ();
33
+ }
34
+ Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( Mage::helper ( 'meinpaketcommon' )->__ ( '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 ( 'meinpaketcommon' )->__ ( 'Please select log entries.' ) );
45
+ } else {
46
+ try {
47
+ $logModel = Mage::getModel ( 'meinpaketcommon/log' );
48
+ foreach ( $logIds as $logId ) {
49
+ $logModel->load ( $logId );
50
+ $xmlDocument = new DOMDocument ();
51
+ $xmlDocument->loadXML ( $logModel->getReceived () );
52
+ Mage::getModel ( 'meinpaketcommon/xml_xmlResponseParser' )->parseResponse ( $xmlDocument );
53
+ }
54
+ Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( Mage::helper ( 'meinpaketcommon' )->__ ( '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
+ * Product grid for AJAX request.
64
+ * Sort and filter result for example.
65
+ */
66
+ public function gridAction() {
67
+ $this->loadLayout ();
68
+ $this->getResponse ()->setBody ( $this->getLayout ()->createBlock ( 'meinpaketcommon/adminhtml_log_grid' )->toHtml () );
69
+ }
70
+ }
app/code/community/Dhl/MeinPaketCommon/controllers/Adminhtml/OrderImportController.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+ class Dhl_MeinPaketCommon_Adminhtml_OrderImportController extends Mage_Adminhtml_Controller_Action {
12
+ /**
13
+ * Initialized the controller.
14
+ *
15
+ * @return Dhl_MeinPaket_Adminhtml_OrderImportController
16
+ */
17
+ protected function _initAction() {
18
+ $this->loadLayout ()->_setActiveMenu ( 'meinpaket' );
19
+ $this->_title ( $this->__ ( 'Allyouneed' ) )->_title ( $this->__ ( 'Order Import' ) );
20
+ return $this;
21
+ }
22
+
23
+ /**
24
+ * Default controller action.
25
+ *
26
+ * @return void
27
+ */
28
+ public function indexAction() {
29
+ $this->_initAction ();
30
+ $this->renderLayout ();
31
+ }
32
+
33
+ /**
34
+ * Triggers the import process.
35
+ *
36
+ * @return void
37
+ */
38
+ public function importAction() {
39
+ /* @var $OrderImportService Dhl_MeinPaket_Model_Order_ImportService */
40
+ $OrderImportService = Mage::getModel ( 'meinpaketcommon/Order_ImportService' );
41
+ $startdate = $this->getRequest ()->getParam ( 'startdate', 0 );
42
+ $enddate = $this->getRequest ()->getParam ( 'enddate', 0 );
43
+
44
+ if ($startdate == 0) {
45
+ $startdate = time () - 3600;
46
+ } else {
47
+ $startdate = $this->parseTime ( $startdate );
48
+ }
49
+ if ($enddate == 0) {
50
+ $enddate = $this->parseTime ( date ( 'm' ) . '/' . date ( 'd' ) . '/' . date ( 'y' ), true );
51
+ } else {
52
+ $enddate = $this->parseTime ( $enddate, true );
53
+ }
54
+
55
+ try {
56
+ $status = $OrderImportService->importOrders ( $startdate, $enddate );
57
+ } catch ( Exception $e ) {
58
+ Mage::logException ( $e );
59
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( 'An error occured: ' . $e->getMessage () );
60
+ }
61
+
62
+ if ($OrderImportService->wasServiceResponseMalformed ()) {
63
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( __ ( 'The MeinPaket server did not deliver a valid response. Have a look at the system log for more information.' ) );
64
+ } else {
65
+ $orderCount = $OrderImportService->getOrderCount ();
66
+
67
+ if ($orderCount ['imported'] > 0) {
68
+ $message = sprintf ( __ ( '%s order(s) sucessfully imported.' ), $orderCount ['imported'] );
69
+ Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( $message );
70
+ } elseif ($orderCount ['outOfStock'] === 0) {
71
+ Mage::getSingleton ( 'adminhtml/session' )->addNotice ( __ ( 'No new orders found.' ) );
72
+ }
73
+
74
+ if ($orderCount ['duplicates'] > 0) {
75
+ if ($orderCount ['duplicates'] > 1)
76
+ $message = sprintf ( __ ( 'Skipped %s duplicate orders that were already imported previously.' ), $orderCount ['duplicates'] );
77
+ else
78
+ $message = sprintf ( __ ( 'Skipped %s duplicate order that was already imported previously.' ), $orderCount ['duplicates'] );
79
+
80
+ Mage::getSingleton ( 'adminhtml/session' )->addNotice ( $message );
81
+ }
82
+
83
+ if ($orderCount ['outOfStock'] > 0) {
84
+ $message = sprintf ( __ ( 'Skipped %s order(s) because: out of stock. Please process the following order(s) at your Allyouneed dealer area:' ), $orderCount ['outOfStock'] );
85
+ $dhlOrderIds = implode ( ', ', $OrderImportService->getOutOfStockOrders () );
86
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $message . " " . $dhlOrderIds );
87
+ }
88
+
89
+ if ($orderCount ['disabled'] > 0) {
90
+ $message = sprintf ( __ ( 'Skipped %s order(s) because: some or all of the included products were disabled in Magento after the export to Allyouneed . Please process the following order(s) at your Allyouneed dealer area:' ), $orderCount ['disabled'] );
91
+ $disabledDhlOrderIds = implode ( ', ', $OrderImportService->getDisabledProductOrders () );
92
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $message . " " . $disabledDhlOrderIds );
93
+ }
94
+
95
+ if ($orderCount ['invalid'] > 0) {
96
+ $message = sprintf ( __ ( 'Skipped %s order(s) because: some or all of the included products were invalid for import. Please process the following order(s) at your Allyouneed dealer area:' ), $orderCount ['invalid'] );
97
+ Mage::getSingleton ( 'adminhtml/session' )->addError ( $message );
98
+ }
99
+ }
100
+
101
+ $this->_initAction ();
102
+ $this->renderLayout ();
103
+ }
104
+
105
+ /**
106
+ * Converts a date string in the format "MM/DD/YY" into a timestamp.
107
+ *
108
+ * @param string $data
109
+ * Must be formatted as "MM/DD/YY"
110
+ * @param boolean $toEndOfDay
111
+ * If set to true the time of the day will be set to "23:59:59", otherwise "00:00:00".
112
+ * @return integer timestamp
113
+ */
114
+ private function parseTime($data, $toEndOfDay = false) {
115
+ $seconds = 0;
116
+ $minutes = 0;
117
+ $hours = 0;
118
+ $timeData = strptime ( $data, '%m/%e/%y' );
119
+
120
+ if ($toEndOfDay === true) {
121
+ $seconds = 59;
122
+ $minutes = 59;
123
+ $hours = 23;
124
+ }
125
+
126
+ return mktime ( $hours, $minutes, $seconds, $timeData ['tm_mon'] + 1, $timeData ['tm_mday'], 1900 + $timeData ['tm_year'] );
127
+ }
128
+ }
app/code/community/Dhl/MeinPaketCommon/etc/adminhtml.xml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <meinpaket>
5
+ <title>Allyouneed</title>
6
+ <children>
7
+ <meinpaket_log translate="title" module="meinpaketcommon">
8
+ <title>Log</title>
9
+ <action>meinpaketcommon/adminhtml_log</action>
10
+ </meinpaket_log>
11
+ <meinpaket_async translate="title" module="meinpaketcommon">
12
+ <title>Async</title>
13
+ <action>meinpaketcommon/adminhtml_async</action>
14
+ </meinpaket_async>
15
+ </children>
16
+ <sort_order>90</sort_order>
17
+ <class>meinpaket</class>
18
+ </meinpaket>
19
+ </menu>
20
+ <acl>
21
+ <resources>
22
+ <admin>
23
+ <children>
24
+ <system>
25
+ <children>
26
+ <config>
27
+ <children>
28
+ <meinpaket translate="title" module="meinpaketcommon">
29
+ <title>Allyouneed</title>
30
+ <sort_order>100</sort_order>
31
+ </meinpaket>
32
+ </children>
33
+ </config>
34
+ </children>
35
+ </system>
36
+ </children>
37
+ </admin>
38
+ </resources>
39
+ </acl>
40
+ </config>
app/code/community/Dhl/MeinPaketCommon/etc/config.xml ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dhl_MeinPaketCommon>
5
+ <version>1.1.0</version>
6
+ </Dhl_MeinPaketCommon>
7
+ </modules>
8
+ <admin>
9
+ <routers>
10
+ <meinpaketcommon>
11
+ <use>admin</use>
12
+ <args>
13
+ <module>Dhl_MeinPaketCommon</module>
14
+ <frontName>meinpaketcommon</frontName>
15
+ </args>
16
+ </meinpaketcommon>
17
+ </routers>
18
+ </admin>
19
+ <adminhtml>
20
+ <translate>
21
+ <modules>
22
+ <meinpaketcommon>
23
+ <files>
24
+ <default>Dhl_MeinPaketCommon.csv</default>
25
+ </files>
26
+ </meinpaketcommon>
27
+ </modules>
28
+ </translate>
29
+ <layout>
30
+ <updates>
31
+ <meinpaketcommon>
32
+ <file>meinpaketcommon.xml</file>
33
+ </meinpaketcommon>
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>meinpaketcommon/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>meinpaketcommon/cron::importOrders</model>
53
+ </run>
54
+ </meinpaket_importOrders>
55
+ <meinpaketcommon_cleanup>
56
+ <schedule>
57
+ <config_path>meinpaketcommon/cron/cleanup</config_path>
58
+ </schedule>
59
+ <run>
60
+ <model>meinpaketcommon/cron::cleanup</model>
61
+ </run>
62
+ </meinpaketcommon_cleanup>
63
+ </jobs>
64
+ </crontab>
65
+ <default>
66
+ <payment>
67
+ <meinpaket>
68
+ <active>1</active>
69
+ <model>meinpaketcommon/payment_method_meinpaket</model>
70
+ <order_status>pending</order_status>
71
+ <title>MeinPaket</title>
72
+ <allowspecific>0</allowspecific>
73
+ <group>offline</group>
74
+ </meinpaket>
75
+ <allyouneed>
76
+ <active>1</active>
77
+ <model>meinpaketcommon/payment_method_allyouneed</model>
78
+ <order_status>pending</order_status>
79
+ <title>MeinPaket</title>
80
+ <allowspecific>0</allowspecific>
81
+ <group>offline</group>
82
+ </allyouneed>
83
+ </payment>
84
+ <carriers>
85
+ <meinpaket>
86
+ <active>1</active>
87
+ <sallowspecific>0</sallowspecific>
88
+ <title>Allyouneed</title>
89
+ <name>MeinPaket</name>
90
+ <model>meinpaketcommon/carrier_meinpaket</model>
91
+ </meinpaket>
92
+ <allyouneed>
93
+ <active>1</active>
94
+ <sallowspecific>0</sallowspecific>
95
+ <title>Allyouneed</title>
96
+ <name>Allyouneed</name>
97
+ <model>meinpaketcommon/carrier_allyouneed</model>
98
+ </allyouneed>
99
+ </carriers>
100
+ <meinpaket>
101
+ <endpoint>
102
+ <sandbox>0</sandbox>
103
+ <https>1</https>
104
+ <proxy></proxy>
105
+ <proxy_host></proxy_host>
106
+ <proxy_port></proxy_port>
107
+ </endpoint>
108
+ <shipment>
109
+ <default_shipment_method>flatrate_flatrate</default_shipment_method>
110
+ </shipment>
111
+ <cron>
112
+ <async>*/10 * * * *</async>
113
+ <cleanup>0 6 * * *</cleanup>
114
+ </cron>
115
+ </meinpaket>
116
+ </default>
117
+ <frontend>
118
+ <translate>
119
+ <modules>
120
+ <meinpaketcommon>
121
+ <files>
122
+ <default>Dhl_MeinPaket.csv</default>
123
+ </files>
124
+ </meinpaketcommon>
125
+ </modules>
126
+ </translate>
127
+ <routers>
128
+ <meinpaketcommon>
129
+ <use>standard</use>
130
+ <args>
131
+ <module>Dhl_MeinPaketCommon</module>
132
+ <frontName>meinpaketcommon</frontName>
133
+ </args>
134
+ </meinpaketcommon>
135
+ </routers>
136
+ <layout>
137
+ <updates>
138
+ <meinpaketcommon>
139
+ <file>meinpaketcommon.xml</file>
140
+ </meinpaketcommon>
141
+ </updates>
142
+ </layout>
143
+ </frontend>
144
+ <global>
145
+ <resources>
146
+ <meinpaketcommon_setup>
147
+ <setup>
148
+ <module>Dhl_MeinPaketCommon</module>
149
+ <class>Dhl_MeinPaketCommon_Model_Resource_Eav_Mysql4_Setup</class>
150
+ </setup>
151
+ <connection>
152
+ <use>core_setup</use>
153
+ </connection>
154
+ </meinpaketcommon_setup>
155
+ </resources>
156
+ <models>
157
+ <meinpaketcommon>
158
+ <class>Dhl_MeinPaketCommon_Model</class>
159
+ <resourceModel>meinpaketcommon_mysql4</resourceModel>
160
+ </meinpaketcommon>
161
+ <meinpaketcommon_mysql4>
162
+ <class>Dhl_MeinPaketCommon_Model_Mysql4</class>
163
+ <entities>
164
+ <async>
165
+ <table>meinpaket_async</table>
166
+ </async>
167
+ <log>
168
+ <table>meinpaket_log</table>
169
+ </log>
170
+ </entities>
171
+ </meinpaketcommon_mysql4>
172
+ </models>
173
+ <blocks>
174
+ <meinpaketcommon>
175
+ <class>Dhl_MeinPaketCommon_Block</class>
176
+ </meinpaketcommon>
177
+ </blocks>
178
+ <helpers>
179
+ <meinpaketcommon>
180
+ <class>Dhl_MeinPaketCommon_Helper</class>
181
+ </meinpaketcommon>
182
+ </helpers>
183
+ <events>
184
+ <sales_order_save_after>
185
+ <observers>
186
+ <meinpaket_cancel_order>
187
+ <type>singleton</type>
188
+ <class>meinpaketcommon/observer</class>
189
+ <method>salesOrderSaveAfter</method>
190
+ </meinpaket_cancel_order>
191
+ </observers>
192
+ </sales_order_save_after>
193
+ <sales_order_shipment_save_after>
194
+ <observers>
195
+ <meinpaket_save_sales_order_shipment>
196
+ <type>singleton</type>
197
+ <class>meinpaketcommon/observer</class>
198
+ <method>salesOrderShipmentSaveAfter</method>
199
+ </meinpaket_save_sales_order_shipment>
200
+ </observers>
201
+ </sales_order_shipment_save_after>
202
+ <sales_order_shipment_save_commit_after>
203
+ <observers>
204
+ <meinpaket_commit_sales_order_shipment>
205
+ <type>singleton</type>
206
+ <class>meinpaketcommon/observer</class>
207
+ <method>salesOrderShipmentSaveCommitAfter</method>
208
+ </meinpaket_commit_sales_order_shipment>
209
+ </observers>
210
+ </sales_order_shipment_save_commit_after>
211
+ <sales_order_shipment_track_save_after>
212
+ <observers>
213
+ <meinpaket_save_sales_order_shipment_track>
214
+ <type>singleton</type>
215
+ <class>meinpaketcommon/observer</class>
216
+ <method>salesOrderShipmentTrackSaveAfter</method>
217
+ </meinpaket_save_sales_order_shipment_track>
218
+ </observers>
219
+ </sales_order_shipment_track_save_after>
220
+ <sales_order_creditmemo_save_after>
221
+ <observers>
222
+ <meinpaket_save_creditmemo>
223
+ <type>singleton</type>
224
+ <class>meinpaketcommon/observer</class>
225
+ <method>salesOrderCreditmemoSaveAfter</method>
226
+ </meinpaket_save_creditmemo>
227
+ </observers>
228
+ </sales_order_creditmemo_save_after>
229
+ <core_block_abstract_prepare_layout_before>
230
+ <observers>
231
+ <meinpaket_grid_column_append>
232
+ <type>singleton</type>
233
+ <class>meinpaketcommon/observer</class>
234
+ <method>gridAddAttributes</method>
235
+ </meinpaket_grid_column_append>
236
+ </observers>
237
+ </core_block_abstract_prepare_layout_before>
238
+ </events>
239
+ </global>
240
+ </config>
app/code/community/Dhl/MeinPaketCommon/etc/system.xml ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <meinpaket module="core" translate="label">
5
+ <label>DHL Allyouneed / Postpay</label>
6
+ <tab>general</tab>
7
+ <frontend_type>text</frontend_type>
8
+ <sort_order>1000</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <class>allyouneed</class>
13
+ <groups>
14
+ <store>
15
+ <label>Store</label>
16
+ <frontend_type>text</frontend_type>
17
+ <sort_order>2</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>1</show_in_website>
20
+ <show_in_store>1</show_in_store>
21
+ <frontend_class>allyouneed</frontend_class>
22
+ <fields translate="label">
23
+ <view translate="label">
24
+ <label>Store View</label>
25
+ <frontend_type>select</frontend_type>
26
+ <source_model>adminhtml/system_config_source_store</source_model>
27
+ <sort_order>1</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>0</show_in_website>
30
+ <show_in_store>0</show_in_store>
31
+ </view>
32
+ </fields>
33
+ </store>
34
+ <credentials translate="label">
35
+ <label>Credentials</label>
36
+ <frontend_type>text</frontend_type>
37
+ <sort_order>1</sort_order>
38
+ <show_in_default>1</show_in_default>
39
+ <show_in_website>1</show_in_website>
40
+ <show_in_store>0</show_in_store>
41
+ <frontend_class>allyouneed</frontend_class>
42
+ <fields>
43
+ <username translate="label comment">
44
+ <label>Username</label>
45
+ <comment><![CDATA[This is the username that was given to you by DHL, mostly your email address.]]></comment>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>10</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>0</show_in_store>
51
+ </username>
52
+ <password translate="label comment">
53
+ <label>Password</label>
54
+ <comment><![CDATA[This is the password that was given to you by DHL.]]></comment>
55
+ <frontend_type>password</frontend_type>
56
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
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>3</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>allyouneed</frontend_class>
72
+ <fields>
73
+ <https translate="label comment">
74
+ <label>Use HTTPs</label>
75
+ <comment><![CDATA[Use https:// to connect to DHL Allyouneed]]></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 Allyouneed 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 Allyouneed]]></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 Allyouneed. 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 Allyouneed. 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>allyouneed</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>meinpaketcommon/entity_attribute_source_carrier</source_model>
144
+ <sort_order>20</sort_order>
145
+ <show_in_default>1</show_in_default>
146
+ <show_in_website>1</show_in_website>
147
+ <show_in_store>0</show_in_store>
148
+ </default_shipment_method>
149
+ </fields>
150
+ </shipment>
151
+ <customer translate="label">
152
+ <label>Customer</label>
153
+ <frontend_type>text</frontend_type>
154
+ <sort_order>50</sort_order>
155
+ <show_in_default>1</show_in_default>
156
+ <show_in_website>1</show_in_website>
157
+ <show_in_store>0</show_in_store>
158
+ <frontend_class>allyouneed</frontend_class>
159
+ <fields>
160
+ <default_email translate="label comment">
161
+ <label>Default customer email</label>
162
+ <comment><![CDATA[This eMail address is used as the default one for orders that do not include one.]]></comment>
163
+ <frontend_type>text</frontend_type>
164
+ <validate>validate-email</validate>
165
+ <sort_order>10</sort_order>
166
+ <show_in_default>1</show_in_default>
167
+ <show_in_website>1</show_in_website>
168
+ <show_in_store>0</show_in_store>
169
+ </default_email>
170
+ </fields>
171
+ </customer>
172
+ <cron translate="label">
173
+ <label>Cron</label>
174
+ <frontend_type>text</frontend_type>
175
+ <sort_order>100</sort_order>
176
+ <show_in_default>1</show_in_default>
177
+ <show_in_website>1</show_in_website>
178
+ <show_in_store>0</show_in_store>
179
+ <frontend_class>allyouneed</frontend_class>
180
+ <fields>
181
+ <async translate="label comment">
182
+ <label>Async Request</label>
183
+ <comment><![CDATA[Async request check interval]]></comment>
184
+ <frontend_type>text</frontend_type>
185
+ <sort_order>10</sort_order>
186
+ <show_in_default>1</show_in_default>
187
+ <show_in_website>1</show_in_website>
188
+ <show_in_store>0</show_in_store>
189
+ </async>
190
+ <order translate="label comment">
191
+ <label>Order Import</label>
192
+ <comment><![CDATA[Order import interval.]]></comment>
193
+ <frontend_type>text</frontend_type>
194
+ <sort_order>30</sort_order>
195
+ <show_in_default>1</show_in_default>
196
+ <show_in_website>1</show_in_website>
197
+ <show_in_store>0</show_in_store>
198
+ </order>
199
+ <cleanup translate="label comment">
200
+ <label>Cleanup Interval</label>
201
+ <comment><![CDATA[Interval to run cleanups.]]></comment>
202
+ <frontend_type>text</frontend_type>
203
+ <sort_order>50</sort_order>
204
+ <show_in_default>1</show_in_default>
205
+ <show_in_website>1</show_in_website>
206
+ <show_in_store>0</show_in_store>
207
+ </cleanup>
208
+ </fields>
209
+ </cron>
210
+ <advanced translate="label">
211
+ <label>Advanced</label>
212
+ <frontend_type>text</frontend_type>
213
+ <sort_order>150</sort_order>
214
+ <show_in_default>1</show_in_default>
215
+ <show_in_website>1</show_in_website>
216
+ <show_in_store>0</show_in_store>
217
+ <frontend_class>allyouneed</frontend_class>
218
+ <fields>
219
+ <cycle_product_count translate="label comment">
220
+ <label>Cycle product count</label>
221
+ <comment><![CDATA[Count of products transfered during a single cycle]]></comment>
222
+ <frontend_type>text</frontend_type>
223
+ <validate>validate-digits</validate>
224
+ <sort_order>15</sort_order>
225
+ <show_in_default>1</show_in_default>
226
+ <show_in_website>1</show_in_website>
227
+ <show_in_store>0</show_in_store>
228
+ </cycle_product_count>
229
+ </fields>
230
+ </advanced>
231
+ </groups>
232
+ </meinpaket>
233
+ <carriers>
234
+ <groups>
235
+ <allyouneed translate="label" module="meinpaket">
236
+ <label>Allyouneed Versand Modul</label>
237
+ <frontend_type>text</frontend_type>
238
+ <sort_order>20</sort_order>
239
+ <show_in_default>1</show_in_default>
240
+ <show_in_website>1</show_in_website>
241
+ <show_in_store>1</show_in_store>
242
+ <fields>
243
+ <active translate="label">
244
+ <label>Enabled</label>
245
+ <frontend_type>select</frontend_type>
246
+ <source_model>adminhtml/system_config_source_yesno</source_model>
247
+ <sort_order>10</sort_order>
248
+ <show_in_default>1</show_in_default>
249
+ <show_in_website>1</show_in_website>
250
+ <show_in_store>1</show_in_store>
251
+ </active>
252
+ </fields>
253
+ </allyouneed>
254
+ </groups>
255
+ </carriers>
256
+ </sections>
257
+ </config>
258
+
app/code/community/Dhl/MeinPaketCommon/sql/meinpaketcommon_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 = "Allyouneed";
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
+ * alter table sales_flat_shipment drop column shipment_was_exported_for_dhl_mein_paket;
18
+ *
19
+ * drop table meinpaket_async
20
+ * drop table meinpaket_log
21
+ */
22
+
23
+ /* @var $installer Dhl_MeinPaketCommon_Model_Resource_Eav_Mysql4_Setup */
24
+ $installer = $this;
25
+ $installer->startSetup ();
26
+
27
+ // get DB connectiondelete from core_resource where code = 'meinpaket_setup';
28
+ $db = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_write' );
29
+ $table_prefix = Mage::getConfig ()->getTablePrefix ();
30
+
31
+ // ############### create dhl_mein_paket_order_id attribute #################
32
+
33
+ // check wether dhl_mein_paket_order_id column exists for orders
34
+ $orderIdFieldExists = false;
35
+ $result = $db->query ( "EXPLAIN {$table_prefix}sales_flat_order" );
36
+
37
+ while ( $resultset = $result->fetch ( PDO::FETCH_ASSOC ) ) {
38
+ if ($resultset ['Field'] == 'dhl_mein_paket_order_id')
39
+ $orderIdFieldExists = true;
40
+ }
41
+
42
+ if (! $orderIdFieldExists) {
43
+ $installer->getConnection ()->addColumn ( $installer->getTable ( 'sales_flat_order' ), 'dhl_mein_paket_order_id', 'varchar(255) NULL DEFAULT NULL AFTER `entity_id`' );
44
+
45
+ $installer->addAttribute ( 'order', 'dhl_mein_paket_order_id', array (
46
+ 'type' => 'static'
47
+ ) );
48
+ // 'visible' => false
49
+ }
50
+
51
+ // check wether dhl_mein_paket_order_id column exists for orders grid
52
+ $orderIdFieldExists = false;
53
+ $result = $db->query ( "EXPLAIN {$table_prefix}sales_flat_order_grid" );
54
+
55
+ while ( $resultset = $result->fetch ( PDO::FETCH_ASSOC ) ) {
56
+ if ($resultset ['Field'] == 'dhl_mein_paket_order_id')
57
+ $orderIdFieldExists = true;
58
+ }
59
+
60
+ if (! $orderIdFieldExists) {
61
+ $installer->getConnection ()->addColumn ( $installer->getTable ( 'sales_flat_order_grid' ), 'dhl_mein_paket_order_id', 'varchar(255) NULL DEFAULT NULL AFTER `entity_id`' );
62
+ }
63
+
64
+ // ############### create shipment_was_exported_for_dhl_mein_paket attribute #################
65
+
66
+ $orderIdFieldExists = false;
67
+ $result = $db->query ( "EXPLAIN {$table_prefix}sales_flat_shipment" );
68
+
69
+ while ( $resultset = $result->fetch ( PDO::FETCH_ASSOC ) ) {
70
+ if ($resultset ['Field'] == 'shipment_was_exported_for_dhl_mein_paket')
71
+ $orderIdFieldExists = true;
72
+ }
73
+
74
+ if (! $orderIdFieldExists) {
75
+ $installer->getConnection ()->addColumn ( $installer->getTable ( 'sales_flat_shipment' ), 'shipment_was_exported_for_dhl_mein_paket', 'int(1) NULL DEFAULT NULL AFTER `entity_id`' );
76
+ }
77
+
78
+ Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( 'DHL Allyouneed extension was successfully installed!' );
79
+
80
+ $installer->installEntities ();
81
+
82
+ $installer->run ( "
83
+ DROP TABLE IF EXISTS {$this->getTable('meinpaketcommon/async')};
84
+ CREATE TABLE {$this->getTable('meinpaketcommon/async')} (
85
+ `async_id` int(11) unsigned NOT NULL auto_increment,
86
+ `request_id` varchar(255),
87
+ `status` varchar(255),
88
+ `created_at` datetime default '0000-00-00 00:00:00',
89
+ `updated_at` datetime default '0000-00-00 00:00:00',
90
+ PRIMARY KEY(`async_id`)
91
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='MeinPaket Async Requests';
92
+ " );
93
+
94
+ $installer->run ( "
95
+ DROP TABLE IF EXISTS {$this->getTable('meinpaketcommon/log')};
96
+ CREATE TABLE {$this->getTable('meinpaketcommon/log')} (
97
+ `log_id` int(11) unsigned NOT NULL auto_increment,
98
+ `request_id` varchar(255),
99
+ `status` varchar(255),
100
+ `send` text default '',
101
+ `received` text default '',
102
+ `error` text default '',
103
+ `created_at` datetime default '0000-00-00 00:00:00',
104
+ PRIMARY KEY(`log_id`)
105
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='MeinPaket Log';
106
+ " );
107
+
108
+ $installer->endSetup ();
app/code/community/Dhl/MeinPaketCommon/sql/meinpaketcommon_setup/mysql4-upgrade-1.0.0-1.1.0.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* @var $installer Dhl_MeinPaketCommon_Model_Resource_Eav_Mysql4_Setup */
4
+ $installer = $this;
5
+ $installer->startSetup ();
6
+
7
+ $installer->installEntities ();
8
+
9
+ $installer->endSetup ();
app/code/community/Dhl/Postpay/Block/Adminhtml/Version.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_Postpay_Block_Adminhtml_Version extends Mage_Adminhtml_Block_System_Config_Form_Field {
3
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
4
+ return ( string ) Mage::helper ( 'postpay/data' )->getExtensionVersion ();
5
+ }
6
+ }
app/code/community/Dhl/Postpay/Block/Checkout.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Paypal expess checkout shortcut link
4
+ */
5
+ class Dhl_Postpay_Block_Checkout extends Mage_Core_Block_Template {
6
+ /**
7
+ * Position of "OR" label against shortcut
8
+ */
9
+ const POSITION_BEFORE = 'before';
10
+ const POSITION_AFTER = 'after';
11
+
12
+ /**
13
+ * Whether the block should be eventually rendered
14
+ *
15
+ * @var bool
16
+ */
17
+ protected $_shouldRender;
18
+
19
+ public function __construct() {
20
+ parent::__construct();
21
+ $this->_shouldRender = Mage::helper('postpay/data')->isActive();
22
+ }
23
+
24
+ /**
25
+ *
26
+ * @return Mage_Core_Block_Abstract
27
+ */
28
+ protected function _beforeToHtml() {
29
+ $result = parent::_beforeToHtml ();
30
+ $quote = Mage::helper ( 'meinpaketcommon/data' )->getQuoteFiltered ();
31
+
32
+ // validate minimum quote amount and validate quote for zero grandtotal
33
+ if (null == $quote || ! $quote->validateMinimumAmount ()) {
34
+ $this->_shouldRender = false;
35
+ return $result;
36
+ }
37
+
38
+ return $result;
39
+ }
40
+ public function getCheckoutUrl() {
41
+ return Mage::getUrl ( 'postpay/checkout' );
42
+ }
43
+ public function getImageUrl() {
44
+ return $this->getSkinUrl ( 'images/postpay/button.png' );
45
+ }
46
+
47
+ /**
48
+ * Render the block if needed
49
+ *
50
+ * @return string
51
+ */
52
+ protected function _toHtml() {
53
+ if (! $this->_shouldRender) {
54
+ return '';
55
+ }
56
+ return parent::_toHtml ();
57
+ }
58
+
59
+ /**
60
+ * Check is "OR" label position before checkout
61
+ *
62
+ * @return bool
63
+ */
64
+ public function isOrPositionBefore() {
65
+ return $this->getShowOrPosition () && $this->getShowOrPosition () == self::POSITION_BEFORE;
66
+ }
67
+
68
+ /**
69
+ * Check is "OR" label position after checkout
70
+ *
71
+ * @return bool
72
+ */
73
+ public function isOrPositionAfter() {
74
+ return $this->getShowOrPosition () && $this->getShowOrPosition () == self::POSITION_AFTER;
75
+ }
76
+ }
app/code/community/Dhl/Postpay/Block/Payment/Form/Standard.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PayPal Standard payment "form"
4
+ */
5
+ class Dhl_Postpay_Block_Payment_Form_Standard extends Mage_Payment_Block_Form {
6
+ public function __construct() {
7
+ parent::__construct ();
8
+
9
+ $image = Mage::getConfig ()->getBlockClassName ( 'core/template' );
10
+ $image = new $image ();
11
+ $image->setTemplate ( 'postpay/checkout/image.phtml' );
12
+
13
+ $this->setTemplate ( 'postpay/payment/redirect.phtml' )->setRedirectMessage ( Mage::helper ( 'postpay' )->__ ( 'You will be redirected to the Postpay website when you place an order.' ) )->setMethodTitle ( '' )->setMethodLabelAfterHtml ( $image->toHtml () );
14
+ }
15
+ }
app/code/community/Dhl/Postpay/Block/Payment/Info/Standard.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Paypal expess checkout shortcut link
4
+ */
5
+ class Dhl_Postpay_Block_Payment_Info_Standard extends Mage_Payment_Block_Info {
6
+ }
app/code/community/Dhl/Postpay/Helper/Cron.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_Postpay_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_Postpay_Model_Cron::SYNC_CATALOG :
45
+ $res = Mage::getSingleton ( 'meinpaket/service_product_export' )->exportProducts ();
46
+ break;
47
+ case Dhl_Postpay_Model_Cron::SYNC_ORDERS :
48
+ $res = Mage::getSingleton ( 'meinpaket/service_order_importService' )->importOrders ();
49
+ break;
50
+ case Dhl_Postpay_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/Postpay/Helper/Data.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Default helper for the Dhl_Postpay package.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_Postpay
8
+ * @subpackage Helper
9
+ */
10
+ class Dhl_Postpay_Helper_Data extends Mage_Core_Helper_Abstract {
11
+ /**
12
+ *
13
+ * @return string
14
+ */
15
+ public function getExtensionVersion() {
16
+ return ( string ) Mage::getConfig ()->getModuleConfig ( 'Dhl_Postpay' )->version;
17
+ }
18
+
19
+ /**
20
+ * Is postpay active?
21
+ *
22
+ * @return bool
23
+ */
24
+ public function isActive() {
25
+ return ( bool ) Mage::getStoreConfigFlag ( 'payment/postpay_express/active' );
26
+ }
27
+ }
app/code/community/Dhl/Postpay/Model/Cart.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_Postpay_Model_Cart extends Mage_Core_Model_Abstract {
3
+ /**
4
+ * (non-PHPdoc)
5
+ *
6
+ * @see Varien_Object::_construct()
7
+ */
8
+ public function _construct() {
9
+ parent::_construct ();
10
+ $this->_init ( 'postpay/cart' );
11
+ }
12
+
13
+ /**
14
+ */
15
+ public function generateNotificationId() {
16
+ $this->setNotificationId ( $this->generateRandomString () );
17
+ }
18
+
19
+ /**
20
+ *
21
+ * @param number $length
22
+ * @return string
23
+ */
24
+ public function generateRandomString($length = 10) {
25
+ $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
26
+ $charactersLength = strlen ( $characters );
27
+ $randomString = '';
28
+ for($i = 0; $i < $length; $i ++) {
29
+ $randomString .= $characters [rand ( 0, $charactersLength - 1 )];
30
+ }
31
+ return $randomString;
32
+ }
33
+
34
+ /**
35
+ * Processing object before save data
36
+ *
37
+ * @return Mage_Core_Model_Abstract
38
+ */
39
+ protected function _beforeSave() {
40
+ if (strlen ( $this->getNotificationId () ) <= 0) {
41
+ $this->generateNotificationId ();
42
+ }
43
+
44
+ if (! $this->getCreatedAt ()) {
45
+ $this->setCreatedAt ( time () );
46
+ }
47
+
48
+ return parent::_beforeSave ();
49
+ }
50
+ }
app/code/community/Dhl/Postpay/Model/Cron.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Cron handler for Dhl Allyouneed.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model
9
+ */
10
+ class Dhl_Postpay_Model_Cron {
11
+ const SYNC_ORDERS = 'meinpaket_sync_orders';
12
+ public static $CRONJOBS = array (
13
+ self::SYNC_CATALOG
14
+ );
15
+
16
+ /**
17
+ * Called to download orders.
18
+ *
19
+ * @return NULL
20
+ */
21
+ public function importOrders() {
22
+ try {
23
+ return Mage::getSingleton ( 'postpay/service_order_importService' )->importOrders ();
24
+ } catch ( Exception $e ) {
25
+ Mage::logException ( $e );
26
+ }
27
+ return null;
28
+ }
29
+ }
app/code/community/Dhl/Postpay/Model/Mysql4/Cart.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_Postpay_Model_Mysql4_Cart 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 ( 'postpay/cart', 'cart_id' );
10
+ }
11
+ }
app/code/community/Dhl/Postpay/Model/Mysql4/Cart/Collection.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_Postpay_Model_Mysql4_Cart_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 ( 'postpay/cart' );
10
+ }
11
+ }
app/code/community/Dhl/Postpay/Model/Observer.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Observer for all events the DHL Allyouneed extension has to catch.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model
9
+ * @version $Id$
10
+ */
11
+ class Dhl_Postpay_Model_Observer {
12
+ }
app/code/community/Dhl/Postpay/Model/Payment/Method/Express.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Postpay payment method for imported orders.
5
+ *
6
+ * @category Mage
7
+ * @package Dhl_Postpay
8
+ * @subpackage Payment_Method
9
+ */
10
+ class Dhl_Postpay_Model_Payment_Method_Express extends Mage_Payment_Model_Method_Abstract {
11
+ /**
12
+ *
13
+ * @var string
14
+ */
15
+ protected $_code = 'postpay_express';
16
+
17
+ /**
18
+ * Is this payment method a gateway (online auth/charge) ?
19
+ */
20
+ protected $_isGateway = true;
21
+
22
+ /**
23
+ * Can authorize online?
24
+ */
25
+ protected $_canAuthorize = true;
26
+
27
+ /**
28
+ * Can capture funds online?
29
+ */
30
+ protected $_canCapture = true;
31
+
32
+ /**
33
+ * Can capture partial amounts online?
34
+ */
35
+ protected $_canCapturePartial = false;
36
+
37
+ /**
38
+ * Can refund online?
39
+ */
40
+ protected $_canRefund = false;
41
+
42
+ /**
43
+ * Can void transactions online?
44
+ */
45
+ protected $_canVoid = true;
46
+
47
+ /**
48
+ * Can use this payment method in administration panel?
49
+ */
50
+ protected $_canUseInternal = false;
51
+
52
+ /**
53
+ * Can show this payment method as an option on checkout payment page?
54
+ */
55
+ protected $_canUseCheckout = false;
56
+
57
+ /**
58
+ * Is this payment method suitable for multi-shipping checkout?
59
+ */
60
+ protected $_canUseForMultishipping = false;
61
+
62
+ /**
63
+ * Can save credit card information for future processing?
64
+ */
65
+ protected $_canSaveCc = false;
66
+
67
+ /**
68
+ * Is this method already authorized for the current order.
69
+ *
70
+ * @var unknown
71
+ */
72
+ protected $_isAuthorized = false;
73
+ }
app/code/community/Dhl/Postpay/Model/Payment/Method/Standard.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Postpay payment method for imported orders.
5
+ *
6
+ * @category Mage
7
+ * @package Dhl_Postpay
8
+ * @subpackage Payment_Method
9
+ */
10
+ class Dhl_Postpay_Model_Payment_Method_Standard extends Mage_Payment_Model_Method_Abstract {
11
+ /**
12
+ *
13
+ * @var string
14
+ */
15
+ protected $_code = 'postpay_standard';
16
+ protected $_infoBlockType = 'postpay/payment_info_standard';
17
+ protected $_formBlockType = 'postpay/payment_form_standard';
18
+
19
+ /**
20
+ * Is this payment method a gateway (online auth/charge) ?
21
+ */
22
+ protected $_isGateway = true;
23
+
24
+ /**
25
+ * Can authorize online?
26
+ */
27
+ protected $_canAuthorize = true;
28
+
29
+ /**
30
+ * Can capture funds online?
31
+ */
32
+ protected $_canCapture = true;
33
+
34
+ /**
35
+ * Can capture partial amounts online?
36
+ */
37
+ protected $_canCapturePartial = false;
38
+
39
+ /**
40
+ * Can refund online?
41
+ */
42
+ protected $_canRefund = false;
43
+
44
+ /**
45
+ * Can void transactions online?
46
+ */
47
+ protected $_canVoid = true;
48
+
49
+ /**
50
+ * Can use this payment method in administration panel?
51
+ */
52
+ protected $_canUseInternal = false;
53
+
54
+ /**
55
+ * Can show this payment method as an option on checkout payment page?
56
+ */
57
+ protected $_canUseCheckout = true;
58
+
59
+ /**
60
+ * Is this payment method suitable for multi-shipping checkout?
61
+ */
62
+ protected $_canUseForMultishipping = false;
63
+
64
+ /**
65
+ * Can save credit card information for future processing?
66
+ */
67
+ protected $_canSaveCc = false;
68
+
69
+ /**
70
+ * Is this method already authorized for the current order.
71
+ *
72
+ * @var unknown
73
+ */
74
+ protected $_isAuthorized = false;
75
+
76
+ /**
77
+ * Here you will need to implement authorize, capture and void public methods
78
+ *
79
+ * @see examples of transaction specific public methods such as
80
+ * authorize, capture and void in Mage_Paygate_Model_Authorizenet
81
+ */
82
+
83
+ /**
84
+ * Return URL to redirect the customer to.
85
+ * Called after 'place order' button is clicked.
86
+ * Called after order is created and saved.
87
+ *
88
+ * @return string
89
+ */
90
+ public function getOrderPlaceRedirectUrl() {
91
+ // Get and clear value from session
92
+ $url = Mage::getSingleton ( 'checkout/session' )->getData ( 'postpay_redirect_url', true );
93
+ return $url;
94
+ }
95
+
96
+ /**
97
+ * Send authorize request to gateway
98
+ *
99
+ * @param Mage_Payment_Model_Info $payment
100
+ * @param decimal $amount
101
+ * @return Mage_Paygate_Model_Authorizenet
102
+ */
103
+ public function authorize(Varien_Object $payment, $amount) {
104
+ if ($this->_isAuthorized) {
105
+ return $this;
106
+ }
107
+
108
+ if ($amount <= 0) {
109
+ Mage::throwException ( Mage::helper ( 'postpay' )->__ ( 'Invalid amount for authorization.' ) );
110
+ }
111
+
112
+ $request = new Dhl_MeinPaketCommon_Model_Xml_Request_SubmitCartRequest ();
113
+
114
+ $cart = Mage::getModel ( 'postpay/cart' );
115
+ $cart->generateNotificationId ();
116
+ $cart->setOrderId ( $payment->getOrder ()->getId () );
117
+ $cart->save ();
118
+
119
+ $notificationId = $request->addCart ( $payment->getOrder (), $cart );
120
+
121
+ $this->getInfoInstance ()->setData ( 'postpay_notification_id', $cart->getNotificationId () );
122
+
123
+ if ($request->isHasData ()) {
124
+ $client = Mage::getModel ( 'meinpaketcommon/client_xmlOverHttp' );
125
+ /* @var $client Dhl_Postpay_Model_Client_XmlOverHttp */
126
+
127
+ $response = $client->send ( $request );
128
+ /* @var $response Dhl_Postpay_Model_Xml_Response_SubmitCartResponse */
129
+
130
+ $this->getInfoInstance ()->setData ( 'postpay_cart_id', $response->getCartId () );
131
+
132
+ Mage::getSingleton ( 'checkout/session' )->setData ( 'postpay_redirect_url', $response->getRedirectURL () );
133
+ } else {
134
+ throw new Exception ( 'Cannot authorize order' );
135
+ }
136
+
137
+ return $this;
138
+ }
139
+
140
+ /**
141
+ * Send capture request to gateway
142
+ *
143
+ * @param Mage_Payment_Model_Info $payment
144
+ * @param decimal $amount
145
+ * @return Mage_Paygate_Model_Authorizenet
146
+ */
147
+ public function capture(Varien_Object $payment, $amount) {
148
+ /*
149
+ * if ($amount <= 0) {
150
+ * Mage::throwException ( Mage::helper ( 'postpay' )->__ ( 'Invalid amount for capture.' ) );
151
+ * }
152
+ */
153
+ return $this;
154
+ }
155
+
156
+ /**
157
+ * Void the payment through gateway
158
+ *
159
+ * @param Mage_Payment_Model_Info $payment
160
+ * @return Mage_Paygate_Model_Authorizenet
161
+ */
162
+ public function void(Varien_Object $payment) {
163
+ return $this;
164
+ }
165
+ }
app/code/community/Dhl/Postpay/Model/Resource/Eav/Mysql4/Setup.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_Postpay_Model_Resource_Eav_Mysql4_Setup extends Mage_Catalog_Model_Resource_Setup {
3
+ /**
4
+ *
5
+ * @return array
6
+ */
7
+ public function getDefaultEntities() {
8
+ return array ();
9
+ }
10
+ }
11
+
app/code/community/Dhl/Postpay/Model/Service/Order/ImportService.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Service class which imports orders from Allyouneed.
5
+ *
6
+ * @category Dhl
7
+ * @package Dhl_MeinPaket
8
+ * @subpackage Model_Order
9
+ * @version $Id$
10
+ */
11
+ class Dhl_Postpay_Model_Service_Order_ImportService extends Dhl_MeinPaketCommon_Model_Service_Order_ImportService {
12
+
13
+ /**
14
+ *
15
+ * @var string
16
+ */
17
+ const POSTPAY_IMPORT_PAYMENT_METHOD = 'postpay_express';
18
+
19
+ /**
20
+ * Constructor.
21
+ *
22
+ * @return void
23
+ */
24
+ public function __construct() {
25
+ parent::__construct ();
26
+ }
27
+
28
+ /**
29
+ * Imports Order from meinPaket
30
+ * //TODO make a simple result object containing: countnew / countexisting / warnings (e.g.
31
+ * if price missmatch)
32
+ *
33
+ * @param integer $start
34
+ * @param integer $stop
35
+ * @return void
36
+ */
37
+ public function importOrders($start = null, $stop = null) {
38
+ /* @var $client Dhl_MeinPaketCommon_Model_Client_XmlOverHttp */
39
+ $client = Mage::getModel ( 'meinpaketcommon/client_xmlOverHttp' );
40
+
41
+ $cartCollection = Mage::getModel ( 'postpay/cart' )->getCollection ()->addFilter ( 'state', 'PENDING' );
42
+
43
+ foreach ( $cartCollection as $cart ) {
44
+ $queryRequest = new Dhl_MeinPaketCommon_Model_Xml_Request_QueryRequest ();
45
+ $queryRequest->addShoppingCartStatus ( $cart->getCartId () );
46
+
47
+ if ($queryRequest->isHasData ()) {
48
+ $connection = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_write' );
49
+ try {
50
+ $connection->beginTransaction ();
51
+
52
+ // Make saves and other actions that affect the database
53
+ $queryResult = $client->send ( $queryRequest );
54
+
55
+ if ($queryResult != null && $queryResult instanceof Dhl_MeinPaketCommon_Model_Xml_Response_QueryResponse) {
56
+ $this->processQueryResponse ( $cart, $queryResult );
57
+ }
58
+
59
+ $connection->commit ();
60
+ } catch ( Exception $e ) {
61
+ $connection->rollback ();
62
+ }
63
+ }
64
+ }
65
+
66
+ return parent::importOrders ( $start, $stop );
67
+ }
68
+
69
+ /**
70
+ * process status infos.
71
+ *
72
+ * @param Dhl_Postpay_Model_Cart $cart
73
+ * @param Dhl_MeinPaketCommon_Model_Xml_Response_QueryResponse $queryResult
74
+ */
75
+ protected function processQueryResponse(Dhl_Postpay_Model_Cart $cart, Dhl_MeinPaketCommon_Model_Xml_Response_QueryResponse $queryResult) {
76
+ $statusResponses = $queryResult->getShoppingCartStatusResponses ();
77
+
78
+ reset ( $statusResponses );
79
+ $key = key ( $statusResponses );
80
+ $status = strtoupper ( $statusResponses [$key] );
81
+
82
+ $orderModel = null;
83
+ /* @var $order Mage_Sales_Model_Order */
84
+ if ($cart->getOrderId () != null) {
85
+ $orderModel = Mage::getModel ( 'sales/order' )->load ( $cart->getOrderId () );
86
+ }
87
+
88
+ switch ($status) {
89
+ case 'PENDING' :
90
+ break;
91
+ case 'CREATEDORDER' :
92
+ $queryRequest = new Dhl_MeinPaketCommon_Model_Xml_Request_QueryRequest ();
93
+ $queryRequest->addOrderExternalId ( $cart->getCartId () );
94
+
95
+ if ($queryRequest->isHasData ()) {
96
+ /* @var $client Dhl_MeinPaketCommon_Model_Client_XmlOverHttp */
97
+ $client = Mage::getModel ( 'meinpaketcommon/client_xmlOverHttp' );
98
+
99
+ $queryResult = $client->send ( $queryRequest );
100
+
101
+ if ($queryResult != null && $queryResult instanceof Dhl_MeinPaketCommon_Model_Xml_Response_QueryResponse) {
102
+ foreach ( $queryResult->getOrders () as $order ) {
103
+ /* @var $order Dhl_MeinPaketCommon_Model_Xml_Response_Partial_Order */
104
+ if ($orderModel != null && $orderModel->getId ()) {
105
+ $this->_orderCount ['imported'] ++;
106
+ $orderModel->setData ( 'dhl_mein_paket_order_id', $order->getOrderId () );
107
+ $this->createInvoice ( $orderModel );
108
+
109
+ $cart->setState ( $status );
110
+ $cart->save ();
111
+ } else {
112
+ $successCode = $this->_importOrder ( $order, self::POSTPAY_IMPORT_PAYMENT_METHOD );
113
+ switch ($successCode) {
114
+ case self::IMPORTED_ORDER_STATUS :
115
+ $this->_orderCount ['imported'] ++;
116
+
117
+ $cart->setState ( $status );
118
+ $cart->save ();
119
+
120
+ break;
121
+ case self::DUPLICATE_ORDER_STATUS :
122
+ $this->_orderCount ['duplicates'] ++;
123
+
124
+ $cart->setState ( $status );
125
+ $cart->save ();
126
+
127
+ break;
128
+ case self::OUT_OF_STOCK_ORDER_STATUS :
129
+ $this->_orderCount ['outOfStock'] ++;
130
+ break;
131
+ case self::INVALID_PRODUCT_STATUS :
132
+ $this->_orderCount ['invalid'] ++;
133
+ break;
134
+ case self::DISABLED_ORDER_STATUS :
135
+ $this->_orderCount ['disabled'] ++;
136
+ break;
137
+ }
138
+ }
139
+ }
140
+ }
141
+ }
142
+
143
+ break;
144
+ case 'CANCELED' :
145
+ if ($order != null) {
146
+ $order->cancel ();
147
+ $order->save ();
148
+ }
149
+ $cart->setState ( $status );
150
+ $cart->save ();
151
+ break;
152
+ }
153
+ }
154
+ }
app/code/community/Dhl/Postpay/controllers/CheckoutController.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_Postpay_CheckoutController extends Mage_Core_Controller_Front_Action {
3
+
4
+ /**
5
+ * Forward to postpay.
6
+ */
7
+ public function indexAction() {
8
+ Mage::log ( 'Called custom ' . __METHOD__ );
9
+
10
+ $quote = Mage::helper ( 'meinpaketcommon/data' )->getQuoteFiltered ();
11
+
12
+ if ($quote == null) {
13
+ $this->_redirect ( 'checkout/cart' );
14
+ }
15
+
16
+ $request = new Dhl_MeinPaketCommon_Model_Xml_Request_SubmitCartRequest ();
17
+
18
+ $cart = Mage::getModel ( 'postpay/cart' );
19
+ $cart->generateNotificationId ();
20
+ $cart->save ();
21
+
22
+ $notificationId = $request->addCart ( $quote, $cart );
23
+
24
+ if ($request->isHasData ()) {
25
+
26
+ // $this->getInfoInstance ()->setData ( 'postpay_notification_id' );
27
+
28
+ $client = Mage::getModel ( 'meinpaketcommon/client_xmlOverHttp' );
29
+ /* @var $client Dhl_MeinPaketCommon_Model_Client_XmlOverHttp */
30
+
31
+ try {
32
+ $response = $client->send ( $request );
33
+ /* @var $response Dhl_MeinPaketCommon_Model_Xml_Response_SubmitCartResponse */
34
+
35
+ // $this->getInfoInstance ()->setData ( 'postpay_cart_id', $response->getCartId () );
36
+
37
+ $quote->delete ();
38
+ $this->_redirectUrl ( $response->getRedirectURL () );
39
+ return;
40
+ } catch ( Exception $e ) {
41
+ Mage::logException ( $e );
42
+ }
43
+ }
44
+ $this->_redirect ( 'checkout/cart' );
45
+ }
46
+ }
app/code/community/Dhl/Postpay/controllers/NotificationController.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_Postpay_ResponseController extends Mage_Core_Controller_Front_Action {
3
+ public function pushAction() {
4
+ // externalCartId=[CartId]&ordered=[ordered]&status=[Status]&notificationId=[notificationId]
5
+ $cart = $Mage::getModel ( 'postpay/cart' )->load ( $this->getRequest ()->getParam ( 'externalCartId' ) );
6
+
7
+ if (! $cart->getId () && $cart->getOrderId () != null) {
8
+ return;
9
+ }
10
+
11
+ $order = Mage::getModel ( 'sales/order' )->load ( $cart->getOrderId () );
12
+ /* @var $order Mage_Sales_Model_Order */
13
+
14
+ if ($order && $order->getPayment ()->getMethodInstance ()->getCode () == 'postpay' && $order->getPayment ()->getMethodInstance ()->getInfoInstance ()->getData ( 'postpay_order_id' ) == $this->getRequest ()->getParam ( 'orderId' ) && $order->getPayment ()->getMethodInstance ()->getInfoInstance ()->getData ( 'postpay_notification_id' ) == $this->getRequest ()->getParam ( 'notificationId' )) {
15
+ $status = $this->getRequest ()->getParam ( 'status', 'Pending' );
16
+ $order->getPayment ()->getMethodInstance ()->getInfoInstance ()->setData ( 'postpay_status', $status );
17
+
18
+ switch ($status) {
19
+ case 'CreatedOrder' :
20
+ if ($order->canInvoice ()) {
21
+ $invoice = $order->prepareInvoice ();
22
+
23
+ $invoice->setRequestedCaptureCase ( Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE );
24
+ $invoice->register ();
25
+ $transactionSave = Mage::getModel ( 'core/resource_transaction' )->addObject ( $invoice )->addObject ( $invoice->getOrder () );
26
+ $transactionSave->save ();
27
+ }
28
+ break;
29
+ case 'Canceled' :
30
+ if ($order->canCancel ()) {
31
+ $order->cancel ();
32
+ $order->save ();
33
+ }
34
+ break;
35
+ default :
36
+ // Nothing to do
37
+ }
38
+ }
39
+ }
40
+ }
app/code/community/Dhl/Postpay/controllers/ResponseController.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dhl_Postpay_ResponseController extends Mage_Core_Controller_Front_Action {
3
+
4
+ /**
5
+ * When paypal returns
6
+ * The order information at this point is in POST
7
+ * variables.
8
+ * However, you don't want to "process" the order until you
9
+ * get validation from the api.
10
+ */
11
+ public function successAction() {
12
+ Mage::log ( 'Called custom ' . __METHOD__ );
13
+ // if (! $this->_isValidToken ()) {
14
+ // Mage::Log ( 'Token is invalid.' );
15
+ // $this->_redirect ( 'checkout/cart' );
16
+ // }
17
+
18
+ $this->_redirect ( 'checkout/onepage/success', array (
19
+ '_secure' => true
20
+ ) );
21
+ }
22
+ /**
23
+ * Handles 'falures' from api
24
+ * Failure could occur if api system failure, insufficent funds, or system error.
25
+ *
26
+ * @throws Exception
27
+ */
28
+ public function errorAction() {
29
+ Mage::Log ( 'Called ' . __METHOD__ );
30
+ $this->_cancelAction ();
31
+ }
32
+ public function backAction() {
33
+ Mage::Log ( 'Called ' . __METHOD__ );
34
+ $this->_cancelAction ();
35
+ }
36
+ protected function _cancelAction() {
37
+ $orderId = $this->getRequest ()->getParam ( 'order' );
38
+
39
+ if ($orderId != null) {
40
+ $order = Mage::getModel ( 'sales/order' )->load ( $orderId );
41
+ /* @var $order Mage_Sales_Model_Order */
42
+ if ($order->canCancel ()) {
43
+ $order->cancel ();
44
+ }
45
+ }
46
+
47
+ $this->_redirect ( 'checkout/onepage/failure', array (
48
+ '_secure' => true
49
+ ) );
50
+ }
51
+ }
app/code/community/Dhl/Postpay/etc/config.xml ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dhl_Postpay>
5
+ <version>1.1.0</version>
6
+ </Dhl_Postpay>
7
+ </modules>
8
+ <admin>
9
+ <routers>
10
+ <postpay>
11
+ <use>admin</use>
12
+ <args>
13
+ <module>Dhl_Postpay</module>
14
+ <frontName>postpay</frontName>
15
+ </args>
16
+ </postpay>
17
+ </routers>
18
+ </admin>
19
+ <adminhtml>
20
+ <translate>
21
+ <modules>
22
+ <postpay>
23
+ <files>
24
+ <default>Dhl_Postpay.csv</default>
25
+ </files>
26
+ </postpay>
27
+ </modules>
28
+ </translate>
29
+ <layout>
30
+ <updates>
31
+ <postpay>
32
+ <file>postpay.xml</file>
33
+ </postpay>
34
+ </updates>
35
+ </layout>
36
+ </adminhtml>
37
+ <default>
38
+ <payment>
39
+ <postpay_standard>
40
+ <active>0</active>
41
+ <model>postpay/payment_method_standard</model>
42
+ <order_status>pending</order_status>
43
+ <title>Postpay Standard</title>
44
+ <allowspecific>0</allowspecific>
45
+ <payment_action>authorize</payment_action>
46
+ <!-- <group>offline</group> -->
47
+ </postpay_standard>
48
+ <postpay_express>
49
+ <active>0</active>
50
+ <model>postpay/payment_method_express</model>
51
+ <order_status>pending</order_status>
52
+ <title>Postpay Express</title>
53
+ <allowspecific>0</allowspecific>
54
+ <payment_action>authorize</payment_action>
55
+ <!-- <group>offline</group> -->
56
+ </postpay_express>
57
+ </payment>
58
+ </default>
59
+ <frontend>
60
+ <translate>
61
+ <modules>
62
+ <postpay>
63
+ <files>
64
+ <default>Dhl_Postpay.csv</default>
65
+ </files>
66
+ </postpay>
67
+ </modules>
68
+ </translate>
69
+ <routers>
70
+ <postpay>
71
+ <use>standard</use>
72
+ <args>
73
+ <module>Dhl_Postpay</module>
74
+ <frontName>postpay</frontName>
75
+ </args>
76
+ </postpay>
77
+ </routers>
78
+ <layout>
79
+ <updates>
80
+ <postpay>
81
+ <file>postpay.xml</file>
82
+ </postpay>
83
+ </updates>
84
+ </layout>
85
+ </frontend>
86
+ <global>
87
+ <resources>
88
+ <postpay_setup>
89
+ <setup>
90
+ <module>Dhl_Postpay</module>
91
+ <class>Dhl_Postpay_Model_Resource_Eav_Mysql4_Setup</class>
92
+ </setup>
93
+ <connection>
94
+ <use>core_setup</use>
95
+ </connection>
96
+ </postpay_setup>
97
+ </resources>
98
+ <models>
99
+ <postpay>
100
+ <class>Dhl_Postpay_Model</class>
101
+ <resourceModel>postpay_mysql4</resourceModel>
102
+ </postpay>
103
+ <postpay_mysql4>
104
+ <class>Dhl_Postpay_Model_Mysql4</class>
105
+ <entities>
106
+ <cart>
107
+ <table>postpay_cart</table>
108
+ </cart>
109
+ </entities>
110
+ </postpay_mysql4>
111
+ <meinpaketcommon>
112
+ <rewrite>
113
+ <service_order_importService>Dhl_Postpay_Model_Service_Order_ImportService</service_order_importService>
114
+ </rewrite>
115
+ </meinpaketcommon>
116
+ </models>
117
+ <blocks>
118
+ <postpay>
119
+ <class>Dhl_Postpay_Block</class>
120
+ </postpay>
121
+ </blocks>
122
+ <helpers>
123
+ <postpay>
124
+ <class>Dhl_Postpay_Helper</class>
125
+ </postpay>
126
+ </helpers>
127
+ </global>
128
+ </config>
app/code/community/Dhl/Postpay/etc/system.xml ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <payment>
5
+ <groups>
6
+ <postpay_standard translate="label" module="postpay">
7
+ <label>Postpay Standard Payment Module</label>
8
+ <sort_order>999</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>0</show_in_store>
12
+ <fields>
13
+ <active translate="label">
14
+ <label>Enabled</label>
15
+ <frontend_type>select</frontend_type>
16
+ <source_model>adminhtml/system_config_source_yesno</source_model>
17
+ <sort_order>1</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>1</show_in_website>
20
+ <show_in_store>0</show_in_store>
21
+ </active>
22
+ <order_status translate="label">
23
+ <label>New order status</label>
24
+ <frontend_type>select</frontend_type>
25
+ <source_model>adminhtml/system_config_source_order_status_processing</source_model>
26
+ <sort_order>2</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>0</show_in_store>
30
+ </order_status>
31
+ <title translate="label">
32
+ <label>Title</label>
33
+ <frontend_type>text</frontend_type>
34
+ <sort_order>3</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>0</show_in_store>
38
+ </title>
39
+ <address translate="label comment">
40
+ <label>Send Customer Address</label>
41
+ <comment><![CDATA[Send Customer Address to POSTPAY]]></comment>
42
+ <frontend_type>select</frontend_type>
43
+ <source_model>adminhtml/system_config_source_yesno</source_model>
44
+ <sort_order>30</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>0</show_in_website>
47
+ <show_in_store>0</show_in_store>
48
+ </address>
49
+ </fields>
50
+ </postpay_standard>
51
+ <postpay_express translate="label" module="postpay">
52
+ <label>Postpay Express Payment Module</label>
53
+ <sort_order>999</sort_order>
54
+ <show_in_default>1</show_in_default>
55
+ <show_in_website>1</show_in_website>
56
+ <show_in_store>0</show_in_store>
57
+ <fields>
58
+ <active translate="label">
59
+ <label>Enabled</label>
60
+ <frontend_type>select</frontend_type>
61
+ <source_model>adminhtml/system_config_source_yesno</source_model>
62
+ <sort_order>1</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>0</show_in_store>
66
+ </active>
67
+ <order_status translate="label">
68
+ <label>New order status</label>
69
+ <frontend_type>select</frontend_type>
70
+ <source_model>adminhtml/system_config_source_order_status_processing</source_model>
71
+ <sort_order>2</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>0</show_in_store>
75
+ </order_status>
76
+ <title translate="label">
77
+ <label>Title</label>
78
+ <frontend_type>text</frontend_type>
79
+ <sort_order>3</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>0</show_in_store>
83
+ </title>
84
+ <address translate="label comment">
85
+ <label>Send Customer Address</label>
86
+ <comment><![CDATA[Send Customer Address to POSTPAY]]></comment>
87
+ <frontend_type>select</frontend_type>
88
+ <source_model>adminhtml/system_config_source_yesno</source_model>
89
+ <sort_order>30</sort_order>
90
+ <show_in_default>1</show_in_default>
91
+ <show_in_website>0</show_in_website>
92
+ <show_in_store>0</show_in_store>
93
+ </address>
94
+ </fields>
95
+ </postpay_express>
96
+ </groups>
97
+ </payment>
98
+ </sections>
99
+ </config>
100
+
app/code/community/Dhl/Postpay/sql/postpay_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Setup-Script fuer Dhl_Postpay
4
+ */
5
+
6
+ /* @var $installer Dhl_Postpay_Model_Resource_Eav_Mysql4_Setup */
7
+ $installer = $this;
8
+ $installer->startSetup ();
9
+
10
+ $installer->installEntities ();
11
+
12
+ $installer->run ( "
13
+ DROP TABLE IF EXISTS {$this->getTable('postpay/cart')};
14
+ CREATE TABLE {$this->getTable('postpay/cart')} (
15
+ `cart_id` int(11) unsigned NOT NULL auto_increment,
16
+ `order_id` int(11) unsigned,
17
+ `notification_id` varchar(255),
18
+ `state` varchar(255) DEFAULT 'PENDING',
19
+ `created_at` timestamp default CURRENT_TIMESTAMP(),
20
+ PRIMARY KEY(`cart_id`)
21
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Allyouneed Sync';
22
+ " );
23
+
24
+ $installer->endSetup ();
app/design/adminhtml/default/default/layout/meinpaket.xml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout version="0.1.0">
3
+ <meinpaket_adminhtml_categoryimport_index>
4
+ <update handle="meinpaket_head_imports" />
5
+ <reference name="content">
6
+ <block type="meinpaket/adminhtml_categoryImport_index" name="meinpaket.adminhtml_categoryImport_index"
7
+ template="meinpaket/category/import/index.phtml" />
8
+ </reference>
9
+ </meinpaket_adminhtml_categoryimport_index>
10
+
11
+ <meinpaket_adminhtml_categoryimport_import>
12
+ <update handle="meinpaket_head_imports" />
13
+ <reference name="content">
14
+ <block type="meinpaket/adminhtml_categoryImport_index" name="meinpaket.adminhtml_categoryImport_import"
15
+ template="meinpaket/category/import/import.phtml" />
16
+ </reference>
17
+ </meinpaket_adminhtml_categoryimport_import>
18
+
19
+ <meinpaket_adminhtml_backlog_product_index>
20
+ <update handle="meinpaket_head_imports" />
21
+ <reference name="content">
22
+ <block type="meinpaket/adminhtml_backlog_product" name="meinpaket_admin_backlog_grid" />
23
+ </reference>
24
+ </meinpaket_adminhtml_backlog_product_index>
25
+
26
+ <meinpaket_adminhtml_matching_index>
27
+ <update handle="meinpaket_head_imports" />
28
+ <block type="core/text_list" name="root" output="toHtml">
29
+ <block type="meinpaket/adminhtml_catalog_product_matching_result" name="catalog.product.matching.result"
30
+ template="meinpaket/catalog/product/matching/result.phtml" />
31
+ </block>
32
+ </meinpaket_adminhtml_matching_index>
33
+
34
+ <meinpaket_adminhtml_bestprice_index translate="label" module="meinpaket">
35
+ <update handle="meinpaket_head_imports" />
36
+ <reference name="content">
37
+ <block type="meinpaket/adminhtml_bestPrice" name="meinpaket_admin_bestPrice_grid" />
38
+ </reference>
39
+ </meinpaket_adminhtml_bestprice_index>
40
+
41
+ <adminhtml_catalog_product_edit>
42
+ <update handle="meinpaket_head_imports" />
43
+ <reference name="product_tabs">
44
+ <action method="addTab">
45
+ <name>meinpaket_matching</name>
46
+ <block>meinpaket/adminhtml_catalog_product_matching_tab</block>
47
+ </action>
48
+ </reference>
49
+ </adminhtml_catalog_product_edit>
50
+ </layout>
app/design/adminhtml/default/default/layout/meinpaketcommon.xml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>meinpaketcommon/module.js</name>
8
+ <params />
9
+ </action>
10
+ <action method="addItem">
11
+ <type>skin_css</type>
12
+ <name>meinpaketcommon/module.css</name>
13
+ <params />
14
+ </action>
15
+ </reference>
16
+ </meinpaket_head_imports>
17
+
18
+ <meinpaketcommon_adminhtml_log_index translate="label"
19
+ module="meinpaketcommon">
20
+ <update handle="meinpaket_head_imports" />
21
+ <reference name="content">
22
+ <block type="meinpaketcommon/adminhtml_log" name="meinpaketcommon_admin_log_grid" />
23
+ </reference>
24
+ </meinpaketcommon_adminhtml_log_index>
25
+
26
+ <meinpaketcommon_adminhtml_async_index translate="label"
27
+ module="meinpaketcommon">
28
+ <update handle="meinpaket_head_imports" />
29
+ <reference name="content">
30
+ <block type="meinpaketcommon/adminhtml_async" name="meinpaket_admin_async_grid" />
31
+ </reference>
32
+ </meinpaketcommon_adminhtml_async_index>
33
+
34
+ <adminhtml_system_config_edit>
35
+ <update handle="meinpaket_head_imports" />
36
+ <reference name="head"></reference>
37
+ </adminhtml_system_config_edit>
38
+ </layout>
app/design/adminhtml/default/default/layout/postpay.xml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout version="0.1.0">
3
+ </layout>
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 allyouneed"><?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 allyouneed-content">
21
+ <ul class="allyouneed-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="allyouneed-results" class="scrollablebox grid entry-edit">
31
+ <?php if($result !== null && $result->getNewCategoriesCount() + $result->getDeletedCategoriesCount() + $result->getUpdatedCategoriesCount() > 0) : ?>
32
+ <table id="allyouneed-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" colspan="2"><?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 colspan="2"><?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" colspan="2"><?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 colspan="2"><?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="allyouneed-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,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <div class="content-header">
3
+ <table 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 allyouneed-content">
17
+
18
+ <ul class="allyouneed-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="allyouneed-description">
28
+ <p><?php echo __('Textual introduction into category import goes here...'); ?></p>
29
+
30
+ <form id="allyouneed_form" name="allyouneed_form" method="get"
31
+ action="<?php echo $this->getUrl('meinpaket/adminhtml_categoryImport/import/') ?>">
32
+ <fieldset>
33
+ <button onclick="startProcessing()" class="scalable" type="button"
34
+ id="startButton">
35
+ <span><?php echo $this->__('import categories'); ?></span>
36
+ </button>
37
+ </fieldset>
38
+ </form>
39
+ </div>
40
+
41
+ <div id="disabled-till-export" class="allyouneed-waitbox"
42
+ style="display: none">
43
+ <img
44
+ src="<?php echo $this->getSkinUrl('meinpaketcommon/images/loader.gif')?>" /><br />
45
+ <small><?php echo $this->__('please wait'); ?></small>
46
+ </div>
47
+
48
+ </div>
49
+
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/steps.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <ul class="allyouneed-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/layout/meinpaketcommon.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/layout/postpay.xml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout version="0.1.0">
3
+ <checkout_cart_index>
4
+ <reference name="checkout.cart.top_methods">
5
+ <block type="postpay/checkout" name="checkout.cart.methods.postpay.top" before="-"
6
+ template="postpay/checkout.phtml">
7
+ <action method="setShowOrPosition">
8
+ <value>after</value>
9
+ </action>
10
+ </block>
11
+ </reference>
12
+ <reference name="checkout.cart.methods">
13
+ <block type="postpay/checkout" name="checkout.cart.methods.postpay.bottom" before="-"
14
+ template="postpay/checkout.phtml">
15
+ <action method="setShowOrPosition">
16
+ <value>after</value>
17
+ </action>
18
+ </block>
19
+ </reference>
20
+ </checkout_cart_index>
21
+ </layout>
app/design/frontend/base/default/template/postpay/checkout.phtml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p class="postpay-button">
2
+ <?php $shortcutHtmlId = $this->getShortcutHtmlId()?>
3
+ <?php if ($this->isOrPositionBefore()): ?>
4
+ <span class="paypal-or"><?php echo $this->__('-OR-');?></span>
5
+ <?php endif; ?>
6
+ <a data-action="checkout-form-submit"
7
+ href="<?php echo $this->getCheckoutUrl()?>"> <img
8
+ src="<?php echo $this->getImageUrl()?>"
9
+ alt="<?php echo Mage::helper('postpay')->__('Checkout with Postpay');?>"
10
+ title="<?php echo Mage::helper('postpay')->__('Checkout with Postpay');?>" />
11
+ </a>
12
+ <?php if ($this->isOrPositionAfter()): ?>
13
+
14
+
15
+ <li>
16
+ <p class="postpay-logo">
17
+ <span class="postpay-or"><?php echo $this->__('-OR-');?></span>
18
+ </p>
19
+ </li>
20
+ <?php endif; ?>
app/design/frontend/base/default/template/postpay/checkout/image.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+
2
+ <img alt="Postpay"
3
+ src="<?php echo $this->getSkinUrl ( 'images/postpay/button.png' ) ?>">
app/design/frontend/base/default/template/postpay/payment/redirect.phtml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @see Dhl_Postpay_Block_Payment_Form_Standard
4
+ */
5
+ ?>
6
+ <ul class="form-list" id="payment_form_<?php echo $this->getMethodCode() ?>" style="display: none;">
7
+ <li class="form-alt"><?php echo $this->getRedirectMessage() ?></li>
8
+ </ul>
app/etc/modules/Dhl_MeinPaket.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dhl_MeinPaket>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Dhl_MeinPaketCommon />
9
+ </depends>
10
+ </Dhl_MeinPaket>
11
+ </modules>
12
+ </config>
app/etc/modules/Dhl_MeinPaketCommon.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dhl_MeinPaketCommon>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Shipping />
9
+ <Mage_Payment />
10
+ </depends>
11
+ <Mage_Shipping />
12
+ </Dhl_MeinPaketCommon>
13
+ </modules>
14
+ </config>
app/etc/modules/Dhl_Postpay.xml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dhl_Postpay>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Payment />
9
+ <Dhl_MeinPaketCommon />
10
+ </depends>
11
+ </Dhl_Postpay>
12
+ </modules>
13
+ </config>
app/locale/de_DE/Dhl_MeinPaket.csv ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Added %s new categories.","Es wurden %s neue Kategorien angelegt."
2
+ "Advanced (only Allyouneed)","Fortgeschritten (nur Allyouneed)"
3
+ "all","Alle"
4
+ "Allyouneed Active","Allyouneed aktivieren"
5
+ "Allyouneed Attribute","Allyouneed-Attribut"
6
+ "Axis","Achse"
7
+ "BestPrice Interval (only Allyouneed)","BestPrice Intervall (nur Allyouneed)"
8
+ "BestPrice refresh interval.","Intervall für BestPrice Aktualisierung."
9
+ "best prices","Beste Preise"
10
+ "Bust Measurement",Brustumfang
11
+ "Category","Kategorie"
12
+ "Color","Farbe"
13
+ "Connecting to Allyouneed server failed.","Die Verbindung zum Allyouneed-Server konnte nicht aufgebaut werden."
14
+ "Connection to Allyouneed server timed out.","Zeitüberschreitung beim Verbindungsaufbau zu Allyouneed-Server."
15
+ "Count of products transfered during a single cycle","Anzahl der Produkte, die in einem Durchlauf übertragen werden"
16
+ "Credentials","Zugangsdaten"
17
+ "Cup","Cup"
18
+ "Customer (nur Allyouneed)","Kunde (nur Allyouneed)"
19
+ "Cycle product count","Anzahl Produkte pro Durchlauf"
20
+ "Cylinder","Zylinder"
21
+ "Default customer email","Standard Kunden Email"
22
+ "Default delivery time","Standard-Lieferzeit"
23
+ "Default tax rate","Standard-Steuersatz"
24
+ "Deleted categories","Gelöschte Kategorien"
25
+ "Deleted %s categories.","Es wurden %s Kategorien gelöscht, die im Allyouneed-Marktplatz nicht mehr verfügbar sind."
26
+ "Delivery time attribute","Attribut für Lieferzeit"
27
+ "Delivery time in days if no other delivery time applies","Lieferzeit in Tagen, wenn keine andere Lieferzeit angegeben wird"
28
+ "Delivery time","Lieferzeit (in Tagen)"
29
+ "Diameter","Durchmesser"
30
+ "Dimension","Abmessung"
31
+ "Disable Postpay using Configuration / Payment Methods / Postpay Standard and Postpay Express.","Deaktivierung von Postpay unter Konfiguration / Bezahlmethoden / Postpay Standard und Postpay Express."
32
+ "edit product","Produkt bearbeiten"
33
+ "Error","Fehler"
34
+ "Flavor","Geschmacksrichtung"
35
+ "Format","Format"
36
+ "Import Categories","Allyouneed Kategorien importieren"
37
+ "import categories","Kategorien importieren"
38
+ "Inscription","Beschriftung"
39
+ "Internal error on Allyouneed server","Interner Fehler auf Allyouneed-Server",
40
+ "Invalid modification of element","Unerlaubte Modifikation des Elementes"
41
+ "Invalid response from Allyouneed server.","Ungültige Antwort von Allyouneed-Server erhalten."
42
+ "Invalid value for field","Ungültiger Wert für Feld"
43
+ "Length","Länge"
44
+ "Marketplace category structure was up to date. There have been no changes.","Markplatz-Kategoriestruktur ist auf dem neuesten Stand."
45
+ "Material","Material"
46
+ "Missing value for field","Fehlender Wert für Feld"
47
+ "Model","Modell"
48
+ "New categories","Neue Kategorien"
49
+ "Overview","Übersicht"
50
+ "Platform","Plattform"
51
+ "Please select the product attribute which represents the approx. delivery time","Bitte wählen Sie die Produkteigenschaft, welche die Lieferzeit angibt."
52
+ "please wait","Bitte warten...",
53
+ "Product attribute containing EAN","Produktattribut der EAN"
54
+ "Product attributes (only Allyouneed)","Produktattribute (nur Allyouneed)"
55
+ "Product attributes","Produkteigenschaften"
56
+ "Product export failed. Failed connecting to Allyouneed server.","Produktexport fehlgeschlagen: Konnte keine Verbindung zu Allyouneed aufgebaut werden."
57
+ "Product export failed for unknown reason.","Der Produktexport ist aus einem unbekannten Grund fehlgeschlagen."
58
+ "Product export interval","Intervall für Produktexport"
59
+ "Product Export (only Allyouneed)","Produkt Export (nur Allyouneed)"
60
+ "Product is unknown in Allyouneed marketplace","Produkt ist im Allyouneed Marktplatz nicht bekannt"
61
+ "Product stock is lower than zero.","Der Lagerbestand für dieses Produkt ist im negativen Bereich."
62
+ "Quantity","Anzahl"
63
+ "Radius","Radius"
64
+ "Reduced tax rate","Reduzierter Steuersatz"
65
+ "Renamed %s categories.","Es wurden %s Kategorien umbenannt."
66
+ "Result","Ergebnis"
67
+ "Size","Größe"
68
+ "%s of %s products were successfully exported","%s von %s Produkten wurden erfolgreich exportiert"
69
+ "start again","nochmal starten"
70
+ "Strength","Stärke"
71
+ "Successfully imported marketplace categories.","Die Marktplatz-Kategorien wurden erfolgreich mit Allyouneed abgeglichen."
72
+ "Tax rates (nur Allyouneed)","Steuersätze (nur Allyouneed)"
73
+ "Tax rates","Steuersätze"
74
+ "Textual introduction into category import goes here...","<b>Hier können Sie die Marktplatzkategorien von Allyouneed importieren.</b><p>Wenn Sie die Allyouneed-Marktplatzkategorien schon einmal importiert haben, werden diese nicht überschrieben, sondern nur mögliche Änderungen und Ergänzungen vorgenommen. Produkte, die Sie bereits Allyouneed-Marktplatzkategorien zugeordnet haben, bleiben weiterhin diesen Kategorien zugeordnet. Produkte, deren Kategorie gelöscht wurde, müssen vor einer erneuten Übertragung neu einer Kategorie zugewiesen werden.</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>"
75
+ "The default tax rate applies to most products","Dieser Steuersatz gilt für die meisten Produkte."
76
+ "The product is not mapped to neither a marketplace nor a shop category","Dieses Produkt ist weder einer Markplatzkategorie noch einer Shopkategorie zugewiesen"
77
+ "The provided data was incorrect","Allyouneed konnte die gegebenen Daten nicht akzeptieren"
78
+ "The reduced tax rate applies to special products, such as aliments","Der reduzierte Steuersatz, der für spezielle Produkte - etwa Nahrungsmittel - gilt."
79
+ "The referenced marketplace category could not be found at Allyouneed","Die angegebene Marktplatzkategorie kann auf Allyouneed nicht gefunden werden. Bitte importieren Sie die Marktplatzkategorien erneut, um auf dem aktuellen Stand zu arbeiten"
80
+ "The referenced product cannot be sold","Das Produkt kann nicht auf Allyouneed verkauft werden"
81
+ "The referenced shop category could not be found at Allyouneed","Die angegebene Shop-Kategorie konnte bei Allyouneed nicht gefunden werden"
82
+ "There were no products that could be exported.","Es konnten keine Produkte exportiert werden."
83
+ "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."
84
+ "total","gesamt"
85
+ "Unknown error","Es ist ein unbekannter Fehler aufgetreten"
86
+ "Use product special price if available","Verwende den Sonderpreis, wenn ein solcher vorhanden ist"
87
+ "Use special price if available","Verwende Sonderpreis, wenn vorhanden"
88
+ "Variant group does not exist on Allyouneed","Die verwendeten Produktattribute sind als Allyouneed-Variantenkonfiguration nicht bekannt."
89
+ "Width","Breite"
90
+ "You are not authorized to execute the requested functionality on Allyouneed","Sie sind nicht berechtigt diese Funktionalität der Allyouneed-Plattform zu nutzen"
app/locale/de_DE/Dhl_MeinPaketCommon.csv ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Credentials","Zugangsdaten"
2
+ "all","Alle"
3
+ "Username","Benutzername"
4
+ "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."
5
+ "Password","Passwort"
6
+ "This is the password that was given to you by DHL.","Dies ist das Passwort, das Ihnen von DHL mitgeteilt wurde."
7
+ "Remote system","Entferntes System"
8
+ "Invalid value for field","Ungültiger Wert für Feld"
9
+ "Missing value for field","Fehlender Wert für Feld"
10
+ "Product is unknown in Allyouneed marketplace","Produkt ist im Allyouneed Marktplatz nicht bekannt"
11
+ "Skipped %s duplicate orders that were already imported previously.","%s Bestellungen übersprungen, die bereits zu einem früheren Zeitpunkt importiert wurden."
12
+ "Skipped %s duplicate order that was already imported previously.","%s Bestellung übersprungen, die bereits zu einem früheren Zeitpunkt importiert wurde."
13
+ "%s order(s) sucessfully imported.","%s Bestellung(en) erfolgreich importiert."
14
+ "No new orders found.","Es wurden keine neuen Bestellungen gefunden."
15
+ "Skipped %s order(s) because: out of stock. Please process the following order(s) at your Allyouneed dealer area:","%s Bestellung(en) übersprungen, da nicht auf Lager. Bitte bearbeiten Sie die folgende(n) Bestellung(en) in Ihrem Allyouneed Händlerbereich:"
16
+ "Skipped %s order(s) because: some or all of the included products were disabled in Magento after the export to Allyouneed . Please process the following order(s) at your Allyouneed dealer area:","%s Bestellung(en) übersprungen, da sie Produkte enthielten, die nachträglich zum Export nach Allyouneed in Magento deaktiviert wurden. Bitte bearbeiten Sie die folgende(n) Bestellung(en) in Ihrem Allyouneed Händlerbereich:"
17
+ "%s was ordered with a different price (%s instead of current price %s). Was the price changed after exporting to Allyouneed?","%s wurde zu einem anderen Preis bestellt (%s statt aktuellem Preis %s). Wurde der Preis nachträglich nach dem Export zu Allyouneed geändert?"
18
+ "Internal error on Allyouneed server","Interner Fehler auf Allyouneed-Server",
19
+ "Product stock is lower than zero.","Der Lagerbestand für dieses Produkt ist im negativen Bereich."
20
+ "Unknown error","Es ist ein unbekannter Fehler aufgetreten"
21
+ "Error","Fehler"
22
+ "Connection to Allyouneed server timed out.","Zeitüberschreitung beim Verbindungsaufbau zu Allyouneed-Server."
23
+ "Imported from DHL Allyouneed","Importiert von Allyouneed"
24
+ "Allyouneed Order No.","Allyouneed Best.Nr."
25
+ "Request could not be built.","Die Anfrage konnte nicht generiert werden."
26
+ "Allyouneed server returned HTPP code %s.","Der Allyouneed-Server hat den HTTP-Fehlercode %s zurückgeliefert."
27
+ "Invalid response from Allyouneed server.","Ungültige Antwort von Allyouneed-Server erhalten."
28
+ "Error on tranfering cancelled items to Allyouneed.","Bei der Stornierung der Bestellpositionen bei Allyouneed ist ein Fehler aufgetreten."
29
+ "Allyouneed server returned error code %s.","Der Allyouneed-Server hat den Fehlercode %s zurückgegeben."
30
+ "Shipment has not been accepted by Allyouneed.","Die Lieferung wurde von Allyouneed nicht akzeptiert."
31
+ "Error on transfering shipment to Allyouneed.","Fehler beim Senden der Lieferinformationen zu Allyouneed."
32
+ "Refund has not been accepted by Allyouneed.","Die Gutschrift wurde nicht von Allyouneed akzeptiert."
33
+ "Error on transfering refund to Allyouneed.","Fehler beim Senden der Gutschrift an Allyouneed."
34
+ "Tracking code has not been accepted by Allyouneed.","Der gesendete Tracking-Code für diese Lieferung wurde von Allyouneed nicht akzeptiert."
35
+ "Allyouneed returned error code %s.","Allyouneed lieferte den Fehler-Code %s zurück."
36
+ "Error on transfering tracking code to Allyouneed.","Fehler beim Senden des Tracking-Codes am Allyouneed."
37
+ "The Allyouneed server did not deliver a valid response. Have a look at the system log for more information.","Der Allyouneed-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."
38
+ "You are not authorized to execute the requested functionality on Allyouneed","Sie sind nicht berechtigt diese Funktionalität der Allyouneed-Plattform zu nutzen"
39
+ "The provided data was incorrect","Allyouneed konnte die gegebenen Daten nicht akzeptieren"
40
+ "The product is not mapped to neither a marketplace nor a shop category","Dieses Produkt ist weder einer Markplatzkategorie noch einer Shopkategorie zugewiesen"
41
+ "The referenced product cannot be sold","Das Produkt kann nicht auf Allyouneed verkauft werden"
42
+ "The referenced marketplace category could not be found at Allyouneed","Die angegebene Marktplatzkategorie kann auf Allyouneed nicht gefunden werden. Bitte importieren Sie die Marktplatzkategorien erneut, um auf dem aktuellen Stand zu arbeiten"
43
+ "The referenced shop category could not be found at Allyouneed","Die angegebene Shop-Kategorie konnte bei Allyouneed nicht gefunden werden"
44
+ "Default Shipment Method","Standard Versandmethode"
45
+ "Shipment method which is used for order import and POSTPAY.","Versandmethode, die beim Import von Allyouneed-Bestellungen und für POSTPAY verwendet wird."
46
+ "Save Mapping","Mapping speichern"
47
+ "Missing value mapping for attribute","Fehlende Wertezuweisung für Attribut"
48
+ "Default customer email","Standard Kunden-E-Mail-Adresse"
49
+ "Customer","Kunde"
50
+ "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."
51
+ "Invalid modification of element","Unerlaubte Modifikation des Elementes"
52
+ "Variant group does not exist on Allyouneed","Die verwendeten Produktattribute sind als Allyouneed-Variantenkonfiguration nicht bekannt."
53
+ "Store View","Shop-Ansicht"
54
+ "Use HTTPs","Verwende HTTPs"
55
+ "Use https:// to connect to DHL Allyouneed","Verwende https:// um die Verbindung zu DHL Allyouneed herzustellen"
56
+ "Use Sandbox","Verwende Sandbox"
57
+ "Use DHL Allyouneed sandbox","Verwende DHL Allyouneed Sandbox"
58
+ "Shipment","Sendung"
59
+ "Async Request","Asynchrone Aufrufe"
60
+ "Order Import","Bestellimport"
61
+ "Cleanup Interval","Intervall für Aufräumfunktionen"
62
+ "Use Proxy","Verwende Proxy"
63
+
64
+
65
+
app/locale/de_DE/Dhl_Postpay.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ "all","Alle"
2
+ "Unknown error","Es ist ein unbekannter Fehler aufgetreten"
3
+ "You will be redirected to the Postpay website when you place an order.","Sie werden auf die Postpay Webseite weiter geleitet, wenn sie die Bestellung aufgeben."
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>DHL_Allyouneed</name>
4
+ <version>2.2.0</version>
5
+ <stability>stable</stability>
6
+ <license>--</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Allyouneed connector</summary>
10
+ <description>The Extension connects your Magento shop with DHL Allyouneed.</description>
11
+ <notes>--</notes>
12
+ <authors><author><name>DHL Vertriebs GmbH</name><user>ybmdeutschland</user><email>support@meinpaket.de</email></author></authors>
13
+ <date>2015-04-09</date>
14
+ <time>08:27:06</time>
15
+ <contents><target name="magecommunity"><dir><dir name="Dhl"><dir name="MeinPaket"><dir><dir name="Block"><dir name="Adminhtml"><dir name="Backlog"><dir name="Product"><file name="Grid.php" hash="7541700fffd1811943ce7d1d5f1ecdaf"/></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="3d5c316f511ca64dfa511f04ac4b4a14"/></dir></dir></dir><dir name="CategoryImport"><file name="Import.php" hash="47f0969b175e1480efe8a97480c169da"/><file name="Index.php" hash="745b3c71e101599fbba7a7fd275362c9"/></dir><file name="LeftMenu.php" hash="b60dea4f9e9a39b663cab89be8e32b97"/><dir name="OrderImport"><file name="Index.php" hash="b45724d6ff1fcda6102b3147f3a66a94"/></dir><dir name="ProductExport"><file name="Export.php" hash="e12ef6d9b52a9607820fbcd5e58e76ca"/><file name="Index.php" hash="65cf2306ad93f387f525ec66cec1abee"/><file name="List.php" hash="4a32ced740d35ebb7a10d0fffa782223"/></dir><file name="Steps.php" hash="ffb3f688b43cd0c1f457b89c84e68b7f"/><file name="Version.php" hash="476febd9f5d12ac999bdc7a6d646fe20"/></dir></dir><dir name="Helper"><file name="Attribute.php" hash="36cf44cf54204426e3f50864381a6443"/><file name="Backlog.php" hash="51c08b4ef137799d0e7dbf900543ab3e"/><file name="Cron.php" hash="b320de066adaec731a4ce5d77397a1e8"/><file name="Data.php" hash="f195ae885607cae202a100aef8091c09"/><file name="Order.php" hash="e3dca5761fa8e5e4171a9712b14b5c30"/><file name="Product.php" hash="3f51562e88a3919ff609e9d9d1376efc"/><file name="Shipment.php" hash="c8764cf370aded8e4d3c55e8c218a879"/></dir><dir name="Model"><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"/><file name="Category.php" hash="d0f5804e7900915f1c03364b079a7dc5"/><file name="Cron.php" hash="6f418837cc6e452eb8470864f6d4b396"/><dir name="Entity"><dir name="Attribute"><dir name="Frontend"><file name="LabelTranslation.php" hash="7f4b3b49b6e12dadd768aee95e041579"/></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="696e7dda6d0bd21eeceb61adc0121cd6"/><file name="Taxrate.php" hash="40bbb2336441fa02916ab992279961e8"/></dir></dir></dir><dir name="Exception"><file name="InvalidDataException.php" hash="dcbfbe06f3d0190d5f4a9f0b47973bf2"/><file name="MissingDataException.php" hash="377d6cc783aa6e8973728a77e1e5b8a9"/></dir><dir name="Mysql4"><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="06fd9a509c1ef252c0b75f6acda1b9eb"/></dir><file name="Category.php" hash="449c4f90fe5e797ca587025c63c745c3"/></dir><file name="Observer.php" hash="07e0c82cfa3d24feef9a1f3dd3599ada"/><dir name="Payment"><dir name="Method"><file name="Meinpaket.php" hash="dcb6ac810be4d0bb9e426464be91610d"/></dir></dir><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="26a300ab45c480c52d201cce79cf496f"/></dir></dir></dir><dir name="Service"><dir name="MarketplaceCategoryImport"><file name="ImportService.php" hash="bf0c889ce83b0afe084c20f97288370e"/><file name="Result.php" hash="cdebaf351ccd1c7aa285801701d32e7f"/></dir><dir name="Product"><dir name="Export"><dir name="Exception"><file name="InvalidEan.php" hash="bc88e3bc48a8a96e45079054290ae68c"/></dir></dir><file name="Export.php" hash="df1c3b905d299deb40b16d9452bcbf02"/></dir><dir name="ProductData"><file name="RequestService.php" hash="028b969756915acb87ab4daced2fd7ac"/></dir><dir name="Result"><file name="Abstract.php" hash="c7d84905431b651779dc1011f246983b"/><file name="Upload.php" hash="4ddf194a126ce18938610f61fcc1260d"/></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Attributes.php" hash="e6cd11540ebf6bc87f4d949d81285703"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Backlog"><file name="ProductController.php" hash="bb1f8850442ff1950549b21a2dcf74c5"/></dir><file name="BestPriceController.php" hash="a0eafd1b7ec08351bf3c02bbf66509c6"/><file name="CategoryImportController.php" hash="e614f4bad2b173e067611e4017c7b1a8"/><file name="MatchingController.php" hash="f568a8a7d331264944d1586aa567e6ee"/><file name="ProductExportController.php" hash="19bdeee189cb404f1a0ffdfe21c66087"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="94c3acad50c77221b674d93c63e50e26"/><file name="config.xml" hash="805e78cc1999a74caf3e72099bb47f6d"/><file name="system.xml" hash="381fa94cf8cef54db494eea83f26dff1"/></dir><dir name="sql"><dir name="meinpaket_setup"><file name="mysql4-install-1.0.0.php" hash="a0a752fa3ec4cf50f3ee230a3ace9dcf"/><file name="mysql4-upgrade-1.0.0-1.1.0.php" hash="bdb2ac11cd070e409c97aa3978c42f7e"/><file name="mysql4-upgrade-1.1.0-2.0.0.php" hash="1a9dc2612fbc6f22a3623f3c65906d14"/><file name="mysql4-upgrade-2.1.0-2.2.0.php" hash="bdb2ac11cd070e409c97aa3978c42f7e"/></dir></dir></dir></dir><dir name="Postpay"><dir><dir name="Block"><dir name="Adminhtml"><file name="Version.php" hash="887b1a63cd09847ba7ab3392bd4f9602"/></dir><file name="Checkout.php" hash="ec8b0f2764d863f03dec0167617510a6"/><dir name="Payment"><dir name="Form"><file name="Standard.php" hash="6aca4f231c317c45ac1556d39639d84f"/></dir><dir name="Info"><file name="Standard.php" hash="45252ddc1f9ebb332ef75efa5f868432"/></dir></dir></dir><dir name="Helper"><file name="Cron.php" hash="c2391d5d085c31f2650655e8acdbfb97"/><file name="Data.php" hash="418df17f5f760dc47bba8bb815d77c58"/></dir><dir name="Model"><file name="Cart.php" hash="e599a64fec791a587552a020b563b426"/><file name="Cron.php" hash="7f563b1e5fabd6534a72ad8239af341d"/><dir name="Mysql4"><dir name="Cart"><file name="Collection.php" hash="3b5150eb69a37a738e3f8494db0f4af1"/></dir><file name="Cart.php" hash="74042698f6fb9f2c7ca054d17f1ff0a2"/></dir><file name="Observer.php" hash="8a9eb2111c0a450e460f10e2b2a721eb"/><dir name="Payment"><dir name="Method"><file name="Express.php" hash="91259cee6e39f7c993a823edbaab4817"/><file name="Standard.php" hash="30d139303e4f80c1ed8c03397666c890"/></dir></dir><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="e75165ec2772e0174d8bdb62adcdd50b"/></dir></dir></dir><dir name="Service"><dir name="Order"><file name="ImportService.php" hash="60c7e7a116d65b2bb3a1e15f03860558"/></dir></dir></dir><dir name="controllers"><file name="CheckoutController.php" hash="7a0801e7c03be05beb8c38004dea1464"/><file name="NotificationController.php" hash="41a608eddf5b891ca0b26b1ef1323691"/><file name="ResponseController.php" hash="79cb81c28fe2460fac0be802a8b598b2"/></dir><dir name="etc"><file name="config.xml" hash="8c25198b05cac404eca2c2fe3e81d35b"/><file name="system.xml" hash="43de1564100406a0cfcf69096f89b41a"/></dir><dir name="sql"><dir name="postpay_setup"><file name="mysql4-install-1.0.0.php" hash="7a43beb424cf14e9054d884367e5fa84"/></dir></dir></dir></dir><dir name="MeinPaketCommon"><dir><dir name="Block"><dir name="Adminhtml"><dir name="Async"><file name="Grid.php" hash="dbf8ebeac3b98728c3cef8785c83c897"/></dir><file name="Async.php" hash="7169a4ea405f54ae1d6da4c56c302fcc"/><dir name="Log"><file name="Grid.php" hash="d371551816e9335e062424e648362ce5"/></dir><file name="Log.php" hash="36a68e5de0cf7dfb87e3b090c05c1e9c"/><file name="Version.php" hash="28defa5c89727f8c3a877affb55d0443"/></dir></dir><dir name="Helper"><file name="Address.php" hash="def05195630f6f98802481d228b4f25e"/><file name="Attribute.php" hash="905db640dbe49889e273aeb7415b2441"/><file name="Cron.php" hash="023eb7080558ebd43af77c1846a44534"/><file name="Data.php" hash="8edcee18eaca83942f5d30bfb65f7ff9"/><file name="Order.php" hash="736798b03eefd167e60854ad2e07792b"/><file name="Product.php" hash="ef60cadd260066b6109711a8e2522c9a"/><file name="Shipment.php" hash="4f62b24147d2998762ca74975e4cc379"/></dir><dir name="Model"><file name="Async.php" hash="3112120abd4ff2773dbcf19dedfd4044"/><dir name="Carrier"><file name="Allyouneed.php" hash="25eaf021d05a89e988c9370f25fd56cf"/><file name="Meinpaket.php" hash="b16814df68414d1fb6e795eadc4d6e83"/></dir><dir name="Client"><file name="BadHttpReturnCodeException.php" hash="3f3d67278be542e42bb882f387c04b67"/><file name="HttpException.php" hash="963bc4b8d30d2996a2a08b4c8aaa6b8f"/><file name="HttpTimeoutException.php" hash="d633742d26c8c5438543c1bbdf5c09bd"/><file name="XmlOverHttp.php" hash="8253371b36f2d8c18ca31b7b16bac10d"/></dir><file name="Cron.php" hash="35c06419c8aa9c6413f8304fda80c3ff"/><dir name="Entity"><dir name="Attribute"><dir name="Source"><file name="Carrier.php" hash="437c70fc9b4e8fa719bdd19676bbbacf"/></dir></dir></dir><dir name="Exception"><file name="InvalidDataException.php" hash="808caf989c24f1146d47fc610be6e131"/><file name="MissingDataException.php" hash="67a06069dcb66c02235f636b6790a62d"/></dir><file name="Log.php" hash="516fc34067f4573d160100d7a975a66c"/><dir name="Mysql4"><dir name="Async"><file name="Collection.php" hash="d5f6fbe4a4be75181844eddfbbd557cf"/></dir><file name="Async.php" hash="2120d8c0411c8773853cee4c5925467a"/><dir name="Log"><file name="Collection.php" hash="9bba87a636029d675e1ceda42f96dbc4"/></dir><file name="Log.php" hash="a09be611512f4dc95880e6e00dab93ca"/></dir><file name="Observer.php" hash="15812db421a573332a95f35e9acb9be9"/><dir name="Payment"><dir name="Method"><file name="Allyouneed.php" hash="663bf3c0f796e41a36eed0c277c0af42"/><file name="Meinpaket.php" hash="fdbc24e8330ecbb71243e1f4b5b83bc3"/></dir></dir><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="c6d8159ce42cb9826d2745a8b88145be"/></dir></dir></dir><dir name="Service"><file name="Abstract.php" hash="406fb92c370df8e93aaffacbad56937b"/><file name="Async.php" hash="5dba3892bc2b78846f2ca7593385a1bc"/><dir name="Order"><dir name="CancellationService"><file name="Result.php" hash="fd81666a5855ea6b25904e14d498ea20"/></dir><file name="CancellationService.php" hash="a6806a3531b596a729a418688ba51dcc"/><file name="ImportService.php" hash="270a81fdc451432d08974e2d11fbabc4"/><dir name="RefundExportService"><file name="Result.php" hash="dcfd1f479709368b446041674ee445d8"/></dir><file name="RefundExportService.php" hash="7ab8222a77e76517247f7f710d60b590"/><dir name="ShipmentExportService"><file name="Result.php" hash="0ba713e725c87d0bc82321582e3fe776"/></dir><file name="ShipmentExportService.php" hash="3045ed7ffb7f6a1f4c592e49832577f9"/></dir><dir name="Result"><file name="Abstract.php" hash="c7d84905431b651779dc1011f246983b"/><file name="Upload.php" hash="51438929f66a7efe3541511b6966ea09"/></dir></dir><dir name="System"><file name="MemoryLimiter.php" hash="813d89b8c21834fb911acc8e59be950c"/></dir><dir name="Validation"><file name="ValidationInterface.php" hash="d11950e6d4a7b52e3784867e8d8d2230"/><dir name="Validator"><file name="CDATAContent.php" hash="425678e9cf44efee9d884c20e4db1f14"/><file name="Ean.php" hash="7bab4c07ebcbdf3ce9e087ff20976d1a"/><file name="IntGreaterZero.php" hash="682c11f5cf24cafcef61350194a65be1"/><file name="NonEmptyString.php" hash="7075a72eace8e1f8c5bc5b61a5a25231"/><file name="StringMaxLength.php" hash="c19f729ff39b5b6b438635fe9bd9c6bf"/><file name="Url.php" hash="7b1f83a803fd8788ad4b22aaa982d04f"/></dir><file name="ValidatorChain.php" hash="72148d630805652276c446ebef817f47"/><file name="ValidatorInterface.php" hash="df41d71f7970d758b18bf36c2e49f6f1"/></dir><dir name="Xml"><file name="AbstractXmlPartial.php" hash="303a1e75e4ba719683f09ea9a5cc2743"/><file name="AbstractXmlRequest.php" hash="1b191b6c7e771043ce76f140f8a638b6"/><file name="InvalidXmlException.php" hash="22c021f43b7df35045814cd1ca714968"/><dir name="Request"><file name="AsynchronousStatusRequest.php" hash="4b17665dfef64f23d366f671a06634e3"/><file name="DataRequest.php" hash="af14f72b8c11013cfed42a0b1cbd22bc"/><file name="DownloadRequest.php" hash="05e941a0db71e679d5e3bce00bd5da8d"/><file name="NotificationRequest.php" hash="2902af863aaa33df93cc6e8cfdbf4b8c"/><file name="QueryRequest.php" hash="31746798830da6d1a5909e9f6761e5e1"/><file name="SubmitCartRequest.php" hash="bda8ba8a1662b59e49ddb974219cacf4"/><file name="UploadRequest.php" hash="93f15776fbc75435c417d7fc1963e4c4"/></dir><dir name="Response"><file name="Abstract.php" hash="f7e963bf5586d26347c4d1a6887a4b79"/><file name="AsynchronousStatusResponse.php" hash="6571d1b3093cd73e7eda7ff940df4453"/><file name="DataResponse.php" hash="672c55dd8e770219eac74214726cb5ef"/><file name="DownloadResponse.php" hash="831f43cece257d44fe65d02304362a8c"/><file name="NotificationResponse.php" hash="be7626da7ef2f744f183228110aabbea"/><dir name="Partial"><file name="Address.php" hash="d9ea71d56eb49fe3a512edd412293922"/><file name="Attribute.php" hash="4c27a169c0c773afde7502d6704ee372"/><file name="Category.php" hash="2b040bd3b89121ba28fef0ae07915915"/><file name="CategoryId.php" hash="09f6b3ecf29c4d3a16d37978efd53b4a"/><dir name="DataResponse"><file name="BestPrice.php" hash="e545a040a9201c3c8a71d4b410dcfc4d"/><file name="Confirmation.php" hash="b93b06d18277c10899535d91c1b71829"/><file name="MerchantData.php" hash="f03d2b35691c4356c43251e3c1c1fd20"/><file name="ProductData.php" hash="ab11140f6a0c4556a558d317651db82b"/><file name="QuotaData.php" hash="feb7180ff8c332decc938c1394ab8018"/></dir><dir name="NotificationResponse"><file name="Confirmation.php" hash="62225a96f3c9ce1047afc3f2c04b44ea"/><file name="Consignment.php" hash="20cb98f68cb94033d7abc5cb29ba47a4"/><file name="Credit.php" hash="7dfa1b551c938bbdbcab3e7f5ca4a86e"/><file name="Return.php" hash="d2538c678241727e3fe996d800da75b1"/></dir><dir name="Order"><file name="ContactData.php" hash="27cd1f6a5f8125352f3c383ab40e18af"/><file name="Entry.php" hash="f925387971c3a4e90bf3a66735f78025"/></dir><file name="Order.php" hash="470ed2a1671600318de784fedc34dbb9"/><file name="ProductId.php" hash="098e038cb611d92a65aa8a305567a2d0"/><file name="VariantConfiguration.php" hash="c3840d3e11cc2cc2c50d1f4f03bca963"/></dir><file name="QueryResponse.php" hash="300bfcfdb7f52380b207b45fede50e8e"/><file name="SubmitCartResponse.php" hash="82743d5832c4a12675796bbbde6f72e0"/><file name="UploadResponse.php" hash="36ac43b1e83c64be86307a6c1b7faf3d"/></dir><file name="XmlBuildException.php" hash="72ee8a17dab2c457bb821cd36bbff689"/><file name="XmlResponseParser.php" hash="94502547e6f7495e708652f72155c020"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="AsyncController.php" hash="480e99dbe107a07d88e60950e25479eb"/><file name="LogController.php" hash="b8a5edb6c275746515b553faa6472687"/><file name="OrderImportController.php" hash="aad84807f8e3c85f79609106b948c608"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="149473dc725145be4791a09d898b3115"/><file name="config.xml" hash="c49c7542ebb894d50e902e8d2b059c42"/><file name="system.xml" hash="f4301e5eb845c4f59c1438eb3467ae9a"/></dir><dir name="sql"><dir name="meinpaketcommon_setup"><file name="mysql4-install-1.0.0.php" hash="32c7c5120243756e17201fbd411f20ea"/><file name="mysql4-upgrade-1.0.0-1.1.0.php" hash="d2fbeb850994dc7fc5e15cb523372b6c"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="modules"><file name="Dhl_MeinPaket.xml" hash="b2ab0b71945c9849bbabe9cac0280beb"/><file name="Dhl_Postpay.xml" hash="26852f055604828ffca341f7437db998"/><file name="Dhl_MeinPaketCommon.xml" hash="b926a30bca6162be2a951f9fb0f62e00"/></dir></dir></target><target name="mage"><dir><dir name="shell"><file name="dhlmeinpaket-category-import.php" hash="b7c47a9b557e7fae4c5309ed95628ab6"/><file name="dhlmeinpaket-product-export.php" hash="9cfb888cdec7047a488fd68e84f5c495"/><file name="dhlmeinpaket-request-bestprice.php" hash="8bbcdd8eb442861f7e94d44b8db99226"/><file name="dhlmeinpaket-order-import.php" hash="7ff812c3c5dbb27d88554946c7e1edab"/></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"/><file name="postpay.xml" hash="890708f41152cb5326040006a0d13bf1"/><file name="meinpaketcommon.xml" hash="3854556688b7e27a8e7eda0cdf2b6610"/></dir><dir name="template"><dir name="postpay"><dir><dir name="checkout"><file name="image.phtml" hash="9283259a1e502907c0ba1c659f4ffe1b"/></dir><dir name="payment"><file name="redirect.phtml" hash="4d6e571020670c2069a2323b54f707ea"/></dir></dir><file name="checkout.phtml" hash="424e3ad9ab6f20dba21412ed9de315e6"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="meinpaket.xml" hash="973b9b6f616f8da3528ab68cc379819c"/><file name="postpay.xml" hash="5bef4c0511b6e60ed9abf1503849809e"/><file name="meinpaketcommon.xml" hash="4563e3cf8fc469dcecf1c8ff88e26cf7"/></dir><dir name="template"><dir name="meinpaket"><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="d749033dde8fe39bc006d9ac2c458ef1"/><file name="index.phtml" hash="cd832201909c7cbfb76f165fe29c0f03"/></dir></dir></dir><file name="leftmenu.phtml" hash="4afb8d200ed8ceddf2f682c5911c565c"/><file name="steps.phtml" hash="70a343086b4559dc0e77173d9a799e39"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir><dir><dir name="de_DE"><file name="Dhl_MeinPaket.csv" hash="b50d2271da07991f17833bdac53ee71e"/><file name="Dhl_Postpay.csv" hash="5c803ebc2d02c6272b6b7b05951faba6"/><file name="Dhl_MeinPaketCommon.csv" hash="c7b3ed7c2c3d6b24a9bd66925658a439"/></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="0b896fdfbd23d33a029f9c3e60757f1c"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="meinpaketcommon"><dir name="images"><file name="1.png" hash="3c2c9a82eb1ba846ba83fff02a7fb89d"/><file name="2.png" hash="ebbbb39b16a74905e9089014dadf27bb"/><file name="3.png" hash="4db863bc8404ba77b12b318d7932ca3d"/><file name="ayn_ger_tuete_produkte_aussen.jpg" hash="18acc68e20f2bc7e9417bb04cb64e2c5"/><file name="dhl_logo_kl.gif" hash="43fdd8c3b923355fdd27070feca49dc7"/><file name="loader.gif" hash="823d2e0f3345c88e9463a38a9c360817"/><file name="shadowtopbg.png" hash="9e274a269dcbe50256d1be49a192a9cd"/></dir><file name="module.css" hash="d477570fa7a981d64d2fdc79af098999"/><file name="module.js" hash="60aec009320033b3c786784934d5cdb2"/></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,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'abstract.php';
3
+
4
+ /**
5
+ * Imports the category structure from Allyouneed.
6
+ *
7
+ * @category Dhl
8
+ * @package Dhl_MeinPaket
9
+ * @subpackage Dhl_MeinPaket_Shell
10
+ * @version $Id$
11
+ */
12
+ class Dhl_MeinPaket_Shell_CategoryImport extends Mage_Shell_Abstract {
13
+ /**
14
+ * Imports the marketplace category structure from DHL Allyouneed.
15
+ *
16
+ * @return Dhl_MeinPaket_Shell_CategoryImport
17
+ */
18
+ public function run() {
19
+ /* @var $result Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result */
20
+ $result = null;
21
+
22
+ echo "Starting Category Import (" . $this->getFormattedDate () . ")\n";
23
+
24
+ try {
25
+ /* @var $service Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_ImportService */
26
+ $service = Mage::getModel ( 'meinpaket/Service_MarketplaceCategoryImport_ImportService' );
27
+
28
+ $result = $service->importMarketplaceCategoryStructure ();
29
+ } catch ( Exception $e ) {
30
+ echo 'Category Import failed. Exception occured: ' . $e->getMessage ();
31
+ Mage::logException ( $e );
32
+ return $this;
33
+ }
34
+
35
+ echo "Finished Category Import (" . $this->getFormattedDate () . ")\n";
36
+
37
+ echo "Number of new categories: " . $result->getNewCategoriesCount() . "\n";
38
+ echo "Number of updated categories: " . $result->getUpdatedCategoriesCount() . "\n";
39
+ echo "Number of deleted categories: " . $result->getDeletedCategoriesCount() . "\n";
40
+
41
+ return $this;
42
+ }
43
+
44
+ /**
45
+ * Retrieve Usage Help Message
46
+ */
47
+ public function usageHelp() {
48
+ return <<<USAGE
49
+ Usage: php -f dhlmeinpaket-order-import.php -- [options]
50
+
51
+ help This help
52
+ \n
53
+ USAGE;
54
+ }
55
+
56
+ /**
57
+ * Returns the current timestamp as a formatted string.
58
+ *
59
+ * @return string
60
+ */
61
+ protected function getFormattedDate() {
62
+ return strftime ( "%Y-%m-%d %H:%M:%S" );
63
+ }
64
+ }
65
+
66
+ $categoryImporter = new Dhl_MeinPaket_Shell_CategoryImport ();
67
+ $categoryImporter->run ();
shell/dhlmeinpaket-order-import.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'abstract.php';
3
+
4
+ /**
5
+ * Imports the category structure from Allyouneed.
6
+ *
7
+ * @category Dhl
8
+ * @package Dhl_MeinPaket
9
+ * @subpackage Dhl_MeinPaket_Shell
10
+ * @version $Id$
11
+ */
12
+ class Dhl_MeinPaketCommon_Shell_OrderImport extends Mage_Shell_Abstract {
13
+ /**
14
+ *
15
+ * @var integer
16
+ */
17
+ const DEFAULT_HOURS = 24;
18
+
19
+ /**
20
+ * Imports orders from DHL Allyouneed.
21
+ *
22
+ * @return Dhl_MeinPaket_Shell_OrderImport
23
+ */
24
+ public function run() {
25
+ echo "Starting order import (" . $this->getFormattedDate () . ")\n";
26
+
27
+ /* @var $service Dhl_MeinPaket_Model_Service_Order_ImportService */
28
+ $service = Mage::getModel ( "meinpaketcommon/service_order_importService" );
29
+ $hours = self::DEFAULT_HOURS;
30
+ $startTime = 0;
31
+ $endTime = 0;
32
+
33
+ if ($this->getArg ( 'hours' )) {
34
+ $passedHours = ( integer ) $this->getArg ( 'hours' );
35
+ if ($passedHours < 1) {
36
+ echo 'Number of given hours (' . $passedHours . ') is to small. Process cancelled.';
37
+ return $this;
38
+ }
39
+ $hours = $passedHours;
40
+ }
41
+
42
+ $endTime = time ();
43
+ $startTime = $endTime - ($hours * 3600);
44
+
45
+ echo "Time range: " . $this->getFormattedDate ( $startTime ) . " GMT - " . $this->getFormattedDate ( $endTime ) . " GMT\n";
46
+
47
+ try {
48
+ $service->importOrders ( $startTime, $endTime );
49
+ } catch ( Exception $e ) {
50
+ Mage::logException ( $e );
51
+ echo 'Order import failed. Exception occured: ' . $e->getMessage ();
52
+ }
53
+
54
+ echo "Import finished (" . $this->getFormattedDate () . ")\n";
55
+ echo "Imported " . $service->getOrderCount ()['imported'] . " orders.\n";
56
+
57
+ return $this;
58
+ }
59
+
60
+ /**
61
+ * Retrieve Usage Help Message
62
+ */
63
+ public function usageHelp() {
64
+ return <<<USAGE
65
+ Usage: php -f dhlmeinpaket-order-import.php -- [options]
66
+
67
+ --hours The time in hours for which to import orders.
68
+ The default setting is 24, which means that the orders of the
69
+ last 24 hours will be imported.
70
+ help This help
71
+ \n
72
+ USAGE;
73
+ }
74
+
75
+ /**
76
+ * Returns the current timestamp as a formatted string.
77
+ *
78
+ * @return string
79
+ */
80
+ protected function getFormattedDate($timestamp = null) {
81
+ $format = "%Y-%m-%d %H:%M:%S";
82
+ $date = '';
83
+
84
+ if ($timestamp !== null) {
85
+ $date = strftime ( $format, $timestamp );
86
+ } else {
87
+ $date = strftime ( $format );
88
+ }
89
+
90
+ return $date;
91
+ }
92
+ }
93
+
94
+ $orderImporter = new Dhl_MeinPaketCommon_Shell_OrderImport ();
95
+ $orderImporter->run ();
shell/dhlmeinpaket-product-export.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'abstract.php';
3
+
4
+ /**
5
+ * Exports products to Allyouneed.
6
+ *
7
+ * @category Dhl
8
+ * @package Dhl_MeinPaket
9
+ * @subpackage Dhl_MeinPaket_Shell
10
+ * @version $Id$
11
+ */
12
+ class Dhl_MeinPaket_Shell_ProductExport extends Mage_Shell_Abstract {
13
+ /**
14
+ * Exports products DHL Allyouneed.
15
+ *
16
+ * @return Dhl_MeinPaket_Shell_ProductExport
17
+ */
18
+ public function run() {
19
+ echo " > Starting Export (" . $this->getFormattedDate () . ")\n";
20
+
21
+ /* @var $exportService Dhl_MeinPaket_Model_Service_Product_Export */
22
+ $exportService = Mage::getModel ( 'meinpaket/service_product_export' );
23
+
24
+ $result = null;
25
+
26
+ $commonErrors = null;
27
+
28
+ // export products
29
+ try {
30
+ $result = $exportService->exportProducts ();
31
+ } catch ( Exception $e ) {
32
+ Mage::logException ( $e );
33
+ echo 'Products could not be exported: ' . $e->getMessage ();
34
+ return $this;
35
+ }
36
+
37
+ //$this->showResults ( $result );
38
+
39
+ return $this;
40
+ }
41
+
42
+ /**
43
+ * Retrieve Usage Help Message
44
+ */
45
+ public function usageHelp() {
46
+ return <<<USAGE
47
+ Usage: php -f dhlmeinpaket-product-export.php -- [options]
48
+
49
+ all Exports all products. No matter if they have their synchronize with DHL MeinPaket flag enabled.
50
+ help This help
51
+ \n
52
+ USAGE;
53
+ }
54
+
55
+ /**
56
+ * Echoes information about the result of the product export process.
57
+ *
58
+ * @param Dhl_MeinPaket_Model_Service_Product_Export_Result $result
59
+ * @return void
60
+ */
61
+ protected function showResults(Dhl_MeinPaket_Model_Service_Product_Export_Result $result) {
62
+ $commonErrors = $result->getCommonErrors ();
63
+ $fullyConfirmedIds = $result->getFullyConfirmedProductIds ();
64
+ $offeredOnly = $result->getProductsWhichCouldOnlyBeOffered ();
65
+ $totallyFailed = $result->getProductsWhichCouldNotBeOfferedOrDescribed ();
66
+
67
+ echo " > Finished Export (" . $this->getFormattedDate () . ")\n";
68
+ echo "----------------------------------------------------------\n";
69
+ echo "| RESULT OVERVIEW: |\n";
70
+ echo "----------------------------------------------------------\n";
71
+ echo " > Successfully exported: " . sizeof ( $fullyConfirmedIds ) . "\n";
72
+ echo " > Offered only: " . sizeof ( $offeredOnly ) . "\n";
73
+ echo " > Not exportable: " . sizeof ( $totallyFailed ) . "\n";
74
+ }
75
+
76
+ /**
77
+ * Returns the current timestamp as a formatted string.
78
+ *
79
+ * @return string
80
+ */
81
+ protected function getFormattedDate() {
82
+ return strftime ( "%Y-%m-%d %H:%M:%S" );
83
+ }
84
+ }
85
+
86
+ $productExporter = new Dhl_MeinPaket_Shell_ProductExport ();
87
+ $productExporter->run ();
88
+
shell/dhlmeinpaket-request-bestprice.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'abstract.php';
3
+
4
+ /**
5
+ * Imports the variant configurations from Allyouneed.
6
+ *
7
+ * @category Dhl
8
+ * @package Dhl_MeinPaket
9
+ * @subpackage Dhl_MeinPaket_Shell
10
+ * @version $Id$
11
+ */
12
+ class Dhl_MeinPaket_Shell_RequestBestPrice extends Mage_Shell_Abstract {
13
+ /**
14
+ * Imports the variant configurations from DHL Allyouneed.
15
+ *
16
+ * @return Dhl_MeinPaket_Shell_VariantConfigurationsDownload
17
+ */
18
+ public function run() {
19
+ /* @var $service Dhl_MeinPaket_Model_Service_ProductData_RequestService */
20
+ $service = Mage::getModel ( 'meinpaket/service_productData_requestService' );
21
+
22
+ /* @var $result Dhl_MeinPaket_Model_Service_MarketplaceCategoryImport_Result */
23
+ $result = null;
24
+
25
+ echo "Requesting \n";
26
+
27
+ try {
28
+ $result = $service->requestBestPrices ();
29
+ } catch ( Exception $e ) {
30
+ echo 'Request failed. Exception occured: "' . $e->getMessage () . '"' . "\n";
31
+ Mage::logException ( $e );
32
+ return $this;
33
+ }
34
+
35
+ return $this;
36
+ }
37
+
38
+ /**
39
+ * Retrieve Usage Help Message
40
+ */
41
+ public function usageHelp() {
42
+ return <<<USAGE
43
+ Usage: php -f dhlmeinpaket-request-bestprice.php -- [options]
44
+
45
+ help This help
46
+ \n
47
+ USAGE;
48
+ }
49
+ }
50
+
51
+ $shll = new Dhl_MeinPaket_Shell_RequestBestPrice ();
52
+ $shll->run ();
53
+
skin/adminhtml/default/default/meinpaketcommon/images/1.png ADDED
Binary file
skin/adminhtml/default/default/meinpaketcommon/images/2.png ADDED
Binary file
skin/adminhtml/default/default/meinpaketcommon/images/3.png ADDED
Binary file
skin/adminhtml/default/default/meinpaketcommon/images/ayn_ger_tuete_produkte_aussen.jpg ADDED
Binary file
skin/adminhtml/default/default/meinpaketcommon/images/dhl_logo_kl.gif ADDED
Binary file
skin/adminhtml/default/default/meinpaketcommon/images/loader.gif ADDED
Binary file
skin/adminhtml/default/default/meinpaketcommon/images/shadowtopbg.png ADDED
Binary file
skin/adminhtml/default/default/meinpaketcommon/module.css ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @CHARSET "UTF-8";
2
+
3
+ h3.allyouneed {}
4
+ div#allyouneed-description { background: url('images/ayn_ger_tuete_produkte_aussen.jpg') no-repeat 20px 5px; padding: 5px 150px 20px 240px; min-height: 150px; position:relative; }
5
+ div#allyouneed-description p {text-align: justify;}
6
+ div#allyouneed-description b {color: #515151;}
7
+ div#allyouneed-description i {color: #646B70;}
8
+ div.allyouneed-content {padding: 10px; background: url('images/shadowtopbg.png') repeat-x #E5E5E5; border: 1px solid #FFCC00}
9
+
10
+ div.allyouneed-content form label {margin-right: 10px; }
11
+
12
+ #disabled-till-export {}
13
+
14
+ #allyouneed_form {
15
+ position: absolute;
16
+ right: 30px;
17
+ bottom: 10px;
18
+ }
19
+
20
+ ul.allyouneed-steps {margin: 10px 0 0 20px; clear: both}
21
+ li.nr1 {background: url('images/1.png') no-repeat 0px 0px }
22
+ li.nr2 {background: url('images/2.png') no-repeat 0px 0px }
23
+ li.nr3 {background: url('images/3.png') no-repeat 0px 0px }
24
+ ul.allyouneed-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;}
25
+ ul.allyouneed-steps li p {margin: 4px 0 4px 80px; font-weight: bold}
26
+ ul.allyouneed-steps li.active { background-color: #FFCC00; border-style: solid; border-color: #ddbb00;}
27
+
28
+ div.scrollablebox {height: 300px; overflow: auto; /*border: 1px solid #eee; padding: 5px;*/}
29
+
30
+ #allyouneed-results {padding-left:20px;}
31
+ th.col-product {min-width: 200px}
32
+ table#allyouneed-results td.row-subheader { background-color: #FFCC00; color: #2F2F2F; font-weight: bold; }
33
+ table#allyouneed-results td.row-subheader span.resultCount { color: #646B70; font-size: 80%; }
34
+ table#allyouneed-results td.row-num { width: 1px; text-align: right !important; }
35
+ table#allyouneed-results th.header-center { text-align: center !important; }
36
+ .cc {clear: both}
37
+
38
+ .allyouneed-waitbox { float: none; display: block; clear: both; padding: 10px; text-align: center; }
39
+ .allyouneed-waitbox small { position: relative; top: -8px; }
40
+
41
+ .columns #edit_form .form-list td.value { width: auto; }
42
+ #edit_form .form-list td.value select { width: 280px; }
43
+
44
+ .section-config.allyouneed > :first-child {
45
+ background-color: #fc0 !important;
46
+ }
47
+
48
+ .section-config.allyouneed > :first-child > a {
49
+ color: #D40511 !important;
50
+ }
51
+
52
+ .section-config.allyouneed:first-child {
53
+ padding-top: 170px;
54
+ background:url('http://portal.allyouneed.com/fileadmin/media/magento_admin.jpg') no-repeat;
55
+ }
skin/adminhtml/default/default/meinpaketcommon/module.js ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function startProcessing() {
2
+ var form = $('allyouneed_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
+ $('allyouneed-description').hide();
15
+ form.submit();
16
+ form.disable();
17
+ //form.hide();
18
+ }
19
+
20
+ function setLocationWithWait(gotourl) {
21
+ setLocation(gotourl);
22
+ $('disabled-till-export').show();
23
+ }
24
+
25
+ function submitForm(actionUrl) {
26
+ var form = $('allyouneed_form');
27
+ form.writeAttribute('action', actionUrl);
28
+ form.submit();
29
+
30
+ }
31
+
32
+ function showResponse(req) {
33
+ alert(req.responseText);
34
+ }
skin/frontend/default/default/meinpaket/images/dhl_checkout_button.png ADDED
Binary file