HummingbirdUK main logo

Coding solutions to business problems

About us

We use code to create solutions to business challenges, bottle-necks and headaches.

If you think your business has a problem that can be solved through code, we are happy to chat things through without any obligation.

Get in touch

Imported products in Magento never appear

Home / Blog / Imported products in Magento never appear

Written by Giles Bennett

A slight head-scratcher this afternoon. Was working on the initial stages of a very big product import for a new site. The import appeared to go well - initial data check passed, and when imported Magento said that the import had been completed with no errors. Instead of the 1050 or so products I was expecting, however, there were just under 1000 in Catalogue -> Manage Products. So despite the import completing there were clearly some imported products missing. So where had the others gone?

A little bit of digging. system.log revealed :

ERR (3): Notice: iconv_strlen() [<a href='function.iconv-strlen'>function.iconv-strlen</a>]: Detected an illegal character in input string  in /home/mysite/public_html/app/code/Mage/Core/Helper/String.php on line 81

OK, so, an illegal character. Not massively helpful, though - short of having to export the products, then run a comparison of the SKUs in one list against the SKUs in the other, was there a better way of finding out what was causing the hiccup? Leaving aside, of course, the fact that it's not massively helpful for Magento to tell me that the product(s) had been imported when they hadn't been.

So, I created a local copy of the file in question at

/home/mysite/public_html/app/code/local/Mage/Core/Helper/String.php

and looked at the offending bit of code :

public function cleanString($string)
{
    return '"libiconv"' == ICONV_IMPL ?
        iconv(self::ICONV_CHARSET, self::ICONV_CHARSET . '//IGNORE', $string) : $string;

}

A security step to ensure that no nasty scripts get through, at a guess - so next step is to see if enhancing the log would help - inserting at the top of the function :

Mage::log($string);

...then running the import again, and checking system.log afterwards. Sure enough, the entire contents of the product's entry in the CSV were dumped, with the error message after the offending cell :

2013-04-25T12:47:35+00:00 DEBUG (7): Origination charges are only on 4 col process. The charge is £80 for 1 design and £20 for every design thereafter. 1 colour COSTS: 500: £64.87 1000: £90.82 5000: £52.65 10000: £43.41.
2013-04-25T12:47:35+00:00 ERR (3): Notice: iconv_strlen() [<a href='function.iconv-strlen'>function.iconv-strlen</a>]: Detected an illegal character in input string  in /home/mysite/public_html/app/code/local/Mage/Core/Helper/String.php on line 81

So - looked like it was the pound sign. A quick find

£
and replace it with
&pound;
, run the import again, and sure enough, the products appear as they should. Nice and easy.

Author : Giles Bennett

About the author

Giles Bennett built his first website in 1996, and is old enough to miss Netscape Navigator. Initially a lawyer, he jumped ship to IT in 2008, and after 5 years as a freelancer, he founded HummingbirdUK in 2013. He can be reached by email at giles@hummingbirduk.com.