Images not showing after upgrading to Nopcommerce 4.1

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

I have pictures stored on my database and they are showing when I run nopcommerce 4.0 but as soon as I upgrade to nopcommerce 4.1 they are not showing. I have tried out everything suggested in the forums but its still not working.(NB: I am running the site and the database from my local machine). Please help?
5 years ago
Hi,
Check if the site is a victim of reorganized folder structure.

The thread should help a bit if that's the case.
Best Regards,
Anshul
5 years ago
Hi this problem seems your upgradation is not successfully.

Actually in nopCommerce 4.10, they created separate table for picture binary and remove binaries from Picture table.

So just follow below steps and it will work.

1. Check PictureBinary table is available or not in your upgraded database.
2. if binary table is available then folow below steps. otherwise ignor this step as now and follow to step 3.

  2.1 Execute below script
  IF EXISTS (SELECT *  FROM sys.foreign_keys  WHERE object_id = OBJECT_ID(N'FK_PictureBinary_Picture_PictureId') AND parent_object_id = OBJECT_ID(N'PictureBinary'))
    ALTER TABLE [PictureBinary] DROP CONSTRAINT [FK_PictureBinary_Picture_PictureId]
  GO


  2.2 check total number of record in PictureBinary table.

  
select count(*) from PictureBinary


  2.3 If there few records or not available any record in table, then execute below script
  If you have few records in Picture table then do this.


  
 --copy existing data
    INSERT INTO [dbo].[PictureBinary](PictureId, BinaryData)
    SELECT [Id], [PictureBinary] FROM [dbo].[Picture]

  If you have lots of records in Picture table then execute this SQL script
  This will prevent duplicate record in table.


  
INSERT INTO [dbo].[PictureBinary](PictureId, BinaryData)
    SELECT top 1 [Id], [PictureBinary] FROM [dbo].[Picture] where Id NOT IN (select PictureId from [PictureBinary])
    


  2.4 Once done this chck total number of records in PictureBinary table. (its same as Picture table's total record)

3.  If table PictureBinary is not available then follow below steps.
  3.1  Create table via below script

  
  
CREATE TABLE [dbo].[PictureBinary]
    (
    [Id] int IDENTITY(1,1) NOT NULL,
    [PictureId] int NOT NULL,
    [BinaryData] [varbinary](max) NULL,    
    PRIMARY KEY CLUSTERED
    (
      [Id] ASC
    ) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
  )

  
  3.2  Now follow step 2
  
4.  Once done above steps it means your binaries are copied to PictureBinary table.
Now drop column from Picture TABLE

ALTER TABLE dbo.Picture  DROP COLUMN [PictureBinary]')  


5. Now execute below SQL script

IF EXISTS (SELECT *  FROM sys.foreign_keys  WHERE object_id = OBJECT_ID(N'FK_PictureBinary_Picture_PictureId') AND parent_object_id = OBJECT_ID(N'PictureBinary'))
  ALTER TABLE [PictureBinary] DROP CONSTRAINT [FK_PictureBinary_Picture_PictureId]
GO

ALTER TABLE [dbo].[PictureBinary] WITH CHECK ADD CONSTRAINT [FK_PictureBinary_Picture_PictureId] FOREIGN KEY(PictureId)
REFERENCES [dbo].[Picture] ([Id])
ON DELETE CASCADE
GO


6. It's done

you can get this scripts from upgrade script.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.