Skip to content

Commit d1d90aa

Browse files
Sebastian80mam08ixo
authored andcommitted
DHLGW-1163: add configuration setting
1 parent 258affb commit d1d90aa

File tree

8 files changed

+105
-12
lines changed

8 files changed

+105
-12
lines changed

Model/Config/ModuleConfig.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/**
4+
* See LICENSE.md for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Netresearch\InteractiveBatchProcessing\Model\Config;
10+
11+
use Magento\Framework\App\Config\ScopeConfigInterface;
12+
use Magento\Store\Model\ScopeInterface;
13+
14+
class ModuleConfig
15+
{
16+
// phpcs:disable Generic.Files.LineLength.TooLong
17+
public const CONFIG_PATH_INTERACTIVE_MASSACTION_ENABLED = 'shipping/batch_processing/shipping_label/interactive_massaction_enabled';
18+
19+
/**
20+
* @var ScopeConfigInterface
21+
*/
22+
private $scopeConfig;
23+
24+
public function __construct(ScopeConfigInterface $scopeConfig)
25+
{
26+
$this->scopeConfig = $scopeConfig;
27+
}
28+
29+
public function isInteractiveMassActionEnabled($store = null): bool
30+
{
31+
return $this->scopeConfig->isSetFlag(
32+
self::CONFIG_PATH_INTERACTIVE_MASSACTION_ENABLED,
33+
ScopeInterface::SCOPE_STORE,
34+
$store
35+
);
36+
}
37+
}

Ui/Component/MassAction/InteractiveBatchProcessing.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\UrlInterface;
1212
use Magento\Framework\View\Element\UiComponent\ContextInterface;
1313
use Magento\Ui\Component\Action;
14+
use Netresearch\InteractiveBatchProcessing\Model\Config\ModuleConfig;
1415

1516
class InteractiveBatchProcessing extends Action
1617
{
@@ -19,14 +20,21 @@ class InteractiveBatchProcessing extends Action
1920
*/
2021
private $urlBuilder;
2122

23+
/**
24+
* @var ModuleConfig
25+
*/
26+
private $moduleConfig;
27+
2228
public function __construct(
2329
ContextInterface $context,
2430
UrlInterface $urlBuilder,
31+
ModuleConfig $moduleConfig,
2532
array $components = [],
2633
array $data = [],
2734
$actions = null
2835
) {
2936
$this->urlBuilder = $urlBuilder;
37+
$this->moduleConfig = $moduleConfig;
3038

3139
parent::__construct($context, $components, $data, $actions);
3240
}
@@ -35,9 +43,7 @@ public function prepare()
3543
{
3644
parent::prepare();
3745

38-
//todo(nr): add configuration setting whether or not to enable interactive mass action
39-
$isInteractiveModeEnabled = true;
40-
if ($isInteractiveModeEnabled) {
46+
if ($this->moduleConfig->isInteractiveMassActionEnabled()) {
4147
$config = $this->getConfiguration();
4248
foreach ($config['actions'] as &$action) {
4349
if ($action['type'] === 'nrshipping_batch_create_shipments') {

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
"php": "^7.1.3",
2525
"magento/framework": "^102.0.0 || ^103.0.0",
2626
"magento/module-backend": "^101.0.0 || ^102.0.0",
27+
"magento/module-config": "^101.1.0",
2728
"magento/module-sales": "^102.0.0 || ^103.0.0",
29+
"magento/module-store": "^101.0.0",
2830
"magento/module-ui": "^101.1.0",
2931
"netresearch/module-shipping-core": "^2.5.0"
3032
},

etc/adminhtml/system.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" ?>
2+
<!--
3+
/**
4+
* See LICENSE.md for license details.
5+
*/
6+
-->
7+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
8+
<system>
9+
<section id="shipping">
10+
<group id="batch_processing">
11+
<group id="shipping_label">
12+
<field id="interactive_massaction_enabled" showInDefault="1" showInWebsite="0" showInStore="0" sortOrder="5"
13+
translate="label button_label comment" type="Netresearch\ConfigFields\Model\Type\Checkbox">
14+
<label>Enable Interactive Mass Action</label>
15+
<button_label>Edit essential shipping settings before batch processing selected orders.</button_label>
16+
<comment>If you want to select packaging or shipping product per order, then it is recommended to enable interactive mass action and to disable fully automated cron processing.</comment>
17+
</field>
18+
</group>
19+
</group>
20+
</section>
21+
</system>
22+
</config>

etc/config.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
3+
<default>
4+
<shipping>
5+
<batch_processing>
6+
<shipping_label>
7+
<interactive_massaction_enabled>0</interactive_massaction_enabled>
8+
</shipping_label>
9+
</batch_processing>
10+
</shipping>
11+
</default>
12+
</config>

etc/module.xml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
*/
66
-->
77
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
8-
<module name="Netresearch_InteractiveBatchProcessing">
9-
<sequence>
10-
<module name="Magento_Backend"/>
11-
<module name="Magento_Framework"/>
12-
<module name="Magento_Sales"/>
13-
<module name="Magento_Ui"/>
14-
<module name="Netresearch_ShippingCore"/>
15-
</sequence>
16-
</module>
8+
<module name="Netresearch_InteractiveBatchProcessing">
9+
<sequence>
10+
<module name="Magento_Backend"/>
11+
<module name="Magento_Config"/>
12+
<module name="Magento_Framework"/>
13+
<module name="Magento_Sales"/>
14+
<module name="Magento_Store"/>
15+
<module name="Magento_Ui"/>
16+
<module name="Netresearch_ShippingCore"/>
17+
</sequence>
18+
</module>
1719
</config>

i18n/de_DE.csv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"Bulk Shipment",Massenversand
2+
"Destination Address",Zieladresse
3+
"Edit essential shipping settings before batch processing selected orders.","Bearbeiten Sie wesentliche Parameter vor dem Ausführen der Massenaktion."
4+
"Enable Interactive Mass Action","Interaktive Massenaktion aktivieren"
5+
"If you want to select packaging or shipping product per order, then it is recommended to enable interactive mass action and to disable fully automated cron processing.","Falls Sie beim Versand Paketgröße oder Versandprodukt je Bestellung festlegen wollen, dann wird empfohlen, die interaktive Massenverarbeitung zu aktivieren und das vollautomatische Erzeugen von Versandetiketten via Cron zu deaktivieren."
6+
"Items to Ship","Zu versendende Artikel"

i18n/en_US.csv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"Bulk Shipment","Bulk Shipment"
2+
"Destination Address","Destination Address"
3+
"Edit essential shipping settings before batch processing selected orders.","Edit essential shipping settings before batch processing selected orders."
4+
"Enable Interactive Mass Action","Enable Interactive Mass Action"
5+
"If you want to select packaging or shipping product per order, then it is recommended to enable interactive mass action and to disable fully automated cron processing.","If you want to select packaging or shipping product per order, then it is recommended to enable interactive mass action and to disable fully automated cron processing."
6+
"Items to Ship","Items to Ship"

0 commit comments

Comments
 (0)