an ASP.NET Open Source CMS & eCommerce platform
Search:
Last Post 11/21/2008 5:19:16 AM By Newmedia Design. 7 replies.
11/17/2008 12:10:53 PM
macker999
Posts: 30
Joined: 10/11/2008
Custom Bulk Import
Hi
 
I importing stock from another source on regular basis. I am using the dsc_product_add and dsc_product_update stored procedures for this. I
 
All our categories and manufacturers etc have been added. We are not importing attributes,crosssell,images and downloads. We are only importing the product,category and  descriptors.
The data is enetered correctly but there is one problem. The 

EXEC dbo.DSC_Product_Add_To_Category_Product_Map @productId, @categoriesValues

  part of the stored procedure does not seem to work, the descriptors are entered fine but not the category map information. All our categories are entered are the correct id is being used.
 
If i alter the stored procedure and i disbale the above stored procedure and use this t-sql

insert into DSC_Category_Product_Map(categoryId,productId) values(@categoriesValues,@productId)

Is there something I am not doing properly?

 

Thanks

11/17/2008 3:17:35 PM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: Custom Bulk Import
Did you get any specific error message when dbo.DSC_Product_Add_To_Category_Product_Map doesn't work?
 
If you change the sproc to what you describe above, then adding product to multiple categories won't work anymore. Neither do marking featured product and changing sort order.
DotShoppingCart Staff
11/18/2008 8:48:36 AM
macker999
Posts: 30
Joined: 10/11/2008
Re: Custom Bulk Import
Hi Lulezy
 
Thanks for getting back to me.
 
Yes is didnt work when i used the admin section of the web sire when updating products.
 
