diff --git a/Controllers/Backend/viaebConfigForm.php b/Controllers/Backend/viaebConfigForm.php index ae81e73..b263211 100644 --- a/Controllers/Backend/viaebConfigForm.php +++ b/Controllers/Backend/viaebConfigForm.php @@ -46,6 +46,9 @@ public function saveConnectionConfigAction() { $this->configWriter->save('userPassword', $_REQUEST['userPassword'], $this->pluginName); $this->configWriter->save('mainSystem', intval($_REQUEST['mainSystem']), $this->pluginName); $this->configWriter->save('ordernumberMapping', intval($_REQUEST['ordernumberMapping']), $this->pluginName); + + $this->configWriter->save('minOrderDate', str_replace(" ", "T", $_REQUEST['minOrderDate'], $this->pluginName)); + $this->configWriter->save('baseCategory', intval($_REQUEST['baseCategory']), $this->pluginName); $this->configWriter->save('ExportAllArticles', intval($_REQUEST['ExportAllArticles']), $this->pluginName); $this->configWriter->save('targetShop', intval($_REQUEST['targetShop']), $this->pluginName); diff --git a/Resources/config.xml b/Resources/config.xml index a6c08a4..fd0687e 100755 --- a/Resources/config.xml +++ b/Resources/config.xml @@ -101,9 +101,23 @@ Spacer3 + + 1 + + + + minOrderDate + + + Nur Bestellungen neuer als das festgelegte Datum exportieren + + + + Spacer4 1 + targetShop diff --git a/Resources/views/backend/viaeb_config_form/view/config_window.js b/Resources/views/backend/viaeb_config_form/view/config_window.js index d8c8606..1a6cc5e 100644 --- a/Resources/views/backend/viaeb_config_form/view/config_window.js +++ b/Resources/views/backend/viaeb_config_form/view/config_window.js @@ -27,6 +27,7 @@ Ext.define('Shopware.apps.viaebConfigForm.view.ConfigWindow', { ordernumberMapping: '{s namespace="backend/viaebConfigForm" name=ordernumberMapping}Bestellnummer Mapping{/s}', baseCategory: '{s namespace="backend/viaebConfigForm" name=baseCategory}Stammkategorie{/s}', ExportAllArticles: '{s namespace="backend/viaebConfigForm" name=ExportAllArticles}Alle Artikel exportieren{/s}', + MinOrderDate: '{s namespace="backend/viaebConfigForm" name=MinOrderdate}Bestellungen exportieren ab{/s}', targetShop: '{s namespace="backend/viaebConfigForm" name=targetShop}Zielshop für Bestellungen{/s}', shipping: '{s namespace="backend/viaebConfigForm" name=shipping}Versandart{/s}', customerGroup: '{s namespace="backend/viaebConfigForm" name=customerGroup}Kundengruppe{/s}', @@ -129,6 +130,11 @@ Ext.define('Shopware.apps.viaebConfigForm.view.ConfigWindow', { resetFieldValues: function (item) { const me = this; + if(me.configValues['minOrderDate'] && me.configValues['minOrderDate'].includes('T')) { + var myDate = Ext.Date.parse(me.configValues['minOrderDate'].substring(0,10), 'Y-m-d'); + me.configValues['minOrderDate'] = Ext.Date.format(myDate, 'd.m.Y'); + } + if (item.name in me.configValues) { item.setValue(me.configValues[item.name]); } @@ -369,6 +375,15 @@ Ext.define('Shopware.apps.viaebConfigForm.view.ConfigWindow', { forceSelection: false, allowBlank: true, }, + { + xtype: 'datefield', + fieldLabel: me.snippets.MinOrderDate, + //dateFormat:'Y-m-dTH:i:s', + submitFormat:'Y-m-d 00:00:00', + format: 'd.m.Y', + name: 'minOrderDate', + allowBlank: true, + }, { fieldLabel: me.snippets.ExportAllArticles, store: me.createYesNoStore(), diff --git a/Services/Helper/ShopwareOrderHelper.php b/Services/Helper/ShopwareOrderHelper.php index 8dc90f1..07863ea 100644 --- a/Services/Helper/ShopwareOrderHelper.php +++ b/Services/Helper/ShopwareOrderHelper.php @@ -3,6 +3,7 @@ namespace viaebShopwareAfterbuy\Services\Helper; use Doctrine\ORM\OptimisticLockException; +use Shopware\Models\Attribute\Order as OrderAttributes; use viaebShopwareAfterbuy\ValueObjects\Address as ValueAddress; use viaebShopwareAfterbuy\ValueObjects\Order as ValueOrder; use viaebShopwareAfterbuy\ValueObjects\OrderPosition; @@ -336,14 +337,26 @@ public function setAfterBuyIds(array $values) /** * @return array */ - public function getUnexportedOrders() + public function getUnexportedOrders(array $config) { - $orders = $this->entityManager->createQueryBuilder() + $query = $this->entityManager->createQueryBuilder(); + + $query ->select(['orders']) ->from(ShopwareOrder::class, 'orders', 'orders.id') ->leftJoin('orders.attribute', 'attributes') ->where('attributes.afterbuyOrderId IS NULL') ->orWhere("attributes.afterbuyOrderId = ''") + ->andWhere('orders.number != 0'); + + if(!empty($config["minOrderDate"])) { + $minOrderDate = new \DateTime($config["minOrderDate"]); + + $query->andWhere('orders.orderTime > :minOrderDate') + ->setParameters(array('minOrderDate' => $minOrderDate)); + } + + $orders = $query ->getQuery() ->setMaxResults(200) ->getResult(); @@ -394,7 +407,8 @@ public function getUnfullfilledOrders() { $orders = $this->entityManager->createQueryBuilder() ->select(['attributes.afterbuyOrderId']) - ->from(\Shopware\Models\Attribute\Order::class, 'attributes') + ->from(OrderAttributes::class, + 'attributes') ->leftJoin('attributes.order', 'orders') ->where('attributes.afterbuyOrderId IS NOT NULL') ->andWhere("attributes.afterbuyOrderId != ''") diff --git a/Services/ReadData/Internal/ReadOrdersService.php b/Services/ReadData/Internal/ReadOrdersService.php index d94c935..7d5e4d9 100644 --- a/Services/ReadData/Internal/ReadOrdersService.php +++ b/Services/ReadData/Internal/ReadOrdersService.php @@ -167,7 +167,7 @@ public function read(array $filter) { /** * @var Repository $repo */ - $data = $this->helper->getUnexportedOrders(); + $data = $this->helper->getUnexportedOrders($this->config); if(!$data) { $this->logger->error('No data received', array('Orders', 'Read', 'Internal')); diff --git a/plugin.xml b/plugin.xml index 8651730..99fe695 100755 --- a/plugin.xml +++ b/plugin.xml @@ -9,6 +9,24 @@ https://www.via-connect.de/ ViA-Online GmbH + + + +
  • New: added min order date for export
  • +
  • fixed: submission of unfinished orders
  • + + ]]> +
    + + +
  • New: added min order date for export
  • +
  • fixed: submission of unfinished orders
  • + + ]]>
    +
    +