Skip to content

Commit

Permalink
Merge pull request #12 from SysteembeheerEdg/feature/SEDG-413
Browse files Browse the repository at this point in the history
Magento 2.4.6 compatible
  • Loading branch information
Luuk-Meijer authored Nov 8, 2023
2 parents 4050031 + 0673d84 commit 00607eb
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 59 deletions.
2 changes: 0 additions & 2 deletions Cron/API/AbstractCron.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ public function sendErrorMail(string $email, string $subject, string $content):
* @param int $priority
* @param array $params
* @return void
* @throws Exception
*/
protected function serviceLog($stream, $message, int $priority = Logger::INFO, array $params = [])
{
Expand All @@ -271,7 +270,6 @@ protected function serviceLog($stream, $message, int $priority = Logger::INFO, a
/**
* @param $path
* @return Logger
* @throws Exception
*/
protected function addLogStreamToServiceLogger($path): Logger
{
Expand Down
7 changes: 1 addition & 6 deletions Cron/API/ArticleInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ class ArticleInfo extends AbstractCron
*/
protected TierPriceManagement $tierpriceManagement;

/**
* @var TransportBuilder
*/
protected TransportBuilder $transportBuilder;

/**
* @var Job
*/
Expand Down Expand Up @@ -190,7 +185,7 @@ protected function processProduct(\Edg\ErpService\DataModel\ArticleInfo $article
$prefix = $this->helper->getSkuPrefix();

// Truncate prefix
$sku = substr($productdata['sku'], strlen($prefix));
$sku = substr($productdata['sku'], strlen((string)$prefix));

try {
$product = $this->productRepository->get($sku, true);
Expand Down
5 changes: 0 additions & 5 deletions Cron/API/ArticleInfoUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@

class ArticleInfoUpdate extends ArticleInfo
{
/**
* @var TransportBuilder
*/
protected TransportBuilder $transportBuilder;

/**
* @param Data $helper
* @param DirectoryList $directoryList
Expand Down
12 changes: 3 additions & 9 deletions Cron/API/OrderExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ class OrderExport extends AbstractCron
*/
protected OrderToDataModel $orderConverter;

/**
* @var TransportBuilder
*/
protected TransportBuilder $transportBuilder;

/**
* @var OrderRepositoryInterface
*/
Expand Down Expand Up @@ -104,24 +99,23 @@ public function execute()
{
// TODO: Implement execute() method.
if ($this->settings['force_order_upload'] === true) {
$this->prepareExport(true);
$this->prepareExport();
return;
}
if ($this->helper->isUploadOrdersEnabled()) {
$this->prepareExport(false);
$this->prepareExport();
} else {
$this->moduleLog(__METHOD__ . '(); - isUploadOrdersEnabled setting disabled, skipping.', true);
}
}

/**
* @param bool $force
* @return $this
* @throws LocalizedException
* @throws NoSuchEntityException
* @throws Exception
*/
protected function prepareExport(bool $force = false): OrderExport
protected function prepareExport(): OrderExport
{
$date = date("Y_m_d");
$stream = $this->addLogStreamToServiceLogger($this->_exportDir . DIRECTORY_SEPARATOR . "log_{$date}.log");
Expand Down
13 changes: 1 addition & 12 deletions Cron/API/OrderStatusImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ class OrderStatusImport extends AbstractCron
*/
protected ShipmentSender $shipmentMailer;

/**
* @var Monolog
*/
protected Monolog $monolog;

/**
* @var TransportBuilder
*/
protected TransportBuilder $transportBuilder;

/**
* @var TrackFactory
*/
Expand All @@ -74,6 +64,7 @@ class OrderStatusImport extends AbstractCron
* @param ShipmentFactory $shipmentFactory
* @param Transaction $transaction
* @param ShipmentSender $sender
* @param TrackFactory $trackFactory
* @param array $settings
* @throws FileSystemException
*/
Expand Down Expand Up @@ -279,8 +270,6 @@ protected function getItemsToShip(

$itemsToShip = [];

$skuPrefix = $this->helper->getSkuPrefix();

foreach ($magentoOrder->getAllItems() as $item) {
$itemSku = $item->getSku();

Expand Down
5 changes: 0 additions & 5 deletions Cron/API/StockMutations.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
class StockMutations extends AbstractCron
{

/**
* @var TransportBuilder
*/
protected TransportBuilder $transportBuilder;

/**
* @var StockRegistryInterface
*/
Expand Down
8 changes: 3 additions & 5 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,11 @@ public function getFullSkusArray()
public function log($msg, $debug = false)
{
if ($debug) {
if ($this->scopeConfig->isSetFlag(self::XML_CONFIG_PATH_SETTING_DEBUG_ENABLED,
ScopeInterface::SCOPE_STORE)
) {
$this->moduleLog->addDebug($msg);
if ($this->scopeConfig->isSetFlag(self::XML_CONFIG_PATH_SETTING_DEBUG_ENABLED, ScopeInterface::SCOPE_STORE)) {
$this->moduleLog->debug($msg);
}
} else {
$this->moduleLog->addInfo($msg);
$this->moduleLog->info($msg);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Model/Convert/OrderToDataModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ protected function processStatusComments(Order $order, &$data): OrderToDataModel
}
}

if (strlen($comment) > 0) {
if (strlen((string)$comment) > 0) {
$_buffer[] = $_historyItem->getData('comment');
}
}
Expand Down
10 changes: 8 additions & 2 deletions Observer/Frontend/PreventDuplicateSkuInCheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Edg\Erp\Observer\Frontend;


use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Store\Model\ScopeInterface;

Expand Down Expand Up @@ -31,7 +32,12 @@ public function __construct(
$this->actionFlag = $actionFlag;
}

public function execute(\Magento\Framework\Event\Observer $observer)
/**
* @param Observer $observer
* @return false|void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function execute(Observer $observer)
{
if (!$this->scopeConfig->isSetFlag('bold_orderexim/settings/block_duplicate_sku',
ScopeInterface::SCOPE_STORE)
Expand Down Expand Up @@ -60,4 +66,4 @@ public function execute(\Magento\Framework\Event\Observer $observer)
}
}
}
}
}
16 changes: 10 additions & 6 deletions Plugin/Block/Admin/Shipping/Tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,26 @@

class Tracking
{
/**
* @param \Magento\Shipping\Block\Adminhtml\Order\Tracking $subject
* @param $result
* @return array|mixed
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterGetCarriers(
\Magento\Shipping\Block\Adminhtml\Order\Tracking $subject,
$result
)
{
if(!is_array($result)){
if (!is_array($result)) {
return $result;
}

foreach($result as $code=>$label){
if($code == 'PostNL'){
return $result;
}
if (array_key_exists('PostNL', $result)) {
return $result;
}

$result['PostNL'] = __('PostNL');
return $result;
}
}
}
10 changes: 7 additions & 3 deletions Plugin/Helper/Shipping/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@

namespace Edg\Erp\Plugin\Helper\Shipping;

use Magento\Framework\Exception\LocalizedException;

class Data
{
protected $helper;

public function __construct(
\Edg\Erp\Helper\Tracktrace $helper
)
{
$this->helper = $helper;
$this->helper = $helper;
}

/**
* @param \Magento\Shipping\Helper\Data $subject
* @param \Closure $proceed
* @param $model
* @return mixed|string
* @throws LocalizedException
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundGetTrackingPopupUrlBySalesModel(
\Magento\Shipping\Helper\Data $subject,
Expand All @@ -32,4 +36,4 @@ public function aroundGetTrackingPopupUrlBySalesModel(

return $proceed($model);
}
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Delete the Bold_PIM and Bold_PIMService from the app/code directory
- Run ```rm -rf app/code/Bold/PIMService``` from the root of the project

Install the latest versions of the Edg_Erp and Edg_ErpService modules by adding the modules and the corresponding repositories to the composer.json file
- ```“edg/module-erp-koppeling": “0.3.0”```
- ```“edg/module-erp-service": “0.1.1```
- ```“edg/module-erp-koppeling": “0.4.0”```
- ```“edg/module-erp-service": “0.1.2```
- ```
"edg-erp": {
"type": "git",
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"require": {
"php": "~8.1.0",
"edg/module-erp-service": "*",
"magento/magento2-base": "^2.1.9"
"magento/magento2-base": "^2.1.9",
"monolog/monolog": "^2.0|^3.0"
},
"type": "magento2-module",
"license": [
Expand Down

0 comments on commit 00607eb

Please sign in to comment.