【问题标题】:How to add custom attribute to customer export csv如何将自定义属性添加到客户导出 csv
【发布时间】:2014-09-18 07:08:21
【问题描述】:

我有 4 个客户自定义属性。我想在导出时将其添加到 csv 中。我已将其添加到网格中仅用于导出,但它似乎不起作用。创建了 csv 但数据未填充 csv。 下面是用于在 grid.php 中导入 csv 的代码。

       if ($this->_isExport) { 
     $this->addColumn('contact_job_title', array(
    'header' => Mage::helper('customer')->__('Contact Job Title'),
    'index'  => 'contact_job_title',
));
 $this->addColumn('contact_seq_no', array(
    'header' => Mage::helper('customer')->__('Contact Seq No'),
    'index'  => 'contact_seq_no',
));
$this->addColumn('debtor_acc_no', array(
    'header' => Mage::helper('customer')->__('Debtor Acc No'),
    'index'  => 'debtor_acc_no',
));
$this->addColumn('debtor_api_key', array(
    'header' => Mage::helper('customer')->__('Debtor Api Key'),
    'index'  => 'debtor_api_key',
));
    }

任何帮助将不胜感激。

【问题讨论】:

    标签: magento grid export magento-1.7


    【解决方案1】:

    好的,我找到答案了

    只需添加属性以在

    中选择
    protected function _prepareCollection()
    {
        $collection = Mage::getResourceModel('customer/customer_collection')
            ->addNameToSelect()
            ->addAttributeToSelect('email')
             ->addAttributeToSelect('debtor_api_key') /* added attribute */
             ->addAttributeToSelect('contact_job_title')  /* added attribute */
             ->addAttributeToSelect('contact_seq_no')  /* added attribute */
             ->addAttributeToSelect('creditstatus')  /* added attribute */
             ->addAttributeToSelect('debtor_acc_no')  /* added attribute */
            ->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();
    }
    

    and addcolumn 仅用于导出

    if ($this->_isExport) { 
            $this->addColumn('debtor_api_key', array(
                'header' => Mage::helper('customer')->__('Debtor Api Key'),
                'index'  => 'debtor_api_key',
            ));
            $this->addColumn('contact_job_title', array(
                'header' => Mage::helper('customer')->__('Contact Job Title'),
                'index'  => 'contact_job_title',
            ));
            $this->addColumn('contact_seq_no', array(
                'header' => Mage::helper('customer')->__('Contact Seq No'),
                'index'  => 'contact_seq_no',
            ));
            $this->addColumn('creditstatus', array(
                'header' => Mage::helper('customer')->__('Creditstatus'),
                'index'  => 'creditstatus',
            ));
            $this->addColumn('debtor_acc_no', array(
                'header' => Mage::helper('customer')->__('Debtor Acc No'),
                'index'  => 'debtor_acc_no',
            ));
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-18
      • 2012-11-25
      • 1970-01-01
      相关资源
      最近更新 更多