人。我有個問題。我在我的自定義模塊中有一個動作,創建客戶。 有一個代碼: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設置爲定義的公司。它能正常工作。 –