1

There are only 3 products in the catalog, when I try to export them using

System -> Import/Export -> Export

I get this error:

Fatal error: Call to undefined method Mage_ImportExport_Model_Export_Adapter_Csv::getRowsCount() in /app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php on line 575

According to the host it seems to be an issue with 'autoload', I should check the path or do a clean instal.

What is autoload and what path should I check? Or what else could be the problem?

1

TL;DR: I'm quite sure you upgraded from a Magento version equal or lower than 1.9.2.4 to a version equal or greater than 1.9.3.0 and that you overridden Mage_ImportExport_Model_Export_Adapter_Abstract in your local file space. So you will have to identify the changes and bring them into an updated version of Mage_ImportExport_Model_Export_Adapter_Abstract.

First, let's clarify what the error message tells us:

The error message says that the method getRowsCount() could not be found (i.e. is not available) within either the class

Mage_ImportExport_Model_Export_Adapter_Csv

(i.e. file app/code/core/Mage/ImportExport/Model/Export/Adapter/Csv.php) or any class it extends - in this case this would be the class

Mage_ImportExport_Model_Export_Adapter_Abstract

(i.e file app/code/core/Mage/ImportExport/Model/Export/Adapter/Abstract.php).


Now, since we know that, we can take a short look at the history of Magento 1.9.x and especially the difference between 1.9.2.4 and 1.9.3.0.

The method getRowsCount() was introduced in version 1.9.3.0:

Also, this method (rather obviously) was not used in app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php before Magento version 1.9.3.0.


Last but not least, let's bring this together with common mistakes made either while upgrading a store or when extending Magento core functionality in a way not considered as "best practice":

An abstract class can not be overwritten directly. This means, if you'd like to change a certain method defined within an abstract class, Magento wont allow you to create a custom module and override it. Rather than this you would need to override a class that is extending the abstract class (see above, rather than overriding Mage_ImportExport_Model_Export_Adapter_Abstract you would need to override Mage_ImportExport_Model_Export_Adapter_Csv).

However, there is another way to modify functionality of Magento - which is not considered best practice because exactly the issue you're experiencing now can easily occur after an upgrade:

You could copy app/code/core/Mage/ImportExport/Model/Export/Adapter/Abstract.php to app/code/local/Mage/ImportExport/Model/Export/Adapter/Abstract.php and do your changes in this new file. Doing so will tell Magento to always use this file in the local file space rather than the one located at the core file space. At the time of an upgrade this will - in case the original core file is changed (i.e. a new method is introduced) - create the problem, that this new class is not present in the local copy, hence it can not be found.


To solve your problem you got basically two options - where the first step is common for both anyway:

Step 1:

You will have to identify the initial changes (the changes between the original pre-1.9.3.0 app/code/core/Mage/ImportExport/Model/Export/Adapter/Abstract.php file and app/code/local/Mage/ImportExport/Model/Export/Adapter/Abstract.php) to see, what was changed back than.

Then you need to check for changes between pre-1.9.3 app/code/core/Mage/ImportExport/Model/Export/Adapter/Abstract.php and post-1.9.3 app/code/core/Mage/ImportExport/Model/Export/Adapter/Abstract.php (i.e. your current version)

The result of these two checks must be that you know, what were manual changes to this file and what changes were done by the upgrade.

Step 2:

You could now go on with the local copy of the Abstract.php file. For this you'll have to copy the new version of the core file and add the manual changes you have identified via step 1 again. This however can create the very same problem in a future upgrade again if the same file again gets updated.

Another option (= the better option) is to create a custom module that extends the original Abstract.php. This would be considered best practice as it is way more update-proof than then other way.



References on these topics:

Autoload/autoloading is basically the concept of not having to include or require classes form other files (since this can mean that at one point you first of all have to include hundreds of files before your actual code starts):

Overriding classes in Magento:

Crating a custom module for Magento:

  • 1
    Thank you for your very detailed response. As it turned out, there was a local abstract overriding the core files. It was set up on the host's recommendation to specify the export path. After I deleted the local file the export is working as it should. – Andras Feb 5 '18 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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