skip to Main Content

I am following the tutorial Create a custom import entity . However, instead of importing learning courses as shown in the tutorial, I’m attempting to import orders.

To adapt the tutorial for orders, I made the following changes:

- const TABLE = 'learning_courses';
+ const TABLE = 'sales_order';

and

- protected $validColumnNames = [
        'entity_id',
        'name',
        'duration'
    ];

+ protected $validColumnNames = [
'entity_id',
'state',
'status',
'coupon_code',...];

After making these changes, I encountered an issue where the $bunch variable still holds the old CSV data, even when using a CSV file adapted to the sales_order attributes:
$bunch = $this->_dataSourceModel->getNextBunch()

i tried adding $this->_dataSourceModel->cleanProcessedBunches(); before the while loop, this change successfully updates the data for the first iteration, but subsequently, the back office freezes.

I would appreciate any insights or suggestions on how to resolve this issue.

2

Answers


  1. You can try deleting the data in the importexport_importdata table.
    The issue will be resolved.

    Login or Signup to reply.
  2. Instead of $bunch = $this->_dataSourceModel->getNextBunch() you can use getNextUniqueBunch($ids = null). This method will only retrieve the next unique bunch of validated rows. All you have to do is pass the ids of the validated rows to this method. You can get them by executing getIds() method on the import class.

    It should look something like this: $bunch = $this->_dataSourceModel->getNextUniqueBunch($this->getIds()). In my case it solved the problem completely.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search