I want to create custom export CSV entity type in magento 2
1 Answer
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.
}
}
-
-
Please check my new question :- magento.stackexchange.com/q/340530/85907 Commented Jun 29, 2021 at 19:00
-
-