Jump to content

Import csv error


Recommended Posts

Hello

Im trying to import from an cvs file made by my supplier but i get an error. It imports me some of the products but not all of them. the error is:

[PrestaShopException]

Property FeatureValue->value length (263) must be between 0 and 255
at line 954 in file classes/ObjectModel.php

949. }
950.
951. $message = $this->validateField($field, $value, $id_lang);
952. if ($message !== true) {
953. if ($die) {
954. throw new PrestaShopException($message);
955. }
956. return $error_return ? $message : false;
957. }
958. }
959. }
  • ObjectModelCore->validateFieldsLang - [line 295 - classes/ObjectModel.php]
    290. // Backward compatibility
    291. if (method_exists($this, 'getTranslationsFieldsChild')) {
    292. return $this->getTranslationsFieldsChild();
    293. }
    294.
    295. $this->validateFieldsLang();
    296. $is_lang_multishop = $this->isLangMultishop();
    297.
    298. $fields = array();
    299. if ($this->id_lang === null) {
    300. foreach (Language::getIDs(false) as $id_lang) {
  • ObjectModelCore->getFieldsLang - [line 511 - classes/ObjectModel.php]
    506. return false;
    507. }
    508.
    509. // Database insertion for multilingual fields related to the object
    510. if (!empty($this->def['multilang'])) {
    511. $fields = $this->getFieldsLang();
    512. if ($fields && is_array($fields)) {
    513. $shops = Shop::getCompleteListOfShopsID();
    514. $asso = Shop::getAssoTable($this->def['table'].'_lang');
    515. foreach ($fields as $field) {
    516. foreach (array_keys($field) as $key) {
  • ObjectModelCore->add - [line 178 - classes/FeatureValue.php] - [2 Arguments]
    173. return (int)$feature_value->id;
    174. }
    175.
    176. public function add($autodate = true, $nullValues = false)
    177. {
    178. $return = parent::add($autodate, $nullValues);
    179. if ($return) {
    180. Hook::exec('actionFeatureValueSave', array('id_feature_value' => $this->id));
    181. }
    182. return $return;
    183. }
  • FeatureValueCore->add - [line 171 - classes/FeatureValue.php]
    166. // Feature doesn't exist, create it
    167. $feature_value = new FeatureValue();
    168. $feature_value->id_feature = (int)$id_feature;
    169. $feature_value->custom = (bool)$custom;
    170. $feature_value->value = array_fill_keys(Language::getIDs(false), $value);
    171. $feature_value->add();
    172.
    173. return (int)$feature_value->id;
    174. }
    175.
    176. public function add($autodate = true, $nullValues = false)
  • FeatureValueCore::addFeatureValueImport - [line 1874 - controllers/admin/AdminImportController.php] - [5 Arguments]
    1869. $id_feature = (int)Feature::addFeatureImport($feature_name, $position);
    1870. $id_product = null;
    1871. if ($force_ids || $match_ref) {
    1872. $id_product = (int)$product->id;
    1873. }
    1874. $id_feature_value = (int)FeatureValue::addFeatureValueImport($id_feature, $feature_value, $id_product, $id_lang, $custom);
    1875. Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value);
    1876. }
    1877. }
    1878. }
    1879. // clean feature positions to avoid conflict
  • AdminImportControllerCore->productImport - [line 3503 - controllers/admin/AdminImportController.php]
  • AdminImportControllerCore->postProcess - [line 178 - classes/controller/Controller.php]
    173. if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className))) {
    174. $this->setMedia();
    175. }
    176.
    177. // postProcess handles ajaxProcess
    178. $this->postProcess();
    179.
    180. if (!empty($this->redirect_after)) {
    181. $this->redirect();
    182. }
    183.
  • ControllerCore->run - [line 367 - classes/Dispatcher.php]
    362. if (isset($params_hook_action_dispatcher)) {
    363. Hook::exec('actionDispatcher', $params_hook_action_dispatcher);
    364. }
    365.
    366. // Running controller
    367. $controller->run();
    368. } catch (PrestaShopException $e) {
    369. $e->displayMessage();
    370. }
    371. }
    372.
  • DispatcherCore->dispatch - [line 58 - admin/index.php]
    53. if (!isset($_REQUEST['controller']) && isset($_REQUEST['tab'])) {
    54. $_REQUEST['controller'] = strtolower($_REQUEST['tab']);
    55. }
    56.
    57. // Prepare and trigger admin dispatcher
    58. Dispatcher::getInstance()->dispatch();

thanks in advance.

Link to comment
Share on other sites

Seems rather clear to me 

Property FeatureValue->value length (263) must be between 0 and 255

So you are trying to add a feature value that is too long. 

 

You can edit the feature values so that they are all shorter than 255.

 

What I did myself was changing the length of the value field in the ps_feature_value_lang table. It worked for me. But of course it is a hack that you implement at your own risk.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...