I want to rewrite the block: Magento\Sales\Block\Adminhtml\Order\Create\Form\Address
Here is my code: 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="Freedom\Adminorder\Block\Adminhtml\Order\Create\Form\Address" />
</config>
Address.php
<?php
namespace Freedom\Adminorder\Block\Adminhtml\Order\Create\Form;
use Magento\Framework\Pricing\PriceCurrencyInterface;
class Address extends \Magento\Sales\Block\Adminhtml\Order\Create\Shipping\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()
{
if ($this->getCustomerId()) {
// $filter = $this->filterBuilder
// ->setField('parent_id')
// ->setValue($this->getCustomerId())
// ->setConditionType('eq')
// ->create();
$filter = $this->filterBuilder
->setField('entity_id')
->setValue([1,5])
->setConditionType('in')
->create();
$this->searchCriteriaBuilder->addFilters([$filter]);
$searchCriteria = $this->searchCriteriaBuilder->create();
$result = $this->addressService->getList($searchCriteria);
return $result->getItems();
}
return [];
}
}
It is not working. Cananyone help me?