I am trying to override block file of adminhtml of sales module.
Below is the code of my 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\Form\Address" type="Vendor\Module\Block\Adminhtml\Order\Create\Form\Address" /> </config> I have used the Address.php file from this path
Magento\Sales\Block\Adminhtml\Order\Create\Form
and moved into my module , but the block file is not overrided,
here is the code of my block file
<?php namespace Vendor\Module\Block\Adminhtml\Order\Create\Form; use Magento\Backend\Model\Session\Quote; use Magento\Framework\App\ObjectManager; use Magento\Framework\Data\Form\Element\AbstractElement; use Magento\Framework\Pricing\PriceCurrencyInterface; use Psr\Log\LoggerInterface; class Address extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\Address { public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, PriceCurrencyInterface $priceCurrency, \Magento\Framework\Data\FormFactory $formFactory, \Magento\Framework\Reflection\DataObjectProcessor $dataObjectProcessor, \Magento\Directory\Helper\Data $directoryHelper, \Magento\Framework\Json\EncoderInterface $jsonEncoder, \Magento\Customer\Model\Metadata\FormFactory $customerFormFactory, \Magento\Customer\Model\Options $options, \Magento\Customer\Helper\Address $addressHelper, \Magento\Customer\Api\AddressRepositoryInterface $addressService, \Magento\Framework\Api\SearchCriteriaBuilder $criteriaBuilder, \Magento\Framework\Api\FilterBuilder $filterBuilder, \Magento\Customer\Model\Address\Mapper $addressMapper, array $data = [] ) { parent::__construct( $context, $sessionQuote, $orderCreate, $priceCurrency, $formFactory, $dataObjectProcessor, $directoryHelper, $jsonEncoder, $customerFormFactory, $options, $addressHelper, $addressService, $criteriaBuilder, $filterBuilder, $addressMapper, $data ); } public function getAddressCollection() { //echo $this->getCustomerId();exit; if ($this->getCustomerId()) { $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $customerObj = $objectManager->create('Magento\Customer\Model\Customer')->load($this->getCustomerId()); $customerMasterId = $customerObj->getMasterId(); $filter = $this->filterBuilder ->setField('parent_id') ->setValue($customerMasterId) ->setConditionType('eq') ->create(); $this->searchCriteriaBuilder->addFilters([$filter]); $searchCriteria = $this->searchCriteriaBuilder->create(); $result = $this->addressService->getList($searchCriteria); return $result->getItems(); } return []; } } Anywhere i am wrong? Its not overriding into my module. Please anybody help me. Thanks