0

I want to create custom export CSV entity type in magento 2

1 Answer 1

0

You can create custom export entity type using below code

app/code/Vendor/Extension/etc/export.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_ImportExport:etc/import.xsd">
    <entity name="customtype" label="Learning Courses Export" model="Vendor\Extension\Model\Export\Courses"/>
</config>

app/code/Vendor/Extension/Model/Export/Courses.php

namespace Vendor\Extension\Model\Export;


class Courses extends \Magento\ImportExport\Model\Export\AbstractEntity
{
    
    const COLUMN_TYPE = 'customtype';
    const COLUMN_MODEL = 'model';
    const COLUMN_PROD_IDS = 'product_ids';

    protected $_permanentAttributes = [
        self::COLUMN_TYPE,
        self::COLUMN_MODEL,
        self::COLUMN_PROD_IDS,
    ];

    public function export()
    {
        // Code For Export
    }

    public function exportItem($item)
    {
        // TODO: Implement exportItem() method.
    }

    public function getEntityTypeCode()
    {
        return  'customtype';
    }

    protected function _getHeaderColumns()
    {
        return $this->_permanentAttributes;
    }

    protected function _getEntityCollection()
    {
        // TODO: Implement _getEntityCollection() method.
    }
}
4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.