Skip to content

Magento overrule Magento/Sales/Model/Order/ShipmentFactory.php

I trie to overrule Magento/Sales/Model/Order/ShipmentFactory.php and i have code below, but i get error:

main.CRITICAL: ReflectionException: Class "JilcoShipmentbugModelOrderShipmentFactory" does not exist in /home/jilco/public_html/vendor/magento/framework/Code/Reader/ClassReader.php:34

registration.php

<?php
use MagentoFrameworkComponentComponentRegistrar;

ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Jilco_Shipmentbug', __DIR__);

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="MagentoSalesModelOrderShipmentFactory" type="JilcoShipmentbugModelOrderShipmentFactory" />
</config>

Module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Jilco_Shipmentbug" />
</config>

ShipmentFactory.php

<?php
namespace MagentoSalesModelOrder;

use MagentoFrameworkExceptionLocalizedException;
use MagentoFrameworkSerializeSerializerJson;

/**
* Factory class for @see MagentoSalesApiDataShipmentInterface
*
* @api
* @since 100.0.2
*/
class ShipmentFactory
{
/**
 * Order converter.
 *
 * @var MagentoSalesModelConvertOrder
 */
protected $converter;

/**
 * Shipment track factory.
 *
 * @var MagentoSalesModelOrderShipmentTrackFactory
 */
protected $trackFactory;