人。我有个问题。我在我的自定义模块中有一个动作,创建客户。 有一个代码:Magento自定义控制器操作不渲染设计
在我的Magentoclass SeosClub_BusinessCategory_CustomerController extends Mage_Core_Controller_Front_Action {
public function createAction(){
$requestData = Mage::app()->getRequest()->getParams();
if(!$requestData['id'] || !$requestData['activation_code']){
Mage::getSingleton('core/session')->addError('Request data invalid');
}
$company = Mage::getModel('businesscategory/company')->load($requestData['id']);
if (!$company->getId()){
Mage::getSingleton('core/session')->addError('Your company does not exist');
}
if($company->getCustomerId()){
Mage::getSingleton('core/session')->addNotice($this->__('Customer already created. Forgot password?'));
$this->_redirect('customer/account/forgotpassword/');
return;
}
$group = Mage::getModel('customer/group')->load('Companies', 'customer_group_code');;
$customer = Mage::getModel("customer/customer");
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
$customer->setStore(Mage::app()->getStore());
$customer->setData('group_id', $group->getId());
$customer->setFirstname($company->getName());
$customer->setLastname($this->__('Unknown'));
$customer->setEmail($company->getEmail());
$customer->setPassword(Mage::helper('core')->getRandomString(8));
try{
$customer->save();
$customer->sendNewAccountEmail();
$company->setCustomerId($customer->getId());
$company->save();
Mage::getSingleton('core/session')->addSuccess($this->__('Account was created succefully'));
}
catch (Exception $e) {
Mage::getSingleton('core/session')->addError($e->getMessage());
}
$this->loadLayout();
$this->renderLayout();
}
}
我也安装的主题。但是,当我打开页面时,它渲染了基础magento主题,而不是我安装的主题。 如果我将代码从if($company->getCustomerId())
改为$this->loadLayout();
(不包括$ this-> loadLayout();),它将呈现正确的主题。
任何想法?
已启用。没有错误。 '公司' - 这是一个选项。 '$ requestData ['id']'定义。除了设计,一切都在运作。 –
再往下看你的代码? $ company-> getCustomerId()? – Emi
我告诉过你,除了设计之外,一切都在运转。当客户被创建时,它将customer_id设置为定义的公司。它能正常工作。 –