Example #1
0
 protected function _prepareColumns()
 {
     parent::_prepareColumns();
     if (!$this->_attributeCollection) {
         return $this;
     }
     foreach ($this->_attributeCollection as $attribute) {
         if ($inputType = $attribute->getFrontend()->getInputType()) {
             switch ($inputType) {
                 case 'date':
                     $this->addColumn($attribute->getAttributeCode(), array('header' => __($attribute->getFrontend()->getLabel()), 'type' => 'date', 'align' => 'center', 'index' => $attribute->getAttributeCode(), 'gmtoffset' => true));
                     break;
                 case 'text':
                 case 'textarea':
                     $this->addColumn($attribute->getAttributeCode(), array('header' => __($attribute->getFrontend()->getLabel()), 'index' => $attribute->getAttributeCode(), 'filter' => 'adminhtml/widget_grid_column_filter_text', 'sortable' => true));
                     break;
                 case 'select':
                     $options = array();
                     foreach ($attribute->getSource()->getAllOptions(false, true) as $option) {
                         $options[$option['value']] = $option['label'];
                     }
                     $this->addColumn($attribute->getAttributeCode(), array('header' => __($attribute->getFrontend()->getLabel()), 'index' => $attribute->getAttributeCode(), 'type' => 'options', 'options' => $options));
                     break;
                 case 'multiselect':
                     $options = array();
                     foreach ($attribute->getSource()->getAllOptions(false, true) as $option) {
                         $options[$option['value']] = $option['label'];
                     }
                     $this->addColumn($attribute->getAttributeCode(), array('header' => $this->__($attribute->getFrontend()->getLabel()), 'index' => $attribute->getAttributeCode(), 'type' => 'options', 'options' => $options, 'renderer' => 'amcustomerattr/adminhtml_renderer_multiselect', 'filter' => 'amcustomerattr/adminhtml_filter_multiselect'));
                     break;
             }
         }
     }
     return $this;
 }
 protected function _prepareCollection()
 {
     if ($vendor = Mage::helper('smvendors')->getVendorLogin()) {
         $user = Mage::getSingleton('admin/session')->getUser();
         $grandParent = get_parent_class(get_parent_class($this));
         $collection = Mage::getResourceModel('customer/customer_collection')->addNameToSelect()->addAttributeToSelect('email')->addAttributeToSelect('created_at')->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_regione', 'customer_address/region', 'default_billing', null, 'left')->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left')->joinField('store_name', 'core/store', 'name', 'store_id=store_id', null, 'left')->joinField('vendor_customer', 'smvendors/vendor_customer', null, 'customer_id=entity_id', "{{table}}.vendor_id={$vendor->getId()}", 'inner');
         $this->setCollection($collection);
         return call_user_func(array($grandParent, '_prepareCollection'));
     } else {
         return parent::_prepareCollection();
     }
     return parent::_prepareCollection();
 }