1

I was following the steps shown Here to add sample data to my magento site for testing then i got this error stack below:

It was the last part of the installation where i executed this command: php <your Magento install dir>/bin/magento setup:upgrade

 Installing data... PHP Fatal error:  Uncaught Error: Call to a member function getDataByKey() on null in C:\xampp\htdocs\Magento\magento2-sample-data\app\code\Magento\SalesSampleData\Model\Order\Converter.php:191
    Stack trace:
    #0 C:\xampp\htdocs\Magento\magento2-sample-data\app\code\Magento\SalesSampleData\Model\Order\Converter.php(171): Magento\SalesSampleData\Model\Order\Converter->getProductAttributes(Array)
    #1 C:\xampp\htdocs\Magento\magento2-sample-data\app\code\Magento\SalesSampleData\Model\Order\Converter.php(76): Magento\SalesSampleData\Model\Order\Converter->convertProductData(Array)
    #2 C:\xampp\htdocs\Magento\magento2-sample-data\app\code\Magento\SalesSampleData\Model\Order.php(101): Magento\SalesSampleData\Model\Order\Converter->convertRow(Array)
    #3 C:\xampp\htdocs\Magento\magento2-sample-data\app\code\Magento\SalesSampleData\Setup\Installer.php(30): Magento\SalesSampleData\Model\Order->install(Array)
    #4 [internal function]: Magento\SalesSampleData\Setup\Installer->install()
    #5 C:\xampp\htdocs\Magento\vendor\magento\framework\App\State in C:\xampp\htdocs\Magento\magento2-sample-data\app\code\Magento\SalesSampleData\Model\Order\Converter.php on line 191

    Fatal error: Uncaught Error: Call to a member function getDataByKey() on null in C:\xampp\htdocs\Magento\magento2-sample-data\app\code\Magento\SalesSampleData\Model\Order\Converter.php:191
    Stack trace:
    #0 C:\xampp\htdocs\Magento\magento2-sample-data\app\code\Magento\SalesSampleData\Model\Order\Converter.php(171): Magento\SalesSampleData\Model\Order\Converter->getProductAttributes(Array)
    #1 C:\xampp\htdocs\Magento\magento2-sample-data\app\code\Magento\SalesSampleData\Model\Order\Converter.php(76): Magento\SalesSampleData\Model\Order\Converter->convertProductData(Array)
    #2 C:\xampp\htdocs\Magento\magento2-sample-data\app\code\Magento\SalesSampleData\Model\Order.php(101): Magento\SalesSampleData\Model\Order\Converter->convertRow(Array)
    #3 C:\xampp\htdocs\Magento\magento2-sample-data\app\code\Magento\SalesSampleData\Setup\Installer.php(30): Magento\SalesSampleData\Model\Order->install(Array)
    #4 [internal function]: Magento\SalesSampleData\Setup\Installer->install()
    #5 C:\xampp\htdocs\Magento\vendor\magento\framework\App\State in C:\xampp\htdocs\Magento\magento2-sample-data\app\code\Magento\SalesSampleData\Model\Order\Converter.php on line 191
2
  • You installed Magento 2 via composer or a different way?
    – camdixon
    Nov 3 '16 at 17:43
  • via composer, correct
    – Callum
    Nov 4 '16 at 9:07
0

I faced this issue while running Linux virtual box on Windows. Sample-data csv files had CRLF endings, so they were incorrectly processed. I installed sample data via Git. Following commands helped me:

cd <path_to_sample_data>

git config core.autocrlf false

git reset --hard HEAD

Alternatevily you can run

cd <path_to_magento2>/vendor/magento

find ./ -type f -exec dos2unix {} \;

This problem was also discussed there

https://github.com/magento/magento2/issues/2400

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.