致命错误:在...中的非对象上调用成员函数 getId() Magento 问题
我正在尝试在网站上设置 ZetaPrint。在最后的步骤之一中,我必须在系统 > 上执行 ZetaPrints 模板同步配置文件。导入/导出>高级配置文件
但是当我执行“添加新配置文件”时,我收到此错误:
Fatal error: Call to a member function getId() on a non-object in /nfs/c06/h02/mnt/93577/domains/cannafresh.com/html/store/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php on line 117
该文件是 magento 的原始文件,我无法找出错误...任何人都可以帮助我吗?这是下面的完整代码:
<?php
/**
* Convert Advanced admin controller
*
* @category Mage
* @package Mage_Adminhtml
* @author Magento Core Team
*/
class Mage_Adminhtml_System_Convert_ProfileController extends Mage_Adminhtml_Controller_Action
{
protected function _initProfile($idFieldName = 'id')
{
$this->_title($this->__('System'))
->_title($this->__('Import and Export'))
->_title($this->__('Profiles'));
$profileId = (int) $this->getRequest()->getParam($idFieldName);
$profile = Mage::getModel('dataflow/profile');
if ($profileId) {
$profile->load($profileId);
if (!$profile->getId()) {
Mage::getSingleton('adminhtml/session')->addError('The profile you are trying to save no longer exists');
$this->_redirect('*/*');
return false;
}
}
Mage::register('current_convert_profile', $profile);
return $this;
}
/**
* Profiles list action
*/
public function indexAction()
{
$this->_title($this->__('System'))
->_title($this->__('Import and Export'))
->_title($this->__('Advanced Profiles'));
if ($this->getRequest()->getQuery('ajax')) {
$this->_forward('grid');
return;
}
$this->loadLayout();
/**
* Set active menu item
*/
$this->_setActiveMenu('system/convert');
/**
* Append profiles block to content
*/
$this->_addContent(
$this->getLayout()->createBlock('adminhtml/system_convert_profile', 'convert_profile')
);
/**
* Add breadcrumb item
*/
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Import/Export'), Mage::helper('adminhtml')->__('Import/Export Advanced'));
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Advanced Profiles'), Mage::helper('adminhtml')->__('Advanced Profiles'));
$this->renderLayout();
}
public function gridAction()
{
$this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/system_convert_profile_grid')->toHtml());
}
/**
* Profile edit action
*/
public function editAction()
{
$this->_initProfile();
$this->loadLayout();
$profile = Mage::registry('current_convert_profile');
// set entered data if was error when we do save
$data = Mage::getSingleton('adminhtml/session')->getConvertProfileData(true);
if (!empty($data)) {
$profile->addData($data);
}
$this->_title($profile->getId() ? $profile->getName() : $this->__('New Profile'));
$this->_setActiveMenu('system/convert');
$this->_addContent(
$this->getLayout()->createBlock('adminhtml/system_convert_profile_edit')
);
/**
* Append edit tabs to left block
*/
$this->_addLeft($this->getLayout()->createBlock('adminhtml/system_convert_profile_edit_tabs'));
$this->renderLayout();
}
/**
* Create new profile action
*/
public function newAction()
{
$this->_forward('edit');
}
/**
* Delete profile action
*/
public function deleteAction()
{
$this->_initProfile();
$profile = Mage::registry('current_convert_profile');
if ($profile->getId()) {
try {
$profile->delete();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('The profile has been deleted.'));
}
catch (Exception $e){
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
}
}
$this->_redirect('*/*');
}
/**
* Save profile action
*/
public function saveAction()
{
if ($data = $this->getRequest()->getPost()) {
if (!$this->_initProfile('profile_id')) {
return ;
}
$profile = Mage::registry('current_convert_profile');
// Prepare profile saving data
if (isset($data)) {
$profile->addData($data);
}
try {
$profile->save();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('The profile has been saved.'));
}
catch (Exception $e){
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::getSingleton('adminhtml/session')->setConvertProfileData($data);
$this->getResponse()->setRedirect($this->getUrl('*/*/edit', array('id'=>$profile->getId())));
return;
}
if ($this->getRequest()->getParam('continue')) {
$this->_redirect('*/*/edit', array('id'=>$profile->getId()));
} else {
$this->_redirect('*/*');
}
}
else {
Mage::getSingleton('adminhtml/session')->addError($this->__('Invalid POST data (please check post_max_size and upload_max_filesize settings in your php.ini file).'));
$this->_redirect('*/*');
}
}
public function runAction()
{
$this->_initProfile();
$this->loadLayout();
$this->renderLayout();
}
public function batchRunAction()
{
if ($this->getRequest()->isPost()) {
$batchId = $this->getRequest()->getPost('batch_id',0);
$rowIds = $this->getRequest()->getPost('rows');
$batchModel = Mage::getModel('dataflow/batch')->load($batchId);
/* @var $batchModel Mage_Dataflow_Model_Batch */
if (!$batchModel->getId()) {
//exit
return ;
}
if (!is_array($rowIds) || count($rowIds) < 1) {
//exit
return ;
}
if (!$batchModel->getAdapter()) {
//exit
return ;
}
$batchImportModel = $batchModel->getBatchImportModel();
$importIds = $batchImportModel->getIdCollection();
$adapter = Mage::getModel($batchModel->getAdapter());
$adapter->setBatchParams($batchModel->getParams());
$errors = array();
$saved = 0;
foreach ($rowIds as $importId) {
$batchImportModel->load($importId);
if (!$batchImportModel->getId()) {
$errors[] = Mage::helper('dataflow')->__('Skip undefined row.');
continue;
}
try {
$importData = $batchImportModel->getBatchData();
$adapter->saveRow($importData);
}
catch (Exception $e) {
$errors[] = $e->getMessage();
continue;
}
$saved ++;
}
$result = array(
'savedRows' => $saved,
'errors' => $errors
);
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
public function batchFinishAction()
{
if ($batchId = $this->getRequest()->getParam('id')) {
$batchModel = Mage::getModel('dataflow/batch')->load($batchId);
/* @var $batchModel Mage_Dataflow_Model_Batch */
if ($batchModel->getId()) {
$result = array();
try {
$batchModel->beforeFinish();
}
catch (Mage_Core_Exception $e) {
$result['error'] = $e->getMessage();
}
catch (Exception $e) {
$result['error'] = Mage::helper('adminhtml')->__('An error occurred while finishing process. Please refresh the cache');
}
$batchModel->delete();
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
}
/**
* Customer orders grid
*
*/
public function historyAction() {
$this->_initProfile();
$this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/system_convert_profile_edit_tab_history')->toHtml());
}
protected function _isAllowed()
{
// switch ($this->getRequest()->getActionName()) {
// case 'index':
// $aclResource = 'admin/system/convert/profiles';
// break;
// case 'grid':
// $aclResource = 'admin/system/convert/profiles';
// break;
// case 'run':
// $aclResource = 'admin/system/convert/profiles/run';
// break;
// default:
// $aclResource = 'admin/system/convert/profiles/edit';
// break;
// }
return Mage::getSingleton('admin/session')->isAllowed('admin/system/convert/profiles');
}
}
谢谢路易斯
I'm trying to setup ZetaPrint on a website. On one of the last steps, I have to do ZetaPrints templates synchronization profile, on System > Import/Export > Advanced Profiles
But When I do the "Add new profile" I get this error:
Fatal error: Call to a member function getId() on a non-object in /nfs/c06/h02/mnt/93577/domains/cannafresh.com/html/store/app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php on line 117
The file is the original one from magento, I can't figure out the error... can anyone help me? Here's the whole code below:
<?php
/**
* Convert Advanced admin controller
*
* @category Mage
* @package Mage_Adminhtml
* @author Magento Core Team
*/
class Mage_Adminhtml_System_Convert_ProfileController extends Mage_Adminhtml_Controller_Action
{
protected function _initProfile($idFieldName = 'id')
{
$this->_title($this->__('System'))
->_title($this->__('Import and Export'))
->_title($this->__('Profiles'));
$profileId = (int) $this->getRequest()->getParam($idFieldName);
$profile = Mage::getModel('dataflow/profile');
if ($profileId) {
$profile->load($profileId);
if (!$profile->getId()) {
Mage::getSingleton('adminhtml/session')->addError('The profile you are trying to save no longer exists');
$this->_redirect('*/*');
return false;
}
}
Mage::register('current_convert_profile', $profile);
return $this;
}
/**
* Profiles list action
*/
public function indexAction()
{
$this->_title($this->__('System'))
->_title($this->__('Import and Export'))
->_title($this->__('Advanced Profiles'));
if ($this->getRequest()->getQuery('ajax')) {
$this->_forward('grid');
return;
}
$this->loadLayout();
/**
* Set active menu item
*/
$this->_setActiveMenu('system/convert');
/**
* Append profiles block to content
*/
$this->_addContent(
$this->getLayout()->createBlock('adminhtml/system_convert_profile', 'convert_profile')
);
/**
* Add breadcrumb item
*/
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Import/Export'), Mage::helper('adminhtml')->__('Import/Export Advanced'));
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Advanced Profiles'), Mage::helper('adminhtml')->__('Advanced Profiles'));
$this->renderLayout();
}
public function gridAction()
{
$this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/system_convert_profile_grid')->toHtml());
}
/**
* Profile edit action
*/
public function editAction()
{
$this->_initProfile();
$this->loadLayout();
$profile = Mage::registry('current_convert_profile');
// set entered data if was error when we do save
$data = Mage::getSingleton('adminhtml/session')->getConvertProfileData(true);
if (!empty($data)) {
$profile->addData($data);
}
$this->_title($profile->getId() ? $profile->getName() : $this->__('New Profile'));
$this->_setActiveMenu('system/convert');
$this->_addContent(
$this->getLayout()->createBlock('adminhtml/system_convert_profile_edit')
);
/**
* Append edit tabs to left block
*/
$this->_addLeft($this->getLayout()->createBlock('adminhtml/system_convert_profile_edit_tabs'));
$this->renderLayout();
}
/**
* Create new profile action
*/
public function newAction()
{
$this->_forward('edit');
}
/**
* Delete profile action
*/
public function deleteAction()
{
$this->_initProfile();
$profile = Mage::registry('current_convert_profile');
if ($profile->getId()) {
try {
$profile->delete();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('The profile has been deleted.'));
}
catch (Exception $e){
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
}
}
$this->_redirect('*/*');
}
/**
* Save profile action
*/
public function saveAction()
{
if ($data = $this->getRequest()->getPost()) {
if (!$this->_initProfile('profile_id')) {
return ;
}
$profile = Mage::registry('current_convert_profile');
// Prepare profile saving data
if (isset($data)) {
$profile->addData($data);
}
try {
$profile->save();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('The profile has been saved.'));
}
catch (Exception $e){
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::getSingleton('adminhtml/session')->setConvertProfileData($data);
$this->getResponse()->setRedirect($this->getUrl('*/*/edit', array('id'=>$profile->getId())));
return;
}
if ($this->getRequest()->getParam('continue')) {
$this->_redirect('*/*/edit', array('id'=>$profile->getId()));
} else {
$this->_redirect('*/*');
}
}
else {
Mage::getSingleton('adminhtml/session')->addError($this->__('Invalid POST data (please check post_max_size and upload_max_filesize settings in your php.ini file).'));
$this->_redirect('*/*');
}
}
public function runAction()
{
$this->_initProfile();
$this->loadLayout();
$this->renderLayout();
}
public function batchRunAction()
{
if ($this->getRequest()->isPost()) {
$batchId = $this->getRequest()->getPost('batch_id',0);
$rowIds = $this->getRequest()->getPost('rows');
$batchModel = Mage::getModel('dataflow/batch')->load($batchId);
/* @var $batchModel Mage_Dataflow_Model_Batch */
if (!$batchModel->getId()) {
//exit
return ;
}
if (!is_array($rowIds) || count($rowIds) < 1) {
//exit
return ;
}
if (!$batchModel->getAdapter()) {
//exit
return ;
}
$batchImportModel = $batchModel->getBatchImportModel();
$importIds = $batchImportModel->getIdCollection();
$adapter = Mage::getModel($batchModel->getAdapter());
$adapter->setBatchParams($batchModel->getParams());
$errors = array();
$saved = 0;
foreach ($rowIds as $importId) {
$batchImportModel->load($importId);
if (!$batchImportModel->getId()) {
$errors[] = Mage::helper('dataflow')->__('Skip undefined row.');
continue;
}
try {
$importData = $batchImportModel->getBatchData();
$adapter->saveRow($importData);
}
catch (Exception $e) {
$errors[] = $e->getMessage();
continue;
}
$saved ++;
}
$result = array(
'savedRows' => $saved,
'errors' => $errors
);
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
public function batchFinishAction()
{
if ($batchId = $this->getRequest()->getParam('id')) {
$batchModel = Mage::getModel('dataflow/batch')->load($batchId);
/* @var $batchModel Mage_Dataflow_Model_Batch */
if ($batchModel->getId()) {
$result = array();
try {
$batchModel->beforeFinish();
}
catch (Mage_Core_Exception $e) {
$result['error'] = $e->getMessage();
}
catch (Exception $e) {
$result['error'] = Mage::helper('adminhtml')->__('An error occurred while finishing process. Please refresh the cache');
}
$batchModel->delete();
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
}
/**
* Customer orders grid
*
*/
public function historyAction() {
$this->_initProfile();
$this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/system_convert_profile_edit_tab_history')->toHtml());
}
protected function _isAllowed()
{
// switch ($this->getRequest()->getActionName()) {
// case 'index':
// $aclResource = 'admin/system/convert/profiles';
// break;
// case 'grid':
// $aclResource = 'admin/system/convert/profiles';
// break;
// case 'run':
// $aclResource = 'admin/system/convert/profiles/run';
// break;
// default:
// $aclResource = 'admin/system/convert/profiles/edit';
// break;
// }
return Mage::getSingleton('admin/session')->isAllowed('admin/system/convert/profiles');
}
}
Thanks Luis
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论