2017-02-14 45 views
0

我得到以下运行设置错误:迪:编译我的Magento 2.错误:迪:编译 - 不兼容的参数类型

不兼容的参数类型:必需类型:\ Magento的\目录\型号\ ProductTypes \ ConfigInterface。实际类型:数组;

不兼容参数类型:必需类型:\ Magento \ Wishlist \ Model \ WishlistFactory。实际类型:数组;

代码负责的错误如下

public function __construct(
    \Magento\Backend\Block\Template\Context $context, 
    \Magento\Backend\Model\Session\Quote $sessionQuote, 
    \Magento\Sales\Model\AdminOrder\Create $orderCreate, 
    PriceCurrencyInterface $priceCurrency, 
    \Magento\Wishlist\Model\WishlistFactory $wishlistFactory, 
    \Magento\GiftMessage\Model\Save $giftMessageSave, 
    \Magento\Tax\Model\Config $taxConfig, 
    \Magento\Tax\Helper\Data $taxData, 
    \Magento\GiftMessage\Helper\Message $messageHelper, 
    StockRegistryInterface $stockRegistry, 
    StockStateInterface $stockState, 
    array $data = [] 
) { 
    $this->_messageHelper = $messageHelper; 
    $this->_wishlistFactory = $wishlistFactory; 
    $this->_giftMessageSave = $giftMessageSave; 
    $this->_taxConfig = $taxConfig; 
    $this->_taxData = $taxData; 
    $this->stockRegistry = $stockRegistry; 
    $this->stockState = $stockState; 
    parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $data); 
} 

而且

public function __construct(
    \Magento\Backend\Block\Context $context, 
    \Magento\Catalog\Model\ProductTypes\ConfigInterface $typeConfig, 
    array $data = [] 
) { 
    parent::__construct($context, $data); 
    $this->typeConfig = $typeConfig; 
} 

在我的布局,我打电话这样

 <block class="MyVendor\MyModule\Block\Adminhtml\Quote\Create\Items" template="Magento_Sales::order/create/items.phtml" name="items"> 
     <block class="Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid" template="Magento_Sales::quote/create/items/grid.phtml" name="items_grid"> 
      <block class="Magento\Sales\Block\Adminhtml\Order\Create\Coupons" template="Magento_Sales::order/create/form.phtml" name="coupons"> 
       <block class="Magento\Sales\Block\Adminhtml\Order\Create\Coupons\Form" template="Magento_Sales::order/create/coupons/form.phtml" name="form" /> 
      </block> 
     </block> 
    </block> 

在此先感谢

+0

错误消息说明了自己:您键入提示某个类型/合同,但是当您调用方法/构造函数时,您提供了一个数组作为参数。 您应该发布调用代码以提供一些上下文。 – jojonas

+0

@jojonas更新问题 – sree

回答

0

也许是个愚蠢的问题,但是在执行命令之前是否清除了magento缓存?

我在更新__construct时也有问题,但在清除缓存时已修复。

+0

是的,我清除缓存并重新索引 – sree

0

保持这样

public function __construct(
    \Magento\Catalog\Model\ProductTypes\ConfigInterface $typeConfig 
) { 
    $this->typeConfig = $typeConfig; 
} 

现在你的构造函数,编译和检查

0

你需要将所有参数传递给它的父类的构造是这样的:

public function __construct(
    \Magento\Backend\Block\Template\Context $context, 
    \Magento\Backend\Model\Session\Quote $sessionQuote, 
    \Magento\Sales\Model\AdminOrder\Create $orderCreate, 
    PriceCurrencyInterface $priceCurrency, 
    \Magento\Wishlist\Model\WishlistFactory $wishlistFactory, 
    \Magento\GiftMessage\Model\Save $giftMessageSave, 
    \Magento\Tax\Model\Config $taxConfig, 
    \Magento\Tax\Helper\Data $taxData, 
    \Magento\GiftMessage\Helper\Message $messageHelper, 
    StockRegistryInterface $stockRegistry, 
    StockStateInterface $stockState, 
    array $data = [] 
) { 
    $this->_messageHelper = $messageHelper; 
    $this->_wishlistFactory = $wishlistFactory; 
    $this->_giftMessageSave = $giftMessageSave; 
    $this->_taxConfig = $taxConfig; 
    $this->_taxData = $taxData; 
    $this->stockRegistry = $stockRegistry; 
    $this->stockState = $stockState; 
    //Pass All Arguments To Parent 
    parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $wishlistFactory, $giftMessageSave, $taxConfig, $taxData, $messageHelper, $stockRegistry, $stockState, $data); 
} 

让我知道,如果你仍然有错误。