我正在管理面板中开发一个子模块。第一页网格显示用户列表(推荐人/父母用户)及其总佣金。在“操作”选项卡中有一个下拉列表,点击其中一些网格打开。与此类似,我想在点击时添加另一个选项,其中应该有一个页面显示在Referrer / Parent用户下引用的人(子用户)以及每个推荐人/子用户使用的Referrer / Parent用户的佣金。
对于ex: A(父用户) - B,C(子用户)通过A的引用注册。 因此,从B,A得到20美元的佣金和C,A得到20美元的佣金,(这些详细信息由哪些人提交,以及有多少佣金存储在表格中)显示总数上一页的40美元。
我得到的错误是 -
致命错误:未捕获错误:在E:\ xampp \ htdocs \ peoplesoilnew \ app \ code \ core \ Mage \ Adminhtml \ Block \ Widget \ Grid \ Container中调用boolean上的成员函数setSaveParametersInSession()。 php:66堆栈跟踪:#0 E:\ xampp \ htdocs \ peoplesoilnew \ app \ code \ core \ Mage \ Core \ Block \ Abstract.php(238):Mage_Adminhtml_Block_Widget_Grid_Container-> _prepareLayout()#1 E:\ xampp \ htdocs \ peoplesoilnew \ app \ code \ core \ Mage \ Core \ Model \ Layout.php(456):Mage_Core_Block_Abstract-> setLayout(Object(Mage_Core_Model_Layout))#2 E:\ xampp \ htdocs \ peoplesoilnew \ app \ code \ local \ Mj \ Friends \ controllers \ Adminhtml \ FriendsController.php(60):Mage_Core_Model_Layout-> createBlock('friends / adminht ...')#3 E:\ xampp \ htdocs \ peoplesoilnew \ app \ code \ core \ Mage \ Core \ Controller \ Varien \ Action.php(419):Mj_Friends_Adminhtml_FriendsController-> friendscommissionAction()#4 E:\ xampp \ htdocs \ peoplesoilnew \ app \ code \ core \ Mage \ Core \ Controller \ Varien \ Router \ Standard.php (250):Mage_Core_Controller_Varien_Action-> dispatch('朋友委员会...')#5 E:\ xampp \ htdocs \ peoplesoilnew \ app \ code \ core \ Ma in E:\ xampp \ htdocs \ peoplesoilnew \ app \ code \ core \ Mage \ Adminhtml \ Block \ Widget \ Grid \第66行的Container.php
代码文件 -
添加下拉选项的代码 -
$this->addColumn('action',
array(
'header' => Mage::helper('customer')->__('Action'),
'width' => '100',
'type' => 'action',
'getter' => 'getId',
'actions' => array(
array(
'caption' => Mage::helper('friends')->__('Make Payment'),
'url' => array('base'=> '*/*/payment'),
'field' => 'friendskey_id'
),
array(
'caption' => Mage::helper('friends')->__('View Referred Friend List'),
'url' => array('base'=> '*/*/friendslist'),
'field' => 'friendskey_id'
),
array(
'caption' => Mage::helper('friends')->__('Distribution of Commission'),
'url' => array('base'=> '*/*/friendscommission'),
'field' => 'friendskey_id'
)
app \ code \ local \ Mj \ Friends \ etc \ config.xml -
<friends_mysql4>
<class>Mj_Friends_Model_Mysql4</class>
<entities>
<friends>
<table>friends</table>
</friends>
<commission>
<table>friends_commission</table>
</commission>
<memberkey>
<table>friendskey</table>
</memberkey>
<friendscommission>
<table>friends_commission</table>
</friendscommission>
</entities>
</friends_mysql4>
app \ code \ local \ Mj \ Friends \ Block \ Adminhtml \ Friendscommission \ Grid.php -
<?php
class Mj_Friends_Block_Adminhtml_Friendscommission_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
public function __construct()
{
parent::__construct();
$this->setId('friends_commission');
$this->setDefaultSort('commission_id');
$this->setDefaultDir('ASC');
$this->setSaveParametersInSession(false);
$this->_prepareCollection();
}
protected function _prepareCollection()
{
// get the member id using friendskey_id
/*$friendsId = $this->getRequest()->getParam('friendskey_id');
$friendsModel = Mage::getModel('friends/memberkey')->load($friendsId);
$memberId = $friendsModel->getMemberId();*/
$collection = Mage::getModel('friends/friends_commission')->getCollection();
// $collection->addFieldToFilter('member_id', $memberId);
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
/*
$this->addColumn('friends_id', array(
'header' => Mage::helper('friends')->__('ID'),
'align' =>'right',
'width' => '50px',
'index' => 'friends_id',
));
*/
$this->addColumn('user_email', array(
'header' => Mage::helper('friends')->__('User Email'),
'align' => 'left',
'width' => '120px',
'default' => '--',
'index' => 'user_email',
));
$this->addColumn('status', array(
'header' => Mage::helper('friends')->__('Status'),
'align' => 'left',
'width' => '80px',
'index' => 'status',
'type' => 'options',
'options' => array(
'Active' => 'Active',
'Inactive' => 'Inactive',
),
));
return parent::_prepareColumns();
}
}
app \ code \ local \ Mj \ Friends \ Block \ Adminhtml \ Friendscommission.php -
<?php
class Mj_Friends_Block_Adminhtml_Friendscommission extends Mage_Adminhtml_Block_Widget_Grid_Container
{
public function __construct()
{
$this->_controller = 'adminhtml_friendscommission';
$this->_blockGroup = 'friends';
$this->_headerText = Mage::helper('friends')->__('Friends Commission');
//$this->_addButtonLabel = Mage::helper('friends')->__('Add Item');
parent::__construct();
$this->_removeButton('add');
/*
$this->_addButton('back');
$this->_addButton('back_button_id', array(
'label' => Mage::helper('friends')->__('Some action'),
'onclick' => 'jsfunction(this.id)',
'class' => 'go'
), 0, 100, 'header', 'header');
*/
}
}
** app \ code \ local \ Mj \ Friends \ Model \ Friendscommission.php **
<?php
class Mj_Friends_Model_Friendscommission extends Mage_Core_Model_Abstract
{
public function _construct()
{
parent::_construct();
$this->_init('friends/friends_commission');
}
}
从控制器调用该模块的操作,app \ code \ local \ Mj \ Friends \ controllers \ Adminhtml \ FriendsController.php -
<?php
class Mj_Friends_Adminhtml_FriendsController extends Mage_Adminhtml_Controller_Action
{
protected function _initAction()
{
$this->loadLayout()
->_setActiveMenu('friends/items')
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
return $this;
}
public function indexAction() {
$this->_initAction();
$this->_addContent($this->getLayout()->createBlock('friends/adminhtml_friends'));
$this->renderLayout();
}
public function editAction()
{
$friendsId = $this->getRequest()->getParam('id');
$friendsModel = Mage::getModel('friends/friends')->load($friendsId);
if ($friendsModel->getId() || $friendsId == 0) {
Mage::register('friends_data', $friendsModel);
$this->loadLayout();
$this->_setActiveMenu('friends/items');
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
$this->_addContent($this->getLayout()->createBlock('friends/adminhtml_friends_edit'))
->_addLeft($this->getLayout()->createBlock('friends/adminhtml_friends_edit_tabs'));
$this->renderLayout();
} else {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('friends')->__('Item does not exist'));
$this->_redirect('*/*/');
}
}
public function newAction()
{
$this->_forward('edit');
}
public function friendslistAction() {
$this->_initAction();
$this->_addContent($this->getLayout()->createBlock('friends/adminhtml_friendslist'));
$this->renderLayout();
}
public function friendscommissionAction() {
$this->_initAction();
$this->_addContent($this->getLayout()->createBlock('friends/adminhtml_friendscommission'));
$this->renderLayout();
}
public function paymentAction()
{
$friendsId = $this->getRequest()->getParam('friendskey_id');
$friendsModel = Mage::getModel('friends/memberkey')->load($friendsId);
if ($friendsModel->getFriendskeyId() || $friendsId > 0) {
Mage::register('friends_data', $friendsModel);
$this->loadLayout();
$this->_setActiveMenu('friends/items');
/* $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));*/
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
$this->_addContent($this->getLayout()->createBlock('friends/adminhtml_friends_payment'))
->_addLeft($this->getLayout()->createBlock('friends/adminhtml_friends_payment_tabs'));
$this->renderLayout();
} else {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('friends')->__('Item does not exist'));
$this->_redirect('*/*/');
}
}
public function saveAction()
{
if ( $this->getRequest()->getPost() ) {
try {
$postData = $this->getRequest()->getPost();
//print_r($postData); die;
if($postData['amount_hidden'] ) {
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_write');
$updateSql = "UPDATE friends_standard_payamount SET standard_amount = '".$postData['standard_payment_amount']."', standard_commission = '".$postData['standard_commission']."'";
$readConnection->query($updateSql);
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Minimum referred payment amount updated successfully.'));
$this->_redirect('new', array('friendskey_id' => $this->getRequest()->getParam('friendskey_id')));
return;
} else {
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_write');
$updateSql = "UPDATE friends_standard_payamount SET standard_commission = '".$postData['commission_amount']."'";
$readConnection->query($updateSql);
//get the commission amount
$friendsModel = Mage::getModel('friends/friends');
$commission_amount = $postData['commission_amount'];
$friendskey_id = $postData['friendskey_id'];
//get the memeber id.
$friendsModel = Mage::getModel('friends/memberkey')->load($friendskey_id);
$memberId = $friendsModel->getMemberId();
//get the member paypal business email address.
$customerData = Mage::getModel('customer/customer')->load($memberId)->getData();
//$customerData['paypalemail'];
if(!empty($customerData['paypalemail'])) {
//get the paypal config settings.
$standard = Mage::getModel('paypal/standard');
$form = new Varien_Data_Form();
$form->setAction($standard->getConfig()->getPaypalUrl())
->setId('paypal_standard_checkout')
->setName('paypal_standard_checkout')
->setMethod('POST')
->setUseContainer(true);
/* @var $api Mage_Paypal_Model_Api_Standard */
$api = Mage::getModel('paypal/api_standard')->setConfigObject($this->getConfig());
//$orderIncrementId = 0 ;
$api->setOrderId($orderIncrementId)
->setCurrencyCode(Mage::app()->getStore()->getCurrentCurrencyCode())
//->setPaymentAction()
//->setOrder($order)
->setNotifyUrl(Mage::getUrl('paypal/ipn/'))
->setReturnUrl(Mage::getUrl('paypal/standard/success'))
->setCancelUrl(Mage::getUrl('paypal/standard/cancel'));
//get and set owner address.
$address = array();
$api->setAddress($address);
$api->setLocale($api->getLocaleCode());
$result = $api->getStandardCheckoutRequest();
foreach ($result as $field=>$value) {
if($field == "business") {
//set the paypal business email address
$form->addField($field, 'hidden', array('name'=>$field, 'value'=>$customerData['paypalemail']));
} else if($field == "return") {
$form->addField($field, 'hidden', array('name'=>$field, 'value'=>$this->getUrl('*/*/success', array())));
} else if($field == "cancel_return") {
$form->addField($field, 'hidden', array('name'=>$field, 'value'=>$this->getUrl('*/*/cancel', array())));
} else {
$form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
}
}
$form->addField('amount', 'hidden', array('name'=>'amount', 'value'=>$commission_amount));
$form->addField('paymentaction', 'hidden', array('name'=>'paymentaction', 'value'=>'sale'));
$form->addField('item_name', 'hidden', array('name'=>'item_name', 'value'=>'Commission Amount'));
//$form->addField('business', 'hidden', array('name'=>'business', 'value'=>$paypalBusinessIdValue));
$idSuffix = Mage::helper('core')->uniqHash();
$submitButton = new Varien_Data_Form_Element_Submit(array(
'value' => $this->__('Click here if you are not redirected within 10 seconds...'),
));
$id = "submit_to_paypal_button_{$idSuffix}";
$submitButton->setId($id);
$form->addElement($submitButton);
$html = '<html><body>';
$html.= $this->__('You will be redirected to the PayPal website in a few seconds.');
$html.= $form->toHtml();
$html.= '<script type="text/javascript">document.getElementById("paypal_standard_checkout").submit();</script>';
$html.= '</body></html>';
echo $html;
exit;
}else {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Member does not have the PayPal Email Address. Thus, unable proceed to make the payment.'));
Mage::getSingleton('adminhtml/session')->setFriendsData($this->getRequest()->getPost());
$this->_redirect('*/*/payment', array('friendskey_id' => $this->getRequest()->getParam('friendskey_id')));
return;
}
}
/*
$friendsModel->setId($this->getRequest()->getParam('id'))
->setTitle($postData['user_email'])
->setContent($postData['content'])
->setStatus($postData['status'])
->save();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully saved'));
Mage::getSingleton('adminhtml/session')->setFriendsData(false);
*/
// $this->_redirect('*/*/');
// return;
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::getSingleton('adminhtml/session')->setFriendsData($this->getRequest()->getPost());
$this->_redirect('*/*/payment', array('friendskey_id' => $this->getRequest()->getParam('friendskey_id')));
return;
}
}
$this->_redirect('*/*/');
}
public function successAction() {
$this->loadLayout();
$this->_setActiveMenu('friends/items');
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
$this->renderLayout();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Payment has been done successfully.'));
}
public function cancelAction() {
$this->loadLayout();
$this->_setActiveMenu('friends/items');
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
$this->renderLayout();
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Payment has been cancelled successfully.'));
}
public function formAction(){
$this->loadLayout();
$this->getResponse()->setBody(
$this->getLayout()->createBlock('friends/adminhtml_friends_payment_tab_amount')->toHtml()
);
}
/**
* Config instance getter
* @return Mage_Paypal_Model_Config
*/
public function getConfig()
{
if (null === $this->_config) {
$params = array($this->_code);
if ($store = Mage::app()->getStore()) {
$params[] = is_object($store) ? $store->getId() : $store;
}
$this->_config = Mage::getModel('paypal/config', $params);
}
return $this->_config;
}
public function deleteAction()
{
if( $this->getRequest()->getParam('id') > 0 ) {
try {
$friendsModel = Mage::getModel('friends/friends');
$friendsModel->setId($this->getRequest()->getParam('id'))
->delete();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
$this->_redirect('*/*/');
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
}
}
$this->_redirect('*/*/');
}
/**
* Product grid for AJAX request.
* Sort and filter result for example.
*/
public function gridAction()
{
$this->loadLayout();
$this->getResponse()->setBody(
$this->getLayout()->createBlock('friends/adminhtml_friends_grid')->toHtml()
);
}
}
从 -
获取数据的表格答案 0 :(得分:0)
好像你错过了控制器“adminhtml_friendscommission”
$this->_controller = 'adminhtml_friendscommission';
请创建上述控制器,它将解决问题。
或者,如果你不想要那个friendscommission控制器,如果你需要使用朋友控制器改变
$this->_controller = 'adminhtml_friendscommission';
到
$this->_controller = 'adminhtml_friends';
在
Mj_Friends_Block_Adminhtml_Friendscommission::__construct method