2017-02-14 54 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); 
} 

讓我知道,如果你仍然有錯誤。