Developer forum

Forum » Swift » Stock details from the correct stock location

Stock details from the correct stock location

Anders Thoresen
Anders Thoresen
Reply

I have an issue with getting the correct stock listed on product list and page. Its setup the same way as product prices, where i do get the customer specific price (using customer number as key).

But for stock it seems to just take the first available item from the list of items on product, not checking what stock location the logged in user is connected to.

Product stock:

Logged in user stock location:

 

 

Whats listed on the product page:

 

Front-end is standard swift.

Running DW 9.14.5

How do i proceed to make it list only stock available from the same stock location as the user has set?


Replies

 
Anders Thoresen
Anders Thoresen
Reply

Some additional information, the stock location is added on the order, so the data is available.

 

 
Anders Thoresen
Anders Thoresen
Reply

As a follow-up to this, i managed to get it to list all stock items on the product.

But for some reason user stock location id is allways "0".

Any thoughts of what im doing wrong here? I checked the data in the db and for the logged in user the value should have been "13"

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Anders

It looks right.

The only thing I can see is that the userid your print out in your template, is the AccessUserID from the user table - that is autogenerated. The one you query out in your screen dump, you use ExternalID - so if those 2 fields do not have the same ID it is not the right user you are looking at.

What version is this?

 
Anders Thoresen
Anders Thoresen
Reply

I managed to make it work with some input from Adrian.

This make me able to find the stock of the stock location the user is connected to.

 

 
Anders Thoresen
Anders Thoresen
Reply

DW version 9.15.4

 
Anders Thoresen
Anders Thoresen
Reply

Accessuserid and externalid is the same in this case, it was done like this on the import. So will give the same result.

So its a bit strange that it returned a "0" and not "13".

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

@Nicolai He tried to take the StockLocation ID from the Pageview user. My expectation would be that the value would be correct regardless of how the user is identified. Since the StockLocationId is stored on the User object and does not have anything to do with the integration. Maybe it is worth looking into how the StockLocationID is retrieved in this situation. Maybe Pageview.User is different than User.GetCurrentUser() ? Although the UserID seems to be the same.

Thank you,

Adrian

 

You must be logged in to post in the forum