I got this file:
module-sales/Block/Adminhtml/Order/Create/Shipping/Method/Form.php
I want to override this in a custom module.
How can I do that? Thanks!
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityFor Block use the below code in your module's 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\Block\Adminhtml\Order\Create\Shipping\Method\Form" type="[VendorName]\[ModuleName]\Block\Adminhtml\Order\Create\Shipping\Method\Form"/>
</config>
For phtml override create a xml file with name sales_order_create_load_block_shipping_method.xml on your module's layout folder and set template for this "order.create.shipping.method.form" and use your template file location as per the requirement.
Try this.
app/code/Namespace/ModuleName/etc/
<?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="Magenticians_Modulecontact" setup_version="1.0.1">
</module>
</config>
app/code/Namespace/ModuleName/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Magenticians_Modulecontact',
__DIR__
);
app/code/Namespace/ModuleName/etc/di.xml file
<?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\Block\Adminhtml\Order\Create\Shipping\Method\Form" type="[Namespace]\[ModuleName]\Block\Adminhtml\Order\Create\Shipping\Method\Form" />
</config>
Run : php bin/magento setup:upgrade
Run : php bin/magento c:c