Developer forum

Forum » Dynamicweb 10 » Reorder using Express Buy

Reorder using Express Buy

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I am trying to set up the reorder using Express Buy (logic from OrderViewSearchList.cshtml but I am getting some issues.
I have tried addin a product to an order then reorder.
The message I get is "The product "XXX" (XXX), that was a part of this order, seems to have been removed. Contact the shop for further information.".
Obviously, the product is active because I just ordered it.

Looking at the code, it all comes down to this condition:

if (product != null && product?.PrimaryOrDefaultGroup?.Id != null)

The product created from the Orderline does not have a PrimaryOrDefaultGroup, although the product is assigned correctly to a Group from the shop. I have also tried setting the primary group manually on a product, but I got the same error.
It is probably related to how the ProductViewModel is generated based on the Orderline.
How do I solve it? Should I change this logic:

var orderId = Dynamicweb.Context.Current?.Request.QueryString.Get("OrderID") ?? null;

To retrieve an OrderViewModel instead? 

Thank you,
Adrian


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Where do you see this line?

if (product != null && product?.PrimaryOrDefaultGroup?.Id != null)

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,
In the /eCom/ProductCatalog/ExpressBuySearchResponse.cshtml file.
In the meantime, I have converted the Order into OrderViewModel, and the problem was solved.
Apparently, when you create the ProductViewModel with the settings, the PrimaryOrDefaultGroup of the resulting ProductViewModel is null. At least in my case, I am not sure if it's a configuration issue on my end. With the ProductViewModel resulting from the OrderViewModel, PrimaryOrDefaultGroup  is not null.

Adrian

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

When the product viewmodel is instantiated it is using a context to fill out information - in this case the pageview that belongs to the current area provides the correct shop context that is used for that property - so that part is probably missing from this instance causing it to be null.

Good you found a workaround.

BR Nicolai

 

You must be logged in to post in the forum