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模塊控制器。你能否讓我知道我的壓倒一切的過程中是否有任何問題?非常感謝你。