PROBLEM 1:

When changing sku to adjustment or node, stock do not reflect the change: uc_product_stock has nid as a field and it is reduntant or it is not update with sku changes in no way.

Solution could be to update nid on every change, adding an hook, or to not rely on nid in that table using join with adjustments and/or node, and ultimately remove nid as unusefull.

PROBLEM 2:
Removing a node do not remove stock level, causing error when creating a new node with the same sku (duplicate sku in uc_product_stock). Given the inconsistency at problem 1, the solution would be to delete (before adjustment) all stock with used model.

Another solution is to force synchronization of sku. I am writing this but I need another hook (adjustments_updated). I'll post here the patch

CommentFileSizeAuthor
#1 uc_stock_consistency.patch2.36 KBsmartango

Comments

smartango’s picture

StatusFileSize
new2.36 KB

this is a possible patch

smartango’s picture

I found another problem:

uc_product_adjustments do not force model to be unique.

I could be added unique index to model column in db?

tr’s picture

Status: Active » Closed (duplicate)

You raised several issues, but I believe all of them are being addressed in other threads. Please search the issue queue and participate in those threads. If after reading through the open issues you still have a problem that has not been raised before, then please open a separate new issue for each problem you find.

smartango’s picture

I miss to point references:
http://drupal.org/node/1415590 problem 2
http://drupal.org/node/1398448 problem 1