From 7a55eea7342a4227ac7e2d35f4402a86eac76666 Mon Sep 17 00:00:00 2001 From: Returnless Date: Tue, 2 Mar 2021 21:59:26 +0200 Subject: [PATCH] Set v1.0.7. Added php74 to composer. Added current module version to Configs in Admin. Added installed_module_version --- Controller/Order/Info.php | 4 ++ Model/Api/OrderInfo.php | 17 +++++++- Model/Config/ModuleVersion.php | 75 ++++++++++++++++++++++++++++++++++ composer.json | 4 +- etc/adminhtml/system.xml | 4 ++ etc/module.xml | 2 +- 6 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 Model/Config/ModuleVersion.php diff --git a/Controller/Order/Info.php b/Controller/Order/Info.php index 7281859..e697ec5 100644 --- a/Controller/Order/Info.php +++ b/Controller/Order/Info.php @@ -153,6 +153,10 @@ protected function returnResponse($result = null) { header("Content-Type: application/json; charset=utf-8"); + if (isset($result['installed_module_version']) && !empty($result['installed_module_version'])) { + $this->response['installed_module_version'] = $result['installed_module_version']; + } + if (isset($result['result']) && !empty($result['result'])) { $this->response['result'] = $result['result']; } diff --git a/Model/Api/OrderInfo.php b/Model/Api/OrderInfo.php index a244ce2..ccdfdb6 100644 --- a/Model/Api/OrderInfo.php +++ b/Model/Api/OrderInfo.php @@ -2,6 +2,7 @@ namespace Returnless\Connector\Model\Api; +use Magento\Framework\Module\ResourceInterface; use Returnless\Connector\Api\OrderInfoInterface; use Magento\Sales\Model\OrderRepository; use Magento\Catalog\Model\ProductRepository; @@ -23,6 +24,16 @@ class OrderInfo implements OrderInfoInterface */ const PRODUCT_TYPE_BUNDLE = 'bundle'; + /** + * const NAMESPACE_MODULE + */ + const NAMESPACE_MODULE = 'Returnless_Connector'; + + /** + * @var ResourceInterface + */ + protected $moduleResource; + /** * @var bool */ @@ -68,6 +79,7 @@ class OrderInfo implements OrderInfoInterface * @param LoggerInterface $logger * @param Image $image * @param Config $config + * @param ResourceInterface $moduleResource */ public function __construct( OrderRepository $orderRepository, @@ -75,7 +87,8 @@ public function __construct( SearchCriteriaBuilder $searchCriteriaBuilder, LoggerInterface $logger, Image $image, - Config $config + Config $config, + ResourceInterface $moduleResource ) { $this->orderRepository = $orderRepository; $this->productRepository = $productRepository; @@ -83,6 +96,7 @@ public function __construct( $this->logger = $logger; $this->image = $image; $this->config = $config; + $this->moduleResource = $moduleResource; } /** @@ -92,6 +106,7 @@ public function getOrderInfoReturnless($incrementId) { $response['return_code'] = 112; $response['return_message'] = ''; + $response['installed_module_version'] = $this->moduleResource->getDbVersion(self::NAMESPACE_MODULE); $orderInfo = []; $this->logger->debug('[RET_ORDER_INFO] Increment Id', [$incrementId]); diff --git a/Model/Config/ModuleVersion.php b/Model/Config/ModuleVersion.php new file mode 100644 index 0000000..ba80be4 --- /dev/null +++ b/Model/Config/ModuleVersion.php @@ -0,0 +1,75 @@ +moduleResource = $moduleResource; + parent::__construct( + $context, + $registry, + $config, + $cacheTypeList, + $resource, + $resourceCollection, + $data + ); + } + + /** + * Inject current installed module version as the config value. + * + * @return void + */ + public function afterLoad() + { + $moduleVersion = $this->moduleResource->getDbVersion(self::NAMESPACE_MODULE); + + $this->setValue($moduleVersion); + } +} diff --git a/composer.json b/composer.json index dcd3f12..8a931a6 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Returnless Connector", "type": "magento2-module", "require": { - "php": "~7.0.0|7.0.2|7.0.4|~7.0.6|~7.1.0|~7.2.0|~7.3.0" + "php": "~7.0.0|7.0.2|7.0.4|~7.0.6|~7.1.0|~7.2.0|~7.3.0|~7.4.0" }, "autoload": { "files": [ @@ -17,5 +17,5 @@ "OSL-3.0", "AFL-3.0" ], - "version": "1.0.6" + "version": "1.0.7" } diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 7784f56..ee91ece 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -11,6 +11,10 @@ Returnless_Connector::returnless_connector_config + + + Returnless\Connector\Model\Config\ModuleVersion + Magento\Config\Model\Config\Source\Yesno diff --git a/etc/module.xml b/etc/module.xml index 2156670..39f29d5 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - +