55 * * See LICENSE.md bundled with this module for license details.
66 *
77 */
8- namespace FireGento \FastSimpleExport \Model \Export ;
8+ namespace FireGento \FastSimpleExport \Model \Entity \ Order ;
99
1010/**
1111 * Export entity customer model
12- *
13- * @method \Magento\Customer\Model\ResourceModel\Attribute\Collection getAttributeCollection() getAttributeCollection()
1412 */
13+
1514class Order extends \Magento \ImportExport \Model \Export \Entity \AbstractEav
1615{
1716 /**#@+
@@ -20,9 +19,6 @@ class Order extends \Magento\ImportExport\Model\Export\Entity\AbstractEav
2019 * Names that begins with underscore is not an attribute. This name convention is for
2120 * to avoid interference with same attribute name.
2221 */
23- const COLUMN_EMAIL = 'email ' ;
24-
25- const COLUMN_WEBSITE = '_website ' ;
2622
2723 const COLUMN_STORE = '_store ' ;
2824
@@ -31,14 +27,8 @@ class Order extends \Magento\ImportExport\Model\Export\Entity\AbstractEav
3127 /**#@+
3228 * Attribute collection name
3329 */
34- const ATTRIBUTE_COLLECTION_NAME = 'Magento\Customer\Model\ResourceModel\Attribute\Collection ' ;
35-
36- /**#@-*/
30+ const ATTRIBUTE_COLLECTION_NAME = 'FireGento\FastSimpleExport\Model\Entity\Order\OrderAttributeCollection ' ;
3731
38- /**#@+
39- * XML path to page size parameter
40- */
41- const XML_PATH_PAGE_SIZE = 'export/customer_page_size/customer ' ;
4232
4333 /**#@-*/
4434
@@ -65,30 +55,30 @@ class Order extends \Magento\ImportExport\Model\Export\Entity\AbstractEav
6555 *
6656 * @var string[]
6757 */
68- protected $ _indexValueAttributes = ['group_id ' , ' website_id ' , ' store_id ' ];
58+ protected $ _indexValueAttributes = ['store_id ' ];
6959
7060 /**
7161 * Permanent entity columns.
7262 *
7363 * @var string[]
7464 */
75- protected $ _permanentAttributes = [self ::COLUMN_EMAIL , self :: COLUMN_WEBSITE , self :: COLUMN_STORE ];
65+ protected $ _permanentAttributes = [self ::COLUMN_STORE ];
7666
7767 /**
78- * Customers whose data is exported
79- *
80- * @var \Magento\Customer\Model\ResourceModel\Customer\Collection
68+ * @var \Magento\Sales\Model\ResourceModel\Order\Collection|mixed
8169 */
82- protected $ _customerCollection ;
70+ protected $ orderCollection ;
71+
8372
8473 /**
74+ * Order constructor.
8575 * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
8676 * @param \Magento\Store\Model\StoreManagerInterface $storeManager
8777 * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory
8878 * @param \Magento\ImportExport\Model\ResourceModel\CollectionByPagesIteratorFactory $resourceColFactory
8979 * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
9080 * @param \Magento\Eav\Model\Config $eavConfig
91- * @param \Magento\Customer \Model\ResourceModel\Customer \CollectionFactory $customerColFactory
81+ * @param \Magento\Sales \Model\ResourceModel\Order \CollectionFactory $orderFactory
9282 * @param array $data
9383 */
9484 public function __construct (
@@ -98,9 +88,10 @@ public function __construct(
9888 \Magento \ImportExport \Model \ResourceModel \CollectionByPagesIteratorFactory $ resourceColFactory ,
9989 \Magento \Framework \Stdlib \DateTime \TimezoneInterface $ localeDate ,
10090 \Magento \Eav \Model \Config $ eavConfig ,
101- \Magento \Sales \Model \ResourceModel \Order \CollectionFactory $ customerColFactory ,
91+ \Magento \Sales \Model \ResourceModel \Order \CollectionFactory $ orderFactory ,
10292 array $ data = []
103- ) {
93+ )
94+ {
10495 parent ::__construct (
10596 $ scopeConfig ,
10697 $ storeManager ,
@@ -111,9 +102,7 @@ public function __construct(
111102 $ data
112103 );
113104
114- $ this ->_customerCollection = isset (
115- $ data ['customer_collection ' ]
116- ) ? $ data ['customer_collection ' ] : $ customerColFactory ->create ();
105+ $ this ->orderCollection = $ orderFactory ->create ();
117106
118107 $ this ->_initAttributeValues ()->_initStores ()->_initWebsites (true );
119108 }
@@ -125,33 +114,29 @@ public function __construct(
125114 */
126115 public function export ()
127116 {
128- $ this ->_prepareEntityCollection ($ this ->_getEntityCollection ());
129117 $ writer = $ this ->getWriter ();
130-
131- // create export file
132118 $ writer ->setHeaderCols ($ this ->_getHeaderColumns ());
133119 $ this ->_exportCollectionByPages ($ this ->_getEntityCollection ());
134-
135120 return $ writer ->getContents ();
136121 }
137122
138123 /**
139- * Get customers collection
140- *
141- * @return \Magento\Customer\Model\ResourceModel\Customer\Collection
124+ * {@inheritdoc}
142125 */
143- protected function _getEntityCollection ()
126+ protected function _getHeaderColumns ()
144127 {
145- return $ this ->_customerCollection ;
128+ $ validAttributeCodes = $ this ->_getExportAttributeCodes ();
129+ return array_merge ($ this ->_permanentAttributes , $ validAttributeCodes );
146130 }
147131
148132 /**
149- * {@inheritdoc}
133+ * Get customers collection
134+ *
135+ * @return \Magento\Customer\Model\ResourceModel\Customer\Collection
150136 */
151- protected function _getHeaderColumns ()
137+ protected function _getEntityCollection ()
152138 {
153- $ validAttributeCodes = $ this ->_getExportAttributeCodes ();
154- return array_merge ($ this ->_permanentAttributes , $ validAttributeCodes , ['password ' ]);
139+ return $ this ->orderCollection ;
155140 }
156141
157142 /**
@@ -162,34 +147,11 @@ protected function _getHeaderColumns()
162147 */
163148 public function exportItem ($ item )
164149 {
165- $ row = $ this ->_addAttributeValuesToRow ($ item );
166- $ row [self ::COLUMN_WEBSITE ] = $ this ->_websiteIdToCode [$ item ->getWebsiteId ()];
150+ $ row = $ item ->getData ();
167151 $ row [self ::COLUMN_STORE ] = $ this ->_storeIdToCode [$ item ->getStoreId ()];
168-
169152 $ this ->getWriter ()->writeRow ($ row );
170153 }
171154
172- /**
173- * Clean up already loaded attribute collection.
174- *
175- * @param \Magento\Framework\Data\Collection $collection
176- * @return \Magento\Framework\Data\Collection
177- */
178- public function filterAttributeCollection (\Magento \Framework \Data \Collection $ collection )
179- {
180- /** @var $attribute \Magento\Customer\Model\Attribute */
181- foreach (parent ::filterAttributeCollection ($ collection ) as $ attribute ) {
182- if (!empty ($ this ->_attributeOverrides [$ attribute ->getAttributeCode ()])) {
183- $ data = $ this ->_attributeOverrides [$ attribute ->getAttributeCode ()];
184-
185- if (isset ($ data ['options_method ' ]) && method_exists ($ this , $ data ['options_method ' ])) {
186- $ data ['filter_options ' ] = $ this ->{$ data ['options_method ' ]}();
187- }
188- $ attribute ->addData ($ data );
189- }
190- }
191- return $ collection ;
192- }
193155
194156 /**
195157 * EAV entity type code getter.
@@ -198,7 +160,7 @@ public function filterAttributeCollection(\Magento\Framework\Data\Collection $co
198160 */
199161 public function getEntityTypeCode ()
200162 {
201- return " sales_order " ; // $this->getAttributeCollection()->getEntityTypeCode();
163+ return $ this ->getAttributeCollection ()->getEntityTypeCode ();
202164 }
203165
204166 /**
0 commit comments