Magento의 고객 그리드 페이지에 사용자 정의 작업을 추가하려고합니다.Magento 고객 그리드에 새로운 고객 조치 추가
두 개의 모듈이 있습니다. 하나는 Manager라고 불리며 고객 호출의 이유 목록 (일반 정보, 주문 쿼리, 장난 전화)이있는 고객 로그 호출 로그입니다. 모든 이유는 데이터베이스에 저장됩니다. '관리자'모듈은 그룹에 고객을 할당하는 방식과 유사합니다. Mage_Adminhtml_Block_Customer_Grid
다음를 확장 Customergrid라고
두 번째 모듈은 I라는 드롭 다운 메뉴에서 옵션을 추가 한 경우 "통화 기록에 추가"입니다. 이 방법을 사용하여 '그룹'에 고객을 추가하는 것이 효과적 일 것입니다. 그리드 목록에서 고객을 선택하고 "통화 로그에 추가"를 선택하면 고객 그룹에 추가하는 것과 같은 다른 드롭 다운에서 "이유"를 선택하고 저장을 클릭해야합니다.
문제 :
나는 드롭 다운 목록에서 이유의 목록을 표시 할 수있는 방법을 찾아야합니다. 여기
는 customergrid 모듈에서 Grid.php 내 코드입니다 :<?php
class Module_Customergrid_Block_Adminhtml_Customer_Grid extends Mage_Adminhtml_Block_Customer_Grid
{
public function __construct()
{
parent::__construct();
$this->setId('customerGrid');
$this->setUseAjax(true);
$this->setDefaultSort('entity_id');
$this->setSaveParametersInSession(true);
}
protected function _prepareCollection()
{
$collection = Mage::getResourceModel('customer/customer_collection')
->addNameToSelect()
->addAttributeToSelect('email')
->addAttributeToSelect('created_at')
->addAttributeToSelect('group_id')
->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left');
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('entity_id', array(
'header' => Mage::helper('customer')->__('ID'),
'width' => '50px',
'index' => 'entity_id',
'type' => 'number',
));
/*$this->addColumn('firstname', array(
'header' => Mage::helper('customer')->__('First Name'),
'index' => 'firstname'
));
$this->addColumn('lastname', array(
'header' => Mage::helper('customer')->__('Last Name'),
'index' => 'lastname'
));*/
$this->addColumn('name', array(
'header' => Mage::helper('customer')->__('Name'),
'index' => 'name'
));
$this->addColumn('email', array(
'header' => Mage::helper('customer')->__('Email'),
'width' => '150',
'index' => 'email'
));
$groups = Mage::getResourceModel('customer/group_collection')
->addFieldToFilter('customer_group_id', array('gt'=> 0))
->load()
->toOptionHash();
$this->addColumn('group', array(
'header' => Mage::helper('customer')->__('Group'),
'width' => '100',
'index' => 'group_id',
'type' => 'options',
'options' => $groups,
));
$this->addColumn('Telephone', array(
'header' => Mage::helper('customer')->__('Telephone'),
'width' => '100',
'index' => 'billing_telephone'
));
$this->addColumn('billing_postcode', array(
'header' => Mage::helper('customer')->__('ZIP'),
'width' => '90',
'index' => 'billing_postcode',
));
$this->addColumn('billing_country_id', array(
'header' => Mage::helper('customer')->__('Country'),
'width' => '100',
'type' => 'country',
'index' => 'billing_country_id',
));
$this->addColumn('billing_region', array(
'header' => Mage::helper('customer')->__('State/Province'),
'width' => '100',
'index' => 'billing_region',
));
$this->addColumn('customer_since', array(
'header' => Mage::helper('customer')->__('Customer Since'),
'type' => 'datetime',
'align' => 'center',
'index' => 'created_at',
'gmtoffset' => true
));
if (!Mage::app()->isSingleStoreMode()) {
$this->addColumn('website_id', array(
'header' => Mage::helper('customer')->__('Website'),
'align' => 'center',
'width' => '80px',
'type' => 'options',
'options' => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(true),
'index' => 'website_id',
));
}
$this->addColumn('action',
array(
'header' => Mage::helper('customer')->__('Action'),
'width' => '100',
'type' => 'action',
'getter' => 'getId',
'actions' => array(
array(
'caption' => Mage::helper('customer')->__('Edit'),
'url' => array('base'=> '*/*/edit'),
'field' => 'id'
)
),
'filter' => false,
'sortable' => false,
'index' => 'stores',
'is_system' => true,
));
$this->addExportType('*/*/exportCsv', Mage::helper('customer')->__('CSV'));
$this->addExportType('*/*/exportXml', Mage::helper('customer')->__('Excel XML'));
return parent::_prepareColumns();
}
protected function _prepareMassaction()
{
$this->setMassactionIdField('entity_id');
$this->getMassactionBlock()->setFormFieldName('customer');
$this->getMassactionBlock()->addItem('delete', array(
'label' => Mage::helper('customer')->__('Delete'),
'url' => $this->getUrl('*/*/massDelete'),
'confirm' => Mage::helper('customer')->__('Are you sure?')
));
$this->getMassactionBlock()->addItem('newsletter_subscribe', array(
'label' => Mage::helper('customer')->__('Subscribe to Newsletter'),
'url' => $this->getUrl('*/*/massSubscribe')
));
$this->getMassactionBlock()->addItem('newsletter_unsubscribe', array(
'label' => Mage::helper('customer')->__('Unsubscribe from Newsletter'),
'url' => $this->getUrl('*/*/massUnsubscribe')
));
$this->getMassactionBlock()->addItem('manager_grid', array(
'label' => Mage::helper('manager')->__('Add to call log'),
'url' => $this->getUrl('*/*/massAssignGroup'),
'additional' => array(
'visibility' => array(
'name' => 'reason',
'type' => 'select',
'class' => 'required-entry',
'label' => Mage::helper('manager')->__('Reason'),
'values' => $data
)
)
));
$groups = $this->helper('customer')->getGroups()->toOptionArray();
array_unshift($groups, array('label'=> '', 'value'=> ''));
$this->getMassactionBlock()->addItem('assign_group', array(
'label' => Mage::helper('customer')->__('Assign a Customer Group'),
'url' => $this->getUrl('*/*/massAssignGroup'),
'additional' => array(
'visibility' => array(
'name' => 'group',
'type' => 'select',
'class' => 'required-entry',
'label' => Mage::helper('customer')->__('Group'),
'values' => $groups
)
)
));
return $this;
}
public function getGridUrl()
{
return $this->getUrl('*/*/grid', array('_current'=> true));
}
public function getRowUrl($row)
{
return $this->getUrl('*/*/edit', array('id'=>$row->getId()));
}
}
사람이 내가의 '이유'목록을 표시 할 수 없습니다 이대로 올바른 방법으로 이것에 대해 갈거야 경우 말해 줄 수 두 번째 드롭 다운 필드. 나는 Magento 관리자를 커스터마이징하는 데 익숙하지 않으므로 지식 부족을 용서하십시오.
나는 빈 화면을 얻을 배열에 옵션을 추가하려고하면 :
$collection = $this->helper('manager')->getCollection()->toOptionArray();
array_unshift($manager, array('label'=> '','value'=>''));
$this->getMassactionBlock()->addItem('manager', array(
'label' => Mage::helper('manager')->__('Add to call log'),
'url' => $this->getUrl('*/*/massAssignManager'),
'additional' => array(
'visibility' => array(
'name' => 'manager',
'type' => 'select',
'class' => 'required-entry',
'label' => Mage::helper('manager')->__('Reason'),
'values' => $manager
)
)
));
내가 알아낼 왜 안 할 수 있습니다!
정확히 내가 겪고있는 문제 ... 내가 가까이에 있음을 알려 주셔서 감사합니다 ... – user1704524
$ groups 변수를 로그하면 구조가 보일 것이며 똑같은 일을 할 수 있습니다. 기본적으로'$ collection = Model-> getCollection() -> filters/select/etc와 같은 것입니다. $ collection = $ collection-> toOptionArray(); array_unshift ($ collection, array ('label'=> '', 'value'=> ''));'모델 구조를 잘 모르기 때문에 더 정확하게 말할 수 없습니다. – dagfr
도움을 주셔서 감사합니다. 조금만 더 도와 주실 수 있으면 매우 고맙겠습니다. 이것은 내가 나의 모듈 http://www.excellencemagentoblog.com/magento-grid-serializer-admin-tabs-grid?facebook=1 – user1704524