In Order.php i am trying to override getShippingMethod and getShippingDescription method but it is not loading the page and in logs
Order.php
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Vendor\Module\Model;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Framework\App\ObjectManager;
class Order extends \Magento\Sales\Model\Order
{
private $_objectManager;
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\App\ObjectManager $objectManager
) {
$this->_objectManager = $objectManager;
parent::__construct(
$context
);
}
public function getShippingDescription()
{
$helper_factory = $this->_objectManager->get('Vendor\PickupAtStore\Helper\Data');
ObjectManager::getInstance()->get(ResolverInterface::class)
if($this->getShippingMethod() == "pickupatstore_pickupatstore_1"){
//return $this->getData(OrderInterface::SHIPPING_DESCRIPTION);
return "Shop – collect from 11am on your preferred day.(".$helper_factory->formatDatetime($order->getPickupDatetime()).")";
}
else
{
return $this->getData(OrderInterface::SHIPPING_DESCRIPTION);
}
}
public function getShippingMethod($asObject = false)
{
$shippingMethod = parent::getShippingMethod();
if (!$asObject) {
return $shippingMethod;
} else {
list($carrierCode, $method) = explode('_', $shippingMethod, 2);
return new \Magento\Framework\DataObject(['carrier_code' => $carrierCode, 'method' => $method]);
}
}
/**
* @return string
*/
//@codeCoverageIgnoreEnd
}
di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Sales\Model\Order" type="Vendor\Module\Model\Order" />
</config>