-1

Old Code:

<?php
/**
 * Copyright © All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Module\Coord\Cron;
class GenerateShipping
{
 protected \Psr\Log\LoggerInterface $logger;
 /**
 * @var \Module\Coord\Model\ShipmentGeneration
 */
 private \Module\Coord\Model\ShipmentGeneration $shipment;
 /**
 * Constructor
 *
 * @param \Psr\Log\LoggerInterface $logger
 * @param \Module\Coord\Model\ShipmentGeneration $shipmentGeneration
 */
 public function __construct(
 \Psr\Log\LoggerInterface $logger,
 \Module\Coord\Model\ShipmentGeneration $shipmentGeneration
 ) {
 $this->logger = $logger;
 $this->shipment = $shipmentGeneration;
 }
 /**
 * Execute the cron
 *
 * @return void
 * @throws \Exception
 */
 public function execute()
 {
 $this->logger->info("Cronjob GenerateShipping is executed.");
 $this->shipment->ordersToShip();
 }
}
asked Nov 13, 2024 at 17:18

1 Answer 1

0

Update Code

<?php
/**
 * Copyright © 2024
 * All rights reserved.
 * See COPYING.txt for license details.
 * Check module
 * Magento 2.4.7-p3
 */
declare(strict_types=1);
namespace Module\Coord\Cron;
use Exception;
use Psr\Log\LoggerInterface;
use Module\Coord\Model\ShipmentGeneration;
/**
 * This class GenerateShipping
 *
 * @class GenerateShipping
 * @since 11/13/2024
 * @version 1.0.0
 */
class GenerateShipping
{
 /**
 * Constructor
 *
 * @param LoggerInterface $logger
 * @param ShipmentGeneration $shipment
 */
 public function __construct(
 protected LoggerInterface $logger,
 private readonly ShipmentGeneration $shipment
 ) {
 }
 /**
 * Execute the cron
 *
 * @return void
 * @throws Exception
 */
 public function execute(): void
 {
 $this->shipment->ordersToShip();
 $this->logger->info("Cronjob GenerateShipping is executed.");
 }
}
answered Nov 13, 2024 at 17:18

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.