Nop Commerce 3.0 - Product Table insert problems with sql script

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
10 years ago
Hi,

I did a small program importing data into my nop commerce web site. The program do an insert into, product, product_variant, Product_Manufacturer_Mapping, Product_Picture_Mapping and I am using a the manufacturer picture per default.

The program was working well with version 2.80 and now when I am using my program the import going well but when I check on the web site the picture and the text link on the grid doesn't work anymore. Then, if I go into manage product in admin section and I simply load the product and save it .. all the links working. I did a SQL trace and I didn't see anything special from this save than my save on my program. It seems that between the version 2.8 and the version 3.0 something changed and I am wondering what it could be..a new table or a new key ..
if anyone have an idea it will be greatly appreciated

Yves
10 years ago
I would bet this has to do with the URL table.  You need to insert a record into the URLRecord table for each product, category, & manufacturer you load in through SQL.  Opening the item in the admin site and saving saves a record to this table so you can use that as a template for how to insert.

Inserting a friendly URL can be somewhat challenging in that you need to replace non URL characters and spaces with another character such as a hyphen (-).  I created a SQL function for doing this:

CREATE FUNCTION [dbo].[fn_SEOCharacters]
(
    @String NVARCHAR(MAX)
)
RETURNS NVARCHAR(MAX)
AS
BEGIN

  -- Replace all non alphanumeric characters with a "-"
    WHILE PatIndex('%[^a-zA-Z0-9-]%', @String) > 0
        SET @String = Stuff(@String, PatIndex('%[^a-zA-Z0-9-]%', @String), 1, '-')

  -- Now remove any repeating dashes
  WHILE PatIndex('%--%',@string) > 0
    SET @string = REPLACE(@String, '--', '-')

    RETURN LOWER(@String)

END


GO
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.