Since the SUPEE-5994 patch in Magento I seem to be getting a 404 error while requesting a function within a controller, before this patch, this function was working fine. According to this post, it has to do something with the config.xml
but as far as I know, this does not apply for the adminhtml blocks that have to be called from a Controller. I also cannot find if this error is a result from the patch that routers need to be defined.
I tried adding a router with all the controllers and the blocks but even after clearing the cache, logging out and in again, the function still is a 404.
This is my code:
<kbd>app/code/community/MyModule/Advanced/Controller/AjaxController.php</kbd>
class Icepay_IceAdvanced_AjaxController extends Mage_Adminhtml_Controller_Action
{
protected $webservice = null;
public function iceWebservice()
{
if ($this->webservice == null)
$this->webservice = new Icepay_IceAdvanced_Model_Paymentmethods();
return $this->webservice;
}
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
public function get_paymentmethodsAction()
{
$this->getResponse()->setBody(Zend_Json::encode($this->iceWebservice()->retrieveAdminGrid($this->getRequest()->get("store"))));
}
public function save_paymentmethodAction()
{
$adv_sql = Mage::getSingleton('iceadvanced/mysql4_iceAdvanced');
$reference = $this->getRequest()->getPost("reference");
$scopeID = $this->getRequest()->getPost("store");
if (!isset($reference))
return;
$adv_sql->setScope($scopeID);
$settings = Mage::helper("iceadvanced")->getPaymentmethodExtraSettings();
if ($this->getRequest()->getPost("active_issuers")) {
$issuers = explode(",", $this->getRequest()->getPost("active_issuers"));
if (count($issuers) >= 1)
array_push($settings, "active_issuers"); //At least 1 issuer active is required
}
foreach ($settings as $setting) {
$adv_sql->saveConfigValue($reference, $setting, $this->getRequest()->getPost($setting));
}
$this->getResponse()->setBody(sprintf($this->__("%s settings have been saved."), $this->getRequest()->getPost("name")));
}
}
<kbd>app/code/community/MyModule/Advanced/Block/Adminhtml/Grid/Paymentmethods.php</kbd>
class Icepay_IceAdvanced_Block_Adminhtml_Grid_PaymentMethods extends Mage_Adminhtml_Block_Widget implements Varien_Data_Form_Element_Renderer_Interface
{
protected $_element;
protected $_scope;
protected $_ajaxLoadPaymentMethodURL;
protected $_ajaxSavePaymentMethodURL;
protected $_ajaxGetPaymentMethodsURL;
protected $debug;
public function __construct()
{
$this->_scope = Mage::app()->getStore(Mage::helper("icecore")->getStoreFromRequest())->getId();
$this->_ajaxLoadPaymentMethodURL = Mage::helper('adminhtml')->getUrl('icepayadvanced/config/index/paymentmethod/{{pm_code}}', array('_secure' => true, 'scope' => $this->_scope));
$this->_ajaxSavePaymentMethodURL = Mage::helper('adminhtml')->getUrl('icepayadvanced/ajax/save_paymentmethod', array('_secure' => true, 'scope' => $this->_scope));
$this->_ajaxGetPaymentMethodsURL = Mage::helper('adminhtml')->getUrl('icepayadvanced/ajax/get_paymentmethods', array('_secure' => true));
$this->setTemplate('icepayadvanced/grid_paymentmethods.phtml');
}
public function render(Varien_Data_Form_Element_Abstract $element)
{
$this->setElement($element);
return $this->toHtml();
}
public function setElement(Varien_Data_Form_Element_Abstract $element)
{
$this->_element = $element;
return $this;
}
public function getElement()
{
return $this->_element;
}
public function getJS($uri)
{
return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS, true) . $uri;
}
public function getPaymentmethods()
{
return Mage::getSingleton('iceadvanced/mysql4_iceAdvanced')->getAdminPaymentmethodConfigForStore($this->_scope);
}
public function getAddButtonHtml()
{
return $this->getChildHtml('add_button');
}
protected function _prepareLayout()
{
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
->setData(array(
'label' => Mage::helper('icecore')->__('Get paymentmethods'),
'onclick' => 'return ICEPAY.retrieveFromICEPAY()',
'class' => 'add'
));
$button->setName('add_tier_price_item_button');
$this->setChild('add_button', $button);
if (version_compare(Mage::getVersion(), '1.7.0.0', '<')) {
$this->getLayout()->getBlock('head')->addItem('js_css', 'prototype/windows/themes/magento.css');
} else {
$this->getLayout()->getBlock('head')->addItem('skin_css', 'lib/prototype/windows/themes/magento.css');
}
$this->getLayout()
->getBlock('head')
->addItem('js_css', 'prototype/windows/themes/default.css');
return parent::_prepareLayout();
}
}
Here I uploaded the config.xml and any other file for review.
Edit: After following BJ Hoffpauir guide; this is the output of the error.log
192.168.137.1 - - [17/Jul/2015:23:03:56 +0000] "POST /index.php/icepayadvanced/ajax/get_paymentmethods/key/21e4f55bb33ad6a323c50140bc5ef585/?isAjax=true HTTP/1.1" 404 16910 "http://192.168.137.124/index.php/admin/system_config/edit/section/icecore/key/e96d9f50648cad8168ebf376470196ad/" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36"