Jump to content

[SOLVED] Error occurred while creating object product


Recommended Posts

Hi!
I have encountered as the title said: an error occurred while creating object product when i try to add a new product in backoffice.

Its possible to add new categories but not new product, im also Not able to duplicate products?

Been reading around here, and found no good answers unfortunatly appreciate all help, can also offer a small amount if a working solution is found. Also tried all kinds of different product names so this cant be the matter.

Please do get back if you can offer some kind of help, getting desperate here!

Thanks

Link to comment
Share on other sites

Thnx for the reply, problem solved. It was ps_product and ps_product_lang tables that didnt match wich caused the problem. Manually corrected all entries then everything works fine.


Hi Tobias,

Could you please explain to me what you did to solve this problem?

Please.

Thanks
Link to comment
Share on other sites

  • 1 month later...
Thnx for the reply, problem solved. It was ps_product and ps_product_lang tables that didnt match wich caused the problem. Manually corrected all entries then everything works fine.


Hi Tobias,

Could you please explain to me what you did to solve this problem?

Please.

Thanks


Yes please.
I have a similar problem.I uploaded the shop to my hosting and I cannot duplicate items.
But I could duplicate them working "locally"...
Any help is welcome.
Thanks
Link to comment
Share on other sites

  • 1 month later...

Hi, I have the same problem as Tobias described at the beginning. I have 67 products in various categories and I can't add new product or duplicate it (I can add categories for instance). I get the same error: "Error occurred while creating object product". I use prestashop v.1.2.2 and I wonder if the update into 1.3.1 would solve the problem. As shopgirl wrote above the problem still exists, even in 1.3.1 So, I don't know what to do. Tobias suggests to fix the problem with 'product' and 'product_lang' tables. I don't know what is the problem with these tables and what is more I wonder if this fix solves the problem for good or not. If the fix has to be repeated from time to time because the relation between tables is spoiled by certain operation in the shop, such solution is useless. Does somebody know where is the problem and how to solve it ?
Thanks in advance.

Link to comment
Share on other sites

From prestashop page:

-------------------------------------------
System requirements:
* - Linux, Unix, or Windows
* - Web Server (Apache 1.3 or later, IIS 6 or later)
* - PHP 5.0* or later
* - MySQL 5** or later

** PrestaShop is working from MySQL 4.1.14 to 5.0 too but some features are not working (e.g., product duplication) or have strange behaviors
------------------------------------------

I use MySQL 5.0.9. In my case there is also problem with common adding new products to the category not only with duplication. Moreover, the duplication and creating new product have worked till now and has stopped to work suddenly.

Link to comment
Share on other sites

I've found following changes in CHANGELOG between 1.2.2 and 1.3.1

Classes : Fixed bug #2988 - Added several methods in order to better clean the DB while deleting a product
BO : fixed bug duplicating product with image (#2862)
Classes : fixed bug while duplicating product without tags (#2860). Thanks to Victor Berchet !

That's interesting what problems could happen wihtout these correction. Maybe badly performed duplication hasn't copied all relations correctly what has caused my problem. Has somebody met similar problem ?

shopgirl, thanks for quick and useful response! Maybe it's really problem with database and mysql 5.0 isn't good enough and we really need to use 5.2 (it would mean mistake on http://www.prestashop.com/en/downloads). It's a next issue to check.

Link to comment
Share on other sites

  • 3 weeks later...

The thread is marked solved because there was a known issue in product image duplication that was fixed in the latest version of PrestaShop. Unfortunately, that won't work for you, since you are using MySQL 5.0, which has known product duplication problems. You should upgrade to a newer version of MySQL.

Link to comment
Share on other sites

  • 1 month later...

It seems it is an issue with MYSQL 4.1. Because Prestashop was developed with MYSQL 5 in mind, you have to hack the code to make it work.

Basically, the problem comes from a MYSQL QUERY which does not work on MYSQL 4.1. Basically the INSERT query includes a variable which refers to a SELECT QUERY.
In my opinion, MYSQL 4.1 does not support such queries which make Prestashop pretty unstable on MYSQL 4.xx versions.

Maybe there are some other queries to correct to make it work correctly on every MYSQL version.

It is in the file Classes/Category.php
You have to modify the code of the function duplicateProductCategories.

To make it work, replace the function duplicateProductCategories with this code:

    public static function duplicateProductCategories($id_old, $id_new)
   {
       $result = Db::getInstance()->ExecuteS('
       SELECT `id_category`
       FROM `'._DB_PREFIX_.'category_product`
       WHERE `id_product` = '.intval($id_old));

       $row = array();
       if ($result)
           foreach ($result AS $i){
               $data = '(SELECT (tmp.max + 1) AS newpos FROM (SELECT MAX(cp.`position`) AS max FROM `'._DB_PREFIX_.'category_product` cp WHERE cp.`id_category`='.intval($i['id_category']).') AS tmp)';
                       $result = Db::getInstance()->getRow($data);
               $maxpos = $result['newpos'];
               $row[] = '('.implode(', ', array(intval($id_new), $i['id_category'], $maxpos)).')';

           }
       $flag = Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'category_product` (`id_product`, `id_category`, `position`) VALUES '.implode(',', $row));
       return $flag;
   }



At least, it works for me! Duplicate product is operational!
Please report if that hack works for you.

Link to comment
Share on other sites

  • 4 weeks later...
  • 3 months later...
  • 3 years later...

Hi,
I resolve this error by enabling dev mode on config/defines.inc.php:
define('_PS_MODE_DEV_', true);

After this I discover that my problem was the field date_add from table categories that is required.

Remove the requirement from DB table, and everything works fine.
Hope it helps

Link to comment
Share on other sites

  • 6 months later...
×
×
  • Create New...