It didnt throw up any errors so I am usure of what to do next. Is there anything else that amybe affecting this? I have included my code. This function is used in a loop to add my products.
 
  public static int Update(StockObject stkObj, int productId)
        {
            try
            {
                using (SqlConnection myconn = new SqlConnection(DBHelper.ConnMidia))
                {
                    SqlCommand myCommand = new SqlCommand("DSC_Product_Update", myconn);
                    myCommand.CommandType = CommandType.StoredProcedure;
                    myCommand.Parameters.AddWithValue("@ProductId", productId);
                    myCommand.Parameters.AddWithValue("@ProductName", stkObj.Shortdesc.Trim());
                    myCommand.Parameters.AddWithValue("@SKU", stkObj.Stockcode.Trim());
                    myCommand.Parameters.AddWithValue("@ShortDescription", stkObj.Shortdesc.Trim());
                    myCommand.Parameters.AddWithValue("@Quantity", stkObj.Quantity);
                    myCommand.Parameters.AddWithValue("@Price", (stkObj.Price * 1.10));
                    myCommand.Parameters.AddWithValue("@RetailPrice", Convert.DBNull);
                    myCommand.Parameters.AddWithValue("@salePrice", Convert.DBNull);
                    myCommand.Parameters.AddWithValue("@Cost", stkObj.Price);
                    myCommand.Parameters.AddWithValue("@ManufacturerId", stkObj.Supplier.ToString());
                    myCommand.Parameters.AddWithValue("@ManufacturerSKU", null);
                    myCommand.Parameters.AddWithValue("@StatusId", stkObj.Webenable);
                    myCommand.Parameters.AddWithValue("@productTypeId", 1);
                    myCommand.Parameters.AddWithValue("@ShipTypeId", 1);
                    myCommand.Parameters.AddWithValue("@ShipEstimateId", 1);
                    myCommand.Parameters.AddWithValue("@TaxTypeId", 1);
                    myCommand.Parameters.AddWithValue("@Weight", stkObj.Weight);
                    myCommand.Parameters.AddWithValue("@WeightMeasureId", 4);
                    myCommand.Parameters.AddWithValue("@Length", 0);
                    myCommand.Parameters.AddWithValue("@Height", 0);
                    myCommand.Parameters.AddWithValue("@Width", 0);
                    myCommand.Parameters.AddWithValue("@DimensionMeasureId", 1);
                    myCommand.Parameters.AddWithValue("@SortOrder", 0);
                    myCommand.Parameters.AddWithValue("@timeCreated", null);
                    myCommand.Parameters.AddWithValue("@showIfOutofStock", null);
                    myCommand.Parameters.AddWithValue("@categoriesValues", stkObj.Category);
                    myCommand.Parameters.AddWithValue("@DefaultImageId", null);
                    myCommand.Parameters.AddWithValue("@ImageIds", "");
                    myCommand.Parameters.AddWithValue("@ImageTitles", "");
                    myCommand.Parameters.AddWithValue("@DescriptorTitleValues", stkObj.Shortdesc);
                    myCommand.Parameters.AddWithValue("@DescriptorDescriptionValues", stkObj.Shortdesc);
                    myCommand.Parameters.AddWithValue("@IsBulletedListValues", false);
                    myCommand.Parameters.AddWithValue("@AttributeValues", String.Empty);
                    myCommand.Parameters.AddWithValue("@billingCycleId", 1);
                    myCommand.Parameters.AddWithValue("@recurringCount", 0);
                    myCommand.Parameters.AddWithValue("@crossSellProductIds", String.Empty);
                    myCommand.Parameters.AddWithValue("@binaryIds", String.Empty);
                    myCommand.Parameters.AddWithValue("@Title", null);
                    myCommand.Parameters.AddWithValue("@Keywords", null);
                    myCommand.Parameters.AddWithValue("@ExtraHeadData", null);
                   
                    myconn.Open();
                    myCommand.ExecuteNonQuery();
                    myconn.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return 0;
        }
 
 
11/18/2008 11:34:41 AM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: Custom Bulk Import
Please set the breakpoint in the catch block and send back the exception stack. I will help you diagnose the issue once I have the exception stack.
DotShoppingCart Staff
11/18/2008 2:23:47 PM
macker999
Posts: 30
Joined: 10/11/2008
Re: Custom Bulk Import
Thanks Lukezy
 
My problem is that there are no errors, it doesnt insert into DSC_Category_Product_Map.
 
I have this record in my category table.
 
1157    NULL Apacer Cards    NULL     NULL    0    2    True    57832.
 
I am then manually executing the stored procedure dsc_product_add. Here is my t-sql.
 

exec DSC_Product_Add
'zzzzzzz','zzzzzzz',10,100.00,100.00,100.00,100.00,100.00,410,null,1,1,1,1,1,null,4,null,null,null,1,
0,null,null,'1157',null,'','','','','','',1,0,'','',null,null,null
 
I excuted this statement and the product was inserted into the dsc_product table.
 
60347 zzzzzzz zzzzzzz 10 410 NULL 1 1 1 1 1 100.0000 100.0000 100.0000 100.0000 100.0000 NULL 4 NULL NULL NULL 1 0 NULL 100 18/11/2008 22:19:34 NULL True 0 0 0 1 0 61609
 
 
but there was no entry to the DSC_Category_Product_Map table. If I add a product using the admin section of the database it works fine but not when I try to do this usign the dsc_product_add stored procedure. Is there some step I am missing that the admin web section uses?
11/18/2008 3:17:24 PM
macker999
Posts: 30
Joined: 10/11/2008
Re: Custom Bulk Import
Hi Lukezxy
 
If I execute this
 
EXEC dbo.DSC_Product_Add_To_Category_Product_Map 56861, '1444'
 
with 56861 as my productid and '1444' as my categoryid it still does not insert. The meesage from the executed query returns
 
(1 row(s) affected)
(1 row(s) affected)
 
 
But no record is entered even though the category and product id's exist
11/19/2008 12:24:17 PM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: Custom Bulk Import
If you look closely at the second parameter of the sproc @categoriesValues, it's a complex value. Check the one sample call into DSC_Product_Add below (yellow background).
 
ALTER PROCEDURE [dbo].[DSC_Product_Add_To_Category_Product_Map]
    @productId INT,
      @categoriesValues VARCHAR(MAX)
AS
 
exec DSC_Product_Add @ProductName=N'unknown',@SKU=N'',@ShortDescription=NULL,@Quantity=NULL,@Price=$11.0000,@RetailPrice=NULL,@salePrice=NULL,
@Cost=NULL,@ManufacturerId=11,@ManufacturerSKU=NULL,@StatusId=1,@productTypeId=1,@ShipTypeId=1,@ShipEstimateId=1,@TaxTypeId=1,
@Weight=NULL,@WeightMeasureId=NULL,@Length=NULL,@Height=NULL,@Width=NULL,@DimensionMeasureId=NULL,@SortOrder=0,@timeCreated=NULL,
@showIfOutofStock=NULL,@categoriesValues=N'12;0;0',@DefaultImageId=NULL,@ImageIds='',@ImageTitles=N'',@DescriptorTitleValues=N'',
@DescriptorDescriptionValues=N'',@IsBulletedListValues='',@AttributeValues=N'',@billingCycleId=NULL,@recurringCount=NULL,@crossSellProductIds='',
@binaryIds='',@Title=N'',@Keywords=N'',@ExtraHeadData=N''
 
The first one is the categoryid, the second one is isFeatured (bit or bool) and the third one is sort order (int).
 
Try running this:EXEC dbo.DSC_Product_Add_To_Category_Product_Map 56861, '1444;0;0'
DotShoppingCart Staff
11/21/2008 5:19:16 AM
Newmedia Design
Posts: 65
Joined: 9/25/2008
Re: Custom Bulk Import
Thanks Lukezy
 
I'll try that this evening and let you know how i got on