avstudnitz / AvS_FastSimpleImport

Wrapper for Magento ImportExport functionality, which imports products and customers from arrays
306 stars 146 forks source link

Call to undefined method Mage_Core_Helper_Data::unEscapeCSVData() #411

Open Triyugi opened 7 years ago

Triyugi commented 7 years ago

I am getting following error:

Call to undefined method Mage_Core_Helper_Data::unEscapeCSVData() in /var/www/html/app/code/community/AvS/FastSimpleImport/Model/Import/Entity/Category.php on line 1276.

How it can be resolved. Is it related to SUPEE-7405?

Triyugi commented 7 years ago

This issue I was getting on Magento 1.9.2.2 because there is no unEscapeCSVData method in app/code/core/Mage/Core/Helper/Data.php.

Create a local Data.php and add two methods from Magento 1.9.2.4 as below:

     public function getEscapedCSVData(array $data)
     {
         if (Mage::getStoreConfigFlag(Mage_ImportExport_Model_Export_Adapter_Csv::CONFIG_ESCAPING_FLAG)) {
             foreach ($data as $key => $value) {
                 $value = (string)$value;

                 $firstLetter = substr($value, 0, 1);
                 if ($firstLetter !== false and in_array($firstLetter, array("=", "+", "-"))) {
                     $data[$key] = ' ' . $value;
                 }
             }
         }
         return $data;
     }

     public function unEscapeCSVData($data)
     {
         if (is_array($data) and Mage::getStoreConfigFlag(Mage_ImportExport_Model_Export_Adapter_Csv::CONFIG_ESCAPING_FLAG)) {

             foreach ($data as $key => $value) {
                 $value = (string)$value;

                 if (preg_match("/^ [=\-+]/", $value)) {
                     $data[$key] = ltrim($value);
                 }
             }
         }
         return $data;
     }

And then I have to define CONFIG_ESCAPING_FLAG in app/code/local/ImportExport/Model/Import/Adapter/Csv.php and in app/code/local/ImportExport/Model/Export/Adapter/Csv.php as below:

class Mage_ImportExport_Model_Export_Adapter_Csv extends Mage_ImportExport_Model_Export_Adapter_Abstract
{
const CONFIG_ESCAPING_FLAG = 'system/export_csv/escaping';
avstudnitz commented 7 years ago

This is not resolved as it is only solved locally.

Triyugi commented 7 years ago

@avstudnitz Then, what should I do?

avstudnitz commented 7 years ago

Either provide a pull request, or do nothing and wait until someone else provides a fix which can be included in the module.

hostep commented 7 years ago

@Triyugi: you are correct, it is related to SUPEE-7405. The code was introduced in this PR: https://github.com/avstudnitz/AvS_FastSimpleImport/pull/278

Have you installed SUPEE-7405 on your Magento 1.9.2.2 installation? If not, then please install it, it should fix the problem (and please install all the other security patches as well which you might not have installed yet).