如何将自定义属性添加到客户导出的CSV

Zaheerabbas

我为customer.custom有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',
));
    }

任何帮助将不胜感激。

Zaheerabbas

好吧,我找到了答案

只需添加属性以选择

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();
}

和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',
        ));
    }

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何将自定义标头添加到SignalR的Typescript客户端?

来自分类Dev

如何将自定义属性添加到Symfony Doctrine YAML映射文件中

来自分类Dev

如何将自定义/额外属性添加到Mediawiki链接?

来自分类Dev

如何将自定义属性添加到传单0.7.7标记中?

来自分类Dev

如何将自定义属性添加到CodeDOM输出

来自分类Dev

如何将自定义属性添加到用户控件以进行绑定?

来自分类Dev

jQuery我们如何将自定义属性添加到<img>

来自分类Dev

如何将自定义属性添加到传单0.7.7标记中?

来自分类Dev

如何将自定义属性添加到 Laravel 分页 json 响应

来自分类Dev

如何将自定义地图和自定义数据添加到Highmaps?

来自分类Dev

如何将自定义文件添加到自定义文章列表页面

来自分类Dev

将自定义属性添加到Serilog

来自分类Dev

将自定义属性添加到SimpleSAMLPhp

来自分类Dev

将自定义属性添加到Trello卡

来自分类Dev

将自定义字段属性添加到CsvHelper

来自分类Dev

如何将自定义xml添加到Oracle XML Publisher数据定义

来自分类Dev

如何将自定义xtype添加到另一个视图?

来自分类Dev

如何将自定义按钮添加到AVPlayerViewController?

来自分类Dev

如何将自定义字段添加到Stripe Checkout的弹出窗体中

来自分类Dev

如何将自定义验证添加到角度组件?

来自分类Dev

如何将自定义库添加到暂存文件

来自分类Dev

如何将自定义字体大小添加到QuillJS编辑器

来自分类Dev

WordPress-如何将自定义元框添加到特定的管理页面?

来自分类Dev

如何将自定义全局JavaScript添加到MediaWiki

来自分类Dev

如何将自定义事件添加到NativeScript UI插件

来自分类Dev

如何将自定义ApplicationContextInitializer添加到Spring Boot应用程序?

来自分类Dev

如何将自定义标签添加到facet_grid()

来自分类Dev

使用CocoaPods时如何将自定义项目配置添加到Xcode?

来自分类Dev

如何将自定义图像标记添加到pagedown?

Related 相关文章

  1. 1

    如何将自定义标头添加到SignalR的Typescript客户端?

  2. 2

    如何将自定义属性添加到Symfony Doctrine YAML映射文件中

  3. 3

    如何将自定义/额外属性添加到Mediawiki链接?

  4. 4

    如何将自定义属性添加到传单0.7.7标记中?

  5. 5

    如何将自定义属性添加到CodeDOM输出

  6. 6

    如何将自定义属性添加到用户控件以进行绑定?

  7. 7

    jQuery我们如何将自定义属性添加到<img>

  8. 8

    如何将自定义属性添加到传单0.7.7标记中?

  9. 9

    如何将自定义属性添加到 Laravel 分页 json 响应

  10. 10

    如何将自定义地图和自定义数据添加到Highmaps?

  11. 11

    如何将自定义文件添加到自定义文章列表页面

  12. 12

    将自定义属性添加到Serilog

  13. 13

    将自定义属性添加到SimpleSAMLPhp

  14. 14

    将自定义属性添加到Trello卡

  15. 15

    将自定义字段属性添加到CsvHelper

  16. 16

    如何将自定义xml添加到Oracle XML Publisher数据定义

  17. 17

    如何将自定义xtype添加到另一个视图?

  18. 18

    如何将自定义按钮添加到AVPlayerViewController?

  19. 19

    如何将自定义字段添加到Stripe Checkout的弹出窗体中

  20. 20

    如何将自定义验证添加到角度组件?

  21. 21

    如何将自定义库添加到暂存文件

  22. 22

    如何将自定义字体大小添加到QuillJS编辑器

  23. 23

    WordPress-如何将自定义元框添加到特定的管理页面?

  24. 24

    如何将自定义全局JavaScript添加到MediaWiki

  25. 25

    如何将自定义事件添加到NativeScript UI插件

  26. 26

    如何将自定义ApplicationContextInitializer添加到Spring Boot应用程序?

  27. 27

    如何将自定义标签添加到facet_grid()

  28. 28

    使用CocoaPods时如何将自定义项目配置添加到Xcode?

  29. 29

    如何将自定义图像标记添加到pagedown?

热门标签

归档