Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 8 of 8

Thread: Clone a manufacturer

  1. #1
    deanfp is offline Senior Member
    Join Date
    May 2009
    Location
    Sweden
    Posts
    556

    Default Clone a manufacturer

    Is this possible?

  2. #2
    George the Great is offline Senior Member
    Join Date
    Nov 2006
    Location
    Cleveland, OH
    Posts
    1,792

    Default

    Not directly through the admin interface no, but would be very simple to do with a sql statement that could be run through sql management studio or through the Run SQL page in the admin section while logged in as a super admin
    Code:
    INSERT INTO [dbo].[Manufacturer]
               ([ManufacturerGUID]
               ,[Name]
               ,[SEName]
               ,[SEKeywords]
               ,[SEDescription]
               ,[SETitle]
               ,[SENoScript]
               ,[SEAltText]
               ,[Address1]
               ,[Address2]
               ,[Suite]
               ,[City]
               ,[State]
               ,[ZipCode]
               ,[Country]
               ,[Phone]
               ,[FAX]
               ,[URL]
               ,[Email]
               ,[QuantityDiscountID]
               ,[SortByLooks]
               ,[Summary]
               ,[Description]
               ,[Notes]
               ,[RelatedDocuments]
               ,[XmlPackage]
               ,[ColWidth]
               ,[DisplayOrder]
               ,[ExtensionData]
               ,[ContentsBGColor]
               ,[PageBGColor]
               ,[GraphicsColor]
               ,[ImageFilenameOverride]
               ,[Published]
               ,[Wholesale]
               ,[ParentManufacturerID]
               ,[IsImport]
               ,[Deleted]
               ,[CreatedOn]
               ,[PageSize]
               ,[SkinID]
               ,[TemplateName])
         SELECT 
          NEWID()
          ,[Name] + ' (CLONED)'
          ,[SEName] + '-(cloned)'
          ,[SEKeywords]
          ,[SEDescription]
          ,[SETitle]
          ,[SENoScript]
          ,[SEAltText]
          ,[Address1]
          ,[Address2]
          ,[Suite]
          ,[City]
          ,[State]
          ,[ZipCode]
          ,[Country]
          ,[Phone]
          ,[FAX]
          ,[URL]
          ,[Email]
          ,[QuantityDiscountID]
          ,[SortByLooks]
          ,[Summary]
          ,[Description]
          ,[Notes]
          ,[RelatedDocuments]
          ,[XmlPackage]
          ,[ColWidth]
          ,[DisplayOrder]
          ,[ExtensionData]
          ,[ContentsBGColor]
          ,[PageBGColor]
          ,[GraphicsColor]
          ,[ImageFilenameOverride]
          ,[Published]
          ,[Wholesale]
          ,[ParentManufacturerID]
          ,[IsImport]
          ,[Deleted]
          ,[CreatedOn]
          ,[PageSize]
          ,[SkinID]
          ,[TemplateName]
      FROM [dbo].[Manufacturer] 
      WHERE [ManufacturerID]=1
    where 1 is the ID of the Manufacturer that you want to clone. Once you've done that if you also want to clone all of the mappings, get the ManufacturerID of the Manufacturer that was just cloned and use it in the following query
    Code:
    INSERT INTO [dbo].[ProductManufacturer]
               ([ProductID]
               ,[ManufacturerID]
               ,[DisplayOrder]
               ,[CreatedOn])
         SELECT [ProductID]
          ,3
          ,[DisplayOrder]
          ,GETDATE()
      FROM [dbo].[ProductManufacturer]
      WHERE [ManufacturerID] = 1
    where 1 is the ID of the Manufacturer whose mappings you want to clone, and 3 is the ManufacturerID of the Manufacturer that you just cloned.
    <a href="http://www.aspdotnetstorefront.com">Shopping Cart Software</a>

  3. #3
    deanfp is offline Senior Member
    Join Date
    May 2009
    Location
    Sweden
    Posts
    556

    Default

    Hi

    Thanks for the quick reply. This has worked but the manufacturer that I am attempting to clone has sub manufacturers within. The prodcuts have cloned but the sub manufacturers have not.

    Would we have to repeat this for each sub manufacturer and then attach it to the parent root?

  4. #4
    George the Great is offline Senior Member
    Join Date
    Nov 2006
    Location
    Cleveland, OH
    Posts
    1,792

    Default

    How many deep are they nested (eg. do sub-manufacturers have sub-manufacturers that have sub-manufacturers)? That query gets a bit more complex, though if they are only 1 deep it's a lot easier.
    <a href="http://www.aspdotnetstorefront.com">Shopping Cart Software</a>

  5. #5
    deanfp is offline Senior Member
    Join Date
    May 2009
    Location
    Sweden
    Posts
    556

    Default

    Hi

    its just one sub manufacturer level

    http://www.nutricentre.com/m-238-nhas.aspx

  6. #6
    George the Great is offline Senior Member
    Join Date
    Nov 2006
    Location
    Cleveland, OH
    Posts
    1,792

    Default

    Perfect.
    Code:
    INSERT INTO [dbo].[Manufacturer]
               ([ManufacturerGUID]
               ,[Name]
               ,[SEName]
               ,[SEKeywords]
               ,[SEDescription]
               ,[SETitle]
               ,[SENoScript]
               ,[SEAltText]
               ,[Address1]
               ,[Address2]
               ,[Suite]
               ,[City]
               ,[State]
               ,[ZipCode]
               ,[Country]
               ,[Phone]
               ,[FAX]
               ,[url]
               ,[email]
               ,[QuantityDiscountID]
               ,[SortByLooks]
               ,[Summary]
               ,[Description]
               ,[Notes]
               ,[RelatedDocuments]
               ,[XmlPackage]
               ,[ColWidth]
               ,[DisplayOrder]
               ,[ExtensionData]
               ,[ContentsBGColor]
               ,[PageBGColor]
               ,[GraphicsColor]
               ,[ImageFilenameOverride]
               ,[Published]
               ,[Wholesale]
               ,[ParentManufacturerID]
               ,[IsImport]
               ,[Deleted]
               ,[CreatedOn]
               ,[PageSize]
               ,[SkinID]
               ,[TemplateName])
         SELECT 
          NEWID()
          ,[Name] + ' (CLONED)'
          ,[SEName] + '-(cloned)'
          ,[SEKeywords]
          ,[SEDescription]
          ,[SETitle]
          ,[SENoScript]
          ,[SEAltText]
          ,[Address1]
          ,[Address2]
          ,[Suite]
          ,[City]
          ,[State]
          ,[ZipCode]
          ,[Country]
          ,[Phone]
          ,[FAX]
          ,[url]
          ,[email]
          ,[QuantityDiscountID]
          ,[SortByLooks]
          ,[Summary]
          ,[Description]
          ,[Notes]
          ,[RelatedDocuments]
          ,[XmlPackage]
          ,[ColWidth]
          ,[DisplayOrder]
          ,[ExtensionData]
          ,[ContentsBGColor]
          ,[PageBGColor]
          ,[GraphicsColor]
          ,[ImageFilenameOverride]
          ,[Published]
          ,[Wholesale]
          ,3
          ,[IsImport]
          ,[Deleted]
          ,[CreatedOn]
          ,[PageSize]
          ,[SkinID]
          ,[TemplateName]
      FROM [dbo].[Manufacturer] 
      WHERE [ParentManufacturerID]=1
    again with 1 being the ID of the manufacturer that you originally wanted to clone, and 3 being the ID of the cloned parent manufacturer.

    As with any direct sql queries...make sure you have a backup of the database before execution just to be safe.
    <a href="http://www.aspdotnetstorefront.com">Shopping Cart Software</a>

  7. #7
    deanfp is offline Senior Member
    Join Date
    May 2009
    Location
    Sweden
    Posts
    556

    Default

    Hi!

    This worked fine in cloning the sub manufacturers but the products were not copied over. I have tried the second part of the original code but this did not work. How can we copy the products to the newly cloned manufacturer or do we have to map these one by one?

  8. #8
    Jao is offline Senior Member
    Join Date
    Oct 2008
    Posts
    1,132

    Default

    You will need to map those products. Cloning the manufacturer only creates a new manufacturer record based on the manufacturer it was cloned from. The product mapping for manufacturer is based on the ProductManufacturer table; therefore, the only record that gets updated is the Manufacturer but not the ProductManufacturer...