commerce hacker

The out of the box basket.pcf file, specifically the Commerce.QueryCatalogInfo component, is marking my basket line items for deletion. The line item catalog and product id values are present and valid. The documentation indicates all other values are optional. Suggestions on how to troubleshoot



Re: Commerce Server 2007 basket.pcf marking line items for deletion

Max Akbar

RequiredProdInfo is the component that deletes lineitems from the orderform. When an item is not found in the database then it's marked for deletion. You need to enable the pipeline logging and read the _Basket_Errors collection.

Can you repro this on Adventure Works Catalog and CSharpSite

-Max






Re: Commerce Server 2007 basket.pcf marking line items for deletion

chuckmed

This is occuring in a custom site (very simple), based on the CSharpSite.

I have enabled pipeline logging (output below) and am dumping the contents of the _Basket_Errors collection to the web page (output below). It is clear that the line item is getting marked for deletion, I just don't understand why. The item added to the shopping cart is in the catalog so QueryCatalogInfo should be finding it, but I'm guessing that for some reason it is not, and therefore removing it. The challenge is knowing why it can't find it since the "product_catalog" and "product_id" properties are set. Any suggestions greatly appreciated!

Sink started at 2007/05/08 16:13:11.0588
PIPELINE:++ 2007/05/08 16:13:11.0588 Pipeline Execution starts (lMode==0x1, lFlags==0x0)
14 components in the list
PIPELINE:++ component[0x0] about to be called ProgID: Commerce.QueryCatalogInfo
RootObject: ReadValue _Basket_Errors VT_DISPATCH PV=[0x8802868] VT_EMPTY __empty__
RootObject: ReadValue Items VT_DISPATCH PV=[0x8801e68] VT_EMPTY __empty__
RootObject: ReadValue catalog_language VT_NULL __null__ VT_EMPTY __empty__
items: ReadItem 0 VT_DISPATCH PV=[0x87faf68] VT_EMPTY __empty__
: ReadValue product_catalog VT_BSTR Catalog Name Guitar Catalog VT_EMPTY __empty__
: ReadValue product_id VT_BSTR six string electric guitar VT_EMPTY __empty__
: ReadValue product_variant_id VT_NULL __null__ VT_EMPTY __empty__
: ReadValue catalog_language VT_NULL __null__ VT_EMPTY __empty__
items: ReadItem 0 VT_DISPATCH PV=[0x87faf68] VT_EMPTY __empty__
: WriteValue delete VT_EMPTY __empty__ VT_I4 1
PIPELINE:-- component [0x0] returned hr: 0x0, IErrorLevel=1 in 420 milliseconds
PIPELINE:++ component[0x1] about to be called ProgID: Commerce.RequiredProdInfo.1
RootObject: ReadValue items VT_DISPATCH PV=[0x8801e68] VT_EMPTY __empty__
items: ReadItem 0 VT_DISPATCH PV=[0x87faf68] VT_EMPTY __empty__
: ReadValue delete VT_I4 1 VT_EMPTY __empty__
items: DeleteItem 0 VT_DISPATCH PV=[0x87faf68] VT_EMPTY __empty__
RootObject: ReadValue _Basket_Errors VT_DISPATCH PV=[0x8802868] VT_EMPTY __empty__
_Basket_Errors: AddItem 1 VT_EMPTY __empty__ VT_BSTR Please note that one or more items were removed from your order because the product is no longer sold.
PIPELINE:-- component [0x1] returned hr: 0x0, IErrorLevel=2 in 0 milliseconds





Re: Commerce Server 2007 basket.pcf marking line items for deletion

chuckmed

I went back and re-read Max's response and followed his advice for testing.

Now I have reproduced this with the Adventure Works Catalog and the CSharpSite. I exported the catalog from the SampleSite and imported it into the CSharpSite that I have installed/deployed. My code does some very simple catalog browsing and adding products to the shopping cart. The pipeline logging from this activity looks like:

