Issues with custom import of orders in Magento 2.4.6 (Adobe Commerce)

Issues with custom import of orders in Magento 2.4.6 (Adobe Commerce)

September 24, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Issues with custom import of orders in Magento 2.4.6 (Adobe Commerce)

Resolving Custom Order Import Issues in Magento 2.4.6

As a developer working with Adobe Commerce (Magento), you may find that while the official tutorials provide valuable insights, they don’t always cover edge cases like importing orders instead of learning courses. In this post, we’ll discuss the challenges faced when adapting the “Create Custom Import Entity” tutorial for order imports and provide a step-by-step solution.

Understanding the Core Issue

When you attempt to adapt the tutorial for order imports, you encounter a specific freeze issue in the Magento backend. This is primarily due to how the getNextBunch() method handles the data flow between the CSV file and the import process.

The core problem lies in the way the cleanProcessedBunches() method interacts with the getNextBunch() call. While adding this line before the while loop cleans up the processed data for the first iteration, it doesn’t handle subsequent iterations efficiently, leading to a freeze when the second bunch of data is fetched.

A Comprehensive Solution

To resolve this issue effectively, we need to refactor the way the import process handles the CSV file and the processed batches. Here’s a step-by-step approach that avoids the freezing problem:

  1. Refactor the Data Source Model The SalesOrderImportDataSource model needs an additional method to handle the cleanup of processed bunches more efficiently.

    class SalesOrderImportDataSource extends \Magento\ImportExport\Model\ResourceModel\Container\AbstractContainer
    {
        //... existing code ...
    
        public function cleanProcessedBunches()
        {
            $this->getSelect()->reset(\Zend_Db_Select::COLUMNS);
            $this->getSelect()->columns($this->getValidColumnNames());
        }
    }
    
  2. Update the Import Model In your custom SalesOrderImport model, you need to modify the way you fetch and process the CSV data.

    class SalesOrderImport extends \Magento\ImportExport\Model\Import\Entity
    {
        //... existing code ...
    
        protected function _getEntities()
        {
            $this->_dataSourceModel->cleanProcessedBunches();
            return parent::_getEntities();
        }
    
        protected function getValidColumnNames()
        {
            return [
                'entity_id',
                'state',
                'status',
                'coupon_code',
                //... other valid column names
            ];
        }
    }
    
  3. Optimize the Import Process To prevent the backend from freezing, you need to ensure that the import process handles each batch efficiently.

    • When working with large CSV files, consider breaking them into smaller chunks before importing.
    • Use Magento’s built-in log and exception handling mechanisms to monitor the import progress and identify any bottlenecks or errors.

Best Practices for Custom Imports

While this solution addresses the specific issue you encountered, it’s essential to follow best practices when working with custom imports in Adobe Commerce:

  • Thoroughly test your import functionality with a variety of data sets to ensure stability.
  • Monitor system resources during imports to prevent performance degradation.
  • Regularly clean up imported data and associated log files to maintain optimal database performance.

Conclusion

Adapting the Magento tutorial for order imports requires careful consideration of how the built-in import mechanisms handle data flow. By refactoring the Data Source Model and optimizing the Import Model, you can resolve the freezing issue and create a more robust solution for custom order imports.

Remember that working with Adobe Commerce (Magento) often involves understanding its core mechanisms to adapt them effectively to your specific needs. Always refer to the official documentation and Magento Stack Exchange for further guidance.

For more insights into Magento 2 development and best practices, feel free to explore our blog at Laravel Company. We cover a wide range of topics related to eCommerce development and Magento optimization.

Happy coding!

Magento 2 Adobe Commerce Admin Orders

Our network