Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Creating new Product_option entity. #147

Closed
RCallejo2 opened this issue Jun 27, 2015 · 5 comments
Closed

Error Creating new Product_option entity. #147

RCallejo2 opened this issue Jun 27, 2015 · 5 comments
Assignees
Labels

Comments

@RCallejo2
Copy link

I am gettin the attachedd error when trying to create a new Product_option entity.
Any Suggestion?

<![CDATA[[SQL Error] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 3. From AttributeGroupCore->setWsProductOptionValues() Query was :

        DELETE FROM `ps_attribute`

        WHERE `id_attribute_group` = 8

        AND `id_attribute` NOT IN ()]]></message>
@RCallejo2
Copy link
Author

I have seen this answer but I do not know how to resolve it. The error happens also when trying to update.

"This problem is due to the PrestaShop webservice. "NOT IN()" needs at least one element.
The exception is thrown when you try to add the first product_option instance in the database.
Best regards."

@RCallejo2
Copy link
Author

I correct myself. Trying to update it works ok.
The error still continues when trying to add new product_ontion in all the cases.

@citrusO2
Copy link

Could it be that you are using more than one language in your shop? I had a similar error once when I tried to add a new product feature value. The shop was configured to take German and English, but when adding a product feature value with just an English value without the German one it returned a strange error, which did not hint the actual problem.

This would somewhat explain why updating is possible but not creating.

----- Ursprüngliche Nachricht -----
Von: "RCallejo2" notifications@github.com
Gesendet: ‎28.‎06.‎2015 10:29
An: "Bukimedia/PrestaSharp" PrestaSharp@noreply.github.com
Betreff: Re: [PrestaSharp] Error Creating new Product_option entity. (#147)

I correct myself. Trying to update it works ok.
The error still continues when trying to add new product_ontion in all the cases.

Reply to this email directly or view it on GitHub.

@RCallejo2
Copy link
Author

Thanks a lot for your comments.
The problem happens when adding a new product_option.
If I try to add a new product_option_value it works fine.

@EduLeonPavon EduLeonPavon self-assigned this Jun 29, 2015
@EduLeonPavon
Copy link
Member

Hello,

This is our workaround. I hope you find it useful.

Best regards.

internal void AddProductOption(Bukimedia.PrestaSharp.Entities.product_option product_option)
        {
            bool flag = true;
            while (flag)
            {
                try
                {
                    lock (this.ProductOptionFactory)
                    {
                        this.ProductOptionFactory.Add(product_option);
                    }
                    flag = false;
                }
                catch (Bukimedia.PrestaSharp.PrestaSharpException ex)
                {
                    if (ex.ResponseHttpStatusCode == 0)
                    {
                        this.CatalogMemory.Logger.LogErrorStampNewLine("Se reinició la conexión. Añadiendo opción de producto.");
                    }
                    else
                    {
                        //Hack para problema con creación de ProductOptions.
                        if (ex.ResponseHttpStatusCode == System.Net.HttpStatusCode.InternalServerError)
                        {
                            flag = false;
                        }
                        else
                        {
                            this.CatalogMemory.Logger.LogErrorStampNewLine("Se produjo un error con la conexión al servicio web. Se reintentará la conexión en 5 minutos. " + Environment.NewLine + ex.ToString());
                            Thread.Sleep(300000);
                        }
                    }
                }
                catch (Exception ex)
                {
                    string ProductOptionName = ((Bukimedia.PrestaSharp.Entities.AuxEntities.language)(from Lan in product_option.name
                                                                                                 where Lan.id == CatalogMemory.GetLanguageIdToCompare()
                                                                                                 select Lan).Single<Bukimedia.PrestaSharp.Entities.AuxEntities.language>()).Value;
                    this.CatalogMemory.Logger.LogErrorStampNewLine("Se produjo un error con la conexión al servicio web. Se reintentará la conexión en 5 minutos. Nombre de la opción de producto: " + ProductOptionName + Environment.NewLine + ex.ToString());
                    Thread.Sleep(300000);
                }
            }
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants