I’m Rameerez, the creator of digital startups like Hustl that are used by companies like Uber, Adobe and thousands of people around the globe. I’m now working on Guard, an AI that fights for your digital privacy. Follow me on social for behind the scenes updates!

TL;DR: Reasons may vary, but you can find the info you need to fix the error inspecting the current AJAX request with your browser’s developer tools. For me it was that because of the ordering of my Excel sheet I was trying to create a category before its parent had been created.

When it comes to Prestashop I have mixed feelings. It is an awesome platform for non-technical people to set up and manage a fully-featured, customizable online shop; but on the other side I’ve always felt it is so developer unfriendly.

Hard to find documentation, weird dev community, intricate architecture, incomprehensible errors and a vast number of variables and constants to set up… I feel like there is no reason for Prestashop to have such a steep learning curve. I might talk more in-depth about this on other post, but for now let’s get our hands dirty with an error that I’ve recently encountered working in a client’s project that has brought me ungodly amounts of frustration.

Shameless plug

On a side note, do you usually work with websites?

I made Edit, a Chrome extension that makes any website instantly editable with a single click – 100% live, no code required.

Thousands of users in 165+ countries around the world, among cool people at these amazing companies are already using some of my products

And just because you're already a reader of my blog, you can click here to get it now with a huge discount!

That's it, sorry for the shameless plug. Back to the post!

The Prestashop import error comes up when trying to import categories from a CSV or Excel sheet in Prestashop 1.7. It states nothing but:

Screen_Shot_2017-07-10_at_13_53_16.png
“Errors occurred: Technical error: Unexpected response returned by server. Import stopped.”

Which gives us close to no information at all about the error, even with debug mode enabled.

Turns out it’s just a poor error handling of AJAX requests and that the actual request holds the information we just might need to succeed.

Open up the developer tools (in Chrome: right click / Inspect) and head over the “Network” tab right before importing. There you should see all the AJAX requests that are being made “behind the scenes” by Prestashop. Click on start import and wait for the error to pop out.

When that happens, check out the last request in the list and look into the request “Preview” or “Response” tab:

Screen_Shot_2017-07-10_at_13_53_16.png

There you go! That’s the reason it wasn’t working.

If we check out the Excel list to import we see that in fact there was trying to assign a category to a parent that wasn’t created yet (it was far below it in the Excel sheet).

If we search for that error message in our Prestashop codebase:

Pasted_Image_10_07_2017__14_19.png
Prestashop’s classes/Category.php, around line 445

We see that, in fact, there is a function trying to calculate the current category to import depth and it throws an exception if it hasn’t been created yet.

Errors and fixing procedures may vary. It can be that your category name is too long, or that it contains weird characters that Prestashop may not like… just open up the developer tools, inspect the request and get the right info.

For me, the fix was obvious: I just ordered my Excel Sheet so that I create first 0-depth-level categories, then depth level 1 categories, and so on.

I tried commenting those 3 exception-related lines in Category.php and worked fine as well. That validation may not be necessary after all.


Picture: Clark Street Mercantile

Oh, and by the way!

I'm most active on Twitter and Instagram – follow me to stay in the loop.

But if you really wanna be above the average, join "The Hidden Report", my exclusive monthly newsletter, and get access to behind-the-scenes stories and confidential metrics. You'll get my secrets directly in your inbox, and you'll be the first one to know about private betas, free early releases and future launches!

Btw – no, I won't send spam, why would I do that. Plus, you can obviously unsubscribe anytime with a single click.

As a quick reminder – I'm Rameerez, an indie software developer that's making cool stuff used by people all around the world in 165+ countries, among cool people at companies like Google, Uber or Adobe. My work has been featured in media like Fast Company, Vox, The Next Web...

If you liked this post, make sure to follow me on social, subscribe to the newsletter and share this!

Leave a Reply