2016-11-18 8 views
0

現在Magento 2で商品をウィッシュリストに追加した後、ウィッシュリストページに移動します。私はそれを製品の詳細ページに戻そうとしています。そのため私は、Magentoの\ウィッシュリスト\コントローラ\インデックスを上書きしようと\ディ好みMagento 2ウィッシュリストに追加する商品の詳細ページに戻る

<preference for="Magento\Wishlist\Controller\Index\Add" 
      type="Eguana\CustomWishlist\Controller\Rewrite\Index\Add" /> 

を追加して、それを私のコントローラは、この

namespace Eguana\CustomWishlist\Controller\Rewrite\Index; 

use Magento\Catalog\Api\ProductRepositoryInterface; 
use Magento\Framework\App\Action; 
use Magento\Framework\Data\Form\FormKey\Validator; 
use Magento\Framework\Exception\NotFoundException; 
use Magento\Framework\Exception\NoSuchEntityException; 
use Magento\Framework\Controller\ResultFactory; 

/** 
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) 
*/ 
class Add extends \Magento\Wishlist\Controller\Index\Add 
{ 


    public function __construct(Action\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProvider, ProductRepositoryInterface $productRepository, Validator $formKeyValidator) 
    { 
     parent::__construct($context, $customerSession, $wishlistProvider, $productRepository, $formKeyValidator); 
    } 

    /** 
    * Adding new item 
    * 
    * @return \Magento\Framework\Controller\Result\Redirect 
    * @throws NotFoundException 
    * @SuppressWarnings(PHPMD.CyclomaticComplexity) 
    * @SuppressWarnings(PHPMD.NPathComplexity) 
    * @SuppressWarnings(PHPMD.UnusedLocalVariable) 
    */ 
    public function execute() 
    { 
     echo 'abc'; 
    } 
} 
のようなものです

私のmodule.xmlファイルはこれと似ています

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> 
    <module name="Eguana_CustomWishlist" setup_version="2.1.3"> 
     <sequence> 
      <module name="Magento_Wishlist" /> 
     </sequence> 
    </module> 
</config> 

しかし、まだMagento Wishlistモジュールコントローラが呼び出されています。私の優先されたプロセスに問題があることを教えてください。どうもありがとうございました。

答えて

0

Magento2 \ Magento \ Wishlist \ Controller \ Index \ Addは別のコアモジュールMultipleWishlistモジュールMagento \ MultipleWishlist \ Controller \ Index \ Addによってオーバーライドされます。そのため、wishlist addコントローラをオーバーライドする場合は、MultipleWishlist addコントローラ。

私はあなたのために働くとあなたの時間を節約しますように願っています。