Sink started at 2007/05/10 09:58:48.0997
PIPELINE:++ 2007/05/10 09:58:48.0997 Pipeline Execution starts (lMode==0x1, lFlags==0x0)
15 components in the list
PIPELINE:++ component[0x0] about to be called ProgID: Commerce.QueryCatalogInfo
RootObject: ReadValue _Basket_Errors VT_DISPATCH PV=[0x7b0ec68] VT_EMPTY __empty__
RootObject: ReadValue Items VT_DISPATCH PV=[0x9c20d78] VT_EMPTY __empty__
RootObject: ReadValue catalog_language VT_NULL __null__ VT_EMPTY __empty__
items: ReadItem 0 VT_DISPATCH PV=[0x9c20b28] VT_EMPTY __empty__
: ReadValue product_catalog VT_BSTR Adventure Works Catalog VT_EMPTY __empty__
: ReadValue product_id VT_BSTR AW200-12 VT_EMPTY __empty__
: ReadValue product_variant_id VT_NULL __null__ VT_EMPTY __empty__
: ReadValue catalog_language VT_NULL __null__ VT_EMPTY __empty__
items: ReadItem 0 VT_DISPATCH PV=[0x9c20b28] VT_EMPTY __empty__
: WriteValue delete VT_EMPTY __empty__ VT_I4 1
PIPELINE:-- component [0x0] returned hr: 0x0, IErrorLevel=1 in 30 milliseconds
PIPELINE:++ component[0x1] about to be called ProgID: Commerce.RequiredProdInfo.1
RootObject: ReadValue items VT_DISPATCH PV=[0x9c20d78] VT_EMPTY __empty__
items: ReadItem 0 VT_DISPATCH PV=[0x9c20b28] VT_EMPTY __empty__
: ReadValue delete VT_I4 1 VT_EMPTY __empty__
items: DeleteItem 0 VT_DISPATCH PV=[0x9c20b28] VT_EMPTY __empty__
RootObject: ReadValue _Basket_Errors VT_DISPATCH PV=[0x7b0ec68] VT_EMPTY __empty__
_Basket_Errors: AddItem 1 VT_EMPTY __empty__ VT_BSTR Please note that one or more items were removed from your order because the product is no longer sold.
PIPELINE:-- component [0x1] returned hr: 0x0, IErrorLevel=2 in 0 milliseconds

The code for adding items to the shopping cart looks like:

Basket basket = MyBasket.GetOrCreateBasket(new Guid(CommerceContext.Current.UserID));
OrderForm orderForm = null;
if (basket.OrderForms.IndexOf(OrderForm.DefaultOrderFormName) == -1)
{
orderForm = new OrderForm(OrderForm.DefaultOrderFormName);
basket.OrderForms.Add(orderForm);
}
else
{
orderForm = basket.OrderForms[OrderForm.DefaultOrderFormName];
}

LineItem item = new LineItem(MyCatalog.CatalogName, this.productId, null, 1);
orderForm.LineItems.Add(item);
basket.Save();

The code for the shopping card:

Basket basket = MyBasket.GetOrCreateBasket(new Guid(CommerceContext.Current.UserID));
PipelineInfo pipelineInfo = new PipelineInfo("basket", OrderPipelineType.Basket);
pipelineInfo.Profiles.Add("UserObject", CommerceContext.Current.UserProfile);
PipelineExecutionResult result = basket.RunPipeline(pipelineInfo);

if (result == PipelineExecutionResult.Warning)
{
foreach (OrderForm of in basket.OrderForms)
{
// Some pipeline components record basket errors, so
// display these.

foreach (String basketError in (ISimpleList)of["_Basket_Errors"])
{
Response.Write(basketError + "<br/>");
}

// Some pipeline components record purchase errors, so
// display these.

foreach (String purchaseError in (ISimpleList)of["_Purchase_Errors"])
{
Response.Write(purchaseError + "<br/>");
}
}

Again any suggestions appreciated.






Re: Commerce Server 2007 basket.pcf marking line items for deletion

Sudha Raghavan - MSFT

The item is removed from the pipeline since it is a ProductFamily. You can only add products or variants to basket. A productFamily is not an item that can be checked out. If you change the item to be Aw200-12, 3 which is a variant you would not see this behavior.