Developer forum

Forum » Ecommerce - Standard features » Add to favorites link

Add to favorites link

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I have recently uograded a project to the latest 9.13 and also added a new language to the solution.

Suddenly, after this change, the add to favorites is not working anymore.

I get this error: 

Cannot insert the value NULL into column 'ProductLanguageId'

I have tried adding various parameters to the URL for the language but nothing works. And the default template tag for the add to favorites does not seem to include any Language information.

Any idea?

Thank you,

Adrian

 


Replies

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Anybody?

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

If you sue this command: ?FavoriteCmd=addproducttofavoritelist

You can use these parameters:

  • ProductId
  • ProductVariantId
  • FavoriteListId
  • Note
  • quantity

Language cannot be set.

The code inserts string.empty in the ProductLanguageId column - we do not use that column any more.

So that exception seems odd. 

How do your add to cart link look like with all parameters?

Also you can change the ProductLanguageId colum on the table to allow null.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

I was using the old add to favorites link returned by the TemplateTags.

I can surely change the column to allow nulls if it's not used anymore.

Thank you.
Adrian

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Adrian,

 

Did this work for you? I am trying to do the same in a database that has been updated since DW8 and I notice that ProductLanguageId is part of the primary key, so it cannot allow nulls.

 

Best Regards,

Nuno Aguiar

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nuno,

Unfortunately, it did not work. We had to change the entire logic to use the new approach.

We'll have to revisit all projects that use the old method.

Adrian

 

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Ugh... Ok. We'll do the same, thanks

 
Mikkel Hammer
Mikkel Hammer
Reply

We've actually run into this issue not long ago where updating the database did work with this:
ALTER TABLE [EcomCustomerFavoriteProducts] ALTER COLUMN [ProductLanguageId] NVARCHAR(50) NULL;

It seems that the change in Application/Admin/Update/ecom.xml.aspx for version "2235" hadn't taken in effect in our database even though we were on a much higher version.

Looking at https://doc.dynamicweb.com/get-started/introduction/installation-dw9/update-script, im not sure by the text "Change the "updates.xml.aspx" field to 2000 - this means that all update scripts from that file/database version will be re-applied if not applied already", if the script only runs for same version you're on or for all the past versions aswell..
If it's only the current one, doesn't that mean it didn't take effect because we upgraded past that version?

Best regards,
Mikkel Hammer

 
Scott Forsyth Dynamicweb Employee
Scott Forsyth
Reply

Good timing since we just ran into this same issue. After looking into it, I see that the primary key name on our site didn't line up with the update script, causing it to fail.

It's from update 2235, 3/16/22. Here's the command:

                    ALTER TABLE [EcomCustomerFavoriteProducts] DROP CONSTRAINT [DW_PK_EcomCustomerFavoriteProducts];

                    ALTER TABLE [EcomCustomerFavoriteProducts] ADD CONSTRAINT [DW_PK_EcomCustomerFavoriteProducts] PRIMARY KEY NONCLUSTERED (
                    [FavoriteListId] ASC,
                    [ProductId] ASC,
                    [ProductVariantId] ASC
                    );
                    ALTER TABLE [EcomCustomerFavoriteProducts] ALTER COLUMN [ProductLanguageId] [nvarchar](50) NULL;
 
 
For us, the issue was that our primary key was named PK__EcomCustomerFavo__743A1EC7. That's our dev instance. In production, it's PK__EcomCust__E84A6639C694A42A. I checked a couple other databases and they are correctly set to DW_PK_EcomCustomerFavoriteProducts. I bet there's some legacy consideration going on.
 
To fix it, I found the name of the primary key on the EcomCustomerFavoriteProducts table and manually ran the script. For example:
 

                    ALTER TABLE [EcomCustomerFavoriteProducts] DROP CONSTRAINT [PK__EcomCust__E84A6639C694A42A];

                    ALTER TABLE [EcomCustomerFavoriteProducts] ADD CONSTRAINT [DW_PK_EcomCustomerFavoriteProducts] PRIMARY KEY NONCLUSTERED (
                    [FavoriteListId] ASC,
                    [ProductId] ASC,
                    [ProductVariantId] ASC
                    );
                    ALTER TABLE [EcomCustomerFavoriteProducts] ALTER COLUMN [ProductLanguageId] [nvarchar](50) NULL;
 
Running that manually updated the database to the expected settings.
 
Thanks,
Scott
 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Scott,

Perfect timing indeed :)

Thank you for the suggested fix. Hopefully we won't need to update the templates on all our (older) implementations.

Adrian

 

You must be logged in to post in the forum