我已經打了一個問題,嘗試新的動作在Magento添加到現有的航線2.Magento的2控制器後拋出404錯誤
我創建了一個新的模塊,其註冊並創建延伸的新動作現有的添加到購物車功能。我曾在一個現有的項目上工作,但必須將其移植到新的安裝中。現在,當我嘗試POST到路徑:<magentourl>/checkout/cart/addbulk
時,它將引發404。GET請求將擊中execute方法並創建日誌條目。
以下是模塊的組件。
應用程序/代碼/測試/結帳的/ etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Test_Checkout" schema_version="2.0.0" setup_version="2.0.3">
<sequence>
<module name="Magento_Checkout"/>
</sequence>
</module>
</config>
應用程序/代碼/測試/結帳的/ etc /前端/ routes.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="checkout" frontName="checkout">
<module name="Test_Checkout" />
</route>
</router>
</config>
應用程序/代碼/測試/結帳/控制器/車/ Addbulk.php
<?php
namespace Test\Checkout\Controller\Cart;
class Addbulk extends \Magento\Checkout\Controller\Cart\Add
{
public function execute()
{
$items = $this->getRequest()->getParam('item', []);
$this->_objectManager->get('Psr\Log\LoggerInterface')>addDebug('Posting data to addBulk');
...
return $this->_goBack();
}
}
我已經啓用的模塊,運行bin/magento setup:upgrade
,清除緩存,然後嘗試發佈。 當我做一個POST時,它會返回一個404錯誤,在GET上它會按照預期創建日誌條目。
有沒有人有任何想法,爲什麼這個模塊不會正確遷移,或者我需要添加任何其他的東西來得到這個工作?
您設置了哪種部署模式?您是否嘗試清除文件系統上的所有緩存文件+生成的代碼文件? – bpoiss